/* ==========================================================================
   XubinGo Academy — design system "Dot Matrix / 疏点"
   Translated from pixel forensics of the reference art:
     paper  #f5f4ee (58-65% of frame)   · ink #26241d (pure black dots)
     halftone: ONE ink, density does the shading — never gray fills
     accent clay #cc7c5e · gold #e6b465 · deep clay #a85c44
     mono type everywhere, hard corners, dotted rules
   ========================================================================== */

:root {
  --paper: #f5f4ee;
  --paper-dim: #eceade;
  --ink: #26241d;
  --ink-soft: rgba(38, 36, 29, 0.66);
  --ink-faint: rgba(38, 36, 29, 0.44);
  --line: rgba(38, 36, 29, 0.22);
  --line-strong: rgba(38, 36, 29, 0.55);
  --clay: #cc7c5e;
  --clay-deep: #a85c44;
  --gold: #e6b465;

  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --font-cjk: "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", sans-serif;
  --font-body: var(--font-mono), var(--font-cjk);

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 16px;
  --space-4: 24px;
  --space-5: 40px;
  --space-6: 64px;

  --shadow-pop: 6px 6px 0 rgba(38, 36, 29, 0.16);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --header-h: 60px;
}

/* The site is deliberately light-only — the dot-matrix look IS the identity. */

/* ---------- reset & base ---------- */

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

html { scroll-behavior: smooth; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15.5px;
  line-height: 1.7;
  text-wrap: pretty;
  -webkit-font-smoothing: antialiased;
}

img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }

h1, h2, h3, h4 {
  font-family: var(--font-body);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

::selection { background: var(--gold); color: var(--ink); }

:focus-visible {
  outline: 2px solid var(--clay-deep);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

/* ---------- dot-matrix primitives ---------- */

/* Halftone fields: one ink color, density carries the tone. */
.dots-sparse {
  background-image: radial-gradient(circle, var(--ink) 1px, transparent 1.4px);
  background-size: 14px 14px;
}
.dots-mid {
  background-image: radial-gradient(circle, var(--ink) 1px, transparent 1.4px);
  background-size: 9px 9px;
}
.dots-dense {
  background-image: radial-gradient(circle, var(--ink) 1.1px, transparent 1.5px);
  background-size: 6px 6px;
}

/* A rule drawn as a row of dots, like a TUI border. */
.rule-dotted {
  border: 0;
  height: 2px;
  background-image: radial-gradient(circle, var(--ink-faint) 1.1px, transparent 1.5px);
  background-size: 8px 2px;
  background-repeat: repeat-x;
  margin: 0;
}

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

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

.section { padding-block: clamp(56px, 9vw, 104px); }
.section + .section { padding-top: 0; }

.section-head { margin-bottom: clamp(28px, 4vw, 44px); max-width: 640px; }

.kicker {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--clay-deep);
  margin-bottom: var(--space-3);
}
.kicker::before { content: "// "; color: var(--ink-faint); }

.section-head h2 { font-size: clamp(24px, 3.4vw, 34px); margin-bottom: var(--space-2); }
.section-head p { color: var(--ink-soft); max-width: 56ch; }

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

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--paper);
  border-bottom: 2px dotted var(--line);
}

.header-inner {
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 16.5px;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: -0.02em;
}

.brand-mark { width: 20px; height: 20px; flex: none; image-rendering: pixelated; }

.brand-sub {
  font-size: 11px;
  font-weight: 400;
  color: var(--ink-faint);
  align-self: center;
  padding-top: 3px;
  letter-spacing: 0.06em;
}

.site-nav {
  display: flex;
  gap: clamp(14px, 2.5vw, 28px);
  margin-left: auto;
}

.site-nav a {
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 13.5px;
  color: var(--ink-soft);
  padding-block: 6px;
  position: relative;
  transition: color 0.25s var(--ease);
}

.site-nav a::before {
  content: "> ";
  color: transparent;
  transition: color 0.25s var(--ease);
}

.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--ink); }
.site-nav a:hover::before, .site-nav a[aria-current="page"]::before { color: var(--clay-deep); }

.header-tools { display: flex; align-items: center; gap: var(--space-3); margin-left: var(--space-2); }

.lang-switch {
  display: inline-flex;
  border: 1px solid var(--line-strong);
  overflow: hidden;
}

.lang-switch button {
  border: 0;
  background: transparent;
  padding: 5px 12px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 0.25s var(--ease), color 0.25s var(--ease);
}

.lang-switch button.on { background: var(--ink); color: var(--paper); }

.nav-toggle { display: none; }

/* ---------- buttons & chips ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1.5px solid var(--ink);
  padding: 10px 20px;
  font-family: var(--font-mono);
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  transition: transform 0.15s var(--ease), box-shadow 0.15s var(--ease),
              background 0.2s var(--ease), color 0.2s var(--ease);
}

.btn:hover:not(:disabled) {
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 var(--ink);
}
.btn:active:not(:disabled) {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--ink);
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }

.btn-primary { background: var(--ink); color: var(--paper); }
.btn-primary:hover:not(:disabled) { background: var(--clay-deep); border-color: var(--clay-deep); box-shadow: 4px 4px 0 var(--clay); }

.btn-ghost { background: transparent; }
.btn-ghost:hover:not(:disabled) { background: var(--paper-dim); }

.btn-small { padding: 6px 13px; font-size: 12.5px; box-shadow: 2px 2px 0 var(--ink); }
.btn-danger { border-color: var(--clay-deep); color: var(--clay-deep); box-shadow: 3px 3px 0 var(--clay); }
.btn-danger:hover:not(:disabled) { background: var(--clay-deep); color: var(--paper); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line-strong);
  padding: 4px 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-soft);
  background: transparent;
  cursor: pointer;
  transition: all 0.22s var(--ease);
}

.chip:hover { border-color: var(--ink); color: var(--ink); }
.chip.on { background: var(--ink); border-color: var(--ink); color: var(--paper); }

.chip-static {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  padding: 3px 10px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-soft);
}

.chip-static.level-beginner { border-color: var(--clay-deep); color: var(--clay-deep); }
.chip-static.level-intermediate { border-color: var(--gold); color: #8a6528; }
.chip-static.level-advanced { border-color: var(--ink); color: var(--ink); }

.dot {
  width: 7px; height: 7px;
  background: var(--ink-faint);
  flex: none;
}
.chip-static .dot.published { background: var(--clay-deep); }

/* ---------- panels ---------- */

.panel {
  border: 1.5px solid var(--ink);
  background: var(--paper);
  box-shadow: var(--shadow-pop);
}

.panel-pad { padding: clamp(20px, 3vw, 32px); }

.grid { display: grid; gap: var(--space-4); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }

/* ---------- video cards ---------- */

.video-card {
  display: block;
  text-decoration: none;
  border: 1.5px solid var(--line);
  background: var(--paper);
  transition: border-color 0.25s var(--ease), transform 0.25s var(--ease), box-shadow 0.25s var(--ease);
}

.video-card:hover {
  border-color: var(--ink);
  transform: translate(-2px, -2px);
  box-shadow: 4px 4px 0 var(--clay);
}

.thumb-wrap {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--paper-dim);
  border-bottom: 1.5px solid var(--line);
}
.thumb-wrap img { width: 100%; height: 100%; object-fit: cover; image-rendering: auto; }

.play-hint {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  opacity: 0;
  transition: opacity 0.25s var(--ease);
  background: radial-gradient(circle, var(--ink) 1.1px, transparent 1.5px);
  background-size: 6px 6px;
  background-color: rgba(245, 244, 238, 0.82);
}
.video-card:hover .play-hint { opacity: 1; }
.play-hint span {
  width: 52px; height: 52px;
  border: 2px solid var(--ink);
  display: grid;
  place-items: center;
  color: var(--ink);
  background: var(--paper);
  box-shadow: 3px 3px 0 var(--ink);
}
.play-hint svg { width: 16px; height: 16px; margin-left: 2px; fill: currentColor; }

.duration-badge {
  position: absolute;
  right: 8px; bottom: 8px;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 8px;
}

.video-card-body { padding: 13px 15px 15px; }
.video-card-body h3 {
  font-family: var(--font-mono);
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.45;
}
.video-card-meta { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

/* series group on videos page */

.series-group { margin-bottom: var(--space-6); }

.series-head {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  padding-bottom: var(--space-3);
  margin-bottom: var(--space-4);
  border-bottom: 2px dotted var(--line);
}

.series-head .series-index {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--clay-deep);
}

.series-head h2 { font-size: clamp(19px, 2.4vw, 24px); }
.series-head .series-count { color: var(--ink-faint); font-size: 12.5px; white-space: nowrap; }
.series-desc { color: var(--ink-soft); font-size: 13.5px; max-width: 64ch; margin-top: 6px; }

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding-block: var(--space-3);
  margin-bottom: var(--space-5);
  border-block: 2px dotted var(--line);
}

.filter-label { font-family: var(--font-mono); font-size: 12px; color: var(--ink-faint); margin-right: 2px; }

.empty-note {
  padding: clamp(40px, 8vw, 80px) var(--space-4);
  text-align: center;
  color: var(--ink-soft);
  border: 1.5px dashed var(--line-strong);
  font-family: var(--font-mono);
  font-size: 14px;
}

/* ---------- lightbox ---------- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: clamp(12px, 4vw, 48px);
  background: radial-gradient(circle, rgba(38, 36, 29, 0.9) 1.2px, rgba(38, 36, 29, 0.92) 1.4px);
  background-size: 5px 5px;
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s var(--ease);
}
.lightbox.open { opacity: 1; pointer-events: auto; }

.lightbox-inner { width: min(940px, 100%); }

.lightbox-frame {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--ink);
  border: 2px solid var(--paper);
  box-shadow: 8px 8px 0 rgba(204, 124, 94, 0.55);
  overflow: hidden;
}
.lightbox-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.lightbox-caption {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  color: var(--paper);
  margin-top: var(--space-3);
}
.lightbox-caption h3 { font-family: var(--font-mono); font-weight: 500; font-size: 14.5px; }
.lightbox-close {
  border: 1.5px solid var(--paper);
  background: transparent;
  color: var(--paper);
  font-family: var(--font-mono);
  padding: 5px 14px;
  cursor: pointer;
  flex: none;
  transition: all 0.22s var(--ease);
}
.lightbox-close:hover { background: var(--paper); color: var(--ink); }

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

.hero {
  position: relative;
  overflow: hidden;
  border-bottom: 2px dotted var(--line);
  background-image: radial-gradient(circle, var(--ink) 0.8px, transparent 1.1px);
  background-size: 22px 22px;
}

.hero-art {
  position: absolute;
  top: clamp(28px, 7vw, 72px);
  right: clamp(8px, 3vw, 48px);
  width: min(42%, 460px);
  height: auto;
  pointer-events: none;
}

@media (max-width: 900px) {
  .hero-art { display: none; }
}

.hero-inner {
  position: relative;
  max-width: 720px;
  padding-block: clamp(72px, 12vw, 140px);
}

.hero h1 {
  font-size: clamp(30px, 5.2vw, 54px);
  letter-spacing: -0.03em;
  margin-block: var(--space-3) var(--space-4);
}

.hero-sub-zh {
  display: block;
  font-family: var(--font-cjk);
  font-size: 0.5em;
  font-weight: 500;
  color: var(--ink-soft);
  margin-top: 0.5em;
  letter-spacing: 0.08em;
}

.hero-lede {
  font-size: clamp(15px, 1.8vw, 17.5px);
  color: var(--ink-soft);
  max-width: 50ch;
  margin-bottom: var(--space-5);
}

.hero-actions { display: flex; gap: var(--space-3); flex-wrap: wrap; }

.teacher-strip {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding-block: var(--space-4);
  border-bottom: 2px dotted var(--line);
  color: var(--ink-soft);
  font-size: 14px;
}

.avatar-square {
  width: 46px; height: 46px;
  border: 1.5px solid var(--ink);
  box-shadow: 3px 3px 0 var(--clay);
  display: grid;
  place-items: center;
  font-family: var(--font-cjk);
  font-size: 21px;
  font-weight: 700;
  flex: none;
  background: var(--gold);
}

.teacher-strip strong { color: var(--ink); font-weight: 600; }

/* ---------- course cards ---------- */

.course-card {
  border: 1.5px solid var(--line);
  padding: clamp(22px, 3vw, 30px);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  text-decoration: none;
  background: var(--paper);
  transition: border-color 0.25s var(--ease), transform 0.25s var(--ease), box-shadow 0.25s var(--ease);
}
.course-card:hover { border-color: var(--ink); transform: translate(-2px, -2px); box-shadow: 5px 5px 0 var(--gold); }
.course-card h3 { font-size: 19px; }
.course-meta-row { display: flex; gap: 8px; flex-wrap: wrap; }
.course-desc { color: var(--ink-soft); font-size: 13.5px; flex: 1; }
.course-foot {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-3);
  border-top: 2px dotted var(--line);
  padding-top: var(--space-3);
  font-size: 13px;
  color: var(--ink-soft);
}
.course-foot .price { color: var(--ink); font-weight: 600; font-family: var(--font-mono); }

/* ---------- forms ---------- */

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-family: var(--font-mono); font-size: 12.5px; font-weight: 500; letter-spacing: 0.03em; }
.field .hint { font-size: 11.5px; color: var(--ink-faint); }

.input, .select, .textarea {
  border: 1.5px solid var(--line-strong);
  background: var(--paper);
  padding: 10px 13px;
  font-family: var(--font-mono);
  font-size: 14px;
  width: 100%;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 3px 3px 0 var(--gold);
}
.textarea { resize: vertical; min-height: 96px; }
.select { appearance: none; background-image:
  linear-gradient(45deg, transparent 49%, var(--ink) 50%),
  linear-gradient(-45deg, transparent 49%, var(--ink) 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%;
  background-size: 6px 6px; background-repeat: no-repeat; padding-right: 38px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
.form-grid .span-2 { grid-column: span 2; }

.form-error { color: var(--clay-deep); font-size: 13px; font-family: var(--font-mono); }
.form-success {
  border: 1.5px solid var(--ink);
  background: var(--paper);
  box-shadow: 5px 5px 0 var(--clay);
  padding: var(--space-4);
  text-align: center;
}

.hp-field { position: absolute; left: -4000px; opacity: 0; height: 0; overflow: hidden; }

/* ---------- session table (course detail) ---------- */

.session-list { list-style: none; padding: 0; border: 1.5px solid var(--ink); background: var(--paper); }
.session-list li {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 10px 16px;
  font-family: var(--font-mono);
  font-size: 13.5px;
  border-bottom: 1px dotted var(--line);
}
.session-list li:last-child { border-bottom: 0; }
.session-list li.past { color: var(--ink-faint); }
.session-num { color: var(--clay-deep); width: 2.4em; flex: none; }

/* ---------- FAQ ---------- */

.faq-item { border-bottom: 2px dotted var(--line); }
.faq-q {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) 0;
  background: none;
  border: 0;
  text-align: left;
  font-size: 15.5px;
  font-weight: 500;
  cursor: pointer;
}
.faq-q svg { width: 13px; height: 13px; flex: none; transition: transform 0.3s var(--ease); }
.faq-item.open .faq-q svg { transform: rotate(45deg); }
.faq-a { max-height: 0; overflow: hidden; transition: max-height 0.35s var(--ease); }
.faq-a-inner { padding-bottom: var(--space-4); color: var(--ink-soft); max-width: 64ch; }

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

.site-footer {
  border-top: 2px dotted var(--line);
  background-image: radial-gradient(circle, var(--ink) 0.8px, transparent 1.1px);
  background-size: 18px 18px;
  background-position: 0 -10px;
  padding-block: var(--space-5);
  margin-top: var(--space-6);
}
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  align-items: center;
  justify-content: space-between;
  color: var(--ink-faint);
  font-family: var(--font-mono);
  font-size: 12.5px;
  background: var(--paper);
  padding-inline: 4px;
}
.footer-links { display: flex; gap: var(--space-4); }
.footer-links a { color: var(--ink-soft); text-decoration: none; }
.footer-links a:hover { color: var(--clay-deep); }

/* ---------- reveal animation ---------- */

.reveal { opacity: 0; transform: translateY(14px); transition: opacity 0.6s var(--ease), transform 0.6s var(--ease); }
.reveal.in { opacity: 1; transform: none; }
.reveal-d1 { transition-delay: 0.07s; }
.reveal-d2 { transition-delay: 0.14s; }
.reveal-d3 { transition-delay: 0.21s; }

.skeleton {
  background-image: radial-gradient(circle, var(--ink-faint) 1px, transparent 1.4px);
  background-size: 9px 9px;
  animation: skeleton-pulse 1.2s infinite ease-in-out alternate;
}
@keyframes skeleton-pulse { to { opacity: 0.45; } }

/* blinking cursor for the hero "latest move" square */
.cursor-blink { animation: blink 1.1s steps(2, start) infinite; }
@keyframes blink { to { visibility: hidden; } }

/* ==========================================================================
   Admin dashboard — same dot language, denser layout
   ========================================================================== */

.admin-body { background: var(--paper-dim); }
.admin-shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }

.admin-side {
  border-right: 2px dotted var(--line);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  background: var(--paper);
}

.admin-side .brand { margin-bottom: var(--space-4); }

.admin-tab {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 13px;
  border: 1.5px solid transparent;
  background: transparent;
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s var(--ease);
  width: 100%;
}
.admin-tab:hover { color: var(--ink); border-color: var(--line-strong); background: var(--paper); }
.admin-tab.on {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
  box-shadow: 3px 3px 0 var(--clay);
}
.admin-tab .badge {
  margin-left: auto;
  background: var(--clay);
  color: var(--paper);
  font-size: 11px;
  padding: 1px 8px;
}
.admin-tab.on .badge { background: var(--paper); color: var(--ink); }

.side-foot { display: flex; flex-direction: column; gap: 8px; margin-top: auto; }

.admin-main { padding: clamp(20px, 3.4vw, 40px); max-width: 1160px; width: 100%; margin-inline: auto; }
.admin-main > header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-5); flex-wrap: wrap; }
.admin-main > header h1 { font-size: clamp(21px, 2.8vw, 27px); }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--space-3); margin-bottom: var(--space-5); }
.stat-tile { border: 1.5px solid var(--ink); background: var(--paper); padding: var(--space-4); box-shadow: 3px 3px 0 var(--line); }
.stat-tile .num { font-family: var(--font-mono); font-size: 32px; line-height: 1; margin-bottom: 8px; }
.stat-tile .lbl { font-family: var(--font-mono); font-size: 12px; color: var(--ink-soft); }
.stat-tile.accent { box-shadow: 3px 3px 0 var(--clay); }
.stat-tile.accent .num { color: var(--clay-deep); }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); margin-bottom: var(--space-4); }
.toolbar .spacer { flex: 1; }
.toolbar .search { max-width: 260px; }

.bulkbar {
  display: none;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  border: 1.5px solid var(--ink);
  background: var(--gold);
  padding: var(--space-2) var(--space-3);
  margin-bottom: var(--space-3);
  font-family: var(--font-mono);
  font-size: 12.5px;
  box-shadow: 3px 3px 0 var(--ink);
}
.bulkbar.show { display: flex; }
.bulkbar strong { margin-right: 4px; }

.table-wrap { border: 1.5px solid var(--ink); background: var(--paper); overflow-x: auto; box-shadow: 4px 4px 0 var(--line); }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-weight: 500;
  padding: 11px 13px;
  border-bottom: 2px solid var(--ink);
  white-space: nowrap;
}
table.data td { padding: 10px 13px; border-bottom: 1px dotted var(--line); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr { transition: background 0.15s; }
table.data tbody tr:hover { background: var(--paper-dim); }
table.data tr.drag-over td { border-top: 2px solid var(--clay-deep); }
tr[draggable] td.drag-cell { cursor: grab; color: var(--ink-faint); user-select: none; }
tr.dragging { opacity: 0.4; }

.row-title { font-weight: 500; }
.row-sub { font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-faint); }
.cell-thumb { width: 74px; aspect-ratio: 16/9; object-fit: cover; border: 1px solid var(--line); background: var(--paper-dim); }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.icon-btn {
  border: 1px solid var(--line-strong);
  background: transparent;
  width: 30px; height: 30px;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: 13px;
  transition: all 0.2s var(--ease);
  flex: none;
}
.icon-btn:hover { border-color: var(--ink); color: var(--ink); background: var(--paper); }
.icon-btn.danger:hover { border-color: var(--clay-deep); color: var(--clay-deep); }
.icon-btn svg { width: 14px; height: 14px; }

.status-select {
  border: 1px solid var(--line-strong);
  background: var(--paper);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 4px 26px 4px 11px;
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 49%, var(--ink) 50%),
    linear-gradient(-45deg, transparent 49%, var(--ink) 50%);
  background-position: calc(100% - 15px) 50%, calc(100% - 11px) 50%;
  background-size: 4px 4px;
  background-repeat: no-repeat;
  cursor: pointer;
}

.pub-toggle { position: relative; width: 34px; height: 19px; border: 1.5px solid var(--line-strong); background: transparent; cursor: pointer; transition: all 0.2s var(--ease); flex: none; }
.pub-toggle::after { content: ""; position: absolute; top: 2px; left: 2px; width: 11px; height: 11px; background: var(--ink-faint); transition: all 0.2s var(--ease); }
.pub-toggle.on { background: var(--ink); border-color: var(--ink); }
.pub-toggle.on::after { left: 17px; background: var(--clay); }

.checkbox { width: 15px; height: 15px; accent-color: var(--clay-deep); cursor: pointer; }

/* modal */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: radial-gradient(circle, rgba(38, 36, 29, 0.78) 1.2px, rgba(38, 36, 29, 0.82) 1.4px);
  background-size: 5px 5px;
  display: grid;
  place-items: center;
  padding: clamp(10px, 3vw, 32px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s var(--ease);
}
.modal-backdrop.open { opacity: 1; pointer-events: auto; }

.modal {
  background: var(--paper);
  border: 2px solid var(--ink);
  box-shadow: 10px 10px 0 rgba(204, 124, 94, 0.75);
  width: min(640px, 100%);
  max-height: min(86vh, 900px);
  display: flex;
  flex-direction: column;
}
.modal.wide { width: min(780px, 100%); }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-bottom: 2px solid var(--ink);
  background: var(--paper);
}
.modal-head h2 { font-size: 17px; }
.modal-body { padding: var(--space-4); overflow-y: auto; display: flex; flex-direction: column; gap: var(--space-3); }
.modal-foot { padding: var(--space-3) var(--space-4); border-top: 2px dotted var(--line); display: flex; justify-content: flex-end; gap: var(--space-2); }

.yt-preview { border: 1.5px solid var(--line-strong); overflow: hidden; aspect-ratio: 16/9; background: var(--paper-dim); position: relative; }
.yt-preview img { width: 100%; height: 100%; object-fit: cover; }
.yt-preview .no-video {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--ink-faint);
  font-family: var(--font-mono);
  font-size: 12.5px;
  background-image: radial-gradient(circle, var(--line) 1px, transparent 1.4px);
  background-size: 12px 12px;
}

/* sessions editor */

.session-editor { border: 1.5px solid var(--ink); }
.session-editor-head {
  padding: var(--space-3) var(--space-4);
  border-bottom: 2px dotted var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  flex-wrap: wrap;
  font-family: var(--font-mono);
}
.gen-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: var(--space-2); padding: var(--space-3) var(--space-4); align-items: end; }
.gen-form .field label { font-size: 11px; color: var(--ink-soft); }
.weekday-picker { display: flex; gap: 4px; flex-wrap: wrap; }
.wd-chip {
  width: 32px; height: 32px;
  border: 1.5px solid var(--line-strong);
  background: transparent;
  font-family: var(--font-mono);
  font-size: 11.5px;
  cursor: pointer;
  transition: all 0.2s var(--ease);
}
.wd-chip.on { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.gen-preview { list-style: none; margin: 0; padding: 0 var(--space-4) var(--space-3); font-family: var(--font-mono); font-size: 12px; color: var(--ink-soft); max-height: 130px; overflow-y: auto; }
.session-existing { list-style: none; margin: 0; padding: 0; max-height: 180px; overflow-y: auto; }
.session-existing li {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 7px var(--space-4);
  border-top: 1px dotted var(--line);
  font-family: var(--font-mono);
  font-size: 12.5px;
}
.session-existing li .spacer { flex: 1; }
.session-existing li.past { color: var(--ink-faint); }

/* toast */

.toast-zone { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 9px 20px;
  box-shadow: 4px 4px 0 var(--clay);
  animation: toast-in 0.3s var(--ease);
}
.toast.error { background: var(--clay-deep); color: var(--paper); box-shadow: 4px 4px 0 var(--ink); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

/* login card */

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: var(--space-4); }
.login-card {
  width: min(380px, 100%);
  border: 2px solid var(--ink);
  background: var(--paper);
  padding: var(--space-6) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  box-shadow: 8px 8px 0 var(--clay);
}
.login-card h1 { font-size: 19px; text-align: center; font-family: var(--font-mono); }

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

@media (max-width: 860px) {
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .admin-shell { grid-template-columns: 1fr; }
  .admin-side {
    position: sticky;
    top: 0;
    z-index: 40;
    flex-direction: row;
    align-items: center;
    gap: var(--space-2);
    overflow-x: auto;
    border-right: 0;
    border-bottom: 2px dotted var(--line);
    padding: var(--space-2) var(--space-3);
  }
  .admin-side .brand { margin-bottom: 0; margin-right: var(--space-2); }
  .admin-side .brand .brand-sub { display: none; }
  .side-foot { flex-direction: row; align-items: center; margin-left: auto; }
  .side-foot a { display: none; }
  .admin-tab { width: auto; white-space: nowrap; }
}

@media (max-width: 640px) {
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: span 1; }

  .nav-toggle {
    display: inline-grid;
    place-items: center;
    width: 38px; height: 38px;
    margin-left: auto;
    background: none;
    border: 1.5px solid var(--line-strong);
    cursor: pointer;
  }
  .header-tools { margin-left: 0; }
  .site-nav {
    display: none;
    position: absolute;
    top: var(--header-h);
    left: 0; right: 0;
    flex-direction: column;
    gap: 0;
    background: var(--paper);
    border-bottom: 2px solid var(--ink);
    padding: var(--space-2) 24px var(--space-3);
  }
  .site-nav.open { display: flex; }
  .site-nav a { padding: 12px 0; font-size: 15px; border-bottom: 1px dotted var(--line); }
  .site-nav a::before { content: none; }
}

/* ==========================================================================
   CMS edit mode (visual editor overlay states on the real pages)
   ========================================================================== */

body.cms-editing [data-cms] {
  outline: 1.5px dashed var(--clay);
  outline-offset: 3px;
  cursor: text;
  min-height: 1em;
}
body.cms-editing [data-cms]:hover {
  outline-color: var(--clay-deep);
  background: rgba(230, 180, 101, 0.18);
}
body.cms-editing [data-cms].cms-active {
  outline: 2px solid var(--clay-deep);
  background: rgba(230, 180, 101, 0.25);
}
body.cms-editing [data-cms]:focus { outline: 2px solid var(--clay-deep); }

/* ==========================================================================
   Home — "The Record · 三幕" staged reading
   Desktop: one fixed stage; wheel, arrow keys and touch turn whole acts like
   pages of a game record (engine in home.js, gated on body.staged). Mobile,
   short windows and reduced-motion fall back to natural scrolling.
   Backdrop: a breathing goban lattice — hairline grid on a 56px module with
   true star points — replaces the old halftone dot field.
   ========================================================================== */

/* ---------- goban lattice backdrop ---------- */

/* A single fixed pseudo-element paints the whole scene, so acts fade over it.
   Star points sit on a 448px tile (= 8 × 56) that lands exactly on the
   lattice; a radial mask lets everything dissolve toward the edges. */
body[data-page="home"] .stage::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    radial-gradient(circle 2.6px at 112px 112px, rgba(38, 36, 29, 0.15) 97%, transparent),
    radial-gradient(circle 2.6px at 336px 112px, rgba(38, 36, 29, 0.15) 97%, transparent),
    radial-gradient(circle 2.6px at 112px 336px, rgba(38, 36, 29, 0.15) 97%, transparent),
    radial-gradient(circle 2.6px at 336px 336px, rgba(38, 36, 29, 0.15) 97%, transparent),
    radial-gradient(circle 3px at 224px 224px, rgba(38, 36, 29, 0.18) 97%, transparent),
    repeating-linear-gradient(to right, rgba(38, 36, 29, 0.042) 0 1px, transparent 1px 56px),
    repeating-linear-gradient(to bottom, rgba(38, 36, 29, 0.042) 0 1px, transparent 1px 56px);
  background-size: 448px 448px, 448px 448px, 448px 448px, 448px 448px, 448px 448px, auto, auto;
  -webkit-mask-image: radial-gradient(125% 100% at 50% 36%, #000 34%, transparent 82%);
  mask-image: radial-gradient(125% 100% at 50% 36%, #000 34%, transparent 82%);
}

/* ---------- act frame (both modes) ---------- */

body[data-page="home"] .act {
  position: relative;
  display: flex;
  flex-direction: column;
  padding-block: clamp(44px, 8vh, 104px);
}

body[data-page="home"] .act > .container {
  position: relative;
  z-index: 1;
  margin-block: auto; /* center when it fits, flow naturally when it grows */
}

/* keep hero copy clear of the stones composition */
body[data-page="home"] .act-hero .act-inner > * { max-width: 680px; }

/* ---------- staged mode (desktop; body.staged is set by home.js) ---------- */

body.staged {
  overflow: hidden;
  overscroll-behavior: none;
}

body.staged .stage {
  height: calc(100vh - var(--header-h));
  height: calc(100svh - var(--header-h));
}

body.staged .act {
  position: absolute;
  inset: 0;
  overflow: hidden;
  visibility: hidden;
  opacity: 0;
  transform: translateY(30px);
  transition:
    opacity 0.62s var(--ease),
    transform 0.62s var(--ease),
    visibility 0s linear 0.62s;
  will-change: opacity, transform;
}
body.staged .act.is-above { transform: translateY(-22px); }
body.staged .act.is-below { transform: translateY(30px); }
body.staged .act.is-active {
  visibility: visible;
  opacity: 1;
  transform: none;
  transition:
    opacity 0.62s var(--ease),
    transform 0.62s var(--ease),
    visibility 0s;
}

/* In staged mode the reveal cascade belongs to the engine: it re-adds .in
   per act with inline transition-delays (kicker → title → lede → actions). */

/* ---------- move counter (right rail) ---------- */

.act-nav {
  position: fixed;
  right: clamp(14px, 2.4vw, 40px);
  top: 50%;
  transform: translateY(-50%);
  z-index: 60;
  display: none;
  flex-direction: column;
  gap: 6px;
}
body.staged .act-nav { display: flex; }

.act-nav button {
  position: relative;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

.act-nav button i {
  display: block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 1.5px solid var(--ink-faint);
  background: transparent;
  transition: all 0.45s var(--ease);
}

.act-nav button:hover i,
.act-nav button:focus-visible i {
  border-color: var(--ink);
  transform: scale(1.28);
}

/* the current act: a settled black stone, ringed in clay */
.act-nav button[aria-current="true"] i {
  background: var(--ink);
  border-color: var(--ink);
  box-shadow:
    0 0 0 3.5px var(--paper),
    0 0 0 5px var(--clay);
  transform: scale(1.1);
}

.act-nav-tip {
  position: absolute;
  right: 42px;
  top: 50%;
  transform: translateY(-50%) translateX(6px);
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.2em;
  white-space: nowrap;
  color: var(--ink-soft);
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 4px 9px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s var(--ease), transform 0.25s var(--ease);
}
.act-nav button:hover .act-nav-tip,
.act-nav button:focus-visible .act-nav-tip {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}
.act-nav-tip:lang(zh-CN) { letter-spacing: 0.3em; }

/* ---------- hero: two stones settling on an intersection ---------- */

.hero-stones {
  position: absolute;
  z-index: 0;
  top: 50%;
  right: clamp(2%, 5vw, 9%);
  transform: translateY(-52%);
  width: clamp(190px, 21vw, 300px);
  height: auto;
  pointer-events: none;
  user-select: none;
}

.hs-cross { opacity: 0; animation: cross-in 0.9s ease 0.05s forwards; }
@keyframes cross-in { to { opacity: 1; } }

.hs-stone { opacity: 0; transform-box: fill-box; transform-origin: center; }
.hs-black {
  transform: scale(0.9);
  animation: stone-settle 0.7s var(--ease) 0.18s forwards;
}
.hs-white {
  transform: scale(0.9);
  animation: stone-settle 0.7s var(--ease) 0.58s forwards;
}
@keyframes stone-settle { to { opacity: 1; transform: scale(1); } }

.hs-glint { opacity: 0; animation: glint-in 0.6s ease 0.52s forwards; }
@keyframes glint-in { to { opacity: 1; } }

.hs-ring { opacity: 0; animation: hsring-in 0.7s var(--ease) 0.8s forwards; }
@keyframes hsring-in { to { opacity: 0.92; } }

/* ---------- hero typography & CTAs ---------- */

body[data-page="home"] #hero-title {
  font-size: clamp(40px, 5.6vw, 68px);
  line-height: 1.06;
  letter-spacing: -0.03em;
  margin-block: var(--space-3) var(--space-4);
}

body[data-page="home"] #hero-title .hero-sub-zh {
  display: block;
  font-family: var(--font-cjk);
  font-size: 0.32em;
  font-weight: 500;
  letter-spacing: 0.3em;
  color: var(--ink-soft);
  margin-top: 0.55em;
}

.btn-act { padding: 13px 26px; font-size: 14px; min-width: 210px; justify-content: center; }

/* language labels must never stack vertically when the header gets tight */
body[data-page="home"] .lang-switch button { white-space: nowrap; }

/* ---------- page furniture: folio, scroll cue, colophon ---------- */

.folio {
  position: absolute;
  right: clamp(20px, 3vw, 44px);
  bottom: 20px;
  z-index: 1;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  color: var(--ink-faint);
}
.folio:lang(zh-CN) { letter-spacing: 0.34em; }

.scroll-cue {
  position: absolute;
  left: clamp(20px, 3vw, 44px);
  bottom: 20px;
  z-index: 1;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--ink-faint);
  text-decoration: none;
  transition: color 0.25s var(--ease);
}
.scroll-cue:hover { color: var(--clay-deep); }
.scroll-cue:lang(zh-CN) { letter-spacing: 0.34em; }
.scroll-cue::after {
  content: "";
  display: block;
  width: 1px;
  height: 30px;
  margin-top: 9px;
  background: linear-gradient(to bottom, var(--ink-faint), transparent);
  transform-origin: top;
  animation: cue-drop 2.4s var(--ease) infinite;
}
@keyframes cue-drop {
  0% { transform: scaleY(0); opacity: 0; }
  35% { transform: scaleY(1); opacity: 1; }
  100% { transform: scaleY(1); opacity: 0; }
}

/* Act III colophon replaces the shared footer while staged */
.act-colophon {
  margin-top: var(--space-5);
  padding-top: var(--space-3);
  border-top: 2px dotted var(--line);
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
}
body:not(.staged) .act-colophon { display: none; }
body.staged .site-footer { display: none; }

/* act-level spacing helpers */
body[data-page="home"] .section-head h2 { font-size: clamp(26px, 3.2vw, 38px); }
body[data-page="home"] .act-more { margin-top: var(--space-4); }

/* teacher strip folds into Act III as a credibility line */
body[data-page="home"] .act-classes .teacher-strip {
  border-bottom: 0;
  border-top: 2px dotted var(--line);
  margin-top: var(--space-5);
  padding-bottom: 0;
}

/* ---------- natural-flow mode (mobile / short window / reduced motion) ---------- */

body[data-page="home"]:not(.staged) .act-hero {
  min-height: calc(100vh - var(--header-h));
  min-height: calc(100svh - var(--header-h));
}

body[data-page="home"]:not(.staged) .act-videos,
body[data-page="home"]:not(.staged) .act-classes {
  border-top: 2px dotted var(--line);
  padding-block: clamp(56px, 10vh, 120px);
}

@media (max-width: 900px) {
  /* the stones tuck into the top-right corner, bleeding off the edge —
     small enough never to collide with the centered copy below */
  .hero-stones {
    top: -26px;
    right: -44px;
    transform: none;
    width: 172px;
  }
}

@media (max-width: 640px) {
  /* the latin sub-brand is the first thing to overflow a narrow header */
  body[data-page="home"] .brand .brand-sub { display: none; }
  .hero-stones { width: 140px; top: -18px; right: -36px; }
}

/* ---------- bilingual type law (i18n.js sets <html lang="zh-CN">) ---------- */

/* hanzi headings: no negative tracking, slightly smaller, looser leading */
body[data-page="home"] #hero-title:lang(zh-CN) {
  font-size: clamp(32px, 4.8vw, 56px);
  letter-spacing: 0.04em;
  line-height: 1.28;
}
body[data-page="home"] .section-head h2:lang(zh-CN) {
  letter-spacing: 0.02em;
  line-height: 1.3;
}

/* hanzi body: em-based measure (ch is meaningless at full-width), looser */
body[data-page="home"] p:lang(zh-CN) { line-height: 1.95; letter-spacing: 0.015em; }
body[data-page="home"] .hero-lede:lang(zh-CN) { max-width: 25em; }
body[data-page="home"] .section-head p:lang(zh-CN) { max-width: 30em; }

body[data-page="home"] .kicker:lang(zh-CN) { letter-spacing: 0.3em; }
body[data-page="home"] .btn:lang(zh-CN) { letter-spacing: 0.1em; padding-inline: 22px; }
body[data-page="home"] .video-card-body h3:lang(zh-CN) { line-height: 1.55; }
.act-colophon:lang(zh-CN) { letter-spacing: 0.12em; }

/* the swapped subtitle: hanzi gets luxurious tracking, latin returns to mono */
body[data-page="home"] #hero-title .hero-sub-zh:lang(zh-CN) {
  font-family: var(--font-mono);
  letter-spacing: 0.06em;
}

/* ---------- graceful degradation ---------- */

@media (prefers-reduced-motion: reduce) {
  .hs-stone,
  .hs-ring,
  .hs-glint,
  .hs-cross {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
  .scroll-cue::after { animation: none; }
  body[data-page="home"] .stage::before { mask-image: none; -webkit-mask-image: none; }
}
