/* THỦY – LUẬN GIẢI CCCD CHUYÊN SÂU · app.css
 * Đỏ – cam – tím, phong cách phương Đông. Font hệ thống, không tải ngoài. */

:root {
  --royal: #4a0d4f;
  --royal-2: #a3173a;
  --royal-deep: #2b0530;
  --gold: #ff8a1f;
  --gold-light: #ffc27a;
  --gold-dark: #d4600c;
  --ivory: #fff4ea;

  --bg: #fff1e8;
  --bg-pattern: rgba(74, 13, 79, .035);
  --surface: #fffaf6;
  --surface-2: #fdeee6;
  --ink: #2a1630;
  --ink-soft: #64506a;
  --strong: #4a0d4f;
  --heading: #8a1238;
  --gold-ink: #b4500a;
  --line: rgba(74, 13, 79, .14);
  --line-gold: rgba(212, 96, 12, .45);
  --focus: #c2185b;
  --danger: #a3261b;
  --danger-bg: #fcebe7;
  --info-bg: #fde6d6;
  --ok: #1e6b3b;
  --shadow: 0 1px 2px rgba(74, 13, 79, .06), 0 8px 24px -12px rgba(74, 13, 79, .22);
  --btn-primary-bg: linear-gradient(110deg, #d7263d 0%, #ff7a1a 50%, #7b2cbf 100%);
  --btn-primary-ink: #ffffff;
  --table-head: #6a1450;
  --table-head-ink: #ffd7a8;
  --table-stripe: rgba(74, 13, 79, .035);

  --serif: "Noto Serif", "Source Serif Pro", "Times New Roman", Times, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --radius: 14px;
  --gutter: 16px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1a0620;
    --bg-pattern: rgba(255, 138, 31, .045);
    --surface: #2a0b33;
    --surface-2: #22082a;
    --ink: #fbe9e4;
    --ink-soft: #d6b9c4;
    --strong: #ffe2c8;
    --heading: #ffb36b;
    --gold-ink: #ffa45a;
    --line: rgba(255, 194, 122, .16);
    --line-gold: rgba(255, 138, 31, .45);
    --focus: #ff8fb8;
    --danger: #ffb4a6;
    --danger-bg: #3b1515;
    --info-bg: #3a1240;
    --ok: #8fdcab;
    --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 10px 28px -14px rgba(0, 0, 0, .7);
    --btn-primary-bg: linear-gradient(110deg, #ff3b52 0%, #ff8a1f 50%, #9d4edd 100%);
    --btn-primary-ink: #ffffff;
    --table-head: #7a1a5a;
    --table-head-ink: #ffd7a8;
    --table-stripe: rgba(255, 194, 122, .04);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1a0620;
  --bg-pattern: rgba(255, 138, 31, .045);
  --surface: #2a0b33;
  --surface-2: #22082a;
  --ink: #fbe9e4;
  --ink-soft: #d6b9c4;
  --strong: #ffe2c8;
  --heading: #ffb36b;
  --gold-ink: #ffa45a;
  --line: rgba(255, 194, 122, .16);
  --line-gold: rgba(255, 138, 31, .45);
  --focus: #ff8fb8;
  --danger: #ffb4a6;
  --danger-bg: #3b1515;
  --info-bg: #3a1240;
  --ok: #8fdcab;
  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 10px 28px -14px rgba(0, 0, 0, .7);
  --btn-primary-bg: linear-gradient(110deg, #ff3b52 0%, #ff8a1f 50%, #9d4edd 100%);
  --btn-primary-ink: #ffffff;
  --table-head: #7a1a5a;
  --table-head-ink: #ffd7a8;
  --table-stripe: rgba(255, 194, 122, .04);
  color-scheme: dark;
}

/* ── Nền tảng ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background-color: var(--bg);
  background-image:
    radial-gradient(circle at 0 0, var(--bg-pattern) 0 2px, transparent 2.5px),
    radial-gradient(circle at 12px 12px, var(--bg-pattern) 0 2px, transparent 2.5px);
  background-size: 24px 24px;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: var(--gold-ink); text-underline-offset: 2px; }
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.muted { color: var(--ink-soft); font-weight: 400; }
.center { text-align: center; }
.print-only { display: none; }
svg { flex: none; }

/* ── Đầu trang ──────────────────────────────────────────── */
.masthead {
  position: relative;
  color: var(--ivory);
  background:
    radial-gradient(120% 140% at 10% 0%, rgba(255, 122, 26, .55), transparent 55%),
    linear-gradient(120deg, #c81d3a 0%, #e8541e 30%, #8a1d6e 65%, #4a0d4f 100%);
  padding: calc(env(safe-area-inset-top) + 14px) var(--gutter) 14px;
}
.masthead__inner {
  max-width: 880px; margin: 0 auto;
  display: flex; align-items: center; gap: 12px;
}
.masthead__emblem { width: 46px; height: 46px; filter: drop-shadow(0 2px 6px rgba(0,0,0,.35)); }
.masthead__brand { min-width: 0; flex: 1; }
.masthead__title {
  margin: 0;
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(15px, 4.4vw, 22px);
  letter-spacing: .06em;
  line-height: 1.25;
  color: var(--gold-light);
  text-shadow: 0 1px 0 rgba(0,0,0,.35);
}
.masthead__title .dash { color: var(--gold); }
.masthead__slogan {
  margin: 3px 0 0;
  font-size: clamp(10px, 2.8vw, 12px);
  letter-spacing: .16em;
  color: rgba(247, 241, 225, .82);
}
.masthead__actions { display: flex; gap: 6px; }
.masthead__rule {
  position: absolute; left: 0; right: 0; bottom: 0; height: 3px;
  background: linear-gradient(90deg, transparent, var(--gold) 15%, var(--gold-light) 50%, var(--gold) 85%, transparent);
  opacity: .9;
}
.masthead__pre { white-space: nowrap; }
@media (max-width: 520px) {
  .masthead__inner { gap: 10px; }
  .masthead__emblem { width: 42px; height: 42px; }
  .masthead__pre .dash { display: none; }
  .masthead__pre { display: block; font-size: 12px; letter-spacing: .3em; color: var(--gold); margin-bottom: 1px; }
  .masthead__title { font-size: clamp(15px, 4.6vw, 19px); letter-spacing: .03em; white-space: normal; line-height: 1.2; }
  .masthead__slogan { font-size: 9.5px; letter-spacing: .09em; white-space: nowrap; }
}
.icon-btn {
  display: inline-flex; align-items: center; gap: 6px;
  min-width: 40px; height: 40px; padding: 0 9px;
  border: 1px solid rgba(255, 138, 31, .55);
  border-radius: 999px;
  background: rgba(255, 255, 255, .06);
  color: var(--gold-light);
  cursor: pointer;
}
.icon-btn:hover { background: rgba(255, 138, 31, .16); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn__label { font-size: 13px; font-weight: 600; white-space: nowrap; }
@media (max-width: 420px) { .icon-btn__label { display: none; } }
.only-dark { display: none; }
:root[data-theme="dark"] .only-dark { display: block; }
:root[data-theme="dark"] .only-light { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .only-dark { display: block; }
  :root:not([data-theme="light"]) .only-light { display: none; }
}

/* ── Banner ─────────────────────────────────────────────── */
.banner {
  max-width: 880px; margin: 12px auto 0; padding: 10px 14px;
  display: flex; align-items: center; gap: 12px; justify-content: space-between;
  background: var(--info-bg); border: 1px solid var(--line-gold); border-radius: 12px;
  font-size: 14px;
  margin-left: max(var(--gutter), calc((100% - 880px) / 2));
  margin-right: max(var(--gutter), calc((100% - 880px) / 2));
}
.banner p { margin: 0; }

/* ── Khung chính ────────────────────────────────────────── */
.shell { max-width: 880px; margin: 0 auto; padding: 18px var(--gutter) 28px; }
.screen { display: flex; flex-direction: column; gap: 16px; animation: fade .35s ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 18px;
}
.card::before {
  /* viền kép vàng kiểu khung tranh */
  content: ""; position: absolute; inset: 5px; border-radius: calc(var(--radius) - 4px);
  border: 1px solid var(--line-gold); opacity: .55; pointer-events: none;
}
.card--hero { max-width: 560px; width: 100%; margin: 6px auto 0; padding: 26px 20px 22px; }
.card__title {
  margin: 0 0 12px;
  font-family: var(--serif);
  font-size: 20px; font-weight: 700; letter-spacing: .02em;
  color: var(--heading);
}
.lead { margin: 0 0 18px; color: var(--ink-soft); }
.hint { margin: 8px 0 0; font-size: 13.5px; color: var(--ink-soft); }
.demo-note { margin: 14px 0 0; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--danger); opacity: .85; }

.ornament { display: flex; align-items: center; gap: 12px; justify-content: center; margin-bottom: 10px; }
.ornament span { flex: 1; max-width: 90px; height: 1px; background: linear-gradient(90deg, transparent, var(--gold)); }
.ornament span:last-child { background: linear-gradient(270deg, transparent, var(--gold)); }
.ornament svg { width: 54px; height: 54px; border-radius: 50%; background: radial-gradient(circle at 50% 40%, #a3173a, var(--royal) 60%, var(--royal-deep)); padding: 3px; box-shadow: 0 4px 14px -4px rgba(74,13,79,.5); }

/* Mã thiết bị */
.device {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px dashed var(--line-gold);
}
.device > div { min-width: 0; }
.device .btn { white-space: nowrap; flex: none; }
.device__label { white-space: nowrap; font-size: 12.5px; color: var(--ink-soft); letter-spacing: .03em; }
.device__id {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, "Roboto Mono", monospace;
  font-size: 21px; font-weight: 700; letter-spacing: .1em; color: var(--strong); white-space: nowrap;
}

/* ── Trường nhập ────────────────────────────────────────── */
.stack { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.field { display: block; }
.field__label { display: block; margin-bottom: 6px; font-weight: 600; font-size: 14.5px; color: var(--strong); }
input[type="text"], textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
input[type="text"]:focus, textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(255, 138, 31, .28); }
textarea { resize: vertical; min-height: 96px; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 14px; letter-spacing: .03em; word-break: break-all; }
.input-row { position: relative; }
#input-cccd { font-size: 22px; letter-spacing: .12em; font-variant-numeric: tabular-nums; padding-right: 70px; font-weight: 600; }
#input-cccd::placeholder { font-size: 16px; letter-spacing: .02em; font-weight: 500; }
.counter { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); font-size: 13px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.counter.ok { color: var(--ok); font-weight: 700; }

/* ── Nút ────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px;
  border-radius: 12px; border: 1px solid transparent;
  font-weight: 700; letter-spacing: .02em;
  cursor: pointer; text-decoration: none;
  transition: transform .06s ease, filter .15s, background .15s;
}
.btn:active { transform: translateY(1px); }
.btn svg { width: 18px; height: 18px; }
.btn--block { width: 100%; }
.btn--primary {
  background: var(--btn-primary-bg); color: var(--btn-primary-ink);
  border-color: var(--gold-dark);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.18), 0 6px 16px -8px rgba(74,13,79,.6);
  font-size: 17px; letter-spacing: .06em;
}
.btn--primary:hover { filter: brightness(1.08); }
.btn--gold { background: linear-gradient(180deg, #ffb055, #ff7a1a); color: var(--royal); border-color: var(--gold-dark); }
.btn--ghost { background: transparent; color: var(--strong); border-color: var(--line-gold); }
.btn--ghost:hover { background: rgba(255, 138, 31, .12); }
.btn--small { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.btn[disabled] { opacity: .65; cursor: progress; }
.link-btn { background: none; border: 0; padding: 6px 4px; color: var(--gold-ink); font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.link-btn.danger { color: var(--danger); }

.spinner { display: none; width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite; }
.is-loading .spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Thông báo ──────────────────────────────────────────── */
.alert {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 11px 13px; border-radius: 12px;
  background: var(--danger-bg); color: var(--danger);
  border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent);
  font-size: 14.5px; line-height: 1.5;
}
.alert svg { width: 20px; height: 20px; margin-top: 1px; }
.alert--info { background: var(--info-bg); color: var(--ink); border-color: var(--line-gold); }
.alert--info svg { color: var(--gold-ink); }

/* ── Thanh trạng thái ───────────────────────────────────── */
.status {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: linear-gradient(120deg, #b3173a 0%, #d9481c 35%, #6e1662 75%, var(--royal) 100%);
  color: var(--ivory);
  border: 1px solid rgba(255, 138, 31, .45);
  box-shadow: var(--shadow);
}
.status__grid { flex: 1; min-width: 0; margin: 0; display: grid; grid-template-columns: 1.4fr 1fr .9fr; gap: 10px; }
.status__grid > div { min-width: 0; }
.status dt { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: rgba(255, 194, 122, .85); }
.status dd { margin: 1px 0 0; font-weight: 700; font-size: 14.5px; line-height: 1.35; overflow-wrap: anywhere; }
.status dd small { display: block; font-weight: 500; font-size: 12px; color: rgba(247, 241, 225, .75); }
.status dd.warn { color: #ffe08a; }
.status .btn--ghost { color: var(--gold-light); border-color: rgba(255, 138, 31, .6); white-space: nowrap; }
@media (max-width: 480px) {
  .status { flex-wrap: wrap; }
  .status__grid { grid-template-columns: 1fr 1fr; flex-basis: 100%; }
  .status__grid > div:first-child { grid-column: 1 / -1; }
  .status .btn { width: 100%; }
}

/* ── Kết quả ────────────────────────────────────────────── */
.result { display: flex; flex-direction: column; gap: 12px; }
.toolbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  padding: 10px; margin: 0 -4px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--line);
}
.btn--tool {
  flex: 1 1 auto; min-height: 40px; padding: 8px 12px; font-size: 14px;
  background: var(--surface); color: var(--strong); border-color: var(--line-gold);
}
.btn--tool:hover { background: var(--surface-2); }
.switch { display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px; font-weight: 600; font-size: 14px; cursor: pointer; color: var(--strong); flex: 1 1 auto; justify-content: center; border: 1px dashed var(--line-gold); border-radius: 12px; min-height: 40px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch__track { width: 40px; height: 22px; border-radius: 999px; background: var(--line); position: relative; transition: background .2s; border: 1px solid var(--line-gold); }
.switch__thumb { position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .2s; }
.switch input:checked + .switch__track { background: var(--gold); }
.switch input:checked + .switch__track .switch__thumb { transform: translateX(18px); background: var(--royal); }
.switch input:focus-visible + .switch__track { outline: 3px solid var(--focus); outline-offset: 2px; }

.paper {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 18px 26px;
  position: relative;
}
.paper::before { content: ""; position: absolute; left: 18px; right: 18px; top: 0; height: 3px; border-radius: 0 0 3px 3px; background: linear-gradient(90deg, transparent, var(--gold), transparent); }

/* Nội dung bài luận (markdown) */
.reading { font-size: 16px; line-height: 1.7; overflow-wrap: anywhere; }
.reading > :first-child { margin-top: 0; }
.reading h1 {
  font-family: var(--serif); font-size: clamp(19px, 5vw, 25px); line-height: 1.3;
  color: var(--heading); margin: 0 0 10px; letter-spacing: .02em;
}
.reading h2 {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--serif); font-size: 19px; line-height: 1.35;
  color: var(--heading); margin: 30px 0 10px; padding-top: 16px;
  border-top: 1px solid var(--line-gold);
  letter-spacing: .02em;
}
.reading h2 .sec-no {
  flex: none; display: inline-grid; place-items: center;
  width: 30px; height: 30px; border-radius: 50%;
  font-family: var(--sans); font-size: 14px; font-weight: 800;
  color: var(--royal); background: radial-gradient(circle at 35% 30%, var(--gold-light), var(--gold) 60%, var(--gold-dark));
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--gold);
}
.reading hr + h2 { border-top: 0; padding-top: 0; margin-top: 18px; }
.reading h3 { font-family: var(--serif); font-size: 17px; color: var(--gold-ink); margin: 20px 0 6px; }
.reading h4 { font-size: 15.5px; margin: 16px 0 4px; color: var(--strong); }
.reading p { margin: 8px 0; }
.reading strong { color: var(--strong); font-weight: 700; }
.reading em { color: var(--ink-soft); }
.reading ul, .reading ol { margin: 6px 0 10px; padding-left: 22px; }
.reading li { margin: 3px 0; }
.reading li > ul, .reading li > ol { margin: 3px 0 4px; }
.reading ul > li::marker { color: var(--gold-dark); }
.reading ol > li::marker { color: var(--gold-ink); font-weight: 700; }
.reading hr { border: 0; height: 1px; margin: 18px 0; background: linear-gradient(90deg, transparent, var(--gold), transparent); }
.reading blockquote { margin: 10px 0; padding: 8px 14px; border-left: 3px solid var(--gold); background: var(--surface-2); border-radius: 0 10px 10px 0; }
.reading code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .92em; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
.table-wrap { overflow-x: auto; margin: 10px 0 12px; border-radius: 12px; border: 1px solid var(--line-gold); -webkit-overflow-scrolling: touch; }
.reading table { width: 100%; border-collapse: collapse; font-size: 14.5px; line-height: 1.5; min-width: 460px; }
.reading th { background: var(--table-head); color: var(--table-head-ink); text-align: left; font-weight: 700; padding: 9px 10px; letter-spacing: .02em; }
.reading th strong { color: inherit; }
.reading td { padding: 8px 10px; border-top: 1px solid var(--line); vertical-align: top; }
.reading tbody tr:nth-child(even) td { background: var(--table-stripe); }
.reading .ntt { padding: 8px 12px; border-radius: 10px; background: var(--info-bg); border: 1px solid var(--line-gold); font-size: 14.5px; }
.reading .basis-block { margin-top: 10px; padding: 4px 14px 10px; border-radius: 12px; border: 1px dashed var(--line-gold); background: var(--surface-2); }

/* ── Lịch sử ────────────────────────────────────────────── */
.history__head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.history__head .card__title { margin-bottom: 6px; }
.history__list { list-style: none; margin: 0; padding: 0; }
.history__item { display: flex; align-items: center; gap: 8px; border-top: 1px solid var(--line); }
.history__item:first-child { border-top: 0; }
.history__open {
  flex: 1; min-width: 0; text-align: left;
  display: grid; gap: 1px; padding: 11px 6px;
  background: none; border: 0; cursor: pointer; border-radius: 10px;
}
.history__open:hover { background: var(--surface-2); }
.history__cccd { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 16px; font-weight: 700; letter-spacing: .08em; color: var(--strong); }
.history__meta { font-size: 13px; color: var(--ink-soft); }
.history__del { flex: none; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 10px; border: 1px solid transparent; background: none; color: var(--ink-soft); cursor: pointer; }
.history__del:hover { color: var(--danger); border-color: var(--line); }
.history__del svg { width: 19px; height: 19px; }
.history__item.is-active .history__cccd::before { content: "◆ "; color: var(--gold); }

/* ── Chân trang ─────────────────────────────────────────── */
.colophon { text-align: center; padding: 8px var(--gutter) calc(28px + env(safe-area-inset-bottom)); color: var(--ink-soft); font-size: 14px; }
.colophon__rule { width: 120px; height: 1px; margin: 0 auto 14px; background: linear-gradient(90deg, transparent, var(--gold), transparent); }
.colophon p { margin: 2px 0; }
.colophon b { color: var(--strong); }
.colophon__ver { font-size: 11.5px; opacity: .75; letter-spacing: .04em; }

/* ── Toast ──────────────────────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 10px 18px; border-radius: 999px;
  background: var(--royal); color: var(--gold-light);
  border: 1px solid var(--gold);
  box-shadow: 0 10px 30px -10px rgba(0,0,0,.5);
  font-weight: 600; font-size: 14.5px; z-index: 50;
  animation: fade .2s ease both;
}

@media (min-width: 720px) {
  .card { padding: 24px 26px; }
  .paper { padding: 34px 40px 40px; }
  .reading { font-size: 16.5px; }
  .reading h2 { font-size: 21px; }
  .toolbar { flex-wrap: nowrap; }
  .btn--tool, .switch { flex: 0 1 auto; }
  .masthead__emblem { width: 54px; height: 54px; }
}

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

/* ── In / Lưu PDF: chỉ in bài luận ──────────────────────── */
@media print {
  @page { margin: 16mm 14mm; }
  :root, :root[data-theme="dark"] {
    --ink: #000; --ink-soft: #333; --strong: #000; --heading: #000; --gold-ink: #000;
    --surface: #fff; --surface-2: #fff; --line: #999; --line-gold: #999;
    --table-head: #fff; --table-head-ink: #000; --table-stripe: transparent; --info-bg: #fff;
  }
  html, body { background: #fff !important; color: #000 !important; }
  body { background-image: none !important; font-size: 11.5pt; }
  .no-print, .masthead, .colophon, .toast, .banner { display: none !important; }
  .shell { max-width: none; padding: 0; }
  .screen { animation: none; gap: 0; }
  .result { display: block !important; }
  .paper { border: 0; box-shadow: none; padding: 0; border-radius: 0; }
  .paper::before { display: none; }
  .print-only { display: block; }
  .print-head { text-align: center; border-bottom: 1.5px solid #000; padding-bottom: 6pt; margin-bottom: 12pt; }
  .print-head__brand { font-family: var(--serif); font-weight: 700; font-size: 15pt; letter-spacing: .08em; }
  .print-head__slogan { font-size: 8.5pt; letter-spacing: .2em; }
  .print-foot { margin-top: 18pt; padding-top: 6pt; border-top: 1px solid #000; text-align: center; font-size: 10pt; }
  .reading { font-size: 11.5pt; line-height: 1.5; color: #000; }
  .reading h1 { font-size: 16pt; }
  .reading h2 { font-size: 13.5pt; border-top: 1px solid #000; margin-top: 16pt; padding-top: 8pt; break-after: avoid; page-break-after: avoid; }
  .reading h3 { font-size: 12pt; break-after: avoid; page-break-after: avoid; }
  .reading h2 .sec-no { background: #fff; color: #000; box-shadow: none; border: 1.5px solid #000; width: 22px; height: 22px; font-size: 10pt; }
  .reading ul > li::marker, .reading ol > li::marker { color: #000; }
  .reading hr { background: #000; }
  .table-wrap { overflow: visible; border: 0; }
  .reading table { min-width: 0; font-size: 10pt; }
  .reading th, .reading td { border: 1px solid #000; background: #fff !important; color: #000; }
  .reading tr, .reading li { break-inside: avoid; page-break-inside: avoid; }
  .reading .ntt, .reading .basis-block { background: #fff; border-color: #000; }
  a { color: #000; text-decoration: none; }
}
