/* Layout: one 600px reading column. Grouped inset lists on a tinted ground,
   a tab bar pinned to the bottom on the main screens, and a full-screen
   question view whose primary action sits in the thumb zone. */
:root {
  --ground: #f4f4f1;
  --surface: #ffffff;
  --raised: #fbfbf9;
  --ink: #17191c;
  --ink-2: #4b4f55;
  --ink-3: #8a8e94;
  --line: #e4e4df;
  --accent: #0e6b63;
  --accent-ink: #ffffff;
  --accent-tint: #e5f0ee;
  --right: #1d7a4c;
  --right-tint: #e6f3ec;
  --wrong: #b8352e;
  --wrong-tint: #f8e9e7;
  --font: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --r: 14px;
  --gut: max(16px, env(safe-area-inset-left, 0px));
  --gut-r: max(16px, env(safe-area-inset-right, 0px));
  --bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ground: #0d0f10; --surface: #17191b; --raised: #1d2022; --ink: #eef0f1; --ink-2: #b4b9bd;
    --ink-3: #7c8287; --line: #2a2e31; --accent: #4fb3a7; --accent-ink: #062521; --accent-tint: #13302d;
    --right: #5cc290; --right-tint: #14301f; --wrong: #ef7a70; --wrong-tint: #3a1a17; color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--ground); color: var(--ink);
  font: 400 16px/1.5 var(--font); font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }

.page {
  max-width: 600px; margin: 0 auto; min-height: 100dvh;
  padding: calc(env(safe-area-inset-top, 0px) + 20px) var(--gut-r) calc(96px + var(--bottom)) var(--gut);
  display: flex; flex-direction: column; gap: 28px;
}

/* headings */
.title { font-size: 30px; line-height: 1.15; font-weight: 600; letter-spacing: -0.022em; margin: 0; text-wrap: balance; }
.subtitle { color: var(--ink-3); font-size: 15px; margin: 4px 0 0; }
.label { font-size: 13px; color: var(--ink-3); margin: 0 4px 8px; }

/* grouped lists */
.group { background: var(--surface); border-radius: var(--r); overflow: hidden; }
.row {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  padding: 13px 16px; min-height: 56px; position: relative;
}
.row + .row::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; height: 1px; background: var(--line); transform: scaleY(.6); }
button.row:active { background: var(--raised); }
@media (hover: hover) { button.row:hover { background: var(--raised); } }
.row .lead { min-width: 30px; flex: none; white-space: nowrap; color: var(--ink-3); font-size: 14px; font-variant-numeric: tabular-nums; }
.row .body { flex: 1; min-width: 0; }
.row .t { display: block; font-weight: 500; line-height: 1.3; }
.row .s { display: block; color: var(--ink-3); font-size: 13px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .end { flex: none; color: var(--ink-3); font-size: 14px; display: flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.chev { width: 7px; height: 12px; color: var(--line); flex: none; }
.score { font-weight: 500; }
.score.hi { color: var(--right); }
.score.mid { color: var(--ink-2); }
.score.lo { color: var(--wrong); }

/* summary */
.summary { background: var(--surface); border-radius: var(--r); padding: 18px 16px 16px; display: grid; gap: 14px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); }
.stat b { display: block; font-size: 24px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat span { color: var(--ink-3); font-size: 13px; }
.bar { height: 4px; background: var(--line); border-radius: 4px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 4px; transition: width .4s ease; }

/* shortcuts */
.shortcuts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.shortcut { background: var(--surface); border-radius: var(--r); padding: 14px 12px; text-align: left; display: grid; gap: 18px; min-height: 92px; }
.shortcut:active { transform: scale(.98); }
.shortcut svg { width: 20px; height: 20px; color: var(--accent); }
.shortcut b { font-weight: 500; font-size: 15px; line-height: 1.25; }
.shortcut small { display: block; color: var(--ink-3); font-size: 12px; font-weight: 400; }
.shortcut:disabled { opacity: .45; }

/* question type */
.formats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; padding: 3px; border-radius: 12px; background: color-mix(in srgb, var(--line) 70%, transparent); }
.formats button { padding: 9px 6px; border-radius: 9px; font-size: 14px; color: var(--ink-2); line-height: 1.2; transition: background .15s ease; }
.formats button[aria-checked="true"] { background: var(--surface); color: var(--ink); font-weight: 500; box-shadow: 0 1px 2px rgba(0,0,0,.08); }

/* search + segments */
.search { position: relative; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--ink-3); }
.search input {
  width: 100%; border: 0; border-radius: 11px; background: var(--surface); padding: 11px 12px 11px 36px; font-size: 16px; outline: none;
}
.search input::placeholder { color: var(--ink-3); }
.segments { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 calc(-1 * var(--gut-r)) 0 calc(-1 * var(--gut)); padding: 0 var(--gut-r) 0 var(--gut); }
.segments::-webkit-scrollbar { display: none; }
.seg { flex: none; padding: 7px 13px; border-radius: 9px; font-size: 14px; color: var(--ink-2); background: transparent; }
.seg[aria-pressed="true"] { background: var(--surface); color: var(--ink); font-weight: 500; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.empty { color: var(--ink-3); text-align: center; padding: 28px 16px; font-size: 15px; }

/* tab bar */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: color-mix(in srgb, var(--ground) 82%, transparent);
  backdrop-filter: saturate(1.6) blur(18px); -webkit-backdrop-filter: saturate(1.6) blur(18px);
  border-top: 1px solid var(--line);
  padding: 6px max(16px, env(safe-area-inset-right, 0px)) calc(6px + var(--bottom)) max(16px, env(safe-area-inset-left, 0px));
}
.tabs nav { max-width: 600px; margin: 0 auto; display: grid; grid-template-columns: repeat(3, 1fr); }
.tab { display: grid; justify-items: center; gap: 2px; padding: 6px 0; font-size: 11px; color: var(--ink-3); }
.tab svg { width: 22px; height: 22px; }
.tab[aria-current="page"] { color: var(--accent); }

/* quiz */
.quiz { max-width: 600px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column;
  padding: env(safe-area-inset-top, 0px) var(--gut-r) 0 var(--gut); }
.qtop { position: sticky; top: 0; z-index: 5; background: var(--ground); padding: 10px 0 12px; display: grid; gap: 12px; }
.qbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; color: var(--ink-2); }
.icon-btn:active { background: var(--surface); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn[aria-pressed="true"] { color: var(--accent); }
.counter { font-size: 14px; color: var(--ink-3); font-variant-numeric: tabular-nums; text-align: center; flex: 1; min-width: 0; }
.counter b { color: var(--ink); font-weight: 500; }
.qbody { flex: 1; display: flex; flex-direction: column; gap: 22px; padding: 6px 0 calc(110px + var(--bottom)); }
.qmeta { font-size: 13px; color: var(--ink-3); }
.qtext { font-size: 20px; line-height: 1.45; font-weight: 500; letter-spacing: -0.012em; margin: 0; text-wrap: pretty; }
.blank { display: inline-block; min-width: 3.2em; border-bottom: 2px solid var(--ink-3); transform: translateY(-3px); }
.blank.filled { border-color: transparent; color: var(--accent); font-weight: 600; transform: none; }
.options { display: grid; gap: 10px; }
.option {
  display: flex; gap: 14px; align-items: flex-start; text-align: left; width: 100%;
  background: var(--surface); border-radius: var(--r); padding: 15px 16px; min-height: 56px;
  box-shadow: inset 0 0 0 1px var(--line); transition: transform .12s ease, box-shadow .15s ease, background .15s ease;
}
.option:not(:disabled):active { transform: scale(.985); }
.option .key {
  flex: none; width: 24px; height: 24px; border-radius: 7px; display: grid; place-items: center;
  font-size: 12px; font-weight: 600; color: var(--ink-3); box-shadow: inset 0 0 0 1px var(--line); margin-top: 1px;
}
.option.right { background: var(--right-tint); box-shadow: inset 0 0 0 1.5px var(--right); }
.option.right .key { background: var(--right); color: var(--surface); box-shadow: none; }
.option.wrong { background: var(--wrong-tint); box-shadow: inset 0 0 0 1.5px var(--wrong); }
.option.wrong .key { background: var(--wrong); color: var(--surface); box-shadow: none; }
.option.dim { opacity: .55; }
.option:disabled { cursor: default; }
.field { display: grid; gap: 10px; }
.field input {
  width: 100%; border: 0; border-radius: var(--r); background: var(--surface); padding: 15px 16px; font-size: 17px;
  box-shadow: inset 0 0 0 1px var(--line); outline: none;
}
.field input:focus { box-shadow: inset 0 0 0 1.5px var(--accent); }
.field input.right { box-shadow: inset 0 0 0 1.5px var(--right); background: var(--right-tint); }
.field input.wrong { box-shadow: inset 0 0 0 1.5px var(--wrong); background: var(--wrong-tint); }
.linkish { color: var(--accent); font-size: 15px; font-weight: 500; padding: 8px 0; justify-self: start; }
.feedback { display: grid; gap: 10px; animation: rise .22s ease both; }
.verdict { font-weight: 600; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.verdict svg { width: 18px; height: 18px; }
.verdict.ok { color: var(--right); }
.verdict.no { color: var(--wrong); }
.note { background: var(--surface); border-radius: var(--r); padding: 14px 16px; font-size: 15px; line-height: 1.55; color: var(--ink-2); }
.note b { color: var(--ink); font-weight: 600; }
.note .from { display: block; font-size: 12px; color: var(--ink-3); margin-bottom: 4px; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  background: linear-gradient(to top, var(--ground) 70%, transparent);
  padding: 22px max(16px, env(safe-area-inset-right, 0px)) calc(14px + var(--bottom)) max(16px, env(safe-area-inset-left, 0px));
}
.dock > div { max-width: 600px; margin: 0 auto; display: flex; gap: 10px; }
.btn {
  flex: 1; min-height: 52px; border-radius: var(--r); font-weight: 600; font-size: 16px;
  background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; padding: 0 18px;
  transition: transform .12s ease, opacity .15s ease;
}
.btn:active { transform: scale(.985); }
.btn.quiet { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); flex: 0 0 auto; }
.btn:disabled { opacity: .4; }
.btn.google { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); display: flex; gap: 10px; justify-content: center; align-items: center; flex: none; width: 100%; }
.btn.google svg { width: 18px; height: 18px; }

/* results */
.result { text-align: center; display: grid; gap: 6px; padding: 24px 0 8px; }
.big { font-size: 64px; font-weight: 600; letter-spacing: -0.04em; line-height: 1; font-variant-numeric: tabular-nums; }
.review .row { align-items: flex-start; }
.review .t { font-weight: 400; font-size: 15px; }
.review .a { display: block; color: var(--right); font-weight: 500; font-size: 14px; margin-top: 4px; }

/* sign in */
.gate { min-height: 100dvh; display: grid; place-items: center; padding: 24px var(--gut-r) calc(24px + var(--bottom)) var(--gut); }
.gate-inner { width: 100%; max-width: 360px; display: grid; gap: 28px; }
.mark { width: 56px; height: 56px; border-radius: 15px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 600; font-size: 19px; letter-spacing: -0.02em; }
.gate p { color: var(--ink-2); margin: 8px 0 0; font-size: 16px; }
.gate small { color: var(--ink-3); font-size: 13px; line-height: 1.5; }
.loading { min-height: 100dvh; display: grid; place-items: center; color: var(--ink-3); font-size: 14px; }

.toast {
  position: fixed; left: 50%; bottom: calc(88px + var(--bottom)); transform: translateX(-50%); z-index: 20;
  background: var(--ink); color: var(--ground); padding: 10px 14px; border-radius: 12px; font-size: 14px;
  animation: rise .2s ease both; max-width: calc(100% - 32px);
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* exam-style questions */
.formats { grid-template-columns: repeat(4, 1fr); }
.formats.two { grid-template-columns: repeat(2, 1fr); }
.formats button { font-size: 13.5px; padding: 9px 4px; }
.pq-tag { display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 6px; font-size: 11.5px; font-weight: 500; color: var(--accent); background: var(--accent-tint); }
.points { display: grid; gap: 8px; }
.point { display: flex; align-items: center; gap: 10px; background: var(--surface); border-radius: 12px; padding: 0 0 0 14px; box-shadow: inset 0 0 0 1px var(--line); }
.point:focus-within { box-shadow: inset 0 0 0 1.5px var(--accent); }
.point .num { color: var(--ink-3); font-size: 14px; width: 14px; flex: none; }
.point input { flex: 1; min-width: 0; border: 0; background: transparent; padding: 14px 14px 14px 0; font-size: 16px; outline: none; }
.field textarea, .paper textarea {
  width: 100%; border: 0; border-radius: var(--r); background: var(--surface); padding: 14px 16px; font: inherit; font-size: 16px;
  box-shadow: inset 0 0 0 1px var(--line); outline: none; resize: vertical; color: var(--ink);
}
.field textarea:focus, .paper textarea:focus { box-shadow: inset 0 0 0 1.5px var(--accent); }
.inblank {
  border: 0; border-bottom: 2px solid var(--ink-3); background: transparent; font: inherit; color: var(--accent); font-weight: 600;
  padding: 0 2px; margin: 0 3px; outline: none; max-width: 100%; text-align: center; border-radius: 0;
}
.inblank:focus { border-color: var(--accent); }
.inblank.right { color: var(--right); border-color: var(--right); }
.inblank.wrong { color: var(--wrong); border-color: var(--wrong); text-decoration: line-through; }
.answers { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 4px; }
.answers li { display: flex; gap: 6px; align-items: baseline; color: var(--ink-2); }
.answers li::before { content: "·"; color: var(--ink-3); width: 14px; flex: none; text-align: center; }
.answers li.hit { color: var(--right); font-weight: 500; }
.answers li.hit::before { content: none; }
.answers li.hit svg { flex: none; width: 14px; transform: translateY(2px); }
.verdict.neutral { color: var(--ink-2); }
.selfmark { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.selfmark > span:first-child { flex: 1; min-width: 120px; font-size: 14px; color: var(--ink-3); }
.chipbtn { padding: 8px 14px; border-radius: 10px; font-size: 14px; font-weight: 500; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); color: var(--ink-2); }
.chipbtn.on[data-self="1"], .chipbtn.on[data-mark="1"] { background: var(--right-tint); color: var(--right); box-shadow: inset 0 0 0 1.5px var(--right); }
.chipbtn.on[data-self="0"], .chipbtn.on[data-mark="0"] { background: var(--wrong-tint); color: var(--wrong); box-shadow: inset 0 0 0 1.5px var(--wrong); }

/* mock paper */
.paper-row .paper-icon { width: 36px; height: 36px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-size: 13px; font-weight: 600; flex: none; letter-spacing: .02em; }
.paper-head { display: grid; gap: 6px; }
.paper-topic { margin-top: 2px; }
.paper-group { padding: 4px 0; }
.paper-q { display: flex; gap: 12px; padding: 14px 16px; position: relative; }
.paper-q + .paper-q::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; height: 1px; background: var(--line); transform: scaleY(.6); }
.pq-num { flex: none; width: 26px; color: var(--ink-3); font-size: 15px; line-height: 1.5; }
.pq-body { flex: 1; min-width: 0; display: grid; gap: 10px; }
.pq-text { margin: 0; font-size: 16px; line-height: 1.55; font-weight: 500; }
.paper .point { background: var(--raised); }
.paper textarea { background: var(--raised); }
.mine ul { list-style: none; margin: 2px 0 0; padding: 0; display: grid; gap: 2px; font-size: 15px; }
.mine .from, .review-q .from { display: block; font-size: 12px; color: var(--ink-3); margin-bottom: 2px; }
.muted { color: var(--ink-3); font-style: italic; }
.review-q .note { background: var(--raised); }
.score-pill { flex: none !important; min-width: 0 !important; padding: 3px 9px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--ink-2); background: var(--raised); font-variant-numeric: tabular-nums; }
.score-pill.full { color: var(--right); background: var(--right-tint); }
.score-pill.part { color: var(--ink); background: var(--accent-tint); }
#clock.low { color: var(--wrong); font-weight: 600; }
.field input.inblank, .paper input.inblank {
  width: auto; padding: 0 2px 1px; font-size: inherit; line-height: inherit; background: transparent;
  box-shadow: none; border-radius: 0; border-bottom: 2px solid var(--ink-3); min-width: 3.5ch;
}
.field input.inblank:focus, .paper input.inblank:focus { box-shadow: none; border-color: var(--accent); }
.field input.inblank.right { background: transparent; box-shadow: none; border-color: var(--right); }
.field input.inblank.wrong { background: transparent; box-shadow: none; border-color: var(--wrong); }
.field .point input, .paper .point input { width: auto; flex: 1; min-width: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; padding: 14px 14px 14px 0; font-size: 16px; }
.field .point input:focus { box-shadow: none; }
