/* Bố cục: một cột đọc hẹp cho điện thoại; đầu trang là tờ bản vẽ xanh có lưới ô vuông. */
:root {
  --bg: #eef3f7;
  --surface: #ffffff;
  --ink: #13283b;
  --muted: #4a5f71;
  --line: #d2dde6;
  --accent: #0a5c9e;
  --accent-ink: #ffffff;
  --accent-soft: #dfecf7;
  --hero-bg: #0b4a80;
  --hero-ink: #ffffff;
  --hero-muted: #c5dcf0;
  --hero-grid: rgba(255, 255, 255, 0.07);
  --trap-bg: #fff3d1;
  --trap-ink: #563e00;
  --ok: #0b6b48;
  --ok-bg: #ddf3e8;
  --bad: #ad2c2b;
  --bad-bg: #fbe5e3;
  --code-bg: #e4ecf3;
  --band: var(--surface);
  --font-body: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1924;
    --surface: #152534;
    --ink: #e4edf4;
    --muted: #a0b4c5;
    --line: #2a4056;
    --accent: #7cc0f5;
    --accent-ink: #06243b;
    --accent-soft: #17364f;
    --hero-bg: #10324f;
    --hero-ink: #f2f8fd;
    --hero-muted: #b4cfe6;
    --hero-grid: rgba(255, 255, 255, 0.05);
    --trap-bg: #3a2e0c;
    --trap-ink: #f8e2a4;
    --ok: #74dcb0;
    --ok-bg: #103a2c;
    --bad: #f6a29d;
    --bad-bg: #451c1b;
    --code-bg: #203548;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0d1924;
  --surface: #152534;
  --ink: #e4edf4;
  --muted: #a0b4c5;
  --line: #2a4056;
  --accent: #7cc0f5;
  --accent-ink: #06243b;
  --accent-soft: #17364f;
  --hero-bg: #10324f;
  --hero-ink: #f2f8fd;
  --hero-muted: #b4cfe6;
  --hero-grid: rgba(255, 255, 255, 0.05);
  --trap-bg: #3a2e0c;
  --trap-ink: #f8e2a4;
  --ok: #74dcb0;
  --ok-bg: #103a2c;
  --bad: #f6a29d;
  --bad-bg: #451c1b;
  --code-bg: #203548;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html {
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.65 var(--font-body);
  overflow-wrap: break-word;
  -webkit-tap-highlight-color: transparent;
}

body.home { --band: var(--hero-bg); }

body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto;
  height: env(safe-area-inset-top, 0px);
  z-index: 10;
  background: var(--band);
}

.wrap {
  width: 100%;
  max-width: 680px;
  margin-inline: auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

a { color: var(--accent); text-underline-offset: 2px; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

h1, h2, h3 { text-wrap: balance; }

h2 {
  margin: 0 0 12px;
  font-size: 22px;
  line-height: 1.3;
  font-weight: 700;
  letter-spacing: -0.01em;
}

h3 {
  margin: 0 0 6px;
  font-size: 16.5px;
  line-height: 1.4;
  font-weight: 600;
}

p { margin: 0 0 12px; }
p:last-child { margin-bottom: 0; }

code {
  padding: 0.08em 0.32em;
  border-radius: 4px;
  background: var(--code-bg);
  font: 500 0.86em var(--font-mono);
  overflow-wrap: anywhere;
}

pre {
  margin: 0 0 12px;
  padding: 12px 14px;
  overflow-x: auto;
  border-radius: 8px;
  background: var(--code-bg);
  font: 500 13px/1.55 var(--font-mono);
}

pre code { padding: 0; background: none; font: inherit; overflow-wrap: normal; }

/* Thanh trên cùng */
.topbar {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 9;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.topbar-in { display: flex; align-items: center; gap: 8px; min-height: 52px; }

.back {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding-right: 6px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.topbar-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-sm {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.readbar { width: 0; height: 3px; background: var(--accent); }

/* Đầu trang */
.hero {
  padding-block: 28px;
  background-color: var(--hero-bg);
  background-image:
    linear-gradient(var(--hero-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--hero-grid) 1px, transparent 1px);
  background-size: 24px 24px;
  color: var(--hero-ink);
}

.hero h1 {
  margin: 0 0 10px;
  font-size: 29px;
  line-height: 1.22;
  font-weight: 700;
  letter-spacing: -0.015em;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--hero-muted);
  font: 500 13px/1.4 var(--font-mono);
  letter-spacing: 0.02em;
}

.lead { margin: 0; color: var(--hero-ink); font-size: 16.5px; }

/* Mục lục */
.toc { display: flex; flex-wrap: wrap; gap: 6px; padding-block: 16px; }

.toc a {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 4px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13.5px;
  line-height: 1.3;
  text-decoration: none;
}

.toc a.toc-quiz { border-color: var(--accent); color: var(--accent); font-weight: 600; }

/* Nội dung */
main section {
  padding-block: 26px;
  border-top: 1px solid var(--line);
  scroll-margin-top: 62px;
}

main section > * + h3 { margin-top: 18px; }

.items, .plain, .steps { margin: 0 0 12px; padding: 0; }
.items:last-child, .plain:last-child, .steps:last-child { margin-bottom: 0; }

.items { list-style: none; }

.items > li { padding-block: 13px; border-top: 1px solid var(--line); }
.items > li:first-child { border-top: 0; padding-top: 2px; }
.items > li:last-child { padding-bottom: 2px; }

.items p { margin-bottom: 6px; }

.plain { padding-left: 20px; }
.plain li { margin-bottom: 7px; }
.plain li:last-child { margin-bottom: 0; }

.steps { padding-left: 24px; }
.steps li { margin-bottom: 8px; padding-left: 2px; }
.steps li:last-child { margin-bottom: 0; }
.steps li::marker { color: var(--accent); font: 500 14px var(--font-mono); }

.kv { display: grid; grid-template-columns: 88px minmax(0, 1fr); gap: 3px 10px; margin: 6px 0 0; }
.kv dt { color: var(--muted); font-size: 13px; line-height: 1.85; }
.kv dd { margin: 0; min-width: 0; }

/* Ghi chú */
.call { margin: 14px 0 0; padding: 12px 14px; border-radius: 10px; font-size: 15px; line-height: 1.6; }
.call p { margin-bottom: 8px; }
.call p:last-child { margin-bottom: 0; }
.call ul { margin: 0; padding-left: 18px; }
.call li { margin-bottom: 6px; }
.call li:last-child { margin-bottom: 0; }

.call-label {
  margin: 0 0 4px !important;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.trap { background: var(--trap-bg); color: var(--trap-ink); }
.trap code { background: rgba(127, 127, 127, 0.18); }
.tip { background: var(--accent-soft); color: var(--ink); }
.fact { background: var(--surface); border: 1px solid var(--line); color: var(--ink); }
.fact .call-label { color: var(--ok); }

/* Sơ đồ cache */
.stack { margin: 12px 0; padding: 0; list-style: none; font-size: 14.5px; }
.stack li { padding: 8px 12px; border-top: 1px solid var(--bg); }
.stack .stable { background: var(--ok-bg); }
.stack .variable { background: var(--trap-bg); color: var(--trap-ink); }
.stack small { display: block; font-size: 12.5px; opacity: 0.85; }
.stack li:first-child { border-radius: 8px 8px 0 0; border-top: 0; }
.stack li:last-child { border-radius: 0 0 8px 8px; }
.stack .breakpoint {
  padding: 5px 12px;
  background: var(--ink);
  color: var(--bg);
  font: 500 12.5px var(--font-mono);
  text-align: center;
}

/* Nhớ nhanh */
.takeaways { margin: 0; padding-left: 20px; }
.takeaways li { margin-bottom: 8px; font-weight: 500; }
.takeaways li:last-child { margin-bottom: 0; }

/* Quiz */
#quiz { scroll-margin-top: 58px; }
.quiz-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 12px; margin-bottom: 10px; }
.quiz-head h2 { margin: 0; }
.quiz-note { color: var(--muted); font-size: 14px; }

#quiz-app { scroll-margin-top: 62px; }

.quiz-tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 18px; }

.quiz-tab {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 1px 6px;
  min-height: 58px;
  padding: 8px 10px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
}

.quiz-tab[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.tab-name { font-size: 14.5px; line-height: 1.4; font-weight: 600; }
.tab-status { color: var(--muted); font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.tab-topic { grid-column: 1 / -1; color: var(--muted); font-size: 12.5px; line-height: 1.35; }
.quiz-tab.is-pass .tab-status { color: var(--ok); }
.quiz-tab.has-wrong .tab-status { color: var(--bad); }

.quiz-progress { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; color: var(--muted); font: 500 13px var(--font-mono); font-variant-numeric: tabular-nums; }
.quiz-track { height: 5px; margin-bottom: 16px; overflow: hidden; border-radius: 3px; background: var(--line); }
.quiz-fill { height: 100%; background: var(--accent); }

.quiz-q { margin: 0 0 14px; font-size: 17px; line-height: 1.5; font-weight: 600; outline: none; }

.opts { display: grid; gap: 8px; }

.opt {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  min-height: 52px;
  padding: 12px 13px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 15.5px;
  line-height: 1.5;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
}

.opt:disabled { color: var(--ink); cursor: default; }
.opt-key { flex: none; width: 18px; color: var(--muted); font: 500 14px/1.65 var(--font-mono); }
.opt-text { flex: 1; min-width: 0; }
.opt-tag { display: block; margin-top: 2px; font-size: 13px; font-weight: 700; }
.opt.is-dim { opacity: 0.6; }
.opt.is-correct { background: var(--ok-bg); border-color: var(--ok); }
.opt.is-correct .opt-tag { color: var(--ok); }
.opt.is-wrong { background: var(--bad-bg); border-color: var(--bad); }
.opt.is-wrong .opt-tag { color: var(--bad); }

.feedback { margin-top: 14px; font-size: 15.5px; }
.feedback-verdict { margin-bottom: 4px; font-weight: 700; }
.feedback-verdict.good { color: var(--ok); }
.feedback-verdict.bad { color: var(--bad); }
.feedback-ref { font-size: 14.5px; }

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 50px;
  padding: 10px 16px;
  border: 1.5px solid var(--accent);
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  font: inherit;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
}

.btn.ghost { background: transparent; color: var(--accent); }
.btn-row { display: grid; gap: 8px; margin-top: 16px; }

.result-title { margin: 0 0 8px; font-size: 19px; line-height: 1.4; font-weight: 700; }
.result-score { margin: 0; font: 500 44px/1.15 var(--font-mono); font-variant-numeric: tabular-nums; }
.result-verdict { display: inline-block; margin: 6px 0 10px; padding: 2px 10px; border-radius: 6px; font-size: 14px; font-weight: 700; }
.result-verdict.is-pass { background: var(--ok-bg); color: var(--ok); }
.result-verdict.is-retry { background: var(--trap-bg); color: var(--trap-ink); }

.wrong-list { margin: 16px 0 0; padding: 0; list-style: none; }
.wrong-list li { padding-block: 12px; border-top: 1px solid var(--line); font-size: 15px; }
.wrong-list strong { display: block; margin-bottom: 4px; font-weight: 600; }
.wrong-list .answer { display: block; margin-bottom: 4px; color: var(--ok); }

/* Trang trước, trang sau */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding-block: 18px; border-top: 1px solid var(--line); }

.pager a {
  display: block;
  min-width: 0;
  min-height: 62px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.35;
  font-weight: 600;
  text-decoration: none;
}

.pager small { display: block; margin-bottom: 2px; color: var(--muted); font-size: 12.5px; font-weight: 400; }
.pager .next { text-align: right; }

.sources { padding-block: 4px 32px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.sources p { margin-bottom: 6px; }

/* Trang chủ */
.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 18px 0 0; }
.facts div { min-width: 0; }
.facts dt { color: var(--hero-muted); font-size: 12.5px; }
.facts dd { margin: 0; font: 500 16px/1.35 var(--font-mono); font-variant-numeric: tabular-nums; }

.overview { padding-block: 18px; }
.overview-line { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 12px; margin-bottom: 8px; font-weight: 600; }
.overview-line span:last-child { color: var(--muted); font: 500 13px var(--font-mono); }
.meter { height: 7px; margin-bottom: 14px; overflow: hidden; border-radius: 4px; background: var(--line); }
.meter span { display: block; width: 0; height: 100%; background: var(--ok); }

.domains { margin: 0; padding: 0; border-top: 1px solid var(--line); list-style: none; }
.domains li { border-bottom: 1px solid var(--line); }

.domain-link {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 2px 8px;
  padding-block: 14px;
  color: var(--ink);
  text-decoration: none;
}

.domain-no { grid-row: span 3; color: var(--accent); font: 500 15px/1.5 var(--font-mono); }
.domain-name { font-size: 16.5px; line-height: 1.4; font-weight: 600; }
.domain-en { color: var(--muted); font-size: 13.5px; line-height: 1.4; }
.domain-wrong { grid-column: 2; margin-top: 4px; color: var(--bad); font-size: 13px; font-weight: 600; }

.domain-meta { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.weight { flex: 1; min-width: 0; height: 6px; overflow: hidden; border-radius: 3px; background: var(--line); }
.weight span { display: block; height: 100%; background: var(--accent); }
.weight-num { width: 30px; color: var(--muted); font: 500 12.5px var(--font-mono); font-variant-numeric: tabular-nums; text-align: right; }

.status { flex: none; min-width: 92px; padding: 2px 8px; border-radius: 6px; background: var(--code-bg); color: var(--muted); font-size: 12.5px; font-weight: 600; text-align: center; white-space: nowrap; }
.status.is-pass { background: var(--ok-bg); color: var(--ok); }
.status.is-retry { background: var(--trap-bg); color: var(--trap-ink); }

.link-btn { min-height: 44px; padding: 0; border: 0; background: none; color: var(--muted); font: inherit; font-size: 13px; text-decoration: underline; cursor: pointer; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

/* Đề thi thử */
.exam-cta {
  display: grid;
  gap: 2px;
  padding: 14px 16px;
  margin-bottom: 18px;
  border: 1.5px solid var(--accent);
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--ink);
  text-decoration: none;
}

.exam-cta-title { font-size: 16.5px; line-height: 1.4; font-weight: 700; }
.exam-cta-sub { color: var(--muted); font-size: 14px; line-height: 1.45; }

.ex-side { min-width: 44px; }

#view section { padding-block: 24px; border-top: 1px solid var(--line); }
#view .ex-howto { border-top: 0; }
.ex-run { padding-block: 14px 32px; }

.ex-cards { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.ex-card { padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.ex-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ex-card-head h3 { margin: 0; font-size: 18px; font-weight: 700; }
.ex-card-sub { margin: 4px 0 12px; color: var(--muted); font-size: 13.5px; line-height: 1.45; }
.ex-card-note { margin: 8px 0 0; color: var(--muted); font-size: 13.5px; line-height: 1.5; }
.ex-modes { display: grid; gap: 8px; }

.ex-field { margin-bottom: 12px; }
.ex-field-label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 13.5px; font-weight: 600; }
.ex-chips { display: flex; flex-wrap: wrap; gap: 6px; }

.ex-pill {
  min-width: 46px;
  min-height: 42px;
  padding: 4px 12px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}

.ex-pill[aria-pressed="true"] { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }

.ex-check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 15px; }
.ex-check input { width: 20px; height: 20px; flex: none; accent-color: var(--accent); }

.ex-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.ex-count { font: 500 14px var(--font-mono); font-variant-numeric: tabular-nums; }

.ex-tool {
  min-height: 40px;
  padding: 4px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}

.ex-tool[aria-pressed="true"], .ex-tool[aria-expanded="true"] { border-color: var(--accent); background: var(--accent-soft); }
.ex-tools { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }

.ex-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-bottom: 10px; }
.ex-type { color: var(--accent); font: 500 12.5px var(--font-mono); letter-spacing: 0.02em; }
.ex-domain { padding: 1px 8px; border-radius: 6px; background: var(--code-bg); color: var(--muted); font-size: 12.5px; font-weight: 600; }

.ex-stem { margin-bottom: 14px; font-size: 16.5px; line-height: 1.55; font-weight: 500; outline: none; }
.ex-stem p { margin-bottom: 8px; }
.ex-stem p:last-child { margin-bottom: 0; }

.ex-vi { color: var(--muted); font-size: 14.5px; font-weight: 400; line-height: 1.5; }
.ex-vi-stem { margin: -4px 0 14px; padding: 10px 12px; border-radius: 8px; background: var(--code-bg); color: var(--ink); }
.ex-vi-stem p { margin-bottom: 6px; }
.ex-vi-stem p:last-child { margin-bottom: 0; }
.opt-text .ex-vi, .ex-chip-text .ex-vi { display: block; margin-top: 3px; }
.ex-row-text .ex-vi { margin-top: 3px; }
.ex-chip .ex-vi { font-size: 12.5px; }

.term { border-bottom: 1.5px dotted var(--accent); cursor: help; }
.term.is-open { background: var(--accent-soft); }
.term:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-radius: 2px; }

.ex-words { display: grid; gap: 10px; margin: 0 0 14px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-size: 14.5px; }
.ex-words dt { font-weight: 700; }
.ex-words dd { margin: 0; color: var(--muted); line-height: 1.5; }

label.opt { position: relative; }
.ex-input { position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; }
label.opt .opt-key { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border: 1.5px solid var(--line); border-radius: 50%; font-size: 13px; line-height: 1; }
label.opt input[type="checkbox"] + .opt-key { border-radius: 6px; }
.opt.is-selected { border-color: var(--accent); background: var(--accent-soft); }
.opt.is-selected .opt-key { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }
label.opt.is-correct .opt-key { border-color: var(--ok); background: var(--ok); color: var(--surface); }
label.opt.is-wrong .opt-key { border-color: var(--bad); background: var(--bad); color: var(--surface); }
.opt.is-locked { opacity: 0.6; cursor: not-allowed; }
.ex-input:focus-visible + .opt-key { outline: 3px solid var(--accent); outline-offset: 2px; }
.ex-hint { margin: 0 0 8px; color: var(--muted); font-size: 14px; }

.ex-rows { display: grid; gap: 14px; }
.ex-row { padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.ex-row:last-child { padding-bottom: 0; border-bottom: 0; }
.ex-row-text { margin-bottom: 8px; font-size: 15.5px; line-height: 1.5; }
.ex-row-text p { margin: 0; }

.ex-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 6px 12px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  cursor: pointer;
  touch-action: manipulation;
}

.ex-chip-text { display: block; }
.ex-chip.is-selected { border-color: var(--accent); background: var(--accent-soft); }
.ex-chip.is-correct { border-color: var(--ok); background: var(--ok-bg); }
.ex-chip.is-wrong { border-color: var(--bad); background: var(--bad-bg); }
.ex-chip.is-dim { opacity: 0.55; }
.ex-input:focus-visible + .ex-chip-text { outline: 3px solid var(--accent); outline-offset: 4px; border-radius: 4px; }

.ex-row-why { margin: 8px 0 0; font-size: 14.5px; line-height: 1.5; }
.ex-row-why.good strong { color: var(--ok); }
.ex-row-why.bad strong { color: var(--bad); }

.ex-fb { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 15.5px; }
.ex-why p { margin-bottom: 8px; }
.ex-ref { display: grid; gap: 6px; margin-top: 14px; font-size: 14.5px; }
.ex-ref .call-label { color: var(--muted); }

.ex-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 18px; }
.ex-submit { margin-top: 8px; }
.ex-warn { margin: 0 0 8px; padding: 10px 12px; border-radius: 8px; background: var(--trap-bg); color: var(--trap-ink); font-size: 14.5px; }

.ex-palette { margin-bottom: 14px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.ex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; }

.ex-cell {
  position: relative;
  min-height: 44px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font: 500 14px var(--font-mono);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  touch-action: manipulation;
}

.ex-cell.is-answered { background: var(--accent-soft); border-color: var(--accent); }
.ex-cell.is-right { background: var(--ok-bg); border-color: var(--ok); }
.ex-cell.is-bad { background: var(--bad-bg); border-color: var(--bad); }
.ex-cell.is-current { outline: 2.5px solid var(--ink); outline-offset: 1px; }
.ex-mark { margin-left: 2px; font-size: 11px; }

#view .ex-result { padding-top: 6px; border-top: 0; }
.ex-domains, .ex-wrong-list { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.ex-domains a { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 4px; color: var(--ink); font-size: 14.5px; text-decoration: none; }
.ex-d-name { min-width: 0; }
.ex-d-score { flex: none; color: var(--muted); font: 500 13px var(--font-mono); font-variant-numeric: tabular-nums; }
.ex-domains .meter { margin-bottom: 0; }

.ex-wrong-row { display: grid; gap: 2px; width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.ex-wrong-no { color: var(--bad); font: 500 12.5px var(--font-mono); }
.ex-wrong-text { display: -webkit-box; overflow: hidden; font-size: 14.5px; line-height: 1.45; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }

.gloss {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 20;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  max-height: 45vh;
  overflow-y: auto;
  padding: 14px max(16px, env(safe-area-inset-right, 0px)) calc(14px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  border-top: 2px solid var(--accent);
  background: var(--surface);
  box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.18);
}

.gloss[hidden] { display: none; }
.gloss-in { flex: 1; min-width: 0; }
.gloss-term { margin: 0 0 2px; font-weight: 700; }
.gloss-vi { margin: 0; font-size: 15px; line-height: 1.5; }
.gloss-close { flex: none; width: 44px; height: 44px; margin: -8px -8px 0 0; border: 0; background: none; color: var(--muted); font-size: 26px; line-height: 1; cursor: pointer; }
