/* ---------- tokens ---------- */
:root {
  --bg: #f6f7fb;
  --bg-glow: rgba(99, 102, 241, .10);
  --surface: #ffffff;
  --surface-2: #f1f3f9;
  --surface-3: #e8ebf4;
  --text: #0f172a;
  --muted: #64748b;
  --faint: #94a3b8;
  --line: #e4e8f0;
  --brand: #4f46e5;
  --brand-2: #7c3aed;
  --brand-soft: #eef2ff;
  --brand-text: #4338ca;
  --know: #059669;
  --know-soft: #ecfdf5;
  --know-line: #a7f3d0;
  --again: #d97706;
  --again-soft: #fffbeb;
  --again-line: #fcd34d;
  --danger: #e11d48;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px -6px rgba(15, 23, 42, .08);
  --shadow-lg: 0 2px 6px rgba(15, 23, 42, .05), 0 24px 48px -12px rgba(15, 23, 42, .18);
  --shadow-brand: 0 8px 20px -6px rgba(79, 70, 229, .45);
  --r-sm: 10px;
  --r: 16px;
  --r-lg: 24px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0b1020;
  --bg-glow: rgba(99, 102, 241, .16);
  --surface: #121a2e;
  --surface-2: #19223a;
  --surface-3: #222c47;
  --text: #e5e9f2;
  --muted: #94a3b8;
  --faint: #64748b;
  --line: #1f2a44;
  --brand: #818cf8;
  --brand-2: #a78bfa;
  --brand-soft: rgba(99, 102, 241, .16);
  --brand-text: #a5b4fc;
  --know: #34d399;
  --know-soft: rgba(16, 185, 129, .13);
  --know-line: rgba(52, 211, 153, .4);
  --again: #fbbf24;
  --again-soft: rgba(245, 158, 11, .13);
  --again-line: rgba(251, 191, 36, .4);
  --danger: #fb7185;
  --shadow-sm: none;
  --shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 8px 24px -8px rgba(0, 0, 0, .5);
  --shadow-lg: 0 24px 60px -12px rgba(0, 0, 0, .7);
  --shadow-brand: 0 8px 24px -6px rgba(99, 102, 241, .55);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1020;
    --bg-glow: rgba(99, 102, 241, .16);
    --surface: #121a2e;
    --surface-2: #19223a;
    --surface-3: #222c47;
    --text: #e5e9f2;
    --muted: #94a3b8;
    --faint: #64748b;
    --line: #1f2a44;
    --brand: #818cf8;
    --brand-2: #a78bfa;
    --brand-soft: rgba(99, 102, 241, .16);
    --brand-text: #a5b4fc;
    --know: #34d399;
    --know-soft: rgba(16, 185, 129, .13);
    --know-line: rgba(52, 211, 153, .4);
    --again: #fbbf24;
    --again-soft: rgba(245, 158, 11, .13);
    --again-line: rgba(251, 191, 36, .4);
    --danger: #fb7185;
    --shadow-sm: none;
    --shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 8px 24px -8px rgba(0, 0, 0, .5);
    --shadow-lg: 0 24px 60px -12px rgba(0, 0, 0, .7);
    --shadow-brand: 0 8px 24px -6px rgba(99, 102, 241, .55);
    color-scheme: dark;
  }
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(900px 420px at 10% -10%, var(--bg-glow), transparent 70%),
    radial-gradient(700px 380px at 100% 0%, rgba(124, 58, 237, .07), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 15px/1.6 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  transition: background-color .3s, color .3s;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
svg .fill { fill: currentColor; stroke: none; }
.wrap { max-width: 920px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
b, strong { font-weight: 600; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
::selection { background: color-mix(in srgb, var(--brand) 25%, transparent); }
kbd {
  font: 600 11px/1 "JetBrains Mono", ui-monospace, monospace; color: var(--faint);
  border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px; padding: 3px 6px; background: var(--surface);
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); background: var(--surface); border-radius: 12px;
  padding: 10px 18px; font-weight: 600; font-size: 14px;
  transition: transform .15s var(--ease), background .2s, box-shadow .2s, border-color .2s, opacity .2s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.97); }
.btn.primary {
  border: 0; color: #fff;
  background: linear-gradient(135deg, #6366f1, #7c3aed);
  box-shadow: var(--shadow-brand);
}
.btn.primary:hover { background: linear-gradient(135deg, #5458ee, #6d28d9); box-shadow: 0 10px 24px -6px rgba(79, 70, 229, .55); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 7px 14px; font-size: 13px; border-radius: 10px; }
.btn:disabled { opacity: .55; cursor: default; transform: none; }
.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px; flex: none;
  border: 1px solid var(--line); background: var(--surface); border-radius: 12px; color: var(--muted);
  transition: background .2s, color .2s, transform .15s var(--ease);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn:active { transform: scale(.92); }
.icon-btn.sm { width: 32px; height: 32px; border-radius: 10px; border-color: transparent; background: transparent; }
.link { border: 0; background: none; padding: 0; color: var(--brand-text); font-weight: 600; font-size: 13.5px; }
.link:hover { text-decoration: underline; }

/* ---------- header ---------- */
.top {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  backdrop-filter: saturate(1.6) blur(14px);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid var(--line);
}
.top-row { display: flex; align-items: center; gap: 12px; height: 64px; }
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; margin-right: auto; }
.logo {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; flex: none;
  background: linear-gradient(135deg, #6366f1, #8b5cf6); color: #fff; font-weight: 800; font-size: 14px; letter-spacing: .02em;
  box-shadow: var(--shadow-brand);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-text b { font-weight: 800; letter-spacing: -.02em; white-space: nowrap; }
.brand-text small { font-size: 12px; color: var(--muted); white-space: nowrap; }

.tabs {
  position: relative; display: flex; gap: 2px; padding: 4px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px;
}
.tabs button {
  position: relative; z-index: 1; display: flex; align-items: center; gap: 7px;
  border: 0; background: none; padding: 7px 14px; border-radius: 10px;
  font-size: 13.5px; font-weight: 600; color: var(--muted); transition: color .25s;
}
.tabs button svg { width: 16px; height: 16px; }
.tabs button:hover, .tabs button.on { color: var(--text); }
.tab-ind {
  position: absolute; z-index: 0; top: 4px; bottom: 4px; left: 0; width: 0;
  background: var(--surface); border-radius: 10px; box-shadow: var(--shadow-sm), 0 0 0 1px var(--line);
  transition: transform .35s var(--spring), width .35s var(--spring);
}

.top-actions { display: flex; align-items: center; gap: 8px; }
.lang {
  position: relative; display: flex; padding: 3px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2);
}
.lang button {
  position: relative; z-index: 1; border: 0; background: none; width: 36px; padding: 5px 0;
  font-size: 12px; font-weight: 700; color: var(--muted); border-radius: 9px; transition: color .25s;
}
.lang button.on { color: #fff; }
.lang-thumb {
  position: absolute; top: 3px; left: 3px; width: 36px; bottom: 3px; border-radius: 9px;
  background: linear-gradient(135deg, #6366f1, #7c3aed); box-shadow: var(--shadow-brand);
  transition: transform .35s var(--spring);
}
.lang[data-lang="pl"] .lang-thumb { transform: translateX(36px); }

#theme-btn svg { transition: transform .5s var(--spring), opacity .3s; position: absolute; }
#theme-btn { position: relative; }
.i-moon { opacity: 0; transform: rotate(-90deg) scale(.5); }
:root[data-theme="dark"] .i-sun { opacity: 0; transform: rotate(90deg) scale(.5); }
:root[data-theme="dark"] .i-moon { opacity: 1; transform: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .i-sun { opacity: 0; transform: rotate(90deg) scale(.5); }
  :root:not([data-theme="light"]) .i-moon { opacity: 1; transform: none; }
}

.account {
  display: flex; align-items: center; gap: 8px; max-width: 220px; height: 38px;
  border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 0 12px 0 5px;
  font-size: 13px; font-weight: 600; transition: background .2s;
}
.account:hover { background: var(--surface-2); }
.avatar {
  display: grid; place-items: center; width: 28px; height: 28px; border-radius: 9px; flex: none;
  background: var(--brand-soft); color: var(--brand-text); font-size: 12px; font-weight: 800; text-transform: uppercase;
}
.avatar svg { width: 15px; height: 15px; }
#account-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; transition: background .3s; }
.sync-dot.ok { background: var(--know); box-shadow: 0 0 0 3px var(--know-soft); }
.sync-dot.pending { background: var(--again); animation: pulse 1s ease-in-out infinite; }
.sync-dot.off { background: var(--danger); }
.sync-dot.local { display: none; }
@keyframes pulse { 50% { transform: scale(.6); opacity: .5; } }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: auto repeat(3, 1fr); gap: 12px; margin: 22px 0 14px; }
.ring-card, .stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow);
}
.ring-card { position: relative; display: grid; place-items: center; width: 108px; height: 100%; min-height: 96px; padding: 10px; }
.ring { width: 84px; height: 84px; transform: rotate(-90deg); overflow: visible; }
.ring circle { fill: none; stroke-width: 7; stroke-linecap: round; }
.ring-bg { stroke: var(--surface-3); }
.ring-know, .ring-again { stroke-dasharray: 169.65; stroke-dashoffset: 169.65; transition: stroke-dashoffset .9s var(--ease); }
.ring-know { stroke: var(--know); }
.ring-again { stroke: var(--again); }
.ring-label { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; line-height: 1.1; }
.ring-label b { font-size: 19px; font-weight: 800; letter-spacing: -.02em; }
.ring-label small { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.stat { display: flex; flex-direction: column; justify-content: center; gap: 2px; padding: 14px 16px; overflow: hidden; position: relative; }
.stat b { font-size: 26px; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat small { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.stat-ic { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 10px; margin-bottom: 6px; }
.stat-ic svg { width: 16px; height: 16px; }
.stat.know .stat-ic { background: var(--know-soft); color: var(--know); }
.stat.again .stat-ic { background: var(--again-soft); color: var(--again); }
.stat.fresh .stat-ic { background: var(--brand-soft); color: var(--brand-text); }
.stat.bump b { animation: bump .45s var(--spring); }
@keyframes bump { 40% { transform: scale(1.18); } }

/* ---------- banner ---------- */
.banner {
  display: flex; align-items: center; gap: 14px; margin: 0 0 16px; padding: 14px 16px;
  background: linear-gradient(135deg, var(--brand-soft), color-mix(in srgb, var(--brand-soft) 40%, var(--surface)));
  border: 1px solid color-mix(in srgb, var(--brand) 22%, var(--line)); border-radius: var(--r-lg);
  animation: rise .5s var(--ease) both;
}
.banner-ic { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: var(--surface); color: var(--brand-text); flex: none; box-shadow: var(--shadow-sm); }
.banner-text { display: flex; flex-direction: column; flex: 1; min-width: 0; line-height: 1.35; }
.banner-text small { color: var(--muted); font-size: 13px; margin-top: 2px; }
.banner-actions { display: flex; align-items: center; gap: 4px; flex: none; }

/* ---------- views ---------- */
.view { animation: viewIn .45s var(--ease) both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(10px); } }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.toolbar { display: flex; flex-direction: column; gap: 12px; padding: 14px; margin-bottom: 16px; }
.toolbar-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.toolbar-actions { display: flex; align-items: center; gap: 12px; }

.search {
  display: flex; align-items: center; gap: 10px; padding: 0 12px; height: 46px;
  background: var(--surface-2); border: 1px solid transparent; border-radius: 14px; transition: border-color .2s, box-shadow .2s, background .2s;
}
.search:focus-within { background: var(--surface); border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
.search svg { color: var(--faint); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; font-size: 14.5px; }
.search input::-webkit-search-cancel-button { cursor: pointer; }

.seg { display: inline-flex; flex-wrap: wrap; gap: 3px; padding: 4px; background: var(--surface-2); border-radius: 13px; }
.seg button {
  border: 0; background: none; padding: 6px 13px; border-radius: 10px; font-size: 13px; font-weight: 600; color: var(--muted);
  transition: background .2s, color .2s, box-shadow .2s;
}
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm), 0 0 0 1px var(--line); }
.seg button .cnt { margin-left: 5px; font-size: 11.5px; color: var(--faint); font-variant-numeric: tabular-nums; }

.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; -webkit-mask-image: linear-gradient(90deg, #000 92%, transparent); mask-image: linear-gradient(90deg, #000 92%, transparent); }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 5px 12px; font-size: 12.5px; font-weight: 600; color: var(--muted); white-space: nowrap;
  transition: background .2s, color .2s, border-color .2s, transform .15s var(--ease);
}
.chip:hover { color: var(--text); border-color: color-mix(in srgb, var(--brand) 35%, var(--line)); }
.chip:active { transform: scale(.95); }
.chip.on { background: linear-gradient(135deg, #6366f1, #7c3aed); border-color: transparent; color: #fff; box-shadow: var(--shadow-brand); }

.switch { display: inline-flex; align-items: center; gap: 9px; font-size: 13.5px; font-weight: 600; color: var(--muted); cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track { position: relative; width: 38px; height: 22px; border-radius: 999px; background: var(--surface-3); transition: background .25s; flex: none; }
.switch .knob { position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .3s var(--spring); }
.switch input:checked + .track { background: linear-gradient(135deg, #6366f1, #7c3aed); }
.switch input:checked + .track .knob { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---------- question list ---------- */
.qlist { display: flex; flex-direction: column; gap: 10px; }
.group-title {
  display: flex; align-items: center; gap: 10px; margin: 18px 4px 2px;
  font-size: 12px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--faint);
}
.group-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.group-title span { color: var(--muted); letter-spacing: 0; text-transform: none; font-weight: 600; }
.q {
  background: var(--surface); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow-sm);
  transition: border-color .25s, box-shadow .25s, transform .25s var(--ease);
}
.q:hover { border-color: color-mix(in srgb, var(--brand) 30%, var(--line)); box-shadow: var(--shadow); }
.q.open { box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--brand) 28%, var(--line)); }
.qlist.animate .q, .qlist.animate .group-title { animation: rise .45s var(--ease) both; animation-delay: calc(min(var(--i, 0), 14) * 28ms); }
.q-head {
  display: grid; grid-template-columns: 40px 1fr 20px; gap: 14px; align-items: center; width: 100%;
  border: 0; background: none; text-align: left; padding: 14px 16px; border-radius: 20px;
}
.q-num {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px;
  background: var(--surface-2); color: var(--muted); font: 700 13.5px/1 "JetBrains Mono", ui-monospace, monospace;
  transition: background .25s, color .25s;
}
.q.s-know .q-num { background: var(--know-soft); color: var(--know); }
.q.s-again .q-num { background: var(--again-soft); color: var(--again); }
.q-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.q-title { font-weight: 600; line-height: 1.4; transition: color .2s; }
.q-head:hover .q-title { color: var(--brand-text); }
.q-alt { font-size: 12.5px; color: var(--faint); font-style: italic; line-height: 1.4; }
.chev { color: var(--faint); transition: transform .35s var(--spring), color .2s; }
.q.open .chev { transform: rotate(180deg); color: var(--brand-text); }
.q-body { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .4s var(--ease); }
.q.open .q-body { grid-template-rows: 1fr; }
.q-inner { overflow: hidden; min-height: 0; }
.q-content { padding: 0 18px 18px 70px; opacity: 0; transform: translateY(-6px); transition: opacity .3s .05s, transform .35s var(--ease); }
.q.open .q-content { opacity: 1; transform: none; }
.q-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.tag { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--brand-soft); color: var(--brand-text); }
.tag.know { background: var(--know-soft); color: var(--know); }
.tag.again { background: var(--again-soft); color: var(--again); }
.tag svg { width: 12px; height: 12px; stroke-width: 2.6; }
.status-pill { font-size: 11.5px; font-weight: 700; padding: 2px 9px; border-radius: 999px; align-self: flex-start; }

.answer { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 9px; }
.answer li { position: relative; padding-left: 18px; line-height: 1.6; }
.answer li::before {
  content: ""; position: absolute; left: 2px; top: .62em; width: 7px; height: 7px; border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6); opacity: .75;
}
.answer b { font-weight: 700; color: var(--text); }
mark { background: color-mix(in srgb, var(--again) 28%, transparent); color: inherit; border-radius: 4px; padding: 0 2px; }

.marks { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.mark-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1.5px solid var(--line); background: var(--surface); border-radius: 12px; padding: 8px 14px;
  font-size: 13.5px; font-weight: 600; color: var(--muted);
  transition: background .2s, color .2s, border-color .2s, transform .15s var(--ease), box-shadow .2s;
}
.mark-btn svg { width: 16px; height: 16px; }
.mark-btn:active { transform: scale(.95); }
.mark-btn.again:hover, .mark-btn.again.on { border-color: var(--again-line); color: var(--again); background: var(--again-soft); }
.mark-btn.know:hover, .mark-btn.know.on { border-color: var(--know-line); color: var(--know); background: var(--know-soft); }
.mark-btn.on { box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 12%, transparent); }
.mark-btn.pop { animation: pop .4s var(--spring); }
@keyframes pop { 40% { transform: scale(1.1); } }
.mark-btn.neutral:hover { border-color: color-mix(in srgb, var(--brand) 40%, var(--line)); color: var(--brand-text); background: var(--brand-soft); }

.empty {
  display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 48px 16px; text-align: center; color: var(--muted);
  background: var(--surface); border: 1px dashed var(--line); border-radius: var(--r-lg); animation: rise .4s var(--ease) both;
}
.empty svg { width: 34px; height: 34px; color: var(--faint); }

/* ---------- cards ---------- */
.deck-head h2, .done h2 { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.deck-head p { margin: 4px 0 16px; font-size: 13.5px; }
.toolbar.compact { gap: 10px; }
.deck-progress { display: flex; align-items: center; gap: 12px; margin: 4px 2px 14px; font-size: 13px; font-weight: 600; color: var(--muted); }
.dp-bar { flex: 1; height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.dp-bar i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, #6366f1, #8b5cf6); transition: width .6s var(--ease); }
.dp-count { font-variant-numeric: tabular-nums; }

.stage { position: relative; max-width: 680px; margin: 0 auto; perspective: 1600px; }
.stage::before, .stage::after {
  content: ""; position: absolute; left: 6%; right: 6%; top: 10px; bottom: -10px; z-index: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: 26px; opacity: .6;
  transform: scale(.96) translateY(6px);
}
.stage::after { left: 12%; right: 12%; bottom: -20px; opacity: .35; transform: scale(.92) translateY(14px); }
.stage.single::before, .stage.single::after { display: none; }
.flip {
  position: relative; z-index: 1; touch-action: pan-y; cursor: pointer; user-select: none; -webkit-user-select: none;
  transition: transform .45s var(--ease), opacity .45s var(--ease);
}
.flip.dragging { transition: none; }
.flip.enter { animation: cardIn .5s var(--spring) both; }
@keyframes cardIn { from { opacity: 0; transform: translateY(24px) scale(.94); } }
.flip.out-right { transform: translateX(120%) rotate(16deg); opacity: 0; }
.flip.out-left { transform: translateX(-120%) rotate(-16deg); opacity: 0; }
.flip-inner {
  display: grid; transform-style: preserve-3d; transition: transform .65s var(--ease);
}
.flip-inner.flipped { transform: rotateY(180deg); }
.face {
  grid-area: 1 / 1; height: clamp(360px, 60vh, 540px); min-height: 0; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: 26px; box-shadow: var(--shadow-lg);
  padding: 24px; backface-visibility: hidden; -webkit-backface-visibility: hidden;
}
.face.front { border-color: color-mix(in srgb, var(--brand) 25%, var(--line)); background:
  radial-gradient(500px 220px at 50% 0%, var(--brand-soft), transparent 70%), var(--surface); }
.face.back { transform: rotateY(180deg); }
.face-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.num-badge { font: 700 13px/1 "JetBrains Mono", ui-monospace, monospace; padding: 7px 11px; border-radius: 10px; background: var(--brand-soft); color: var(--brand-text); }
.face-cat { font-size: 12.5px; color: var(--muted); font-weight: 600; text-align: right; }
.face-q { margin: auto 0; padding: 30px 6px; text-align: center; }
.face-q h2 { margin: 0; font-size: clamp(19px, 3.2vw, 25px); line-height: 1.35; font-weight: 800; letter-spacing: -.02em; text-wrap: balance; }
.face-q p { margin: 12px 0 0; font-size: 14px; color: var(--muted); font-style: italic; text-wrap: balance; }
.face-hint { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--brand-text); }
.face-hint svg { width: 16px; height: 16px; animation: spinHint 2.6s var(--ease) infinite; }
@keyframes spinHint { 0%, 60% { transform: rotate(0); } 85%, 100% { transform: rotate(180deg); } }
.back-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-bottom: 12px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.back-title { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .07em; color: var(--know); }
.back-q { font-size: 13px; color: var(--muted); font-weight: 600; margin: -4px 0 12px; line-height: 1.45; flex: none; }
.back-head { flex: none; }
.back-scroll {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; margin: 0 -10px; padding: 0 10px 18px;
  -webkit-mask-image: linear-gradient(#000 calc(100% - 28px), transparent); mask-image: linear-gradient(#000 calc(100% - 28px), transparent);
  scrollbar-width: thin;
}
.stamp {
  position: absolute; z-index: 3; top: 26px; padding: 6px 14px; border-radius: 12px; border: 3px solid;
  font-size: 18px; font-weight: 900; letter-spacing: .06em; text-transform: uppercase; opacity: 0; pointer-events: none;
  background: var(--surface);
}
.stamp.know { right: 22px; color: var(--know); border-color: var(--know); transform: rotate(10deg); }
.stamp.again { left: 22px; color: var(--again); border-color: var(--again); transform: rotate(-10deg); }

.card-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; max-width: 680px; margin: 30px auto 0; }
.card-actions .mark-btn { padding: 14px; font-size: 15px; border-radius: 16px; border-width: 1.5px; }
.card-actions .mark-btn svg { width: 18px; height: 18px; }
.card-actions .mark-btn.again { border-color: var(--again-line); color: var(--again); background: var(--again-soft); }
.card-actions .mark-btn.know { border-color: var(--know-line); color: var(--know); background: var(--know-soft); }
.card-actions .mark-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.card-actions kbd { margin-left: 2px; }
.card-foot { display: flex; align-items: center; justify-content: space-between; max-width: 680px; margin: 12px auto 0; font-size: 13px; }
.skip { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; color: var(--muted); font-weight: 600; padding: 6px 4px; border-radius: 8px; }
.skip:hover:not(:disabled) { color: var(--text); }
.skip:disabled { opacity: .4; cursor: default; }
.skip svg { width: 16px; height: 16px; transition: transform .2s var(--ease); }
.skip:hover:not(:disabled) svg { transform: translateX(3px); }
.keys { color: var(--faint); font-size: 12px; display: flex; gap: 6px; align-items: center; }
.swipe-hint { display: none; align-items: center; gap: 6px; color: var(--faint); font-size: 12.5px; font-weight: 600; }
.swipe-hint svg { width: 15px; height: 15px; }
.ring-know.zero, .ring-again.zero { opacity: 0; }

.done {
  max-width: 560px; margin: 8px auto 0; text-align: center; padding: 40px 24px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 26px; box-shadow: var(--shadow-lg);
  animation: cardIn .55s var(--spring) both;
}
.done-ic { display: inline-grid; place-items: center; width: 64px; height: 64px; border-radius: 20px; margin-bottom: 14px; background: linear-gradient(135deg, #10b981, #34d399); color: #fff; box-shadow: 0 10px 24px -8px rgba(16, 185, 129, .6); }
.done-ic.plain { background: var(--surface-2); color: var(--faint); box-shadow: none; }
.done-ic svg { width: 30px; height: 30px; stroke-width: 2.4; }
.done p { margin: 6px 0 0; }
.done-stats { display: flex; justify-content: center; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.done .toolbar-row { justify-content: center; margin-top: 22px; }

/* ---------- ticket ---------- */
.hero {
  position: relative; overflow: hidden; display: flex; align-items: center; justify-content: space-between; gap: 24px;
  padding: 28px; border-radius: 28px; color: #fff; margin-bottom: 18px;
  background: linear-gradient(125deg, #4f46e5 0%, #6d28d9 55%, #9333ea 100%);
  box-shadow: 0 20px 40px -16px rgba(79, 70, 229, .6);
}
.hero::before, .hero::after { content: ""; position: absolute; border-radius: 50%; background: rgba(255, 255, 255, .09); pointer-events: none; }
.hero::before { width: 320px; height: 320px; right: -80px; top: -140px; animation: float 9s ease-in-out infinite; }
.hero::after { width: 180px; height: 180px; left: 38%; bottom: -110px; animation: float 11s ease-in-out infinite reverse; }
@keyframes float { 50% { transform: translate(-18px, 14px); } }
.hero-text { position: relative; z-index: 1; max-width: 520px; }
.hero-badge { display: inline-block; padding: 4px 11px; border-radius: 999px; background: rgba(255, 255, 255, .18); font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; backdrop-filter: blur(4px); }
.hero h2 { margin: 10px 0 6px; font-size: 27px; font-weight: 800; letter-spacing: -.02em; }
.hero p { margin: 0 0 16px; font-size: 14px; color: rgba(255, 255, 255, .82); line-height: 1.55; }
.switch.light { color: rgba(255, 255, 255, .9); }
.switch.light .track { background: rgba(255, 255, 255, .25); }
.switch.light input:checked + .track { background: #fff; }
.switch.light input:checked + .track .knob { background: #6d28d9; }
.hero-side { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: stretch; gap: 12px; flex: none; }
.hero-btn {
  border: 0; background: #fff; color: #4338ca; padding: 16px 24px; border-radius: 18px; font-size: 15px; font-weight: 800;
  box-shadow: 0 12px 28px -10px rgba(0, 0, 0, .45);
}
.hero-btn:hover { background: #fff; transform: translateY(-2px); }
.hero-btn svg { width: 20px; height: 20px; }
.hero-btn.rolling svg { animation: roll .6s var(--ease); }
@keyframes roll { to { transform: rotate(360deg) scale(1.1); } }
.timer {
  display: flex; align-items: center; justify-content: center; gap: 10px; padding: 8px 12px; border-radius: 14px;
  background: rgba(255, 255, 255, .15); backdrop-filter: blur(6px); animation: rise .4s var(--ease) both;
}
.timer > svg { width: 18px; height: 18px; opacity: .85; }
#timer-value { font: 700 20px/1 "JetBrains Mono", ui-monospace, monospace; letter-spacing: .02em; min-width: 62px; text-align: center; }
.timer-btn { display: grid; place-items: center; width: 30px; height: 30px; border: 0; border-radius: 9px; background: rgba(255, 255, 255, .18); color: #fff; transition: background .2s; }
.timer-btn:hover { background: rgba(255, 255, 255, .3); }
.timer-btn svg { width: 14px; height: 14px; }

.ticket { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
.tq {
  position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px;
  box-shadow: var(--shadow); overflow: hidden;
}
.tq::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: linear-gradient(90deg, #6366f1, #a855f7); }
.tq.deal { animation: deal .6s var(--spring) both; }
.tq.deal:nth-child(2) { animation-delay: .12s; }
@keyframes deal { from { opacity: 0; transform: translateY(40px) rotate(-4deg) scale(.95); } }
.tq-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.tq h3 { margin: 0 0 6px; font-size: 18px; line-height: 1.4; font-weight: 800; letter-spacing: -.01em; }
.tq .q-alt { display: block; }
.tq .q-body { margin-top: 0; }
.tq.shown .q-body { grid-template-rows: 1fr; }
.tq .q-content { padding: 14px 0 0; }
.tq.shown .q-content { opacity: 1; transform: none; }
.ticket-empty { grid-column: 1 / -1; }

/* ---------- toasts & confetti ---------- */
.toasts { position: fixed; z-index: 60; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast {
  display: flex; align-items: center; gap: 9px; padding: 10px 16px; border-radius: 14px; font-size: 13.5px; font-weight: 600;
  background: #0f172a; color: #f8fafc; box-shadow: 0 12px 30px -8px rgba(0, 0, 0, .45);
  animation: toastIn .45s var(--spring) both;
}
:root[data-theme="dark"] .toast { background: #e2e8f0; color: #0f172a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .toast { background: #e2e8f0; color: #0f172a; } }
.toast svg { width: 16px; height: 16px; }
.toast.know svg { color: #34d399; } .toast.again svg { color: #fbbf24; }
.toast.out { animation: toastOut .3s var(--ease) forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(16px) scale(.9); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(8px) scale(.95); } }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 70; overflow: hidden; }
.confetti i { position: absolute; top: -12px; width: 9px; height: 14px; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { transform: translate(var(--dx), 105vh) rotate(var(--rot)); opacity: .9; } }

/* ---------- dialogs ---------- */
dialog {
  border: 1px solid var(--line); border-radius: 26px; padding: 0; background: var(--surface); color: var(--text);
  width: min(420px, calc(100vw - 32px)); box-shadow: var(--shadow-lg);
}
dialog[open] { animation: dlgIn .4s var(--spring) both; }
dialog::backdrop { background: rgba(15, 23, 42, .45); backdrop-filter: blur(4px); animation: fade .3s both; }
@keyframes dlgIn { from { opacity: 0; transform: translateY(16px) scale(.95); } }
@keyframes fade { from { opacity: 0; } }
.dlg { padding: 26px; display: flex; flex-direction: column; gap: 12px; }
.dlg-ic { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 15px; background: var(--brand-soft); color: var(--brand-text); }
.dlg-ic.ok { background: var(--know-soft); color: var(--know); }
.dlg-ic svg { width: 22px; height: 22px; }
.dlg h2 { margin: 4px 0 0; font-size: 20px; font-weight: 800; letter-spacing: -.02em; word-break: break-all; }
.dlg p { margin: 0; font-size: 14px; line-height: 1.5; }
.dlg input[type=email] {
  width: 100%; height: 48px; padding: 0 14px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--surface-2); outline: 0;
  font-size: 15px; transition: border-color .2s, box-shadow .2s, background .2s;
}
.dlg input[type=email]:focus { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); background: var(--surface); }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.error { color: var(--danger); font-size: 13.5px; font-weight: 600; animation: shake .4s var(--ease); }
@keyframes shake { 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }

.foot { padding: 34px 4px 40px; font-size: 12px; color: var(--faint); text-align: center; }

/* ---------- bottom nav (phones) ---------- */
.bottom-nav { display: none; }

@media (max-width: 820px) {
  .tabs { display: none; }
  .bottom-nav {
    position: fixed; z-index: 40; left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom));
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 6px;
    background: color-mix(in srgb, var(--surface) 86%, transparent); backdrop-filter: saturate(1.6) blur(16px); -webkit-backdrop-filter: saturate(1.6) blur(16px);
    border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow-lg);
  }
  .bottom-nav button {
    display: flex; flex-direction: column; align-items: center; gap: 3px; border: 0; background: none;
    padding: 8px 0 6px; border-radius: 16px; font-size: 11.5px; font-weight: 700; color: var(--faint);
    transition: color .2s, background .25s;
  }
  .bottom-nav button svg { width: 21px; height: 21px; transition: transform .3s var(--spring); }
  .bottom-nav button.on { color: var(--brand-text); background: var(--brand-soft); }
  .bottom-nav button.on svg { transform: translateY(-1px) scale(1.08); }
  main.wrap { padding-bottom: 90px; }
  .toasts { bottom: calc(96px + env(safe-area-inset-bottom)); }
}
@media (max-width: 640px) {
  body { font-size: 15px; }
  .top-row { height: 58px; gap: 8px; }
  .brand-text small { display: none; }
  .brand-text b { font-size: 14px; }
  .logo { width: 34px; height: 34px; font-size: 13px; border-radius: 11px; }
  .account { padding-right: 6px; }
  #account-label { display: none; }
  .account .sync-dot { margin-right: 2px; }
  .icon-btn { width: 36px; height: 36px; }
  .brand-text b { overflow: hidden; text-overflow: ellipsis; }
  .stats {
    grid-template-columns: auto 1fr 1fr 1fr; gap: 0; margin: 14px 0 12px; padding: 8px;
    background: var(--surface); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow);
  }
  .ring-card, .stat { background: none; border: 0; box-shadow: none; border-radius: 0; }
  .ring-card { width: 60px; min-height: 0; padding: 0; }
  .ring { width: 52px; height: 52px; }
  .ring circle { stroke-width: 8; }
  .ring-label b { font-size: 13px; }
  .ring-label small { display: none; }
  .stat { padding: 2px 4px 2px 12px; border-left: 1px solid var(--line); gap: 0; }
  .stat:first-of-type { border-left: 0; }
  .stat b { font-size: 20px; }
  .stat small { font-size: 11.5px; }
  .stat-ic { display: none; }
  .banner { padding: 10px 10px 10px 12px; gap: 10px; margin-bottom: 12px; border-radius: 18px; }
  .banner-ic { width: 34px; height: 34px; border-radius: 10px; }
  .banner-text b { font-size: 13.5px; }
  .banner-text small { display: none; }
  .deck-head p { display: none; }
  .deck-head h2 { margin-bottom: 10px; font-size: 20px; }
  .toolbar { padding: 12px; border-radius: 20px; }
  .seg button { padding: 6px 10px; }
  .q-head { grid-template-columns: 36px 1fr 18px; gap: 12px; padding: 12px 14px; }
  .q-num { width: 36px; height: 36px; font-size: 12.5px; border-radius: 11px; }
  .q-content { padding: 0 16px 16px 16px; }
  .face { height: clamp(340px, 62svh, 520px); padding: 20px 18px; border-radius: 24px; }
  .card-actions { margin-top: 26px; gap: 10px; }
  .keys, .card-actions kbd { display: none; }
  .card-actions .mark-btn { padding: 13px 8px; }
  .swipe-hint { display: inline-flex; }
  .hero { flex-direction: column; align-items: stretch; padding: 22px 20px; border-radius: 24px; }
  .hero h2 { font-size: 23px; }
  .ticket { grid-template-columns: 1fr; }
  .dlg { padding: 22px; }
}

@media (max-width: 400px) {
  .brand-text { display: none; }
  .wrap { padding: 0 12px; }
  .seg button { padding: 6px 8px; font-size: 12.5px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
