/* luyendethi — design tokens
   Concept: the Vietnamese exam answer sheet. Purple ballpoint ink ("mực tím") on cool paper,
   bubbles that fill when you answer, and a highlighter for reading. */

:root {
  --paper: #F4F5F9;
  --surface: #FFFFFF;
  --surface-2: #FAFAFD;
  --ink: #1B1A2E;
  --ink-2: #46445E;
  --muted: #706D8A;
  --line: #E2E1EC;
  --line-strong: #CFCDE0;

  --violet: #4B2BB3;
  --violet-hover: #3D2096;
  --violet-weak: #EEEAFB;
  --violet-ink: #3A1F93;
  --on-violet: #FFFFFF;

  --marker: #FFE76A;
  --marker-soft: #FFF3A8;

  --good: #127A55;
  --good-weak: #E2F3EB;
  --bad: #BF3149;
  --bad-weak: #FBE8EB;
  --warn: #965600;
  --warn-weak: #FFF0D4;
  --pending: #275FA6;
  --pending-weak: #E5EEFA;

  --font-ui: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-read: "Literata", Georgia, "Times New Roman", serif;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --shadow-1: 0 1px 2px rgba(27, 26, 46, .06), 0 1px 1px rgba(27, 26, 46, .04);
  --shadow-2: 0 10px 30px -12px rgba(43, 26, 110, .22), 0 2px 6px rgba(27, 26, 46, .06);
  --header-h: 64px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #121120; --surface: #1B1A2C; --surface-2: #201F33; --ink: #ECEAF7; --ink-2: #C5C2DA; --muted: #9692B0;
    --line: #2E2C45; --line-strong: #3D3A58; --violet: #A795FF; --violet-hover: #BBAEFF; --violet-weak: #29234E; --violet-ink: #CFC6FF; --on-violet: #15112E;
    --marker: rgba(255, 224, 80, .38); --marker-soft: rgba(255, 224, 80, .2);
    --good: #4FCB97; --good-weak: #173327; --bad: #FF8197; --bad-weak: #3A1C25; --warn: #F2B65A; --warn-weak: #3A2C14; --pending: #8DB8F2; --pending-weak: #1A2840;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .4); --shadow-2: 0 14px 34px -14px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #121120; --surface: #1B1A2C; --surface-2: #201F33; --ink: #ECEAF7; --ink-2: #C5C2DA; --muted: #9692B0;
  --line: #2E2C45; --line-strong: #3D3A58; --violet: #A795FF; --violet-hover: #BBAEFF; --violet-weak: #29234E; --violet-ink: #CFC6FF; --on-violet: #15112E;
  --marker: rgba(255, 224, 80, .38); --marker-soft: rgba(255, 224, 80, .2);
  --good: #4FCB97; --good-weak: #173327; --bad: #FF8197; --bad-weak: #3A1C25; --warn: #F2B65A; --warn-weak: #3A2C14; --pending: #8DB8F2; --pending-weak: #1A2840;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .4); --shadow-2: 0 14px 34px -14px rgba(0, 0, 0, .7);
  color-scheme: dark;
}

/* ---------------- base ---------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 400 16px/1.6 var(--font-ui); min-height: 100vh; display: flex; flex-direction: column;
  -webkit-font-smoothing: antialiased;
}
main { flex: 1; outline: none; }
a { color: var(--violet); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--violet-hover); }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: clamp(1.7rem, 1.2rem + 1.8vw, 2.4rem); font-weight: 700; letter-spacing: -.02em; }
h2 { font-size: 1.4rem; font-weight: 700; }
h3 { font-size: 1.1rem; font-weight: 600; }
p { margin: 0 0 1em; }
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--violet); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--marker-soft); }
.wrap { width: min(1160px, 100% - 40px); margin-inline: auto; }
.narrow { width: min(760px, 100% - 40px); margin-inline: auto; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 100; border-radius: var(--r-sm); }
.skip-link:focus { left: 8px; }
[hidden] { display: none !important; }

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

/* ---------------- header ---------------- */
.site-header {
  position: sticky; top: 0; z-index: 40; height: var(--header-h);
  background: color-mix(in srgb, var(--paper) 86%, transparent); backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.header-inner { height: 100%; display: flex; align-items: center; gap: 28px; }
.logo { display: inline-flex; align-items: center; gap: 9px; text-decoration: none; color: var(--ink); font-weight: 700; font-size: 1.15rem; letter-spacing: -.02em; }
.logo-mark { width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid var(--violet); display: grid; place-items: center; }
.logo-mark::after { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--violet); }
.main-nav { display: flex; gap: 4px; }
.main-nav a { color: var(--ink-2); text-decoration: none; padding: 8px 12px; border-radius: var(--r-sm); font-weight: 500; font-size: .95rem; }
.main-nav a:hover { background: var(--violet-weak); color: var(--violet-ink); }
.main-nav a[aria-current="page"] { color: var(--violet-ink); background: var(--violet-weak); }
.header-tools { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid transparent; background: transparent;
  display: grid; place-items: center; cursor: pointer; color: var(--ink-2);
}
.icon-btn:hover { background: var(--violet-weak); color: var(--violet-ink); }
.menu-btn { display: none; }
.student-chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px 5px 5px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); text-decoration: none; font-size: .9rem; font-weight: 500;
  max-width: 220px;
}
.student-chip .avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--violet); color: var(--on-violet); display: grid; place-items: center; font-weight: 700; font-size: .8rem; flex: none; }
.student-chip .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.student-chip .tag { color: var(--muted); font-weight: 400; }

@media (max-width: 760px) {
  .header-inner { gap: 12px; }
  .menu-btn { display: grid; }
  .main-nav {
    position: absolute; top: var(--header-h); left: 0; right: 0; flex-direction: column; padding: 8px 16px 16px;
    background: var(--surface); border-bottom: 1px solid var(--line); box-shadow: var(--shadow-2); display: none;
  }
  .main-nav.open { display: flex; }
  .main-nav a { padding: 12px; }
  .student-chip .name, .student-chip .tag { display: none; }
  .student-chip { padding: 5px; }
}

.site-footer { border-top: 1px solid var(--line); margin-top: 64px; padding: 22px 0; color: var(--muted); font-size: .875rem; }
.footer-inner { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.footer-inner a { color: var(--muted); }
body.exam-mode .site-header, body.exam-mode .site-footer { display: none; }

/* ---------------- buttons, inputs ---------------- */
.btn {
  --b-bg: var(--surface); --b-fg: var(--ink); --b-bd: var(--line-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 9px 18px;
  border-radius: 10px; border: 1px solid var(--b-bd); background: var(--b-bg); color: var(--b-fg);
  font-weight: 600; font-size: .95rem; text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background .15s var(--ease), border-color .15s var(--ease), transform .1s var(--ease);
}
.btn:hover { border-color: var(--violet); color: var(--b-fg); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-primary { --b-bg: var(--violet); --b-fg: var(--on-violet); --b-bd: var(--violet); }
.btn-primary:hover { --b-bg: var(--violet-hover); --b-bd: var(--violet-hover); color: var(--on-violet); }
.btn-ghost { --b-bg: transparent; --b-bd: transparent; color: var(--violet); }
.btn-ghost:hover { background: var(--violet-weak); border-color: transparent; color: var(--violet-ink); }
.btn-danger { --b-fg: var(--bad); }
.btn-danger:hover { border-color: var(--bad); }
.btn-sm { min-height: 34px; padding: 5px 12px; font-size: .875rem; border-radius: 8px; }
.btn-lg { min-height: 50px; padding: 12px 24px; font-size: 1.02rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field label, .label { font-weight: 600; font-size: .9rem; color: var(--ink-2); }
.field .hint { font-size: .825rem; color: var(--muted); }
.input, .textarea, .select {
  width: 100%; padding: 10px 13px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--surface);
  min-height: 44px; transition: border-color .15s, box-shadow .15s;
}
.textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.input:focus, .textarea:focus, .select:focus { outline: none; border-color: var(--violet); box-shadow: 0 0 0 3px var(--violet-weak); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85rem; }

/* ---------------- surfaces ---------------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 24px; }
.panel + .panel { margin-top: 18px; }
.page { padding: 36px 0 24px; }
.page-head { margin-bottom: 26px; }
.page-head p { color: var(--ink-2); max-width: 64ch; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; background: var(--violet-weak); color: var(--violet-ink); white-space: nowrap; }
.chip-good { background: var(--good-weak); color: var(--good); }
.chip-bad { background: var(--bad-weak); color: var(--bad); }
.chip-warn { background: var(--warn-weak); color: var(--warn); }
.chip-pending { background: var(--pending-weak); color: var(--pending); }
.chip-plain { background: transparent; border: 1px solid var(--line-strong); color: var(--ink-2); font-weight: 500; }
.notice { border-radius: var(--r-md); padding: 14px 16px; background: var(--violet-weak); color: var(--ink); border: 1px solid color-mix(in srgb, var(--violet) 22%, transparent); }
.notice-warn { background: var(--warn-weak); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.notice-bad { background: var(--bad-weak); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.notice-pending { background: var(--pending-weak); border-color: color-mix(in srgb, var(--pending) 30%, transparent); }
.empty { text-align: center; padding: 48px 20px; color: var(--ink-2); }
.empty h3 { color: var(--ink); }
.loading { padding: 80px 0; text-align: center; color: var(--muted); }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--violet); animation: spin .8s linear infinite; margin: 0 auto 12px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- home ---------------- */
.hero { padding: 56px 0 40px; display: grid; grid-template-columns: 1.1fr .9fr; gap: 48px; align-items: center; }
.hero h1 { font-size: clamp(2rem, 1.3rem + 2.6vw, 3.1rem); line-height: 1.12; max-width: 17ch; text-wrap: balance; }
.hero p.lead { font-size: 1.1rem; color: var(--ink-2); max-width: 46ch; }
.hero .btn-row { margin-top: 26px; }
.sheet {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-2);
  padding: 22px 24px; transform: rotate(1.2deg); max-width: 380px; justify-self: end; width: 100%;
}
.sheet-head { display: flex; justify-content: space-between; font-size: .8rem; color: var(--muted); border-bottom: 1px dashed var(--line-strong); padding-bottom: 10px; margin-bottom: 12px; }
.sheet-row { display: grid; grid-template-columns: 32px repeat(4, 1fr); align-items: center; gap: 8px; padding: 6px 0; }
.sheet-row .n { font-weight: 700; color: var(--ink-2); font-size: .9rem; font-variant-numeric: tabular-nums; }
.sheet-bubble { width: 26px; height: 26px; border-radius: 50%; border: 1.5px solid var(--line-strong); display: grid; place-items: center; font-size: .72rem; font-weight: 600; color: var(--muted); }
.sheet-bubble.on { background: var(--violet); border-color: var(--violet); color: var(--on-violet); }
.sheet-bubble.ok { background: var(--good); border-color: var(--good); color: #fff; }
.sheet-bubble.no { border-color: var(--bad); color: var(--bad); box-shadow: inset 0 0 0 1.5px var(--bad); }
.sheet-foot { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line-strong); display: flex; justify-content: space-between; align-items: baseline; }
.sheet-foot strong { font-size: 1.6rem; color: var(--violet-ink); font-variant-numeric: tabular-nums; }
.feature-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; border-top: 1px solid var(--line); margin-top: 24px; }
.feature-list > div { padding: 22px 24px 4px 0; }
.feature-list h3 { font-size: 1rem; }
.feature-list p { color: var(--ink-2); font-size: .95rem; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin: 44px 0 16px; }
.section-title h2 { margin: 0; }
@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; padding-top: 32px; gap: 28px; }
  .sheet { justify-self: start; transform: none; }
  .feature-list { grid-template-columns: 1fr; }
}

/* exam cards */
.exam-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.exam-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px 20px 18px;
  display: flex; flex-direction: column; gap: 12px; text-decoration: none; color: var(--ink);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.exam-card:hover { border-color: var(--violet); box-shadow: var(--shadow-2); color: var(--ink); }
.exam-card h3 { margin: 0; font-size: 1.05rem; }
.exam-card .meta { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--ink-2); font-size: .875rem; }
.exam-card .desc { color: var(--ink-2); font-size: .9rem; margin: 0; }
.exam-card .foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; gap: 10px; border-top: 1px solid var(--line); padding-top: 12px; font-size: .875rem; }
.skill-dots { display: flex; flex-wrap: wrap; gap: 6px; }
.grade-badge { font-weight: 700; color: var(--violet-ink); font-size: .8rem; }

/* ---------------- exam intro ---------------- */
.intro-grid { display: grid; grid-template-columns: 1fr 340px; gap: 24px; align-items: start; }
.mode-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 18px 0; }
.mode-card { border: 1.5px solid var(--line-strong); border-radius: var(--r-md); padding: 16px; cursor: pointer; display: grid; gap: 4px; background: var(--surface); position: relative; }
.mode-card input { position: absolute; opacity: 0; }
.mode-card:has(input:checked) { border-color: var(--violet); background: var(--violet-weak); }
.mode-card:has(input:focus-visible) { outline: 3px solid var(--violet); outline-offset: 2px; }
.mode-card strong { font-size: 1rem; }
.mode-card span { color: var(--ink-2); font-size: .875rem; }
.section-list { list-style: none; padding: 0; margin: 0; }
.section-list li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: .93rem; }
.section-list li:last-child { border-bottom: 0; }
@media (max-width: 860px) { .intro-grid { grid-template-columns: 1fr; } .mode-cards { grid-template-columns: 1fr; } }

/* ---------------- exam interface ---------------- */
body.exam-mode { background: var(--paper); }
.exam-top {
  position: sticky; top: 0; z-index: 30; height: 60px; background: var(--surface); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 14px; padding: 0 16px;
}
.exam-top .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }
.exam-top .title small { display: block; font-weight: 400; color: var(--muted); font-size: .78rem; }
.save-state { font-size: .8rem; color: var(--muted); white-space: nowrap; }
.save-state.err { color: var(--bad); }
.timer {
  font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.05rem; padding: 6px 12px; border-radius: 10px;
  background: var(--violet-weak); color: var(--violet-ink); display: inline-flex; gap: 6px; align-items: center; white-space: nowrap;
}
.timer.warn { background: var(--warn-weak); color: var(--warn); }
.timer.danger { background: var(--bad-weak); color: var(--bad); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .65; } }
.progress-track { height: 3px; background: var(--line); position: sticky; top: 60px; z-index: 29; }
.progress-fill { height: 100%; background: var(--violet); transition: width .3s var(--ease); }

.exam-layout { display: grid; grid-template-columns: minmax(0, 1fr) 272px; height: calc(100vh - 63px); height: calc(100dvh - 63px); }
.exam-main { min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.exam-side { border-left: 1px solid var(--line); background: var(--surface); overflow-y: auto; padding: 18px 16px; }

.section-bar { padding: 12px 22px; border-bottom: 1px solid var(--line); background: var(--surface-2); display: flex; gap: 12px; align-items: baseline; }
.section-bar .s-title { font-weight: 700; white-space: nowrap; }
.section-bar .s-ins { color: var(--ink-2); font-size: .9rem; }
.section-bar .s-ins em { font-style: normal; }

.split { flex: 1; min-height: 0; display: grid; grid-template-columns: var(--split, 52%) 10px minmax(0, 1fr); }
.single { flex: 1; min-height: 0; overflow-y: auto; }
.pane { overflow-y: auto; min-height: 0; overscroll-behavior: contain; }
.pane-passage { background: var(--surface); padding: 28px 34px 60px; }
.pane-questions { padding: 22px 24px 60px; }
.resizer { cursor: col-resize; background: var(--paper); border-inline: 1px solid var(--line); position: relative; touch-action: none; }
.resizer::after { content: ""; position: absolute; left: 50%; top: 50%; width: 4px; height: 40px; border-radius: 4px; transform: translate(-50%, -50%); background: var(--line-strong); }
.resizer:hover::after, .resizer.dragging::after, .resizer:focus-visible::after { background: var(--violet); }

.passage { font-family: var(--font-read); font-size: 1.06rem; line-height: 1.8; color: var(--ink); max-width: 68ch; }
.passage h2 { font-family: var(--font-ui); font-size: 1.05rem; text-transform: none; letter-spacing: 0; margin-bottom: 14px; }
.passage p { margin: 0 0 1.05em; }
.passage .source { font-family: var(--font-ui); font-size: .82rem; color: var(--muted); font-style: italic; }
.passage mark.hl { background: var(--marker); color: inherit; border-radius: 2px; padding: 0 1px; cursor: pointer; }
.gap { font-family: var(--font-ui); font-weight: 700; font-size: .85em; color: var(--violet-ink); background: var(--violet-weak); border-radius: 6px; padding: 1px 7px; cursor: pointer; white-space: nowrap; border-bottom: 2px solid var(--violet); }
.gap::after { content: " " attr(data-pick); }
.gap[data-pick=""]::after { content: ""; display: inline-block; width: 2.6em; margin-left: .3em; border-bottom: 1.5px solid currentColor; transform: translateY(-2px); }
.gap.filled { background: var(--violet); color: var(--on-violet); }
.gap.active { outline: 2px solid var(--violet); outline-offset: 2px; }
.blank { display: inline-block; min-width: 72px; border-bottom: 1.5px solid var(--ink-2); margin: 0 3px; transform: translateY(-3px); }
.hl-tool {
  position: fixed; z-index: 60; display: flex; gap: 2px; background: var(--ink); color: var(--paper); border-radius: 10px; padding: 4px; box-shadow: var(--shadow-2);
}
.hl-tool button { border: 0; background: transparent; color: inherit; padding: 6px 10px; border-radius: 7px; cursor: pointer; font-size: .85rem; font-weight: 600; display: inline-flex; gap: 6px; align-items: center; }
.hl-tool button:hover { background: rgba(255, 255, 255, .14); }
.hl-swatch { width: 12px; height: 12px; border-radius: 3px; background: #FFE76A; }

.q {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 16px 18px 18px; margin-bottom: 14px;
  scroll-margin-top: 16px; transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}
.q.current { border-color: var(--violet); box-shadow: 0 0 0 3px var(--violet-weak); }
.q-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.q-num { font-weight: 700; font-size: .95rem; color: var(--violet-ink); font-variant-numeric: tabular-nums; }
.q-flag { margin-left: auto; border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 4px 11px; font-size: .8rem; cursor: pointer; color: var(--ink-2); display: inline-flex; gap: 6px; align-items: center; }
.q-flag[aria-pressed="true"] { background: var(--warn-weak); border-color: color-mix(in srgb, var(--warn) 50%, transparent); color: var(--warn); font-weight: 600; }
.q-stem { margin-bottom: 12px; line-height: 1.6; }
.q-stem .line { display: block; padding: 2px 0; }
.q-stem .line + .line { margin-top: 2px; }
.options { display: grid; gap: 8px; }
.opt {
  display: grid; grid-template-columns: 32px 1fr; gap: 12px; align-items: center; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line);
  cursor: pointer; background: var(--surface); transition: background .12s, border-color .12s; position: relative; line-height: 1.45;
}
.opt:hover { border-color: var(--violet); }
.opt input { position: absolute; opacity: 0; pointer-events: none; }
.opt .bubble {
  width: 30px; height: 30px; border-radius: 50%; border: 1.6px solid var(--line-strong); display: grid; place-items: center;
  font-weight: 700; font-size: .85rem; color: var(--ink-2); transition: all .15s var(--ease);
}
.opt:has(input:checked) { background: var(--violet-weak); border-color: var(--violet); }
.opt:has(input:checked) .bubble { background: var(--violet); border-color: var(--violet); color: var(--on-violet); transform: scale(1.04); }
.opt:has(input:focus-visible) { outline: 3px solid var(--violet); outline-offset: 2px; }
.options.inline { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.options.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 560px) { .options.inline { grid-template-columns: repeat(2, minmax(0, 1fr)); } .options.two { grid-template-columns: 1fr; } }
.text-answer { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.text-answer .input { flex: 1 1 220px; }
.rewrite-orig { padding: 10px 14px; border-left: 3px solid var(--line-strong); color: var(--ink-2); margin-bottom: 12px; background: var(--surface-2); border-radius: 0 8px 8px 0; }
.rewrite-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.rewrite-line .arrow { color: var(--violet); font-weight: 700; }
.rewrite-line .input { flex: 1 1 240px; }

.sec-nav { display: flex; justify-content: space-between; gap: 12px; margin-top: 18px; flex-wrap: wrap; }

/* answer-sheet navigator */
.sheet-nav h3 { font-size: .95rem; margin-bottom: 10px; display: flex; justify-content: space-between; }
.sheet-group { margin-bottom: 12px; }
.sheet-group .g-title { font-size: .75rem; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.sheet-cells { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.cell {
  aspect-ratio: 1; border-radius: 50%; border: 1.5px solid var(--line-strong); background: transparent; cursor: pointer;
  font-size: .78rem; font-weight: 600; color: var(--ink-2); font-variant-numeric: tabular-nums; position: relative; padding: 0; min-width: 0;
}
.cell:hover { border-color: var(--violet); }
.cell.answered { background: var(--violet); border-color: var(--violet); color: var(--on-violet); }
.cell.flagged::after { content: ""; position: absolute; top: -2px; right: -2px; width: 10px; height: 10px; border-radius: 50%; background: var(--warn); border: 2px solid var(--surface); }
.cell.current { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--violet); }
.sheet-legend { display: grid; gap: 6px; font-size: .78rem; color: var(--ink-2); margin: 14px 0; padding-top: 12px; border-top: 1px solid var(--line); }
.sheet-legend span { display: inline-flex; align-items: center; gap: 8px; }
.lg { width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--line-strong); display: inline-block; position: relative; }
.lg.answered { background: var(--violet); border-color: var(--violet); }
.lg.flagged::after { content: ""; position: absolute; top: -3px; right: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--warn); }

.mobile-tabs { display: none; }
.mobile-bar { display: none; }

@media (max-width: 900px) {
  .exam-layout { grid-template-columns: 1fr; height: auto; }
  .exam-main { overflow: visible; }
  .exam-side {
    position: fixed; inset: auto 0 0 0; max-height: 72vh; z-index: 50; border-left: 0; border-top: 1px solid var(--line);
    border-radius: 18px 18px 0 0; box-shadow: var(--shadow-2); transform: translateY(105%); transition: transform .25s var(--ease);
    padding-bottom: calc(18px + env(safe-area-inset-bottom));
  }
  .exam-side.open { transform: none; }
  .sheet-cells { grid-template-columns: repeat(8, 1fr); }
  .split { display: block; }
  .split .resizer { display: none; }
  .split .pane { overflow: visible; }
  .split[data-tab="passage"] .pane-questions, .split[data-tab="questions"] .pane-passage { display: none; }
  .pane-passage { padding: 20px 18px 90px; }
  .pane-questions { padding: 16px 12px 90px; }
  .single { overflow: visible; padding-bottom: 80px; }
  .mobile-tabs {
    display: grid; grid-template-columns: 1fr 1fr; position: sticky; top: 63px; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--line);
  }
  .mobile-tabs button { border: 0; background: transparent; padding: 12px; font-weight: 600; color: var(--muted); border-bottom: 2.5px solid transparent; cursor: pointer; }
  .mobile-tabs button[aria-selected="true"] { color: var(--violet-ink); border-bottom-color: var(--violet); }
  .mobile-bar {
    display: flex; gap: 10px; position: fixed; left: 0; right: 0; bottom: 0; z-index: 45; padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(8px); border-top: 1px solid var(--line);
  }
  .mobile-bar .btn { flex: 1; min-width: 0; padding-inline: 10px; }
  .q { scroll-margin-top: 130px; }
  .exam-top .save-state { display: none; }
  .section-bar { padding: 10px 14px; flex-direction: column; gap: 2px; }
  .sheet-backdrop { position: fixed; inset: 0; background: rgba(10, 8, 30, .35); z-index: 49; }
}

/* ---------------- modal & toast ---------------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(14, 10, 40, .45); z-index: 80; display: grid; place-items: center; padding: 16px; animation: fade .15s ease; }
.modal {
  background: var(--surface); border-radius: var(--r-lg); width: min(480px, 100%); max-height: calc(100vh - 32px); overflow-y: auto;
  padding: 24px; box-shadow: var(--shadow-2); animation: pop .18s var(--ease); border: 1px solid var(--line);
}
.modal.wide { width: min(640px, 100%); }
.modal h2 { font-size: 1.2rem; }
.modal .btn-row { justify-content: flex-end; margin-top: 20px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.code-box {
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 1.5rem; letter-spacing: .12em; font-weight: 700; text-align: center;
  padding: 16px; border-radius: var(--r-md); background: var(--violet-weak); color: var(--violet-ink); border: 1.5px dashed var(--violet); user-select: all;
}
.toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 90; display: grid; gap: 8px; width: min(440px, calc(100% - 24px)); }
.toast { background: var(--ink); color: var(--paper); padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow-2); font-size: .92rem; animation: pop .2s var(--ease); }
.toast.warn { background: var(--warn); color: #fff; }
.toast.bad { background: var(--bad); color: #fff; }
.toast.good { background: var(--good); color: #fff; }
body.exam-mode .toasts { bottom: 84px; }

/* ---------------- results ---------------- */
.result-hero { display: grid; grid-template-columns: auto 1fr; gap: 32px; align-items: center; padding: 28px; }
.score-ring { width: 156px; height: 156px; position: relative; }
.score-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.score-ring .val { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.score-ring .val strong { font-size: 2.5rem; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -.03em; display: block; }
.score-ring .val span { font-size: .8rem; color: var(--muted); }
.result-stats { display: flex; flex-wrap: wrap; gap: 10px 26px; margin: 12px 0 18px; }
.result-stats div { display: grid; }
.result-stats b { font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.result-stats span { font-size: .8rem; color: var(--muted); }
.st-good b { color: var(--good); } .st-bad b { color: var(--bad); } .st-pending b { color: var(--pending); }
@media (max-width: 640px) { .result-hero { grid-template-columns: 1fr; justify-items: start; padding: 20px; } }

.fb-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.fb-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px 22px; }
.fb-card h3 { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.fb-card .sub { color: var(--muted); font-size: .85rem; margin-bottom: 14px; }
.fb-card ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.fb-card li { padding-left: 14px; border-left: 3px solid var(--line-strong); }
.fb-card li strong { display: block; }
.fb-card li .ev { font-size: .82rem; color: var(--muted); }
.fb-well li { border-left-color: var(--good); }
.fb-improve li { border-left-color: var(--bad); }
.fb-improve li.watch { border-left-color: var(--warn); }
.fb-plan ol { margin: 0; padding-left: 0; list-style: none; display: grid; gap: 14px; counter-reset: plan; }
.fb-plan ol > li { counter-increment: plan; padding-left: 40px; border: 0; position: relative; }
.fb-plan ol > li::before { content: counter(plan); position: absolute; left: 0; top: 0; width: 28px; height: 28px; border-radius: 50%; background: var(--violet); color: var(--on-violet); display: grid; place-items: center; font-weight: 700; font-size: .85rem; }
.fb-plan ol ul { margin-top: 6px; gap: 6px; }
.fb-plan ol ul li { border: 0; padding: 0; color: var(--ink-2); font-size: .92rem; }
.fb-errors table { width: 100%; }
@media (max-width: 860px) { .fb-grid { grid-template-columns: 1fr; } }
.fb-icon { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex: none; }
.fb-icon.good { background: var(--good-weak); color: var(--good); }
.fb-icon.bad { background: var(--bad-weak); color: var(--bad); }
.fb-icon.violet { background: var(--violet-weak); color: var(--violet-ink); }
.fb-icon.warn { background: var(--warn-weak); color: var(--warn); }

.bars { display: grid; gap: 12px; }
.bar-row { display: grid; grid-template-columns: minmax(120px, 190px) 1fr 76px; gap: 12px; align-items: center; font-size: .9rem; }
.bar-track { height: 10px; border-radius: 5px; background: var(--line); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 5px; background: var(--violet); }
.bar-row .v { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.bar-row .few { color: var(--muted); font-size: .78rem; }
@media (max-width: 560px) { .bar-row { grid-template-columns: 1fr 64px; } .bar-row .bar-track { grid-column: 1 / -1; grid-row: 2; } }

.err-list { display: grid; gap: 10px; }
.err-item { display: grid; grid-template-columns: 54px 1fr; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.err-item:first-child { border-top: 0; }
.err-item .no { font-weight: 700; color: var(--violet-ink); }
.err-item .ans { font-size: .9rem; display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 4px 0; }
.err-item .note { font-size: .9rem; color: var(--ink-2); }

.filter-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.filter-row button { border: 1px solid var(--line-strong); background: var(--surface); padding: 6px 14px; border-radius: 999px; font-size: .875rem; cursor: pointer; color: var(--ink-2); font-weight: 500; }
.filter-row button[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }

.review-section { margin-bottom: 22px; }
.review-section > h3 { margin: 20px 0 10px; }
details.passage-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 0 18px; margin-bottom: 12px; }
details.passage-box summary { padding: 14px 0; cursor: pointer; font-weight: 600; color: var(--violet-ink); }
details.passage-box .passage { padding-bottom: 14px; font-size: 1rem; }
.rq { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 16px 18px; margin-bottom: 12px; border-left: 4px solid var(--line-strong); }
.rq.correct { border-left-color: var(--good); }
.rq.wrong { border-left-color: var(--bad); }
.rq.blank { border-left-color: var(--muted); }
.rq.pending { border-left-color: var(--pending); }
.rq .opt { cursor: default; }
.rq .opt.is-correct { border-color: var(--good); background: var(--good-weak); }
.rq .opt.is-correct .bubble { background: var(--good); border-color: var(--good); color: #fff; }
.rq .opt.is-wrong { border-color: var(--bad); background: var(--bad-weak); }
.rq .opt.is-wrong .bubble { border-color: var(--bad); color: var(--bad); }
.rq .opt .onote { grid-column: 2; font-size: .84rem; color: var(--ink-2); }
.explain { margin-top: 12px; padding: 12px 14px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); font-size: .94rem; }
.explain h4 { font-size: .82rem; margin: 0 0 4px; color: var(--violet-ink); }
.explain-body p { margin: 0 0 6px; }
.explain-body ul { margin: 2px 0 8px; padding-left: 20px; }
.explain-body li { margin-bottom: 4px; }
.explain-body > :last-child { margin-bottom: 0; }
.evidence { font-family: var(--font-read); border-left: 3px solid var(--marker); padding: 4px 0 4px 12px; margin: 6px 0 10px; font-style: italic; color: var(--ink-2); }
.your-text { display: grid; gap: 4px; font-size: .94rem; }
.your-text .lab { font-size: .78rem; color: var(--muted); }
.your-text .wrongtxt { color: var(--bad); text-decoration: line-through; text-decoration-thickness: 1px; }
.your-text .oktxt { color: var(--good); font-weight: 600; }

/* ---------------- progress ---------------- */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 16px 18px; }
.tile b { display: block; font-size: 1.7rem; font-variant-numeric: tabular-nums; letter-spacing: -.02em; line-height: 1.2; }
.tile span { font-size: .82rem; color: var(--muted); }
@media (max-width: 760px) { .tiles { grid-template-columns: 1fr 1fr; } }
.two-col { display: grid; grid-template-columns: 1.2fr 1fr; gap: 18px; margin-top: 18px; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }
.chart-wrap { position: relative; }
.chart-wrap svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart-tip { position: absolute; pointer-events: none; background: var(--ink); color: var(--paper); padding: 7px 10px; border-radius: 8px; font-size: .8rem; white-space: nowrap; transform: translate(-50%, calc(-100% - 12px)); box-shadow: var(--shadow-2); }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: left; font-weight: 600; color: var(--muted); font-size: .8rem; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table-scroll { overflow-x: auto; }

/* ---------------- mistakes ---------------- */
.mistake-list { display: grid; gap: 10px; }
.mistake { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 14px 16px; display: grid; gap: 6px; }
.mistake .top { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; font-size: .85rem; color: var(--muted); }
.mistake .stem { color: var(--ink); }

/* ---------------- admin ---------------- */
.admin-nav { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 22px; border-bottom: 1px solid var(--line); padding-bottom: 12px; }
.admin-nav a { padding: 7px 12px; border-radius: 8px; text-decoration: none; color: var(--ink-2); font-weight: 500; font-size: .92rem; }
.admin-nav a[aria-current="page"], .admin-nav a:hover { background: var(--violet-weak); color: var(--violet-ink); }
.editor-bar { position: sticky; top: var(--header-h); z-index: 20; background: var(--paper); padding: 12px 0; border-bottom: 1px solid var(--line); margin-bottom: 18px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.editor-bar .grow { flex: 1; min-width: 180px; }
.ed-section { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); margin-bottom: 16px; }
.ed-section > .ed-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.ed-section > .ed-body { padding: 18px; }
.ed-q { border: 1px solid var(--line); border-radius: var(--r-md); padding: 14px 16px; margin-bottom: 12px; background: var(--surface-2); }
.ed-q-head { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.ed-opts { display: grid; gap: 8px; }
.ed-opt { display: grid; grid-template-columns: 36px 1fr; gap: 8px; align-items: center; }
.ed-opt label { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; border: 1.5px solid var(--line-strong); cursor: pointer; font-weight: 700; font-size: .85rem; }
.ed-opt input[type=radio] { position: absolute; opacity: 0; }
.ed-opt label:has(input:checked) { background: var(--good); border-color: var(--good); color: #fff; }
.ed-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ed-grid-3 { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 12px; }
@media (max-width: 760px) { .ed-grid-2, .ed-grid-3 { grid-template-columns: 1fr; } }
.tag-input { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 6px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); min-height: 44px; }
.tag-input .chip button { border: 0; background: transparent; cursor: pointer; color: inherit; padding: 0 0 0 2px; font-size: 1rem; line-height: 1; }
.tag-input input { border: 0; outline: none; background: transparent; flex: 1; min-width: 160px; padding: 6px; }
.validation { display: grid; gap: 4px; font-size: .9rem; }
.validation .e { color: var(--bad); }
.validation .w { color: var(--warn); }
.grading-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 16px 18px; margin-bottom: 12px; }
.rate { display: inline-block; min-width: 46px; text-align: right; font-variant-numeric: tabular-nums; }
.mini-bar { height: 6px; border-radius: 3px; background: var(--line); width: 90px; overflow: hidden; display: inline-block; vertical-align: middle; margin-right: 8px; }
.mini-bar i { display: block; height: 100%; background: var(--violet); }
.dist { display: flex; gap: 8px; font-size: .8rem; color: var(--ink-2); flex-wrap: wrap; }
.dist b.ok { color: var(--good); }
