/* =========================================================
   ASCII MOTION ARCHIVE
   A zero-build, monochrome terminal gallery.
   ========================================================= */

:root {
  --bg: #070a09;
  --bg-2: #0a0f0c;
  --panel: #0d1410;
  --panel-2: #111a15;
  --panel-3: #16221b;
  --text: #cfdad2;
  --text-strong: #edf5ef;
  --muted: #82958a;
  --faint: #53655a;
  --line: rgba(151, 188, 164, 0.15);
  --line-strong: rgba(151, 188, 164, 0.30);
  --accent: #7dffb0;
  --accent-rgb: 125, 255, 176;
  --accent-dim: #3f9b68;
  --accent-soft: rgba(125, 255, 176, 0.10);
  --glow: rgba(125, 255, 176, 0.15);
  --danger: #ff8a78;
  --grid: rgba(125, 255, 176, 0.045);
  --scanline: rgba(255, 255, 255, 0.016);
  --shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
  --font: "JetBrains Mono", "Fira Code", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --radius: 3px;
  --max: 1420px;
  --topbar: 64px;
}

[data-theme="amber"] {
  --bg: #0b0906;
  --bg-2: #100c08;
  --panel: #15100a;
  --panel-2: #1b140d;
  --panel-3: #241a10;
  --text: #e0d2c1;
  --text-strong: #fff1df;
  --muted: #9b8771;
  --faint: #665444;
  --line: rgba(214, 178, 132, 0.15);
  --line-strong: rgba(214, 178, 132, 0.32);
  --accent: #ffbd73;
  --accent-rgb: 255, 189, 115;
  --accent-dim: #a46b33;
  --accent-soft: rgba(255, 189, 115, 0.10);
  --glow: rgba(255, 189, 115, 0.15);
  --grid: rgba(255, 189, 115, 0.045);
}

[data-theme="ice"] {
  --bg: #07090c;
  --bg-2: #0a0e13;
  --panel: #0d1218;
  --panel-2: #111921;
  --panel-3: #17212c;
  --text: #cfdce5;
  --text-strong: #f0f8ff;
  --muted: #8295a3;
  --faint: #536573;
  --line: rgba(165, 198, 220, 0.15);
  --line-strong: rgba(165, 198, 220, 0.32);
  --accent: #bfe9ff;
  --accent-rgb: 191, 233, 255;
  --accent-dim: #5f93aa;
  --accent-soft: rgba(191, 233, 255, 0.10);
  --glow: rgba(191, 233, 255, 0.15);
  --grid: rgba(191, 233, 255, 0.045);
}

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

html {
  scroll-behavior: smooth;
  background: var(--bg);
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border: 3px solid var(--bg);
  border-radius: 0;
}
::-webkit-scrollbar-thumb:hover { background: var(--accent-dim); }

body {
  margin: 0;
  min-width: 280px;
  background:
    radial-gradient(1100px 620px at 48% -12%, rgba(var(--accent-rgb), 0.075), transparent 62%),
    radial-gradient(800px 500px at 100% 20%, rgba(var(--accent-rgb), 0.03), transparent 60%),
    linear-gradient(180deg, var(--bg-2), var(--bg) 32%, var(--bg));
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(180deg, rgba(0,0,0,.9), rgba(0,0,0,.28) 60%, transparent);
}

main,
.footer {
  position: relative;
  z-index: 1;
}

.crt {
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
  background:
    repeating-linear-gradient(0deg, var(--scanline) 0 1px, transparent 1px 3px),
    radial-gradient(120% 90% at 50% 50%, transparent 58%, rgba(0, 0, 0, 0.22) 100%);
  opacity: 0.55;
  mix-blend-mode: screen;
}

::selection {
  background: var(--accent);
  color: var(--bg);
}

a {
  color: var(--accent);
  text-decoration: none;
  text-underline-offset: 3px;
}

a:hover { text-decoration: underline; }

button,
input { font: inherit; }

button { color: inherit; }

code {
  font-family: var(--font);
  color: var(--accent);
  font-size: 0.92em;
}

[hidden] { display: none !important; }

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

.skip-link {
  position: fixed;
  left: 16px;
  top: -60px;
  z-index: 300;
  padding: 10px 14px;
  background: var(--accent);
  color: var(--bg);
  font-weight: 700;
  transition: top 160ms ease;
}
.skip-link:focus { top: 12px; }

/* ---------- top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  min-height: var(--topbar);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 clamp(16px, 3.2vw, 42px);
  background: rgba(7, 10, 9, 0.78);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px) saturate(120%);
}

[data-theme="amber"] .topbar { background: rgba(11, 9, 6, 0.80); }
[data-theme="ice"] .topbar { background: rgba(7, 9, 12, 0.80); }

.brand {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  color: var(--text-strong);
  font-weight: 700;
  letter-spacing: 0.045em;
  white-space: nowrap;
  text-decoration: none;
}
.brand:hover { text-decoration: none; }
.brand-prompt { color: var(--accent); font-weight: 500; }
.brand-slash { color: var(--accent); font-weight: 400; }
.brand-cursor {
  color: var(--accent);
  animation: blink 1.12s steps(1, end) infinite;
  margin-left: -2px;
}

@keyframes blink {
  0%, 45% { opacity: 1; }
  46%, 100% { opacity: 0; }
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.theme-switch {
  display: flex;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.14);
}

.theme-switch button {
  appearance: none;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--faint);
  padding: 7px 10px;
  font-size: 9px;
  letter-spacing: 0.13em;
  cursor: pointer;
  transition: color 150ms ease, background 150ms ease;
}
.theme-switch button:last-child { border-right: 0; }
.theme-switch button:hover { color: var(--text); }
.theme-switch button[aria-pressed="true"] {
  color: var(--accent);
  background: var(--accent-soft);
}

.ghost-button,
.primary-button,
.action-button,
.nav-button,
.modal-close {
  appearance: none;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-family: var(--font);
  font-size: 10px;
  letter-spacing: 0.09em;
  padding: 9px 12px;
  cursor: pointer;
  transition: border-color 150ms ease, color 150ms ease, background 150ms ease, transform 150ms ease;
  white-space: nowrap;
}

.ghost-button:hover,
.action-button:hover,
.nav-button:hover,
.modal-close:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.ghost-button:active,
.primary-button:active,
.action-button:active,
.nav-button:active { transform: translateY(1px); }

.ghost-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.ghost-button[aria-pressed="true"] {
  color: var(--accent);
  border-color: var(--accent-dim);
  background: var(--accent-soft);
}
.button-dot,
.status-dot,
.live-dot {
  width: 5px;
  height: 5px;
  display: inline-block;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}
.ghost-button[aria-pressed="true"] .button-dot { animation: pulse 1.2s ease-in-out infinite; }

.primary-button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
  padding: 12px 16px;
  font-weight: 600;
}
.primary-button:hover {
  text-decoration: none;
  background: var(--accent);
  color: var(--bg);
  box-shadow: 0 0 24px var(--glow);
}

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

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

.hero {
  max-width: var(--max);
  margin: 0 auto;
  padding: clamp(48px, 8vw, 100px) clamp(16px, 3.2vw, 42px) 36px;
  display: grid;
  grid-template-columns: minmax(0, 1.28fr) minmax(320px, 0.72fr);
  gap: clamp(28px, 5vw, 70px);
  align-items: end;
}

.eyebrow {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 9px;
}

.hero h1 {
  margin: 0;
  font-size: clamp(54px, 9.6vw, 142px);
  line-height: 0.82;
  letter-spacing: -0.075em;
  font-weight: 700;
  color: var(--text-strong);
  text-wrap: balance;
}
.hero h1 .slash {
  color: var(--accent);
  font-weight: 400;
  letter-spacing: -0.1em;
  display: inline-block;
  transform: translateY(-0.03em);
}

.lede {
  max-width: 54ch;
  margin: 28px 0 0;
  color: var(--muted);
  font-size: clamp(13px, 1.4vw, 15px);
  line-height: 1.9;
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  margin-top: 28px;
}
.hero-note {
  color: var(--faint);
  font-size: 9px;
  letter-spacing: 0.1em;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
  margin-top: 38px;
}
.stats > div {
  padding: 14px 14px 12px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  min-width: 0;
}
.stats strong {
  display: block;
  color: var(--text-strong);
  font-size: clamp(18px, 2.4vw, 28px);
  line-height: 1;
  letter-spacing: -0.04em;
  font-weight: 500;
}
.stats span {
  display: block;
  margin-top: 7px;
  color: var(--faint);
  font-size: 8px;
  letter-spacing: 0.12em;
}

.hero-panel {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(var(--accent-rgb), 0.035), transparent 34%), var(--panel);
  box-shadow: var(--shadow);
  position: relative;
}
.hero-panel::before,
.hero-panel::after {
  content: "+";
  position: absolute;
  color: var(--accent-dim);
  font-size: 11px;
  line-height: 1;
  pointer-events: none;
}
.hero-panel::before { left: 6px; top: 4px; }
.hero-panel::after { right: 6px; bottom: 4px; }

.panel-head,
.panel-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  color: var(--faint);
  font-size: 8px;
  letter-spacing: 0.1em;
}
.panel-head { border-bottom: 1px solid var(--line); }
.panel-foot { border-top: 1px solid var(--line); flex-wrap: wrap; }
.panel-live { color: var(--accent); display: inline-flex; align-items: center; gap: 6px; }
.panel-live i { width: 4px; height: 4px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px var(--accent); animation: pulse 1.4s ease-in-out infinite; }

.hero-frame {
  aspect-ratio: 16 / 9.4;
  min-height: 220px;
}

/* ---------- shared frame box ---------- */

.frame-box {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(70% 80% at 50% 50%, rgba(var(--accent-rgb), 0.035), transparent 72%),
    #080c09;
  isolation: isolate;
}
[data-theme="amber"] .frame-box { background: radial-gradient(70% 80% at 50% 50%, rgba(var(--accent-rgb), 0.035), transparent 72%), #0c0905; }
[data-theme="ice"] .frame-box { background: radial-gradient(70% 80% at 50% 50%, rgba(var(--accent-rgb), 0.035), transparent 72%), #070b10; }

.frame-box::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 24px 24px;
  opacity: 0.7;
  mask-image: radial-gradient(70% 70% at 50% 50%, #000, transparent);
}

.frame-box::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255,255,255,0.022), transparent 18%, transparent 82%, rgba(0,0,0,0.18));
}

.frame-box pre {
  position: absolute;
  left: 50%;
  top: 50%;
  margin: 0;
  padding: 0;
  color: var(--text-strong);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1;
  white-space: pre;
  transform: translate(-50%, -50%) scale(1);
  transform-origin: center center;
  text-shadow: 0 0 14px var(--glow);
  font-variant-ligatures: none;
  font-kerning: none;
  tab-size: 1;
  pointer-events: none;
  will-change: transform;
}

.frame-box pre[data-placeholder="true"] {
  color: var(--faint);
  font-size: 11px;
  letter-spacing: 0.08em;
  white-space: normal;
  text-align: center;
}

/* ---------- controls ---------- */

.controls {
  position: sticky;
  top: var(--topbar);
  z-index: 30;
  max-width: var(--max);
  margin: 0 auto;
  padding: 15px clamp(16px, 3.2vw, 42px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  background: rgba(7, 10, 9, 0.80);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px) saturate(120%);
}
[data-theme="amber"] .controls { background: rgba(11, 9, 6, 0.82); }
[data-theme="ice"] .controls { background: rgba(7, 9, 12, 0.82); }

.filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--faint);
  padding: 7px 9px;
  font-size: 9px;
  letter-spacing: 0.09em;
  cursor: pointer;
  transition: color 150ms ease, border-color 150ms ease, background 150ms ease;
}
.chip:hover { color: var(--text); border-color: var(--line); }
.chip[aria-pressed="true"] {
  color: var(--accent);
  border-color: var(--accent-dim);
  background: var(--accent-soft);
}
.chip-count { color: var(--faint); margin-left: 2px; }
.chip[aria-pressed="true"] .chip-count { color: var(--accent); }

.control-right {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 0 1 auto;
}

.search-field {
  display: flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  padding: 0 9px;
  height: 34px;
  background: rgba(0, 0, 0, 0.14);
  transition: border-color 150ms ease;
}
.search-field:focus-within { border-color: var(--accent-dim); }
.search-prefix { color: var(--accent); font-size: 11px; }
.search-field input {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text);
  font-family: var(--font);
  font-size: 10px;
  letter-spacing: 0.08em;
  width: 170px;
  outline: 0;
}
.search-field input::placeholder { color: var(--faint); }
.search-field kbd {
  border: 1px solid var(--line);
  color: var(--faint);
  padding: 1px 4px;
  font-family: var(--font);
  font-size: 9px;
}

.speed-field {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--faint);
  font-size: 8px;
  letter-spacing: 0.1em;
  white-space: nowrap;
}
.speed-field input[type="range"] {
  width: 86px;
  accent-color: var(--accent);
  cursor: pointer;
}
.speed-field output { color: var(--accent); min-width: 34px; text-align: right; }

.archive-status {
  max-width: var(--max);
  margin: 0 auto;
  padding: 11px clamp(16px, 3.2vw, 42px) 0;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--faint);
  font-size: 9px;
  letter-spacing: 0.1em;
}
.data-status { color: var(--accent-dim); }
.data-status.is-ready { color: var(--accent); }
.data-status.is-error { color: var(--danger); cursor: pointer; }

/* ---------- gallery ---------- */

.gallery {
  max-width: var(--max);
  margin: 0 auto;
  padding: 16px clamp(16px, 3.2vw, 42px) 70px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: clamp(12px, 1.8vw, 22px);
}

.card {
  position: relative;
  min-width: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.024), transparent 34%), var(--panel);
  border: 1px solid var(--line);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}
.card:hover,
.card:focus-within {
  border-color: var(--line-strong);
  box-shadow: 0 0 0 1px rgba(var(--accent-rgb), 0.06), 0 22px 60px rgba(0, 0, 0, 0.36);
  transform: translateY(-2px);
}
.card.is-active { border-color: rgba(var(--accent-rgb), 0.34); }

.card-open {
  position: absolute;
  inset: 0;
  z-index: 1;
  appearance: none;
  border: 0;
  background: transparent;
  cursor: pointer;
}
.card-open:focus-visible {
  outline: 2px dashed var(--accent);
  outline-offset: -4px;
}

.card-content {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  min-height: 100%;
  pointer-events: none;
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--faint);
  font-size: 8px;
  letter-spacing: 0.11em;
}
.card-index { color: var(--accent); }
.card-cat { text-align: right; }
.card-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--faint);
}
.card-status i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--faint);
}
.card.is-active .card-status { color: var(--accent); }
.card.is-active .card-status i { background: var(--accent); box-shadow: 0 0 8px var(--accent); animation: pulse 1.3s ease-in-out infinite; }

.card .frame-box {
  aspect-ratio: 16 / 10;
  border-bottom: 1px solid var(--line);
}

.card-body {
  padding: 13px 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  flex: 1;
}

.card-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.card-title {
  margin: 0;
  color: var(--text-strong);
  font-size: clamp(16px, 1.6vw, 19px);
  line-height: 1.15;
  letter-spacing: -0.03em;
  font-weight: 500;
}
.card-zh {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.card-summary {
  margin: 0;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.7;
  min-height: 2.9em;
}
.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.tag {
  color: var(--faint);
  border: 1px solid var(--line);
  padding: 2px 5px;
  font-size: 8px;
  letter-spacing: 0.05em;
}
.card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  color: var(--faint);
  font-size: 8px;
  letter-spacing: 0.08em;
}
.license-badge {
  color: var(--accent-dim);
  border: 1px solid var(--line);
  padding: 2px 5px;
  font-size: 8px;
  white-space: nowrap;
}
.license-badge.is-original { color: var(--accent); border-color: var(--accent-dim); }

.card-actions {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  padding: 0 14px 13px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(3px);
  transition: opacity 160ms ease, transform 160ms ease, visibility 160ms ease;
  pointer-events: none;
}
.card:hover .card-actions,
.card:focus-within .card-actions,
.card.is-active .card-actions {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}
.card-actions button {
  pointer-events: auto;
  flex: 1 1 auto;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.12);
  color: var(--muted);
  font-size: 8px;
  letter-spacing: 0.08em;
  padding: 6px 7px;
  cursor: pointer;
  transition: color 140ms ease, border-color 140ms ease, background 140ms ease;
}
.card-actions button:hover {
  color: var(--accent);
  border-color: var(--accent-dim);
  background: var(--accent-soft);
}

.card[hidden] { display: none; }

/* ---------- empty / about / footer ---------- */

.empty-state {
  max-width: var(--max);
  margin: 0 auto;
  padding: 80px clamp(16px, 3.2vw, 42px);
  border-top: 1px solid var(--line);
}
.empty-state h2 {
  margin: 0 0 10px;
  font-size: clamp(26px, 4vw, 48px);
  letter-spacing: -0.05em;
  font-weight: 500;
}
.empty-state p { color: var(--muted); margin: 0 0 18px; }

.about {
  max-width: var(--max);
  margin: 0 auto;
  padding: 2px clamp(16px, 3.2vw, 42px) 80px;
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: clamp(30px, 6vw, 90px);
  border-top: 1px solid var(--line);
  padding-top: 54px;
}
.about h2 {
  margin: 0 0 20px;
  color: var(--text-strong);
  font-size: clamp(28px, 4.2vw, 54px);
  line-height: 1.12;
  letter-spacing: -0.06em;
  font-weight: 500;
}
.about p {
  color: var(--muted);
  max-width: 54ch;
  line-height: 1.9;
  font-size: 12.5px;
}
.about-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}
.about-grid > div {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 18px 16px;
}
.about-k {
  display: block;
  color: var(--faint);
  font-size: 8px;
  letter-spacing: 0.13em;
}
.about-grid strong {
  display: block;
  color: var(--accent);
  font-size: 12px;
  font-weight: 500;
  margin: 8px 0 7px;
  letter-spacing: 0.02em;
}
.about-grid p {
  margin: 0;
  font-size: 10px;
  line-height: 1.7;
  color: var(--muted);
}

.footer {
  border-top: 1px solid var(--line);
  padding: 22px clamp(16px, 3.2vw, 42px) 30px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  color: var(--faint);
  font-size: 9px;
  letter-spacing: 0.08em;
}
.footer-brand { display: block; color: var(--text); margin-bottom: 4px; }
.footer-muted { color: var(--faint); }
.footer-links { display: flex; flex-wrap: wrap; gap: 14px; }
.footer-links a { color: var(--muted); }
.footer-links a:hover { color: var(--accent); }

/* ---------- modal ---------- */

body.modal-open { overflow: hidden; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: clamp(10px, 2vw, 28px);
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 5, 4, 0.82);
  backdrop-filter: blur(10px);
}
[data-theme="amber"] .modal-backdrop { background: rgba(6, 4, 3, 0.84); }
[data-theme="ice"] .modal-backdrop { background: rgba(3, 5, 8, 0.84); }

.modal-panel {
  position: relative;
  width: min(1180px, 96vw);
  outline: none;
  max-height: 92vh;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow), 0 0 0 1px rgba(var(--accent-rgb), 0.08);
  animation: modal-in 180ms ease both;
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(8px) scale(0.995); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-head {
  position: sticky;
  top: 0;
  z-index: 4;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  background: rgba(13, 20, 16, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}
[data-theme="amber"] .modal-head { background: rgba(21, 16, 10, 0.93); }
[data-theme="ice"] .modal-head { background: rgba(13, 18, 24, 0.93); }

.modal-head-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.modal-index { color: var(--accent); font-size: 11px; }
.modal-category { color: var(--faint); font-size: 9px; letter-spacing: 0.1em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-close { border-color: transparent; color: var(--faint); }
.modal-close:hover { border-color: var(--accent); }

.modal-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.8fr);
}
.modal-stage {
  padding: clamp(14px, 2.2vw, 28px);
  border-right: 1px solid var(--line);
  min-width: 0;
}
.modal-frame {
  aspect-ratio: 16 / 9.6;
  min-height: 300px;
  border: 1px solid var(--line);
}
.modal-frame pre { font-size: 16px; }

.frame-hud {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 9px;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  color: var(--faint);
  font-size: 8px;
  letter-spacing: 0.08em;
  pointer-events: none;
  text-shadow: 0 1px 6px var(--bg);
}
.frame-hud-right { display: inline-flex; align-items: center; gap: 6px; color: var(--accent-dim); }
.live-dot { width: 4px; height: 4px; }
.modal-frame.is-paused .live-dot { animation: none; background: var(--faint); box-shadow: none; }
.modal-frame.is-paused .frame-hud-right { color: var(--faint); }

.modal-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.10);
}
.scrub-field {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 220px;
  color: var(--faint);
  font-size: 8px;
  letter-spacing: 0.1em;
}
.scrub-field input { flex: 1; accent-color: var(--accent); min-width: 80px; }
.modal-speed { flex: 0 0 auto; }
.modal-speed input { width: 70px; }

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  text-decoration: none;
}
.action-button:hover { text-decoration: none; }

.modal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 14px;
  color: var(--faint);
  font-size: 9px;
  letter-spacing: 0.08em;
}
.nav-button { flex: 0 0 auto; }

.modal-info {
  padding: clamp(18px, 2.6vw, 32px);
  overflow: auto;
  max-height: calc(92vh - 52px);
}
.modal-info .eyebrow { margin-bottom: 12px; }
.modal-info h2 {
  margin: 0;
  color: var(--text-strong);
  font-size: clamp(26px, 3.4vw, 44px);
  line-height: 1.02;
  letter-spacing: -0.06em;
  font-weight: 500;
}
.modal-zh { margin: 7px 0 0; color: var(--accent-dim); font-size: 12px; }
.modal-summary { margin: 18px 0; color: var(--muted); line-height: 1.9; font-size: 12px; }
.modal-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 18px; }

.modal-meta {
  margin: 0 0 20px;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.modal-meta > div {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 9px 10px;
  min-width: 0;
}
.modal-meta dt { color: var(--faint); font-size: 7px; letter-spacing: 0.13em; }
.modal-meta dd { margin: 3px 0 0; color: var(--text); font-size: 10px; overflow-wrap: anywhere; }

.source-block {
  border-top: 1px solid var(--line);
  padding-top: 16px;
}
.source-title { margin: 0; color: var(--text-strong); font-size: 12px; }
.source-author { margin: 4px 0 9px; color: var(--faint); font-size: 9px; }
.source-adaptation,
.source-notes { margin: 0 0 8px; color: var(--muted); font-size: 10px; line-height: 1.75; }
.source-url { display: inline-block; margin-top: 7px; font-size: 9px; letter-spacing: 0.07em; }

/* ---------- toast / noscript ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 200;
  transform: translate(-50%, 12px);
  background: var(--panel-2);
  border: 1px solid var(--accent-dim);
  color: var(--text-strong);
  padding: 10px 15px;
  font-size: 10px;
  letter-spacing: 0.05em;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
  opacity: 0;
  visibility: hidden;
  transition: opacity 160ms ease, transform 160ms ease, visibility 160ms ease;
  max-width: min(90vw, 560px);
  text-align: center;
}
.toast.is-visible { opacity: 1; visibility: visible; transform: translate(-50%, 0); }

.noscript {
  margin: 20px;
  padding: 16px;
  border: 1px solid var(--line);
  color: var(--muted);
}

/* ---------- loading skeleton ---------- */

.skeleton-card {
  min-height: 360px;
  border: 1px solid var(--line);
  background: linear-gradient(100deg, var(--panel) 20%, var(--panel-2) 40%, var(--panel) 60%);
  background-size: 220% 100%;
  animation: skeleton 1.4s linear infinite;
}
@keyframes skeleton {
  to { background-position: -220% 0; }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

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

@media (max-width: 1080px) {
  .hero { grid-template-columns: 1fr; align-items: start; }
  .hero-panel { max-width: 720px; }
  .hero-frame { min-height: 180px; }
  .controls { align-items: flex-start; flex-direction: column; gap: 12px; }
  .control-right { width: 100%; justify-content: space-between; }
  .modal-grid { grid-template-columns: 1fr; }
  .modal-stage { border-right: 0; border-bottom: 1px solid var(--line); }
  .modal-info { max-height: none; }
}

@media (max-width: 720px) {
  :root { --topbar: 58px; }
  .topbar { padding: 0 14px; gap: 10px; }
  .brand-text { font-size: 11px; }
  .theme-switch button { padding: 6px 7px; font-size: 8px; }
  .theme-switch button:nth-child(2) { display: none; }
  .hero { padding-top: 42px; }
  .hero h1 { font-size: clamp(46px, 14vw, 86px); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .controls { position: static; padding: 12px 14px; }
  .filter-group { gap: 3px; }
  .chip { padding: 6px 7px; font-size: 8px; }
  .control-right { flex-direction: column; align-items: stretch; gap: 10px; }
  .search-field input { width: 100%; }
  .speed-field { justify-content: space-between; }
  .speed-field input[type="range"] { flex: 1; width: auto; }
  .gallery { grid-template-columns: 1fr; padding-left: 14px; padding-right: 14px; }
  .card-actions { opacity: 1; visibility: visible; transform: none; pointer-events: auto; }
  .card-summary { min-height: 0; }
  .about { grid-template-columns: 1fr; padding-left: 14px; padding-right: 14px; }
  .about-grid { grid-template-columns: 1fr; }
  .footer { flex-direction: column; padding-left: 14px; padding-right: 14px; }
  .modal { padding: 0; }
  .modal-panel { width: 100vw; max-height: 100vh; min-height: 100vh; border-left: 0; border-right: 0; }
  .modal-head { padding: 10px 12px; }
  .modal-stage { padding: 12px; }
  .modal-frame { min-height: 220px; }
  .modal-info { padding: 18px 14px 28px; }
  .modal-controls { gap: 9px; }
  .scrub-field { flex-basis: 100%; }
  .modal-speed { width: 100%; justify-content: space-between; }
  .frame-hud { font-size: 7px; }
}

@media (max-width: 430px) {
  .brand-text { font-size: 10px; }
  .ghost-button { padding: 8px 9px; font-size: 9px; }
  .theme-switch { display: flex; }
  .theme-switch button { font-size: 0; letter-spacing: 0; padding: 7px 8px; }
  .theme-switch button:nth-child(2) { display: block; }
  .theme-switch button::after { font-size: 9px; content: "P"; }
  .theme-switch button[data-theme-value="amber"]::after { content: "A"; }
  .theme-switch button[data-theme-value="ice"]::after { content: "I"; }
  .hero-actions { align-items: flex-start; flex-direction: column; gap: 10px; }
  .stats strong { font-size: 20px; }
  .card-title-row { flex-direction: column; align-items: flex-start; gap: 2px; }
  .card-zh { white-space: normal; }
  .modal-actions .action-button { flex: 1 1 44%; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .crt { display: none; }
}
