/* ============================================================
   ZettelCards — styles
   Design tokens + component styles ported from the original
   single-file React artifact.
   ============================================================ */

:root {
  --paper: #fbfaf7;
  --panel: #ffffff;
  --ink: #1f1d1a;
  --sub: #56524c;
  --faint: #9a948c;
  --line: #e6e2da;
  --line-soft: #efece5;
  --accent: #3f6d8c;
  --accent-dark: #325873;
  --accent-soft: #eef3f6;
  --danger: #b4413c;
  --success: #4f7a52;
  --success-soft: #eef4ee;
  --warn: #c08a2e;
  --warn-soft: #f7efdd;
  --flame: #d9742b;
  --flame-soft: #fbeede;

  --serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;
  --ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--ui);
  -webkit-font-smoothing: antialiased;
}

/* ---------- app shell ---------- */
.app { min-height: 100vh; background: var(--paper); color: var(--ink); font-family: var(--ui); }

.loading {
  min-height: 100vh; display: grid; place-items: center;
  color: var(--faint); font-family: var(--ui); font-size: 14px; letter-spacing: .08em;
}

.header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 28px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: rgba(251, 250, 247, .86);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; background: none; border: none; cursor: pointer; padding: 0; }
.brand-mark { width: 32px; height: 32px; border-radius: 9px; background: var(--ink); color: var(--paper); display: grid; place-items: center; }
.brand-text { font-size: 18px; font-weight: 600; letter-spacing: -.01em; color: var(--ink); }
.brand-text .accent { color: var(--accent); }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav-btn {
  display: flex; align-items: center; gap: 7px; padding: 8px 13px;
  background: none; border: none; color: var(--sub); font-size: 14px; font-weight: 500;
  cursor: pointer; border-radius: 8px; font-family: inherit;
}
.nav-btn.active { color: var(--ink); background: var(--line-soft); }
.nav-btn:hover { color: var(--ink); }

.main { max-width: 980px; margin: 0 auto; padding: 36px 24px 80px; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 26px; flex-wrap: wrap; }
.h1 { font-family: var(--serif); font-size: 34px; font-weight: 600; margin: 0; letter-spacing: -.02em; line-height: 1.05; }
.lede { color: var(--sub); font-size: 15px; margin: 8px 0 0; max-width: 520px; line-height: 1.5; }

/* ---------- buttons ---------- */
.primary {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px;
  background: var(--accent); color: #fff; border: none; border-radius: 9px;
  font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap; font-family: inherit;
}
.primary:hover { background: var(--accent-dark); }
.ghost {
  display: inline-flex; align-items: center; gap: 7px; padding: 10px 15px;
  background: transparent; color: var(--sub); border: 1px solid var(--line);
  border-radius: 9px; font-size: 14px; font-weight: 500; cursor: pointer; white-space: nowrap; font-family: inherit;
}
.ghost:hover { background: var(--line-soft); }
.ghost-danger {
  display: inline-flex; align-items: center; gap: 7px; padding: 10px 15px;
  background: transparent; color: var(--danger); border: 1px solid var(--line);
  border-radius: 9px; font-size: 14px; font-weight: 500; cursor: pointer; white-space: nowrap; font-family: inherit;
}
.ghost-danger:hover { background: var(--line-soft); }
.icon-btn { background: none; border: none; color: var(--sub); cursor: pointer; padding: 6px; border-radius: 8px; display: grid; place-items: center; }
.icon-btn:hover { background: var(--line-soft); }
.back {
  display: inline-flex; align-items: center; gap: 4px; background: none; border: none;
  color: var(--sub); font-size: 14px; font-weight: 500; cursor: pointer; padding: 0; margin-bottom: 18px; font-family: inherit;
}
.back:hover { color: var(--ink); }

/* ---------- composer / inputs ---------- */
.composer {
  display: flex; gap: 12px; flex-wrap: wrap; align-items: center;
  padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); margin-bottom: 24px;
}
.input-lg {
  flex: 1 1 220px; padding: 11px 14px; border: 1px solid var(--line); border-radius: 9px;
  font-size: 16px; font-weight: 500; background: var(--paper); color: var(--ink); font-family: inherit;
}
.input {
  flex: 1 1 200px; padding: 11px 14px; border: 1px solid var(--line); border-radius: 9px;
  font-size: 14px; background: var(--paper); color: var(--ink); width: 100%; font-family: inherit;
}

/* ---------- deck grid ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(248px, 1fr)); gap: 16px; }
.deck {
  text-align: left; padding: 20px; border: 1px solid var(--line); border-radius: 14px;
  background: var(--panel); cursor: pointer; display: flex; flex-direction: column; gap: 10px; font-family: inherit;
}
.deck-top { display: flex; align-items: center; justify-content: space-between; }
.deck-icon { width: 30px; height: 30px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; }
.due-badge { font-size: 12px; font-weight: 600; color: var(--accent); background: var(--accent-soft); padding: 3px 9px; border-radius: 20px; }
.deck-name { font-family: var(--serif); font-size: 21px; font-weight: 600; margin: 0; color: var(--ink); }
.deck-desc { font-size: 13.5px; color: var(--sub); margin: 0; line-height: 1.45; }
.deck-meta { display: flex; gap: 16px; margin-top: 4px; padding-top: 12px; border-top: 1px solid var(--line-soft); }
.meta-item { display: flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--faint); font-weight: 500; }

/* generic hover-lift tile */
.card-tile { transition: all .16s ease; }
.card-tile:hover { border-color: var(--faint); transform: translateY(-1px); }

/* ---------- toolbar / search ---------- */
.toolbar { display: flex; gap: 12px; align-items: center; margin-bottom: 20px; flex-wrap: wrap; }
.search-wrap {
  flex: 1 1 240px; display: flex; align-items: center; gap: 9px; padding: 10px 14px;
  border: 1px solid var(--line); border-radius: 9px; background: var(--panel);
}
.search-input { flex: 1; border: none; background: none; font-size: 14px; color: var(--ink); outline: none; font-family: inherit; }

/* ---------- card rows ---------- */
.card-list { display: flex; flex-direction: column; gap: 10px; }
.row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  text-align: left; padding: 16px 18px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--panel); cursor: pointer; width: 100%; font-family: inherit;
}
.row-main { min-width: 0; flex: 1; }
.row-front { font-family: var(--serif); font-size: 16.5px; font-weight: 600; color: var(--ink); margin-bottom: 3px; }
.row-back { font-size: 13.5px; color: var(--sub); line-height: 1.4; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; }
.row-side { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.row-stat { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--faint); font-weight: 500; white-space: nowrap; }
.stat-dot { width: 7px; height: 7px; border-radius: 50%; }
.grade-tick { font-size: 11px; font-weight: 600; }
.tag-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.tag { font-size: 11.5px; color: var(--sub); background: var(--line-soft); padding: 2px 9px; border-radius: 20px; font-weight: 500; }

/* ---------- editor modal ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(31, 29, 26, .32); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: 20px; z-index: 60;
}
.modal {
  width: min(560px, 100%); max-height: 90vh; overflow-y: auto; background: var(--panel);
  border: 1px solid var(--line); border-radius: 18px; padding: 26px;
  box-shadow: 0 30px 80px -30px rgba(31, 29, 26, .5);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.modal-title { font-family: var(--serif); font-size: 22px; font-weight: 600; margin: 0; }
.field { margin-bottom: 16px; }
.label { display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--sub); margin-bottom: 7px; letter-spacing: .01em; }
.textarea-front {
  width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 16.5px; font-family: var(--serif); font-weight: 600; color: var(--ink); background: var(--paper); resize: vertical; line-height: 1.4;
}
.textarea {
  width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 14.5px; color: var(--ink); background: var(--paper); resize: vertical; line-height: 1.5; font-family: inherit;
}
.link-chips { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 10px; }
.link-chip {
  display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; color: var(--accent);
  background: var(--accent-soft); padding: 4px 6px 4px 11px; border-radius: 20px; font-weight: 500;
}
.chip-x { background: none; border: none; color: var(--accent); cursor: pointer; padding: 2px; display: grid; place-items: center; border-radius: 50%; }
.link-results { margin-top: 8px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.link-result {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  padding: 10px 13px; background: var(--panel); border: none; border-bottom: 1px solid var(--line-soft);
  font-size: 13.5px; color: var(--ink); cursor: pointer; font-family: inherit; transition: all .16s ease;
}
.link-result:last-child { border-bottom: none; }
.link-result:hover { background: var(--accent-soft); }
.modal-foot { display: flex; align-items: center; gap: 10px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line-soft); }

/* ---------- study ---------- */
.study-top { display: flex; align-items: center; gap: 16px; margin-bottom: 32px; }
.progress-track { flex: 1; height: 4px; background: var(--line); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 4px; transition: width .3s ease; }
.counter { font-size: 12.5px; color: var(--faint); font-weight: 600; white-space: nowrap; }
.stage { display: grid; place-items: center; margin-bottom: 28px; }
.flashcard {
  width: min(620px, 100%); min-height: 280px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 20px; padding: 40px 38px; cursor: pointer; position: relative;
  box-shadow: 0 10px 36px -26px rgba(31, 29, 26, .4); display: flex; flex-direction: column; justify-content: center;
  transition: all .16s ease;
}
.flashcard:hover { box-shadow: 0 14px 40px -22px rgba(31, 29, 26, .4); }
.face { display: flex; flex-direction: column; gap: 14px; }
.face-tag { font-size: 11px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--faint); }
.face-front { font-family: var(--serif); font-size: 27px; font-weight: 600; line-height: 1.25; margin: 0; color: var(--ink); }
.face-back { font-size: 18px; line-height: 1.55; margin: 0; color: var(--ink); }
.flip { position: absolute; bottom: 18px; left: 0; right: 0; text-align: center; font-size: 12px; color: var(--faint); }
.linked-box { margin-top: 8px; padding: 12px 14px; background: var(--accent-soft); border-radius: 11px; display: flex; flex-direction: column; gap: 6px; }
.linked-head { display: flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 600; color: var(--accent); letter-spacing: .02em; }
.linked-item { font-size: 13.5px; color: var(--sub); }

.reveal-bar { display: grid; place-items: center; }
.reveal-btn {
  display: inline-flex; align-items: center; gap: 9px; padding: 14px 28px;
  background: var(--ink); color: var(--paper); border: none; border-radius: 12px;
  font-size: 15px; font-weight: 600; cursor: pointer; font-family: inherit; transition: all .16s ease;
}
.grades { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.grade {
  position: relative; display: flex; flex-direction: column; gap: 4px; align-items: flex-start;
  padding: 16px 16px 14px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 13px; cursor: pointer; text-align: left; font-family: inherit; transition: all .16s ease;
}
.grade:hover { border-color: var(--ga); background: #fff; transform: translateY(-2px); }
.grade-dot { width: 9px; height: 9px; border-radius: 50%; margin-bottom: 4px; }
.grade-label { font-size: 15px; font-weight: 600; color: var(--ink); }
.grade-hint { font-size: 12.5px; color: var(--faint); }
.grade-next { font-size: 12px; color: var(--sub); font-weight: 600; margin-top: 6px; }
.grade-key {
  position: absolute; top: 12px; right: 13px; width: 19px; height: 19px; border-radius: 5px;
  background: var(--line-soft); color: var(--faint); font-size: 11px; font-weight: 700;
  display: grid; place-items: center;
}

.done-card {
  max-width: 460px; margin: 60px auto; text-align: center; padding: 40px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.done-mark { width: 56px; height: 56px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; margin-bottom: 12px; }

/* ---------- graph ---------- */
.legend { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 16px; }
.legend-item { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--sub); font-weight: 500; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; }
.graph-wrap {
  position: relative; border: 1px solid var(--line); border-radius: 16px; background: var(--panel);
  overflow: hidden; min-height: 420px;
}
.graph-node { cursor: pointer; }
.graph-panel {
  position: absolute; top: 16px; right: 16px; width: min(300px, calc(100% - 32px));
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px;
  box-shadow: 0 20px 50px -28px rgba(31, 29, 26, .5);
}
.panel-front { font-family: var(--serif); font-size: 18px; font-weight: 600; margin: 4px 0 8px; line-height: 1.3; }
.panel-back { font-size: 14px; color: var(--sub); line-height: 1.5; margin: 0; }

/* ---------- empty ---------- */
.empty {
  display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center;
  padding: 56px 24px; border: 1px dashed var(--line); border-radius: 16px; background: var(--panel);
}
.empty-icon { width: 48px; height: 48px; border-radius: 12px; background: var(--line-soft); color: var(--faint); display: grid; place-items: center; margin-bottom: 6px; }
.empty-title { font-family: var(--serif); font-size: 19px; font-weight: 600; margin: 0; color: var(--ink); }
.empty-body { font-size: 14px; color: var(--sub); margin: 0; max-width: 320px; line-height: 1.5; }

/* ---------- exam setup ---------- */
.exam-form { display: flex; flex-direction: column; gap: 26px; max-width: 600px; }
.type-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.type-opt {
  position: relative; text-align: left; display: flex; flex-direction: column; gap: 4px;
  padding: 16px 16px 15px; border: 1px solid var(--line); border-radius: 13px; background: var(--panel);
  cursor: pointer; font-family: inherit; transition: all .16s ease;
}
.type-opt:hover { border-color: var(--faint); }
.type-opt.on { border-color: var(--accent); background: var(--accent-soft); }
.type-check {
  position: absolute; top: 13px; right: 13px; width: 18px; height: 18px; border-radius: 5px;
  border: 1.5px solid var(--line); background: var(--panel); display: grid; place-items: center; color: #fff;
}
.type-check.on { background: var(--accent); border-color: var(--accent); }
.type-icon { margin-bottom: 2px; color: var(--faint); }
.type-opt.on .type-icon { color: var(--accent); }
.type-name { font-size: 14.5px; font-weight: 600; color: var(--ink); }
.type-desc { font-size: 12.5px; color: var(--sub); line-height: 1.4; }
.range { width: 100%; accent-color: var(--accent); cursor: pointer; margin-top: 4px; }
.range-ends { display: flex; justify-content: space-between; font-size: 12px; color: var(--faint); margin-top: 4px; }

/* ---------- exam runner ---------- */
.exam-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 30px 30px 26px;
  box-shadow: 0 10px 36px -28px rgba(31, 29, 26, .4);
}
.exam-prompt { font-family: var(--serif); font-size: 23px; font-weight: 600; line-height: 1.3; margin: 12px 0 22px; color: var(--ink); }
.options { display: flex; flex-direction: column; gap: 10px; }
.option {
  display: flex; align-items: center; gap: 13px; text-align: left; width: 100%;
  padding: 14px 16px; border: 1px solid var(--line); border-radius: 11px; background: var(--panel);
  cursor: pointer; font-size: 15px; color: var(--ink); font-family: inherit; transition: all .16s ease;
}
.option:not(:disabled):hover { border-color: var(--accent); background: var(--accent-soft); }
.option-correct { border-color: var(--success); background: #f1f6f1; }
.option-wrong { border-color: var(--danger); background: #faf0ef; }
.opt-mark {
  flex-shrink: 0; width: 24px; height: 24px; border-radius: 7px; background: var(--line-soft); color: var(--sub);
  font-size: 13px; font-weight: 700; display: grid; place-items: center;
}
.opt-text { flex: 1; line-height: 1.4; }
.tf-statement {
  padding: 18px 20px; background: var(--paper); border: 1px solid var(--line); border-radius: 12px;
  font-size: 16.5px; line-height: 1.5; color: var(--ink); margin-bottom: 16px; font-family: var(--serif);
}
.tf-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tf-btn {
  display: flex; align-items: center; justify-content: center; gap: 9px; padding: 16px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--panel); cursor: pointer;
  font-size: 15.5px; font-weight: 600; color: var(--ink); font-family: inherit; transition: all .16s ease;
}
.tf-btn:not(:disabled):hover { border-color: var(--accent); background: var(--accent-soft); }
.tf-correct { margin-top: 16px; padding: 14px 16px; background: #f1f6f1; border-radius: 11px; border: 1px solid var(--success); }
.next-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line-soft); }
.verdict { display: flex; align-items: center; gap: 7px; font-size: 14.5px; font-weight: 600; }

/* ---------- open feedback ---------- */
.open-fb { margin-top: 18px; display: flex; flex-direction: column; gap: 16px; }
.open-model { padding: 14px 16px; background: var(--accent-soft); border-radius: 11px; }
.kw-block { display: flex; flex-direction: column; gap: 8px; }
.kw-label { font-size: 12.5px; font-weight: 600; color: var(--sub); }
.kw-bar { height: 6px; background: var(--line); border-radius: 6px; overflow: hidden; }
.kw-fill { height: 100%; border-radius: 6px; transition: width .4s ease; }
.kw-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.kw-tag { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; padding: 3px 9px; border-radius: 20px; font-weight: 500; }
.kw-hit { background: #eef4ee; color: var(--success); }
.kw-miss { background: var(--line-soft); color: var(--faint); text-decoration: line-through; }
.override-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-top: 4px; }
.override-hint { font-size: 12.5px; color: var(--faint); }

/* ---------- result ---------- */
.result-hero { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 20px 0 36px; }
.result-ring {
  width: 96px; height: 96px; border-radius: 50%; border: 3px solid; display: grid; place-items: center;
  font-size: 26px; font-weight: 700; margin-bottom: 12px; font-family: var(--ui);
}
.review-list { display: flex; flex-direction: column; gap: 10px; }
.review-item { display: flex; gap: 14px; padding: 16px 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.review-icon { flex-shrink: 0; margin-top: 1px; }
.review-top { display: flex; align-items: center; gap: 9px; margin-bottom: 5px; }
.review-num { font-size: 12px; font-weight: 700; color: var(--faint); }
.review-type { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); }
.review-prompt { font-family: var(--serif); font-size: 16px; font-weight: 600; margin: 0; color: var(--ink); line-height: 1.35; }
.review-answer { font-size: 13.5px; color: var(--sub); margin: 7px 0 0; line-height: 1.45; }

/* ---------- gamification: header chip ---------- */
.streak-chip {
  display: flex; align-items: center; gap: 7px; padding: 7px 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 20px;
  cursor: pointer; margin-right: 4px; font-family: inherit; transition: all .16s ease;
}
.streak-chip:hover { border-color: var(--flame); }
.streak-num { font-size: 14px; font-weight: 700; }
.streak-divider { width: 1px; height: 14px; background: var(--line); }
.streak-goal { font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; min-width: 18px; justify-content: center; }

/* ---------- progress page ---------- */
.stat-band { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card {
  padding: 18px 18px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel);
  display: flex; flex-direction: column; gap: 2px;
}
.stat-icon { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; margin-bottom: 10px; }
.stat-value { font-family: var(--serif); font-size: 26px; font-weight: 700; color: var(--ink); line-height: 1; }
.stat-label { font-size: 13px; color: var(--sub); font-weight: 500; margin-top: 4px; }
.stat-sub { font-size: 12px; color: var(--faint); }

.goal-panel {
  display: flex; gap: 22px; align-items: center; padding: 22px;
  border: 1px solid var(--line); border-radius: 16px; background: var(--panel); margin-bottom: 30px; flex-wrap: wrap;
}
.goal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.goal-title { font-family: var(--serif); font-size: 20px; font-weight: 600; margin: 0; }
.goal-done-tag { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; color: var(--success); background: var(--success-soft); padding: 3px 9px; border-radius: 20px; }
.goal-text { font-size: 14px; color: var(--sub); margin: 0 0 14px; line-height: 1.5; }
.goal-set-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.goal-set-label { font-size: 12.5px; color: var(--faint); font-weight: 600; margin-right: 2px; }
.goal-opt {
  min-width: 38px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 9px;
  background: var(--paper); color: var(--sub); font-size: 13.5px; font-weight: 600; cursor: pointer; font-family: inherit; transition: all .16s ease;
}
.goal-opt:hover { border-color: var(--accent); }
.goal-opt.on { background: var(--accent); color: #fff; border-color: var(--accent); }

.section-title { font-family: var(--serif); font-size: 22px; font-weight: 600; margin: 0 0 16px; }
.ach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.ach-card {
  display: flex; gap: 13px; align-items: center; padding: 15px 16px;
  border: 1px solid var(--line); border-radius: 13px; background: var(--panel); opacity: .7;
}
.ach-card.on { opacity: 1; border-color: var(--line-soft); box-shadow: 0 6px 20px -16px rgba(31, 29, 26, .5); }
.ach-icon { width: 40px; height: 40px; border-radius: 10px; background: var(--line-soft); color: var(--faint); display: grid; place-items: center; flex-shrink: 0; }
.ach-icon.on { background: var(--warn-soft); color: var(--warn); }
.ach-name { font-size: 14.5px; font-weight: 600; margin-bottom: 2px; color: var(--faint); }
.ach-name.on { color: var(--ink); }
.ach-desc { font-size: 12.5px; color: var(--faint); line-height: 1.4; }

.center-cta { display: grid; place-items: center; margin-top: 32px; }

/* ---------- toasts ---------- */
.toast-stack {
  position: fixed; right: 20px; bottom: 20px; z-index: 90;
  display: flex; flex-direction: column; gap: 10px; max-width: calc(100vw - 40px);
}
.toast {
  display: flex; gap: 12px; align-items: center; width: 300px; max-width: 100%;
  padding: 13px 15px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 13px; box-shadow: 0 18px 44px -20px rgba(31, 29, 26, .45);
  animation: toastIn .34s cubic-bezier(.2, .9, .3, 1.2);
}
.toast-icon { width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; flex-shrink: 0; }
.toast-title { font-size: 14px; font-weight: 700; color: var(--ink); line-height: 1.2; }
.toast-body { font-size: 13px; color: var(--sub); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(14px) scale(.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- focus / misc ---------- */
button:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
input::placeholder, textarea::placeholder { color: var(--faint); }
textarea, input { font-family: inherit; }
::selection { background: var(--accent-soft); }

@media (prefers-reduced-motion: reduce) {
  .toast { animation: none; }
  * { transition: none !important; }
}

/* ============================================================
   Bloque A — recuerdo activo (A1), cloze (A2), free recall (A3)
   ============================================================ */

/* A1 — toggle de recuerdo escrito en la barra de estudio */
.type-toggle {
  display: inline-flex; align-items: center; gap: 5px; padding: 6px 11px;
  border: 1px solid var(--line); border-radius: 20px; background: var(--panel);
  color: var(--faint); font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap;
  font-family: inherit; transition: all .16s ease;
}
.type-toggle:hover { border-color: var(--accent); }
.type-toggle.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* A1 — zona para escribir la respuesta antes de revelar */
.recall-area { display: grid; place-items: stretch; max-width: 620px; margin: 0 auto; }
.recall-input { font-size: 15px; }

/* A1 — feedback tras el intento escrito */
.recall-fb {
  max-width: 620px; margin: 0 auto 22px; display: flex; flex-direction: column; gap: 14px;
  padding: 18px 20px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel);
}
.recall-mine { display: flex; flex-direction: column; gap: 6px; }
.recall-mine-text {
  margin: 0; font-size: 14.5px; line-height: 1.5; color: var(--ink);
  padding: 10px 12px; background: var(--paper); border: 1px solid var(--line-soft); border-radius: 10px; white-space: pre-wrap;
}
.recall-hint { margin: 0; font-size: 12.5px; color: var(--faint); }

/* A2 — cloze */
.cloze-text { font-family: var(--serif); font-size: 24px; font-weight: 600; line-height: 1.4; margin: 0; color: var(--ink); }
.cloze-context { font-size: 13.5px; color: var(--sub); margin: 0 0 2px; }
.cloze-blank {
  display: inline-block; min-width: 44px; padding: 0 8px; margin: 0 1px; border-radius: 6px;
  background: var(--accent-soft); color: var(--accent); border-bottom: 2px solid var(--accent);
  font-weight: 700; letter-spacing: .04em; vertical-align: baseline;
}
.cloze-fill {
  border-radius: 5px; padding: 0 4px; margin: 0 1px;
  background: var(--warn-soft); color: #8a6410; font-weight: 700;
  box-shadow: inset 0 -2px 0 rgba(192, 138, 46, .45);
}
.cloze-tag { color: var(--accent); }

/* editor — pista de huecos */
.field-hint { font-size: 12px; color: var(--accent); margin-top: 6px; font-weight: 500; min-height: 15px; }

/* A3 — vaciar memoria */
.recall-dump-wrap { display: flex; flex-direction: column; max-width: 720px; }
.recall-dump { font-size: 15px; line-height: 1.55; min-height: 220px; }
.recall-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 10px; }
.recall-col { border: 1px solid var(--line); border-radius: 14px; background: var(--panel); padding: 16px 18px; }
.recall-col-title { display: flex; align-items: center; gap: 7px; font-family: var(--serif); font-size: 16px; font-weight: 600; margin: 0 0 12px; color: var(--ink); }
.recall-col-empty { font-size: 13px; color: var(--faint); margin: 0; }
.recall-item { display: flex; align-items: flex-start; gap: 9px; padding: 8px 0; border-top: 1px solid var(--line-soft); }
.recall-item:first-of-type { border-top: none; }
.recall-dot { width: 7px; height: 7px; border-radius: 50%; margin-top: 7px; flex-shrink: 0; }
.recall-item-text { font-size: 13.5px; color: var(--sub); line-height: 1.45; }

@media (max-width: 560px) {
  .recall-cols { grid-template-columns: 1fr; }
}

/* ============================================================
   Bloque B — programación (FSRS B4, interleaving B5, circadiano B6, carga B7)
   ============================================================ */

/* B5/B6 — modos de estudio en la página de mazos */
.study-modes { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 22px; }
.study-modes-hint { font-size: 12.5px; color: var(--faint); }

/* B5 — chip de mazo actual en sesión mixta */
.deck-chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 5px 10px; border-radius: 20px;
  background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 600; white-space: nowrap;
}

/* B4/B6/B7 — paneles de datos */
.srs-panel, .data-panel {
  padding: 20px 22px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); margin-bottom: 20px;
}

/* barras genéricas (pronóstico + heatmap horario) */
.bars { display: flex; align-items: flex-end; gap: 8px; margin-top: 14px; }
.bars-24 { gap: 3px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; min-width: 0; }
.bar-count { font-size: 12px; font-weight: 700; color: var(--sub); }
.bar-track { width: 100%; height: 92px; display: flex; align-items: flex-end; background: var(--paper); border-radius: 6px; overflow: hidden; }
.bar-track-sm { height: 60px; border-radius: 4px; }
.bar-fill { width: 100%; border-radius: 6px 6px 0 0; min-height: 2px; transition: height .4s ease; }
.bar-label { font-size: 10.5px; color: var(--faint); font-weight: 600; height: 13px; }

/* ============================================================
   Bloque C — elaboración (C8), conexión (C9), predicción (C10)
   ============================================================ */

/* C8 — panel de elaboración */
.elab-card {
  max-width: 620px; margin: 0 auto; background: var(--panel); border: 1px solid var(--line);
  border-radius: 20px; padding: 28px 30px; display: flex; flex-direction: column; gap: 14px;
  box-shadow: 0 10px 36px -26px rgba(31, 29, 26, .4);
}
.elab-reminder { padding: 14px 16px; background: var(--paper); border: 1px solid var(--line-soft); border-radius: 12px; }
.elab-front { font-family: var(--serif); font-size: 17px; font-weight: 600; margin: 0 0 4px; color: var(--ink); }
.elab-back { font-size: 14px; color: var(--sub); margin: 0; line-height: 1.5; }
.elab-prompt { font-family: var(--serif); font-size: 20px; font-weight: 600; margin: 4px 0 0; color: var(--ink); }
.elab-links { display: flex; flex-direction: column; gap: 8px; }
.elab-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }
.elab-list { display: flex; flex-direction: column; gap: 8px; }
.elab-note {
  margin: 0; font-size: 13.5px; line-height: 1.5; color: var(--sub);
  padding: 10px 12px; background: var(--accent-soft); border-radius: 10px; white-space: pre-wrap;
}

/* C9 — par de notas en la pregunta de conexión */
.conn-pair { display: flex; align-items: stretch; gap: 12px; margin-bottom: 4px; }
.conn-note {
  flex: 1; padding: 16px 18px; background: var(--paper); border: 1px solid var(--line); border-radius: 12px;
  font-family: var(--serif); font-size: 16px; font-weight: 600; color: var(--ink); line-height: 1.35;
  display: flex; align-items: center;
}
.conn-link { display: flex; align-items: center; flex-shrink: 0; }

/* C10 — scoreboard de predicción */
.predict-stats { display: flex; align-items: baseline; gap: 12px; margin: 2px 0 8px; }
.predict-found { font-family: var(--serif); font-size: 24px; font-weight: 700; color: var(--success); }
.predict-wrong { font-size: 13px; font-weight: 600; color: var(--faint); }
.predict-last { font-size: 13px; line-height: 1.45; margin: 0; color: var(--sub); }
.predict-hit { color: var(--success); font-weight: 600; }
.predict-miss { color: var(--danger); font-weight: 600; }
.predict-dup { color: var(--warn); font-weight: 600; }

/* Ajustes de estudio (toggles C8/A1) */
.pref-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-top: 1px solid var(--line-soft); }
.pref-row:first-of-type { border-top: none; }
.pref-name { font-size: 14px; font-weight: 600; color: var(--ink); }
.pref-desc { font-size: 12.5px; color: var(--faint); margin-top: 2px; }

/* ============================================================
   Bloque D — metacognición (calibración D11, hipercorrección D12, datos D13)
   ============================================================ */

/* D11 — prompt de confianza (antes de revelar) */
.conf-prompt { display: flex; flex-direction: column; gap: 12px; }
.conf-q { text-align: center; font-size: 14.5px; font-weight: 600; color: var(--sub); margin: 0; }
.conf-btns { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.conf-btn {
  position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
  padding: 14px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 13px;
  cursor: pointer; font-family: inherit; transition: all .16s ease;
}
.conf-btn:hover { border-color: var(--cc); transform: translateY(-2px); }
.conf-dot { width: 9px; height: 9px; border-radius: 50%; }
.conf-label { font-size: 14.5px; font-weight: 600; color: var(--ink); }
.conf-verdict {
  display: flex; align-items: center; gap: 8px; max-width: 620px; margin: 0 auto 16px;
  padding: 10px 14px; background: var(--paper); border: 1px solid var(--line-soft); border-radius: 10px;
  font-size: 13px; color: var(--sub);
}

/* D12 — banner de hipercorrección */
.hyper-banner {
  display: flex; align-items: center; gap: 9px; max-width: 620px; margin: 0 auto 16px;
  padding: 11px 15px; background: #faf0ef; border: 1px solid var(--danger); border-radius: 12px;
  font-size: 13.5px; font-weight: 500; color: var(--danger);
}
.hyper-mode { color: var(--danger); border-color: var(--danger); }

/* D11 — panel de calibración */
.cal-rows { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.cal-row { display: grid; grid-template-columns: 96px 1fr 44px; align-items: center; gap: 10px; }
.cal-label { font-size: 13px; font-weight: 600; }
.cal-track { position: relative; height: 16px; background: var(--paper); border: 1px solid var(--line-soft); border-radius: 8px; overflow: visible; }
.cal-fill { height: 100%; border-radius: 8px; }
.cal-expected { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--faint); border-radius: 2px; }
.cal-val { font-size: 12.5px; font-weight: 700; color: var(--sub); text-align: right; }

/* D13 — estado de memoria */
.mem-bar { display: flex; height: 16px; border-radius: 8px; overflow: hidden; margin-top: 14px; background: var(--paper); }
.mem-seg { min-width: 3px; }
.mem-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; }
.mem-legend-item { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--sub); font-weight: 500; }
.mem-curve { margin-top: 16px; padding: 12px; background: var(--paper); border-radius: 12px; }

/* D13 — leeches */
.leech-title { display: flex; align-items: center; gap: 6px; font-family: var(--serif); font-size: 15px; font-weight: 600; margin: 20px 0 0; color: var(--ink); }
.leech-box { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.leech-item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line-soft); }
.leech-item:first-child { border-top: none; }
.leech-front { flex: 1; min-width: 0; font-size: 13.5px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leech-count { font-size: 12px; font-weight: 700; color: var(--danger); white-space: nowrap; }

/* ============================================================
   Bloque E — dual coding / oclusión (E14), linter (E15)
   ============================================================ */

/* E15 — linter de atomicidad (editor) */
.lint-box:empty { display: none; }
.lint-inner { margin-top: 8px; padding: 10px 12px; background: var(--warn-soft); border: 1px solid #e8d3a3; border-radius: 10px; }
.lint-head { display: flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700; color: #8a6410; letter-spacing: .01em; }
.lint-list { margin: 6px 0 0; padding-left: 18px; }
.lint-list li { font-size: 12.5px; color: var(--sub); line-height: 1.5; }

/* E14 — imagen + oclusión (editor) */
.occ-edit { position: relative; display: inline-block; max-width: 100%; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); line-height: 0; }
.occ-img { display: block; max-width: 100%; height: auto; user-select: none; }
.occ-overlay { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.occ-meta { font-size: 12px; color: var(--faint); margin-top: 8px; }
.occ-actions { display: flex; gap: 8px; margin-top: 10px; }

/* E14 — imagen + oclusión (estudio) */
.occ-wrap { position: relative; display: block; width: 100%; max-width: 460px; margin: 0 auto; border-radius: 12px; overflow: hidden; line-height: 0; }
.occ-img { display: block; width: 100%; height: auto; }
.occ-masks { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

/* ============================================================
   Auth (login / bootstrap) — Cloudflare backend
   ============================================================ */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--paper); }
.auth-card {
  width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  padding: 32px 30px; box-shadow: 0 30px 80px -40px rgba(31, 29, 26, .5);
  display: flex; flex-direction: column; gap: 12px;
}
.auth-mark { width: 44px; height: 44px; border-radius: 12px; margin: 0 auto 4px; }
.auth-title { font-family: var(--serif); font-size: 26px; font-weight: 600; text-align: center; margin: 0; }
.auth-sub { text-align: center; color: var(--sub); font-size: 14px; margin: 0 0 8px; line-height: 1.5; }
.auth-err { color: var(--danger); font-size: 13px; min-height: 16px; text-align: center; }
