/* ==========================================================================
   模型图库 - 页面样式（index 与 viewer 共用）
   加载顺序契约：/css/tokens.css → /css/frame.css → 本文件（页面样式最后，
   只管页面内容，不碰站点头/页脚）。所有颜色/字号/间距/圆角/动效一律消费
   全局 design tokens，且逐条带契约值 fallback —— 即使本目录被单独部署、
   tokens.css/frame.css 缺席（404），页面也不会裸奔。
   注意：本文件不定义任何 :root 变量，避免后加载覆盖 tokens。
   Obys 契约：页面 chrome 是暖纸白（--surface 白面板 + 墨字 + hairline 边框
   + 唯一橙红点缀）；查看器画布保持墨黑媒体块（viewer.js 的
   scene.background）。悬在墨黑画布上的浮层一律实心 --surface 白板 —— 半透
   明纸玻璃会压低墨底亮度，令 --text-dim/--accent-dim 小字跌出 4.5:1。
   ========================================================================== */

/* ---- 基础 ---------------------------------------------------------------- */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg, #F2F0EA);
  color: var(--text, #141414);
  font-family: var(--font-sans, system-ui, -apple-system, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif);
  line-height: var(--leading-body, 1.6);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-dim, #C93D02); text-decoration: none; }
button { font-family: inherit; }

.hidden { display: none !important; }

/* ---------- Pin-screen hero (Obys project-page layout) ----------------------
   Left paper half: mono site mark on the left edge, a centered info column,
   "Back" at bottom-left. Right ink half: a vertical cover strip whose
   translateY is scroll-driven by the inline script in index.html
   (lerp sp += (p - sp) * 0.09); this file only authors the static shape.
   With JS absent or reduced motion requested the strip rests at
   translateY(0) and the hero reads as two static slabs.
   <768px: halves stack vertically, brackets hide, strip shows all covers. */

.hero {
  position: relative;
  display: flex;
  height: 100vh; /* hard height: the ink-side strip is taller than the slab on purpose */
  height: 100svh;
  background: var(--bg, #F2F0EA);
}

/* Left half: warm paper ------------------------------------------------------ */

.hero-left {
  position: relative;
  width: 50%;
  display: flex;
  align-items: center;
}

.hero-eyebrow {
  position: absolute;
  top: 50%;
  left: var(--space-4, 1rem);
  transform: translateY(-50%);
  margin: 0;
  font-family: var(--font-mono, ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace);
  font-size: var(--text-xs, 0.75rem);
  line-height: var(--leading-mono, 1.5);
  color: var(--text, #141414);
}

.hero-info {
  margin-left: clamp(7.5rem, 34%, 16rem);
  padding-right: var(--space-4, 1rem);
}

.hero-cat {
  margin: 0;
  font-size: var(--text-base, 1rem);
  font-weight: 600;
  line-height: var(--leading-tight, 1.2);
}

.hero-credits {
  margin: var(--space-1, 0.25rem) 0 0;
  font-family: var(--font-mono, ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace);
  font-size: var(--text-xs, 0.75rem);
  line-height: var(--leading-mono, 1.5);
  color: var(--text-dim, #6B675E);
}

/* Obys underlined link: ink by default (underline carries the affordance),
   orange-red hover (--accent-dim keeps 4.4:1 at body size) */
.hero-cta {
  display: inline-block;
  margin-top: var(--space-6, 1.5rem);
  padding-bottom: 2px;
  border-bottom: 1px solid currentColor;
  color: var(--text, #141414);
  font-size: var(--text-base, 1rem);
  font-weight: 600;
  line-height: var(--leading-tight, 1.2);
  transition: color var(--dur-fast, 120ms) var(--ease-out, cubic-bezier(0.22, 1, 0.36, 1));
}

.hero-cta:hover { color: var(--accent-dim, #C93D02); }

.hero-back {
  position: absolute;
  left: var(--space-4, 1rem);
  bottom: var(--space-4, 1rem);
  font-family: var(--font-mono, ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace);
  font-size: var(--text-xs, 0.75rem);
  line-height: var(--leading-mono, 1.5);
  color: var(--text-dim, #6B675E); /* 4.9:1 on --bg — essential nav keeps AA */
  transition: color var(--dur-fast, 120ms) var(--ease-out, cubic-bezier(0.22, 1, 0.36, 1));
}

.hero-back:hover { color: var(--text, #141414); }

/* Right half: ink slab + vertical cover strip -------------------------------- */

.hero-right {
  width: 50%;
  display: flex;
  justify-content: center;
  overflow: hidden; /* strip is taller than the slab; the script shifts it */
  background: var(--text, #141414);
}

.hero-strip {
  width: clamp(240px, 26vw, 420px);
  display: flex;
  flex-direction: column;
  gap: var(--space-2, 0.5rem); /* 8px per spec */
  will-change: transform; /* rAF loop writes transform every frame */
}

.hero-shot {
  display: block;
  transition: opacity var(--dur-base, 180ms) var(--ease-out, cubic-bezier(0.22, 1, 0.36, 1));
}

.hero-shot img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1; /* covers are 720x720 squares */
  object-fit: cover;
  outline: 1px solid rgba(255, 255, 255, .12); /* pure-white hairline on ink */
  outline-offset: -1px;
  transition: opacity var(--dur-slow, 320ms) var(--ease-out, cubic-bezier(0.22, 1, 0.36, 1));
}

/* Hover/focus the strip: the current shot reads full, neighbours dim to 0.45. */
@media (hover: hover) {
  .hero-strip:hover .hero-shot,
  .hero-strip:focus-within .hero-shot { opacity: 0.45; }

  .hero-strip:hover .hero-shot:hover,
  .hero-strip .hero-shot:focus-visible { opacity: 1; }
}

/* Giant display brackets astride the 50% seam: "(" inks on paper,
   ")" papers on ink. Pure chrome: no pointer events, not selectable. */

.hero-brackets {
  position: absolute;
  z-index: 2;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: inline-flex;
  gap: 0.05em;
  font-family: var(--font-display, "Archivo Black", "Arial Black", "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif);
  font-size: 30vh;
  line-height: 1;
  pointer-events: none;
  user-select: none;
}

.hero-brackets span:first-child { color: var(--text, #141414); }

.hero-brackets span:last-child { color: var(--bg, #F2F0EA); }

/* <768px: halves stack, brackets hide, strip shows all four covers */

@media (max-width: 767.98px) {
  .hero { flex-direction: column; height: auto; } /* stacked slabs flow naturally */

  .hero-left {
    width: 100%;
    min-height: 72vh;
    min-height: 72svh;
    display: block;
    padding: var(--space-8, 2rem) var(--space-4, 1rem) var(--space-16, 4rem);
  }

  .hero-eyebrow { position: static; transform: none; }

  .hero-info { margin: var(--space-12, 3rem) 0 0; padding-right: 0; }

  .hero-brackets { display: none; }

  .hero-right { width: 100%; padding: var(--space-16, 4rem) 0; overflow: visible; }
}

/* ---------- 目录页 --------------------------------------------------------- */

.page-header {
  max-width: var(--container-max, 1140px);
  margin: 0 auto;
  padding: var(--space-8, 2rem) var(--space-4, 1rem) 0;
}

.page-header h1 {
  margin: 0;
  font-size: var(--text-h1, clamp(1.5625rem, 1.39rem + 0.77vw, 1.9375rem));
  font-weight: 700;
  line-height: var(--leading-tight, 1.2);
}

.page-header .stats {
  margin-top: var(--space-2, 0.5rem);
  color: var(--text-dim, #6B675E);
  font-family: var(--font-mono, ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace);
  font-size: var(--text-xs, 0.75rem);
  line-height: var(--leading-mono, 1.5);
}

/* 卡片网格：手机 1 列 / >=640px 2 列 / >=1024px 3 列（对齐站点规范） */

.grid {
  max-width: var(--container-max, 1140px);
  margin: var(--space-6, 1.5rem) auto var(--space-16, 4rem);
  padding: 0 var(--space-4, 1rem);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-6, 1.5rem);
}

/* frame.css 的 .grid 是 12 列布局网格并强令子项跨全行；此处是卡片网格，解除它 */
.grid > * { grid-column: auto; }

@media (min-width: 640px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 720px) {
  .page-header { padding-inline: var(--space-6, 1.5rem); }
  .grid { padding-inline: var(--space-6, 1.5rem); }
}

@media (min-width: 1024px) {
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.card {
  display: flex;
  flex-direction: column;
  background: var(--surface-2, #EAE6DC);
  border: 1px solid var(--border-color, #D9D5CA);
  border-radius: var(--radius, 0);
  overflow: hidden;
  color: var(--text, #141414);
  transition:
    transform var(--dur-base, 180ms) var(--ease-out, cubic-bezier(0.22, 1, 0.36, 1)),
    border-color var(--dur-fast, 120ms) var(--ease-out, cubic-bezier(0.22, 1, 0.36, 1));
}

/* hover 抬升 -4px / 180ms；仅限有指针的设备，触屏禁用。按压回落 -1px */
@media (hover: hover) {
  .card:hover {
    transform: translateY(-4px);
    border-color: var(--border-strong, #141414); /* Obys hover：黑描边 */
  }

  .card:active {
    transform: translateY(-1px);
  }
}

.thumb {
  position: relative;
  aspect-ratio: 4 / 3; /* 预留比例防加载抖动，与 600x450 封面一致 */
  background: linear-gradient(160deg, var(--surface-2, #EAE6DC) 0%, var(--bg, #F2F0EA) 100%);
  overflow: hidden;
}

.thumb .poster,
.thumb .cover-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* 有 src 但未解出首帧的 video 会画黑块，故起播前保持透明露出海报 */
.thumb .cover-video { z-index: 2; opacity: 0; transition: opacity var(--dur-slow, 320ms) var(--ease-out, cubic-bezier(0.22, 1, 0.36, 1)); }
.thumb .cover-video.ready { opacity: 1; }

.placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint, #807a67);
}

.placeholder svg { width: 46px; height: 46px; opacity: .8; }

.badges {
  position: absolute;
  z-index: 3;
  top: var(--space-2, 0.5rem);
  left: var(--space-2, 0.5rem);
  right: var(--space-2, 0.5rem);
  display: flex;
  gap: var(--space-1, 0.25rem);
  flex-wrap: wrap;
  pointer-events: none;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1, 0.25rem);
  padding: var(--space-1, 0.25rem) var(--space-2, 0.5rem);
  border-radius: var(--radius-sm, 0);
  font-family: var(--font-mono, ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace);
  font-size: var(--text-xs, 0.75rem);
  font-weight: 600;
  line-height: var(--leading-mono, 1.5);
  background: rgba(242, 240, 234, .92); /* --bg #F2F0EA 的半透明版（0.92 保证墨字在深色封面上仍 >= 4.5:1） */
  border: 1px solid rgba(20, 20, 20, .16); /* --text #141414 的半透明版 */
  color: var(--text, #141414);
  backdrop-filter: blur(6px);
}

/* "官方" = 状态印章：唯一强调色，实心 --accent-dim 底 + 白字（5.1:1），
   不受下方封面图明暗影响 */
.badge.official {
  background: var(--accent-dim, #C93D02);
  border-color: var(--accent-dim, #C93D02);
  color: var(--on-accent, #FFFFFF);
}

.badge.clips { color: var(--text-dim, #6B675E); }

.badge.nomodel { color: var(--text-faint, #807a67); border-style: dashed; }

.card .meta {
  padding: var(--space-3, 0.75rem) var(--space-4, 1rem);
}

.card .title {
  font-size: var(--text-base, 1rem);
  font-weight: 600;
  line-height: var(--leading-tight, 1.2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card .sub {
  margin-top: var(--space-1, 0.25rem);
  font-family: var(--font-mono, ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace);
  font-size: var(--text-xs, 0.75rem);
  line-height: var(--leading-mono, 1.5);
  color: var(--text-dim, #6B675E);
}

/* 空态 / 错误态（目录页） */

.empty {
  width: min(460px, calc(100% - var(--space-8, 2rem)));
  max-width: 460px;
  margin: var(--space-16, 4rem) auto 0;
  padding: var(--space-8, 2rem);
  text-align: center;
  background: var(--surface-2, #EAE6DC);
  border: 1px dashed var(--border-color, #D9D5CA);
  border-radius: var(--radius, 0);
}

.empty .icon { color: var(--text-faint, #807a67); margin-bottom: var(--space-3, 0.75rem); }
.empty .icon svg { width: 52px; height: 52px; }

.empty h2 {
  margin: 0 0 var(--space-2, 0.5rem);
  font-size: var(--text-md, 1.25rem);
  line-height: var(--leading-tight, 1.2);
}

.empty p {
  margin: 0 0 var(--space-4, 1rem);
  font-size: var(--text-base, 1rem);
  line-height: var(--leading-body, 1.6);
  color: var(--text-dim, #6B675E);
}

.btn {
  display: inline-block;
  padding: var(--space-2, 0.5rem) var(--space-4, 1rem);
  border-radius: var(--radius, 0);
  border: 1px solid var(--accent-dim, #C93D02);
  background: transparent;
  color: var(--accent-dim, #C93D02); /* 4.4:1 on --bg；--accent 仅限展示级 */
  font-size: var(--text-base, 1rem);
  font-weight: 600;
  cursor: pointer;
  transition:
    background var(--dur-fast, 120ms) var(--ease-out, cubic-bezier(0.22, 1, 0.36, 1)),
    color var(--dur-fast, 120ms) var(--ease-out, cubic-bezier(0.22, 1, 0.36, 1)),
    scale var(--dur-fast, 120ms) var(--ease-out, cubic-bezier(0.22, 1, 0.36, 1));
}

/* hover 反转为实心橙红底 + 白字（5.1:1），印刷式的状态确认 */
.btn:hover {
  background: var(--accent-dim, #C93D02);
  color: var(--on-accent, #FFFFFF);
}

.btn:active,
#chips .chip:active { scale: 0.96; }

.btn.ghost {
  border-color: var(--border-color, #D9D5CA);
  background: transparent;
  color: var(--text-dim, #6B675E);
}

.btn.ghost:hover { border-color: var(--border-strong, #141414); color: var(--text, #141414); }

/* ---------- 查看器 --------------------------------------------------------- */

#stage {
  position: fixed;
  inset: 0;
  background: var(--bg, #F2F0EA);
  overflow: hidden;
}

#canvasWrap {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity var(--dur-slow, 320ms) var(--ease-out, cubic-bezier(0.22, 1, 0.36, 1));
  pointer-events: none; /* 加载中不允许操作不可见画布 */
}

#canvasWrap.show { opacity: 1; pointer-events: auto; }

#c { width: 100%; height: 100%; display: block; touch-action: none; }

/* 封面层：进入立即显示，加载完成后淡出 */

#cover {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 42%, var(--surface, #FFFFFF) 0%, var(--bg, #F2F0EA) 72%);
  opacity: 1;
  transition: opacity var(--dur-slow, 320ms) var(--ease-out, cubic-bezier(0.22, 1, 0.36, 1));
  pointer-events: none;
}

#cover.hide { opacity: 0; }

#cover img,
#cover video {
  max-width: min(86vw, 900px);
  max-height: 72vh;
  object-fit: contain;
  border-radius: var(--radius-lg, 2px); /* 大预览媒体，允许 rare 的 radius-lg */
  box-shadow: 0 18px 60px rgba(0, 0, 0, .3);
}

#cover .placeholder svg { width: 72px; height: 72px; color: var(--text-faint, #807a67); }

/* 加载进度卡（机器语音：等宽字体）。实心 --surface 白板悬在墨黑画布上 */

#progressCard {
  position: fixed;
  z-index: 30;
  top: var(--space-4, 1rem);
  right: var(--space-4, 1rem);
  width: min(320px, calc(100vw - var(--space-8, 2rem)));
  padding: var(--space-3, 0.75rem) var(--space-4, 1rem);
  background: var(--surface, #FFFFFF);
  border: 1px solid var(--border-strong, #141414);
  border-radius: var(--radius, 0);
  box-shadow: 0 10px 34px rgba(0, 0, 0, .2);
  transition:
    opacity var(--dur-slow, 320ms) var(--ease-out, cubic-bezier(0.22, 1, 0.36, 1)),
    transform var(--dur-slow, 320ms) var(--ease-out, cubic-bezier(0.22, 1, 0.36, 1));
}

#progressCard.done {
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
}

#progressCard .pc-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-2, 0.5rem);
  margin-bottom: var(--space-2, 0.5rem);
}

#progressCard .pc-name {
  font-family: var(--font-mono, ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace);
  font-size: var(--text-base, 1rem);
  font-weight: 600;
  line-height: var(--leading-mono, 1.5);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#progressCard .pc-pct {
  font-family: var(--font-mono, ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace);
  font-size: var(--text-md, 1.25rem);
  font-weight: 700;
  color: var(--accent-dim, #C93D02); /* 5.1:1 on --surface */
  font-variant-numeric: tabular-nums;
}

#progressCard .pc-bar {
  height: 10px;
  border-radius: var(--radius-sm, 0);
  background: var(--bg, #F2F0EA);
  border: 1px solid var(--border-color, #D9D5CA);
  overflow: hidden;
}

#progressCard .pc-fill {
  height: 100%;
  width: 0;
  border-radius: var(--radius-sm, 0);
  background: var(--accent, #FF4D00); /* 唯一点缀色的进度条，配 --accent-dim 百分比文字 */
  transition: width var(--dur-fast, 120ms) linear;
}

#progressCard .pc-fill.indet {
  width: 36%;
  animation: indet 1.1s ease-in-out infinite alternate;
}

@keyframes indet {
  from { margin-left: 0; }
  to { margin-left: 64%; }
}

#progressCard .pc-meta {
  display: flex;
  justify-content: space-between;
  gap: var(--space-2, 0.5rem);
  margin-top: var(--space-2, 0.5rem);
  font-family: var(--font-mono, ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace);
  font-size: var(--text-xs, 0.75rem);
  line-height: var(--leading-mono, 1.5);
  color: var(--text-dim, #6B675E);
  font-variant-numeric: tabular-nums;
}

#progressCard .pc-phase { color: var(--text-dim, #6B675E); }

/* 左上返回 / 右上信息。实心白板悬在墨黑画布上 */

.back-link {
  position: fixed;
  z-index: 40;
  top: var(--space-4, 1rem);
  left: var(--space-4, 1rem);
  display: inline-flex;
  align-items: center;
  gap: var(--space-1, 0.25rem);
  padding: var(--space-2, 0.5rem) var(--space-3, 0.75rem);
  border-radius: var(--radius-sm, 0);
  background: var(--surface, #FFFFFF);
  border: 1px solid var(--border-color, #D9D5CA);
  color: var(--text, #141414);
  font-family: var(--font-mono, ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace);
  font-size: var(--text-base, 1rem);
  line-height: var(--leading-mono, 1.5);
  transition:
    border-color var(--dur-fast, 120ms) var(--ease-out, cubic-bezier(0.22, 1, 0.36, 1)),
    color var(--dur-fast, 120ms) var(--ease-out, cubic-bezier(0.22, 1, 0.36, 1));
}

.back-link:hover {
  border-color: var(--border-strong, #141414); /* Obys hover：黑描边 */
  color: var(--accent-dim, #C93D02);
}

#hud {
  position: fixed;
  z-index: 40;
  top: var(--space-4, 1rem);
  right: var(--space-4, 1rem);
  max-width: min(46vw, 420px);
  padding: var(--space-2, 0.5rem) var(--space-4, 1rem);
  border-radius: var(--radius-sm, 0);
  background: var(--surface, #FFFFFF);
  border: 1px solid var(--border-color, #D9D5CA);
  font-family: var(--font-mono, ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace);
  font-size: var(--text-xs, 0.75rem);
  line-height: var(--leading-mono, 1.5);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#hud .dim { color: var(--text-dim, #6B675E); font-weight: 500; }

/* 动画 chips */

#chips {
  position: fixed;
  z-index: 40;
  bottom: max(var(--space-4, 1rem), env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: var(--space-1, 0.25rem);
  max-width: min(92vw, 860px);
  padding: var(--space-1, 0.25rem);
  overflow-x: auto;
  background: var(--surface, #FFFFFF);
  border: 1px solid var(--border-color, #D9D5CA);
  border-radius: var(--radius-sm, 0);
  scrollbar-width: none;
}

#chips::-webkit-scrollbar { display: none; }

#chips .chip {
  flex: 0 0 auto;
  padding: var(--space-1, 0.25rem) var(--space-3, 0.75rem);
  border-radius: var(--radius-sm, 0);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-dim, #6B675E);
  font-family: var(--font-mono, ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace);
  font-size: var(--text-xs, 0.75rem);
  line-height: var(--leading-mono, 1.5);
  font-weight: 600;
  cursor: pointer;
  transition:
    color var(--dur-fast, 120ms) var(--ease-out, cubic-bezier(0.22, 1, 0.36, 1)),
    background var(--dur-fast, 120ms) var(--ease-out, cubic-bezier(0.22, 1, 0.36, 1)),
    scale var(--dur-fast, 120ms) var(--ease-out, cubic-bezier(0.22, 1, 0.36, 1));
  white-space: nowrap;
}

#chips .chip:hover { color: var(--text, #141414); }

/* 激活 = 墨底 + 橙红字（5.5:1），与骑士页 kbtn.is-active 同一语言 */
#chips .chip.on {
  background: var(--text, #141414);
  border-color: var(--text, #141414);
  color: var(--accent, #FF4D00);
}

/* 查看器覆盖态：无模型 / 加载失败 */

.viewer-overlay {
  position: fixed;
  z-index: 50;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(400px, calc(100vw - var(--space-8, 2rem)));
  padding: var(--space-6, 1.5rem);
  text-align: center;
  background: var(--surface, #FFFFFF);
  border: 1px solid var(--border-color, #D9D5CA);
  border-radius: var(--radius, 0);
  box-shadow: 0 16px 50px rgba(0, 0, 0, .25);
}

.viewer-overlay .icon { color: var(--text-faint, #807a67); margin-bottom: var(--space-2, 0.5rem); }
.viewer-overlay .icon svg { width: 48px; height: 48px; }

.viewer-overlay h2 {
  margin: 0 0 var(--space-2, 0.5rem);
  font-size: var(--text-md, 1.25rem);
  line-height: var(--leading-tight, 1.2);
}

.viewer-overlay p {
  margin: 0 0 var(--space-4, 1rem);
  font-size: var(--text-base, 1rem);
  line-height: var(--leading-body, 1.6);
  color: var(--text-dim, #6B675E);
  word-break: break-all;
}

.viewer-overlay .row { display: flex; gap: var(--space-2, 0.5rem); justify-content: center; flex-wrap: wrap; }

/* 错误/危险语义色：tokens.css 未定义 --danger，恒走 fallback；全局仅此处允许红。
   #C53030 在白底上 4.97:1（旧 #ff5d5d 只有 2.5:1，纸白上不可读） */
.viewer-overlay .btn.danger {
  border-color: var(--danger, #C53030);
  background: rgba(197, 48, 48, .10);
  color: var(--danger, #C53030);
}

.viewer-overlay .btn.danger:hover {
  background: var(--danger, #C53030);
  color: var(--on-accent, #FFFFFF);
}

/* ---------- 移动端 --------------------------------------------------------- */

@media (max-width: 600px) {
  .back-link {
    top: var(--space-3, 0.75rem);
    left: var(--space-3, 0.75rem);
    padding: var(--space-1, 0.25rem) var(--space-2, 0.5rem);
    font-size: var(--text-xs, 0.75rem);
  }
  #hud { top: var(--space-3, 0.75rem); right: var(--space-3, 0.75rem); max-width: calc(100vw - 132px); }
  #progressCard { top: var(--space-16, 4rem); right: var(--space-3, 0.75rem); width: calc(100vw - var(--space-6, 1.5rem)); }
  #chips { max-width: calc(100vw - var(--space-4, 1rem)); }
}

/* ---------- 独立部署兜底 ------------------------------------------------------
   与 tokens.css 末尾两条全局 a11y 规则逐字相同：tokens.css 在位时声明一致、
   不构成覆盖；tokens.css 缺席（本目录单独预览）时键盘焦点环与 reduced-motion
   仍然生效。 */
:focus-visible {
  outline: 2px solid var(--accent, #FF4D00);
  outline-offset: 2px;
}

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