/* ==========================================================================
   COMP2120/6120 Final Thoughts — study companion
   ========================================================================== */

:root {
  --paper: #f5f2ea;
  --paper-2: #efeade;
  --card: #fffefb;
  --ink: #14243a;
  --ink-2: #34465e;
  --muted: #6d7c90;
  --line: #e3ddcf;
  --line-strong: #cfc6b3;
  --navy: #0e2a4a;
  --navy-2: #163a63;
  --navy-3: #24527f;
  --gold: #b9862f;
  --gold-2: #d7ab55;
  --gold-wash: #f6ecd7;
  --green: #1d7355;
  --green-wash: #e6f3ed;
  --red: #a83a3a;
  --red-wash: #fbeceb;
  --blue-wash: #e9f0f7;
  --violet: #5b4b8a;
  --violet-wash: #efecf7;
  --amber: #8a5a12;
  --amber-wash: #fbf0dc;
  --teal: #1d6b72;
  --teal-wash: #e5f2f2;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Songti SC",
    "Noto Serif SC", Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --mono: "SF Mono", "JetBrains Mono", "Roboto Mono", Menlo, Consolas, monospace;

  --shadow-sm: 0 1px 2px rgba(20, 36, 58, 0.05), 0 8px 24px rgba(20, 36, 58, 0.04);
  --shadow-md: 0 2px 4px rgba(20, 36, 58, 0.06), 0 18px 40px rgba(20, 36, 58, 0.08);
  --radius: 14px;
  --header-h: 64px;
}

* { box-sizing: border-box; }

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  background-image:
    radial-gradient(circle at 12% -10%, rgba(185, 134, 47, 0.10), transparent 38%),
    radial-gradient(circle at 88% 0%, rgba(14, 42, 74, 0.06), transparent 34%);
  background-repeat: no-repeat;
}

img { max-width: 100%; }

a {
  color: var(--navy-3);
  text-decoration: none;
}

a:hover { text-decoration: underline; }

code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: rgba(14, 42, 74, 0.06);
  border: 1px solid rgba(14, 42, 74, 0.08);
  border-radius: 4px;
  padding: 0.08em 0.34em;
  white-space: nowrap;
}

pre {
  margin: 0;
  padding: 16px 18px;
  background: #10233a;
  color: #e8edf4;
  border-radius: 10px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
}

pre code {
  background: none;
  border: 0;
  padding: 0;
  color: inherit;
  font-size: inherit;
  white-space: pre;
}

::selection { background: var(--gold-2); color: #fff; }

/* ---------- header ------------------------------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  background: rgba(14, 42, 74, 0.97);
  backdrop-filter: blur(10px);
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.header-inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #fff;
  text-decoration: none;
  min-width: 0;
}

.brand:hover { text-decoration: none; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(215, 171, 85, 0.7);
  border-radius: 8px;
  color: var(--gold-2);
  font-family: var(--serif);
  font-size: 15px;
  letter-spacing: 0.04em;
  flex: none;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  min-width: 0;
}

.brand-text strong {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 16px;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.brand-text small {
  color: rgba(255, 255, 255, 0.62);
  font-size: 11.5px;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.top-nav a {
  color: rgba(255, 255, 255, 0.78);
  font-size: 14px;
  padding: 7px 12px;
  border-radius: 999px;
  white-space: nowrap;
}

.top-nav a:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  text-decoration: none;
}

.top-nav a.is-active {
  color: #10233a;
  background: var(--gold-2);
}

.ghost-btn {
  appearance: none;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.26);
  color: rgba(255, 255, 255, 0.8);
  font: inherit;
  font-size: 13px;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: 0.18s ease;
}

.ghost-btn:hover {
  border-color: var(--gold-2);
  color: var(--gold-2);
}

.wrap {
  width: min(1320px, calc(100% - 48px));
  margin-inline: auto;
}

/* ---------- hero --------------------------------------------------------- */

.hero {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(900px 380px at 82% -20%, rgba(185, 134, 47, 0.26), transparent 62%),
    linear-gradient(160deg, #0d2745 0%, #102f53 55%, #0c2039 100%);
  color: #fff;
  border-bottom: 3px solid var(--gold);
}

.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(circle at 70% 30%, #000, transparent 75%);
  pointer-events: none;
}

.hero-inner {
  position: relative;
  z-index: 1;
  padding: 58px 0 44px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 11.5px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold-2);
  margin: 0 0 18px;
}

.eyebrow::before {
  content: "";
  width: 34px;
  height: 1px;
  background: var(--gold-2);
}

.hero h1 {
  margin: 0 0 10px;
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(30px, 4.4vw, 50px);
  line-height: 1.18;
  letter-spacing: 0.01em;
}

.hero h1 .en {
  display: block;
  margin-top: 8px;
  font-size: 0.48em;
  font-weight: 400;
  font-style: italic;
  color: rgba(255, 255, 255, 0.72);
  letter-spacing: 0.02em;
}

.hero-lead {
  max-width: 760px;
  margin: 20px 0 0;
  color: rgba(255, 255, 255, 0.8);
  font-size: 15.5px;
}

.hero-lead strong { color: #fff; font-weight: 600; }

.exam-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 26px;
}

.exam-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  padding: 7px 13px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.85);
}

.exam-chip b {
  color: var(--gold-2);
  font-weight: 600;
  letter-spacing: 0.06em;
  font-size: 11px;
  text-transform: uppercase;
}

.hero-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 40px;
  margin-top: 38px;
  padding-top: 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.stat b {
  display: block;
  font-family: var(--serif);
  font-size: 30px;
  line-height: 1;
  color: var(--gold-2);
  font-weight: 500;
}

.stat span {
  display: block;
  margin-top: 7px;
  font-size: 12.5px;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.62);
}

.disclaimer {
  margin: 22px 0 0;
  font-size: 12.5px;
  color: rgba(255, 255, 255, 0.5);
  max-width: 820px;
}

/* ---------- layout ------------------------------------------------------- */

.layout {
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr);
  gap: 48px;
  padding: 48px 0 80px;
  align-items: start;
}

.sidebar {
  position: sticky;
  top: calc(var(--header-h) + 24px);
  align-self: start;
  max-height: calc(100vh - var(--header-h) - 48px);
  overflow-y: auto;
  padding-right: 6px;
  scrollbar-width: thin;
}

.sidebar h2 {
  margin: 0 0 4px;
  font-size: 12px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

.sidebar .side-sub {
  margin: 0 0 18px;
  font-size: 12.5px;
  color: var(--muted);
}

.side-nav {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 2px solid var(--line);
}

.side-nav li { margin: 0; }

.side-nav a {
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 8px;
  align-items: baseline;
  padding: 9px 0 9px 14px;
  margin-left: -2px;
  border-left: 2px solid transparent;
  color: var(--ink-2);
  font-size: 14px;
  line-height: 1.35;
}

.side-nav a:hover {
  color: var(--navy);
  text-decoration: none;
  border-left-color: var(--line-strong);
}

.side-nav a .num {
  font-family: var(--serif);
  font-size: 12px;
  color: var(--gold);
  letter-spacing: 0.04em;
}

.side-nav a .zh { font-weight: 500; }

.side-nav a .en {
  display: block;
  font-size: 11.5px;
  color: var(--muted);
  font-style: italic;
  margin-top: 1px;
}

.side-nav a.is-active {
  border-left-color: var(--gold);
  color: var(--navy);
  background: linear-gradient(90deg, rgba(185, 134, 47, 0.10), transparent 85%);
}

.side-nav a.is-active .zh { font-weight: 700; }

.side-tools {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.side-tools h3 {
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 10px;
  font-weight: 600;
}

.mini-progress {
  height: 5px;
  border-radius: 999px;
  background: var(--paper-2);
  overflow: hidden;
}

.mini-progress span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--gold), var(--gold-2));
  border-radius: 999px;
  transition: width 0.35s ease;
}

.mini-progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
}

.content { min-width: 0; }

section[id] { scroll-margin-top: calc(var(--header-h) + 24px); }

/* ---------- section headings -------------------------------------------- */

.section-head {
  margin: 0 0 30px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line-strong);
  position: relative;
}

.section-head::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -1px;
  width: 72px;
  height: 3px;
  background: var(--gold);
}

.section-kicker {
  font-size: 11.5px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--gold);
  margin: 0 0 8px;
  font-weight: 600;
}

.section-head h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(24px, 2.6vw, 32px);
  font-weight: 600;
  letter-spacing: 0.01em;
}

.section-head h2 .en {
  font-family: var(--sans);
  font-size: 0.56em;
  font-style: italic;
  font-weight: 400;
  color: var(--muted);
  margin-left: 10px;
  letter-spacing: 0;
}

.section-head p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
  max-width: 760px;
}

/* ---------- module ------------------------------------------------------- */

.module {
  margin: 0 0 54px;
  scroll-margin-top: calc(var(--header-h) + 24px);
}

.module-head {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
  margin-bottom: 20px;
}

.module-num {
  font-family: var(--serif);
  font-size: 40px;
  line-height: 1;
  color: var(--gold);
  border-top: 2px solid var(--gold);
  padding-top: 8px;
  letter-spacing: -0.02em;
}

.module-title h3 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.module-title .en {
  display: block;
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: 15px;
  color: var(--muted);
  margin-top: 2px;
}

.module-title .lead {
  margin: 10px 0 0;
  color: var(--ink-2);
  font-size: 14.5px;
  max-width: 820px;
}

.module-meta {
  margin: 10px 0 0;
  font-size: 11.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.card-grid {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.card {
  min-width: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 24px 20px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
  position: relative;
  scroll-margin-top: calc(var(--header-h) + 24px);
}

.card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--line-strong);
  transform: translateY(-1px);
}

.card.is-hidden { display: none; }

.card-term {
  margin: 0 0 14px;
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--navy);
  display: flex;
  gap: 10px;
  align-items: baseline;
}

.card-term::before {
  content: "§";
  font-size: 14px;
  color: var(--gold);
  flex: none;
  transform: translateY(-1px);
}

.card-block {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr);
  gap: 14px;
  padding: 12px 0;
  border-top: 1px dashed var(--line);
}

.card-block:first-of-type { border-top: 0; padding-top: 0; }

.card-label {
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 700;
  padding-top: 4px;
}

.card-label.en-label { color: var(--gold); }
.card-label.zh-label { color: var(--navy-3); letter-spacing: 0.08em; }

.card-block p {
  margin: 0;
  font-size: 14.5px;
  line-height: 1.7;
  color: var(--ink-2);
}

.card-block.zh p {
  color: var(--ink);
  font-size: 14.5px;
  background: rgba(185, 134, 47, 0.05);
  border-left: 2px solid var(--gold-2);
  padding: 2px 0 2px 12px;
  margin-left: -2px;
}

.card-list {
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 5px;
}

.card-list li {
  position: relative;
  padding-left: 16px;
  font-size: 13.5px;
  color: var(--ink-2);
  line-height: 1.55;
}

.card-list li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 0.62em;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--gold-2);
}

.flow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 14px 0 2px;
}

.flow span {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  background: var(--blue-wash);
  border: 1px solid #d5e2ee;
  border-radius: 999px;
  font-size: 12.5px;
  color: var(--navy-2);
  font-weight: 500;
}

.flow span:not(:last-child)::after {
  content: "→";
  color: var(--gold);
  margin-left: 8px;
  font-weight: 400;
}

.table-wrap {
  margin: 16px 0 2px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
}

table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
  background: #fff;
}

th {
  text-align: left;
  background: var(--navy);
  color: #fff;
  font-weight: 600;
  padding: 9px 12px;
  font-size: 12px;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

td {
  padding: 9px 12px;
  border-top: 1px solid var(--line);
  color: var(--ink-2);
  vertical-align: top;
}

tbody tr:nth-child(even) td { background: #fbf9f3; }

.card-code { margin-top: 14px; }

.module-callout {
  margin-top: 18px;
  padding: 16px 20px;
  background: var(--gold-wash);
  border: 1px solid #ebd9b6;
  border-left: 3px solid var(--gold);
  border-radius: 10px;
  display: grid;
  gap: 8px;
}

.module-callout p {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.65;
}

.module-callout .zh { color: #5c4517; }
.module-callout .en { color: #7a622f; font-style: italic; }

/* ---------- practice ----------------------------------------------------- */

.practice-toolbar {
  position: sticky;
  top: var(--header-h);
  z-index: 30;
  background: rgba(245, 242, 234, 0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  padding: 14px 0 12px;
  margin: -6px 0 26px;
}

.toolbar-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.filter-chip {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: var(--card);
  color: var(--ink-2);
  border-radius: 999px;
  padding: 7px 14px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: 0.15s ease;
  white-space: nowrap;
}

.filter-chip:hover { border-color: var(--gold); color: var(--navy); }

.filter-chip.is-on {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}

.filter-chip .count { opacity: 0.6; margin-left: 5px; font-size: 11.5px; }

.select-wrap { position: relative; }

select {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: var(--card);
  color: var(--ink-2);
  border-radius: 999px;
  padding: 8px 34px 8px 14px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.select-wrap::after {
  content: "▾";
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--muted);
  font-size: 11px;
}

.search-wrap {
  position: relative;
  flex: 1 1 220px;
  min-width: 180px;
}

.search-wrap input {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: var(--card);
  border-radius: 999px;
  padding: 8px 36px 8px 36px;
  font: inherit;
  font-size: 13.5px;
  color: var(--ink);
}

.search-wrap input:focus {
  outline: 2px solid rgba(185, 134, 47, 0.35);
  outline-offset: 1px;
  border-color: var(--gold);
}

.search-wrap::before {
  content: "⌕";
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-52%);
  color: var(--muted);
  font-size: 16px;
}

.progress-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 12px;
  font-size: 12.5px;
  color: var(--muted);
}

.progress-bar {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: var(--paper-2);
  overflow: hidden;
}

.progress-bar span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--gold), var(--gold-2));
  transition: width 0.4s ease;
}

.progress-text { white-space: nowrap; font-variant-numeric: tabular-nums; }

.q-list { display: grid; gap: 18px; }

.q-card {
  min-width: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow-sm);
  scroll-margin-top: calc(var(--header-h) + 210px);
}

.q-card.is-hidden { display: none; }

.q-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.q-index {
  font-family: var(--serif);
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.08em;
}

.badge {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 5px;
  border: 1px solid transparent;
}

.badge-matching { color: #24527f; background: var(--blue-wash); border-color: #cfe0ee; }
.badge-selection { color: var(--violet); background: var(--violet-wash); border-color: #ddd6ee; }
.badge-short { color: var(--amber); background: var(--amber-wash); border-color: #eedcb7; }
.badge-applied { color: var(--teal); background: var(--teal-wash); border-color: #c8e3e3; }

.q-topic {
  font-size: 12px;
  color: var(--muted);
  margin-left: auto;
  white-space: nowrap;
  padding-left: 12px;
  border-left: 1px solid var(--line);
}



.q-prompt { font-size: 15px; color: var(--ink); }
.q-prompt p { margin: 0 0 10px; }
.q-prompt p:last-child { margin-bottom: 0; }

.q-code { margin: 14px 0 4px; }

.options {
  display: grid;
  gap: 8px;
  margin: 16px 0 4px;
  padding: 0;
  list-style: none;
}

.option {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) 18px;
  gap: 10px;
  align-items: start;
  width: 100%;
  text-align: left;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px 12px;
  font: inherit;
  font-size: 14px;
  color: var(--ink-2);
  cursor: pointer;
  transition: 0.14s ease;
}

.option:hover { border-color: var(--gold-2); background: #fffdf7; }

.option .letter {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--paper-2);
  color: var(--ink-2);
  font-family: var(--serif);
  font-size: 12px;
  font-weight: 600;
  transition: 0.14s ease;
}

.option .mark {
  font-size: 13px;
  text-align: center;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.option.is-picked { border-color: var(--navy-3); background: #f1f6fb; }
.option.is-picked .letter { background: var(--navy-3); color: #fff; }

.option.is-correct { border-color: var(--green); background: var(--green-wash); }
.option.is-correct .letter { background: var(--green); color: #fff; }
.option.is-correct .mark { opacity: 1; color: var(--green); }

.option.is-wrong { border-color: var(--red); background: var(--red-wash); }
.option.is-wrong .letter { background: var(--red); color: #fff; }
.option.is-wrong .mark { opacity: 1; color: var(--red); }

.option:disabled { cursor: default; }

.q-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
}

.reveal-btn {
  appearance: none;
  border: 1px solid var(--navy);
  background: var(--navy);
  color: #fff;
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: 7px;
  cursor: pointer;
  transition: 0.16s ease;
}

.reveal-btn:hover { background: var(--navy-2); border-color: var(--navy-2); }

.reveal-btn.is-open {
  background: transparent;
  color: var(--navy);
}

.answer-hint { font-size: 12px; color: var(--muted); }

.q-answer {
  margin-top: 16px;
  border-top: 1px dashed var(--line-strong);
  padding-top: 16px;
  animation: fade 0.25s ease;
}

@keyframes fade {
  from { opacity: 0; transform: translateY(-3px); }
  to { opacity: 1; transform: none; }
}

.answer-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.answer-head h4 {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
}

.verdict {
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
}

.verdict.ok { color: var(--green); background: var(--green-wash); }
.verdict.bad { color: var(--red); background: var(--red-wash); }
.verdict.neutral { color: var(--muted); background: var(--paper-2); }

.answer-body { font-size: 14.5px; color: var(--ink-2); line-height: 1.72; }
.answer-body p { margin: 0 0 10px; }
.answer-body p:last-child { margin-bottom: 0; }
.answer-body ol, .answer-body ul { margin: 0 0 10px; padding-left: 22px; }
.answer-body li { margin: 4px 0; }
.answer-body strong { color: var(--ink); }
.answer-body pre { margin: 10px 0; }
.answer-body code { white-space: normal; }
.answer-body .mini-table { margin: 10px 0; font-size: 12.5px; }
.answer-body .mini-table th { white-space: normal; }

.write-area {
  width: 100%;
  min-height: 92px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  padding: 12px 14px;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  margin-top: 14px;
}

.write-area:focus {
  outline: 2px solid rgba(185, 134, 47, 0.3);
  border-color: var(--gold);
}

.write-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 6px;
}

.empty-state {
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 40px 24px;
  text-align: center;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.5);
}

/* ---------- glossary ----------------------------------------------------- */

.glossary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
}

.glossary-item {
  display: block;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 11px 14px;
  color: var(--ink-2);
  transition: 0.15s ease;
}

.glossary-item:hover {
  border-color: var(--gold-2);
  text-decoration: none;
  background: #fffdf7;
}

.glossary-item b {
  display: block;
  font-family: var(--serif);
  font-size: 14px;
  color: var(--navy);
  font-weight: 600;
}

.glossary-item span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.glossary-item.is-hidden { display: none; }

/* ---------- footer ------------------------------------------------------- */

.site-footer {
  border-top: 1px solid var(--line-strong);
  background: #0d2745;
  color: rgba(255, 255, 255, 0.55);
  padding: 30px 0;
  font-size: 12.5px;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 28px;
  justify-content: space-between;
}

.site-footer b { color: rgba(255, 255, 255, 0.82); font-weight: 500; }

.to-top {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--card);
  color: var(--navy);
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-md);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: 0.2s ease;
  z-index: 40;
  font-size: 16px;
}

.to-top.is-visible { opacity: 1; pointer-events: auto; }

/* ---------- responsive --------------------------------------------------- */

@media (max-width: 1080px) {
  .layout { grid-template-columns: 232px minmax(0, 1fr); gap: 32px; }
  .side-nav a .en { display: none; }
}

@media (max-width: 880px) {
  .wrap { width: calc(100% - 32px); }
  .layout { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .sidebar {
    position: static;
    max-height: none;
    max-width: 100%;
    overflow: visible;
    padding: 0;
    margin-bottom: 18px;
  }
  .side-nav li { min-width: 0; }
  .sidebar h2, .sidebar .side-sub { display: none; }
  .side-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    border-left: 0;
    padding: 0;
  }
  .side-nav a {
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 7px 13px;
    margin: 0;
    background: var(--card);
    white-space: nowrap;
    display: flex;
    gap: 6px;
  }
  .side-nav a.is-active { background: var(--navy); color: #fff; border-color: var(--navy); }
  .side-nav a.is-active .num { color: var(--gold-2); }
  .side-tools { display: none; }
  .module-head { grid-template-columns: 52px minmax(0, 1fr); gap: 14px; }
  .module-num { font-size: 30px; }
  .hero-inner { padding: 42px 0 34px; }
  .card { padding: 18px; }
  .q-card { padding: 18px; }
  .practice-toolbar { top: var(--header-h); }
  .top-nav a { padding: 6px 10px; font-size: 13px; }
  .top-nav { gap: 2px; }
  #resetProgress { display: none; }
}

@media (max-width: 460px) {
  .brand-text { display: none; }
}

@media (max-width: 560px) {
  .brand-text small { display: none; }
  .brand-text strong { font-size: 14.5px; }
  .card-block { grid-template-columns: 1fr; gap: 4px; }
  .card-label { padding-top: 0; }
  .hero-stats { gap: 26px; }
  .stat b { font-size: 24px; }
  .exam-strip { gap: 8px; }
  .exam-chip { font-size: 12px; padding: 6px 10px; }
  .q-topic { margin-left: 0; width: 100%; }
  .progress-row { flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation: none !important; transition: none !important; }
}

/* ---------- print -------------------------------------------------------- */

@media print {
  body { background: #fff; }
  .site-header, .sidebar, .practice-toolbar, .top-nav, .q-actions,
  .to-top, .site-footer, .hero::after { display: none !important; }
  .hero { background: #fff; color: #000; border-bottom: 2px solid #000; }
  .hero h1, .hero .en, .hero-lead, .hero-stats, .stat b, .exam-chip,
  .eyebrow { color: #000 !important; }
  .layout { display: block; padding: 0; }
  .card, .q-card { break-inside: avoid; box-shadow: none; page-break-inside: avoid; }
  .q-answer { display: block !important; }
  .q-answer[hidden] { display: block !important; }
  a { color: #000; text-decoration: none; }
}

/* ---------- knowledge links on questions --------------------------------- */

.q-refs {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
}

.q-refs summary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 11.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--muted);
  list-style: none;
}

.q-refs summary::-webkit-details-marker { display: none; }

.q-refs summary::before {
  content: "▸";
  color: var(--gold);
  font-size: 11px;
  transition: transform 0.15s ease;
}

.q-refs[open] summary::before { transform: rotate(90deg); }

.q-refs summary:hover { color: var(--navy); }

.ref-count {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--paper-2);
  color: var(--ink-2);
  font-size: 10.5px;
  letter-spacing: 0;
  font-weight: 600;
}

.ref-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.ref-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  padding: 5px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: #fff;
  color: var(--navy);
  font-size: 12.5px;
  line-height: 1.4;
  transition: 0.15s ease;
}

.ref-chip:hover {
  border-color: var(--gold);
  background: #fffdf7;
  text-decoration: none;
}

.ref-module {
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.card:target {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(185, 134, 47, 0.16), var(--shadow-md);
}
