:root {
  --k: 1;
  --pen: #c8372d;
  --graphite: #2a2a2a;
  /* palette: white content, light blue-grey chrome with dashed rules, royal-blue actions, near-black text */
  --bg: #ffffff; --chrome: #e6ecf7; --card: #ffffff; --ink: #1b1b1f; --ink2: #4c5262; --ink3: #8a90a0; --line: #c8cdd8; --dash: #1b1b1f;
  --brand: #3247c8; --brand-ink: #ffffff; --brand-soft: #e8ecfb; --accent: #3247c8; --navy: #1c2559;
  --ok: #2e7d4f; --ok-soft: #e4f2e8; --bad: #c8102e; --bad-soft: #fbe7ea; --warn: #b7791f;
  --paper: #ffffff; --radius: 12px; --shadow: 0 1px 3px rgba(20,30,70,.06);
  --serif: "Times New Roman", "ExamSerif", Times, "SimSun", "Songti SC", "STSong", "ExamSong", serif;
  --song: "SimSun", "Songti SC", "STSong", "ExamSong", "Times New Roman", "ExamSerif", serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151c; --chrome: #1b2130; --card: #181d27; --ink: #e8eaf0; --ink2: #a7adbb; --ink3: #6e7584; --line: #2e3545; --dash: #8d95a8;
    --brand: #7c8df2; --brand-ink: #0e1220; --brand-soft: #1f2645; --accent: #7c8df2; --navy: #c9d0f5;
    --ok: #63c08a; --ok-soft: #1b2e23; --bad: #ff6b7d; --bad-soft: #3a1f26; --paper: #151922;
    --shadow: none;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 16px/1.55 var(--sans); -webkit-text-size-adjust: 100%; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: var(--brand); }
h1, h2, h3 { margin: 0; line-height: 1.3; }
.muted { color: var(--ink2); }
.small { font-size: 13px; }
.hidden { display: none !important; }

/* ---------- app shell ---------- */
.page { max-width: 760px; margin: 0 auto; padding: calc(12px + var(--safe-t)) 16px calc(88px + var(--safe-b)); }
.topbar { display: flex; align-items: center; gap: 10px; padding: 6px 0 14px; }
.topbar h1 { font-size: 22px; flex: 1; letter-spacing: .5px; }
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; background: var(--card); border-top: 1px solid var(--line);
  display: flex; padding-bottom: var(--safe-b); z-index: 20; }
.tabbar a { flex: 1; text-align: center; padding: 8px 0 7px; font-size: 12px; color: var(--ink3); text-decoration: none; }
.tabbar a .ic { display: block; font-size: 20px; line-height: 1.2; }
.tabbar a.on { color: var(--brand); font-weight: 600; }

.card { background: var(--card); border-radius: calc(var(--radius) * var(--k)); box-shadow: var(--shadow); border: 1px solid var(--line); }
.set-card { padding: 16px; margin-bottom: 14px; }
.set-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.set-head h2 { font-size: 18px; flex: 1; }
.note { font-size: 13px; color: var(--ink2); background: var(--bg); border-radius: calc(8px * var(--k)); padding: 6px 10px; margin: 0 0 10px; }
.sec-row { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 12px 4px; border-top: 1px solid var(--line); }
.sec-row:first-of-type { border-top: 0; }
.sec-row .tag { flex: none; width: 40px; height: 40px; border-radius: calc(10px * var(--k)); display: grid; place-items: center; font-size: 13px; font-weight: 600;
  background: var(--brand-soft); color: var(--brand); }
.sec-row .tag.t-writing, .sec-row .tag.t-translation { background: #f6eadc; color: #9a5a19; }
.sec-row .tag.t-listening { background: #e6ecf7; color: #3a5a92; }
@media (prefers-color-scheme: dark) {
  .sec-row .tag.t-writing, .sec-row .tag.t-translation { background: #33281c; color: #e0a15e; }
  .sec-row .tag.t-listening { background: #1e2638; color: #8fb0e8; }
}
.sec-row .info { flex: 1; min-width: 0; }
.sec-row .info b { display: block; font-weight: 600; }
.sec-row .info span { font-size: 13px; color: var(--ink2); }
.sec-row .best { font-size: 13px; color: var(--ink2); text-align: right; }
.sec-row .best b { display: block; color: var(--ink); font-size: 15px; }
.chev { color: var(--ink3); }

.btn { display: inline-block; vertical-align: middle; text-align: center; white-space: nowrap; text-decoration: none; line-height: 1; padding: 15px 18px; border-radius: calc(12px * var(--k));
  background: var(--brand); color: var(--brand-ink); font-weight: 600; }
.btn.sm { padding: 12px 12px; border-radius: calc(10px * var(--k)); font-size: 14px; }
.btn.ghost { background: var(--brand-soft); color: var(--brand); }
.btn.line { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.danger { background: var(--bad-soft); color: var(--bad); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; }
.resume { padding: 14px 16px; margin-bottom: 14px; display: flex; align-items: center; gap: 12px; border-color: var(--accent); }
.resume .info { flex: 1; }

/* ---------- sheets ---------- */
.sheet-mask { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 50; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.sheet { background: var(--card); width: 100%; max-width: 560px; border-radius: calc(18px * var(--k)) calc(18px * var(--k)) 0 0; padding: 18px 18px calc(18px + var(--safe-b));
  max-height: 88vh; overflow: auto; animation: up .18s ease-out; }
@media (min-width: 700px) { .sheet-mask { align-items: center; } .sheet { border-radius: calc(18px * var(--k)); } }
.sheet h3 { font-size: 18px; margin-bottom: 4px; }
.sheet .row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.sheet .row:last-child { border-bottom: 0; }
.sheet .row label { flex: 1; }
.sheet .actions { display: flex; gap: 10px; margin-top: 16px; }
.sheet .actions .btn { flex: 1; }
@keyframes up { from { transform: translateY(30px); opacity: .6; } }
@keyframes fade { from { opacity: 0; } }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: calc(10px * var(--k)); overflow: hidden; }
.stepper button { width: 36px; height: 34px; font-size: 18px; color: var(--brand); }
.stepper input { width: 46px; text-align: center; border: 0; background: transparent; height: 34px; -moz-appearance: textfield; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; }
.check { width: 22px; height: 22px; accent-color: var(--brand); }

#toast { position: fixed; left: 50%; top: calc(14px + var(--safe-t)); transform: translateX(-50%); z-index: 80; pointer-events: none; }
#toast div { background: var(--ink); color: var(--bg); padding: 9px 16px; border-radius: calc(20px * var(--k)); font-size: 14px; margin-top: 6px; animation: up .2s; text-align: center; }

/* ---------- login ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login .box { width: 100%; max-width: 340px; text-align: center; }
.login .logo { width: 72px; height: 72px; border-radius: calc(18px * var(--k)); margin: 0 auto 14px; display: block; }
.login h1 { font-size: 24px; margin-bottom: 4px; }
.login input { width: 100%; height: 48px; border-radius: calc(12px * var(--k)); border: 1px solid var(--line); background: var(--card); padding: 0 14px; margin: 22px 0 12px; font-size: 18px; text-align: center; letter-spacing: 2px; }

/* ---------- exam ---------- */
.exam { position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--bg); }
.exam-top { flex: none; background: var(--card); border-bottom: 1px solid var(--line); padding: calc(6px + var(--safe-t)) 10px 6px; }
.exam-bar { display: flex; align-items: center; gap: 8px; height: 44px; }
.exam-bar .x { width: 36px; height: 36px; border-radius: calc(10px * var(--k)); font-size: 20px; color: var(--ink2); }
.exam-bar .title { flex: 1; min-width: 0; font-size: 14px; color: var(--ink2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 18px; padding: 4px 10px; border-radius: calc(10px * var(--k)); background: var(--brand-soft); color: var(--brand); }
.timer.low { background: var(--bad-soft); color: var(--bad); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .65; } }
.sec-tabs { display: flex; gap: 6px; overflow-x: auto; padding: 4px 0 2px; scrollbar-width: none; }
.sec-tabs::-webkit-scrollbar { display: none; }
.sec-tabs button { flex: none; padding: 5px 12px; border-radius: calc(16px * var(--k)); font-size: 13px; background: var(--bg); color: var(--ink2); white-space: nowrap; }
.sec-tabs button.on { background: var(--brand); color: var(--brand-ink); font-weight: 600; }
.sec-tabs button .cnt { opacity: .75; margin-left: 4px; font-size: 12px; }

.exam-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.split { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.pane { overflow-y: auto; -webkit-overflow-scrolling: touch; min-height: 0; }
.pane-a { flex: 0 0 61.8%; background: var(--paper); }
.pane-q { flex: 1 1 0; background: var(--bg); }
/* Draggable divider: 1px line + small grip; the touch area overhangs both panes without taking space. */
.divider { position: relative; flex: none; height: 1px; background: var(--line); z-index: 5; touch-action: none; }
.divider::before { content: ""; position: absolute; left: 0; right: 0; top: -11px; bottom: -11px; }
.divider .grip { position: absolute; left: 50%; top: 50%; width: 36px; height: 5px; margin: -2.5px 0 0 -18px; border-radius: 3px;
  background: var(--ink3); opacity: .55; transition: opacity .15s, transform .15s, background .15s; pointer-events: none; }
.divider.armed .grip { opacity: 1; background: var(--brand); transform: scale(1.35); }
.divider.armed { background: var(--brand); }
.split.dragging { user-select: none; -webkit-user-select: none; }
@media (min-width: 900px) {
  .split { flex-direction: row; }
  .divider { width: 1px; height: auto; }
  .divider::before { top: 0; bottom: 0; left: -8px; right: -8px; cursor: col-resize; }
  .divider .grip { width: 5px; height: 36px; margin: -18px 0 0 -2.5px; }
}

.group-title { font-size: 13px; font-weight: 700; color: var(--ink2); margin: 14px 2px 8px; letter-spacing: .3px; }
.group-title:first-child { margin-top: 2px; }

.bank-hint { font-size: 13px; color: var(--ink2); margin: 2px 2px 10px; display: flex; align-items: center; gap: 8px; }
.bank-hint .btn { margin-left: auto; }



.audio-box { background: var(--card); border: 1px solid var(--line); border-radius: calc(var(--radius) * var(--k)); padding: 12px; margin-bottom: 12px; }
.audio-box audio { width: 100%; }

.exam-foot { flex: none; display: flex; gap: 8px; padding: 8px 10px calc(8px + var(--safe-b)); background: var(--card); border-top: 1px solid var(--line); }
.exam-foot .btn { flex: 1; padding-top: 14px; padding-bottom: 14px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); gap: 8px; margin: 10px 0 4px; }
.card-grid button { height: 40px; border-radius: calc(10px * var(--k)); border: 1px solid var(--line); font-weight: 600; background: var(--bg); }
.card-grid button.done { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.card-grid button.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.card-grid button.bad { background: var(--bad); border-color: var(--bad); color: #fff; }

/* ---------- results ---------- */
.score-hero { padding: 20px 18px; text-align: center; margin-bottom: 14px; }
.score-hero .big { font-size: 44px; font-weight: 800; color: var(--brand); line-height: 1.1; font-variant-numeric: tabular-nums; }
.score-hero .big small { font-size: 18px; color: var(--ink3); font-weight: 600; }
.score-hero .sub { color: var(--ink2); font-size: 14px; margin-top: 6px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.stats div { background: var(--bg); border-radius: calc(10px * var(--k)); padding: 8px 4px; }
.stats b { display: block; font-size: 18px; font-variant-numeric: tabular-nums; }
.stats span { font-size: 12px; color: var(--ink2); }
.sec-result { padding: 14px 14px 6px; margin-bottom: 14px; }
.sec-result h3 { font-size: 17px; display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.sec-result h3 .pts { margin-left: auto; font-size: 14px; color: var(--ink2); font-weight: 500; }
.ritem { border-top: 1px solid var(--line); padding: 10px 2px; }
.ritem .line { display: flex; gap: 8px; align-items: baseline; width: 100%; text-align: left; }
.ritem .mark { flex: none; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; color: #fff; font-weight: 700; }
.ritem .mark.ok { background: var(--ok); } .ritem .mark.bad { background: var(--bad); } .ritem .mark.skip { background: var(--ink3); }
.ritem .line .t { flex: 1; min-width: 0; }
.ritem .line .t .n { font-weight: 700; margin-right: 4px; }
.ritem .ans { font-size: 13px; color: var(--ink2); margin-top: 2px; }
.ritem .ans b.ok { color: var(--ok); } .ritem .ans b.bad { color: var(--bad); }
.explain { background: var(--bg); border-radius: calc(10px * var(--k)); padding: 10px 12px; margin-top: 8px; font-size: 14px; line-height: 1.7; color: var(--ink); }
.explain .opts { font-size: 13px; color: var(--ink2); margin-bottom: 6px; }
details.fold { border-top: 1px solid var(--line); padding: 10px 2px; }
details.fold summary { cursor: pointer; color: var(--brand); font-weight: 600; font-size: 14px; list-style: none; }
details.fold summary::-webkit-details-marker { display: none; }
details.fold summary::before { content: "▸ "; }
details.fold[open] summary::before { content: "▾ "; }
.transcript p { margin: 6px 0; font-family: var(--serif); font-size: 15px; line-height: 1.65; }
.transcript h5 { margin: 12px 0 4px; font-size: 13px; color: var(--ink2); }
.compare h5 { margin: 12px 0 6px; font-size: 13px; color: var(--ink2); }
.compare .txt { background: var(--paper); border: 1px solid var(--line); border-radius: calc(10px * var(--k)); padding: 10px 12px; font-family: var(--serif); line-height: 1.7; white-space: pre-wrap; }
.bands { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: 8px; }
.bands button { padding: 9px 2px 7px; border-radius: calc(10px * var(--k)); border: 1px solid var(--line); background: var(--card); font-size: 13px; line-height: 1.3; }
.bands button b { display: block; font-size: 16px; }
.bands button.on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.band-desc { font-size: 12.5px; color: var(--ink2); margin-top: 8px; line-height: 1.6; }

.list-item { display: flex; align-items: center; gap: 12px; padding: 14px; margin-bottom: 10px; width: 100%; text-align: left; }
.list-item .info { flex: 1; min-width: 0; }
.list-item .info b { display: block; }
.list-item .info span { font-size: 13px; color: var(--ink2); }
.list-item .sc { text-align: right; font-weight: 700; color: var(--brand); font-variant-numeric: tabular-nums; }
.list-item .sc small { display: block; color: var(--ink3); font-weight: 500; font-size: 12px; }
.empty { text-align: center; color: var(--ink2); padding: 50px 20px; }
.empty .ic { font-size: 40px; display: block; margin-bottom: 8px; }
.wgroup { padding: 14px; margin-bottom: 12px; }
.wgroup h3 { font-size: 16px; margin-bottom: 2px; }
.witem { display: flex; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); font-size: 14px; align-items: flex-start; }
.witem .n { font-weight: 700; color: var(--bad); flex: none; width: 26px; }
.witem .t { flex: 1; min-width: 0; color: var(--ink); }
.witem .times { flex: none; font-size: 12px; color: var(--ink3); }
.set-block { padding: 14px 16px; margin-bottom: 14px; }
.set-block h3 { font-size: 16px; margin-bottom: 6px; }
.field-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.field-row:first-of-type { border-top: 0; }
.field-row label { flex: 1; }
.seg { display: inline-flex; background: var(--bg); border-radius: calc(10px * var(--k)); padding: 3px; }
.seg button { padding: 5px 12px; border-radius: calc(8px * var(--k)); font-size: 13px; color: var(--ink2); }
.seg button.on { background: var(--card); color: var(--ink); font-weight: 600; box-shadow: var(--shadow); }
.pill { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: calc(10px * var(--k)); background: var(--bg); color: var(--ink2); }
.pill.warn { background: var(--bad-soft); color: var(--bad); }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; margin: 60px auto; }
@keyframes spin { to { transform: rotate(360deg); } }


/* Continuous-curvature corners are drawn by squircle.js (same code as byamy-mail) in every browser. */

/* ---------- paper-style exam typography (follows the official CET-6 paper) ---------- */
.paper { max-width: 720px; margin: 0 auto; padding: 14px 16px 40px; font-family: var(--serif); font-size: 17px; line-height: 1.6;
  color: var(--ink); text-align: justify; font-kerning: normal; -webkit-hyphens: auto; hyphens: auto; hyphenate-limit-chars: 6 3 3; }
.paper .cjk { display: inline-block; text-indent: 0; }
.paper [lang="zh-CN"] { -webkit-hyphens: none; hyphens: none; }
.paper.inset { padding: 8px 0 4px; }
.paper p { margin: 0; }
.exfont { font-family: var(--serif); }
.ex-part { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; font-weight: 700; font-size: clamp(14.5px, 4.3vw, 19px); white-space: nowrap; line-height: 1.3; margin: 4px 0 6px; text-align: left; }
.ex-part span:nth-child(2) { flex: 1; text-align: center; }
.ex-sec { font-weight: 700; margin-top: 4px !important; text-align: left; }
.ex-dir { margin: 0 0 10px !important; }
.ex-dir i { font-style: italic; }
.ex-copy { font-weight: 700; text-decoration: underline; text-underline-offset: 2px; text-align: left; margin-bottom: 12px !important; }
.ex-bold { font-weight: 700; text-align: left; }
.ex-bold + .ex-q, .ex-bold + .ex-p { margin-top: 2px; }
.ex-p { text-indent: 2em; }
.ex-p.cn { font-family: var(--song); line-height: 1.85; letter-spacing: .02em; margin-bottom: 12px !important; }
.ex-title { font-weight: 700; text-align: center; margin: 6px 0 4px !important; line-height: 1.35; }

/* paragraphs labelled A) B) … with hanging indent */
.mp { padding-left: 1.75em; text-indent: -1.75em; border-radius: 6px; transition: background .2s; }
.mp .lab { display: inline-block; width: 1.75em; text-indent: 0; }
.mp.tappable { cursor: pointer; }
.mp.flash { background: var(--brand-soft); }

/* numbered questions: number column + body, options under the stem */
.ex-q { display: grid; grid-template-columns: 2em 1fr; margin-top: 4px; }
.ex-q .no { text-align: left; }
.ex-q .stem { text-align: left; }
.ex-opts { display: grid; grid-template-columns: 1fr; padding-left: .4em; }
.ex-q .stem + .ex-opts { padding-left: 1.1em; }
.ex-opts.two { grid-template-columns: 1fr 1fr; grid-template-rows: auto auto; grid-auto-flow: column; column-gap: 10px; }
.ex-opt { display: grid; grid-template-columns: 1.55em 1fr; align-items: baseline; width: 100%; text-align: left; font: inherit; line-height: 1.45;
  padding: 3px 6px; margin: 1px 0 1px -6px; border-radius: 7px; color: var(--ink); }
.ex-opt .k { white-space: nowrap; }
.ex-opt.ok { background: var(--ok-soft); } .ex-opt.ok .k { color: var(--ok); font-weight: 700; }
.ex-opt.bad { background: var(--bad-soft); } .ex-opt.bad .k { color: var(--bad); font-weight: 700; }

/* cloze blanks: __26__ like the paper */
.blank { display: inline-block; min-width: 3.4em; padding: 0 .3em; margin: 0 .15em; border-bottom: 1px solid currentColor; text-align: center;
  font: inherit; line-height: 1.25; text-indent: 0; vertical-align: baseline; color: var(--ink); border-radius: 4px 4px 0 0; }
.blank .no { font-size: .82em; }
.blank.filled .no { display: none; }
.blank.filled .w { color: var(--brand); }
.blank.given .w { color: var(--ink2); }
.blank.sel { background: var(--brand-soft); border-bottom: 2px solid var(--accent); }
.blank.ok { background: var(--ok-soft); } .blank.ok .w { color: var(--ok); }
.blank.bad { background: var(--bad-soft); } .blank.bad .w { color: var(--bad); }

/* word bank: boxed, two columns (A–H | I–O) */
.bank { display: grid; grid-template-columns: 1fr 1fr; grid-auto-flow: column; column-gap: 8px; border: 1px solid var(--ink); padding: 8px 10px; }
.bank button { display: grid; grid-template-columns: 1.55em 1fr; align-items: baseline; text-align: left; font: inherit; line-height: 1.45; padding: 3px 6px; margin: 0 -6px; border-radius: 7px; }
.bank button.used { color: var(--ink3); }
.bank button.cur { background: var(--brand-soft); color: var(--brand); }
.bank-hint { font: 13px/1.4 var(--sans); color: var(--ink2); margin: 0 0 8px; display: flex; align-items: center; gap: 8px; min-height: 30px; text-align: left; }
.bank-hint .btn { margin-left: auto; }

/* matching statements */
.mq { margin-top: 2px; }
.mstem { display: grid; grid-template-columns: 2em 1fr auto; column-gap: 6px; align-items: start; width: 100%; text-align: left; font: inherit; line-height: inherit;
  padding: 3px 6px; margin: 0 -6px; border-radius: 7px; }
.mq.active .mstem { background: var(--brand-soft); }
.mstem .txt { text-align: left; }
.ex-opt .v { -webkit-hyphens: auto; hyphens: auto; }
.mstem .pick { width: 30px; height: 26px; margin-top: 1px; border-radius: 7px; border: 1px dashed var(--ink3); display: flex; align-items: center; justify-content: center;
  font: 700 15px/1 var(--serif); color: var(--ink3); }
.mstem .pick.has { border: 1px solid var(--brand); background: var(--brand); color: var(--brand-ink); }
.letters { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 0 6px 2em; }
.letters button { width: 36px; height: 32px; border-radius: 8px; border: 1px solid var(--line); background: var(--card);
  display: flex; align-items: center; justify-content: center; font: 600 15px/1 var(--serif); }
.letters button.on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }

textarea.answer { display: block; width: 100%; min-height: 42vh; margin-top: 10px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--card);
  padding: 12px 14px; font: 17px/1.6 var(--serif); resize: vertical; text-align: left; }
textarea.answer:focus { outline: 2px solid var(--brand); outline-offset: -1px; }
.wc { text-align: right; font: 13px var(--sans); color: var(--ink2); margin-top: 6px; }
.audio-box { font-family: var(--sans); text-align: left; }

/* ---------- optical centering of labels ----------
   Trim each label's text box to cap-height/baseline so padding centres the letters themselves,
   whatever font the device uses (digits, Latin and CJK all land within ~0.5px of centre). */
.btn, .timer, .tabbar a, .pill, .sec-tabs button, .seg button, .letters button, .card-grid button, .pick, .tag, .bands button b,
.bank-hint .btn, .split-handle button { text-box: trim-both cap alphabetic; }
.timer { padding: 8px 10px; line-height: 1; }
.pill { padding: 5px 8px; }
.sec-tabs button { padding: 8px 12px; }
.seg button { padding: 8px 12px; }
.tabbar a { padding: 10px 0 9px; }
.tabbar a .ic { margin-bottom: 6px; }
.stepper button { position: relative; }
.stepper button::before, .stepper button::after { content: ""; position: absolute; left: 50%; top: 50%; background: currentColor; border-radius: 1px; }
.stepper button::before { width: 12px; height: 2px; margin: -1px 0 0 -6px; }
.stepper .st-plus::after { width: 2px; height: 12px; margin: -6px 0 0 -1px; }
.field-row label.btn { flex: none; }

/* ---------- pen marks on the passage ---------- */
@media (prefers-color-scheme: dark) { :root { --pen: #ff7a6b; } }
.lab[data-lab] { cursor: pointer; position: relative; }
.lab.struck::after, .letters button.struck::after { content: ""; position: absolute; left: -.1em; right: .35em; top: 52%; height: 1.6px; background: var(--pen); transform: rotate(-12deg); }
.letters button { position: relative; }
.letters button.struck::after { left: 7px; right: 7px; }
.letters button.struck:not(.on) { color: var(--ink3); }
.sw { display: flex; align-items: center; gap: 8px; font: 13px/1.3 var(--sans); color: var(--ink2); margin: -2px 0 8px; text-align: left; }
.sw input { width: 18px; height: 18px; accent-color: var(--brand); margin: 0; }

/* ---------- question number = final answer; option pen marks ---------- */
.ex-q .no { display: block; text-align: left; font: inherit; line-height: inherit; color: inherit; padding: 0; align-self: start;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.ex-opt { position: relative; }
.ex-opt .k { position: relative; }


/* ---------- deletable history rows ---------- */
.swipe-tip { margin: -6px 2px 10px; }
.swipe-row { position: relative; margin-bottom: 10px; border-radius: var(--radius); overflow: hidden; }
.swipe-row .list-item { margin-bottom: 0; position: relative; z-index: 1; text-decoration: none; color: inherit; touch-action: pan-y; -webkit-user-drag: none; user-select: none; -webkit-user-select: none; }
.swipe-del { position: absolute; top: 50%; right: 14px; width: 46px; height: 46px; margin-top: -23px; border-radius: 50%; visibility: hidden; background: var(--bad); color: #fff;
  display: flex; align-items: center; justify-content: center; box-shadow: 0 3px 10px rgba(192,57,43,.3); transform: scale(.6); opacity: 0; transition: transform .18s ease, opacity .18s ease; }
.swipe-del svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.swipe-row.open .swipe-del { transform: scale(1); opacity: 1; }
.hover-del { display: none; width: 34px; height: 34px; border-radius: 10px; color: var(--bad); align-items: center; justify-content: center; flex: none; }
.hover-del svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
@media (hover: hover) and (pointer: fine) {
  .swipe-del { display: none; }
  .swipe-tip { display: none; }
  .swipe-row:hover .hover-del { display: inline-flex; }
  .hover-del:hover { background: var(--bad-soft); }
}
.sheet .actions.col { flex-direction: column; }
.swipe-row.reveal .swipe-del { visibility: visible; }
.btn.danger-solid { background: var(--bad); color: #fff; }

/* ---------- pencil layer ---------- */
@media (prefers-color-scheme: dark) { :root { --graphite: #e4e4e4; } }
.paper { position: relative; }
svg.pencil { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; z-index: 3; }
svg.pencil image { opacity: .92; }
@media (prefers-color-scheme: dark) { svg.pencil image { filter: invert(1); opacity: .85; } }
.ex-opt .k { -webkit-user-select: none; user-select: none; }
.ex-opt .v, .mstem .txt { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
.ex-opt, .mstem { cursor: pointer; }
.ex-opt:focus-visible, .mstem:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
html.radial-on, html.radial-on * { -webkit-user-select: none !important; user-select: none !important; -webkit-touch-callout: none !important; }

/* ---------- long-press menu (simplified Pinterest style) ---------- */
.radial { position: fixed; inset: 0; z-index: 70; pointer-events: none; }
.radial .r-veil { position: absolute; inset: 0; background: rgba(255,255,255,.82); animation: fade .15s; }
@media (prefers-color-scheme: dark) { .radial .r-veil { background: rgba(16,20,18,.85); } }
.radial .r-hole { position: absolute; border-radius: 12px; box-shadow: 0 0 0 200vmax rgba(255,255,255,.82); animation: fade .15s; }
@media (prefers-color-scheme: dark) { .radial .r-hole { box-shadow: 0 0 0 200vmax rgba(16,20,18,.85); } }
.radial .rb { position: absolute; width: 50px; height: 50px; margin: -25px 0 0 -25px; border-radius: 50%; pointer-events: auto;
  background: #fff; color: #111; box-shadow: 0 2px 12px rgba(0,0,0,.18); display: flex; align-items: center; justify-content: center;
  transition: transform .12s ease, background .12s, color .12s; animation: pop .16s ease-out backwards; font: 700 20px/1 var(--serif); }
.radial .rb svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.radial .rb.on { box-shadow: 0 0 0 2px #111, 0 2px 12px rgba(0,0,0,.18); }
.radial .rb.hot { transform: scale(1.25); background: #111; color: #fff; }
@keyframes pop { from { transform: scale(.4); opacity: 0; } }

/* word/sentence toolbar: white round buttons with captions, like the long-press menu */
.annbar { position: fixed; z-index: 60; display: flex; gap: 12px; padding: 0; background: none; }
.annbar button { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.annbar .c { width: 46px; height: 46px; border-radius: 50%; background: #fff; color: #111; box-shadow: 0 2px 12px rgba(0,0,0,.2);
  display: flex; align-items: center; justify-content: center; transition: transform .1s, background .1s, color .1s; }
.annbar button:active .c { transform: scale(1.15); background: #111; color: #fff; }
.annbar .c svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.annbar .l { font: 600 12px/1 var(--sans); color: var(--ink); background: var(--card); padding: 3px 6px; border-radius: 6px; box-shadow: 0 1px 4px rgba(0,0,0,.12); }
/* inside the paper, long-press selects text without the iPhone copy/look-up menu */
.paper { -webkit-touch-callout: none; }

.radial .r-card { position: absolute; max-width: min(360px, calc(100vw - 16px)); padding: 8px 16px 10px 14px; font-size: 25px; line-height: 1.45;
  background: var(--paper); border-radius: 14px; box-shadow: 0 6px 28px rgba(0,0,0,.16); text-align: left; animation: fade .12s; pointer-events: none; }
.radial .r-card .ex-opt { margin: 0; padding: 2px 4px; }
.radial .r-card p { margin: 0; text-indent: 0; }
.radial .r-letter { position: absolute; width: auto; opacity: 0; transform: scale(.85); transition: opacity .1s, transform .1s; pointer-events: none; }
.radial .r-letter.show { opacity: .95; transform: none; }
@media (prefers-color-scheme: dark) { .radial .r-letter { filter: invert(1); } }

.annlayer { position: fixed; inset: 0; z-index: 59; pointer-events: none; }
.annlayer .r-hole { position: absolute; border-radius: 8px; box-shadow: 0 0 0 200vmax rgba(255,255,255,.82); }
@media (prefers-color-scheme: dark) { .annlayer .r-hole { box-shadow: 0 0 0 200vmax rgba(16,20,18,.85); } }
.annlayer .r-card { position: absolute; max-width: min(360px, calc(100vw - 16px)); padding: 8px 16px 12px; font-size: 25px; line-height: 1.5;
  background: var(--paper); border-radius: 14px; box-shadow: 0 6px 28px rgba(0,0,0,.16); text-align: left; }
.annlayer .r-card p { margin: 0; text-indent: 0; }
.annbar button.hot .c { transform: scale(1.18); background: #111; color: #fff; }

/* ---------- colour scheme: blue-grey chrome, dashed rules, pill buttons ---------- */
.exam-top { background: var(--chrome); border-bottom: 2px dashed var(--dash); }
.exam-foot { background: var(--chrome); border-top: 2px dashed var(--dash); }
.tabbar { background: var(--chrome); border-top: 2px dashed var(--dash); }
.tabbar a { color: var(--ink2); }
.tabbar a.on { color: var(--brand); }
.timer, .timer.low { background: none; color: var(--ink); font-size: 22px; padding: 6px 6px; }
.timer.low { color: var(--bad); }
.btn { border-radius: 999px; }
.btn.line { border: 1.5px solid var(--ink); color: var(--ink); }
.btn.ghost { background: var(--brand-soft); color: var(--brand); }
.exam-bar .btn { background: var(--brand); color: var(--brand-ink); }
.exam-foot #prev, .exam-foot #next { background: var(--brand); color: var(--brand-ink); border: 0; }
.exam-foot #prev:disabled, .exam-foot #next:disabled { opacity: .35; }
.exam-foot #card { background: var(--ink); color: var(--bg); }
.sec-tabs button { background: var(--card); border: 1px solid var(--line); }
.sec-tabs button.on { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.card-grid button { background: var(--card); border: 1.5px dashed var(--ink); color: var(--brand); border-radius: 4px; }
.card-grid button.done { background: var(--brand); border: 1.5px solid var(--brand); color: var(--brand-ink); }
.pane-a { background: var(--paper); }
.pane-q { background: var(--paper); }
.divider { background: #8a8f9a; }
.card { border-color: var(--line); }
.sec-row .tag { background: var(--brand-soft); color: var(--brand); }
.sec-row .tag.t-writing, .sec-row .tag.t-translation { background: #f1ecfa; color: #5a3fb0; }
.sec-row .tag.t-listening { background: #e6f1fb; color: #1d5f9e; }
@media (prefers-color-scheme: dark) {
  .sec-row .tag.t-writing, .sec-row .tag.t-translation { background: #2a2340; color: #b9a6f2; }
  .sec-row .tag.t-listening { background: #1b2a3d; color: #8fc0ee; }
}
.topbar h1 { color: var(--ink); }
.pill { background: var(--chrome); color: var(--ink2); }
.mstem .pick.has, .letters button.on { background: var(--brand); border-color: var(--brand); }
.resume { border-color: var(--brand); }

/* ---------- home: year / month / set folding ---------- */
.fold.closed > .fold-body, .fold.closed > .set-head + .fold-body { display: none; }
.fold-btn { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; }
.tri { flex: none; width: 0; height: 0; border-left: 6px solid var(--ink); border-top: 5px solid transparent; border-bottom: 5px solid transparent; transform: rotate(90deg); transition: transform .18s ease; }
.fold.closed > .fold-btn .tri, .fold.closed > .set-head .tri { transform: none; }
.yr { margin-bottom: 6px; }
.yr-head { padding: 12px 2px; font-size: 20px; border-bottom: 2px dashed var(--dash); margin-bottom: 10px; }
.yr-head b, .mo-head b { flex: 1; }
.yr-head .cnt, .mo-head .cnt { font-size: 13px; color: var(--ink2); }
.mo-head { padding: 6px 2px 10px; font-size: 16px; }
.mo > .fold-body { padding-left: 16px; }
.set-card.fold { padding: 12px 14px; }
.set-card.fold .set-head { margin-bottom: 0; }
.set-card.fold .fold-body { margin-top: 8px; border-top: 1px solid var(--line); padding-top: 2px; }
.set-card .fold-btn { flex: 1; min-width: 0; }
.set-card .fold-btn .info { flex: 1; min-width: 0; }
.set-card .fold-btn .info b { display: block; font-size: 17px; }
.set-card .fold-btn .info span { font-size: 13px; color: var(--ink2); }
.audio-row { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 10px 14px; margin-bottom: 10px;
  border: 1.5px dashed var(--line); border-radius: calc(12px * var(--k)); background: var(--card); }
.audio-row .tag { flex: none; width: 40px; height: 40px; border-radius: calc(10px * var(--k)); display: grid; place-items: center; font-size: 13px; font-weight: 600; background: #e6f1fb; color: #1d5f9e; }
.audio-row .info { flex: 1; min-width: 0; }
.audio-row .info b { display: block; font-weight: 600; }
.audio-row .info span { font-size: 13px; color: var(--ink2); }
.audio-row .chev, .sec-row .chev { color: var(--ink3); }
.sub-h { font-size: 14px; margin: 16px 0 2px; color: var(--ink2); }

/* ---------- 积累 ---------- */
.ok { color: var(--ok); } .bad { color: var(--bad); }
.rand-card { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 16px; margin-bottom: 14px; background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.rand-card .info { flex: 1; } .rand-card b { display: block; font-size: 18px; } .rand-card span span { font-size: 13px; opacity: .85; }
.acc-block { padding: 16px; margin-bottom: 14px; }
.acc-block h3 { font-size: 15px; margin-bottom: 4px; }
.acc-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.acc-head h2 { flex: 1; font-size: 18px; }
.meter { height: 6px; border-radius: 3px; background: var(--brand-soft); overflow: hidden; margin: 2px 0 10px; }
.meter i { display: block; height: 100%; background: var(--brand); border-radius: 3px; }
.meter.thin { height: 3px; border-radius: 0; margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 12px; }
.chip { display: inline-block; padding: 6px 10px; border-radius: 999px; font-size: 13px; line-height: 1; background: var(--card); border: 1px solid var(--line); color: var(--ink); white-space: nowrap; }
.chip i { font-style: normal; color: var(--ink3); margin-left: 2px; }
.chip.on { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.chip.on i { color: inherit; opacity: .7; }
button.chip { cursor: pointer; }
.pick-chips { margin: 8px 0 6px; }
.acc-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.acc-btns .btn { flex: 1; padding: 13px 10px; }
.witem .chip { flex: none; padding: 4px 8px; font-size: 12px; }

.qz { position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--bg); }
.qz-top { flex: none; display: flex; align-items: center; gap: 10px; padding: calc(8px + var(--safe-t)) 12px 8px; background: var(--chrome); }
.qz-x { width: 34px; height: 34px; display: grid; place-items: center; text-decoration: none; color: var(--ink); font-size: 18px; }
.qz-title { flex: 1; font-weight: 600; text-align: center; }
.qz-count { min-width: 34px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
.qz .meter.thin { background: var(--chrome); border-bottom: 2px dashed var(--dash); height: 5px; }
.qz-body { flex: 1; overflow-y: auto; padding: 18px 16px 24px; max-width: 680px; width: 100%; margin: 0 auto; }
.qz-tag { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.qz-stem { font-size: 19px; line-height: 1.5; font-weight: 600; margin-bottom: 16px; }
.qz-stem.zh { font-weight: 500; }
.qz-opts { display: flex; flex-direction: column; gap: 10px; }
.qz-opt { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: calc(12px * var(--k)); background: var(--card); font-size: 16px; line-height: 1.4; }
.qz-opt .l { flex: none; width: 28px; height: 28px; border-radius: 50%; border: 1.5px solid var(--ink); display: grid; place-items: center; font-weight: 700; font-size: 14px; }
.qz-opt .v { flex: 1; min-width: 0; }
.qz-opts:not(.done) .qz-opt:active { border-color: var(--brand); }
@media (hover: hover) { .qz-opts:not(.done) .qz-opt:hover { border-color: var(--brand); } }
.qz-opt.right { border-color: var(--ok); background: var(--ok-soft); }
.qz-opt.right .l { background: var(--ok); border-color: var(--ok); color: #fff; }
.qz-opt.wrongpick { border-color: var(--bad); background: var(--bad-soft); }
.qz-opt.wrongpick .l { background: var(--bad); border-color: var(--bad); color: #fff; }
.qz-opts.done .qz-opt:not(.right):not(.wrongpick) { opacity: .55; }
.qz-exp { margin-top: 16px; padding: 12px 14px; border-radius: calc(12px * var(--k)); background: var(--chrome); font-size: 15px; line-height: 1.6; }
.qz-exp b { display: block; margin-bottom: 2px; }
.qz-exp p { margin: 0; }
.qz-exp .en { font-family: var(--serif); font-size: 17px; margin: 4px 0 6px; }
.qz-foot { flex: none; display: flex; gap: 8px; padding: 10px 12px calc(10px + var(--safe-b)); background: var(--chrome); border-top: 2px dashed var(--dash); }
.qz-foot .btn { flex: 1; }
.sent-in { width: 100%; min-height: 130px; padding: 12px; border: 1.5px solid var(--line); border-radius: calc(12px * var(--k)); background: var(--card); font-family: var(--serif); font-size: 17px; line-height: 1.5; resize: vertical; }
.sent-in:focus { outline: none; border-color: var(--brand); }

.fc-stage { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px; perspective: 1200px; overflow: hidden; }
.fc { position: relative; width: min(340px, 86vw); height: min(420px, 56vh); transform-style: preserve-3d; transition: transform .3s ease; touch-action: none; user-select: none; -webkit-user-select: none; cursor: pointer; }
.fc-face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: calc(20px * var(--k)); background: var(--card);
  border: 1.5px solid var(--line); box-shadow: 0 6px 24px rgba(20,30,70,.08); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; text-align: center; gap: 10px; }
.fc-face.back { transform: rotateY(180deg); background: var(--chrome); }
.fc-main { font-size: 28px; font-weight: 700; line-height: 1.3; font-family: var(--serif); }
.fc-ex { font-family: var(--serif); font-size: 17px; color: var(--ink2); font-style: italic; }
.fc-sub { font-size: 14px; color: var(--ink3); }
.fc-cat { font-size: 12px; color: var(--ink3); }
.fc.lean-r .fc-face { border-color: var(--ok); }
.fc.lean-l .fc-face { border-color: var(--bad); }
.fc-hint { margin-top: 16px; }
.chip, .qz-opt .l { text-box: trim-both cap alphabetic; }
.chip { padding: 8px 11px; }
.set-card .fold-btn { align-items: flex-start; }
.set-card .fold-btn .tri { margin-top: 7px; }
.seg { background: var(--chrome); }
.seg button.on { background: var(--card); }
/* wrong book rows: number/tag sit on the first line, count + button centred vertically */
.witem { align-items: center; padding: 12px 0; line-height: 1.55; }
.witem .n, .witem .chip { align-self: flex-start; }
.witem .n { line-height: 1.55; }
.witem .chip { margin-top: 1px; }
.witem .times { white-space: nowrap; }
.witem .btn.sm { flex: none; }
