/* -- design tokens ---------------------------------------------------- */
:root {
  --bg: #0f1419;
  --bg-elev: #161c24;
  --bg-elev-2: #1c2530;
  --border: #2a3441;
  --text: #e6edf3;
  --text-dim: #9aa7b4;
  --text-mute: #6c7a89;
  --accent: #4f9eff;
  --accent-warm: #ffb454;
  --good: #2ea043;
  --hard: #d29922;
  --again: #e5534b;
  --easy: #2f81f7;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f8fa;
    --bg-elev: #ffffff;
    --bg-elev-2: #f0f3f6;
    --border: #d0d7de;
    --text: #1f2328;
    --text-dim: #57606a;
    --text-mute: #848d97;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-size-adjust: 100%;
}

@media (max-width: 480px) {
  html, body {
    font-size: 14px;
  }
}

/* -- topbar ----------------------------------------------------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
  position: sticky;
  top: 0;
  z-index: 50;
  gap: 8px;
  flex-wrap: wrap;
}

.brand {
  background: none;
  border: 0;
  color: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  line-height: 1.1;
  padding: 0;
  min-width: 0;
}
.brand-logo {
  width: 36px;
  height: 36px;
  max-width: 36px;
  max-height: 36px;
  border-radius: 9px;
  flex-shrink: 0;
}
.brand-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
.brand-mark {
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--accent);
  font-size: 16px;
}
.brand-sub {
  font-size: 11px;
  color: var(--text-dim);
}

.topnav {
  display: flex;
  gap: 2px;
  margin-left: auto;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.topnav button {
  background: none;
  border: 0;
  color: var(--text-dim);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font: inherit;
  min-height: 44px;
  display: flex;
  align-items: center;
  touch-action: manipulation;
}
.topnav button:hover { background: var(--bg-elev-2); color: var(--text); }

@media (max-width: 480px) {
  .topbar {
    padding: 10px 12px;
  }

  .brand-mark {
    font-size: 14px;
  }

  .topnav {
    width: 100%;
    order: 3;
    gap: 4px;
  }

  .topnav button {
    padding: 8px 12px;
    font-size: 13px;
    flex: 1;
    text-align: center;
    min-height: 40px;
  }
}

/* -- root layout ----------------------------------------------------- */
.root {
  max-width: 980px;
  margin: 0 auto;
  padding: 20px 16px 100px;
}

h1 { font-size: 24px; margin: 0 0 4px; line-height: 1.2; }
h2 { font-size: 18px; margin: 24px 0 12px; line-height: 1.2; }
h3 { font-size: 15px; margin: 16px 0 6px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; }
p { margin: 6px 0; }

@media (max-width: 768px) {
  .root {
    padding: 16px 12px 100px;
  }

  h1 { font-size: 20px; }
  h2 { font-size: 16px; margin: 18px 0 10px; }
  h3 { font-size: 13px; }
}

@media (max-width: 480px) {
  .root {
    padding: 12px 12px 100px;
  }

  h1 { font-size: 18px; }
  h2 { font-size: 15px; margin: 16px 0 8px; }
}

a, .link {
  color: var(--accent);
  cursor: pointer;
  text-decoration: none;
}
a:hover, .link:hover { text-decoration: underline; }

/* -- home grid ------------------------------------------------------- */
.subtitle {
  color: var(--text-dim);
  margin-bottom: 20px;
}

.sheet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

@media (max-width: 768px) {
  .sheet-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
  }
}

@media (max-width: 480px) {
  .sheet-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
}

.sheet-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  transition: transform 0.08s, border-color 0.08s;
  display: flex;
  flex-direction: column;
  min-height: 160px;
}
.sheet-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.sheet-card:active { transform: translateY(0); }

@media (max-width: 480px) {
  .sheet-card {
    padding: 12px 14px;
    min-height: 140px;
  }
}

.sheet-card .row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sheet-id {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 11px;
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sheet-title {
  font-size: 16px;
  font-weight: 600;
  margin: 2px 0 8px;
  line-height: 1.3;
}

.sheet-meta {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 10px;
}

.mastery-bar {
  position: relative;
  height: 6px;
  background: var(--bg-elev-2);
  border-radius: 999px;
  overflow: hidden;
  margin-top: auto;
}
.mastery-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: linear-gradient(90deg, var(--accent), var(--good));
  border-radius: 999px;
}

.sheet-stats {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 6px;
}

.due-pill {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 600;
}
.due-pill.zero { background: var(--bg-elev-2); color: var(--text-mute); }

/* -- roadmap --------------------------------------------------------- */
.roadmap {
  margin-top: 36px;
  padding: 16px 18px;
  background: var(--bg-elev);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}
.roadmap h2 { margin-top: 0; }
.roadmap ul { padding-left: 20px; color: var(--text-dim); }
.roadmap li { margin: 6px 0; }
.roadmap .tag {
  display: inline-block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg-elev-2);
  color: var(--text-mute);
  margin-right: 6px;
  vertical-align: middle;
}

/* -- sheet detail ---------------------------------------------------- */
.crumbs {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.sheet-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.sheet-header .meta {
  font-size: 13px;
  color: var(--text-dim);
}

.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.tabs button {
  background: none;
  border: 0;
  color: var(--text-dim);
  padding: 12px 16px;
  cursor: pointer;
  font: inherit;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  min-height: 44px;
  display: flex;
  align-items: center;
  white-space: nowrap;
  touch-action: manipulation;
}
.tabs button:hover { color: var(--text); }
.tabs button.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

@media (max-width: 480px) {
  .tabs {
    margin-bottom: 14px;
  }

  .tabs button {
    padding: 10px 12px;
    font-size: 13px;
  }
}

/* -- flashcard ------------------------------------------------------- */
.study-pane { max-width: 680px; margin: 0 auto; padding: 0 4px; }

@media (max-width: 480px) {
  .study-pane {
    padding: 0;
  }
}

.study-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 10px;
}

.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 24px;
  min-height: 260px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

@media (max-width: 768px) {
  .card {
    padding: 24px 20px;
    min-height: 240px;
  }
}

@media (max-width: 480px) {
  .card {
    padding: 20px 16px;
    min-height: 220px;
  }
}

.card-section {
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 14px;
}

.card-parent {
  color: var(--text-dim);
  font-size: 13px;
  margin-bottom: 8px;
}
.card-parent::before { content: "↳ "; color: var(--text-mute); }

.card-prompt {
  font-size: 16px;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.mnemonic-prompt {
  text-align: center;
  background: var(--bg-elev-2);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 18px 14px;
  margin: 6px 0 12px;
}
.mnemonic-prompt .mnemonic-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-mute);
  margin-bottom: 10px;
}
.mnemonic-letters {
  display: flex;
  justify-content: center;
  gap: 14px;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: 0;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

@media (max-width: 480px) {
  .mnemonic-letters {
    font-size: 22px;
    gap: 10px;
  }
}
.mnemonic-letters .mn-letter {
  color: var(--text-mute);
  min-width: 24px;
  text-align: center;
  padding: 2px 4px;
  border-radius: 4px;
}
.mnemonic-letters .mn-letter.active {
  color: var(--accent-warm);
  background: rgba(255, 180, 84, 0.12);
  border: 1px solid var(--accent-warm);
  padding: 1px 6px;
}
.mnemonic-ask {
  font-size: 14px;
  color: var(--text-dim);
}
.mnemonic-ask strong { color: var(--accent-warm); }

.card-answer {
  font-size: 20px;
  font-weight: 500;
  line-height: 1.4;
  margin: 4px 0 12px;
}

.card-points {
  font-size: 12px;
  color: var(--text-mute);
}

.card-mnemonic {
  margin: 12px 0;
  padding: 8px 12px;
  background: var(--bg-elev-2);
  border-left: 3px solid var(--accent-warm);
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.card-mnemonic .label {
  font-weight: 600;
  color: var(--accent-warm);
  margin-right: 6px;
}

.card-examiner {
  margin: 12px 0;
  padding: 8px 12px;
  background: var(--bg-elev-2);
  border-left: 3px solid var(--text-mute);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-dim);
  font-style: italic;
}

.card-note {
  margin: 12px 0;
  padding: 8px 12px;
  background: rgba(79, 158, 255, 0.08);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  font-size: 13px;
  white-space: pre-wrap;
}
.card-note .label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.card-actions {
  margin-top: 18px;
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

@media (max-width: 480px) {
  .card-actions {
    margin-top: 14px;
    gap: 6px;
  }
}

.btn {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font: inherit;
  cursor: pointer;
  font-weight: 500;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
}
.btn:hover { background: var(--bg-elev); border-color: var(--accent); }
.btn:active { transform: scale(0.98); }

.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #3b8aef; }

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn-ghost:hover { background: var(--bg-elev-2); color: var(--text); }

.btn-link {
  background: none;
  border: 0;
  color: var(--accent);
  cursor: pointer;
  padding: 8px 8px;
  font: inherit;
  font-size: 13px;
  min-height: auto;
}
.btn-link:hover { text-decoration: underline; }

@media (max-width: 480px) {
  .btn {
    padding: 12px 16px;
    font-size: 14px;
  }

  .btn-link {
    padding: 6px 6px;
    font-size: 12px;
  }
}

.grade-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 18px;
}

.grade {
  border: 1px solid var(--border);
  background: var(--bg-elev-2);
  color: var(--text);
  padding: 14px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font: inherit;
  font-weight: 500;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-height: 80px;
  justify-content: center;
  touch-action: manipulation;
}
.grade small {
  color: var(--text-mute);
  font-size: 11px;
  font-weight: 400;
}
.grade:hover { background: var(--bg-elev); }
.grade:active { transform: scale(0.96); }
.grade.again:hover { border-color: var(--again); }
.grade.hard:hover  { border-color: var(--hard);  }
.grade.good:hover  { border-color: var(--good);  }
.grade.easy:hover  { border-color: var(--easy);  }

@media (max-width: 480px) {
  .grade-row {
    gap: 6px;
  }

  .grade {
    padding: 12px 6px;
    min-height: 70px;
    font-size: 13px;
  }

  .grade small {
    font-size: 10px;
  }
}

.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--text-dim);
}
.empty-state .big {
  font-size: 40px;
  margin-bottom: 8px;
}

/* -- reference sheet view ------------------------------------------- */
.ref-section {
  margin: 22px 0;
}
.ref-section h3 {
  color: var(--text);
  font-size: 13px;
  background: var(--bg-elev-2);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  letter-spacing: 0.5px;
}

.ref-section-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  list-style: none;
  cursor: pointer;
  user-select: none;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  background: var(--bg-elev-2);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  letter-spacing: 0.5px;
}
.ref-section-summary::-webkit-details-marker { display: none; }
.ref-section-summary::marker { display: none; }
.ref-section-summary:hover { background: var(--bg-elev); }

.ref-section-summary::before {
  content: "▸";
  font-size: 11px;
  color: var(--text-mute);
  transition: transform 0.15s;
  flex-shrink: 0;
}
details[open] > .ref-section-summary::before { transform: rotate(90deg); }

.ref-section-name { flex: 1; }

.ref-section-count {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-mute);
}

.ref-section-summary--critical { color: var(--again); }
.ref-section-summary--critical .ref-section-count { color: var(--again); opacity: 0.7; }

.ref-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.ref-row:hover { background: var(--bg-elev); }
.ref-row .text { flex: 1; min-width: 0; }
.ref-row .points {
  font-family: ui-monospace, SFMono-Regular, monospace;
  color: var(--text-dim);
  font-size: 13px;
  min-width: 36px;
  text-align: right;
  flex-shrink: 0;
}
.ref-row .note-btn {
  font-size: 11px;
  color: var(--text-mute);
  background: none;
  border: 1px dashed var(--border);
  border-radius: 4px;
  cursor: pointer;
  padding: 4px 8px;
  min-height: 32px;
  touch-action: manipulation;
}
.ref-row .note-btn:hover { color: var(--accent); border-color: var(--accent); }
.ref-row .note-btn.has-note { color: var(--accent); border-style: solid; }

@media (max-width: 480px) {
  .ref-row {
    padding: 8px 10px;
    gap: 8px;
  }

  .ref-row .text {
    flex-basis: 100%;
  }

  .ref-row .points,
  .ref-row .note-btn {
    flex-basis: auto;
  }
}

.ref-sub {
  margin-left: 24px;
  color: var(--text-dim);
  font-size: 13px;
}
.ref-sub .ref-row { border: none; padding: 4px 12px; }

.examiner-line {
  background: var(--bg-elev-2);
  padding: 6px 12px;
  font-size: 12px;
  font-style: italic;
  color: var(--text-dim);
  border-radius: var(--radius-sm);
  margin: 6px 0 6px 24px;
}

.critical-list {
  list-style: none;
  padding: 0;
  margin: 8px 0 0;
}
.critical-list li {
  padding: 6px 12px;
  border-left: 3px solid var(--again);
  background: var(--bg-elev);
  margin: 4px 0;
  border-radius: var(--radius-sm);
  font-size: 14px;
}

/* -- notes view ----------------------------------------------------- */
.notes-list { margin-top: 8px; }
.notes-block {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 12px;
}
.notes-block .target {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.notes-block .target strong { color: var(--text); }

.notes-block textarea {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  padding: 10px 12px;
  resize: vertical;
  min-height: 80px;
  font-size: 16px;
}
.notes-block textarea:focus { outline: 0; border-color: var(--accent); }

@media (max-width: 480px) {
  .notes-block textarea {
    min-height: 70px;
    font-size: 16px;
  }
}

.notes-block .row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-mute);
}

/* -- Markdown editor ----------------------------------------------- */
.md-editor {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.md-editor-toolbar {
  display: flex;
  gap: 2px;
  padding: 5px 8px;
  background: var(--bg-elev-2);
  border-bottom: 1px solid var(--border);
}
.md-toolbar-btn {
  background: none;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  cursor: pointer;
  line-height: 1.4;
}
.md-toolbar-btn:hover { background: var(--bg); border-color: var(--border); color: var(--text); }
.md-editor-tabs {
  display: flex;
  background: var(--bg-elev-2);
  border-bottom: 1px solid var(--border);
}
.md-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 5px 14px;
  font-size: 12px;
  color: var(--text-dim);
  cursor: pointer;
}
.md-tab.active { color: var(--text); border-bottom-color: var(--accent); }
.md-editor-textarea {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: none;
  border-radius: 0;
  font: inherit;
  font-size: 14px;
  font-family: 'SFMono-Regular', Consolas, monospace;
  padding: 10px 12px;
  resize: vertical;
  min-height: 100px;
  box-sizing: border-box;
}
.md-editor-textarea:focus { outline: none; }
.md-editor-preview {
  background: var(--bg);
  padding: 10px 12px;
  min-height: 100px;
  font-size: 14px;
}
.md-editor-actions {
  display: flex;
  gap: 8px;
  padding: 8px 0 0;
}

/* -- Markdown content rendering ------------------------------------ */
.md-content { line-height: 1.6; }
.md-content > *:first-child { margin-top: 0; }
.md-content > *:last-child { margin-bottom: 0; }
.md-content p { margin: 0 0 6px; }
.md-content ul, .md-content ol { margin: 2px 0 6px; padding-left: 20px; }
.md-content li { margin: 2px 0; }
.md-content h1, .md-content h2, .md-content h3 {
  margin: 8px 0 4px; font-size: 14px; font-weight: 700; color: var(--text);
}
.md-content code {
  background: var(--bg-elev-2); padding: 1px 5px; border-radius: 3px;
  font-family: 'SFMono-Regular', Consolas, monospace; font-size: 0.88em; color: var(--accent);
}
.md-content pre {
  background: var(--bg-elev-2); padding: 8px 12px; border-radius: var(--radius-sm);
  overflow-x: auto; margin: 4px 0;
}
.md-content pre code { background: none; padding: 0; color: var(--text); }
.md-content blockquote {
  border-left: 3px solid var(--border); margin: 4px 0;
  padding: 2px 12px; color: var(--text-dim);
}
.md-content strong { font-weight: 700; }
.md-content em { font-style: italic; }
.md-content a { color: var(--accent); }
.md-content hr { border: none; border-top: 1px solid var(--border); margin: 6px 0; }

.ref-note-display { margin: 2px 12px 10px; }

/* -- stats ---------------------------------------------------------- */

/* Hero banner */
.stats-hero {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
  overflow: hidden;
}
.hero-block {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 18px 12px;
  text-align: center;
  border-right: 1px solid var(--border);
}
.hero-block:last-child { border-right: none; }
.hero-center {
  flex: 2;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
}
.hero-icon-big { font-size: 26px; margin-bottom: 4px; line-height: 1; }
.hero-num {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text);
}
.hero-num-big { font-size: 36px; }
.hero-label {
  font-size: 11px;
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}
.hero-bar-wrap { width: 100%; max-width: 160px; margin-top: 8px; }
.hero-bar {
  height: 6px;
  background: var(--bg-elev-2);
  border-radius: 999px;
  overflow: hidden;
}
.hero-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--good));
  border-radius: 999px;
  transition: width 0.4s ease;
}

@media (max-width: 480px) {
  .stats-hero { gap: 0; }
  .hero-num { font-size: 20px; }
  .hero-num-big { font-size: 26px; }
  .hero-icon-big { font-size: 20px; }
  .hero-block { padding: 14px 8px; }
}

/* Stat grid */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin: 16px 0;
}

@media (max-width: 768px) {
  .stat-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
}
@media (max-width: 480px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
}

.stat-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.stat-card-warn { border-color: var(--again); }
.stat-card-icon { font-size: 18px; margin-bottom: 4px; line-height: 1; }
.stat-card .num { font-size: 22px; font-weight: 700; }
.stat-card .label { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

/* Achievement section */
.ach-count-badge {
  display: inline-block;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  padding: 1px 8px;
  color: var(--text-dim);
  vertical-align: middle;
}

.ach-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
  margin-bottom: 8px;
}
@media (max-width: 600px) {
  .ach-grid { grid-template-columns: 1fr; }
}

.ach-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  transition: border-color 0.12s;
  position: relative;
}
.ach-locked {
  background: var(--bg-elev);
  opacity: 0.5;
}
.ach-unlocked {
  background: var(--bg-elev);
  border-color: rgba(46, 160, 67, 0.4);
  background: rgba(46, 160, 67, 0.04);
}
.ach-icon {
  font-size: 28px;
  line-height: 1;
  flex-shrink: 0;
  margin-top: 2px;
}
.ach-locked .ach-icon { filter: grayscale(1); }
.ach-body { flex: 1; min-width: 0; }
.ach-name { font-weight: 600; font-size: 14px; margin-bottom: 2px; }
.ach-locked .ach-name { color: var(--text-dim); }
.ach-desc { font-size: 12px; color: var(--text-dim); line-height: 1.4; }
.ach-date { font-size: 11px; color: var(--good); margin-top: 4px; font-weight: 500; }
.ach-check {
  font-size: 16px;
  color: var(--good);
  font-weight: 700;
  flex-shrink: 0;
  align-self: center;
}

/* Sheet progress list */
.sheet-progress-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 24px;
}
.sheet-progress-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  transition: border-color 0.12s;
}
.sheet-progress-card:hover { border-color: var(--accent); }
.spc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.spc-title {
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  padding: 0;
  min-height: auto;
}
.spc-meta { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
.spc-due {
  font-size: 11px;
  font-weight: 600;
  color: var(--again);
  background: rgba(229, 83, 75, 0.1);
  border-radius: 999px;
  padding: 2px 8px;
}
.spc-ok {
  font-size: 11px;
  color: var(--good);
}
.spc-notes {
  font-size: 11px;
  color: var(--text-mute);
}
.spc-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.spc-bar {
  flex: 1;
  height: 8px;
  background: var(--bg-elev-2);
  border-radius: 999px;
  overflow: hidden;
}
.spc-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--good));
  border-radius: 999px;
}
.spc-pct {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  min-width: 36px;
  text-align: right;
}
.spc-drills { display: flex; gap: 5px; flex-wrap: wrap; }

/* Drill status badges */
.drill-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  letter-spacing: 0.2px;
  white-space: nowrap;
}
.drill-none {
  background: var(--bg-elev-2);
  color: var(--text-mute);
}
.drill-good {
  background: rgba(46, 160, 67, 0.15);
  color: var(--good);
}
.drill-mid {
  background: rgba(210, 153, 34, 0.15);
  color: var(--hard);
}
.drill-low {
  background: rgba(229, 83, 75, 0.1);
  color: var(--again);
}

/* Drill mastery overview table */
.drill-mastery-table {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 24px;
}
.drill-mastery-row {
  display: grid;
  grid-template-columns: 180px 1fr 48px;
  align-items: center;
  gap: 12px;
}
@media (max-width: 480px) {
  .drill-mastery-row { grid-template-columns: 140px 1fr 40px; gap: 8px; }
}
.drill-mastery-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-dim);
}
.drill-mastery-icon { font-size: 16px; line-height: 1; }
.drill-mastery-bar-wrap { flex: 1; }
.drill-mastery-bar {
  height: 8px;
  background: var(--bg-elev-2);
  border-radius: 999px;
  overflow: hidden;
}
.drill-bar-fill {
  height: 100%;
  background: var(--text-mute);
  border-radius: 999px;
  transition: width 0.4s ease;
  min-width: 2px;
}
.drill-bar-fill.mid { background: var(--hard); }
.drill-bar-fill.good { background: var(--good); }
.drill-mastery-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  text-align: right;
  white-space: nowrap;
}

/* Achievement toast (bigger, green-tinted) */
.toast-achievement {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  background: #1a3a1a;
  border: 1px solid rgba(46, 160, 67, 0.5);
  color: #c8f0c8;
  animation: toast-in 0.22s ease-out;
  max-width: 320px;
}
@media (prefers-color-scheme: light) {
  .toast-achievement {
    background: #e6f9e6;
    border-color: var(--good);
    color: #1a3a1a;
  }
}
.ach-toast-icon { font-size: 26px; line-height: 1; flex-shrink: 0; }
.ach-toast-desc { font-size: 11px; opacity: 0.8; margin-top: 1px; }

/* -- settings ------------------------------------------------------- */
.settings-section {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 16px;
}
.settings-section h3 {
  margin-top: 0;
  color: var(--text);
}
.settings-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

@media (max-width: 480px) {
  .settings-section {
    padding: 14px 14px;
    margin-bottom: 12px;
  }

  .settings-section h3 {
    font-size: 13px;
  }

  .settings-row {
    gap: 10px;
  }
}

/* -- help icons & modal -------------------------------------------- */
.help-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: none;
  color: var(--text-mute);
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  line-height: 1;
  padding: 0;
  transition: border-color 0.12s, color 0.12s;
  vertical-align: middle;
  font-family: inherit;
}
.help-icon:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.help-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.help-modal {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-width: 460px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
}

.help-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 15px;
}

.help-modal-close {
  background: none;
  border: 0;
  color: var(--text-mute);
  cursor: pointer;
  font-size: 16px;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  line-height: 1;
  font-family: inherit;
}
.help-modal-close:hover { color: var(--text); background: var(--bg-elev-2); }

.help-modal-body {
  padding: 14px 16px 16px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-dim);
}
.help-modal-body p { margin: 0 0 10px; }
.help-modal-body p:last-child { margin-bottom: 0; }
.help-modal-body strong { color: var(--text); font-weight: 600; }
.help-modal-body em { font-style: italic; }
.help-modal-body ul { margin: 4px 0 10px; padding-left: 18px; }
.help-modal-body li { margin: 4px 0; }
.kbd-help {
  display: inline-block;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 11px;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, monospace;
  line-height: 1.4;
}

/* -- guide page ---------------------------------------------------- */
.guide-intro {
  color: var(--text-dim);
  margin-bottom: 24px;
  max-width: 660px;
  line-height: 1.6;
}
.guide-modes {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 8px;
}
.guide-mode {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 0 20px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  align-items: start;
}
.guide-mode:last-child { border-bottom: none; }
.guide-mode:nth-child(even) { background: var(--bg-elev-2); }
.guide-mode-name {
  font-weight: 600;
  color: var(--text);
  font-size: 14px;
  padding-top: 2px;
}
.guide-mode-desc {
  font-size: 14px;
  color: var(--text-dim);
  line-height: 1.55;
}
.guide-mode-desc strong { color: var(--text); font-weight: 600; }
.guide-tip {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-top: 20px;
  font-size: 14px;
  color: var(--text-dim);
  line-height: 1.55;
}
.guide-tip strong { color: var(--text); font-weight: 600; }
.guide-seq {
  color: var(--text-dim);
  line-height: 1.7;
  padding-left: 22px;
  max-width: 580px;
}
.guide-seq li { margin: 4px 0; }
.guide-seq strong { color: var(--text); font-weight: 600; }

@media (max-width: 600px) {
  .guide-mode {
    grid-template-columns: 1fr;
    gap: 3px 0;
    padding: 12px 14px;
  }
  .guide-mode-name {
    font-size: 13px;
    color: var(--accent);
  }
}

.study-meta-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* -- toast --------------------------------------------------------- */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  font-size: 13px;
  font-weight: 500;
  z-index: 100;
  animation: toast-in 0.18s ease-out;
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* -- footer -------------------------------------------------------- */
.footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 8px 12px;
  font-size: 11px;
  color: var(--text-mute);
  background: var(--bg);
  border-top: 1px solid var(--border);
  text-align: right;
  z-index: 49;
}

@media (max-width: 480px) {
  .footer {
    padding: 6px 10px;
    font-size: 10px;
  }
}

/* -- Section Order Drill ------------------------------------------- */
.drill-pane {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 4px;
}

.drill-header {
  margin-bottom: 20px;
}

.drill-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.drill-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.mastered-badge {
  display: inline-block;
  background: var(--good);
  color: #fff;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
}

.drill-sub {
  margin: 4px 0 10px;
}

.drill-hint {
  font-size: 11px;
  margin: 0 0 6px;
}

.streak-row {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  flex-wrap: wrap;
}

.streak-label {
  color: var(--text-mute);
}

.streak-pip {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--bg-elev-2);
  border: 1px solid var(--text-mute);
  flex-shrink: 0;
}

.streak-pip.filled {
  background: var(--good);
  border-color: var(--good);
}

/* ---- draggable list ---- */
.order-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 16px;
  user-select: none;
  -webkit-user-select: none;
}

.order-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  cursor: grab;
  transition: border-color 0.12s, background 0.12s, opacity 0.12s;
  min-height: 52px;
}

.order-item:active {
  cursor: grabbing;
}

.order-item.dragging {
  opacity: 0.35;
  cursor: grabbing;
}

.order-item.drag-over {
  border-color: var(--accent);
  background: var(--bg-elev-2);
}

.order-item.correct {
  border-color: var(--good);
  background: rgba(46, 160, 67, 0.07);
  cursor: default;
}

.order-item.wrong {
  border-color: var(--again);
  background: rgba(229, 83, 75, 0.06);
  cursor: default;
}

.drag-handle {
  color: var(--text-mute);
  font-size: 17px;
  line-height: 1;
  cursor: grab;
  flex-shrink: 0;
  padding-right: 2px;
}

.order-idx {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 11px;
  color: var(--text-mute);
  min-width: 18px;
  flex-shrink: 0;
}

.order-name {
  flex: 1;
  font-weight: 500;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  min-width: 0;
}

.order-arrows {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.arrow-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 4px;
  cursor: pointer;
  font: inherit;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  touch-action: manipulation;
  flex-shrink: 0;
}

.arrow-btn:hover:not([disabled]) {
  background: var(--bg-elev-2);
  color: var(--text);
  border-color: var(--accent);
}

.arrow-btn[disabled] {
  opacity: 0.25;
  cursor: default;
}

.order-check {
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
  margin-left: auto;
}

.order-item.correct .order-check {
  color: var(--good);
}

.order-item.wrong .order-check {
  color: var(--again);
}

/* ---- drill actions / result ---- */
.drill-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.drill-result {
  margin-top: 16px;
  padding: 16px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.result-pass {
  border-color: var(--good);
  background: rgba(46, 160, 67, 0.07);
}

.result-fail {
  border-color: var(--again);
  background: rgba(229, 83, 75, 0.05);
}

.result-icon {
  font-size: 26px;
  margin-bottom: 6px;
}

.drill-result strong {
  font-size: 16px;
}

.drill-result p {
  color: var(--text-dim);
  margin: 4px 0 12px;
}

.hint-details {
  margin-top: 14px;
  font-size: 13px;
}

.hint-details summary {
  cursor: pointer;
  padding: 6px 0;
  color: var(--text-dim);
}

.hint-details summary:hover {
  color: var(--text);
}

.correct-order-list {
  padding-left: 22px;
  color: var(--text-dim);
  margin: 8px 0 0;
}

.correct-order-list li {
  padding: 3px 0;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

/* ---- home screen badges ---- */
.roadmap .tag.shipped {
  background: rgba(46, 160, 67, 0.15);
  color: var(--good);
}

.sec-badge {
  display: inline-block;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 999px;
  font-weight: 600;
}

.sec-badge.mastered {
  background: rgba(46, 160, 67, 0.15);
  color: var(--good);
}

.sec-badge.progress {
  background: rgba(79, 158, 255, 0.12);
  color: var(--accent);
}

@media (max-width: 480px) {
  .drill-pane {
    padding: 0;
  }

  .drill-title {
    font-size: 16px;
  }

  .order-item {
    padding: 10px 12px;
    gap: 8px;
    min-height: 48px;
  }

  .order-name {
    font-size: 12px;
  }

  .arrow-btn {
    width: 38px;
    height: 38px;
    font-size: 16px;
  }

  .drill-result {
    padding: 14px 14px;
  }
}

/* -- Step Sequence Drill – section picker -------------------------- */
.section-picker {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.picker-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  cursor: pointer;
  transition: border-color 0.1s, background 0.1s;
  min-height: 64px;
}

.picker-row:hover {
  border-color: var(--accent);
  background: var(--bg-elev-2);
}

.picker-row.mastered {
  border-color: var(--good);
  background: rgba(46, 160, 67, 0.05);
}

.picker-info {
  flex: 1;
  min-width: 0;
}

.picker-name {
  font-weight: 600;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.picker-meta {
  font-size: 12px;
  margin-top: 2px;
}

.picker-right {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.picker-arrow {
  color: var(--text-mute);
  font-size: 16px;
  flex-shrink: 0;
}

.picker-row:hover .picker-arrow {
  color: var(--accent);
}

/* Step names are sentence-case – override the uppercase section style */
.order-name.step-name {
  text-transform: none;
  letter-spacing: 0;
  font-size: 13px;
  line-height: 1.4;
}

@media (max-width: 480px) {
  .picker-row {
    padding: 10px 12px;
    gap: 10px;
    min-height: 58px;
  }

  .picker-name {
    font-size: 12px;
  }
}

/* -- Critical Fail Mode ------------------------------------------- */

/* Badge shown on card front: "⚠ Auto-fail if missed" */
.crit-badge {
  display: inline-block;
  background: rgba(229, 83, 75, 0.10);
  color: var(--again);
  border: 1px solid rgba(229, 83, 75, 0.28);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  margin: 8px 0 4px;
  letter-spacing: 0.3px;
}

/* Card gets a red left accent to distinguish from regular SRS cards */
.crit-card {
  border-left: 3px solid var(--again);
}

/* Revealed answer is displayed prominently */
.crit-answer {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  padding: 16px 18px;
  background: rgba(229, 83, 75, 0.06);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--again);
  margin: 14px 0;
  line-height: 1.45;
}

/* 3-column grid instead of the default 4-column SRS grade row */
.crit-grade-row {
  grid-template-columns: repeat(3, 1fr);
}

/* -- What's Next? Drill ------------------------------------------- */
.whatnext-prompt {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 18px;
}

.whatnext-prompt-text {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin: 6px 0 10px;
  line-height: 1.4;
}

.whatnext-question {
  font-size: 13px;
  color: var(--text-dim);
  font-style: italic;
}

.whatnext-choices {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.whatnext-choice {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 16px;
  cursor: pointer;
  text-align: left;
  font-size: 14px;
  transition: border-color 0.12s, background 0.12s;
  line-height: 1.4;
}

.whatnext-choice:hover:not([disabled]) {
  border-color: var(--accent);
  background: var(--bg-elev-2);
}

.whatnext-choice[disabled] {
  cursor: default;
  opacity: 0.75;
}

.whatnext-choice.correct {
  border-color: var(--good);
  background: rgba(46, 160, 67, 0.07);
  opacity: 1;
}

.whatnext-choice.wrong {
  border-color: var(--again);
  background: rgba(229, 83, 75, 0.06);
  opacity: 1;
}

.whatnext-choice.dim {
  opacity: 0.55;
  color: var(--text-dim);
}

.choice-letter {
  font-weight: 700;
  font-size: 13px;
  color: var(--text-dim);
  min-width: 20px;
  padding-top: 1px;
  flex-shrink: 0;
}

.whatnext-choice.correct .choice-letter { color: var(--good); }
.whatnext-choice.wrong   .choice-letter { color: var(--again); }

.choice-text {
  flex: 1;
}

/* -- Blank Sheet Recall ------------------------------------------- */
.recall-textarea {
  width: 100%;
  min-height: 280px;
  box-sizing: border-box;
  resize: vertical;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.6;
  padding: 12px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  margin-bottom: 14px;
  display: block;
}

.recall-textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.recall-score {
  font-size: 18px;
  font-weight: 700;
  padding: 6px 0;
}

.score-good  { color: var(--good); }
.score-ok    { color: var(--accent); }
.score-poor  { color: var(--again); }

.recall-results {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 16px 0;
}

.recall-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.4;
}

.recall-match { background: rgba(46, 160, 67, 0.07);  }
.recall-ooo   { background: rgba(99, 179, 237, 0.10); }
.recall-miss  { background: rgba(229, 83, 75, 0.06);  }

.recall-icon {
  font-weight: 700;
  min-width: 16px;
  flex-shrink: 0;
}

.recall-match .recall-icon { color: var(--good); }
.recall-ooo   .recall-icon { color: var(--accent); }
.recall-miss  .recall-icon { color: var(--again); }

.recall-step {
  flex: 1;
  min-width: 0;
}

.recall-typed {
  width: 100%;
  padding-left: 24px;
  font-size: 11px;
  color: var(--text-mute);
  font-style: italic;
}

.small { font-size: 12px; }

/* -- small utilities ---------------------------------------------- */
.muted { color: var(--text-dim); }
.row-wrap { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }
.kbd {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 11px;
  color: var(--text-dim);
}

/* ================================================================
   MNEMONICS TAB
   ================================================================ */
.mnemonics-pane {
  padding-bottom: 40px;
}

.mnemonic-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 14px;
  background: var(--bg-elev-1);
}

.mnemonic-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.mnemonic-card-label {
  font-weight: 600;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-dim);
}

.mnemonic-steps-details {
  margin-bottom: 10px;
}

.mnemonic-steps-toggle {
  font-size: 12px;
  color: var(--text-mute);
  cursor: pointer;
  user-select: none;
}

.mnemonic-steps-list {
  margin: 6px 0 0 18px;
  padding: 0;
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.6;
}

.mnemonic-display-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mnemonic-sentence {
  font-size: 16px;
  font-weight: 500;
  line-height: 1.5;
  color: var(--text);
  padding: 6px 0 2px;
}

.mnemonic-acronym {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--accent);
  padding-bottom: 10px;
  text-transform: uppercase;
}

.mnemonic-breakdown {
  display: flex;
  flex-direction: column;
  gap: 5px;
  border-left: 2px solid var(--border);
  padding-left: 12px;
  margin-bottom: 4px;
}

.mnemonic-row {
  display: grid;
  grid-template-columns: 120px 20px 1fr;
  align-items: baseline;
  gap: 6px;
  font-size: 13px;
  line-height: 1.4;
}

@media (max-width: 480px) {
  .mnemonic-row {
    grid-template-columns: 90px 16px 1fr;
    font-size: 12px;
  }
}

.mnemonic-word {
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mnemonic-letter {
  color: var(--accent);
  font-size: 15px;
}

.mnemonic-arrow {
  color: var(--text-mute);
  text-align: center;
}

.mnemonic-step-label {
  color: var(--text-dim);
}

.mnemonic-display {
  font-size: 16px;
  font-weight: 500;
  line-height: 1.5;
  color: var(--text);
  padding: 6px 0;
}

.mnemonic-empty {
  color: var(--text-mute);
  font-style: italic;
  font-weight: 400;
}

.mnemonic-textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  resize: vertical;
}

.mnemonic-textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.mnemonic-editor-actions {
  display: flex;
  gap: 8px;
}

.btn-sm {
  padding: 4px 12px;
  font-size: 13px;
}

.btn-secondary {
  background: var(--bg-elev-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
}

.btn-secondary:hover {
  background: var(--bg-elev-3, #3a3a3a);
}

/* -- cloud sync -------------------------------------------------------- */
.btn-google {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  color: #3c4043;
  border: 1px solid #dadce0;
  border-radius: 6px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: box-shadow 0.15s;
}
.btn-google:hover { box-shadow: 0 1px 4px rgba(0,0,0,0.2); }
.btn-google:active { background: #f8f8f8; }

.sync-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
}
.sync-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
}
.sync-avatar-placeholder {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}
.sync-user-info { line-height: 1.4; }

.sync-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
}
.sync-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

.btn-danger {
  background: transparent;
  color: var(--again);
  border: 1px solid var(--again);
}
.btn-danger:hover { background: rgba(229, 83, 75, 0.12); }
.btn-danger:active { transform: scale(0.98); }

.confirm-modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 16px;
  flex-wrap: wrap;
}

.conflict-versions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 14px 0;
}
.conflict-card {
  flex: 1;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}
.conflict-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-mute);
  margin-bottom: 4px;
}
.conflict-time {
  font-size: 14px;
  font-weight: 500;
}
.conflict-vs {
  color: var(--text-mute);
  font-size: 12px;
  flex-shrink: 0;
}

/* ===== AI CHAT ===================================================== */

/* Settings: AI config grid */
.ai-config-grid {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 8px 10px;
  align-items: center;
  margin-top: 10px;
}
.ai-config-label { font-size: 13px; color: var(--text-dim); }
.ai-model-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}
.ai-model-row .ai-select { flex: 1; }
.ai-select {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 6px 8px;
  font-size: 13px;
  width: 100%;
}
.ai-key-input {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 6px 8px;
  font-size: 13px;
  width: 100%;
  font-family: monospace;
}

/* Chat list view */
.chat-view { max-width: 760px; }

.chat-no-key {
  text-align: center;
  padding: 48px 24px;
}

.chat-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.chat-list-header h2 { margin: 0; }
.chat-new-btn { flex-shrink: 0; }

.chat-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.chat-list-row {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  cursor: pointer;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: 4px 8px;
  transition: border-color 0.15s;
  position: relative;
}
.chat-list-row:hover { border-color: var(--accent); }
.chat-list-meta {
  display: flex;
  gap: 6px;
  align-items: center;
  grid-column: 1;
}
.chat-list-title {
  font-size: 14px;
  font-weight: 500;
  grid-column: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-list-time {
  font-size: 12px;
  grid-column: 2;
  grid-row: 1 / 3;
  align-self: center;
}
.chat-delete-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: transparent;
  border: none;
  color: var(--text-mute);
  cursor: pointer;
  font-size: 14px;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  line-height: 1;
  display: none;
}
.chat-list-row:hover .chat-delete-btn { display: block; }
@media (hover: none) {
  .chat-delete-btn { display: block; }
}

/* Mode and sheet badges */
.chat-mode-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.chat-mode-chat     { background: #1a3a5c; color: #7bbfff; }
.chat-mode-examiner { background: #3a2020; color: #ffaa7b; }
@media (prefers-color-scheme: light) {
  .chat-mode-chat     { background: #dbeafe; color: #1d4ed8; }
  .chat-mode-examiner { background: #fee2e2; color: #b91c1c; }
}
.chat-sheet-badge {
  font-size: 11px;
  color: var(--text-mute);
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 2px 7px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

/* New chat modal mode buttons */
.new-chat-mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.new-chat-mode-btn {
  background: var(--bg-elev-2);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  text-align: left;
  cursor: pointer;
  color: var(--text);
  transition: border-color 0.15s;
}
.new-chat-mode-btn:hover { border-color: var(--text-dim); }
.new-chat-mode-btn.active { border-color: var(--accent); }

/* Chat detail view */
.chat-detail {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.chat-detail-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}
.chat-back-btn { flex-shrink: 0; }
.chat-detail-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

/* Message thread */
.chat-thread {
  flex: 1;
  overflow-y: auto;
  padding: 16px 0;
  min-height: 240px;
  max-height: calc(100vh - 340px);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.chat-empty-thread {
  padding: 24px;
  text-align: center;
  font-size: 14px;
}
.chat-bubble {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}
.chat-bubble p:first-child { margin-top: 0; }
.chat-bubble p:last-child  { margin-bottom: 0; }
.chat-bubble-user {
  background: var(--accent);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.chat-bubble-assistant {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

/* Input area */
.chat-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 12px 0 6px;
  border-top: 1px solid var(--border);
}
.chat-input {
  flex: 1;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  min-height: 44px;
  max-height: 140px;
  line-height: 1.4;
}
.chat-input:focus { outline: none; border-color: var(--accent); }
.chat-send-btn {
  padding: 10px 18px;
  height: 44px;
  flex-shrink: 0;
  align-self: flex-end;
}
.chat-input-hint {
  font-size: 11px;
  text-align: right;
  padding-bottom: 4px;
}

/* Mobile adjustments */
@media (max-width: 768px) {
  .ai-config-grid {
    grid-template-columns: 80px 1fr;
  }
  .new-chat-mode-grid {
    grid-template-columns: 1fr;
  }
  .chat-bubble { max-width: 92%; }
  .chat-thread {
    max-height: calc(100vh - 380px);
    min-height: 180px;
  }
  .chat-input-hint { display: none; }
}
@media (max-width: 480px) {
  .chat-sheet-badge { max-width: 120px; }
  .chat-thread {
    max-height: calc(100vh - 420px);
  }
}

/* ── EMS Clinical Mnemonics ─────────────────────────────────────── */

.ems-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 16px;
}
.ems-filter-chip {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 13px;
  padding: 5px 14px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.ems-filter-chip:hover { background: var(--bg-elev); color: var(--text); }
.ems-filter-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.ems-quiz-btn {
  margin-bottom: 20px;
}

.ems-mnemonic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 12px;
  margin-bottom: 32px;
}

.ems-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.15s;
}
.ems-card:hover { border-color: var(--accent); }
.ems-card.expanded { border-color: var(--accent); }

.ems-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 16px;
}
.ems-card-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.ems-acronym {
  font-family: monospace;
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 2px;
}
.ems-card-title {
  font-size: 13px;
  color: var(--text-dim);
}
.ems-card-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.ems-category-tag {
  background: var(--bg-elev-2);
  border-radius: var(--radius-sm);
  color: var(--text-mute);
  font-size: 11px;
  padding: 2px 8px;
  white-space: nowrap;
}
.ems-due-badge {
  border-radius: var(--radius-sm);
  color: var(--text-mute);
  font-size: 11px;
  padding: 2px 8px;
  white-space: nowrap;
  background: var(--bg-elev-2);
}
.ems-due-badge.due {
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  color: var(--accent);
}
.ems-expand-icon {
  color: var(--text-mute);
  font-size: 14px;
  transition: transform 0.15s;
}
.ems-card.expanded .ems-expand-icon { transform: rotate(180deg); }

.ems-card-body {
  border-top: 1px solid var(--border);
  padding: 12px 16px 16px;
}
.ems-card-note {
  background: color-mix(in srgb, var(--accent-warm) 10%, transparent);
  border-left: 3px solid var(--accent-warm);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-dim);
  font-size: 13px;
  margin-bottom: 12px;
  padding: 8px 12px;
}

.ems-letter-table {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ems-letter-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.ems-letter-badge {
  background: var(--bg-elev-2);
  border-radius: var(--radius-sm);
  color: var(--accent);
  flex-shrink: 0;
  font-family: monospace;
  font-size: 15px;
  font-weight: 700;
  min-width: 28px;
  padding: 3px 8px;
  text-align: center;
}
.ems-letter-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 3px;
}
.ems-letter-content strong { font-size: 14px; }
.ems-letter-detail { font-size: 12px; line-height: 1.5; }

/* Quiz mode */
.ems-quiz-header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-bottom: 12px;
}
.ems-quiz-counter {
  color: var(--text-mute);
  font-size: 13px;
}
.ems-quiz-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 560px;
  margin: 0 auto;
  padding: 28px 24px 20px;
}
.ems-quiz-acronym {
  font-family: monospace;
  font-size: 36px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 4px;
  text-align: center;
  margin-bottom: 8px;
}
.ems-quiz-category {
  color: var(--text-dim);
  font-size: 14px;
  text-align: center;
  margin-bottom: 4px;
}
.ems-quiz-prompt {
  font-size: 13px;
  text-align: center;
  margin-bottom: 20px;
}
.ems-quiz-back { margin-bottom: 20px; }
.ems-reveal-btn {
  display: block;
  margin: 0 auto 0;
  min-width: 140px;
}
.ems-grade-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 4px;
}

@media (max-width: 600px) {
  .ems-mnemonic-grid { grid-template-columns: 1fr; }
  .ems-card-right { flex-direction: column; align-items: flex-end; gap: 4px; }
  .ems-quiz-acronym { font-size: 28px; }
}

/* ── Medical Conditions ──────────────────────────────────────────────── */
.medcond-wrap {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 4px 40px;
}
.medcond-header { margin-bottom: 16px; }
.medcond-tab-strip {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}
.medcond-tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  padding: 8px 16px;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}
.medcond-tab-btn:hover { color: var(--text); }
.medcond-tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Filter row */
.medcond-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}
.medcond-filter-chip {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 12px;
  padding: 4px 12px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.medcond-filter-chip:hover { color: var(--text); border-color: var(--text-dim); }
.medcond-filter-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
  font-weight: 600;
}

/* Condition cards */
.medcond-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
.medcond-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.15s;
}
.medcond-card:hover { border-color: var(--text-dim); }
.medcond-card.expanded { border-color: var(--accent); }
.medcond-card-header {
  align-items: center;
  cursor: pointer;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 14px 16px;
  user-select: none;
}
.medcond-card-left {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-width: 0;
}
.medcond-name {
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
}
.medcond-key-diff {
  color: var(--text-dim);
  font-size: 12px;
}
.medcond-card-right {
  align-items: center;
  display: flex;
  flex-shrink: 0;
  gap: 8px;
}
.medcond-cat-badge {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-dim);
  font-size: 11px;
  padding: 2px 8px;
}
.medcond-expand-icon {
  color: var(--text-dim);
  font-size: 14px;
  transition: transform 0.2s;
}
.medcond-card.expanded .medcond-expand-icon { transform: rotate(180deg); }

.medcond-card-body {
  border-top: 1px solid var(--border);
  padding: 16px 16px 12px;
}
.medcond-section { margin-bottom: 14px; }
.medcond-section:last-child { margin-bottom: 0; }
.medcond-section-label {
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
  text-transform: uppercase;
}
.medcond-critical .medcond-section-label { color: #e5534b; }
.medcond-treatment .medcond-section-label { color: var(--accent); }
.medcond-list {
  list-style: disc;
  margin: 0;
  padding-left: 20px;
}
.medcond-list li {
  color: var(--text);
  font-size: 13px;
  line-height: 1.55;
  margin-bottom: 3px;
}
.medcond-critical .medcond-list li { color: #f0736b; }
.medcond-onset {
  color: var(--text-dim);
  font-size: 12px;
  margin-top: 10px;
}

/* Compare tab */
.medcond-group-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 20px;
}
.medcond-group-chip {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 12px;
  padding: 5px 12px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.medcond-group-chip:hover { color: var(--text); border-color: var(--text-dim); }
.medcond-group-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
  font-weight: 600;
}
.medcond-compare-wrap { overflow-x: auto; }
.medcond-compare-table {
  display: grid;
  grid-template-columns: 160px repeat(var(--cols, 2), 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  min-width: 520px;
  margin-bottom: 24px;
}
.medcond-th {
  background: var(--bg-raised);
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  padding: 12px 16px;
  text-align: left;
  vertical-align: middle;
}
.medcond-th.medcond-dim-label { color: var(--text-dim); font-size: 12px; font-weight: 600; }
.medcond-td {
  background: var(--bg-elev);
  color: var(--text);
  font-size: 13px;
  padding: 10px 16px;
  text-align: left;
  line-height: 1.55;
  vertical-align: top;
}
.medcond-td.medcond-dim-label {
  background: var(--bg-raised);
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-align: left;
  text-transform: uppercase;
  vertical-align: middle;
}
.medcond-td.medcond-row-stripe { background: color-mix(in srgb, var(--bg-raised) 60%, var(--bg-elev)); }
.medcond-td.medcond-dim-label.medcond-row-stripe { background: color-mix(in srgb, var(--border) 30%, var(--bg-raised)); }
.medcond-td.medcond-key-row {
  background: color-mix(in srgb, var(--accent) 12%, var(--bg-elev));
  color: var(--accent);
  font-weight: 700;
  font-size: 13px;
}

/* Quiz tab */
.medcond-quiz-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 600px;
  margin: 0 auto 12px;
}
.medcond-quiz-counter {
  color: var(--text-dim);
  font-size: 13px;
}
.medcond-quiz-srs-info {
  display: flex;
  gap: 6px;
}
.medcond-srs-count {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  letter-spacing: 0.02em;
}
.medcond-srs-count-due { background: color-mix(in srgb, #d29922 20%, var(--bg-raised)); color: #d29922; }
.medcond-srs-count-new { background: color-mix(in srgb, var(--accent) 20%, var(--bg-raised)); color: var(--accent); }
.medcond-quiz-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 600px;
  margin: 0 auto;
  padding: 0 20px 20px;
}
.medcond-quiz-card-header {
  min-height: 36px;
  display: flex;
  align-items: center;
  padding: 8px 0 4px;
}
.medcond-srs-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.medcond-srs-new { background: color-mix(in srgb, var(--accent) 18%, var(--bg-raised)); color: var(--accent); }
.medcond-srs-due { background: color-mix(in srgb, #d29922 18%, var(--bg-raised)); color: #d29922; }
.medcond-quiz-label {
  font-size: 12px;
  margin-bottom: 6px;
  text-align: center;
}
.medcond-quiz-clue {
  color: var(--text);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.5;
  margin-bottom: 8px;
  text-align: center;
}
.medcond-quiz-hint {
  font-size: 12px;
  text-align: center;
  margin-bottom: 18px;
}
.medcond-quiz-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}
.medcond-option {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  padding: 10px 8px;
  text-align: center;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: normal;
  word-break: break-word;
}
.medcond-option:hover:not(:disabled) {
  background: var(--bg-elev);
  border-color: var(--accent);
  color: var(--accent);
}
.medcond-option.correct {
  background: color-mix(in srgb, #3fb950 20%, var(--bg-raised));
  border-color: #3fb950;
  color: #3fb950;
  font-weight: 600;
}
.medcond-option.wrong {
  background: color-mix(in srgb, #e5534b 20%, var(--bg-raised));
  border-color: #e5534b;
  color: #e5534b;
}
.medcond-quiz-feedback {
  background: var(--bg-raised);
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 14px;
  padding: 10px 14px;
}
.medcond-feedback-correct { color: #3fb950; font-weight: 600; margin-bottom: 4px; }
.medcond-feedback-wrong { color: #e5534b; font-weight: 600; margin-bottom: 4px; }
.medcond-feedback-schedule { color: var(--text-dim); font-size: 12px; margin-bottom: 4px; }
.medcond-feedback-detail { color: var(--text-dim); font-size: 12px; line-height: 1.5; }
.medcond-quiz-next { display: block; margin: 0 auto; min-width: 120px; }

/* Results screen */
.medcond-results {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 32px 20px 20px;
  text-align: center;
}
.medcond-results-icon { font-size: 48px; }
.medcond-results-score {
  font-size: 52px;
  font-weight: 700;
  line-height: 1;
}
.medcond-grade-great { color: var(--accent); }
.medcond-grade-good  { color: #d29922; }
.medcond-grade-low   { color: var(--text-dim); }
.medcond-results-grade { font-size: 18px; font-weight: 600; color: var(--text); }
.medcond-results-detail { color: var(--text-dim); font-size: 14px; }
.medcond-results .btn { min-width: 200px; }

/* Stats page CTA */
.medcond-stats-cta {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 20px 0;
  padding: 20px;
  text-align: center;
}
.medcond-stats-cta p { color: var(--text-dim); font-size: 14px; margin-bottom: 12px; }

@media (max-width: 600px) {
  .medcond-tab-strip { overflow-x: auto; }
  .medcond-quiz-options { grid-template-columns: 1fr; }
  .medcond-compare-table { grid-template-columns: 110px repeat(var(--cols, 2), 1fr); }
  .medcond-card-right { flex-direction: column; align-items: flex-end; gap: 4px; }
}
