/* ============================================================
   Zelinx Flashcards — quiet study UI.

   Identity:
     • Warm charcoal background (not pure black) with paper-warm text
     • One accent colour (muted gold) for primary actions + active states
     • Editorial serif (Fraunces) for headlines, Inter for everything else
     • Generous whitespace, calm contrast, no gradients, minimal shadows

   The goal is "library / study desk" — easy on the eyes for long sessions,
   low visual noise for ADHD-friendly focus, and visually distinct from
   any other flashcard app on the market.
============================================================ */

:root {
  /* surfaces */
  --bg-0:        #0F0E12;
  --bg-1:        #15131A;
  --surface:     #1B1922;
  --surface-2:   #221F2A;
  --surface-3:   #2A2733;

  /* borders */
  --line:        #27242F;
  --line-strong: #3A3645;

  /* text */
  --text-hi:     #FBF8F1;
  --text:        #DAD6CC;
  --text-low:    #918C9C;
  --text-mut:    #5F5A68;

  /* accent — warm gold */
  --accent:      #D4A95C;
  --accent-hi:   #E6BE74;
  --accent-low:  #A88240;
  --accent-bg:   rgba(212, 169, 92, 0.10);

  /* semantic */
  --ok:          #7DBE8F;
  --ok-bg:       rgba(125, 190, 143, 0.10);
  --err:         #D67A6A;
  --err-bg:      rgba(214, 122, 106, 0.10);
  --info:        #7AAFD4;

  /* spacing (8-pt scale) */
  --s-1:  4px;
  --s-2:  8px;
  --s-3:  12px;
  --s-4:  16px;
  --s-5:  24px;
  --s-6:  32px;
  --s-7:  48px;
  --s-8:  64px;

  /* radii — squarer than the previous design */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;

  --nav-h: 64px;
  --page-max: 880px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-0);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }
a { color: inherit; }

.hidden { display: none !important; }
.mt-lg { margin-top: var(--s-7); }

/* ============================================================
   AUTH OVERLAY
============================================================ */

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--bg-0);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s-5);
  overflow-y: auto;
}
.auth-overlay::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 10%, rgba(212, 169, 92, 0.10) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 90%, rgba(122, 175, 212, 0.06) 0%, transparent 50%);
  pointer-events: none;
}

.auth-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 36px 30px 26px;
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.auth-brand {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  margin-bottom: var(--s-2);
}
.brand-logo {
  width: 30px;
  height: 30px;
  background: var(--accent);
  color: var(--bg-0);
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  font-family: 'Fraunces', serif;
}
.brand-name {
  font-family: 'Fraunces', serif;
  font-weight: 500;
  font-size: 19px;
  letter-spacing: -0.01em;
  color: var(--text-hi);
}
.auth-card h1 {
  font-family: 'Fraunces', serif;
  font-weight: 500;
  font-size: 28px;
  letter-spacing: -0.01em;
  color: var(--text-hi);
  margin: 0;
}
.muted-lead {
  margin: 0;
  color: var(--text-low);
  font-size: 14px;
  line-height: 1.5;
}

.auth-form { display: flex; flex-direction: column; gap: 10px; }
.auth-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-low);
  letter-spacing: 0.04em;
  margin-bottom: -2px;
}
.auth-label-hint {
  font-weight: 400;
  color: var(--text-mut);
  margin-left: 4px;
}
.auth-form input {
  background: var(--bg-1);
  border: 1px solid var(--line);
  color: var(--text-hi);
  font-size: 15px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  outline: none;
  transition: border-color 120ms ease;
}
.auth-form input:focus {
  border-color: var(--accent);
}
.auth-form input#auth-code {
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.35em;
  text-align: center;
  font-size: 20px;
}
.auth-submit { margin-top: var(--s-2); }
.auth-link {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 13px;
  padding: 4px;
  align-self: flex-start;
  cursor: pointer;
}
.auth-link:hover { color: var(--accent-hi); text-decoration: underline; }

.auth-info { margin: 0; font-size: 14px; color: var(--text); line-height: 1.55; }
.auth-info strong { color: var(--text-hi); font-weight: 600; }

.auth-error {
  background: var(--err-bg);
  border: 1px solid rgba(214, 122, 106, 0.35);
  color: #f4c0b6;
  padding: 10px 14px;
  border-radius: var(--r-md);
  font-size: 13px;
}
.auth-error code {
  font-family: 'JetBrains Mono', monospace;
  background: rgba(0, 0, 0, 0.25);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
}
.auth-footer {
  margin: var(--s-2) 0 0;
  font-size: 12px;
  color: var(--text-mut);
  text-align: center;
  line-height: 1.5;
}

/* ============================================================
   APP SHELL + TOP NAV
============================================================ */

.app { display: flex; flex-direction: column; min-height: 100vh; }
.app.hidden { display: none; }

.topnav {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(15, 14, 18, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  height: var(--nav-h);
}
.topnav-inner {
  max-width: 1100px;
  margin: 0 auto;
  height: 100%;
  padding: 0 var(--s-5);
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--s-5);
}

.brand {
  background: none;
  border: none;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-hi);
}
.brand:hover { color: var(--accent-hi); }
.brand-mark {
  width: 26px;
  height: 26px;
  background: var(--accent);
  color: var(--bg-0);
  border-radius: var(--r-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: 'Fraunces', serif;
  font-weight: 700;
  font-size: 14px;
}
.brand-word {
  font-family: 'Fraunces', serif;
  font-weight: 500;
  font-size: 19px;
  letter-spacing: -0.01em;
}

.topnav-nav {
  display: flex;
  justify-content: center;
  gap: var(--s-2);
}
.navlink {
  background: none;
  border: none;
  color: var(--text-low);
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--r-sm);
  transition: color 120ms ease, background 120ms ease;
}
.navlink:hover { color: var(--text-hi); background: var(--surface); }
.navlink.active {
  color: var(--text-hi);
  background: var(--surface-2);
}

.topnav-end {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}
.iconbtn {
  background: none;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-low);
  transition: background 120ms ease, color 120ms ease;
}
.iconbtn:hover { background: var(--surface); color: var(--text-hi); }
.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg-0);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
}

/* ============================================================
   MAIN + PAGE
============================================================ */

.main {
  flex: 1;
  padding: var(--s-6) var(--s-5) var(--s-8);
}

.page {
  max-width: var(--page-max);
  margin: 0 auto;
}

.view { animation: fadeUp 220ms ease both; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}

.eyebrow {
  margin: 0 0 var(--s-2);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
}

.page-h1 {
  font-family: 'Fraunces', serif;
  font-weight: 500;
  font-size: 38px;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--text-hi);
  margin: 0 0 var(--s-3);
}

.section-h2 {
  font-family: 'Fraunces', serif;
  font-weight: 500;
  font-size: 22px;
  letter-spacing: -0.01em;
  color: var(--text-hi);
  margin: var(--s-7) 0 var(--s-4);
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s-5);
  flex-wrap: wrap;
  margin-bottom: var(--s-6);
}
.page-actions {
  display: flex;
  gap: var(--s-3);
  flex-wrap: wrap;
}

.backlink {
  background: none;
  border: none;
  color: var(--text-low);
  padding: 0;
  margin-bottom: var(--s-4);
  font-size: 14px;
  cursor: pointer;
}
.backlink:hover { color: var(--text-hi); }

.breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 13px;
  color: var(--text-mut);
  margin-bottom: var(--s-3);
}
.breadcrumb a {
  color: var(--text-low);
  cursor: pointer;
  text-decoration: none;
}
.breadcrumb a:hover { color: var(--text-hi); }
.breadcrumb .crumb-sep { opacity: 0.5; }

.row-actions {
  margin-top: var(--s-5);
  display: flex;
  justify-content: center;
}

/* ============================================================
   BUTTONS
============================================================ */

.btn {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  padding: 10px 16px;
  border-radius: var(--r-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: border-color 120ms ease, background 120ms ease, color 120ms ease, transform 80ms ease;
}
.btn:hover { border-color: var(--line-strong); color: var(--text-hi); }
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg-0);
  font-weight: 600;
}
.btn-primary:hover {
  background: var(--accent-hi);
  border-color: var(--accent-hi);
  color: var(--bg-0);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-low);
}
.btn-ghost:hover { color: var(--text-hi); background: var(--surface); border-color: var(--line); }

.btn[disabled] { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-danger {
  background: transparent;
  border-color: rgba(214, 122, 106, 0.30);
  color: var(--err);
}
.btn-danger:hover {
  background: var(--err-bg);
  border-color: var(--err);
  color: #f4c0b6;
}

/* ============================================================
   HOME
============================================================ */

.home-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--s-3);
  margin: var(--s-5) 0 var(--s-6);
}
.home-stat {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--s-3) var(--s-4);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.home-stat-value {
  font-family: 'Fraunces', serif;
  font-size: 26px;
  font-weight: 500;
  color: var(--text-hi);
  line-height: 1.2;
}
.home-stat-label {
  font-size: 11px;
  color: var(--text-mut);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 600;
}

.continue-card {
  background: var(--accent-bg);
  border: 1px solid rgba(212, 169, 92, 0.30);
  border-radius: var(--r-md);
  padding: var(--s-4) var(--s-5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  margin-bottom: var(--s-5);
}
.continue-label {
  margin: 0 0 2px;
  font-size: 11px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 600;
}
.continue-deck {
  margin: 0;
  font-family: 'Fraunces', serif;
  font-size: 19px;
  color: var(--text-hi);
}

/* ============================================================
   DECK LIST (rows with left colour bar)
============================================================ */

.deck-list {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--line);
}
.deck-row {
  display: grid;
  grid-template-columns: 20px 4px 1fr auto;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-4) var(--s-4) var(--s-4) var(--s-2);
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  background: transparent;
  border-left: none;
  border-right: none;
  border-top: none;
  text-align: left;
  width: 100%;
  color: var(--text);
  transition: background 120ms ease;
  position: relative;
}
.deck-row:hover { background: var(--surface); }
.deck-row-bar {
  width: 4px;
  height: 100%;
  min-height: 36px;
  background: var(--accent);
  border-radius: 2px;
}
.deck-row-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.deck-row-name {
  font-family: 'Fraunces', serif;
  font-size: 18px;
  font-weight: 500;
  color: var(--text-hi);
  line-height: 1.3;
  letter-spacing: -0.01em;
}
.deck-row-meta {
  font-size: 13px;
  color: var(--text-low);
  display: flex;
  align-items: center;
  gap: var(--s-3);
  flex-wrap: wrap;
}
.deck-row-meta .pct {
  color: var(--accent);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.deck-row-right {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  color: var(--text-mut);
}
.deck-row-more {
  background: none;
  border: none;
  color: var(--text-mut);
  width: 28px;
  height: 28px;
  border-radius: var(--r-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}
.deck-row-more:hover { background: var(--surface-2); color: var(--text-hi); }
.deck-row-arrow {
  color: var(--text-mut);
  font-size: 18px;
  transition: transform 120ms ease, color 120ms ease;
}
.deck-row:hover .deck-row-arrow {
  color: var(--accent);
  transform: translateX(2px);
}

/* Drag-and-drop states */
.deck-row[draggable="true"] { cursor: grab; }
.deck-row.dragging {
  opacity: 0.45;
  cursor: grabbing;
}
.deck-row.drop-into {
  background: var(--accent-bg);
  outline: 2px dashed var(--accent);
  outline-offset: -2px;
}
.deck-row.drop-into::after {
  content: "Drop to nest inside";
  position: absolute;
  right: var(--s-4);
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
}
.deck-row.drop-into .deck-row-arrow,
.deck-row.drop-into .deck-row-more { visibility: hidden; }

/* Selection — custom checkbox, hover-revealed (always visible during
   active multi-select so the user can deselect easily). */
.deck-row-check {
  width: 20px;
  height: 20px;
  border: 1.5px solid var(--line-strong);
  border-radius: 5px;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  flex-shrink: 0;
  padding: 0;
  color: var(--bg-0);
  position: relative;
  pointer-events: none;
  transition: opacity 120ms ease, background 120ms ease, border-color 120ms ease;
}
/* Invisible hit-area extension. Adds ~16px of clickable padding on every
   side so the checkbox is easy to grab without making the visible box
   bigger. Pointer-events: none while the checkbox is hidden — we don't
   want stray taps in dead space to toggle selection. */
.deck-row-check::before {
  content: "";
  position: absolute;
  inset: -16px;
}
.deck-row-check svg { opacity: 0; transition: opacity 80ms ease; }
.deck-row:hover .deck-row-check,
body.has-selection .deck-row-check,
.deck-row.selected .deck-row-check {
  opacity: 1;
  pointer-events: auto;
}
.deck-row.selected .deck-row-check {
  background: var(--accent);
  border-color: var(--accent);
}
.deck-row.selected .deck-row-check svg { opacity: 1; }

.deck-row.selected {
  background: var(--accent-bg);
}
.deck-row.selected .deck-row-bar {
  box-shadow: 0 0 0 1px var(--accent);
}

/* Floating bulk-action bar (bottom-centred), appears whenever there's an
   active selection. */
.bulk-bar {
  position: fixed;
  bottom: var(--s-5);
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 8px 8px 8px var(--s-4);
  display: flex;
  gap: var(--s-3);
  align-items: center;
  /* Below modal layer (modal is 60, backdrop is 50) so the action bar
     never covers modal buttons. */
  z-index: 40;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: transform 200ms cubic-bezier(.3,.9,.4,1.1), opacity 200ms ease;
}
.bulk-bar.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}
.bulk-bar-count {
  font-family: 'JetBrains Mono', monospace;
  color: var(--accent);
  font-weight: 700;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.bulk-bar .btn { padding: 8px 14px; font-size: 13px; }
.bulk-bar-hint {
  font-size: 11px;
  color: var(--text-mut);
  margin-left: var(--s-2);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
}

/* Drop zones now float on the LEFT edge of the viewport — they slide in
   only while a deck is being dragged, so they don't take up inline space
   in the page. Each view (Library, Node) has its own zone in the DOM, but
   only the one whose parent view is visible actually appears. */
.root-drop-zone {
  position: fixed;
  top: 50%;
  left: -260px;
  transform: translateY(-50%);
  width: 220px;
  min-height: 220px;
  padding: var(--s-5) var(--s-4);
  background: var(--surface);
  border: 2px dashed var(--line-strong);
  border-radius: var(--r-md);
  color: var(--text-low);
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 600;
  text-align: center;
  line-height: 1.5;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 80;
  pointer-events: none;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
  transition: left 220ms cubic-bezier(.3,.9,.4,1.1),
              border-color 120ms ease,
              color 120ms ease,
              background 120ms ease;
}
.root-drop-zone.show {
  left: var(--s-4);
  pointer-events: auto;
}
.root-drop-zone.drop-into {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-bg);
  border-style: solid;
}

/* ============================================================
   TABS
============================================================ */

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: var(--s-5);
}
.tab {
  background: none;
  border: none;
  color: var(--text-low);
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab:hover { color: var(--text-hi); }
.tab.active {
  color: var(--text-hi);
  border-bottom-color: var(--accent);
}

/* ============================================================
   CARD LIST (inside a deck)
============================================================ */

.card-list {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--line);
}
.card-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: var(--s-4);
  padding: var(--s-4) 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.card-row:hover { background: var(--surface); margin: 0 calc(-1 * var(--s-4)); padding-left: var(--s-4); padding-right: var(--s-4); border-radius: var(--r-sm); }
.card-row-q {
  font-weight: 500;
  color: var(--text-hi);
  font-size: 14px;
  line-height: 1.45;
}
.card-row-a {
  color: var(--text-low);
  font-size: 13px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-row-a strong { color: var(--accent); font-weight: 600; }
.card-row-actions {
  display: flex;
  gap: 4px;
  align-items: flex-start;
}
.card-row-action {
  background: none;
  border: none;
  color: var(--text-mut);
  padding: 4px 8px;
  border-radius: var(--r-sm);
  font-size: 12px;
  font-weight: 500;
}
.card-row-action:hover { color: var(--text-hi); background: var(--surface-2); }

.empty {
  padding: var(--s-7) var(--s-4);
  text-align: center;
  color: var(--text-low);
  border: 1px dashed var(--line);
  border-radius: var(--r-md);
}
.empty p { margin: 0 0 var(--s-4); }

/* ============================================================
   NODE VIEW — title block with colour bar
============================================================ */

.node-title-block {
  display: flex;
  gap: var(--s-4);
  align-items: stretch;
}
.node-color-bar {
  width: 4px;
  border-radius: 2px;
  background: var(--accent);
  flex-shrink: 0;
}

/* ============================================================
   MODE PICKER
============================================================ */

.mode-list {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  margin-top: var(--s-5);
}
.mode-row {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--s-4) var(--s-5);
  display: grid;
  grid-template-columns: 4px 1fr auto;
  align-items: center;
  gap: var(--s-4);
  text-align: left;
  color: var(--text);
  transition: border-color 120ms ease, background 120ms ease, transform 120ms ease;
}
.mode-row:hover {
  border-color: var(--accent);
  background: var(--surface);
  transform: translateX(2px);
}
.mode-stripe {
  width: 4px;
  height: 32px;
  background: var(--accent);
  border-radius: 2px;
}
.mode-text { display: flex; flex-direction: column; gap: 2px; }
.mode-name {
  margin: 0;
  font-family: 'Fraunces', serif;
  font-size: 20px;
  font-weight: 500;
  color: var(--text-hi);
}
.mode-desc { margin: 0; font-size: 13px; color: var(--text-low); }
.mode-arrow { color: var(--text-mut); font-size: 20px; }
.mode-row:hover .mode-arrow { color: var(--accent); }

/* ============================================================
   FOCUS VIEW (study / recall / test)
   Hides the top nav for distraction-free study.
============================================================ */

.focus-view {
  position: fixed;
  inset: 0;
  background: var(--bg-0);
  overflow-y: auto;
  z-index: 30;
  padding: var(--s-6) var(--s-5) var(--s-7);
}
.focus-exit {
  position: absolute;
  top: var(--s-4);
  right: var(--s-4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  width: 40px;
  height: 40px;
  color: var(--text-low);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 120ms ease, background 120ms ease;
  z-index: 1;
}
.focus-exit:hover { color: var(--text-hi); background: var(--surface-2); }

.focus-page {
  max-width: 720px;
  margin: 0 auto;
}

.focus-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: var(--s-4);
}
.focus-title {
  font-family: 'Fraunces', serif;
  font-size: 22px;
  font-weight: 500;
  color: var(--text-hi);
  margin: 0;
  letter-spacing: -0.01em;
}
.focus-counter {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--text-low);
}
.focus-percent {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--text-low);
  font-variant-numeric: tabular-nums;
}

.progress-rail {
  background: var(--surface);
  border-radius: 999px;
  height: 4px;
  overflow: hidden;
  margin: var(--s-3) 0 var(--s-4);
}
.progress-fill {
  background: var(--accent);
  height: 100%;
  transition: width 250ms ease;
}

.topic-row {
  display: flex;
  gap: var(--s-2);
  flex-wrap: wrap;
  margin-bottom: var(--s-4);
}
.topic-chip {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-low);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 120ms ease;
}
.topic-chip:hover { color: var(--text-hi); border-color: var(--line-strong); }
.topic-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg-0);
}

.counters {
  display: flex;
  gap: var(--s-5);
  margin: var(--s-3) 0;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--text-low);
}
.counter { display: inline-flex; align-items: center; gap: 6px; }
.counter strong { color: var(--text); font-weight: 600; }
.dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.dot-ok { background: var(--ok); }
.dot-err { background: var(--err); }

/* ============================================================
   FLASHCARDS CARD
============================================================ */

.card-stage {
  perspective: 1600px;
  margin: var(--s-5) 0 var(--s-4);
}
.card {
  position: relative;
  transform-style: preserve-3d;
  min-height: 300px;
  cursor: pointer;
  transition: transform 550ms cubic-bezier(.4,0,.2,1);
}
.card.flipped { transform: rotateY(180deg); }
.card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--s-7) var(--s-5);
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}
.card-back {
  transform: rotateY(180deg);
  background: var(--surface-2);
  border-color: var(--accent-low);
}
.card-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.card-text {
  font-family: 'Fraunces', serif;
  font-size: 28px;
  font-weight: 400;
  color: var(--text-hi);
  line-height: 1.4;
  letter-spacing: -0.01em;
  flex: 1;
}
.card-text strong { color: var(--accent); font-weight: 500; }
.card-text ul { padding-left: 22px; margin: 8px 0 0; }
.card-text li {
  margin: 8px 0;
  font-size: 20px;
  font-weight: 400;
  font-family: 'Fraunces', serif;
}
.card-text p { margin: 0; }
.card-hint {
  font-size: 12px;
  color: var(--text-mut);
  text-align: center;
}

.judgement-row {
  display: flex;
  gap: var(--s-3);
  margin: var(--s-3) 0 var(--s-4);
}
.btn-judge {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 14px 16px;
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--r-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  transition: all 120ms ease;
}
.btn-judge .check { font-size: 17px; }
.btn-got { color: #b6e2c0; border-color: rgba(125, 190, 143, 0.30); }
.btn-got:hover { background: var(--ok-bg); border-color: var(--ok); }
.btn-miss { color: #f0c0b6; border-color: rgba(214, 122, 106, 0.30); }
.btn-miss:hover { background: var(--err-bg); border-color: var(--err); }

.key-hint {
  margin-left: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-mut);
  background: var(--bg-1);
  padding: 2px 6px;
  border-radius: 4px;
}

.nav-row {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  flex-wrap: wrap;
  margin-top: var(--s-3);
}
.nav-counter {
  color: var(--text-low);
  font-size: 13px;
  margin: 0 var(--s-2);
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   RECALL
============================================================ */

.recall-prompt {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--r-md);
  padding: var(--s-6) var(--s-5);
  font-family: 'Fraunces', serif;
  font-size: 26px;
  font-weight: 400;
  color: var(--text-hi);
  margin: var(--s-5) 0 var(--s-4);
  line-height: 1.4;
  letter-spacing: -0.01em;
}

.recall-input {
  width: 100%;
  background: var(--bg-1);
  border: 1px solid var(--line);
  color: var(--text-hi);
  font-size: 18px;
  padding: var(--s-4) var(--s-5);
  border-radius: var(--r-md);
  outline: none;
  transition: border-color 120ms ease, background 120ms ease;
}
.recall-input:focus { border-color: var(--accent); }
.recall-input.correct { border-color: var(--ok); background: var(--ok-bg); }
.recall-input.wrong { border-color: var(--err); background: var(--err-bg); }

.recall-actions {
  display: flex;
  justify-content: space-between;
  gap: var(--s-3);
  margin-top: var(--s-3);
  flex-wrap: wrap;
}

.recall-feedback {
  margin-top: var(--s-5);
  padding: var(--s-4) var(--s-5);
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--line);
}
.recall-feedback.correct { border-color: rgba(125, 190, 143, 0.40); }
.recall-feedback.wrong { border-color: rgba(214, 122, 106, 0.40); }
.recall-feedback-row {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  margin-bottom: var(--s-3);
}
.recall-feedback-tag {
  background: var(--ok);
  color: var(--bg-0);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.recall-feedback.wrong .recall-feedback-tag { background: var(--err); }
.recall-feedback-text { color: var(--text-low); font-size: 13px; }
.recall-feedback-answer {
  background: var(--bg-1);
  border-radius: var(--r-sm);
  padding: var(--s-3) var(--s-4);
  font-family: 'Fraunces', serif;
  font-size: 17px;
  color: var(--text-hi);
  line-height: 1.5;
}
.recall-feedback-answer strong { color: var(--accent); font-weight: 500; }
.recall-feedback-buttons {
  display: flex;
  justify-content: flex-end;
  gap: var(--s-2);
  margin-top: var(--s-4);
  flex-wrap: wrap;
}

/* ============================================================
   TEST / QUIZ
============================================================ */

.test-question {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--r-md);
  padding: var(--s-6) var(--s-5);
  font-family: 'Fraunces', serif;
  font-size: 24px;
  font-weight: 400;
  color: var(--text-hi);
  margin: var(--s-5) 0 var(--s-4);
}
.test-choices {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  margin-bottom: var(--s-4);
}
.test-choice {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
  padding: var(--s-4) var(--s-5);
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  gap: var(--s-3);
  font-size: 15px;
  text-align: left;
  transition: all 120ms ease;
}
.test-choice:hover:not(.disabled) {
  border-color: var(--accent);
  background: var(--surface-2);
}
.test-choice.correct {
  border-color: var(--ok);
  background: var(--ok-bg);
}
.test-choice.wrong {
  border-color: var(--err);
  background: var(--err-bg);
}
.test-choice.disabled { cursor: default; }
.test-choice-letter {
  background: var(--bg-1);
  color: var(--text-low);
  width: 28px;
  height: 28px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
  flex-shrink: 0;
  font-family: 'JetBrains Mono', monospace;
}
.test-feedback {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--s-4) var(--s-5);
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}
.test-feedback-text { font-size: 14px; color: var(--text); line-height: 1.5; }
.test-feedback-text strong { color: var(--accent); font-weight: 600; }

/* ============================================================
   DONE
============================================================ */

.done-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--s-7) var(--s-5);
  text-align: center;
  max-width: 480px;
  margin: var(--s-7) auto 0;
}
.done-emoji { font-size: 48px; }
.done-card h2 {
  font-family: 'Fraunces', serif;
  margin: var(--s-4) 0 var(--s-2);
  font-size: 26px;
  font-weight: 500;
  color: var(--text-hi);
}
.done-card p { color: var(--text-low); margin: 0; }
.done-stats {
  display: flex;
  gap: var(--s-3);
  justify-content: center;
  margin: var(--s-5) 0;
  flex-wrap: wrap;
}
.done-stat {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--s-3) var(--s-5);
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 100px;
}
.done-stat-value {
  font-family: 'Fraunces', serif;
  font-size: 28px;
  font-weight: 500;
  color: var(--text-hi);
}
.done-stat-label {
  font-size: 11px;
  color: var(--text-mut);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 600;
}
.done-stat.got .done-stat-value { color: var(--ok); }
.done-stat.miss .done-stat-value { color: var(--err); }
.done-stat.score .done-stat-value { color: var(--accent); }
.done-buttons {
  display: flex;
  gap: var(--s-3);
  justify-content: center;
  flex-wrap: wrap;
}

/* ============================================================
   MODAL
============================================================ */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 7, 10, 0.75);
  backdrop-filter: blur(6px);
  z-index: 50;
}
.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s-4);
}
.modal-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--s-5) var(--s-5) var(--s-4);
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
  max-height: 86vh;
  overflow-y: auto;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 {
  margin: 0;
  font-family: 'Fraunces', serif;
  font-size: 20px;
  font-weight: 500;
  color: var(--text-hi);
}
.modal-close {
  background: none;
  border: none;
  color: var(--text-low);
  font-size: 20px;
  width: 30px;
  height: 30px;
  border-radius: var(--r-sm);
}
.modal-close:hover { background: var(--surface-2); color: var(--text-hi); }

.modal-body { display: flex; flex-direction: column; gap: var(--s-2); }
.modal-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-low);
  letter-spacing: 0.04em;
  margin: var(--s-2) 0 -2px;
}
.modal-body input,
.modal-body textarea {
  background: var(--bg-1);
  border: 1px solid var(--line);
  color: var(--text-hi);
  font-size: 14px;
  padding: 10px 14px;
  border-radius: var(--r-md);
  outline: none;
  font-family: inherit;
  resize: vertical;
}
.modal-body input:focus,
.modal-body textarea:focus { border-color: var(--accent); }
.modal-parent-row {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 8px 14px;
  font-size: 13px;
}
.modal-parent-row .modal-label { margin: 0; }
.modal-parent-name { color: var(--text-hi); font-weight: 500; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--s-3);
  margin-top: var(--s-2);
}

/* In-app confirm dialog — same modal frame as Add Card / Add Deck. */
.modal-confirm-card {
  max-width: 420px;
  gap: var(--s-3);
}
.modal-confirm-title {
  margin: 0;
  font-family: 'Fraunces', serif;
  font-size: 22px;
  font-weight: 500;
  color: var(--text-hi);
  letter-spacing: -0.01em;
}
.modal-confirm-message {
  margin: 0;
  color: var(--text-low);
  font-size: 14px;
  line-height: 1.55;
}

.color-row { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.color-swatch {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 120ms ease;
}
.color-swatch.active { border-color: var(--text-hi); }
.color-swatch:hover { transform: scale(1.1); }

.picker-list { display: flex; flex-direction: column; gap: var(--s-2); }
.picker-item {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--s-4) var(--s-4);
  display: flex;
  align-items: center;
  gap: var(--s-4);
  text-align: left;
  color: var(--text);
  transition: border-color 120ms ease, background 120ms ease;
}
.picker-item:hover { border-color: var(--accent); background: var(--surface-2); }
.picker-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  background: var(--bg-1);
  color: var(--accent);
}
.picker-item strong {
  display: block;
  font-family: 'Fraunces', serif;
  font-size: 17px;
  font-weight: 500;
  color: var(--text-hi);
}
.picker-item em {
  display: block;
  font-style: normal;
  font-size: 13px;
  color: var(--text-low);
  margin-top: 2px;
}

/* ============================================================
   PROFILE / STATS
============================================================ */

.profile-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--s-4) var(--s-5);
  display: flex;
  align-items: center;
  gap: var(--s-4);
  margin: var(--s-4) 0 var(--s-5);
}
.profile-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg-0);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Fraunces', serif;
  font-size: 22px;
  font-weight: 600;
}
.profile-card h2 {
  margin: 0 0 2px;
  font-family: 'Fraunces', serif;
  font-size: 22px;
  font-weight: 500;
  color: var(--text-hi);
}
.profile-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--s-3);
}
.profile-actions {
  display: flex;
  gap: var(--s-3);
  flex-wrap: wrap;
}

.profile-password-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--s-4) var(--s-5);
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}
.profile-password-card .muted-lead { margin: 0; font-size: 13px; }
.profile-password-form {
  display: flex;
  gap: var(--s-3);
  flex-wrap: wrap;
}
.profile-password-form input {
  flex: 1;
  min-width: 200px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  color: var(--text-hi);
  font-size: 14px;
  padding: 10px 14px;
  border-radius: var(--r-md);
  outline: none;
}
.profile-password-form input:focus { border-color: var(--accent); }
.profile-password-msg-ok {
  background: var(--ok-bg) !important;
  border-color: rgba(125, 190, 143, 0.35) !important;
  color: #b6e2c0 !important;
}

.progress-summary {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--s-4) var(--s-5);
  display: flex;
  gap: var(--s-6);
  flex-wrap: wrap;
  margin: var(--s-4) 0;
}
.progress-summary-item { display: flex; flex-direction: column; gap: 2px; }
.progress-summary-item strong {
  font-family: 'Fraunces', serif;
  font-size: 26px;
  font-weight: 500;
  color: var(--text-hi);
}
.progress-summary-item span {
  font-size: 11px;
  color: var(--text-mut);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 600;
}

.progress-list { display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.progress-row-item {
  display: grid;
  grid-template-columns: 4px 1fr 1.5fr auto;
  align-items: center;
  gap: var(--s-4);
  padding: var(--s-3) var(--s-2);
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background 120ms ease;
}
.progress-row-item:hover { background: var(--surface); }
.progress-row-stripe {
  width: 4px;
  height: 24px;
  background: var(--accent);
  border-radius: 2px;
}
.progress-row-name { font-weight: 500; color: var(--text); }
.progress-row-bar {
  height: 6px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}
.progress-row-fill { height: 100%; background: var(--accent); }
.progress-row-pct {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--text-low);
  font-weight: 500;
  min-width: 44px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   XP / LEVEL / LEADERBOARD
============================================================ */

.level-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--r-md);
  padding: var(--s-4) var(--s-5);
  margin: var(--s-4) 0 var(--s-5);
}
.level-card-top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s-4);
  margin-bottom: var(--s-3);
}
.level-eyebrow {
  margin: 0 0 2px;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
}
.level-value {
  margin: 0;
  font-family: 'Fraunces', serif;
  font-size: 36px;
  font-weight: 500;
  color: var(--text-hi);
  line-height: 1;
  letter-spacing: -0.02em;
}
.level-xp {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  color: var(--text-low);
  font-variant-numeric: tabular-nums;
}
.level-xp-sep { color: var(--text-mut); margin: 0 2px; }
.level-bar {
  height: 8px;
  background: var(--bg-1);
  border-radius: 999px;
  overflow: hidden;
}
.level-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-hi));
  transition: width 400ms ease;
}
.level-stats {
  display: flex;
  gap: var(--s-5);
  margin-top: var(--s-3);
  flex-wrap: wrap;
}
.level-stat {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-low);
  font-size: 13px;
}
.level-stat-icon {
  font-size: 18px;
  width: 28px;
  text-align: center;
}
.level-stat > div { display: flex; flex-direction: column; line-height: 1.1; }
.level-stat span:first-child + span,
.level-stat > div > span:first-child {
  color: var(--text-hi);
  font-family: 'JetBrains Mono', monospace;
  font-size: 16px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.level-stat-label {
  font-size: 10px;
  color: var(--text-mut);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 600;
  margin-top: 2px;
}

.leaderboard {
  border-top: 1px solid var(--line);
}
.leaderboard-row {
  display: grid;
  grid-template-columns: 40px 1fr auto auto;
  align-items: center;
  gap: var(--s-4);
  padding: var(--s-3) var(--s-2);
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.leaderboard-row.me {
  background: var(--accent-bg);
  border-left: 3px solid var(--accent);
  padding-left: 12px;
}
.leaderboard-rank {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  color: var(--text-mut);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.leaderboard-row.me .leaderboard-rank { color: var(--accent); font-weight: 600; }
.leaderboard-row.top-1 .leaderboard-rank { color: var(--accent); font-weight: 700; }
.leaderboard-name {
  font-family: 'Fraunces', serif;
  font-size: 16px;
  color: var(--text-hi);
  font-weight: 500;
  letter-spacing: -0.005em;
}
.leaderboard-row.me .leaderboard-name::after {
  content: ' (you)';
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  color: var(--accent);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-left: 4px;
}
.leaderboard-streak {
  color: var(--text-low);
  font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
  font-variant-numeric: tabular-nums;
}
.leaderboard-xp {
  color: var(--text-hi);
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  min-width: 70px;
  text-align: right;
}
.leaderboard-row.me .leaderboard-xp { color: var(--accent); }

/* XP toast — slides in bottom-right when an answer earns XP */
.xp-toast {
  position: fixed;
  bottom: var(--s-5);
  right: var(--s-5);
  z-index: 200;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: var(--r-md);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-hi);
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
  animation: xpToastIn 220ms cubic-bezier(.2,.9,.3,1.2);
  pointer-events: none;
}
.xp-toast.fade { animation: xpToastOut 280ms ease both; }
.xp-toast-amount {
  font-family: 'JetBrains Mono', monospace;
  color: var(--accent);
  font-weight: 700;
  font-size: 15px;
}
.xp-toast-streak {
  font-size: 12px;
  color: var(--text-low);
  font-family: 'JetBrains Mono', monospace;
}
.xp-toast.level-up {
  border-color: var(--accent-hi);
  background: var(--accent-bg);
}
.xp-toast.level-up::before {
  content: '★';
  color: var(--accent);
  font-size: 18px;
}
@keyframes xpToastIn {
  from { opacity: 0; transform: translateY(20px) scale(0.96); }
  to   { opacity: 1; transform: none; }
}
@keyframes xpToastOut {
  from { opacity: 1; }
  to   { opacity: 0; transform: translateY(-6px); }
}

/* ============================================================
   STREAK PILL (top nav)
============================================================ */
.streak-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: var(--accent-bg);
  border: 1px solid rgba(212, 169, 92, 0.30);
  border-radius: 999px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.streak-flame { font-size: 14px; }

/* ============================================================
   DUE CARD on Home
============================================================ */
.due-card {
  background: var(--accent-bg);
  border: 1px solid rgba(212, 169, 92, 0.40);
  border-radius: var(--r-md);
  padding: var(--s-4) var(--s-5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  margin: var(--s-3) 0 var(--s-3);
}
.due-text { display: flex; flex-direction: column; gap: 2px; }
.due-label {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}
.due-count {
  margin: 0;
  font-family: 'Fraunces', serif;
  font-size: 20px;
  color: var(--text-hi);
}
.due-count span { font-weight: 600; }

/* ============================================================
   MODE-PICKER SESSION PILLS
============================================================ */
.session-options {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  margin: var(--s-5) 0;
  padding: var(--s-4) var(--s-5);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}
.session-option-group {
  display: flex;
  align-items: center;
  gap: var(--s-4);
  flex-wrap: wrap;
}
.session-option-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 700;
  color: var(--text-mut);
  min-width: 50px;
}
.session-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.session-pill {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-low);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 120ms ease;
}
.session-pill:hover { color: var(--text-hi); border-color: var(--line-strong); }
.session-pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg-0);
  font-weight: 600;
}
.session-pill-badge {
  background: rgba(0, 0, 0, 0.18);
  color: inherit;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}
.session-pill:not(.active) .session-pill-badge {
  background: var(--bg-1);
  color: var(--text-low);
}

/* ============================================================
   SEARCH MODAL
============================================================ */
.modal-search-card {
  max-width: 600px;
  padding: 0;
  overflow: hidden;
}
.search-input-wrap {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--line);
  color: var(--text-low);
}
#search-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-hi);
  font-size: 16px;
  padding: 6px 0;
  outline: none;
}
#search-input::placeholder { color: var(--text-mut); }
.search-esc {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  background: var(--bg-1);
  color: var(--text-low);
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.04em;
}
.search-results {
  max-height: 60vh;
  overflow-y: auto;
  padding: var(--s-2) 0;
}
.search-empty {
  padding: var(--s-5) var(--s-4);
  text-align: center;
  margin: 0;
}
.search-result {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--s-3) var(--s-4);
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background 120ms ease, border-color 120ms ease;
}
.search-result:hover {
  background: var(--surface-2);
  border-left-color: var(--accent);
}
.search-result-q {
  font-weight: 500;
  color: var(--text-hi);
  font-size: 14px;
}
.search-result-q mark {
  background: var(--accent-bg);
  color: var(--accent);
  padding: 0 2px;
  border-radius: 3px;
}
.search-result-a {
  color: var(--text-low);
  font-size: 12px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.search-result-deck {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-mut);
  font-weight: 600;
  margin-top: 2px;
}

/* ============================================================
   STAR ICON on cards
============================================================ */
.star-btn {
  background: none;
  border: none;
  padding: 6px;
  cursor: pointer;
  color: var(--text-mut);
  border-radius: var(--r-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 120ms ease, background 120ms ease, transform 120ms ease;
}
.star-btn:hover { background: var(--surface-2); color: var(--accent); }
.star-btn.starred {
  color: var(--accent);
}
.star-btn.starred svg { fill: var(--accent); }
.star-btn.just-starred { animation: starPulse 320ms cubic-bezier(.3,1.5,.4,1); }
@keyframes starPulse {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.4); }
  100% { transform: scale(1); }
}

/* ============================================================
   PROFILE TOGGLE ROW (sound)
============================================================ */
.toggle-row {
  display: flex;
  align-items: center;
  gap: var(--s-4);
  padding: var(--s-4) var(--s-5);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  cursor: pointer;
  margin-top: var(--s-3);
}
.toggle-row-text { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.toggle-row-title {
  font-weight: 600;
  color: var(--text-hi);
  font-size: 14px;
}
.toggle-row-desc { font-size: 12px; color: var(--text-low); }
.toggle-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.toggle-slider {
  display: inline-block;
  width: 44px;
  height: 24px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 999px;
  position: relative;
  flex-shrink: 0;
  transition: background 160ms ease, border-color 160ms ease;
}
.toggle-slider::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: var(--text-low);
  border-radius: 50%;
  transition: transform 180ms cubic-bezier(.3,.9,.4,1.2), background 160ms ease;
}
.toggle-input:checked + .toggle-slider {
  background: var(--accent);
  border-color: var(--accent);
}
.toggle-input:checked + .toggle-slider::after {
  background: var(--bg-0);
  transform: translateX(20px);
}

/* ============================================================
   RESPONSIVE
============================================================ */

@media (max-width: 720px) {
  :root { --nav-h: 56px; }
  .topnav-inner { padding: 0 var(--s-4); gap: var(--s-3); }
  .topnav-nav .navlink { padding: 8px 10px; font-size: 13px; }
  .main { padding: var(--s-5) var(--s-4) var(--s-7); }
  .page-h1 { font-size: 30px; }
  .card-row { grid-template-columns: 1fr; }
  .card-row-actions { justify-content: flex-end; }
  .focus-view { padding: var(--s-5) var(--s-4) var(--s-7); }
  .recall-prompt, .test-question { font-size: 22px; padding: var(--s-5) var(--s-4); }
  .card-text { font-size: 22px; }
}
