/* practisEN — Legal English Books — Theme
   Brand: violet #7030E0
   Fonts: Baloo 2 (display) · Nunito (body) · JetBrains Mono (mono)
*/

:root {
  /* Primary — violet from logo */
  --violet-950:#1A0840;
  --violet-900:#2E1065;
  --violet-800:#7030E0;
  --violet-700:#5B21B6;
  --violet-600:#6D28D9;
  --violet-500:#8B5CF6;
  --violet-400:#A78BFA;
  --violet-300:#C4B5FD;
  --violet-200:#DDD6FE;
  --violet-100:#EDE9FE;
  --violet-50:#F5F3FF;

  /* Neutrals — violet-tinted */
  --ink:#1A0840;
  --ink-2:#3D2A6B;
  --ink-3:#6E5FA0;
  --ink-4:#A89FC8;
  --line:#E8E2F2;
  --line-2:#D0C6E8;
  --bg:#FBFAFE;
  --bg-2:#F3F0FB;
  --surface:#FFFFFF;

  /* Status */
  --ok:#16A374;
  --warn:#E08A15;
  --err:#DC3545;
  --info:#3B82F6;

  /* Radii */
  --r-xs:6px; --r-sm:8px; --r-md:14px; --r-lg:22px; --r-xl:32px; --r-full:999px;

  /* Shadows */
  --shadow-xs:0 1px 2px rgba(112,48,224,.06);
  --shadow-sm:0 2px 8px rgba(112,48,224,.08);
  --shadow-md:0 8px 24px rgba(112,48,224,.10);
  --shadow-lg:0 20px 50px rgba(112,48,224,.14);

  /* Typography */
  --font-display: 'Baloo 2', system-ui, sans-serif;
  --font-body: 'Nunito', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;

  /* Layout */
  --sidebar-w: 280px;
  --content-max: 760px;
  --toc-w: 220px;
  --header-h: 64px;
}

[data-theme="dark"] {
  --violet-50:#1A0840;
  --violet-100:#231057;
  --violet-200:#2E1065;
  --ink:#F5F3FF;
  --ink-2:#DDD6FE;
  --ink-3:#A78BFA;
  --ink-4:#7B6CA8;
  --line:#3D2A6B;
  --line-2:#5B21B6;
  --bg:#0F0428;
  --bg-2:#1A0840;
  --surface:#231057;
  --shadow-xs:0 1px 2px rgba(0,0,0,.3);
  --shadow-sm:0 2px 8px rgba(0,0,0,.35);
  --shadow-md:0 8px 24px rgba(0,0,0,.4);
  --shadow-lg:0 20px 50px rgba(0,0,0,.5);
}

/* ───────── Base ───────── */
*,*::before,*::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 500;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--violet-700); text-decoration: none; }
[data-theme="dark"] a { color: var(--violet-300); }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; }

/* ───────── Header ───────── */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(251,250,254,.85);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border-bottom: 1px solid var(--line);
  height: var(--header-h);
  display: flex; align-items: center;
}
[data-theme="dark"] .site-header {
  background: rgba(15,4,40,.85);
}
.header-inner {
  width: 100%; max-width: 1600px; margin: 0 auto; padding: 0 24px;
  display: flex; align-items: center; gap: 20px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-display); font-weight: 800; font-size: 18px;
  color: var(--ink); letter-spacing: -0.02em;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 36px; height: 36px;
  flex-shrink: 0;
  display: block;
  object-fit: contain;
}
.brand-wordmark {
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: -0.02em;
}
.brand em { color: var(--violet-800); font-style: normal; }
[data-theme="dark"] .brand em { color: var(--violet-400); }
.book-crumb {
  margin-left: 12px; padding-left: 16px;
  border-left: 1px solid var(--line);
  font-size: 13px; color: var(--ink-3); font-weight: 600;
}
.book-crumb .level {
  display: inline-block; padding: 3px 9px;
  background: var(--violet-100); color: var(--violet-700);
  border-radius: var(--r-full);
  font-size: 11px; font-weight: 700; letter-spacing: 0.5px;
  text-transform: uppercase; margin-right: 6px;
}
.header-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.icon-btn {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: var(--r-full);
  color: var(--ink-2);
  transition: .2s;
}
.icon-btn:hover { background: var(--violet-100); color: var(--violet-700); }
.icon-btn svg { width: 18px; height: 18px; }

/* ───────── Layout ───────── */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  max-width: 1600px;
  margin: 0 auto;
  min-height: calc(100vh - var(--header-h));
}
.sidebar {
  border-right: 1px solid var(--line);
  padding: 28px 20px;
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  background: var(--bg);
}
.main {
  padding: 48px 40px 80px;
  min-width: 0;
}
.content-wrap {
  max-width: var(--content-max);
  margin: 0 auto;
}
@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: var(--header-h); left: 0;
    width: 85%; max-width: 320px;
    z-index: 90;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .main { padding: 28px 18px 60px; }
}

/* ───────── Sidebar ───────── */
.side-section {
  margin-bottom: 28px;
}
.side-label {
  font-family: var(--font-mono);
  font-size: 11px; font-weight: 600;
  color: var(--ink-3);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-bottom: 12px;
  padding: 0 8px;
}
.unit-list {
  list-style: none;
  display: flex; flex-direction: column; gap: 2px;
}
.unit-list a {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  color: var(--ink-2);
  font-weight: 600; font-size: 14px;
  line-height: 1.3;
  transition: .15s;
}
.unit-list a:hover { background: var(--violet-50); color: var(--violet-700); text-decoration: none; }
.unit-list a.current {
  background: var(--violet-800); color: white;
}
.unit-list .num {
  font-family: var(--font-mono);
  font-size: 11px; font-weight: 700;
  background: var(--violet-100); color: var(--violet-700);
  padding: 3px 8px; border-radius: var(--r-sm);
  min-width: 28px; text-align: center;
  flex-shrink: 0; margin-top: 1px;
}
.unit-list a.current .num {
  background: rgba(255,255,255,.22); color: white;
}
.unit-list .title {
  flex: 1; word-break: break-word;
}
.unit-list a.done .title::after {
  content: "✓";
  display: inline-block; margin-left: 6px;
  color: var(--ok); font-weight: 800;
}
.unit-list a.current.done .title::after { color: white; }

.toc-progress {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px 16px;
  margin-top: 6px;
}
.toc-progress .label {
  font-size: 12px; color: var(--ink-3); font-weight: 700;
  display: flex; justify-content: space-between;
  margin-bottom: 8px;
}
.toc-progress .bar {
  height: 6px;
  background: var(--violet-100);
  border-radius: var(--r-full);
  overflow: hidden;
}
.toc-progress .fill {
  height: 100%;
  background: linear-gradient(90deg, var(--violet-500), var(--violet-800));
  border-radius: var(--r-full);
  transition: width .4s ease;
}

/* ───────── Content typography ───────── */
.content-wrap h1, .content-wrap h2, .content-wrap h3 {
  font-family: var(--font-display);
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--ink);
}
.content-wrap h1 {
  font-size: clamp(36px, 5vw, 56px);
  font-weight: 800;
  margin: 0 0 12px;
}
.content-wrap h2 {
  font-size: clamp(24px, 3vw, 32px);
  font-weight: 700;
  margin: 56px 0 18px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--violet-100);
}
.content-wrap h3 {
  font-size: clamp(18px, 2.4vw, 22px);
  font-weight: 700;
  margin: 36px 0 14px;
  color: var(--violet-700);
}
[data-theme="dark"] .content-wrap h3 { color: var(--violet-300); }
.content-wrap p {
  font-size: 16px;
  margin-bottom: 14px;
  color: var(--ink-2);
}
.content-wrap ul, .content-wrap ol {
  margin: 12px 0 18px 22px;
  color: var(--ink-2);
}
.content-wrap li {
  margin-bottom: 6px;
  line-height: 1.6;
}
.content-wrap blockquote {
  margin: 20px 0;
  padding: 14px 20px;
  border-left: 3px solid var(--violet-400);
  background: var(--violet-50);
  color: var(--ink-2);
  font-style: italic;
  border-radius: 0 var(--r-md) var(--r-md) 0;
}
.content-wrap img.page-img {
  margin: 24px 0;
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  background: white;
}
.content-wrap strong { color: var(--ink); font-weight: 700; }
.content-wrap em { color: var(--violet-700); font-style: italic; }
[data-theme="dark"] .content-wrap em { color: var(--violet-300); }

/* ───────── Unit hero (cover) ───────── */
.unit-hero {
  position: relative;
  padding: 56px 48px 60px;
  margin-bottom: 40px;
  background: linear-gradient(135deg, var(--violet-50), var(--violet-100) 50%, var(--violet-50));
  border: 1px solid var(--violet-200);
  border-radius: var(--r-xl);
  overflow: hidden;
}
[data-theme="dark"] .unit-hero {
  background: linear-gradient(135deg, var(--violet-200), var(--violet-100));
}
.unit-hero::before {
  content: "";
  position: absolute; top: -100px; right: -100px;
  width: 280px; height: 280px;
  background: radial-gradient(circle, var(--violet-300), transparent 70%);
  filter: blur(40px); opacity: .5;
}
.unit-hero .kicker {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--font-mono);
  font-size: 12px; font-weight: 600;
  color: var(--violet-700);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  position: relative;
}
[data-theme="dark"] .unit-hero .kicker { color: var(--violet-200); }
.unit-hero .kicker .badge {
  background: var(--violet-800);
  color: white;
  padding: 3px 10px;
  border-radius: var(--r-full);
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.5px;
}
.unit-hero h1 {
  margin: 18px 0 0 !important;
  position: relative;
}
.unit-hero h1 em {
  color: var(--violet-800);
  font-style: normal;
  position: relative;
  display: inline-block;
}
[data-theme="dark"] .unit-hero h1 em { color: var(--violet-800); }
.unit-hero h1 em::after {
  content: "";
  position: absolute; left: 0; right: 0; bottom: 6%;
  height: 16%;
  background: var(--violet-300);
  z-index: -1;
  border-radius: 4px;
  transform: rotate(-0.8deg);
}
.unit-hero .meta {
  margin-top: 26px;
  display: flex; gap: 28px; flex-wrap: wrap;
  font-size: 13px; color: var(--ink-2); font-weight: 600;
  position: relative;
}
.unit-hero .meta span {
  display: inline-flex; align-items: center; gap: 6px;
}
.unit-hero .meta svg {
  width: 14px; height: 14px; color: var(--violet-700);
}

/* ───────── Exercise card ───────── */
.exercise {
  margin: 32px 0;
  padding: 24px 26px 26px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
  position: relative;
}
.exercise::before {
  content: "";
  position: absolute; left: 0; top: 24px; bottom: 24px;
  width: 4px;
  background: linear-gradient(180deg, var(--violet-500), var(--violet-700));
  border-radius: var(--r-full);
}
.exercise-head {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 16px;
}
.exercise-num {
  font-family: var(--font-mono);
  font-size: 11px; font-weight: 700;
  background: var(--violet-100); color: var(--violet-700);
  padding: 5px 10px;
  border-radius: var(--r-sm);
  letter-spacing: 0.8px;
}
.exercise-title {
  font-family: var(--font-display);
  font-size: 18px; font-weight: 700;
  color: var(--ink);
  line-height: 1.3;
}
.exercise-mark {
  margin-left: auto;
  width: 28px; height: 28px;
  border-radius: var(--r-full);
  border: 1.5px solid var(--line-2);
  cursor: pointer;
  display: grid; place-items: center;
  font-size: 14px; color: transparent;
  transition: .15s;
}
.exercise-mark:hover { border-color: var(--violet-400); }
.exercise.done .exercise-mark {
  background: var(--ok); border-color: var(--ok);
  color: white;
}

/* Exercise instructions: italic block between title and content */
.exercise-instructions {
  margin: -4px 0 16px;
  padding: 12px 18px;
  background: var(--violet-50);
  border-left: 3px solid var(--violet-400);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  font-style: italic;
  font-size: 15px;
  color: var(--ink-2);
  line-height: 1.5;
}
[data-theme="dark"] .exercise-instructions { background: var(--violet-100); }
.exercise-instructions::before {
  content: "INSTRUCTIONS";
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.3px;
  color: var(--violet-700);
  font-style: normal;
  margin-bottom: 4px;
  text-transform: uppercase;
}

/* ───────── Callouts ───────── */
.callout {
  margin: 24px 0;
  padding: 18px 22px;
  border-radius: var(--r-md);
  display: flex; gap: 16px; align-items: flex-start;
  border-left: 3px solid;
}
.callout-icon {
  flex-shrink: 0;
  width: 28px; height: 28px;
  border-radius: var(--r-full);
  display: grid; place-items: center;
  font-weight: 800; font-size: 14px;
}
.callout-tip { background: var(--violet-50); border-color: var(--violet-500); color: var(--ink-2); }
.callout-tip .callout-icon { background: var(--violet-500); color: white; }
.callout-note { background: #FFF8E6; border-color: var(--warn); color: var(--ink-2); }
.callout-note .callout-icon { background: var(--warn); color: white; }
[data-theme="dark"] .callout-note { background: rgba(224,138,21,.1); color: var(--ink-2); }

.dialogue {
  margin: 24px 0;
  padding: 22px 26px;
  background: var(--violet-50);
  border: 1px solid var(--violet-200);
  border-radius: var(--r-md);
  font-style: italic;
  color: var(--ink-2);
}
[data-theme="dark"] .dialogue { background: var(--violet-100); }

/* Vocabulary chips */
.vocab-list {
  display: flex; flex-wrap: wrap; gap: 6px 8px;
  margin: 18px 0 26px;
  padding: 18px 20px;
  background: var(--violet-50);
  border: 1px solid var(--violet-200);
  border-radius: var(--r-md);
}
.vocab-list::before {
  content: "KEY VOCABULARY";
  display: block; width: 100%;
  font-family: var(--font-mono);
  font-size: 11px; font-weight: 700;
  color: var(--violet-700);
  letter-spacing: 1.5px;
  margin-bottom: 10px;
}
[data-theme="dark"] .vocab-list { background: var(--violet-100); }
[data-theme="dark"] .vocab-list::before { color: var(--violet-300); }
.vchip {
  display: inline-block;
  background: var(--surface);
  border: 1px solid var(--violet-200);
  border-radius: var(--r-sm);
  padding: 5px 12px;
  font-size: 14px; font-weight: 600;
  color: var(--ink);
}
[data-theme="dark"] .vchip { background: var(--surface); border-color: var(--violet-200); }

/* Letter-marker ordered list */
.letter-list {
  list-style: none;
  margin: 16px 0 22px;
  padding: 0;
  display: flex; flex-direction: column; gap: 12px;
  counter-reset: letter-list;
}
.letter-list li {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 12px 16px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
}
[data-theme="dark"] .letter-list li { background: var(--surface); }
.letter-list .letter {
  display: inline-grid; place-items: center;
  flex-shrink: 0;
  width: 24px; height: 24px;
  background: var(--violet-700); color: white;
  border-radius: var(--r-full);
  font-family: var(--font-mono);
  font-weight: 700; font-size: 12px;
  text-transform: lowercase;
}
.letter-list li > div {
  flex: 1; line-height: 1.55; color: var(--ink-2);
}
.letter-list li > div p {
  margin: 0 0 8px;
}
.letter-list li > div p:last-child { margin-bottom: 0; }

/* True/False toggles */
.tf {
  display: inline-flex; align-items: center; gap: 6px;
  margin: 4px 8px 4px 0;
  padding: 5px 14px;
  background: var(--surface);
  border: 1.5px solid var(--line-2);
  border-radius: var(--r-full);
  font-size: 13px; font-weight: 700;
  color: var(--ink-2);
  cursor: pointer;
  transition: .15s;
  user-select: none;
}
.tf:hover { border-color: var(--violet-400); }
.tf::before {
  content: "";
  width: 14px; height: 14px;
  border: 1.5px solid var(--line-2);
  border-radius: var(--r-full);
  display: inline-block;
}
.tf.true { color: var(--ok); border-color: var(--ok); background: rgba(22,163,116,.08); }
.tf.true::before { background: var(--ok); border-color: var(--ok); }
.tf.false { color: var(--err); border-color: var(--err); background: rgba(220,53,69,.08); }
.tf.false::before { background: var(--err); border-color: var(--err); }

/* Interactive True/False button pair */
.tf-pair {
  display: inline-flex; gap: 6px;
  margin: 0 6px;
  vertical-align: middle;
}
.tf-btn {
  padding: 4px 14px;
  border-radius: var(--r-full);
  border: 1.5px solid var(--line-2);
  background: var(--surface);
  font-size: 13px; font-weight: 700;
  color: var(--ink-3);
  transition: .15s;
  cursor: pointer;
}
.tf-btn:hover { border-color: var(--violet-400); color: var(--violet-700); }
.tf-btn.selected[data-v="true"] { border-color: var(--ok); background: rgba(22,163,116,.12); color: var(--ok); }
.tf-btn.selected[data-v="false"] { border-color: var(--err); background: rgba(220,53,69,.12); color: var(--err); }
.tf-btn:active { transform: scale(0.96); }

.caption {
  font-size: 13px; color: var(--ink-3);
  font-style: italic;
  margin: 6px 0 14px;
}
.letter-stand {
  font-family: var(--font-mono);
  color: var(--violet-700);
  font-size: 14px; font-weight: 700;
  margin: 12px 0 4px;
  letter-spacing: 0.5px;
}

/* Two-column matching table */
.match-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 18px 0 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
  font-size: 15px;
}
.match-table thead th {
  font-family: var(--font-mono);
  font-size: 10px; font-weight: 700;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 10px 14px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
  text-align: left;
}
.match-table thead th:first-child { width: 50px; text-align: center; }
.match-table tbody td {
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  vertical-align: top;
  line-height: 1.5;
  color: var(--ink-2);
}
.match-table tbody tr:first-child td { border-top: 0; }
.match-table .match-key {
  font-family: var(--font-mono);
  font-weight: 700;
  text-align: center;
  color: var(--violet-700);
  width: 50px;
  background: var(--violet-50);
}
[data-theme="dark"] .match-table .match-key { background: var(--violet-100); }
.match-table .match-left {
  font-weight: 600;
  color: var(--ink);
  width: 38%;
}
.match-table .match-right {
  color: var(--ink-2);
}
@media (max-width: 720px) {
  .match-table thead { display: none; }
  .match-table tbody tr {
    display: grid;
    grid-template-columns: 50px 1fr;
    grid-template-areas: "key left" "key right";
    gap: 4px;
    padding: 8px 4px;
  }
  .match-table tbody td {
    padding: 6px 10px;
    border: 0;
  }
  .match-table tbody tr + tr td.match-key {
    border-top: 1px solid var(--line);
  }
  .match-table .match-key { grid-area: key; align-self: start; }
  .match-table .match-left { grid-area: left; }
  .match-table .match-right { grid-area: right; }
}

/* ───────── Interactive exercise actions ───────── */
.ex-actions {
  display: flex; align-items: center; gap: 10px;
  margin: -4px 0 18px;
  padding-bottom: 14px;
  border-bottom: 1px dashed var(--line);
  flex-wrap: wrap;
}
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  border-radius: var(--r-full);
  font-size: 13px; font-weight: 700;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: .15s;
  font-family: inherit;
}
.btn-primary {
  background: var(--violet-800); color: white;
  border-color: var(--violet-800);
}
.btn-primary:hover { background: var(--violet-900); border-color: var(--violet-900); }
.btn-ghost {
  background: transparent; color: var(--ink-2);
  border-color: var(--line-2);
}
.btn-ghost:hover { background: var(--violet-50); color: var(--violet-700); border-color: var(--violet-400); }
[data-theme="dark"] .btn-ghost:hover { background: var(--violet-100); }
.ex-score {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 13px; font-weight: 700;
  padding: 5px 12px;
  border-radius: var(--r-full);
  background: var(--bg-2);
  color: var(--ink-3);
  display: none;
}
.ex-score.show { display: inline-block; }
.ex-score.perfect { background: var(--ok); color: white; }
.ex-score.partial { background: var(--warn); color: white; }
.ex-score.fail    { background: var(--err); color: white; }

/* Answer box */
.answer-box {
  margin: 24px 0 6px;
  padding: 18px 22px 20px;
  background: var(--violet-50);
  border: 1px solid var(--violet-200);
  border-radius: var(--r-md);
}
[data-theme="dark"] .answer-box { background: var(--violet-100); }
.answer-box-head {
  display: flex; align-items: center; gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.answer-box-label {
  font-family: var(--font-mono);
  font-size: 11px; font-weight: 700;
  color: var(--violet-700);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding: 3px 10px;
  background: var(--surface);
  border-radius: var(--r-sm);
  border: 1px solid var(--violet-200);
}
[data-theme="dark"] .answer-box-label { color: var(--violet-300); background: var(--violet-200); border-color: var(--violet-300); }
.answer-box-hint {
  font-size: 12px; color: var(--ink-3);
  font-style: italic;
}
.ans-rows {
  display: flex; flex-direction: column; gap: 8px;
}
.ans-row {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  position: relative;
  transition: .15s;
}
.ans-row.open {
  grid-template-columns: 28px 1fr;
  align-items: flex-start;
}
.ans-row.correct {
  border-color: var(--ok);
  background: rgba(22,163,116,.08);
}
.ans-row.incorrect {
  border-color: var(--err);
  background: rgba(220,53,69,.06);
}
.ans-row.revealed {
  border-color: var(--violet-400);
  background: var(--violet-50);
}
[data-theme="dark"] .ans-row { background: var(--bg-2); }
[data-theme="dark"] .ans-row.revealed { background: var(--violet-100); }
.ans-key {
  font-family: var(--font-mono);
  font-size: 13px; font-weight: 700;
  color: var(--violet-700);
  text-align: center;
}
.ans-input {
  display: flex; align-items: center; gap: 6px;
  flex-wrap: wrap;
}
.ans-text, .ans-textarea {
  width: 100%;
  padding: 7px 12px;
  border: 1.5px solid var(--line-2);
  background: var(--bg);
  border-radius: var(--r-sm);
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  font-weight: 500;
  outline: none;
  transition: .15s;
}
[data-theme="dark"] .ans-text, [data-theme="dark"] .ans-textarea { background: var(--surface); }
.ans-text:focus, .ans-textarea:focus {
  border-color: var(--violet-500);
  box-shadow: 0 0 0 3px var(--violet-100);
}
.ans-textarea { resize: vertical; min-height: 88px; line-height: 1.5; }
.open-answer-box .ans-textarea { min-height: 110px; }
/* When the open-answer box has multiple lettered rows, lay them out as a
   stacked grid with a left key column so each prompt has its own pad. */
.open-answer-box .ans-rows { display: grid; gap: 12px; }
.open-answer-box .ans-row.open { display: grid; grid-template-columns: 36px 1fr; align-items: start; gap: 10px; background: transparent; padding: 0; }
.open-answer-box .ans-row.open.single { grid-template-columns: 1fr; }
.open-answer-box .ans-row.open .ans-key { font-weight: 700; color: var(--violet-700); padding-top: 8px; }
.open-answer-box .ans-row.open .ans-input { width: 100%; min-width: 0; }
.open-answer-box .ans-row.open .ans-textarea { width: 100%; box-sizing: border-box; }
.ans-select {
  padding: 6px 10px;
  border: 1.5px solid var(--line-2);
  background: var(--bg);
  border-radius: var(--r-sm);
  font: inherit;
  font-size: 14px; font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  font-family: var(--font-mono);
}
[data-theme="dark"] .ans-select { background: var(--surface); }
.tf-opt, .mcq-opt {
  padding: 5px 14px;
  border-radius: var(--r-full);
  border: 1.5px solid var(--line-2);
  background: var(--bg);
  font-size: 13px; font-weight: 700;
  color: var(--ink-3);
  cursor: pointer;
  transition: .15s;
  font-family: inherit;
}
.tf-opt:hover, .mcq-opt:hover {
  border-color: var(--violet-400); color: var(--violet-700);
}
.tf-opt.selected[data-v="true"],
.mcq-opt.selected {
  background: var(--violet-800); color: white;
  border-color: var(--violet-800);
}
.tf-opt.selected[data-v="false"] {
  background: var(--violet-700); color: white;
  border-color: var(--violet-700);
}
[data-theme="dark"] .tf-opt, [data-theme="dark"] .mcq-opt { background: var(--surface); }
.mcq-opt {
  font-family: var(--font-mono);
  min-width: 36px; text-align: center;
}
.ans-status {
  font-size: 16px; font-weight: 800;
  width: 24px; height: 24px;
  border-radius: var(--r-full);
  display: grid; place-items: center;
  color: white;
  flex-shrink: 0;
}
.ans-row.correct .ans-status::before { content: "✓"; background: var(--ok); width: 24px; height: 24px; border-radius: var(--r-full); display: grid; place-items: center; }
.ans-row.incorrect .ans-status::before { content: "✕"; background: var(--err); width: 24px; height: 24px; border-radius: var(--r-full); display: grid; place-items: center; }
.ans-correct {
  display: none;
  grid-column: 2 / -1;
  font-size: 13px;
  padding: 6px 12px;
  margin-top: 4px;
  background: var(--violet-100);
  border-radius: var(--r-sm);
  color: var(--violet-700);
  font-weight: 600;
}
.ans-correct::before {
  content: "Correct: ";
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-right: 6px;
  opacity: .7;
}
.ans-row.show-correct .ans-correct { display: block; }
.ans-row.revealed .ans-correct { display: block; }
[data-theme="dark"] .ans-correct { background: var(--violet-200); color: var(--violet-700); }

/* When an item is "correct", lock it visually */
.ans-row.correct .tf-opt, .ans-row.correct .mcq-opt, .ans-row.correct .ans-select, .ans-row.correct .ans-text {
  pointer-events: none;
}

/* No-key exercises ("none" type): hide actions */
.exercise[data-ex-type="none"] .ex-actions { display: none; }

/* ───────── Collapsible topic sections ───────── */
.topic {
  margin: 28px 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  transition: border-color .2s, box-shadow .2s;
}
.topic[open] {
  border-color: var(--violet-300);
  box-shadow: var(--shadow-sm);
}
[data-theme="dark"] .topic[open] { border-color: var(--violet-400); }
.topic-head {
  display: flex; align-items: center; gap: 16px;
  padding: 18px 24px;
  cursor: pointer;
  list-style: none;
  font-family: var(--font-display);
  font-size: 19px; font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
  user-select: none;
  transition: background .15s;
}
.topic-head::-webkit-details-marker { display: none; }
.topic-head:hover { background: var(--violet-50); }
[data-theme="dark"] .topic-head:hover { background: var(--violet-100); }
.topic[open] .topic-head {
  background: linear-gradient(135deg, var(--violet-50), var(--violet-100));
  border-bottom: 1px solid var(--violet-200);
}
[data-theme="dark"] .topic[open] .topic-head {
  background: var(--violet-100);
}
.topic-chev {
  display: grid; place-items: center;
  width: 32px; height: 32px;
  border-radius: var(--r-full);
  background: var(--violet-100);
  color: var(--violet-700);
  flex-shrink: 0;
  transition: transform .25s ease, background .15s;
}
[data-theme="dark"] .topic-chev { background: var(--violet-200); color: var(--violet-700); }
.topic[open] .topic-chev {
  transform: rotate(180deg);
  background: var(--violet-800);
  color: white;
}
.topic-chev svg { width: 16px; height: 16px; }
.topic-name {
  flex: 1; word-break: break-word;
  text-transform: uppercase;
}
.topic-name h2 { all: unset; }
.topic-name strong { font-weight: 700; }
.topic-meta {
  font-family: var(--font-mono);
  font-size: 11px; font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 4px 10px;
  background: var(--bg-2);
  border-radius: var(--r-full);
  flex-shrink: 0;
}
[data-theme="dark"] .topic-meta { background: var(--violet-200); color: var(--violet-700); }
.topic-time {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--font-mono);
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.6px;
  color: var(--violet-700);
  padding: 4px 10px;
  background: var(--violet-50);
  border: 1px solid var(--violet-200);
  border-radius: var(--r-full);
  flex-shrink: 0;
  margin-right: 4px;
}
[data-theme="dark"] .topic-time { background: var(--violet-100); color: var(--violet-700); border-color: var(--violet-300); }
.topic-time svg { width: 12px; height: 12px; }
@media (max-width: 600px) {
  .topic-time { font-size: 10px; padding: 3px 8px; }
  .topic-time svg { width: 11px; height: 11px; }
}
.topic-body {
  padding: 24px 28px 32px;
}
@media (max-width: 600px) {
  .topic-head { padding: 14px 16px; gap: 10px; font-size: 16px; }
  .topic-body { padding: 18px 16px 24px; }
  .topic-chev { width: 26px; height: 26px; }
  .topic-meta { font-size: 10px; padding: 3px 8px; }
}
/* Override h2 styles inside topic-name */
.topic-name * {
  font: inherit !important;
  color: inherit !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  letter-spacing: inherit !important;
}

/* When printed, expand every topic */
@media print {
  .topic { border: 1px solid #ccc; box-shadow: none; }
  .topic .topic-body { display: block !important; padding: 12px 0; }
  .topic .topic-chev { display: none; }
  .topic-head { padding: 4px 0; background: none !important; border: 0; }
}
details > summary { list-style: none; }
details > summary::marker { display: none; }

/* ───────── Practice (TOEFL-style) block ───────── */
.practice-pack {
  margin: 48px 0 8px;
  padding: 0;
  background: linear-gradient(180deg, var(--bg-2) 0%, var(--bg) 100%);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  overflow: hidden;
}
.practice-head {
  padding: 28px 32px 20px;
  border-bottom: 1px solid var(--line);
  position: relative;
  background: var(--violet-50);
}
[data-theme="dark"] .practice-head { background: var(--violet-100); }
.practice-head .kicker {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--font-mono);
  font-size: 11px; font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--violet-700);
  margin-bottom: 12px;
}
.practice-head .kicker .badge {
  background: var(--violet-800); color: white;
  padding: 3px 10px;
  border-radius: var(--r-full);
  font-size: 11px;
  letter-spacing: 0.6px;
}
.practice-head h2 {
  all: unset;
  font-family: var(--font-display);
  font-size: 28px; font-weight: 800;
  color: var(--ink);
  letter-spacing: -0.02em;
  line-height: 1.15;
  display: block;
}
.practice-head .lead {
  margin-top: 8px;
  font-size: 14px;
  color: var(--ink-3);
  max-width: 60ch;
  line-height: 1.55;
}

.task {
  padding: 28px 32px;
  border-top: 1px solid var(--line);
}
.task:first-of-type { border-top: 0; }
.task-head {
  display: flex; align-items: flex-start; gap: 14px;
  margin-bottom: 16px;
}
.task-icon {
  width: 38px; height: 38px;
  background: var(--violet-800); color: white;
  border-radius: var(--r-full);
  display: grid; place-items: center;
  flex-shrink: 0;
}
.task-icon svg { width: 18px; height: 18px; }
.task-meta {
  flex: 1;
}
.task-meta .lbl {
  font-family: var(--font-mono);
  font-size: 11px; font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 4px;
}
.task-meta h3 {
  all: unset;
  display: block;
  font-family: var(--font-display);
  font-size: 20px; font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.task-prompt {
  padding: 16px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  margin-bottom: 18px;
  font-size: 16px;
  color: var(--ink-2);
  line-height: 1.55;
  display: flex; gap: 14px; align-items: flex-start;
}
.task-prompt strong { color: var(--ink); font-weight: 700; }
.task-prompt .prompt-text {
  flex: 1; display: block;
}
.btn-tts {
  flex-shrink: 0;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  border: 1.5px solid var(--violet-300);
  background: var(--violet-50);
  border-radius: var(--r-full);
  color: var(--violet-700);
  font-size: 13px; font-weight: 700;
  cursor: pointer; transition: .15s;
}
.btn-tts:hover {
  background: var(--violet-800); color: white; border-color: var(--violet-800);
}
.btn-tts svg { width: 16px; height: 16px; }
.btn-tts.playing {
  background: var(--err); color: white; border-color: var(--err);
  animation: tts-pulse 1.2s ease-in-out infinite;
}
@keyframes tts-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220,53,69,.45); }
  50%      { box-shadow: 0 0 0 6px rgba(220,53,69,0); }
}
[data-theme="dark"] .btn-tts { background: var(--violet-100); color: var(--violet-700); border-color: var(--violet-300); }

/* Mini practice-pack (per-section) — slightly tighter than the full one */
.practice-mini {
  margin: 36px 0 0;
  border-radius: var(--r-lg);
}
.practice-mini .practice-head {
  padding: 22px 26px 16px;
}
.practice-mini .practice-head h2 {
  font-size: 22px;
}
.practice-mini .task {
  padding: 22px 26px;
}

/* Speaking task */
.speaking-controls {
  display: flex; align-items: center; gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.rec-btn {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 12px 22px;
  border-radius: var(--r-full);
  font-size: 15px; font-weight: 700;
  font-family: inherit;
  border: 2px solid var(--violet-800);
  background: var(--violet-800); color: white;
  cursor: pointer;
  transition: .2s;
}
.rec-btn:hover { background: var(--violet-900); border-color: var(--violet-900); }
.rec-btn .dot {
  width: 10px; height: 10px;
  background: #ff4444;
  border-radius: var(--r-full);
  display: inline-block;
  box-shadow: 0 0 0 0 #ff4444;
}
.rec-btn.recording { background: var(--err); border-color: var(--err); }
.rec-btn.recording .dot { animation: pulse 1s infinite; }
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(255,68,68,.7); }
  70%  { box-shadow: 0 0 0 10px rgba(255,68,68,0); }
  100% { box-shadow: 0 0 0 0 rgba(255,68,68,0); }
}
.rec-timer {
  font-family: var(--font-mono);
  font-size: 18px; font-weight: 700;
  color: var(--ink);
  min-width: 64px;
}
.rec-status {
  font-size: 13px; color: var(--ink-3);
  font-style: italic;
}
.rec-audio {
  display: none;
  margin: 12px 0;
  width: 100%;
}
.rec-audio.show { display: block; }
.rec-transcript {
  display: none;
  margin-top: 12px;
  padding: 16px 20px;
  background: var(--violet-50);
  border: 1px solid var(--violet-200);
  border-radius: var(--r-md);
  font-size: 15px;
  color: var(--ink);
  line-height: 1.55;
  min-height: 60px;
  white-space: pre-wrap;
}
.rec-transcript.show { display: block; }
.rec-transcript:empty::before {
  content: "Transcript will appear here…";
  color: var(--ink-3);
  font-style: italic;
}
.rec-transcript-label {
  display: none;
  font-family: var(--font-mono);
  font-size: 10px; font-weight: 700;
  letter-spacing: 1.3px;
  text-transform: uppercase;
  color: var(--violet-700);
  margin: 18px 0 6px;
}
.rec-transcript.show + .rec-transcript-label,
.rec-transcript-label.show { display: block; }

/* Writing task */
.writing-input {
  position: relative;
  margin-bottom: 12px;
}
.writing-textarea {
  width: 100%;
  min-height: 120px;
  padding: 16px 20px;
  border: 1.5px solid var(--line-2);
  border-radius: var(--r-md);
  background: var(--surface);
  font: inherit;
  font-size: 15px;
  color: var(--ink);
  font-weight: 500;
  line-height: 1.6;
  outline: none;
  resize: vertical;
  font-family: var(--font-body);
}
.writing-textarea:focus {
  border-color: var(--violet-500);
  box-shadow: 0 0 0 3px var(--violet-100);
}
.writing-meta {
  display: flex; align-items: center; gap: 14px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.word-count {
  font-family: var(--font-mono);
  font-size: 13px; font-weight: 700;
  color: var(--ink-3);
}
.word-count.target { color: var(--ok); }
.word-count.short  { color: var(--warn); }
.word-count.long   { color: var(--err); }
.word-count strong { font-weight: 800; }

/* Score card */
.task-score {
  display: none;
  margin-top: 20px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  overflow: hidden;
}
.task-score.show { display: block; }
.task-score-top {
  padding: 18px 22px;
  background: linear-gradient(135deg, var(--violet-700), var(--violet-800));
  color: white;
  display: flex; align-items: center; gap: 18px;
  flex-wrap: wrap;
}
.task-score-top .num {
  font-family: var(--font-display);
  font-size: 44px; font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
}
.task-score-top .denom {
  font-family: var(--font-display);
  font-size: 20px; font-weight: 600;
  opacity: .7;
  align-self: flex-end;
  margin-bottom: 6px;
}
.task-score-top .label {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 12px; font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  opacity: .85;
}
.task-score-top .band {
  font-family: var(--font-display);
  font-size: 14px; font-weight: 700;
  padding: 6px 14px;
  border-radius: var(--r-full);
  background: rgba(255,255,255,.18);
}
.task-score-rubric {
  padding: 18px 22px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 18px;
}
.rubric-item .label {
  font-family: var(--font-mono);
  font-size: 11px; font-weight: 700;
  letter-spacing: 1.2px;
  color: var(--ink-3);
  text-transform: uppercase;
  margin-bottom: 6px;
}
.rubric-item .bar {
  height: 6px;
  background: var(--violet-100);
  border-radius: var(--r-full);
  overflow: hidden;
  margin: 6px 0;
}
.rubric-item .bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--violet-500), var(--violet-800));
  border-radius: var(--r-full);
  transition: width .6s ease;
}
.rubric-item .note {
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 4px;
}
.task-score-feedback {
  padding: 18px 22px;
  border-top: 1px solid var(--line);
  background: var(--violet-50);
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink-2);
}
[data-theme="dark"] .task-score-feedback { background: var(--violet-100); }
.task-score-feedback ul {
  margin: 8px 0 0 18px;
  padding: 0;
}
.task-score-feedback li {
  margin-bottom: 4px;
}

/* ───────── Footer / nav ───────── */
.unit-nav {
  margin-top: 64px;
  padding-top: 32px;
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.unit-nav a {
  padding: 18px 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  transition: .15s;
  display: block;
}
.unit-nav a:hover {
  border-color: var(--violet-400);
  box-shadow: var(--shadow-sm);
  transform: translateY(-2px);
  text-decoration: none;
}
.unit-nav .dir {
  font-family: var(--font-mono);
  font-size: 11px; font-weight: 700;
  color: var(--ink-3);
  letter-spacing: 1.2px;
  text-transform: uppercase;
  margin-bottom: 6px;
  display: flex; align-items: center; gap: 6px;
}
.unit-nav .title {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--ink);
  font-size: 16px;
}
.unit-nav .next { text-align: right; }
.unit-nav .next .dir { justify-content: flex-end; }
@media (max-width: 600px) {
  .unit-nav { grid-template-columns: 1fr; }
}

/* ───────── Index / Home ───────── */
.home-hero {
  padding: 60px 0 50px;
  text-align: center;
  position: relative;
}
.home-hero .kicker {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 6px 16px 6px 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  font-size: 12px; font-weight: 600;
  color: var(--ink-2);
  box-shadow: var(--shadow-xs);
  margin-bottom: 24px;
}
.home-hero .kicker .badge {
  background: var(--violet-800);
  color: white;
  padding: 3px 12px;
  border-radius: var(--r-full);
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.5px;
}
.home-hero h1 {
  font-family: var(--font-display);
  font-size: clamp(48px, 7vw, 88px);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
  margin-bottom: 24px;
}
.home-hero h1 em {
  color: var(--violet-800);
  font-style: normal;
  position: relative;
}
.home-hero h1 em::after {
  content: "";
  position: absolute; left: 0; right: 0; bottom: 8%;
  height: 18%;
  background: var(--violet-200);
  z-index: -1;
  border-radius: 6px;
  transform: rotate(-1deg);
}
.home-hero p {
  font-size: 18px;
  color: var(--ink-2);
  max-width: 60ch;
  margin: 0 auto 16px;
}

.book-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 24px;
  margin-top: 60px;
  max-width: 1100px; margin-left: auto; margin-right: auto;
}
.book-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  padding: 32px 30px;
  transition: .25s;
  position: relative;
  overflow: hidden;
  display: flex; flex-direction: column;
}
.book-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--violet-400);
  text-decoration: none;
}
.book-card::before {
  content: "";
  position: absolute; top: -50px; right: -50px;
  width: 200px; height: 200px;
  background: radial-gradient(circle, var(--violet-200), transparent 60%);
  border-radius: 50%;
  opacity: .5;
  pointer-events: none;
}
.book-card .level {
  display: inline-block;
  background: var(--violet-100);
  color: var(--violet-700);
  font-family: var(--font-mono);
  font-size: 11px; font-weight: 700;
  letter-spacing: 1px;
  padding: 4px 10px;
  border-radius: var(--r-sm);
  margin-bottom: 14px;
  text-transform: uppercase;
}
.book-card.higher .level {
  background: var(--violet-800); color: white;
}
.book-card.advanced .level {
  background: linear-gradient(135deg, var(--violet-900), var(--violet-700)); color: white;
}
.book-card h2 {
  font-family: var(--font-display);
  font-size: 30px; font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin: 0 0 10px;
  color: var(--ink);
}
.book-card .desc {
  font-size: 15px;
  color: var(--ink-3);
  margin-bottom: 22px;
  flex: 1;
}
.book-card .stats {
  display: flex; gap: 18px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.book-card .stat {
  flex: 1; min-width: 80px;
}
.book-card .stat .v {
  font-family: var(--font-display);
  font-size: 22px; font-weight: 700;
  color: var(--violet-800);
  display: block;
}
[data-theme="dark"] .book-card .stat .v { color: var(--violet-400); }
.book-card .stat .l {
  font-size: 11px; color: var(--ink-3);
  font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.5px;
}
.book-card .cta {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 20px;
  background: var(--violet-800); color: white;
  border-radius: var(--r-full);
  font-size: 14px; font-weight: 700;
  align-self: flex-start;
  transition: .2s;
}
.book-card:hover .cta {
  background: var(--violet-900);
  gap: 12px;
}

/* Book-index page: unit grid */
.units-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
  margin-top: 40px;
}
.unit-tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 22px 22px 20px;
  transition: .2s;
  position: relative;
  display: block;
}
.unit-tile:hover {
  transform: translateY(-2px);
  border-color: var(--violet-400);
  box-shadow: var(--shadow-md);
  text-decoration: none;
}
.unit-tile .head {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 12px;
}
.unit-tile .n {
  font-family: var(--font-mono);
  font-size: 11px; font-weight: 700;
  background: var(--violet-100); color: var(--violet-700);
  padding: 4px 9px;
  border-radius: var(--r-sm);
  letter-spacing: 0.5px;
}
.unit-tile .pages {
  margin-left: auto;
  font-size: 12px; color: var(--ink-3); font-weight: 600;
}
.unit-tile h3 {
  font-family: var(--font-display);
  font-size: 19px; font-weight: 700;
  line-height: 1.2;
  color: var(--ink);
  margin: 0;
}
.unit-tile .check {
  position: absolute; top: 18px; right: 18px;
  width: 22px; height: 22px;
  border-radius: var(--r-full);
  background: var(--ok);
  color: white;
  display: none;
  place-items: center;
  font-size: 12px; font-weight: 800;
}
.unit-tile.done .check { display: grid; }

/* ───────── Search ───────── */
.search-overlay {
  position: fixed; inset: 0;
  background: rgba(26,8,64,.4);
  backdrop-filter: blur(6px);
  display: none;
  z-index: 200;
  padding-top: 8vh;
}
.search-overlay.open { display: block; }
.search-box {
  max-width: 560px; margin: 0 auto;
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.search-input-wrap {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.search-input-wrap svg {
  width: 20px; height: 20px; color: var(--ink-3); flex-shrink: 0;
}
.search-input-wrap input {
  flex: 1;
  background: none; border: none; outline: none;
  font-size: 16px; font-family: var(--font-body); font-weight: 500;
  color: var(--ink);
}
.search-results {
  max-height: 60vh; overflow-y: auto;
}
.search-result {
  display: block;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  transition: .15s;
}
.search-result:hover { background: var(--violet-50); text-decoration: none; }
.search-result .crumb {
  font-size: 11px; font-weight: 700;
  color: var(--violet-700); letter-spacing: 0.5px;
  margin-bottom: 4px; text-transform: uppercase;
}
.search-result .snippet {
  font-size: 14px; color: var(--ink-2); line-height: 1.45;
}
.search-result mark {
  background: var(--violet-200); color: var(--violet-900);
  padding: 0 2px; border-radius: 3px;
  font-weight: 700;
}
.search-empty {
  padding: 32px 24px; text-align: center;
  color: var(--ink-3); font-size: 14px;
}
.kbd {
  display: inline-block;
  font-family: var(--font-mono); font-size: 11px; font-weight: 600;
  padding: 2px 6px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-xs);
  color: var(--ink-3);
}

/* mini reading progress on top of header */
.reading-progress {
  position: absolute;
  bottom: -1px; left: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--violet-500), var(--violet-800));
  width: 0%;
  transition: width .1s linear;
  z-index: 2;
}

/* ───────── Mobile menu toggle ───────── */
.menu-toggle { display: none; }
@media (max-width: 960px) {
  .menu-toggle { display: grid; }
}

/* ───────── Print ───────── */
@media print {
  .site-header, .sidebar, .header-actions, .unit-nav,
  .exercise-mark, .menu-toggle, .reading-progress { display: none !important; }
  .layout { grid-template-columns: 1fr; }
  .main { padding: 0; max-width: 100%; }
  .content-wrap { max-width: 100%; }
  body { background: white; color: black; }
  .unit-hero {
    background: white; border: 2px solid var(--violet-800);
    padding: 24px;
  }
  .exercise { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
  h1, h2, h3 { break-after: avoid; }
  img { break-inside: avoid; }
  a { color: black; text-decoration: none; }
}

/* ───────── Expandable sidebar with sections ───────── */
.unit-list-expandable {
  gap: 4px;
}
.unit-list-expandable .unit-item {
  display: block;
}
.unit-list-expandable .unit-toggle {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
  transition: .15s;
}
.unit-list-expandable .unit-toggle[open] {
  background: var(--surface);
  border-color: var(--violet-200);
  box-shadow: var(--shadow-xs);
}
.unit-list-expandable .unit-item.current .unit-toggle {
  background: var(--violet-50);
  border-color: var(--violet-400);
}
.unit-header {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
  list-style: none;
  user-select: none;
  font-weight: 600; font-size: 14px;
  color: var(--ink-2);
}
.unit-header::-webkit-details-marker { display: none; }
.unit-header:hover { color: var(--violet-700); }
.unit-toggle[open] .unit-header { color: var(--violet-800); }
.unit-header .num {
  font-family: var(--font-mono);
  font-size: 11px; font-weight: 700;
  background: var(--violet-100); color: var(--violet-700);
  padding: 3px 8px; border-radius: var(--r-sm);
  min-width: 28px; text-align: center;
  flex-shrink: 0;
}
.unit-item.current .unit-header .num {
  background: var(--violet-800); color: white;
}
.unit-header .title {
  flex: 1; word-break: break-word;
}
.unit-header .title a {
  color: inherit;
  text-decoration: none;
}
.unit-header .title a:hover {
  text-decoration: underline;
}
.unit-header .chevron {
  color: var(--ink-3);
  font-size: 12px;
  transition: transform .2s;
  flex-shrink: 0;
}
.unit-toggle[open] .chevron { transform: rotate(180deg); color: var(--violet-700); }

.section-list {
  list-style: none;
  margin: 0; padding: 4px 8px 10px 8px;
  display: flex; flex-direction: column; gap: 1px;
  border-top: 1px solid var(--line);
}
.section-item a {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px 7px 28px;
  border-radius: var(--r-sm);
  font-size: 13px; font-weight: 500;
  color: var(--ink-3);
  text-decoration: none;
  line-height: 1.3;
}
.section-item a:hover {
  background: var(--violet-50);
  color: var(--violet-700);
}
.section-check {
  width: 14px; height: 14px;
  border: 1.5px solid var(--line);
  border-radius: 50%;
  flex-shrink: 0;
  position: relative;
  background: var(--surface);
}
.section-item.done .section-check {
  background: var(--ok);
  border-color: var(--ok);
}
.section-item.done .section-check::after {
  content: "";
  position: absolute;
  left: 3px; top: 1px;
  width: 4px; height: 8px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.section-name {
  flex: 1;
  word-break: break-word;
  text-transform: capitalize;
}
.section-item.done .section-name {
  color: var(--ink-2);
  font-weight: 600;
}
.section-date {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-3);
  white-space: nowrap;
  font-weight: 600;
  letter-spacing: .3px;
}

/* ───────── Fill-blank visual marker for fill-in-the-blank exercises ───────── */
.fill-blank {
  display: inline-block;
  min-width: 80px;
  padding: 0 6px;
  margin: 0 3px;
  border-bottom: 2px solid var(--violet-400);
  color: transparent;
  user-select: none;
  font-family: var(--font-mono);
  font-weight: 700;
  vertical-align: 1px;
}
.fill-blank::before {
  content: "________";
  color: var(--violet-300);
  letter-spacing: -1px;
}

/* ───────── End-of-unit alphabetical vocabulary grid ───────── */
.vocab-grid {
  list-style: none;
  margin: 12px 0 18px;
  padding: 18px;
  background: var(--violet-50);
  border: 1px solid var(--violet-200);
  border-radius: var(--r-md, 10px);
  columns: 4;
  column-gap: 24px;
}
[data-theme="dark"] .vocab-grid { background: var(--bg-2); }
.vocab-grid li {
  padding: 3px 0;
  break-inside: avoid;
  line-height: 1.55;
  color: var(--ink-1);
}
@media (max-width: 900px) { .vocab-grid { columns: 3; } }
@media (max-width: 640px) { .vocab-grid { columns: 2; } }

/* ───────── Categorize grid (3-column sorting tasks) ───────── */
.cat-box {
  margin-top: 16px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--violet-200);
  border-radius: var(--r-md, 10px);
}
.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  margin-top: 12px;
}
.cat-col {
  background: var(--violet-50);
  border: 1px solid var(--violet-200);
  border-radius: var(--r-md, 10px);
  padding: 12px;
}
[data-theme="dark"] .cat-col { background: var(--bg-2); }
.cat-head {
  text-align: center;
  font-weight: 700;
  color: var(--violet-800);
  background: var(--violet-100);
  border-radius: var(--r-sm, 6px);
  padding: 8px;
  margin-bottom: 10px;
}
[data-theme="dark"] .cat-head { background: var(--violet-200); color: var(--violet-900); }
.cat-cells { display: flex; flex-direction: column; gap: 6px; }
.cat-cell { display: flex; align-items: center; gap: 6px; }
.cat-cell .cat-input {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid var(--violet-300);
  border-bottom: 2px solid var(--violet-500);
  border-radius: var(--r-sm, 6px);
  background: var(--surface);
  color: var(--ink-1);
  font: inherit;
  outline: none;
}
[data-theme="dark"] .cat-cell .cat-input { background: var(--bg-1); }
.cat-cell .cat-input:focus { border-color: var(--violet-600); box-shadow: 0 0 0 3px rgba(124,58,237,.18); }
.cat-cell.correct .cat-input { border-color: var(--ok); background: rgba(16,185,129,.08); }
.cat-cell.incorrect .cat-input { border-color: var(--err); background: rgba(239,68,68,.08); }
.cat-cell .ans-status { width: 18px; text-align: center; font-weight: 700; }
.cat-cell.correct .ans-status::before { content: "✓"; color: var(--ok); }
.cat-cell.incorrect .ans-status::before { content: "✕"; color: var(--err); }
.cat-reveal {
  display: none;
  list-style: none;
  margin: 10px 0 0;
  padding: 8px;
  background: var(--violet-100);
  border-radius: var(--r-sm, 6px);
}
[data-theme="dark"] .cat-reveal { background: var(--violet-200); color: var(--violet-700); }
.cat-reveal li { padding: 2px 0; font-weight: 600; }
.exercise.revealed-all .cat-reveal { display: block; }

/* ───────── Inline fill input (typed directly inside the sentence) ───────── */
.ans-row.inline-fill,
.inline-fill {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  margin: 0 4px;
  padding: 0;
  background: transparent;
  border: 0;
  vertical-align: baseline;
}
.ans-row.inline-fill .ans-text,
.inline-fill .ans-text {
  display: inline-block;
  width: auto;
  min-width: 140px;
  max-width: 260px;
  padding: 4px 10px;
  border: 1px solid var(--violet-300);
  border-bottom: 2px solid var(--violet-500);
  border-radius: var(--r-sm, 6px);
  background: var(--surface);
  color: var(--ink-1);
  font: inherit;
  line-height: 1.3;
  outline: none;
}
.ans-row.inline-fill .ans-text:focus,
.inline-fill .ans-text:focus {
  border-color: var(--violet-600);
  box-shadow: 0 0 0 3px rgba(124,58,237,.18);
}
.ans-row.inline-fill .ans-status {
  display: inline-block;
  width: 18px;
  text-align: center;
  font-weight: 700;
}
.ans-row.inline-fill.correct .ans-status::before {
  content: "✓"; color: var(--ok); background: none; width: auto; height: auto; border-radius: 0;
}
.ans-row.inline-fill.incorrect .ans-status::before {
  content: "✕"; color: var(--err); background: none; width: auto; height: auto; border-radius: 0;
}
.ans-row.inline-fill .ans-correct {
  display: none;
  margin: 0;
  padding: 1px 8px;
  background: var(--violet-100);
  color: var(--violet-700);
  border-radius: var(--r-sm, 6px);
  font-size: 0.95em;
  font-weight: 600;
}
.ans-row.inline-fill.show-correct .ans-correct,
.ans-row.inline-fill.revealed .ans-correct {
  display: inline-block;
}
.ans-row.inline-fill.correct .ans-text {
  border-color: var(--ok);
  background: rgba(16,185,129,.08);
}
.ans-row.inline-fill.incorrect .ans-text {
  border-color: var(--err);
  background: rgba(239,68,68,.08);
}
[data-theme="dark"] .ans-row.inline-fill .ans-text { background: var(--bg-2); }
[data-theme="dark"] .ans-row.inline-fill .ans-correct { background: var(--violet-200); color: var(--violet-700); }

/* ───────── Unit Videos bar (top of unit page) ───────── */
.unit-videos {
  margin: 24px 0 32px;
  padding: 24px;
  background: linear-gradient(135deg, var(--violet-50), var(--surface));
  border: 1px solid var(--violet-200);
  border-radius: var(--r-lg);
}
.uv-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.uv-title {
  font-family: var(--font-display);
  font-size: 18px; font-weight: 700;
  color: var(--violet-800);
  display: flex; align-items: center; gap: 10px;
}
.uv-title .icon {
  width: 24px; height: 24px;
  background: var(--violet-800); color: white;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px;
}
.uv-progress {
  font-family: var(--font-mono);
  font-size: 11px; font-weight: 700;
  color: var(--ink-3);
  letter-spacing: 1px;
}
.uv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}
.uv-card {
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
  cursor: pointer;
  transition: .2s;
  text-align: left;
  padding: 0;
  font: inherit;
  color: inherit;
}
.uv-card:hover {
  border-color: var(--violet-400);
  box-shadow: 0 8px 24px rgba(112, 48, 224, 0.18);
  transform: translateY(-2px);
}
.uv-card:disabled {
  opacity: .5;
  cursor: default;
}
.uv-card:disabled:hover {
  border-color: var(--line);
  box-shadow: none;
  transform: none;
}
.uv-thumb {
  position: relative;
  aspect-ratio: 16/9;
  background: var(--bg-2);
  overflow: hidden;
}
.uv-thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.uv-thumb .placeholder {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--violet-100), var(--violet-50));
  color: var(--violet-700);
  font-family: var(--font-display);
  font-size: 14px; font-weight: 700;
  text-align: center;
  padding: 12px;
}
.uv-ep {
  position: absolute;
  top: 8px; left: 8px;
  background: rgba(12, 17, 66, 0.85);
  color: white;
  font-family: var(--font-mono);
  font-size: 10px; font-weight: 700;
  padding: 4px 8px;
  border-radius: var(--r-sm);
  letter-spacing: 1px;
  backdrop-filter: blur(4px);
}
.uv-play {
  position: absolute;
  inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.0);
  transition: .2s;
}
.uv-play::before {
  content: "";
  width: 48px; height: 48px;
  background: rgba(255,255,255,.92);
  border-radius: 50%;
  box-shadow: 0 4px 12px rgba(0,0,0,.3);
  display: block;
}
.uv-play::after {
  content: "";
  position: absolute;
  border-style: solid;
  border-width: 9px 0 9px 14px;
  border-color: transparent transparent transparent var(--violet-800);
  margin-left: 4px;
}
.uv-card:hover .uv-play {
  background: rgba(0,0,0,.2);
}
.uv-watched-badge {
  position: absolute;
  top: 8px; right: 8px;
  width: 24px; height: 24px;
  background: var(--ok);
  color: white;
  border-radius: 50%;
  display: none;
  align-items: center; justify-content: center;
  font-size: 14px; font-weight: 800;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.uv-card.watched .uv-watched-badge {
  display: flex;
}
.uv-card.watched .uv-thumb img {
  opacity: .8;
}
.uv-name {
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  line-height: 1.35;
  border-top: 1px solid var(--line);
}
.uv-section {
  font-size: 11px;
  color: var(--ink-3);
  font-weight: 500;
  margin-top: 4px;
}

/* ───────── Lightbox modal ───────── */
.uv-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center; justify-content: center;
  padding: 20px;
}
.uv-lightbox.open { display: flex; }
.uv-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.85);
  backdrop-filter: blur(4px);
}
.uv-dialog {
  position: relative;
  width: 100%;
  max-width: 900px;
  background: var(--surface);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0,0,0,.5);
  animation: uv-pop .2s ease-out;
}
@keyframes uv-pop {
  from { opacity: 0; transform: scale(.95); }
  to { opacity: 1; transform: scale(1); }
}
.uv-close {
  position: absolute;
  top: 12px; right: 12px;
  width: 40px; height: 40px;
  background: rgba(0,0,0,.65);
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 22px;
  cursor: pointer;
  z-index: 2;
  display: flex; align-items: center; justify-content: center;
}
.uv-close:hover { background: rgba(0,0,0,.85); }
.uv-iframe-wrap {
  position: relative;
  aspect-ratio: 16/9;
  background: black;
}
.uv-iframe-wrap iframe {
  width: 100%; height: 100%;
  border: 0;
}
.uv-meta {
  padding: 16px 20px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
}
.uv-meta-title {
  font-family: var(--font-display);
  font-size: 18px; font-weight: 700;
  margin: 0;
  color: var(--ink);
}
.uv-meta-sub {
  font-size: 13px;
  color: var(--ink-3);
  margin-top: 2px;
}
.uv-mark-watched {
  background: var(--ok);
  color: white;
  border: none;
  border-radius: var(--r-md);
  padding: 10px 18px;
  font-weight: 700;
  cursor: pointer;
  display: flex; align-items: center; gap: 8px;
  font-size: 13px;
  white-space: nowrap;
}
.uv-mark-watched:hover { filter: brightness(1.05); }
.uv-mark-watched.is-watched {
  background: var(--bg-2);
  color: var(--ink-3);
  border: 1px solid var(--line);
}

@media (max-width: 640px) {
  .uv-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .uv-name { font-size: 12px; padding: 10px 12px; }
  .uv-meta { flex-direction: column; align-items: stretch; }
}

/* ───────── Unit hero with side video panel (overrides default hero) ───────── */
.unit-hero-with-videos {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 32px;
  align-items: start;
}
.unit-hero-with-videos .unit-hero-text {
  /* let the existing .unit-hero styles for h1/kicker/meta apply */
}
.unit-hero-videos {
  align-self: stretch;
}
.unit-hero-videos.has-videos,
.unit-hero-videos.is-empty {
  background: rgba(255,255,255,.7);
  border: 1px solid var(--violet-200);
  border-radius: var(--r-md);
  padding: 12px;
  display: flex; flex-direction: column; gap: 10px;
  backdrop-filter: blur(8px);
}
.unit-hero-videos .uv-head-mini {
  display: flex; align-items: center; justify-content: space-between;
  font-family: var(--font-mono); font-size: 10px; font-weight: 700;
  color: var(--violet-700);
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 0 4px;
}
.unit-hero-videos .uv-head-mini .progress {
  color: var(--ink-3);
}
.unit-hero-videos .uv-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
/* Reuse uv-card styles but smaller for the hero panel */
.unit-hero-videos .uv-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: .15s;
  padding: 0;
  font: inherit;
  color: inherit;
  text-align: left;
  display: flex; flex-direction: column;
}
.unit-hero-videos .uv-card:hover {
  border-color: var(--violet-400);
  box-shadow: 0 4px 12px rgba(112, 48, 224, 0.18);
  transform: translateY(-1px);
}
.unit-hero-videos .uv-thumb {
  position: relative;
  aspect-ratio: 16/9;
  background: var(--bg-2);
  overflow: hidden;
}
.unit-hero-videos .uv-thumb img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.unit-hero-videos .uv-name {
  padding: 6px 8px 8px;
  font-size: 11px; font-weight: 600;
  color: var(--ink-2);
  line-height: 1.25;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  border-top: 1px solid var(--line);
}
.unit-hero-videos .uv-play {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0);
  transition: .15s;
}
.unit-hero-videos .uv-play::before {
  content: "";
  width: 32px; height: 32px;
  background: rgba(255,255,255,.92);
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0,0,0,.3);
}
.unit-hero-videos .uv-play::after {
  content: "";
  position: absolute;
  border: solid transparent;
  border-width: 6px 0 6px 10px;
  border-left-color: var(--violet-800);
  margin-left: 3px;
}
.unit-hero-videos .uv-card:hover .uv-play {
  background: rgba(0,0,0,.25);
}
.unit-hero-videos .uv-watched-badge {
  position: absolute;
  top: 4px; right: 4px;
  width: 18px; height: 18px;
  background: var(--ok);
  color: white;
  border-radius: 50%;
  display: none;
  align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800;
}
.unit-hero-videos .uv-card.watched .uv-watched-badge { display: flex; }
.unit-hero-videos .uv-card.watched .uv-thumb img { opacity: .75; }

/* Add Video button */
.uv-add {
  background: var(--violet-50);
  border: 1.5px dashed var(--violet-400);
  border-radius: 8px;
  aspect-ratio: 16/9;
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px;
  color: var(--violet-700);
  font-family: var(--font-mono);
  font-size: 10px; font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  transition: .15s;
}
.uv-add:hover {
  background: var(--violet-100);
  border-color: var(--violet-600);
  color: var(--violet-800);
}
.uv-add .plus {
  font-size: 22px;
  font-weight: 400;
  font-family: var(--font-body);
  line-height: 1;
}

.unit-hero-videos.is-empty .uv-cards {
  grid-template-columns: 1fr;
}

/* Tiny export hint */
.uv-export-hint {
  font-family: var(--font-mono); font-size: 10px;
  color: var(--ink-3);
  text-align: center;
  padding: 4px;
  cursor: pointer;
}
.uv-export-hint:hover { color: var(--violet-700); }

/* ───────── Add Video modal ───────── */
.uv-add-modal {
  position: fixed; inset: 0; z-index: 1001;
  display: none;
  align-items: center; justify-content: center;
  padding: 20px;
}
.uv-add-modal.open { display: flex; }
.uv-add-modal .backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(4px);
}
.uv-add-modal .dialog {
  position: relative;
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 24px;
  width: 100%; max-width: 480px;
  box-shadow: 0 24px 64px rgba(0,0,0,.4);
  animation: uv-pop .2s ease-out;
}
.uv-add-modal h3 {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-size: 20px;
  color: var(--ink);
}
.uv-add-modal p {
  font-size: 13px; color: var(--ink-3);
  margin: 0 0 16px;
}
.uv-add-modal input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  font-family: var(--font-body);
  font-size: 14px;
  margin-bottom: 12px;
  background: var(--surface);
  color: var(--ink);
}
.uv-add-modal input:focus {
  outline: none;
  border-color: var(--violet-600);
  box-shadow: 0 0 0 3px rgba(112,48,224,.18);
}
.uv-add-modal .actions {
  display: flex; gap: 8px; justify-content: flex-end;
}
.uv-add-modal button {
  padding: 10px 18px;
  border-radius: var(--r-md);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  border: 1px solid transparent;
}
.uv-add-modal .btn-primary {
  background: var(--violet-800); color: white;
  border-color: var(--violet-800);
}
.uv-add-modal .btn-primary:hover { background: var(--violet-700); }
.uv-add-modal .btn-ghost {
  background: transparent; color: var(--ink-2);
  border-color: var(--line);
}
.uv-add-modal .btn-ghost:hover {
  background: var(--bg-2);
}
.uv-add-modal .err {
  color: var(--err);
  font-size: 12px;
  margin: -8px 0 12px;
  min-height: 16px;
}

@media (max-width: 900px) {
  .unit-hero-with-videos {
    grid-template-columns: 1fr;
  }
  .unit-hero-videos .uv-cards { grid-template-columns: 1fr 1fr 1fr; }
}
@media (max-width: 540px) {
  .unit-hero-videos .uv-cards { grid-template-columns: 1fr 1fr; }
}
