/* Charcoal / white banded catalog. Cyan actions, a small red accent. */
:root {
  --ink: #141414;
  --ink-2: #1f1f1f;
  --paper: #ffffff;
  --paper-2: #f2f2f2;
  --text: #1a1a1a;
  --text-muted: #555555;
  --text-on-dark: #f5f5f5;
  --muted-on-dark: #b8b8b8;
  --line: #d4d4d4;
  --line-strong: #141414;
  --line-dark: #3a3a3a;
  --cyan: #00d2f2;
  --cyan-text: #0a7d92;
  --cyan-on-dark: #3fe1ff;
  --red: #e3262c;
  --radius: 4px;
  --wrap: 1280px;
  --font: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", "Noto Sans CJK SC", "Source Han Sans SC", system-ui, -apple-system, "Segoe UI", sans-serif;
}

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

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

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
  color: var(--text);
  background: var(--paper);
}

[hidden] { display: none !important; }

img { display: block; max-width: 100%; }

a { color: var(--cyan-text); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--ink); }

h1, h2, h3 { margin: 0; line-height: 1.25; font-weight: 700; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }

:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.band-dark :focus-visible,
.masthead :focus-visible,
.colophon :focus-visible { outline-color: var(--cyan); }

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

.icon {
  width: 1.1em;
  height: 1.1em;
  flex: none;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -0.2em;
}

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------- bands ---------- */
.band { padding: 48px 0; }
.band-light { background: var(--paper); color: var(--text); }
.band-dark { background: var(--ink); color: var(--text-on-dark); }
.band-dark a { color: var(--cyan-on-dark); }
.band-dark a:hover { color: var(--paper); }

.band-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 24px;
  padding-bottom: 16px;
  margin-bottom: 24px;
  border-bottom: 3px solid currentColor;
}
.band-head .btn { margin-left: auto; align-self: center; }
.band-title { font-size: 1.75rem; }
.band-meta { color: var(--text-muted); }
.band-dark .band-meta { color: var(--muted-on-dark); }

.rule-title {
  font-size: 1.25rem;
  padding: 12px 0;
  margin: 40px 0 20px;
  border-top: 3px solid var(--line-strong);
  border-bottom: 1px solid var(--line);
}

/* ---------- buttons / links ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 18px;
  border: 2px solid transparent;
  border-radius: var(--radius);
  font: inherit;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
}
.btn-cyan { background: var(--cyan); color: var(--ink); border-color: var(--cyan); }
.btn-cyan:hover { background: var(--ink); color: var(--cyan); border-color: var(--ink); }
.band-dark .btn-cyan:hover { background: var(--paper); color: var(--ink); border-color: var(--paper); }
.btn-line { background: transparent; color: var(--ink); border-color: var(--ink); }
.btn-line:hover { background: var(--ink); color: var(--paper); }
.btn-onDark,
.band-dark .btn-line { color: var(--paper); border-color: var(--paper); }
.btn-onDark:hover,
.band-dark .btn-line:hover { background: var(--paper); color: var(--ink); }
.btn-lg { min-height: 52px; padding: 10px 26px; font-size: 1.05rem; }
.btn-sm { min-height: 36px; padding: 4px 12px; font-size: 0.9rem; }

.text-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 600;
  min-height: 44px;
}

.cat-mark { font-size: 0.85rem; font-weight: 700; letter-spacing: 0; text-transform: uppercase; }
.cat-mark a {
  display: inline-block;
  padding: 2px 8px;
  border: 1px solid currentColor;
  border-radius: var(--radius);
  color: var(--ink);
  text-decoration: none;
}
.cat-mark a:hover { background: var(--ink); color: var(--paper); }
.band-dark .cat-mark a { color: var(--paper); }
.band-dark .cat-mark a:hover { background: var(--paper); color: var(--ink); }

.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-list li {
  font-size: 0.85rem;
  padding: 2px 8px;
  background: var(--paper-2);
  color: var(--text);
  border-radius: var(--radius);
}
.band-dark .tag-list li { background: var(--ink-2); color: var(--text-on-dark); border: 1px solid var(--line-dark); }

.dot-red {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--red);
  vertical-align: 0.05em;
}

/* ---------- masthead ---------- */
.masthead { background: #000; color: var(--paper); }
.masthead-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 24px;
  min-height: 72px;
  padding-top: 10px;
  padding-bottom: 10px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  color: var(--paper);
  text-decoration: none;
  margin-right: auto;
}
.brand-logo { height: 44px; width: auto; }
.brand-name { font-weight: 700; font-size: 1.05rem; }

.menu-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 6px 12px;
  background: transparent;
  color: var(--paper);
  border: 2px solid var(--paper);
  border-radius: var(--radius);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.menu-toggle .icon { width: 1.4em; height: 1.4em; }
.menu-toggle .icon-close { display: none; }
.menu-toggle[aria-expanded="true"] .icon-menu { display: none; }
.menu-toggle[aria-expanded="true"] .icon-close { display: block; }

.site-menu-list { display: flex; flex-wrap: wrap; gap: 4px; }
.site-menu-list a {
  display: inline-block;
  padding: 10px 14px;
  color: var(--paper);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 3px solid transparent;
}
.site-menu-list a:hover { color: var(--cyan-on-dark); }
.site-menu-list a[aria-current="page"] { border-bottom-color: var(--red); }

/* secondary strip: light, contrasting with the black masthead */
.substrip {
  background: var(--paper-2);
  color: var(--text);
  border-bottom: 1px solid var(--line);
}
.substrip-row {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 48px;
}
.substrip-label { font-size: 0.8rem; font-weight: 700; color: var(--text-muted); flex: none; }
.substrip-list {
  display: flex;
  gap: 4px;
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: thin;
}
.substrip-list a,
.cat-jump a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.substrip-list a:hover,
.cat-jump a:hover { color: var(--cyan-text); }
.substrip-count,
.cat-jump .substrip-count {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0 6px;
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--paper);
}
.substrip-all {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 700;
  color: var(--cyan-text);
  text-decoration: none;
  white-space: nowrap;
}
.substrip-all:hover { color: var(--ink); text-decoration: underline; }

/* ---------- index: lead band ---------- */
.lead-band { padding-top: 32px; }
.lead-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 24px;
  padding-bottom: 14px;
  margin-bottom: 28px;
  border-bottom: 3px solid var(--line-strong);
}
.lead-title { font-size: 1.5rem; }
.lead-kicker { font-weight: 700; }

.lead-spread {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  gap: 32px 48px;
  align-items: start;
}
.lead-media { min-width: 0; }
.lead-cover {
  width: 100%;
  height: auto;
  border-radius: var(--radius);
}
.lead-text { display: grid; gap: 14px; align-content: start; min-width: 0; }
.lead-name { font-size: 2.25rem; line-height: 1.15; overflow-wrap: anywhere; }
.lead-en { font-size: 1.05rem; color: var(--text-muted); overflow-wrap: anywhere; }
.lead-desc { font-size: 1.05rem; white-space: pre-line; overflow-wrap: anywhere; }
.lead-actions { display: flex; flex-wrap: wrap; gap: 12px; padding-top: 6px; }

.cover-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 24px;
}
.cover-strip-item { display: grid; gap: 8px; align-content: start; }
.cover-strip-link { color: var(--text); text-decoration: none; display: grid; gap: 6px; }
.cover-strip-link:hover .cover-strip-name { color: var(--cyan-text); text-decoration: underline; }
.cover-strip-name { font-weight: 700; overflow-wrap: anywhere; }
.cover-strip-en { font-size: 0.85rem; color: var(--text-muted); overflow-wrap: anywhere; }

.cover-thumb {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: contain;
  background: var(--ink-2);
  border-radius: var(--radius);
}

/* ---------- index: catalog band ---------- */
.catalog-rows { border-top: 1px solid var(--line-dark); }
.catalog-row {
  display: grid;
  grid-template-columns: minmax(200px, 1fr) minmax(0, 3fr);
  gap: 16px 32px;
  align-items: center;
  padding: 20px 0;
  border-bottom: 1px solid var(--line-dark);
}
.catalog-row-text { display: grid; gap: 4px; justify-items: start; }
.catalog-row-name { font-size: 1.3rem; }
.catalog-row-name a { color: var(--paper); text-decoration: none; }
.catalog-row-name a:hover { color: var(--cyan-on-dark); text-decoration: underline; }
.catalog-row-count { color: var(--muted-on-dark); }
.catalog-row-covers {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.catalog-row-covers a { display: block; }
.catalog-row-covers .cover-thumb { background: #000; border: 1px solid var(--line-dark); }

/* ---------- index: featured ---------- */
.featured-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 28px 24px;
}
.featured-item { display: grid; gap: 8px; align-content: start; justify-items: start; }
.featured-link { display: block; width: 100%; }
.featured-name { font-size: 1.1rem; overflow-wrap: anywhere; }
.featured-name a { color: var(--text); text-decoration: none; }
.featured-name a:hover { color: var(--cyan-text); text-decoration: underline; }
.featured-en { font-size: 0.85rem; color: var(--text-muted); overflow-wrap: anywhere; }

.guide-band { padding: 32px 0; }
.guide-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; }
.guide-row .btn { margin-left: auto; }

/* ---------- games / category heads ---------- */
.list-head { padding: 32px 0 24px; }
.list-title { font-size: 2rem; }
.list-meta { margin-top: 6px; color: var(--text-muted); }
.list-count { font-weight: 700; color: var(--text); }

.cat-jump {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 3px solid var(--line-strong);
}

/* ---------- games: tools strip ---------- */
.list-tools { padding: 18px 0; }
.tools-form {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 16px 24px;
}
.tools-field { display: grid; gap: 4px; }
.tools-search { flex: 1 1 280px; }
.tools-filter { flex: 0 1 260px; }
.tools-label { font-size: 0.8rem; font-weight: 700; color: var(--muted-on-dark); }
.tools-input-wrap,
.tools-select-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.tools-input-wrap .icon,
.tools-select-wrap .icon {
  position: absolute;
  pointer-events: none;
  color: var(--text-muted);
}
.tools-input-wrap .icon { left: 12px; }
.tools-select-wrap .icon { right: 12px; }
.tools-form input,
.tools-form select {
  width: 100%;
  min-height: 44px;
  padding: 8px 12px 8px 40px;
  font: inherit;
  color: var(--text);
  background: var(--paper);
  border: 2px solid var(--paper);
  border-radius: var(--radius);
}
.tools-form select {
  padding: 8px 40px 8px 12px;
  appearance: none;
  -webkit-appearance: none;
}
.tools-form input:focus,
.tools-form select:focus { border-color: var(--cyan); outline: none; }
.tools-form input:focus-visible,
.tools-form select:focus-visible { outline: 3px solid var(--cyan); outline-offset: 2px; }

.list-empty {
  padding: 24px 0;
  font-weight: 700;
  border-top: 3px solid var(--red);
  border-bottom: 1px solid var(--line);
}

/* ---------- games: alternating rows ---------- */
.list-band { padding-top: 8px; }
.game-flow { display: grid; }
.game-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 24px 48px;
  align-items: start;
  padding: 40px 0;
  border-bottom: 1px solid var(--line);
  scroll-margin-top: 16px;
}
.game-row:first-child { border-top: 3px solid var(--line-strong); }
.game-row:target { border-left: 4px solid var(--red); padding-left: 20px; }
.game-row.is-flip .game-row-media { order: 2; }
.game-row-media { min-width: 0; }
.game-cover {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: contain;
  background: var(--ink-2);
  border-radius: var(--radius);
}
.game-row-text { display: grid; gap: 12px; align-content: start; min-width: 0; }
.game-row-top { display: flex; align-items: center; gap: 12px; }
.game-index { font-size: 0.85rem; font-weight: 700; color: var(--red); font-variant-numeric: tabular-nums; }
.game-name { font-size: 1.75rem; overflow-wrap: anywhere; }
.game-en { color: var(--text-muted); overflow-wrap: anywhere; }
.game-desc { white-space: pre-line; overflow-wrap: anywhere; }
.game-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; padding-top: 4px; }

/* ---------- category page ---------- */
.cat-band { scroll-margin-top: 16px; }
.cat-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 24px 32px;
}
.cat-item {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}
.band-dark .cat-item { border-bottom-color: var(--line-dark); }
.cat-item-cover { display: block; }
.cat-item-text { display: grid; gap: 6px; justify-items: start; }
.cat-item-name { font-size: 1.1rem; overflow-wrap: anywhere; }
.cat-item-name a { color: inherit; text-decoration: none; }
.cat-item-name a:hover { text-decoration: underline; }
.cat-item-en { font-size: 0.85rem; color: var(--text-muted); overflow-wrap: anywhere; }
.band-dark .cat-item-en { color: var(--muted-on-dark); }

/* ---------- supporting sheets ---------- */
.sheet-head { padding: 36px 0; border-bottom: 6px solid var(--cyan); }
.sheet-title { font-size: 2rem; }
.sheet-lede { margin-top: 10px; max-width: 70ch; color: var(--muted-on-dark); }

.sheet-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 32px;
}
.sheet-index {
  padding-bottom: 20px;
  border-bottom: 3px solid var(--line-strong);
}
.sheet-index-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.sheet-index-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  counter-reset: sheet;
}
.sheet-index-list li { counter-increment: sheet; }
.sheet-index-list li::before {
  content: counter(sheet, decimal-leading-zero);
  margin-right: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--red);
}
.sheet-index-list a { font-weight: 600; color: var(--text); }
.sheet-index-list a:hover { color: var(--cyan-text); }

.sheet-body { max-width: 78ch; }
.sheet-body > * + * { margin-top: 16px; }
.sheet-body > .sheet-h2 {
  font-size: 1.5rem;
  padding: 14px 0 10px;
  margin-top: 40px;
  border-top: 3px solid var(--line-strong);
  border-bottom: 1px solid var(--line);
  scroll-margin-top: 16px;
}
.sheet-body > .sheet-h2:first-child { margin-top: 0; }
.sheet-body > .sheet-h3 {
  font-size: 1.15rem;
  padding-left: 12px;
  margin-top: 28px;
  border-left: 4px solid var(--cyan);
  scroll-margin-top: 16px;
}
.sheet-p { overflow-wrap: anywhere; }
.sheet-list { padding-left: 1.4em; list-style: disc; }
.sheet-list-ordered { list-style: decimal; }
.sheet-list li { margin: 6px 0; overflow-wrap: anywhere; }
.sheet-body code {
  font-family: ui-monospace, "Cascadia Mono", Consolas, "Courier New", monospace;
  font-size: 0.92em;
  padding: 1px 6px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

/* ---------- footer ---------- */
.colophon { background: #000; color: var(--paper); border-top: 6px solid var(--cyan); }
.colophon-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px 40px;
  padding-top: 32px;
  padding-bottom: 32px;
}
.colophon-name { font-weight: 700; font-size: 1.1rem; }
.colophon-meta { color: var(--muted-on-dark); }
.colophon-nav ul { display: flex; flex-wrap: wrap; gap: 4px 8px; }
.colophon-nav a {
  display: inline-block;
  padding: 8px 10px;
  color: var(--paper);
  font-weight: 600;
  text-decoration: none;
}
.colophon-nav a:hover { color: var(--cyan-on-dark); text-decoration: underline; }

/* ---------- responsive ---------- */
@media (min-width: 900px) {
  .sheet-grid { grid-template-columns: 220px minmax(0, 1fr); align-items: start; }
  .sheet-index { position: static; border-bottom: 0; border-right: 3px solid var(--line-strong); padding: 0 20px 0 0; }
  .sheet-index-list { flex-direction: column; gap: 6px; }
}

@media (max-width: 899px) {
  .lead-spread { grid-template-columns: minmax(0, 1fr); }
  .lead-name { font-size: 1.75rem; }
  .catalog-row { grid-template-columns: minmax(0, 1fr); }
  .catalog-row-covers { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 767px) {
  .band { padding: 32px 0; }
  .wrap { padding: 0 16px; }
  .brand-name { display: none; }
  .brand-logo { height: 38px; }

  .masthead-row { flex-wrap: wrap; }
  .menu-toggle { margin-left: auto; }
  .site-menu { flex-basis: 100%; }
  .js .site-menu:not(.is-open) { display: none; }
  .site-menu-list { flex-direction: column; gap: 0; border-top: 1px solid var(--line-dark); padding-top: 8px; }
  .site-menu-list a { display: block; padding: 12px 4px; border-bottom: 0; border-left: 3px solid transparent; padding-left: 10px; }
  .site-menu-list a[aria-current="page"] { border-left-color: var(--red); }

  .game-row { grid-template-columns: minmax(0, 1fr); gap: 16px; padding: 28px 0; }
  .game-row.is-flip .game-row-media { order: 0; }
  .game-row:target { padding-left: 12px; }
  .game-name { font-size: 1.4rem; }
  .catalog-row-covers { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cat-list { grid-template-columns: minmax(0, 1fr); }
  .cat-item { grid-template-columns: 110px minmax(0, 1fr); }
  .band-head .btn,
  .guide-row .btn { margin-left: 0; flex-basis: 100%; justify-content: center; }
  .band-title { font-size: 1.4rem; }
  .list-title, .sheet-title { font-size: 1.6rem; }
  .sheet-h2 { font-size: 1.3rem; }
  .cover-strip { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 16px; }
}

@media (min-width: 768px) {
  .menu-toggle { display: none; }
  .site-menu { display: block; }
}

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

/* ---------- protected handoff: VR signal calibration dialog ---------- */
/* Squared charcoal panel, cyan rule under the head, red status detail.
   Built by site.js on demand, so it exists on every page with a gate link. */
.gate {
  width: min(680px, calc(100vw - 32px));
  max-width: none;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--text);
  overflow: hidden;
}
.gate::backdrop { background: rgba(0, 0, 0, 0.78); }
.gate[open] { animation: gate-enter 140ms ease-out; }
@keyframes gate-enter {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
html.gate-open,
html.gate-open body { overflow: hidden; }

.gate-panel {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  max-height: calc(100vh - 38px);
  max-height: calc(100dvh - 38px);
}

.gate-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 10px 16px;
  padding: 14px 16px;
  background: var(--ink);
  color: var(--text-on-dark);
  border-bottom: 3px solid var(--cyan);
}
.gate-head-text { flex: 1 1 200px; min-width: 0; margin-right: auto; }
.gate-kicker {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-on-dark);
}
.gate-title { font-size: 1.3rem; color: var(--paper); margin-top: 2px; }
.gate-lede { margin-top: 6px; font-size: 0.9rem; color: var(--muted-on-dark); }

.gate-rail { display: flex; align-self: center; gap: 4px; }
.gate-rail li {
  padding: 5px 7px;
  font-family: ui-monospace, "Cascadia Mono", Consolas, "Courier New", monospace;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.1em;
  color: var(--muted-on-dark);
  background: var(--ink-2);
  border: 1px solid var(--line-dark);
  border-radius: var(--radius);
}
.gate-rail li:first-child,
.gate-rail li:last-child { color: var(--cyan-on-dark); border-color: var(--cyan-text); }

.gate-close {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  background: transparent;
  color: var(--paper);
  border: 2px solid var(--line-dark);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
}
.gate-close:hover { background: var(--paper); color: var(--ink); border-color: var(--paper); }
.gate-close .icon { width: 1.3em; height: 1.3em; vertical-align: 0; }

.gate-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  background: var(--paper);
}
.gate-frame {
  display: block;
  width: 100%;
  height: clamp(260px, 48vh, 440px);
  border: 0;
  background: var(--paper);
}
.gate-veil {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px;
  text-align: center;
  background: var(--paper);
}
.gate[data-state="loading"] .gate-veil,
.gate[data-state="error"] .gate-veil { display: flex; }
.gate-veil-text { font-weight: 700; font-size: 0.95rem; }
.gate[data-state="error"] .gate-veil-text { color: var(--red); }
.gate-scan {
  position: relative;
  width: 160px;
  max-width: 60%;
  height: 6px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  overflow: hidden;
}
.gate-scan::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: -40%;
  width: 40%;
  background: var(--cyan);
  animation: gate-scan 1100ms linear infinite;
}
.gate[data-state="error"] .gate-scan::after {
  left: 0;
  width: 100%;
  background: var(--red);
  animation: none;
}
@keyframes gate-scan {
  from { left: -40%; }
  to { left: 100%; }
}

.gate-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  padding: 12px 16px;
  background: var(--paper-2);
  border-top: 3px solid var(--line-strong);
}
.gate-status { flex: 1 1 200px; min-width: 0; font-size: 0.9rem; color: var(--text-muted); }
.gate[data-state="error"] .gate-status { color: var(--red); font-weight: 700; }
.gate[data-state="done"] .gate-status { color: var(--cyan-text); font-weight: 700; }
.gate-foot .btn { flex: none; }

@media (max-width: 520px) {
  .gate { width: calc(100vw - 16px); }
  .gate-head { padding: 12px; }
  .gate-title { font-size: 1.1rem; }
  .gate-lede { font-size: 0.85rem; }
  .gate-rail { order: 3; align-self: flex-start; }
  .gate-frame { height: clamp(240px, 52vh, 420px); }
  .gate-foot { padding: 10px 12px; }
  .gate-foot .btn { flex: 1 1 100%; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  .gate[open] { animation: none; }
  .gate-scan::after { left: 0; width: 100%; animation: none; }
}
