:root {
  --bg: #f7f6f3;
  --surface: #ffffff;
  --surface-2: #f1efeb;
  --ink: #17161a;
  --ink-2: #55525c;
  --ink-3: #8a8792;
  --line: #e4e1dc;
  --brand: #6d4aff;
  --brand-ink: #ffffff;
  --brand-soft: #efeaff;
  --new: #2a78d6;
  --learn: #d0442f;
  --review: #128a52;
  --danger: #c4372f;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 18, 30, .06), 0 6px 24px rgba(20, 18, 30, .06);
  --series-1: #2a78d6;
  --series-2: #eb6834;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121115;
    --surface: #1b1a20;
    --surface-2: #24222a;
    --ink: #f1eff5;
    --ink-2: #bdb9c6;
    --ink-3: #8b8796;
    --line: #2f2d36;
    --brand: #9b83ff;
    --brand-ink: #120d26;
    --brand-soft: #2a2347;
    --new: #5aa2f0;
    --learn: #f07a68;
    --review: #45c486;
    --danger: #f06b62;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    --series-1: #3987e5;
    --series-2: #d95926;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  background: var(--bg); color: var(--ink);
  font: 16px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .6em; letter-spacing: -.01em; }
h1 { font-size: 1.8rem; }
h2 { font-size: 1.3rem; }
p { margin: 0 0 1em; }
code, kbd { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em; background: var(--surface-2); padding: .1em .35em; border-radius: 5px; }
.muted { color: var(--ink-2); }
.small { font-size: .875rem; }
.wrap { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.page { padding-top: 28px; padding-bottom: 48px; flex: 1; }
main { flex: 1; }

/* top bar */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar-inner { display: flex; align-items: center; gap: 16px; min-height: 60px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.2rem; color: var(--ink); }
.brand:hover { text-decoration: none; }
.nav { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.nav > a, .menu summary { color: var(--ink-2); padding: 8px 12px; border-radius: 10px; font-weight: 500; cursor: pointer; }
.nav > a:hover, .menu summary:hover { background: var(--surface-2); text-decoration: none; color: var(--ink); }
.nav > a.active { color: var(--brand); background: var(--brand-soft); }
.nav > a.btn { color: var(--brand-ink); }
.menu { position: relative; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu summary::after { content: " ▾"; font-size: .8em; }
.menu-pop { position: absolute; right: 0; top: 110%; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); min-width: 180px; padding: 6px; display: flex; flex-direction: column; }
.menu-pop a, .menu-pop .linklike { padding: 8px 12px; border-radius: 8px; color: var(--ink); text-align: left; width: 100%; }
.menu-pop a:hover, .menu-pop .linklike:hover { background: var(--surface-2); text-decoration: none; }
.menu-pop form { margin: 0; }
.nav-toggle, .nav-burger { display: none; }
@media (max-width: 760px) {
  .nav-burger { display: block; margin-left: auto; width: 36px; height: 36px; cursor: pointer; position: relative; }
  .nav-burger span, .nav-burger span::before, .nav-burger span::after { position: absolute; left: 8px; right: 8px; height: 2px; background: var(--ink); content: ""; }
  .nav-burger span { top: 17px; } .nav-burger span::before { top: -7px; left: 0; right: 0; } .nav-burger span::after { top: 7px; left: 0; right: 0; }
  .nav { display: none; position: absolute; top: 60px; left: 0; right: 0; background: var(--surface); border-bottom: 1px solid var(--line); flex-direction: column; align-items: stretch; padding: 8px 16px 16px; }
  .nav-toggle:checked ~ .nav { display: flex; }
  .menu-pop { position: static; box-shadow: none; border: 0; }
}

/* flash */
.flashes { padding-top: 16px; }
.flash { padding: 12px 16px; border-radius: 12px; margin-bottom: 8px; font-weight: 500; overflow-wrap: anywhere; }
.flash-notice { background: color-mix(in srgb, var(--review) 14%, var(--surface)); color: var(--ink); border: 1px solid color-mix(in srgb, var(--review) 35%, transparent); }
.flash-alert { background: color-mix(in srgb, var(--danger) 12%, var(--surface)); color: var(--ink); border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent); }

/* buttons & forms */
.btn, button.btn, input[type=submit].btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--brand); color: var(--brand-ink); border: 0; border-radius: 10px;
  padding: 10px 18px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { filter: brightness(1.06); text-decoration: none; }
.btn-small { padding: 6px 12px; font-size: .9rem; }
.btn-large { padding: 14px 28px; font-size: 1.1rem; border-radius: 12px; }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger); color: #fff; }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: var(--brand); cursor: pointer; }
.linklike.danger { color: var(--danger); }
.button_to { display: inline; }
form .field { margin-bottom: 16px; }
label { display: block; font-weight: 600; margin-bottom: 6px; font-size: .95rem; }
.hint { display: block; font-weight: 400; color: var(--ink-3); font-size: .85rem; margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: 0; border-color: var(--brand); }
textarea { min-height: 90px; resize: vertical; }
textarea.code { font-family: ui-monospace, Menlo, monospace; font-size: .9rem; min-height: 120px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.row > .grow { flex: 1; min-width: 180px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.grid-2 > .panel { margin-top: 0; }
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr)); gap: 20px; }
.chart-grid > .panel { margin-top: 0; }
.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 20px; }
.errors { background: color-mix(in srgb, var(--danger) 10%, var(--surface)); border-radius: 10px; padding: 10px 16px; margin-bottom: 16px; }

/* cards / panels */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
:where(.panel) + :where(.panel) { margin-top: 20px; }
.narrow { max-width: 440px; margin: 0 auto; }
.medium { max-width: 720px; margin: 0 auto; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { margin: 0; }

/* deck list */
.decks { width: 100%; border-collapse: collapse; }
.decks th { text-align: right; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); font-weight: 600; padding: 0 10px 10px; }
.decks th:first-child { text-align: left; }
.decks td { padding: 12px 10px; border-top: 1px solid var(--line); text-align: right; font-variant-numeric: tabular-nums; }
.decks td:first-child { text-align: left; }
.decks td.deck-name a { font-weight: 600; color: var(--ink); font-size: 1.05rem; }
.decks tr:hover td { background: var(--surface-2); }
.count { font-weight: 700; min-width: 2.2em; display: inline-block; }
.count.zero { color: var(--ink-3); font-weight: 400; }
.c-new { color: var(--new); } .c-learn { color: var(--learn); } .c-review { color: var(--review); }
.deck-actions { width: 1%; white-space: nowrap; }
.deck-actions details { position: relative; display: inline-block; }
.deck-actions summary { list-style: none; cursor: pointer; padding: 2px 10px; border-radius: 8px; color: var(--ink-2); }
.deck-actions summary::-webkit-details-marker { display: none; }
.deck-actions summary:hover { background: var(--line); }
.deck-actions .menu-pop { text-align: left; z-index: 5; }
.indent { display: inline-block; }
.studied-today { margin-top: 20px; text-align: center; }

/* study */
.study-wrap { max-width: 760px; margin: 0 auto; }
.study-counts { display: flex; justify-content: center; gap: 18px; font-weight: 700; font-variant-numeric: tabular-nums; margin-bottom: 12px; }
.study-counts .current { text-decoration: underline; text-underline-offset: 4px; }
.card-stage { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); min-height: 300px; padding: 8px; }
.card-frame { width: 100%; border: 0; display: block; min-height: 280px; background: transparent; }
.answer-bar { position: sticky; bottom: 0; padding: 16px 0; background: linear-gradient(transparent, var(--bg) 30%); display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.ease-btn { display: flex; flex-direction: column; align-items: center; min-width: 92px; padding: 8px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font: inherit; cursor: pointer; color: var(--ink); }
.ease-btn small { font-size: .78rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.ease-btn strong { font-size: 1rem; }
.ease-btn:hover { border-color: currentColor; }
.ease-1 strong { color: var(--danger); } .ease-2 strong { color: var(--ink-2); } .ease-3 strong { color: var(--review); } .ease-4 strong { color: var(--new); }
.study-tools { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; gap: 8px; flex-wrap: wrap; }
.study-tools form { display: inline; }
.overview { text-align: center; }
.overview .big-counts { display: flex; justify-content: center; gap: 32px; margin: 24px 0; }
.big-counts div { display: flex; flex-direction: column; }
.big-counts strong { font-size: 2.2rem; font-variant-numeric: tabular-nums; }
.big-counts span { color: var(--ink-2); font-size: .9rem; }
.congrats { text-align: center; padding: 40px 16px; }
.kbd-hint { text-align: center; color: var(--ink-3); font-size: .8rem; }
@media (max-width: 560px) {
  .ease-btn { min-width: 0; flex: 1; padding: 8px 6px; }
  .answer-bar { flex-wrap: nowrap; }
}

/* browse */
.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.table th { text-align: left; color: var(--ink-3); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr.suspended td { background: color-mix(in srgb, #e2b93b 14%, transparent); }
.table td.clip { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flag-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }
.flag-1 { background: #d03b3b; } .flag-2 { background: #eb6834; } .flag-3 { background: #0ca30c; } .flag-4 { background: #2a78d6; }
.bulk-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 0; }
.bulk-bar select { width: auto; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 0; }
.chip { font-size: .8rem; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); }
.chip:hover { text-decoration: none; color: var(--ink); }
.pager { display: flex; gap: 12px; justify-content: center; align-items: center; margin-top: 16px; }

/* note editor */
.editor-field textarea { min-height: 70px; }
.field-label { display: flex; justify-content: space-between; }
.cloze-btn { font-size: .8rem; }

/* stats */
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 20px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.tile .label { color: var(--ink-2); font-size: .85rem; }
.tile .value { font-size: 1.7rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.chart { position: relative; }
.bars { display: flex; align-items: flex-end; gap: 2px; height: 180px; border-bottom: 1px solid var(--line); padding-top: 8px; }
.bar { flex: 1; display: flex; flex-direction: column-reverse; gap: 2px; height: 100%; justify-content: flex-start; position: relative; cursor: default; min-width: 4px; }
.bar .seg { border-radius: 4px 4px 0 0; min-height: 0; }
.bar .seg + .seg { border-radius: 4px 4px 0 0; }
.bar .seg.s1 { background: var(--series-1); }
.bar .seg.s2 { background: var(--series-2); }
.bar:hover { background: color-mix(in srgb, var(--ink) 5%, transparent); border-radius: 4px; }
.bar .tip { display: none; position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); font-size: .78rem; padding: 6px 8px; border-radius: 8px; white-space: nowrap; z-index: 3; pointer-events: none; }
.bar:hover .tip, .bar:focus .tip { display: block; }
.axis { display: flex; justify-content: space-between; color: var(--ink-3); font-size: .75rem; margin-top: 4px; }
.legend { display: flex; gap: 16px; font-size: .85rem; color: var(--ink-2); margin-bottom: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.hbar-row { display: grid; grid-template-columns: 110px 1fr 60px; gap: 10px; align-items: center; margin-bottom: 8px; font-size: .9rem; }
.hbar-track { background: var(--surface-2); border-radius: 4px; height: 14px; overflow: hidden; }
.hbar-fill { height: 100%; background: var(--series-1); border-radius: 0 4px 4px 0; }
.hbar-row .num { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.data-table summary { cursor: pointer; color: var(--ink-2); font-size: .85rem; margin-top: 10px; }

/* landing */
.hero { padding: 72px 0 56px; text-align: center; }
.hero .eyebrow { display: inline-block; color: var(--brand); background: var(--brand-soft); padding: 4px 12px; border-radius: 999px; font-weight: 600; font-size: .85rem; margin-bottom: 18px; }
.hero h1 { font-size: clamp(2.2rem, 6vw, 3.6rem); letter-spacing: -.03em; max-width: 820px; margin: 0 auto 18px; }
.hero p { font-size: 1.2rem; color: var(--ink-2); max-width: 640px; margin: 0 auto 28px; }
.hero .actions { justify-content: center; }
.demo-card { max-width: 520px; margin: 48px auto 0; background: var(--surface); border-radius: 20px; border: 1px solid var(--line); box-shadow: var(--shadow); padding: 28px; }
.demo-card .q { font-size: 1.5rem; font-weight: 600; }
.demo-card hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
.demo-card .a { font-size: 1.2rem; color: var(--ink-2); }
.demo-btns { display: flex; gap: 8px; justify-content: center; margin-top: 20px; flex-wrap: wrap; }
.demo-btns span { padding: 6px 14px; border-radius: 10px; border: 1px solid var(--line); font-size: .9rem; }
.section { padding: 56px 0; }
.section.alt { background: var(--surface); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.section h2 { font-size: 1.8rem; text-align: center; margin-bottom: 8px; }
.section .lead { text-align: center; color: var(--ink-2); max-width: 620px; margin: 0 auto 36px; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; }
.feature { padding: 22px; border-radius: var(--radius); background: var(--bg); border: 1px solid var(--line); }
.section:not(.alt) .feature { background: var(--surface); }
.feature .ico { width: 40px; height: 40px; border-radius: 10px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; margin-bottom: 12px; }
.feature h3 { font-size: 1.1rem; margin-bottom: 6px; }
.feature p { color: var(--ink-2); margin: 0; font-size: .95rem; }
.concepts { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 24px; }
.downloads { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.download { padding: 22px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); }
.download h3 { margin-bottom: 4px; }
.download code { display: block; margin-top: 10px; padding: 8px 10px; white-space: pre-wrap; overflow-wrap: anywhere; }

.footer { border-top: 1px solid var(--line); padding: 20px 0; color: var(--ink-3); font-size: .875rem; }
.footer .wrap { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; }

/* shared */
.shared-list { display: grid; gap: 12px; }
.shared-item { display: flex; justify-content: space-between; gap: 16px; align-items: center; padding: 16px 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.shared-item h3 { margin: 0 0 4px; font-size: 1.05rem; }
.shared-item p { margin: 0; color: var(--ink-2); font-size: .9rem; }
.meta { color: var(--ink-3); font-size: .85rem; }
.template-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.footer .linklike { font-size: inherit; }
.footer .current-locale { color: var(--ink); font-weight: 700; cursor: default; }
