/* WordVale web app — the iOS app's palette (App/Theme.swift) and shapes. */
:root {
  --paper: #F6F1E6; --card: #FFFDF8; --ink: #101B33; --teal: #1D5C58; --gold: #B9832A;
  --navy: #101B33; --cream: #F3EAD7; --on-teal: #FFFFFF;
  --secondary: rgba(16, 27, 51, 0.62); --tertiary: rgba(16, 27, 51, 0.40);
  --separator: rgba(16, 27, 51, 0.12); --fill: rgba(16, 27, 51, 0.06);
  --tier-familiar: #85B3AB; --tier-known: #307F78; --tier-mastered: #BF942E;
  --streak: #D9A340; --danger: #C0392B; --good: #2E9D57;
  --shadow: 0 8px 24px rgba(16, 27, 51, 0.10);
  --serif: ui-serif, "New York", Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --r-card: 22px; --gutter: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0B1426; --card: #16213A; --ink: #F3EAD7; --teal: #5FB3A9; --gold: #D9A441;
    --navy: #1A2744; --on-teal: #0B1426;
    --secondary: rgba(243, 234, 215, 0.66); --tertiary: rgba(243, 234, 215, 0.42);
    --separator: rgba(243, 234, 215, 0.14); --fill: rgba(243, 234, 215, 0.08);
    --tier-known: #4FA79E; --danger: #FF6B5E; --good: #4CC27A;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0B1426; --card: #16213A; --ink: #F3EAD7; --teal: #5FB3A9; --gold: #D9A441;
  --navy: #1A2744; --on-teal: #0B1426;
  --secondary: rgba(243, 234, 215, 0.66); --tertiary: rgba(243, 234, 215, 0.42);
  --separator: rgba(243, 234, 215, 0.14); --fill: rgba(243, 234, 215, 0.08);
  --tier-known: #4FA79E; --danger: #FF6B5E; --good: #4CC27A;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 17px/1.45 var(--sans);
       -webkit-font-smoothing: antialiased; overflow-x: hidden; }
a { color: var(--teal); }
h1, h2, h3 { margin: 0; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; border-radius: 8px; }
.visually-hidden { position: absolute !important; left: 0; top: 0; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.secondary { color: var(--secondary); }
.tertiary { color: var(--tertiary); }
.small { font-size: 15px; }
.tiny { font-size: 12px; }
.strong { font-weight: 600; }
.center { text-align: center; }
.teal, .tint { color: var(--teal); }
.gold { color: var(--gold); }
.grow { flex: 1 1 auto; }
.grow1 { flex: 1; min-width: 0; }
.clamp1, .clamp2 { display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; }
.clamp1 { -webkit-line-clamp: 1; }
.clamp2 { -webkit-line-clamp: 2; }
.ic { flex: none; vertical-align: -0.15em; }
kbd { font: 600 11px/1 var(--sans); padding: 3px 5px; border-radius: 5px; border: 1px solid var(--separator);
      background: var(--fill); color: var(--secondary); }
.btn kbd { margin-left: 4px; border-color: currentColor; opacity: .6; background: transparent; color: inherit; }
@media (hover: none) { .btn kbd, .kbd-help { display: none; } }

/* ---- Buttons (iOS bordered / borderedProminent) ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px;
       padding: 10px 18px; border-radius: 999px; border: 0; font-weight: 600; font-size: 16px;
       cursor: pointer; text-decoration: none; transition: filter .15s, transform .1s; white-space: nowrap; }
.btn:active { transform: scale(0.98); }
.btn.prominent { background: var(--teal); color: var(--on-teal); }
.btn.prominent:hover { filter: brightness(1.08); }
.btn.bordered { background: color-mix(in srgb, var(--teal) 14%, transparent); color: var(--teal); }
.btn.bordered:hover { background: color-mix(in srgb, var(--teal) 20%, transparent); }
.btn.bordered.gold { background: color-mix(in srgb, var(--gold) 16%, transparent); color: var(--gold); }
.btn.bordered.gray { background: var(--fill); color: var(--secondary); }
.btn.bordered.danger { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.btn.destructive { background: var(--danger); color: #fff; }
.btn:disabled, .btn.disabled { opacity: .45; cursor: default; }
.wide-btn { width: 100%; }
.small-btn { min-height: 36px; padding: 6px 14px; font-size: 15px; }
.link-btn { background: none; border: 0; color: var(--teal); padding: 6px 2px; cursor: pointer; font-size: 17px;
            display: inline-flex; align-items: center; gap: 2px; text-decoration: none; }
.link-btn.strong { font-weight: 600; }
.icon-btn { background: none; border: 0; color: var(--teal); width: 44px; height: 44px; border-radius: 50%; cursor: pointer;
            display: inline-flex; align-items: center; justify-content: center; }
.icon-btn:hover { background: var(--fill); }
.round-btn { width: 46px; height: 46px; border-radius: 50%; border: 0; cursor: pointer; flex: none;
             background: color-mix(in srgb, var(--teal) 14%, transparent); color: var(--teal);
             display: inline-flex; align-items: center; justify-content: center; }
.round-btn:hover { background: color-mix(in srgb, var(--teal) 22%, transparent); }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.row-buttons { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.row-buttons .btn { flex: 1 1 140px; }

/* ---- Cards, chips ---- */
.card { background: var(--card); border-radius: var(--r-card); padding: 16px; display: block; color: inherit; text-decoration: none; }
.card h2 { font-size: 17px; font-weight: 600; margin-bottom: 8px; }
.card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.card-head h2 { margin: 0; flex: 1; }
.count { font-weight: 600; color: var(--teal); font-variant-numeric: tabular-nums; }
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px;
        background: color-mix(in srgb, var(--c) 18%, transparent); color: var(--c); white-space: nowrap; }
.pill { font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 999px; margin-left: 4px;
        background: color-mix(in srgb, var(--teal) 15%, transparent); color: var(--teal); text-transform: none; letter-spacing: 0; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase; color: var(--secondary); }
.eyebrow.gold { color: var(--gold); }
.tier { display: inline-flex; }
.spinner { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--separator);
           border-top-color: var(--secondary); animation: spin .8s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { text-align: center; padding: 48px 16px; color: var(--ink); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty .ic { color: var(--secondary); }
.empty h2 { font-size: 22px; font-weight: 700; }
.empty p { max-width: 42ch; }
.form-error { color: var(--danger); font-size: 15px; min-height: 1em; margin-top: 8px; }
.form-error:empty { display: none; }

/* ---- App shell: bottom tab bar on phones, sidebar on wide screens ---- */
.app { min-height: 100vh; }
.view { padding: 0 var(--gutter) calc(96px + env(safe-area-inset-bottom)); max-width: 760px; margin: 0 auto; outline: none; }
.tabbar { position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-around;
          padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
          background: color-mix(in srgb, var(--paper) 86%, transparent); backdrop-filter: blur(20px) saturate(1.6);
          -webkit-backdrop-filter: blur(20px) saturate(1.6); border-top: 1px solid var(--separator); }
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0; font-size: 11px; font-weight: 500;
       color: var(--secondary); text-decoration: none; border-radius: 10px; min-width: 0; }
.tab.on { color: var(--teal); }
.side-brand, .side-sync { display: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding: 22px 0 14px; }
.page-head h1 { font: 700 34px/1.15 var(--serif); letter-spacing: .2px; }

@media (min-width: 860px) {
  .tabbar { top: 0; right: auto; width: 220px; flex-direction: column; justify-content: flex-start; gap: 2px;
            padding: 20px 12px; border-top: 0; border-right: 1px solid var(--separator); }
  .side-brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; color: var(--ink); text-decoration: none;
                font: 700 20px var(--serif); }
  .side-brand img { border-radius: 8px; }
  .tab { flex: none; flex-direction: row; gap: 12px; font-size: 16px; padding: 10px 12px; color: var(--ink); }
  .tab .ic { color: var(--teal); }
  .tab:hover { background: var(--fill); }
  .tab.on { background: color-mix(in srgb, var(--teal) 14%, transparent); color: var(--teal); font-weight: 600; }
  .side-sync { display: block; margin-top: auto; padding: 10px 12px; font-size: 13px; color: var(--tertiary); }
  .app { padding-left: 220px; }
  .view { padding: 8px 32px 48px; max-width: 1180px; }
  .page-head { padding-top: 28px; }
}

/* ---- Today ---- */
.today, .col { display: flex; flex-direction: column; gap: 18px; }
.two-col { display: grid; gap: 18px; grid-template-columns: 1fr; }
@media (min-width: 1100px) { .two-col { grid-template-columns: 1fr 1fr; align-items: start; } }
.ring-card { display: flex; align-items: center; gap: 20px; padding: 20px; border-radius: var(--r-card);
             background: var(--navy); color: var(--cream); }
.ring { position: relative; width: 84px; height: 84px; flex: none; }
.ring svg { transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 10; }
.ring .track { stroke: rgba(255, 255, 255, 0.12); }
.ring .fill { stroke: #D9A441; stroke-linecap: round; transition: stroke-dashoffset .6s cubic-bezier(.3,1.3,.5,1); }
.ring-num { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-num b { font: 700 24px/1 var(--serif); font-variant-numeric: tabular-nums; }
.ring-num small { font-size: 11px; color: rgba(243, 234, 215, 0.7); }
.ring-title { font: 600 18px var(--serif); margin-bottom: 4px; }
.streak { display: flex; align-items: center; gap: 5px; font-weight: 600; font-size: 15px; color: rgba(243, 234, 215, 0.8); }
.streak .ic { color: rgba(243, 234, 215, 0.6); }
.streak.on, .streak.on .ic { color: var(--streak); }
.freeze { font-size: 12px; color: rgba(243, 234, 215, 0.65); margin-top: 2px; }
.badge-card { display: flex; align-items: center; gap: 14px; }
.badge-card:hover, .wotd:hover { filter: brightness(0.985); }
.b-title { font-weight: 600; margin: 2px 0 6px; }
.bar { height: 6px; border-radius: 3px; background: var(--fill); overflow: hidden; margin-bottom: 4px; }
.bar div { height: 100%; background: var(--gold); border-radius: 3px; }
.wotd-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 4px 0; }
.wotd-word { font: 700 26px/1.2 var(--serif); }
.queue { list-style: none; margin: 0; padding: 0; }
.queue li + li { border-top: 1px solid var(--separator); }
.queue a { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: baseline; padding: 9px 0; color: inherit; text-decoration: none; font-size: 15px; }
.vault-stats { display: grid; grid-template-columns: repeat(4, 1fr); text-align: center; }
.vault-stats div + div { border-left: 1px solid var(--separator); }
.vault-stats b { display: block; font-size: 22px; font-variant-numeric: tabular-nums; }
.vault-stats small { font-size: 12px; color: var(--secondary); }
.select-btn select { appearance: none; -webkit-appearance: none; min-height: 44px; border: 0; border-radius: 999px; padding: 10px 18px;
  font-weight: 600; font-size: 16px; cursor: pointer; background: color-mix(in srgb, var(--teal) 14%, transparent); color: var(--teal); }

/* ---- Medals ---- */
.medal { width: var(--s); height: var(--s); border-radius: 50%; flex: none; display: inline-flex; align-items: center; justify-content: center;
         background: color-mix(in srgb, var(--secondary) 12%, transparent); color: color-mix(in srgb, var(--secondary) 60%, transparent);
         box-shadow: inset 0 0 0 calc(var(--s) * 0.05) color-mix(in srgb, var(--secondary) 25%, transparent); }
.medal.earned { background: var(--navy); color: #D9A441; box-shadow: inset 0 0 0 calc(var(--s) * 0.05) #D9A441; --badge-bg: var(--navy); }
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 16px 10px; text-align: center; }
.bg { display: flex; flex-direction: column; align-items: center; gap: 4px; }

/* ---- Words ---- */
.toolbar { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; position: sticky; top: 0; z-index: 5;
           background: var(--paper); padding: 6px 0; }
.search { display: flex; align-items: center; gap: 8px; background: var(--fill); border-radius: 12px; padding: 0 12px; color: var(--secondary); }
.search input { flex: 1; min-width: 0; border: 0; background: none; padding: 10px 0; outline: none; color: var(--ink); font-size: 17px; }
.search:focus-within { outline: 3px solid var(--teal); outline-offset: 1px; }
.filters { position: relative; display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.filters select { appearance: none; -webkit-appearance: none; border: 0; border-radius: 999px; padding: 7px 28px 7px 12px; font-size: 14px;
  font-weight: 500; cursor: pointer; background: var(--card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23888' fill='none' stroke-width='1.6'/%3E%3C/svg%3E") no-repeat right 11px center;
  color: var(--ink); }
.word-list { list-style: none; margin: 0; padding: 0; background: var(--card); border-radius: 14px; overflow: hidden; }
.word-list li + li { border-top: 1px solid var(--separator); }
.word-row { display: block; padding: 11px 16px; color: inherit; text-decoration: none; }
.word-row:hover { background: var(--fill); }
.word-row.selected { background: color-mix(in srgb, var(--teal) 14%, transparent); }
.word-row:focus-visible { outline-offset: -3px; }
.wr-top { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.wr-word { font: 700 20px/1.25 var(--serif); }
.wr-meaning { font-size: 15px; margin-top: 2px; }
.wr-prov { font-size: 12px; margin-top: 4px; }
.list-foot { padding: 10px 16px; }
.words-layout.split { display: grid; grid-template-columns: minmax(340px, 420px) 1fr; gap: 24px; align-items: start; }
.words-layout.split .words-detail-col { position: sticky; top: 16px; }

/* ---- Word detail ---- */
.detail { display: flex; flex-direction: column; gap: 18px; padding-bottom: 8px; }
.detail-bar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding-top: 12px; }
.detail-title { font: 700 17px var(--serif); text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-wrap { justify-self: end; position: relative; }
.menu { position: absolute; right: 0; top: 46px; z-index: 30; min-width: 220px; background: var(--card); border-radius: 14px;
        box-shadow: 0 12px 40px rgba(0,0,0,.25); padding: 6px; border: 1px solid var(--separator); }
.menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border: 0; background: none;
               border-radius: 9px; cursor: pointer; text-align: left; font-size: 16px; }
.menu button:hover, .menu button:focus-visible { background: var(--fill); }
.menu .destructive { color: var(--danger); }
.detail-card .flashcard { min-height: 420px; }
.details { display: flex; flex-direction: column; gap: 12px; }
.drow { display: flex; gap: 10px; align-items: flex-start; }
.drow > .ic, .drow > .tier { width: 22px; margin-top: 2px; }
.intents { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 6px; }
.intent { height: 58px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; padding: 0 4px;
          border-radius: 12px; border: 1.5px solid transparent; background: var(--fill); color: var(--secondary); cursor: pointer;
          font-size: 12px; font-weight: 600; }
.intent.on { background: color-mix(in srgb, var(--c) 14%, transparent); border-color: color-mix(in srgb, var(--c) 80%, transparent); color: var(--c); }

/* ---- Flashcard ---- */
.flashcard { perspective: 1400px; display: flex; min-height: 440px; transition: transform .25s; }
.flip { position: relative; flex: 1; transform-style: preserve-3d; transition: transform .45s cubic-bezier(.3,1.25,.5,1); cursor: pointer;
        border-radius: 24px; display: grid; }
.flashcard.flipped .flip { transform: rotateY(180deg); }
.face { grid-area: 1 / 1; backface-visibility: hidden; -webkit-backface-visibility: hidden; background: var(--card); border-radius: 24px;
        box-shadow: var(--shadow); padding: 20px; display: flex; flex-direction: column; min-height: 100%; position: relative; }
.face.back { transform: rotateY(180deg); }
.face-body { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; min-height: 0; }
.face.back .face-body { align-items: stretch; text-align: left; }
.corner { position: absolute; top: 14px; right: 14px; }
.card-word { font: 600 clamp(30px, 7vw, 40px)/1.15 var(--serif); overflow-wrap: anywhere; padding: 0 8px; }
.respell { font-size: 20px; font-weight: 500; color: var(--secondary); }
.respell .stress { color: var(--teal); }
.respell .dot { color: var(--tertiary); }
.ipa { font-size: 20px; color: var(--secondary); }
.ipa.small { font-size: 15px; color: var(--tertiary); }
.hint { font-size: 12px; color: var(--tertiary); }
.big { font-size: 20px; }
.intent-cue { display: flex; align-items: center; gap: 6px; font-size: 15px; font-weight: 500; }
.card-meaning-front { font-size: 20px; white-space: pre-line; max-height: 9.5em; overflow: hidden; }
.back-scroll { overflow-y: auto; max-height: 520px; display: flex; flex-direction: column; gap: 16px; padding-right: 2px; }
.back-head { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; }
.back-head > div { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.back-word { font: 700 28px/1.2 var(--serif); overflow-wrap: anywhere; }
.compact-ph { display: flex; gap: 8px; flex-wrap: wrap; font-size: 15px; }
.compact-ph .respell { font-size: 15px; }
.compact-ph .ipa { font-size: 15px; color: var(--tertiary); }
.section .label { font-size: 13px; font-variant: small-caps; text-transform: lowercase; letter-spacing: .3px; color: var(--secondary); margin-bottom: 4px; }
.meaning { white-space: pre-line; }
.example { font-style: italic; font-size: 15px; margin: 4px 0; }
.translation + .translation { margin-top: 10px; }
.tr-lang { font-size: 13px; font-weight: 600; color: var(--secondary); }
.prov { margin-top: 12px; padding-top: 8px; border-top: 1px solid var(--separator); text-align: center; font-size: 12px; color: var(--secondary); }

.answer-row { display: flex; gap: 12px; }
.answer-row .btn { flex: 1; padding: 10px 8px; min-width: 0; }
@media (max-width: 380px) { .answer-row .btn { font-size: 15px; gap: 4px; } .answer-row .btn .ic { display: none; } }

/* ---- Review session (full-screen cover) ---- */
body.in-session { overflow: hidden; }
.session { position: fixed; inset: 0; z-index: 50; background: var(--paper); overflow-y: auto; display: flex; flex-direction: column;
           padding-bottom: env(safe-area-inset-bottom); animation: rise .25s ease-out; }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } }
.session-bar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 8px var(--gutter); padding-top: max(8px, env(safe-area-inset-top)); }
.session-title { font-weight: 600; }
.session-body { flex: 1; display: flex; flex-direction: column; gap: 14px; width: 100%; max-width: 600px; margin: 0 auto; padding: 0 var(--gutter) 16px; }
.progress { height: 4px; background: var(--fill); border-radius: 2px; overflow: hidden; }
.progress div { height: 100%; background: var(--teal); transition: width .3s; }
.card-stage { position: relative; flex: 1; display: flex; min-height: 0; touch-action: pan-y; }
.card-stage .flashcard { flex: 1; min-height: min(62vh, 560px); }
.swipe-hint { position: absolute; top: 28px; font: 900 20px var(--sans); padding: 4px 12px; border: 3px solid; border-radius: 10px; pointer-events: none; opacity: 0; }
.swipe-hint.got { left: 28px; color: var(--teal); transform: rotate(-12deg); opacity: var(--got, 0); }
.swipe-hint.learn { right: 28px; color: var(--gold); transform: rotate(12deg); opacity: var(--learn, 0); }
.kbd-help { text-align: center; }
.summary { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; padding: 24px var(--gutter);
           max-width: 560px; width: 100%; margin: 0 auto; position: relative; }
.summary h2 { font-size: 26px; }
.summary-icon { color: var(--teal); }
.summary-card { width: 100%; border-radius: 16px; display: flex; flex-direction: column; gap: 10px; }
.srow { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: start; font-size: 15px; }
.srow .ic { color: var(--teal); }
.srow .up { transform: rotate(180deg); }
.srow b { font-weight: 400; color: var(--secondary); text-align: right; }
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 60; }
.confetti i { position: absolute; top: -12px; width: 8px; height: 12px; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { top: 105%; transform: rotate(720deg) translateX(40px); } }

/* ---- Quiz ---- */
.quiz { display: flex; flex-direction: column; gap: 16px; max-width: 640px; }
.quiz-meta { display: flex; justify-content: space-between; }
.quiz .q { font-size: 17px; font-weight: 600; }
.prompt { white-space: pre-line; border-radius: 12px; }
.options { display: flex; flex-direction: column; gap: 10px; }
.option { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 12px; border: 0; background: var(--card);
          text-align: left; cursor: pointer; font-size: 17px; min-height: 52px; }
.option span { flex: 1; }
.option:hover:not(:disabled) { background: color-mix(in srgb, var(--teal) 8%, var(--card)); }
.option:disabled { cursor: default; }
.option.right { background: color-mix(in srgb, var(--good) 20%, var(--card)); }
.option.right .ic { color: var(--good); }
.option.wrong { background: color-mix(in srgb, var(--danger) 20%, var(--card)); }
.option.wrong .ic { color: var(--danger); }
.quiz-result { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 40px 0; }
.quiz-result .score { font-size: 34px; }

/* ---- Stats, settings ---- */
.stats .card h2, .settings .card h2 { margin-bottom: 12px; }
.stat-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; justify-content: space-between; }
.stat-row > span:first-of-type { flex: 1; }
.stat-row > .ic + span { flex: 1; }
.stat-row b { font-variant-numeric: tabular-nums; color: var(--secondary); }
.bar-row { display: grid; grid-template-columns: 112px 1fr 40px; align-items: center; gap: 10px; padding: 5px 0; font-size: 13px; }
.bar-label { font-weight: 600; display: flex; align-items: center; gap: 5px; white-space: nowrap; overflow: hidden; }
.bar-track { height: 12px; }
.bar-fill { display: block; height: 12px; border-radius: 6px; }
.bar-num { text-align: right; color: var(--secondary); font-variant-numeric: tabular-nums; }
.settings { display: flex; flex-direction: column; gap: 18px; max-width: 640px; }
.settings .stat-row b { max-width: 60%; overflow-wrap: anywhere; text-align: right; font-weight: 400; }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--fill); border-radius: 10px; padding: 2px; }
.segmented button { border: 0; background: none; padding: 8px; border-radius: 8px; cursor: pointer; font-size: 15px; font-weight: 500; }
.segmented button.on { background: var(--card); box-shadow: 0 1px 4px rgba(0,0,0,.12); }

/* ---- Sheets / dialogs ---- */
dialog.sheet { border: 0; padding: 0; background: var(--card); color: var(--ink); border-radius: 22px; width: min(520px, calc(100vw - 32px));
               max-height: calc(100vh - 48px); box-shadow: 0 24px 80px rgba(0,0,0,.35); }
dialog.sheet::backdrop { background: rgba(5, 10, 20, 0.45); }
dialog.sheet form { padding: 18px 20px 22px; }
.sheet-bar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; margin: -4px -4px 12px; }
.sheet-bar h2 { font-size: 17px; font-weight: 600; }
.sheet-bar .link-btn:last-child { justify-self: end; }
.field { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; }
.field .label { font-size: 13px; text-transform: uppercase; letter-spacing: .4px; color: var(--secondary); font-weight: 500; }
.field input, .field textarea { width: 100%; border: 1px solid var(--separator); background: var(--paper); border-radius: 12px; padding: 12px 14px;
  font-size: 17px; color: var(--ink); }
.field input:focus, .field textarea:focus { outline: 3px solid var(--teal); outline-offset: 0; border-color: transparent; }
.confirm h2 { font: 700 22px var(--serif); margin-bottom: 8px; }
.badge-earned { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.badge-earned .eyebrow { color: var(--gold); }
.be { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.be h2, .badge-earned > h2 { font: 700 26px var(--serif); }
.toast { position: fixed; left: 50%; bottom: calc(88px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); z-index: 70;
         background: var(--ink); color: var(--paper); padding: 10px 18px; border-radius: 999px; font-size: 15px; font-weight: 500;
         opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; max-width: calc(100vw - 32px); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (min-width: 860px) { .toast { bottom: 28px; margin-left: 110px; } }

/* ---- Signed-out welcome ---- */
.welcome { max-width: 980px; margin: 0 auto; padding: 0 var(--gutter) 40px; }
.welcome-top { padding: 18px 0; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font: 700 21px var(--serif); }
.brand img { border-radius: 9px; }
.welcome-hero { max-width: 560px; margin: 28px auto 0; text-align: center; }
.welcome-hero .eyebrow { color: var(--gold); }
.welcome-hero h1 { font: 700 clamp(34px, 7vw, 50px)/1.1 var(--serif); margin: 10px 0 14px; text-wrap: balance; }
.lede { color: var(--secondary); font-size: 18px; }
.signin-card { margin: 28px 0 12px; padding: 20px; text-align: left; box-shadow: var(--shadow); }
.signin .field { margin-top: 0; margin-bottom: 14px; }
.signin p { margin-bottom: 12px; }
.code-input { font: 600 28px/1 ui-monospace, "SF Mono", Menlo, monospace !important; letter-spacing: 10px; text-align: center; }
.fine { color: var(--tertiary); font-size: 14px; }
.welcome-steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin: 48px 0 32px; }
.step { display: flex; gap: 12px; background: var(--card); border-radius: var(--r-card); padding: 18px; }
.step .num { flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--navy); color: #D9A441; display: flex;
             align-items: center; justify-content: center; font: 700 15px var(--serif); }
.step h2 { font-size: 17px; margin-bottom: 4px; }
.step p { color: var(--secondary); font-size: 15px; }
.welcome-apps { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }
.store { display: inline-flex; flex-direction: column; align-items: flex-start; background: var(--ink); color: var(--paper); text-decoration: none;
         padding: 9px 20px; border-radius: 12px; font-weight: 600; font-size: 18px; line-height: 1.15; }
.store small { font-size: 11px; font-weight: 400; letter-spacing: .4px; }
.store.soon { background: var(--fill); color: var(--secondary); }
.welcome-foot { margin-top: 48px; padding-top: 20px; border-top: 1px solid var(--separator); color: var(--secondary); font-size: 14px; text-align: center; }
.welcome-foot nav { display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; margin-bottom: 8px; }
.welcome-foot a { color: var(--secondary); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  .flashcard.flipped .flip { transform: none; }
  .face.back { transform: none; }
  .flashcard .face.back { visibility: hidden; }
  .flashcard.flipped .face.back { visibility: visible; }
  .flashcard.flipped .face.front { visibility: hidden; }
}
.flip:focus-visible { outline-offset: 4px; border-radius: 26px; }
