/* JungleCards — one stylesheet, one set of tokens.
   Type: Nunito throughout (400 body, 600 labels/buttons, 700–800 headings).
   Scale: 13 / 14 / 16 / 18 / 22 / 28 / 36 px. Spacing: 4-px steps.
   The jungle photo sits behind a dark overlay; every surface is a translucent
   forest green so the background stays visible but never fights the text. */

:root {
  --font: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Consolas, monospace;

  --text: #eefaf2;
  --text-muted: #b2d3bf;
  --text-faint: #86a994;
  --accent: #2ecc71;
  --accent-strong: #5ff09a;
  --accent-ink: #03140a;
  --accent-soft: rgba(46, 204, 113, 0.14);
  --gold: #f4c94a;
  --gold-soft: rgba(244, 201, 74, 0.12);
  --danger: #ff8f80;
  --danger-line: rgba(255, 143, 128, 0.55);

  --shell: rgba(4, 24, 13, 0.9);
  --panel: rgba(0, 0, 0, 0.32);
  --field: rgba(0, 12, 6, 0.75);
  --line: rgba(46, 204, 113, 0.22);
  --line-strong: rgba(46, 204, 113, 0.5);

  --fs-xs: 0.8125rem;
  --fs-sm: 0.875rem;
  --fs-md: 1rem;
  --fs-lg: 1.125rem;
  --fs-xl: 1.375rem;
  --fs-2xl: 1.75rem;
  --fs-3xl: 2.25rem;

  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px;
  --s5: 20px; --s6: 24px; --s8: 32px;

  --r-sm: 8px;
  --r: 12px;
  --r-lg: 18px;
  --control-h: 42px;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.55);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs-md);
  line-height: 1.55;
  color: var(--text);
  background: #02130a;
}
h1, h2, h3 { margin: 0; line-height: 1.2; font-weight: 800; letter-spacing: -0.01em; }
h2 { font-size: var(--fs-2xl); }
h3 { font-size: var(--fs-lg); }
p { margin: 0; }
a { color: var(--accent-strong); }
a:hover { color: #9dffc4; }
code, kbd { font-family: var(--mono); font-size: 0.85em; }
code { padding: 1px 5px; border-radius: 5px; background: rgba(255, 255, 255, 0.08); }
kbd {
  display: inline-block; padding: 0 6px; border-radius: 5px; line-height: 1.5;
  border: 1px solid rgba(255, 255, 255, 0.3); background: rgba(255, 255, 255, 0.07); font-weight: 600;
}
img { max-width: 100%; }
[hidden], .hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: -999px; top: var(--s2); z-index: 20;
  padding: var(--s2) var(--s4); border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-weight: 700;
}
.skip-link:focus { left: var(--s2); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
h2[tabindex="-1"]:focus, main:focus { outline: none; }

/* ---------- Layout ---------- */
.jungle-bg {
  min-height: 100vh;
  padding: var(--s6);
  background:
    linear-gradient(135deg, rgba(0, 0, 0, 0.75), rgba(0, 0, 0, 0.85)),
    url("jungle-bg.jpg") center / cover no-repeat fixed;
}
.app-shell {
  max-width: 1040px;
  min-height: calc(100vh - 2 * var(--s6));
  margin: 0 auto;
  padding: var(--s6) var(--s8);
  display: flex;
  flex-direction: column;
  gap: var(--s5);
  background: var(--shell);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
}
main { flex: 1; }
.screen { display: none; animation: fade-in 160ms ease-out; }
.screen.active { display: block; }
@keyframes fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.narrow { max-width: 680px; margin: 0 auto; }
.stack { display: flex; flex-direction: column; gap: var(--s4); }
.stack-sm { display: flex; flex-direction: column; gap: var(--s2); }
.stack-lg { display: flex; flex-direction: column; gap: var(--s5); }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3); }
.row--center { justify-content: center; }
.row--fields { align-items: flex-start; }
.row--fields > .field { flex: 1 1 180px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s5); align-items: start; }
.grid-2--wide-left { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
.grid-builder { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: var(--s5); align-items: start; }

/* ---------- Navigation ---------- */
.top-nav {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s4);
  padding-bottom: var(--s4); border-bottom: 1px solid var(--line);
}
.top-nav--hidden { display: none; }
.brand { display: inline-flex; align-items: center; gap: var(--s3); text-decoration: none; color: var(--text); }
.brand__logo { width: 36px; height: 36px; border-radius: 10px; filter: drop-shadow(0 0 8px rgba(46, 204, 113, 0.45)); }
.brand__name { font-size: var(--fs-lg); font-weight: 800; letter-spacing: 0.02em; color: var(--accent-strong); }
.nav-links { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--s1); }
.nav-link {
  display: inline-flex; align-items: center; gap: var(--s2);
  height: 38px; padding: 0 var(--s3); border: 0; border-radius: 999px; cursor: pointer;
  background: transparent; color: var(--text-muted); font: 600 var(--fs-sm) var(--font);
  transition: background 120ms, color 120ms;
}
.nav-link:hover { background: var(--accent-soft); color: var(--text); }
.nav-link[aria-current="page"] { background: var(--accent-soft); color: var(--accent-strong); box-shadow: inset 0 0 0 1px var(--line-strong); }
.nav-link--quiet { color: var(--text-faint); }
.count-badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--gold); color: #2a1d00; font-size: 0.72rem; font-weight: 800;
}

/* ---------- Screen headers ---------- */
.screen-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s4); flex-wrap: wrap;
  margin-bottom: var(--s5);
}
.lede { margin-top: var(--s1); color: var(--text-muted); font-size: var(--fs-md); max-width: 62ch; }

/* ---------- Surfaces ---------- */
.panel {
  padding: var(--s5);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}
.panel__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s3); }
.panel__title { font-size: var(--fs-md); font-weight: 800; color: var(--text); margin-bottom: var(--s3); }
.panel__head .panel__title, .stack > .panel__title, .stack-sm > .panel__title { margin-bottom: 0; }
.subpanel { margin-top: var(--s4); padding-top: var(--s4); border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: var(--s3); }
.subpanel__title { font-size: var(--fs-md); }
.banner {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap;
  padding: var(--s3) var(--s4); border-radius: var(--r);
  background: var(--gold-soft); border: 1px solid rgba(244, 201, 74, 0.45); color: #ffe7a8; font-size: var(--fs-sm);
}
.banner--ok { background: var(--accent-soft); border-color: var(--line-strong); color: #c9ffdc; }
.notice {
  padding: var(--s3) var(--s4); border-radius: var(--r); font-size: var(--fs-sm); color: #ffe2b8;
  background: rgba(244, 201, 74, 0.08); border: 1px solid rgba(244, 201, 74, 0.35);
}

/* ---------- Hero (sign-in) ---------- */
.hero { text-align: center; margin: var(--s4) 0 var(--s8); }
.hero__logo { width: 88px; height: 88px; filter: drop-shadow(0 0 18px rgba(46, 204, 113, 0.55)); }
.hero__title {
  margin-top: var(--s3); font-size: var(--fs-3xl); font-weight: 800; letter-spacing: 0.03em;
  color: var(--accent-strong); text-shadow: 0 0 18px rgba(46, 204, 113, 0.45);
}
.hero__tagline { margin-top: var(--s2); color: var(--text-muted); font-size: var(--fs-lg); }
.auth-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s5); max-width: 820px; margin: 0 auto; align-items: start; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; font-size: var(--fs-sm); font-weight: 600; color: var(--text-muted); }
.field-label { font-size: var(--fs-sm); font-weight: 600; color: var(--text-muted); }
.field-optional { font-weight: 400; color: var(--text-faint); }
.field--inline { flex-direction: row; align-items: center; gap: var(--s2); }
input, select, textarea {
  width: 100%; margin: 0;
  font: 400 var(--fs-md) var(--font); color: var(--text);
  background-color: var(--field); border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  transition: border-color 120ms, box-shadow 120ms;
}
input, select { height: var(--control-h); padding: 0 var(--s3); }
textarea { padding: var(--s3); line-height: 1.5; resize: vertical; min-height: 96px; }
input[type="file"] { height: auto; padding: var(--s2); font-size: var(--fs-sm); }
input[type="file"]::file-selector-button {
  margin-right: var(--s3); padding: 6px 14px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--accent-soft); color: var(--text); font: 600 var(--fs-sm) var(--font);
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }
input:hover, select:hover, textarea:hover { border-color: var(--accent); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent-strong); box-shadow: 0 0 0 3px rgba(46, 204, 113, 0.22); }
input:disabled, select:disabled { opacity: 0.5; cursor: not-allowed; }
input[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--danger-line); }
select {
  appearance: none; padding-right: 36px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%), linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 55%, calc(100% - 13px) 55%;
  background-size: 5px 5px; background-repeat: no-repeat;
}
select option { background: #04170c; color: var(--text); }
.field--inline select { width: auto; }
.choice-group { margin: 0; padding: 0; border: 0; display: flex; flex-direction: column; gap: var(--s2); }
.choice-group legend { margin-bottom: var(--s1); padding: 0; }
.choice { display: flex; align-items: center; gap: var(--s3); font-size: var(--fs-md); font-weight: 400; color: var(--text); cursor: pointer; }
.choice input { width: 18px; height: 18px; flex: none; accent-color: var(--accent); }
.hint { font-size: var(--fs-xs); font-weight: 400; color: var(--text-faint); }
.hint--error { color: var(--danger); }
.hint--error:empty { display: none; }
.link-btn {
  align-self: center; padding: var(--s1) 0; border: 0; background: none; cursor: pointer;
  color: var(--accent-strong); font: 600 var(--fs-sm) var(--font); text-decoration: underline; text-underline-offset: 3px;
}
.message { font-size: var(--fs-sm); color: var(--text-muted); }
.message:empty { display: none; }
.message.error { color: var(--danger); }
.message.ok { color: var(--accent-strong); }
.message--center { text-align: center; margin-top: var(--s4); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  height: var(--control-h); padding: 0 var(--s5); border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line-strong); background: rgba(0, 0, 0, 0.35); color: var(--text);
  font: 700 var(--fs-sm) var(--font); letter-spacing: 0.01em; white-space: nowrap; text-decoration: none;
  transition: transform 90ms, background 120ms, border-color 120ms, box-shadow 120ms;
}
.btn:hover { background: var(--accent-soft); border-color: var(--accent); }
.btn:active { transform: scale(0.98); }
.btn.primary { background: linear-gradient(135deg, #27ae60, #2ecc71); border-color: transparent; color: var(--accent-ink); }
.btn.primary:hover { background: linear-gradient(135deg, #2ecc71, #5ff09a); box-shadow: 0 0 16px rgba(46, 204, 113, 0.45); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn.ghost:hover { background: var(--accent-soft); color: var(--text); }
.btn-danger { border-color: var(--danger-line); color: #ffd0c8; }
.btn-danger:hover { background: rgba(255, 143, 128, 0.12); border-color: var(--danger); }
.btn-small { height: 32px; padding: 0 var(--s3); font-size: var(--fs-xs); }
.btn-lg { height: 52px; font-size: var(--fs-md); }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }

/* ---------- Pills, badges, tags ---------- */
.pill {
  display: inline-flex; align-items: center; gap: var(--s1); padding: 2px 10px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: rgba(0, 0, 0, 0.3); font-size: var(--fs-xs); font-weight: 600; color: var(--text-muted);
}
.badge { display: inline-flex; align-items: center; padding: 1px 8px; border-radius: 999px; font-size: 0.72rem; font-weight: 700; border: 1px solid; }
.badge--pending { color: var(--gold); border-color: rgba(244, 201, 74, 0.55); }
.badge--ai { color: #c3b6ff; border-color: rgba(195, 182, 255, 0.55); }
.badge--rejected { color: var(--danger); border-color: var(--danger-line); }
.badge--archived { color: var(--text-faint); border-color: rgba(255, 255, 255, 0.25); }
.badge--accepted { color: var(--accent-strong); border-color: var(--line-strong); }
.tag { font-size: var(--fs-xs); color: var(--text-faint); }

/* ---------- Tabs & toolbars ---------- */
.tabs {
  display: flex; flex-wrap: wrap; gap: var(--s1); padding: var(--s1); margin-bottom: var(--s5);
  border-radius: 999px; background: rgba(0, 0, 0, 0.3); border: 1px solid var(--line); width: fit-content; max-width: 100%;
}
.tab {
  display: inline-flex; align-items: center; gap: var(--s2); height: 36px; padding: 0 var(--s4); border: 0; border-radius: 999px; cursor: pointer;
  background: transparent; color: var(--text-muted); font: 600 var(--fs-sm) var(--font);
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { background: var(--accent-soft); color: var(--accent-strong); box-shadow: inset 0 0 0 1px var(--line-strong); }
.tab-panel { display: flex; flex-direction: column; gap: var(--s4); }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s4); }
.toolbar__actions { display: flex; gap: var(--s2); margin-left: auto; }
.sticky-actions {
  position: sticky; bottom: 0; z-index: 2; display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2);
  margin-top: var(--s4); padding: var(--s3) var(--s4); border-radius: var(--r);
  background: rgba(3, 20, 11, 0.96); border: 1px solid var(--line-strong);
}
.sticky-actions .message { flex-basis: 100%; }

/* ---------- Filters & lists ---------- */
.filters { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr) auto; gap: var(--s3); align-items: end; margin-bottom: var(--s4); }
.list-head { display: flex; align-items: baseline; gap: var(--s4); margin-bottom: var(--s3); }
.list-head__count { font-size: var(--fs-sm); font-weight: 700; color: var(--text-muted); white-space: nowrap; }
.card-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s3); }
.card-list[aria-busy="true"], #dash-body[aria-busy="true"], #ai-results[aria-busy="true"] { opacity: 0.55; }
.card-item {
  display: flex; flex-direction: column; gap: var(--s3);
  padding: var(--s4) var(--s5); background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
}
.card-item--selectable { flex-direction: row; align-items: flex-start; gap: var(--s4); }
.card-item--selectable > input { width: 18px; height: 18px; margin-top: 4px; flex: none; accent-color: var(--accent); }
.card-item__body { display: flex; flex-direction: column; gap: var(--s2); flex: 1; min-width: 0; }
.card-item .card-cloze { font-size: var(--fs-md); font-weight: 600; }
.card-item .card-explanation { margin: 0; padding-top: var(--s2); font-size: var(--fs-sm); }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
.actions { display: flex; flex-wrap: wrap; gap: var(--s2); }
.card-note { font-size: var(--fs-sm); color: var(--text-muted); }
.card-note--warn { color: #ffe2b8; }
.empty { padding: var(--s8) var(--s4); text-align: center; color: var(--text-faint); font-style: italic; list-style: none; }
.pager { display: flex; align-items: center; justify-content: center; gap: var(--s4); margin-top: var(--s4); font-size: var(--fs-sm); color: var(--text-muted); }
.simple-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.simple-list li { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3); padding: var(--s3) 0; border-bottom: 1px solid var(--line); }
.simple-list li:last-child { border-bottom: 0; }
.simple-list__main { flex: 1; min-width: 200px; display: flex; flex-direction: column; gap: 2px; }
.simple-list__title { font-weight: 700; }
.simple-list__sub { font-size: var(--fs-xs); color: var(--text-faint); }
.steps { margin: 0; padding-left: var(--s5); display: flex; flex-direction: column; gap: var(--s1); font-size: var(--fs-sm); color: var(--text-muted); }
.kv { margin: 0; display: grid; gap: var(--s2); }
.kv > div { display: grid; grid-template-columns: 80px 1fr; gap: var(--s3); font-size: var(--fs-sm); }
.kv dt { color: var(--text-faint); }
.kv dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }

/* ---------- Topic picker ---------- */
.topic-tree {
  max-height: 340px; overflow-y: auto; padding: var(--s2);
  border: 1px solid var(--line); border-radius: var(--r); background: rgba(0, 0, 0, 0.25);
}
.topic-group + .topic-group { border-top: 1px solid var(--line); margin-top: var(--s1); padding-top: var(--s1); }
.topic-option {
  display: flex; align-items: center; gap: var(--s3); padding: 7px var(--s2); border-radius: var(--r-sm);
  font-size: var(--fs-md); font-weight: 400; color: var(--text); cursor: pointer;
}
.topic-option:hover { background: var(--accent-soft); }
.topic-option input { width: 18px; height: 18px; flex: none; accent-color: var(--accent); }
.topic-option--root { font-weight: 700; }
.topic-children { margin-left: 26px; }
.topic-children .topic-option { font-size: var(--fs-sm); }
.topic-count { margin-left: auto; min-width: 28px; text-align: right; font-size: var(--fs-xs); color: var(--text-faint); }
.lib-empty { padding: var(--s4); text-align: center; color: var(--text-faint); font-style: italic; }

/* ---------- Flashcard ---------- */
.flashcard {
  display: flex; flex-direction: column; gap: var(--s4);
  min-height: 240px; padding: var(--s8) var(--s8) var(--s6);
  border-radius: 22px; border: 1px solid var(--line-strong);
  background:
    radial-gradient(circle at 0 0, rgba(46, 204, 113, 0.12), transparent 55%),
    radial-gradient(circle at 100% 100%, rgba(39, 174, 96, 0.12), transparent 55%),
    rgba(0, 0, 0, 0.5);
  box-shadow: 0 0 26px rgba(46, 204, 113, 0.18), inset 0 0 24px rgba(0, 0, 0, 0.6);
  animation: card-in 200ms ease-out;
}
.flashcard.revealed { border-color: rgba(244, 201, 74, 0.7); box-shadow: 0 0 28px rgba(244, 201, 74, 0.25), inset 0 0 24px rgba(0, 0, 0, 0.6); }
.flashcard--compact { min-height: 0; padding: var(--s5); }
@keyframes card-in { from { opacity: 0; transform: translateY(6px) scale(0.985); } to { opacity: 1; transform: none; } }
.flashcard__topic { font-size: var(--fs-xs); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint); min-height: 1em; }
.flashcard__reveal { align-self: flex-start; margin-top: auto; }
.card-cloze { font-size: var(--fs-xl); font-weight: 600; line-height: 1.5; overflow-wrap: anywhere; }
.flashcard--compact .card-cloze { font-size: var(--fs-lg); }
.cloze-blank {
  display: inline-block; min-width: 3.5em; text-align: center; color: var(--accent-strong);
  border-bottom: 2px dashed var(--accent); line-height: 1.2;
}
.cloze-answer {
  padding: 0 0.15em; border-radius: 4px; color: var(--gold); font-weight: 800;
  background: var(--gold-soft); box-shadow: inset 0 -2px 0 rgba(244, 201, 74, 0.65);
}
.card-explanation {
  padding-top: var(--s3); border-top: 1px dashed rgba(178, 211, 191, 0.35);
  font-size: var(--fs-md); color: var(--text-muted); white-space: pre-wrap; overflow-wrap: anywhere;
}
.preview-placeholder { color: var(--text-faint); font-style: italic; font-weight: 400; }
.progress { height: 6px; margin-bottom: var(--s4); border-radius: 999px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.progress__fill { height: 100%; width: 0; background: linear-gradient(90deg, #27ae60, #5ff09a); transition: width 200ms ease-out; }
.rating-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s3); margin: var(--s4) 0 var(--s2); }
.difficulty.hard { border-color: rgba(224, 74, 106, 0.8); }
.difficulty.medium { border-color: rgba(184, 138, 0, 0.9); }
.difficulty.easy { border-color: rgba(10, 156, 120, 0.9); }
.difficulty.hard:hover:not(:disabled) { background: rgba(224, 74, 106, 0.15); }
.difficulty.medium:hover:not(:disabled) { background: rgba(184, 138, 0, 0.18); }
.difficulty.easy:hover:not(:disabled) { background: rgba(10, 156, 120, 0.18); }
#end-session-btn { margin-top: var(--s2); }

/* ---------- Session complete ---------- */
.complete { display: flex; flex-direction: column; align-items: center; gap: var(--s4); text-align: center; padding: var(--s8); }
.complete__mascot { width: 200px; height: auto; filter: drop-shadow(0 0 16px rgba(46, 204, 113, 0.6)); animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.complete__stats { margin: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--s3); width: 100%; }
.complete__stats div { padding: var(--s3); border-radius: var(--r); background: rgba(0, 0, 0, 0.3); border: 1px solid var(--line); }
.complete__stats dt { font-size: var(--fs-xs); color: var(--text-faint); }
.complete__stats dd { margin: 0; font-size: var(--fs-xl); font-weight: 800; }
.rating-split { display: flex; gap: 2px; width: 100%; height: 12px; border-radius: 999px; overflow: hidden; background: rgba(255, 255, 255, 0.08); }
.rating-split span { display: block; height: 100%; width: 0; transition: width 500ms ease-out; }
.rating-split__hard { background: #e04a6a; }
.rating-split__medium { background: #b88a00; }
.rating-split__easy { background: #0a9c78; }

/* ---------- Dashboard ---------- */
.hero-stat {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s4); flex-wrap: wrap;
  background: linear-gradient(135deg, rgba(46, 204, 113, 0.14), rgba(0, 0, 0, 0.35)); border-color: var(--line-strong);
}
.hero-stat__text { display: flex; align-items: baseline; gap: var(--s3); }
.hero-stat__value { font-size: 3rem; font-weight: 800; line-height: 1; color: var(--text); }
.hero-stat__label { font-size: var(--fs-lg); color: var(--text-muted); }
.stat-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s3); }
.stat-tiles--compact { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat-tile { display: flex; flex-direction: column; gap: 2px; padding: var(--s4); border-radius: var(--r); background: var(--panel); border: 1px solid var(--line); }
.stat-tile__value { font-size: var(--fs-2xl); font-weight: 800; line-height: 1.15; color: var(--text); }
.stat-tile__label { font-size: var(--fs-sm); font-weight: 600; color: var(--text-muted); }
.stat-tile__sub { font-size: var(--fs-xs); color: var(--text-faint); }
.maturity-bar { display: flex; gap: 2px; height: 16px; border-radius: 999px; overflow: hidden; background: rgba(255, 255, 255, 0.06); }
.maturity-bar span { display: block; min-width: 4px; }
.maturity-bar__empty { flex: 1; }
.chart-legend { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4); list-style: none; padding: 0; margin: var(--s3) 0 0; font-size: var(--fs-xs); color: var(--text-muted); }
.chart-legend li { display: flex; align-items: center; gap: 6px; }
.chart-legend__key { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.column-chart__wrap { position: relative; }
.column-chart { display: flex; align-items: stretch; gap: 2px; height: 170px; padding: var(--s4) 0 22px; border-bottom: 1px solid rgba(178, 211, 191, 0.25); }
.column-chart__col { flex: 1 1 0; position: relative; display: flex; flex-direction: column; justify-content: flex-end; border-radius: 4px; }
.column-chart__col:hover, .column-chart__col:focus-visible { background: rgba(255, 255, 255, 0.05); }
.column-chart__stack { display: flex; flex-direction: column-reverse; gap: 2px; margin: 0 16%; border-radius: 4px 4px 0 0; overflow: hidden; min-height: 0; }
.column-chart__stack span { display: block; min-height: 2px; }
.column-chart__v { text-align: center; font-size: var(--fs-xs); font-weight: 700; color: var(--text); margin-bottom: 2px; }
.column-chart__x { position: absolute; bottom: -20px; left: 0; right: 0; text-align: center; font-size: 0.7rem; color: var(--text-faint); white-space: nowrap; }
.column-chart__col.is-current .column-chart__x { color: var(--text); font-weight: 700; }
.chart-tooltip {
  position: absolute; top: -6px; transform: translate(-50%, -100%); z-index: 3; pointer-events: none;
  display: flex; flex-direction: column; gap: 1px; min-width: 140px; padding: var(--s2) var(--s3); border-radius: var(--r-sm);
  background: #03170b; border: 1px solid var(--line-strong); box-shadow: var(--shadow); font-size: var(--fs-xs); color: var(--text-muted);
}
.chart-tooltip strong { color: var(--text); }
.details { margin-top: var(--s3); font-size: var(--fs-sm); }
.details summary { cursor: pointer; color: var(--accent-strong); font-weight: 600; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.dash-table, .data-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.dash-table th, .dash-table td, .data-table th, .data-table td { padding: var(--s2) var(--s3); text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
.dash-table th:first-child, .dash-table td:first-child, .data-table th:first-child, .data-table td:first-child { text-align: left; }
.dash-table thead th, .data-table thead th { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-faint); font-weight: 700; }
.dash-table tbody th, .data-table tbody th { font-weight: 600; color: var(--text); }
.retention-cell { display: inline-flex; align-items: center; gap: var(--s2); }
.retention-cell__bar { width: 60px; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.1); overflow: hidden; display: inline-block; }
.retention-cell__bar span { display: block; height: 100%; background: #45b97a; }

/* ---------- Import summary ---------- */
.summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s3); }
.problems { margin: 0; padding-left: var(--s5); font-size: var(--fs-xs); color: var(--text-muted); max-height: 180px; overflow-y: auto; }

/* ---------- My deck ---------- */
.filters--deck { grid-template-columns: minmax(0, 2fr) repeat(3, minmax(0, 1fr)) auto; }
.list-head__actions { display: flex; flex-wrap: wrap; gap: var(--s2); margin-left: auto; }
.list-head { flex-wrap: wrap; }
.learn-pill { font-size: 0.72rem; font-weight: 700; padding: 1px 8px; border-radius: 999px; background: rgba(255, 255, 255, 0.07); color: var(--text-muted); }
.learn-pill--due { background: var(--gold-soft); color: var(--gold); }
.learn-pill--new { background: var(--accent-soft); color: var(--accent-strong); }
.badge--private { color: #9fd8ff; border-color: rgba(159, 216, 255, 0.5); }
.in-deck { font-size: var(--fs-xs); font-weight: 700; color: var(--accent-strong); }
.banner-panel { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); flex-wrap: wrap; border-color: var(--line-strong); }
.banner-panel .lede { margin-top: 0; }

/* ---------- Coach ---------- */
.coach-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: var(--s5); align-items: start; }
.coach-chat { display: flex; flex-direction: column; gap: var(--s4); min-height: 460px; }
.coach-log { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s3); max-height: 62vh; overflow-y: auto; }
.coach-log:empty { display: none; }
.bubble { max-width: 88%; padding: var(--s3) var(--s4); border-radius: 16px; font-size: var(--fs-md); line-height: 1.55; overflow-wrap: anywhere; }
.bubble p + p, .bubble p + ul, .bubble ul + p { margin-top: var(--s2); }
.bubble ul { margin: 0; padding-left: var(--s5); }
.bubble--user { align-self: flex-end; background: linear-gradient(135deg, rgba(39, 174, 96, 0.35), rgba(46, 204, 113, 0.22)); border: 1px solid var(--line-strong); border-bottom-right-radius: 4px; }
.bubble--coach { align-self: flex-start; background: rgba(0, 0, 0, 0.4); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.coach-event { align-self: flex-start; display: flex; align-items: center; gap: var(--s2); font-size: var(--fs-xs); color: var(--text-faint); padding-left: var(--s2); }
.coach-event::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); opacity: 0.7; }
.coach-event--notice { color: #ffe2b8; }
.coach-event--notice::before { background: var(--gold); }
.coach-card { align-self: stretch; padding: var(--s3) var(--s4); border-radius: var(--r); border: 1px dashed var(--line-strong); background: rgba(46, 204, 113, 0.06); display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3); }
.coach-card__main { flex: 1; min-width: 200px; display: flex; flex-direction: column; gap: 2px; }
.coach-typing { align-self: flex-start; color: var(--text-muted); font-size: var(--fs-sm); }
.coach-typing span { display: inline-block; animation: blink 1.2s infinite; }
.coach-typing span:nth-child(2) { animation-delay: 0.2s; }
.coach-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.2; } 40% { opacity: 1; } }
.coach-input { display: flex; gap: var(--s2); align-items: flex-end; margin-top: auto; }
.coach-input textarea { min-height: 52px; }
.coach-intake { padding-bottom: var(--s2); }
.plan-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; }
.plan-title { font-size: var(--fs-lg); font-weight: 800; }
.plan-days { font-size: var(--fs-sm); font-weight: 700; color: var(--gold); }
.plan-targets { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s2); }
.plan-target { padding: var(--s2) var(--s3); border-radius: var(--r-sm); background: rgba(0, 0, 0, 0.3); border: 1px solid var(--line); }
.plan-target b { display: block; font-size: var(--fs-lg); }
.plan-target span { font-size: var(--fs-xs); color: var(--text-faint); }
.plan-phases { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s2); font-size: var(--fs-sm); }
.plan-phases li { padding-left: var(--s3); border-left: 2px solid var(--line); color: var(--text-muted); }
.plan-phases li.is-current { border-left-color: var(--gold); color: var(--text); }
.plan-tips { margin: 0; padding-left: var(--s5); font-size: var(--fs-sm); color: var(--text-muted); }

@media (max-width: 860px) {
  .coach-grid { grid-template-columns: minmax(0, 1fr); }
  .filters--deck { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .coach-log { max-height: none; }
}

/* ---------- Footer ---------- */
.credits { padding-top: var(--s4); border-top: 1px solid var(--line); text-align: center; font-size: var(--fs-xs); color: var(--text-faint); display: flex; flex-direction: column; gap: 2px; }
.credits a { color: var(--text-muted); text-decoration: none; }
.credits a:hover { text-decoration: underline; color: var(--text); }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .grid-2, .grid-2--wide-left, .grid-builder, .auth-grid { grid-template-columns: minmax(0, 1fr); }
  .filters { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .filters__search, .filters__go { grid-column: 1 / -1; }
  .stat-tiles--compact, .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
  .jungle-bg { padding: 0; }
  .app-shell { min-height: 100vh; padding: var(--s4); border-radius: 0; border: 0; }
  h2 { font-size: var(--fs-xl); }
  .top-nav { flex-direction: column; align-items: stretch; gap: var(--s2); }
  .nav-links { flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; scrollbar-width: none; margin: 0 calc(-1 * var(--s4)); padding: 0 var(--s4); }
  .nav-links::-webkit-scrollbar { display: none; }
  .nav-link { flex: none; }
  .hero { margin-bottom: var(--s5); }
  .hero__title { font-size: var(--fs-2xl); }
  .panel { padding: var(--s4); }
  .stat-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero-stat__value { font-size: 2.4rem; }
  .complete { padding: var(--s5); }
  .complete__stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .flashcard { padding: var(--s5); min-height: 200px; }
  .card-cloze { font-size: var(--fs-lg); }
  .rating-row { gap: var(--s2); }
  .rating-row .btn { padding: 0 var(--s2); font-size: var(--fs-sm); }
  .rating-row kbd { display: none; }
  .tabs { border-radius: var(--r); }
  .toolbar__actions { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
