:root {
  --bg: #ffffff; --text: #18181b; --muted: #8a8a93; --line: #ececee; --field: #f6f6f8;
  --accent: #2563eb; --accent-soft: #eef3ff; --accent-text: #fff;
  --good: #16a34a; --bad: #dc2626; --warn: #b45309;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111113; --text: #ececef; --muted: #8b8b95; --line: #232327; --field: #19191c;
    --accent: #7aa2ff; --accent-soft: #1a2032; --accent-text: #0b1020;
    --good: #4ade80; --bad: #f87171; --warn: #fbbf24; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111113; --text: #ececef; --muted: #8b8b95; --line: #232327; --field: #19191c;
  --accent: #7aa2ff; --accent-soft: #1a2032; --accent-text: #0b1020;
  --good: #4ade80; --bad: #f87171; --warn: #fbbf24; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- shell */
.top-in { max-width: 680px; margin: 0 auto; padding: 0 20px; height: 64px; display: flex; align-items: center; gap: 24px; }
.brand { font-weight: 650; letter-spacing: -.01em; white-space: nowrap; }
.brand i { font-style: normal; color: var(--accent); margin-right: 8px; }
nav { display: flex; gap: 20px; margin-left: auto; }
nav button {
  background: none; border: 0; padding: 6px 0; color: var(--muted); font-weight: 500;
  border-bottom: 2px solid transparent; white-space: nowrap;
}
nav button:hover { color: var(--text); }
nav button[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }
nav .badge { margin-left: 6px; color: var(--bad); font-size: .8rem; font-weight: 600; }
main { max-width: 680px; margin: 0 auto; padding: 24px 20px 150px; }
h1 { font-size: 1.75rem; letter-spacing: -.025em; margin: 0 0 6px; font-weight: 650; }
h2 { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 36px 0 6px; font-weight: 600; }
p.lead { margin: 0 0 24px; color: var(--muted); }

/* ---- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 22px;
  border-radius: 10px; border: 0; background: var(--field); font-weight: 600;
}
.btn:hover { filter: brightness(.96); }
.btn.primary { background: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: none; color: var(--muted); padding: 0 12px; }
.btn.ghost:hover { color: var(--text); filter: none; }
.btn:disabled { opacity: .45; cursor: default; }
.btn kbd { font: inherit; font-size: .8rem; opacity: .7; }
.link { background: none; border: 0; color: var(--accent); padding: 0; font-weight: 500; font-size: .9rem; text-transform: none; letter-spacing: 0; }
.pills { display: flex; gap: 4px; }
.pill { min-height: 32px; min-width: 38px; padding: 0 10px; border-radius: 8px; border: 0; background: none; color: var(--muted); font-weight: 550; }
.pill:hover { color: var(--text); }
.pill[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }

/* ---- topics */
.group-title { display: flex; align-items: baseline; justify-content: space-between; }
.topic {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; padding: 16px 0;
  background: none; border: 0; border-bottom: 1px solid var(--line);
}
.topic:hover .topic-name { color: var(--accent); }
.tick {
  flex: none; width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid var(--line);
  display: grid; place-items: center; color: transparent; font-size: 11px; font-weight: 800;
}
.topic[aria-pressed="true"] .tick { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.topic[aria-pressed="true"] .topic-name { color: var(--accent); }
.topic-main { flex: 1; min-width: 0; }
.topic-name { font-weight: 600; }
.topic-desc { color: var(--muted); font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topic-stat { text-align: right; font-size: .82rem; color: var(--muted); white-space: nowrap; line-height: 1.35; }
.topic-stat b { color: var(--text); font-size: .95rem; font-weight: 600; }
.empty { padding: 48px 0; text-align: center; color: var(--muted); }
.empty code { background: var(--field); padding: 2px 7px; border-radius: 6px; color: var(--text); }
.banner { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 16px; margin-bottom: 20px; border-radius: 12px; background: var(--accent-soft); }
.banner span { flex: 1; min-width: 160px; }
.banner .btn { min-height: 36px; padding: 0 16px; }

/* folders */
.folder {
  position: relative; display: flex; align-items: center; gap: 16px; padding: 18px 0; cursor: pointer;
  border-bottom: 1px solid var(--line);
}
.folder .ficon { flex: none; color: var(--muted); transition: color .15s; }
.folder:hover .ficon, .folder:focus-visible .ficon { color: var(--accent); }
.folder:hover .topic-name { color: var(--accent); }
.folder .open { min-height: 36px; padding: 0 18px; opacity: 0; transform: translateX(6px); transition: opacity .15s, transform .15s; }
.folder:hover .open, .folder:focus-visible .open { opacity: 1; transform: none; }
.folder .open { background: var(--accent); color: var(--accent-text); }
.folder:hover .topic-stat, .folder:focus-visible .topic-stat { display: none; }
@media (hover: none) { .folder .open { opacity: 1; transform: none; } .folder .topic-stat { display: none; } }
.crumbs { font-size: .9rem; margin-bottom: 14px; display: flex; gap: 8px; align-items: center; }

.startbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 4; background: var(--bg); border-top: 1px solid var(--line);
  transform: translateY(100%); visibility: hidden; transition: transform .2s ease, visibility 0s .2s; }
.startbar.show { transform: none; visibility: visible; transition: transform .2s ease; }
.startbar .lbl2 { color: var(--muted); font-size: .85rem; margin-left: 6px; }
.startbar-in { max-width: 680px; margin: 0 auto; padding: 12px 20px calc(12px + env(safe-area-inset-bottom)); display: flex; align-items: center; gap: 14px; }
.startbar .group { display: flex; align-items: center; gap: 6px; }
.startbar .lbl { display: none; }
.startbar .sep { width: 1px; height: 20px; background: var(--line); }
.startbar .go { margin-left: auto; white-space: nowrap; }

/* ---- test */
.meta { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: .88rem; margin-bottom: 10px; }
.meta .topic-tag { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.timer { min-width: 4em; text-align: right; font-variant-numeric: tabular-nums; }
.timer.over { color: var(--bad); }
.bar { height: 2px; background: var(--line); margin-bottom: 44px; }
.bar > i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .25s ease; }
.question { font-size: 1.6rem; line-height: 1.6; min-height: 3.4em; overflow-x: auto; overflow-y: hidden; letter-spacing: -.01em; }
.hint { color: var(--muted); font-size: .9rem; margin-top: 4px; min-height: 1.4em; }
.answer-wrap { margin-top: 20px; }
math-field {
  display: block; width: 100%; font-size: 1.7rem; padding: 12px 16px; min-height: 68px;
  border: 1px solid transparent; border-radius: 12px; background: var(--field); color: var(--text);
  --caret-color: var(--accent); --selection-background-color: var(--accent-soft); --contains-highlight-background-color: transparent;
}
math-field:focus-within { border-color: var(--accent); outline: none; background: var(--bg); box-shadow: 0 0 0 3px var(--accent-soft); }
math-field::part(virtual-keyboard-toggle), math-field::part(menu-toggle) { display: none; }
math-field.ok { border-color: var(--good); background: var(--bg); box-shadow: none; }
math-field.no { border-color: var(--bad); background: var(--bg); box-shadow: none; }
.symbols { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.symgroup { display: flex; flex-wrap: wrap; gap: 6px; }
.sym {
  min-width: 48px; height: 46px; padding: 0 10px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--field); color: var(--text); font-size: 1.05rem; display: inline-flex; align-items: center; justify-content: center;
}
.sym .katex { font-size: 1.3em; }
.sym:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.sym:active { transform: translateY(1px); }
.tip { color: var(--muted); font-size: .8rem; margin-top: 6px; opacity: .8; }
.msg { min-height: 1.4em; margin-top: 8px; font-size: .9rem; color: var(--warn); }
.actions { display: flex; align-items: center; gap: 10px; margin-top: 18px; }
.actions .spacer { flex: 1; }
.actions .btn.primary { min-width: 130px; }

.feedback { margin-top: 20px; padding-left: 16px; border-left: 3px solid var(--line); }
.feedback.ok { border-left-color: var(--good); }
.feedback.no { border-left-color: var(--bad); }
.verdict { font-weight: 650; display: flex; gap: 10px; align-items: baseline; }
.feedback.ok .verdict { color: var(--good); }
.feedback.no .verdict { color: var(--bad); }
.verdict .t { font-weight: 400; color: var(--muted); font-size: .88rem; }
.kv { display: grid; grid-template-columns: 8em 1fr; gap: 6px 12px; margin: 12px 0 0; align-items: baseline; font-size: 1.15rem; }
.kv dt { color: var(--muted); font-size: .82rem; }
.kv dd { margin: 0; overflow-x: auto; overflow-y: hidden; }
.steps { margin: 14px 0 0; padding: 0; list-style: none; counter-reset: s; color: var(--muted); }
.steps li { counter-increment: s; padding: 3px 0 3px 26px; position: relative; }
.steps li::before { content: counter(s) "."; position: absolute; left: 0; font-variant-numeric: tabular-nums; }
.steps-toggle { margin-top: 8px; }

/* ---- results / progress */
.stats { display: flex; flex-wrap: wrap; gap: 8px 40px; margin: 8px 0 8px; }
.stat b { display: block; font-size: 1.5rem; letter-spacing: -.02em; line-height: 1.25; font-weight: 600; }
.stat span { color: var(--muted); font-size: .8rem; }
.list { border-top: 1px solid var(--line); }
.row { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.row .mark { flex: none; width: 20px; text-align: center; font-weight: 700; }
.row .mark.ok { color: var(--good); }
.row .mark.no { color: var(--bad); }
.row .body { flex: 1; min-width: 0; }
.row .q { overflow-x: auto; overflow-y: hidden; white-space: nowrap; }
.row .sub { color: var(--muted); font-size: .85rem; overflow-x: auto; overflow-y: hidden; white-space: nowrap; }
.row .time { color: var(--muted); font-size: .85rem; white-space: nowrap; }
.row .time.over { color: var(--bad); }
.btnrow { display: flex; gap: 10px; flex-wrap: wrap; margin: 24px 0; align-items: center; }
.spark { width: 100px; height: 28px; flex: none; }
.spark polyline { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.spark circle { fill: var(--accent); }
.spark line { stroke: var(--line); }
.bigscore { font-size: 3.6rem; font-weight: 650; letter-spacing: -.04em; line-height: 1.1; margin-top: 4px; }
.err { color: var(--bad); }
.foot { margin-top: 32px; color: var(--muted); font-size: .82rem; }

@media (max-width: 560px) {
  .top-in { padding: 0 16px; gap: 12px; height: 56px; }
  nav { gap: 14px; }
  .brand span { display: none; }
  main { padding: 16px 16px 150px; }
  .question { font-size: 1.3rem; }
  math-field { font-size: 1.45rem; }
  .startbar-in { padding-left: 16px; padding-right: 16px; gap: 10px; }
  .startbar .pill { min-width: 30px; padding: 0 7px; }
  .startbar .go { padding: 0 16px; }
  .topic-stat, .spark { display: none; }
  .kv { grid-template-columns: 1fr; gap: 0; }
  .kv dt { margin-top: 8px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---- scroll wheel picker */
.wheel { display: flex; align-items: center; gap: 12px; --wh: 36px; }
.wbox { position: relative; width: 76px; height: calc(var(--wh) * 3); flex: none; }
.wband { position: absolute; left: 0; right: 0; top: var(--wh); height: var(--wh); border-radius: 10px; background: var(--accent-soft); pointer-events: none; }
.wlist {
  position: absolute; inset: 0; overflow-y: auto; scroll-snap-type: y mandatory; scrollbar-width: none; overscroll-behavior: contain;
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 32%, #000 68%, transparent);
  mask-image: linear-gradient(to bottom, transparent, #000 32%, #000 68%, transparent);
  cursor: grab; touch-action: pan-y; outline: none;
}
.wlist::-webkit-scrollbar { display: none; }
.wlist:focus-visible { box-shadow: 0 0 0 2px var(--accent); border-radius: 10px; }
.wpad { height: var(--wh); }
.wi { height: var(--wh); line-height: var(--wh); text-align: center; scroll-snap-align: center; color: var(--muted); font-variant-numeric: tabular-nums; user-select: none; }
.wi.sel { color: var(--accent); font-weight: 650; font-size: 1.15rem; }
.wside { display: flex; flex-direction: column; gap: 2px; }
.winput {
  width: 72px; height: 36px; border: 1px solid var(--line); border-radius: 8px; background: var(--field); color: var(--text);
  text-align: center; font-variant-numeric: tabular-nums; -moz-appearance: textfield;
}
.winput::-webkit-outer-spin-button, .winput::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.winput:focus { outline: none; border-color: var(--accent); }
.wlbl { color: var(--muted); font-size: .8rem; }
.startbar .wheel { margin-right: 4px; }

/* ---- assessment prep */
.sub-head { padding: 14px 0 4px; color: var(--muted); font-size: .8rem; font-weight: 600; }
.dateinput {
  height: 44px; padding: 0 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--field); color: var(--text);
  font: inherit; color-scheme: inherit;
}
.dateinput:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.today { padding: 20px 22px; border-radius: 14px; background: var(--accent-soft); }
.today-meta { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.badge2 { font-size: .75rem; font-weight: 600; padding: 2px 10px; border-radius: 20px; background: var(--bg); color: var(--accent); }
.badge2.hot { color: var(--bad); }
.today-title { font-size: 1.25rem; font-weight: 650; letter-spacing: -.01em; }
.today p { margin: 6px 0 16px; }
.donebox { color: var(--good); font-weight: 600; margin-bottom: 14px !important; }
.plan-row .pdate { width: 7.5em; flex: none; }
.plan-row.is-today { background: var(--accent-soft); margin: 0 -12px; padding-left: 12px; padding-right: 12px; border-radius: 10px; border-bottom-color: transparent; }
.st { font-size: .85rem; white-space: nowrap; color: var(--muted); }
.st.ok { color: var(--good); font-weight: 600; }
.st.now { color: var(--accent); font-weight: 600; }
@media (max-width: 560px) {
  .startbar-in { flex-wrap: wrap; row-gap: 6px; }
  #lgroup { order: 3; width: 100%; justify-content: center; }
  #lsep { display: none; }
  .plan-row .pdate { width: 5.6em; }
  .wlbl { display: none; }
  .startbar .wheel { margin-right: 0; }
}
