:root {
  color-scheme: dark;
  --bg: oklch(0.075 0 0);
  --surface: oklch(0.135 0.018 230);
  --surface-2: oklch(0.185 0.026 230);
  --surface-3: oklch(0.245 0.032 230);
  --surface-wash: oklch(0.105 0.016 230);
  --ink: oklch(0.925 0.018 230);
  --muted: oklch(0.705 0.026 230);
  --muted-2: oklch(0.58 0.028 230);
  --primary: oklch(0.56 0.12 230);
  --primary-bright: oklch(0.72 0.14 230);
  --accent: oklch(0.78 0.16 155);
  --warning: oklch(0.72 0.13 55);
  --danger: oklch(0.64 0.15 20);
  --line: oklch(0.31 0.03 230);
  --line-soft: oklch(0.24 0.022 230);
  --shadow: rgb(0 0 0 / 0.24);
  --max: 1440px;
  --radius: 12px;
  --font-body:
    "SF Pro Text",
    "PingFang SC",
    "Hiragino Sans GB",
    "Microsoft YaHei UI",
    "Microsoft YaHei",
    "Noto Sans CJK SC",
    "Source Han Sans SC",
    system-ui,
    sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(110deg, color-mix(in oklch, var(--primary) 7%, transparent), transparent 34%),
    linear-gradient(250deg, color-mix(in oklch, var(--accent) 5%, transparent), transparent 42%),
    var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  letter-spacing: 0;
  line-height: 1.72;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

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

figure {
  margin: 0;
}

.skip-link {
  position: fixed;
  left: 16px;
  top: 12px;
  z-index: 30;
  transform: translateY(-160%);
  border-radius: 999px;
  background: var(--accent);
  color: var(--bg);
  padding: 8px 14px;
  font-weight: 760;
  transition: transform 160ms var(--ease-out);
}

.skip-link:focus {
  transform: translateY(0);
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(180px, 260px) minmax(220px, 1fr) auto;
  align-items: center;
  gap: 18px;
  min-height: 72px;
  border-bottom: 1px solid var(--line-soft);
  background: color-mix(in oklch, var(--bg) 88%, transparent);
  backdrop-filter: blur(18px);
  padding: 0 clamp(16px, 3vw, 44px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand:focus-visible,
.topnav a:focus-visible,
.button:focus-visible,
.chip:focus-visible,
.toc a:focus-visible,
.work-card-media:focus-visible,
.work-title:focus-visible,
.search-result:focus-visible,
.tech-row:focus-visible,
.model-row:focus-visible,
.topic-card:focus-visible,
.related-card:focus-visible,
.rail-item:focus-visible,
.wiki-link:focus-visible,
.mini-directory a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--accent);
  font-family: var(--font-mono);
  font-weight: 760;
}

.brand strong {
  display: block;
  font-size: 15px;
  letter-spacing: 0;
}

.brand small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.search-box {
  position: relative;
  min-width: 0;
}

.search-box input {
  width: 100%;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  padding: 0 48px 0 18px;
  outline: none;
  transition:
    border-color 160ms var(--ease-out),
    background 160ms var(--ease-out);
}

.search-box input::placeholder {
  color: color-mix(in oklch, var(--muted) 92%, var(--ink));
}

.search-box input:focus {
  border-color: var(--primary-bright);
  background: var(--surface-2);
}

.search-key {
  position: absolute;
  right: 15px;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 12px;
}

.search-results {
  position: absolute;
  inset: calc(100% + 8px) 0 auto 0;
  z-index: 40;
  display: none;
  max-height: min(520px, calc(100dvh - 92px));
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 8px 8px var(--shadow);
}

.search-results[data-open="true"] {
  display: block;
}

.search-result {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px 12px;
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  background: transparent;
  color: var(--ink);
  padding: 12px 14px;
  text-align: left;
}

.search-result:hover,
.search-result[aria-selected="true"] {
  background: var(--surface-2);
}

.search-result span:first-child {
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 12px;
}

.search-result small {
  display: block;
  color: var(--muted);
}

.topnav {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.topnav a,
.button,
.chip {
  transition:
    transform 140ms var(--ease-out),
    border-color 160ms var(--ease-out),
    background 160ms var(--ease-out),
    color 160ms var(--ease-out);
}

.topnav a {
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--muted);
  padding: 8px 11px;
  font-size: 14px;
}

.topnav a:hover {
  border-color: var(--line);
  color: var(--ink);
}

.topnav a:active,
.button:active,
.chip:active,
.work-card-media:active,
.work-title:active,
.related-card:active {
  transform: scale(0.98);
}

#app {
  min-height: 70dvh;
}

#directory,
#tech-map,
#social-map,
.section-panel,
.related {
  scroll-margin-top: 92px;
}

.hero {
  position: relative;
  isolation: isolate;
  min-height: clamp(520px, 70dvh, 680px);
  overflow: hidden;
  border-bottom: 1px solid var(--line-soft);
}

.hero canvas {
  position: absolute;
  inset: 0;
  z-index: -2;
  width: 100%;
  height: 100%;
}

.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(90deg, var(--bg), rgb(0 0 0 / 0.64), rgb(0 0 0 / 0.12)),
    linear-gradient(180deg, transparent, var(--bg));
  pointer-events: none;
}

.hero::before {
  content: "";
  position: absolute;
  inset: 18% 3vw 12%;
  z-index: -1;
  border-top: 1px solid color-mix(in oklch, var(--line) 48%, transparent);
  border-bottom: 1px solid color-mix(in oklch, var(--line-soft) 72%, transparent);
  background: linear-gradient(90deg, transparent, color-mix(in oklch, var(--primary) 10%, transparent), transparent);
  opacity: 0.72;
  pointer-events: none;
}

.hero-inner,
.section-inner,
.detail-shell,
.topic-shell {
  width: min(var(--max), calc(100% - clamp(32px, 6vw, 88px)));
  margin: 0 auto;
}

.hero-inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.58fr);
  align-items: center;
  gap: clamp(28px, 6vw, 76px);
  min-height: inherit;
  padding: 30px 0 34px;
}

.hero-copy {
  max-width: 860px;
}

.kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 680;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
  line-height: 1.12;
  text-wrap: balance;
}

h1 {
  max-width: 900px;
  margin-top: 18px;
  font-size: 4.5rem;
}

.hero-copy p {
  max-width: 68ch;
  margin: 24px 0 0;
  color: var(--muted);
  font-size: 1.1875rem;
  line-height: 1.78;
  text-wrap: pretty;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 30px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  padding: 10px 18px;
  font-weight: 720;
}

.button.primary {
  border-color: color-mix(in oklch, var(--accent) 64%, var(--line));
  background: var(--accent);
  color: var(--bg);
}

.button:hover {
  border-color: var(--primary-bright);
  background: var(--surface-2);
}

.button.primary:hover {
  background: color-mix(in oklch, var(--accent) 88%, white);
  color: var(--bg);
}

.hero-index {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
  padding: 18px 0;
}

.index-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
  border-top: 1px solid var(--line);
  padding: 14px 0 0;
}

.index-line strong {
  font-size: 2.375rem;
  line-height: 1;
}

.index-line span {
  color: var(--muted);
  text-align: right;
}

.band {
  border-bottom: 1px solid var(--line-soft);
  padding: 72px 0;
}

.section-title {
  display: grid;
  grid-template-columns: minmax(280px, 0.72fr) minmax(280px, 1fr);
  align-items: end;
  gap: 12px;
  max-width: 1180px;
  margin-bottom: 28px;
}

.section-title h2 {
  max-width: 14ch;
  font-size: 2.75rem;
}

.section-title p {
  max-width: 72ch;
  margin: 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.78;
}

.tech-grid {
  display: grid;
  grid-template-columns: minmax(280px, 400px) minmax(0, 1fr);
  align-items: start;
  gap: clamp(28px, 5vw, 68px);
}

.tech-summary {
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.tech-summary .section-title {
  display: block;
  max-width: none;
  margin: 0;
}

.tech-summary .section-title h2 {
  max-width: 12.5ch;
  font-size: clamp(2.15rem, 3.6vw, 3.15rem);
}

.tech-summary .section-title p {
  margin-top: 18px;
}

.tech-summary p {
  max-width: 65ch;
  color: var(--muted);
  font-size: 18px;
}

.tech-list,
.model-list {
  display: grid;
  gap: 10px;
}

.tech-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: start;
}

.tech-row,
.model-row,
.fact-card,
.work-card,
.related-card,
.image-panel,
.section-panel {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--surface);
}

.tech-row {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "copy value"
    "bar bar";
  gap: 12px 14px;
  align-items: start;
  min-height: 112px;
  padding: 16px;
}

.tech-row:hover,
.model-row:hover,
.work-card:hover,
.related-card:hover {
  border-color: color-mix(in oklch, var(--primary) 72%, var(--line));
  background: var(--surface-2);
}

.tech-row strong,
.model-row strong {
  display: block;
  line-height: 1.35;
}

.tech-row small,
.model-row small {
  display: block;
  color: var(--muted);
}

.tech-row > span:first-child {
  grid-area: copy;
  min-width: 0;
}

.bar {
  grid-area: bar;
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--line-soft);
}

.bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--accent));
}

.progress-value {
  grid-area: value;
  color: var(--muted);
  font-family: var(--font-mono);
  text-align: right;
}

.model-row {
  display: grid;
  grid-template-columns: minmax(180px, 0.8fr) minmax(220px, 1fr) minmax(160px, 0.8fr);
  gap: 16px;
  padding: 14px 16px;
}

.marquee {
  overflow: hidden;
  border-block: 1px solid var(--line-soft);
  background: var(--surface);
  padding: 14px 0;
}

.marquee-track {
  display: flex;
  gap: 14px;
  width: max-content;
  animation: rail 58s linear infinite;
}

.marquee:hover .marquee-track {
  animation-play-state: paused;
}

.rail-item {
  display: inline-grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  flex: 0 0 390px;
  min-width: 0;
  height: 48px;
  overflow: hidden;
  border-right: 1px solid var(--line);
  color: var(--muted);
  padding: 0 18px;
}

.rail-item strong {
  max-width: 10ch;
  overflow: hidden;
  color: var(--ink);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rail-item span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@keyframes rail {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(-50%);
  }
}

.facts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

.fact-card {
  padding: 18px;
}

.fact-card span {
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 12px;
}

.fact-card p {
  margin: 8px 0 0;
  color: var(--ink);
}

.directory-actions {
  display: flex;
  justify-content: center;
  margin-top: 24px;
}

.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  padding: 8px 12px;
}

.chip[aria-current="page"],
.chip.active {
  border-color: var(--accent);
  background: color-mix(in oklch, var(--accent) 18%, transparent);
  color: var(--ink);
}

.directory-layout {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}

.directory-side {
  position: sticky;
  top: 88px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.directory-side .section-title {
  display: block;
  max-width: none;
  margin-bottom: 12px;
}

.directory-side .section-title h2 {
  font-size: 2rem;
  max-width: none;
  margin-bottom: 4px;
}

.directory-side .section-title p {
  font-size: 0.85rem;
  line-height: 1.5;
}

.directory-filters {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.filter-group {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 12px 14px 14px;
  margin: 0;
  min-width: 0;
}

.filter-group legend {
  padding: 0 6px;
  color: var(--ink);
  font-weight: 600;
  font-size: 0.95rem;
}

.filter-options {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 6px;
}

.filter-option {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-option input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
  flex: none;
}

.filter-option label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex: 1;
  min-width: 0;
  padding: 4px 6px;
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
}

.filter-option input[type="checkbox"]:checked + label {
  color: var(--ink);
}

.filter-option input[type="checkbox"]:focus-visible + label {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.filter-option-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.filter-option-count {
  flex: none;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 0.8rem;
}

.filter-clear {
  align-self: flex-start;
}

/* 移动端筛选切换按钮，桌面端隐藏 */
.filter-toggle-mobile {
  display: none;
}

.directory-resultbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-top: 4px;
}

.directory-count {
  margin: 0;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 1.05rem;
}

.directory-empty {
  text-align: left;
}

.work-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.work-card {
  position: relative;
  display: grid;
  grid-template-columns: 148px minmax(0, 1fr);
  min-height: 154px;
  padding: 8px;
  gap: 14px;
  overflow: hidden;
  color: var(--ink);
  transition:
    transform 160ms var(--ease-out),
    border-color 160ms var(--ease-out),
    background 160ms var(--ease-out);
}

.work-card:hover {
  transform: translateY(-2px);
}

.work-card-media,
.work-title {
  display: block;
  min-width: 0;
  color: inherit;
  transition: transform 140ms var(--ease-out), color 160ms var(--ease-out);
}

.work-title:hover {
  color: var(--accent);
}

.work-card-body {
  display: grid;
  align-content: start;
  min-width: 0;
  gap: 7px;
  padding: 6px 8px 6px 0;
}

.work-card h3 {
  display: -webkit-box;
  overflow: hidden;
  margin-top: 0;
  font-size: 1.375rem;
  line-height: 1.24;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.work-card p {
  display: -webkit-box;
  overflow: hidden;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.62;
  text-wrap: pretty;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.meta-line,
.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  max-height: 60px;
  overflow: hidden;
}

.meta-pill,
.tag {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  padding: 2px 8px;
  font-size: 12px;
  line-height: 1.45;
}

.tag {
  color: var(--ink);
  background: color-mix(in oklch, var(--primary) 20%, transparent);
}

.image-panel {
  position: relative;
  overflow: hidden;
  min-height: 170px;
  background:
    linear-gradient(135deg, color-mix(in oklch, var(--primary) 26%, transparent), transparent 58%),
    linear-gradient(315deg, color-mix(in oklch, var(--accent) 10%, transparent), transparent 54%),
    var(--surface-2);
}

.image-panel::before {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px solid color-mix(in oklch, var(--accent) 22%, transparent);
  border-radius: 8px;
  opacity: 0.55;
  pointer-events: none;
}

/* 目录卡锁 3/4 竖版：封面多为竖构图海报，定宽图列（148px / 96px）下锁固定比例，
   让所有卡封面同高、对齐成整齐网格，而非被相邻文本列高度撑成参差（AC1 枚举形态）。
   图框被 <a class="work-card-media">（display:block）包裹，是普通流块级子元素而非 .work-card
   的网格项，故高度仅由 aspect-ratio 决定，无需 align-self（在此处不生效）。 */
.work-card .image-panel {
  aspect-ratio: 3 / 4;
  min-height: 0;
  border: 0;
  border-radius: 9px;
}

.image-panel img {
  width: 100%;
  height: 100%;
  min-height: inherit;
  object-fit: cover;
  object-position: center;
  opacity: 0;
  filter: saturate(0.92) contrast(1.04);
  transition: opacity 260ms var(--ease-out);
}

.image-panel[data-loaded="true"] img {
  opacity: 1;
}

.image-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: end;
  gap: 8px;
  padding: 16px;
  color: var(--ink);
  background: linear-gradient(180deg, transparent, rgb(0 0 0 / 0.62));
}

.image-panel[data-loaded="true"] .image-fallback {
  opacity: 0;
  /* 真实封面加载后，整块占位卡（含「来源：Wikipedia ↗」链接）退出焦点顺序与无障碍树：
     仅 opacity:0 会让不可见的链接仍可被键盘聚焦 / Enter 激活、且 focus-visible 轮廓画在
     封面之上（鼠标点不到却键盘能激活，行为不一致）。visibility:hidden 一并移除可聚焦性。 */
  visibility: hidden;
}

.image-fallback strong {
  max-width: 16ch;
  font-size: 26px;
  line-height: 1.12;
}

/* 占位卡来源链接：常驻文字链接（离线可见），指向该作品 Wikipedia 条目。 */
.image-source {
  justify-self: start;
  max-width: max-content;
  border-radius: 6px;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 12px;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* AI 兜底图来源标注：非链接 caption「AI 生成（Seedream）」——去下划线、用 --muted，
   与真图的 accent 文字链接区分，不让用户误以为可点（无来源页可跳）。--muted 在暗色占位卡上达 WCAG AA。 */
.image-source-ai {
  color: var(--muted);
  text-decoration: none;
  cursor: default;
}

.image-source:hover {
  color: var(--ink);
}

.image-source:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* 图片成功加载后整张占位卡淡出；来源链接随之不再可点，避免压在真实封面上。 */
.image-panel[data-loaded="true"] .image-source {
  pointer-events: none;
}

.work-card .image-fallback {
  align-content: space-between;
  padding: 12px;
}

.work-card .image-fallback::before {
  content: attr(data-code);
  justify-self: start;
  border: 1px solid color-mix(in oklch, var(--accent) 34%, transparent);
  border-radius: 999px;
  color: var(--accent);
  padding: 2px 8px;
  font-family: var(--font-mono);
  font-size: 12px;
}

.work-card .image-fallback strong {
  display: none;
}

.work-card .image-fallback span {
  max-width: 9ch;
  color: var(--ink);
  font-weight: 720;
  line-height: 1.45;
}

.topic-shell {
  padding: clamp(36px, 6vw, 72px) 0;
}

.topic-head {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(240px, 0.45fr);
  gap: 30px;
  align-items: end;
  border-bottom: 1px solid var(--line-soft);
  padding-bottom: 26px;
  margin-bottom: 28px;
}

.topic-head-index {
  grid-template-columns: minmax(0, 1fr) minmax(220px, 320px);
}

.topic-head h1 {
  margin: 0;
  font-size: 4.875rem;
}

.topic-head p {
  margin: 16px 0 0;
  color: var(--muted);
  max-width: 72ch;
}

.topic-note {
  display: grid;
  align-content: end;
  gap: 4px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  padding-top: 16px;
}

.topic-note strong {
  color: var(--ink);
  font-size: 4rem;
  line-height: 1;
}

.topic-note span {
  color: var(--accent);
  font-weight: 760;
}

.topic-switcher {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 24px;
}

.topic-switcher .chip {
  display: inline-flex;
  gap: 7px;
}

.topic-switcher .chip span {
  color: var(--accent);
  font-family: var(--font-mono);
}

.topic-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 14px;
}

.topic-card {
  display: grid;
  min-height: 210px;
  align-content: start;
  gap: 14px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, color-mix(in oklch, var(--primary) 12%, transparent), transparent 58%),
    var(--surface);
  padding: 18px;
  transition:
    transform 160ms var(--ease-out),
    border-color 160ms var(--ease-out),
    background 160ms var(--ease-out);
}

.topic-card:hover {
  transform: translateY(-2px);
  border-color: color-mix(in oklch, var(--primary) 72%, var(--line));
  background: var(--surface-2);
}

.topic-card-top {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
}

.topic-card strong {
  max-width: 16ch;
  font-size: 22px;
  line-height: 1.25;
}

.topic-card span:not(.topic-card-top),
.topic-card small,
.topic-card em {
  color: var(--muted);
  font-style: normal;
  line-height: 1.55;
}

.topic-card-top small {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--accent);
  padding: 3px 8px;
  font-family: var(--font-mono);
}

.detail-shell {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  gap: clamp(24px, 4vw, 54px);
  padding: clamp(28px, 5vw, 60px) 0;
}

.detail-side {
  /* DOM 里侧栏在主内容之后（修正 h1 先于 h2 的层级），视觉仍放第 1 列。 */
  grid-column: 1;
  grid-row: 1;
  position: sticky;
  top: 92px;
  align-self: start;
  display: grid;
  gap: 18px;
}

.detail-main {
  grid-column: 2;
  grid-row: 1;
}

.toc,
.mini-directory {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.toc h2,
.mini-directory h2 {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.toc a,
.mini-directory a {
  display: block;
  border-radius: 8px;
  color: var(--muted);
  padding: 7px 0;
  font-size: 14px;
}

.toc a:hover,
.mini-directory a:hover {
  color: var(--ink);
}

.detail-main {
  min-width: 0;
}

.detail-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 430px);
  gap: clamp(22px, 5vw, 58px);
  align-items: end;
  border-bottom: 1px solid var(--line-soft);
  padding-bottom: 36px;
  margin-bottom: 10px;
}

.detail-hero h1 {
  font-size: 4.375rem;
}

.detail-hero p {
  max-width: 75ch;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 16.5px;
  line-height: 1.78;
}

/* hero 图片面板：自适应比例，竖版海报完整展示，横版图片也不截断。
   移除固定 16/9 比例，改用 max-height 限制高度，object-fit: contain 保证完整展示。 */
.detail-hero .image-panel {
  align-self: start;
  min-width: 0;
  min-height: 0;
  max-height: 420px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
}

.detail-hero .image-panel img {
  width: 100%;
  height: 100%;
  max-height: 420px;
  object-fit: contain;
  object-position: center;
}

.section-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 360px);
  gap: clamp(24px, 4vw, 54px);
  align-items: start;
  margin-top: 0;
  border: 0;
  border-top: 1px solid var(--line-soft);
  border-radius: 0;
  background: transparent;
  padding: 40px 0;
}

.section-copy {
  min-width: 0;
}

.section-panel h2 {
  font-size: 2.125rem;
  margin-bottom: 14px;
}

.section-panel p {
  max-width: 74ch;
  margin: 0;
  color: color-mix(in oklch, var(--ink) 88%, var(--muted));
  font-size: 16.5px;
  line-height: 1.86;
  text-wrap: pretty;
}

.section-items {
  display: grid;
  gap: 14px;
}

.section-items-world,
.section-items-society,
.section-items-insight {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.evidence-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(150px, 230px);
  gap: 16px;
  /* start（非 stretch）：让图列由自身 aspect-ratio:4/3 决定高度，而非被相邻文本列拉伸——
     stretch 下 aspect-ratio 会按拉伸后的高反算宽度，溢出 230px 图列（Issue #16 根因）。 */
  align-items: start;
  min-width: 0;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background:
    linear-gradient(145deg, color-mix(in oklch, var(--surface-2) 70%, transparent), color-mix(in oklch, var(--surface) 86%, transparent)),
    var(--surface);
  padding: 14px;
}

.section-items-world .evidence-card,
.section-items-society .evidence-card,
.section-items-insight .evidence-card {
  grid-template-columns: 1fr;
}

.evidence-copy {
  display: grid;
  align-content: start;
  gap: 8px;
  min-width: 0;
}

.evidence-kicker {
  width: fit-content;
  border-radius: 999px;
  background: color-mix(in oklch, var(--primary) 18%, transparent);
  color: color-mix(in oklch, var(--primary-bright) 82%, var(--ink));
  padding: 3px 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.35;
}

.evidence-card h3 {
  margin: 0;
  color: var(--ink);
  font-size: 1.05rem;
  line-height: 1.35;
  text-wrap: balance;
}

.section-panel .evidence-card p {
  max-width: none;
  color: color-mix(in oklch, var(--ink) 84%, var(--muted));
  font-size: 14.5px;
  line-height: 1.72;
}

/* min-height:0：与 hero/work-card 同治。aspect-ratio:4/3 是证据卡图框高度的唯一裁决者；
   留下 min-height 下限会在 980px 断点正下方反咬——窄两列图列宽到 width×3/4<下限时，占位卡
   内容盒按比例反算高（~148px），而 `.image-panel img { min-height:inherit }` 让 img 继承下限
   （150px），img 比占位卡内容盒高 2px → 纵向溢出（被 overflow:hidden 藏住，违反 AC2/AC6）。 */
.evidence-card .image-panel {
  align-self: start;
  min-height: 0;
  aspect-ratio: 4 / 3;
  border-radius: 10px;
}

.section-media {
  display: grid;
  gap: 12px;
  position: sticky;
  top: 92px;
}

/* 侧栏（.section-media）唯一的配图就是 .mini-image-grid 里的缩略卡，比例由下方
   `.mini-image-grid .image-panel`（锁 1/1）决定，侧栏本身不再单独约束 image-panel。 */

.section-media-copy {
  display: grid;
  gap: 4px;
  border-top: 1px solid var(--line-soft);
  color: var(--muted);
  padding-top: 12px;
}

.section-media-copy strong {
  color: var(--accent);
}

.section-media-copy span {
  font-size: 14px;
  line-height: 1.62;
}

.evidence-list {
  display: grid;
  gap: 8px;
}

.evidence-list a {
  display: grid;
  gap: 3px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: var(--surface);
  padding: 10px 12px;
}

.evidence-list a:hover {
  border-color: color-mix(in oklch, var(--accent) 48%, var(--line));
  background: var(--surface-2);
}

.evidence-list span {
  color: var(--ink);
  font-weight: 720;
  line-height: 1.35;
}

.evidence-list small {
  color: var(--muted);
  line-height: 1.45;
}

.section-facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.section-facts span {
  display: grid;
  gap: 2px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: var(--surface);
  padding: 10px;
}

.section-facts strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.section-facts small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.mini-image-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.mini-image-grid a {
  display: grid;
  gap: 7px;
  min-width: 0;
  color: var(--muted);
}

/* 缩略网格锁 1/1：方形缩略保证两列对齐、不被各自图片长宽比撑成参差不齐。 */
.mini-image-grid .image-panel {
  aspect-ratio: 1 / 1;
  min-height: 0;
  border-radius: 10px;
}

.mini-image-grid span {
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  font-weight: 720;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wiki-link {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: color-mix(in oklch, var(--accent) 55%, transparent);
  text-underline-offset: 3px;
}

.related {
  margin-top: 8px;
  border-top: 1px solid var(--line-soft);
  padding-top: 30px;
}

.related h2 {
  margin-bottom: 16px;
  font-size: 2.375rem;
}

.related > p {
  max-width: 76ch;
  margin: -4px 0 18px;
  color: var(--muted);
  line-height: 1.72;
}

.related-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.related-card {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 12px;
  min-height: 104px;
  padding: 8px;
  color: var(--ink);
  transition:
    transform 160ms var(--ease-out),
    border-color 160ms var(--ease-out),
    background 160ms var(--ease-out);
}

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

/* 关联卡缩略锁 1/1：方形缩略在固定首列宽内 cover 居中，任意配图都不变形。 */
.related-card .image-panel {
  aspect-ratio: 1 / 1;
  min-height: 0;
  align-self: center;
  border: 0;
  border-radius: 8px;
}

.related-card .image-fallback {
  align-content: end;
  padding: 8px;
}

.related-card .image-fallback strong {
  display: none;
}

.related-card .image-fallback span {
  max-width: none;
  color: var(--ink);
  font-size: 12px;
  font-weight: 720;
  line-height: 1.35;
  word-break: keep-all;
}

.image-thumb .image-fallback::before {
  content: attr(data-code);
  position: absolute;
  left: 8px;
  top: 8px;
  border: 1px solid color-mix(in oklch, var(--accent) 34%, transparent);
  border-radius: 999px;
  color: var(--accent);
  padding: 1px 6px;
  font-family: var(--font-mono);
  font-size: 10px;
}

.related-card-copy {
  display: grid;
  align-content: center;
  min-width: 0;
  gap: 3px;
}

.related-card-copy small {
  overflow: hidden;
  color: var(--muted-2);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.related-card-copy strong {
  overflow: hidden;
  font-size: 16px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.related-card-copy span {
  display: -webkit-box;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.empty-state {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  padding: 24px;
}

.footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 16px;
  border-top: 1px solid var(--line-soft);
  color: var(--muted);
  padding: 28px clamp(16px, 3vw, 44px);
}

.footer p {
  margin: 0;
}

.footer a {
  color: var(--accent);
}

@media (hover: hover) and (pointer: fine) {
  .chip:hover,
  .button:hover {
    transform: translateY(-1px);
  }
}

@media (max-width: 980px) {
  .topbar {
    grid-template-columns: 1fr auto;
    gap: 8px;
    padding-block: 10px;
    flex-wrap: wrap;
  }

  .search-box {
    grid-column: 1 / -1;
    order: 3;
  }

  .topnav {
    justify-self: end;
  }

  h1,
  .topic-head h1 {
    font-size: 3.5rem;
  }

  .detail-hero h1 {
    font-size: 3.25rem;
  }

  .section-title h2 {
    font-size: 2.75rem;
  }

  .index-line strong {
    font-size: 2.125rem;
  }

  .topnav {
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .hero-inner,
  .tech-grid,
  .topic-head,
  .detail-shell,
  .detail-hero,
  .section-panel {
    grid-template-columns: 1fr;
  }

  .section-title {
    grid-template-columns: 1fr;
  }

  .tech-list {
    grid-template-columns: 1fr;
  }

  .hero-index {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .detail-side,
  .section-media {
    position: static;
  }

  /* 侧栏堆叠到正文下方后变成整页宽，锁 1/1 的缩略卡会被撑成超大方块（900px 下达 ~419px，
     桌面侧栏仅 ~176px）。封顶网格宽度，让缩略仍是小图、与桌面侧栏体量一致。 */
  .mini-image-grid {
    max-width: 360px;
  }

  /* 单列堆叠：复位桌面端的显式列定位，让主内容（h1）先于侧栏按 DOM 顺序排列。 */
  .detail-side,
  .detail-main {
    grid-column: auto;
    grid-row: auto;
  }

  .mini-directory {
    display: none;
  }

  .tech-row,
  .model-row {
    grid-template-columns: 1fr;
  }

  .tech-row {
    grid-template-areas:
      "copy"
      "bar"
      "value";
    min-height: auto;
  }

  .work-grid,
  .related-grid {
    grid-template-columns: 1fr;
  }

  .directory-layout {
    grid-template-columns: 1fr;
  }

  .directory-side {
    position: static;
    max-height: none;
    overflow: visible;
  }

  /* 移动端筛选框折叠为可展开的手风琴 */
  .directory-filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
  }

  .directory-filters[data-collapsed="true"] .filter-group {
    display: none;
  }

  .directory-filters[data-collapsed="true"] .filter-clear {
    display: none;
  }

  .filter-toggle-mobile {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--ink);
    font-weight: 680;
    font-size: 0.95rem;
    cursor: pointer;
    transition: border-color 160ms var(--ease-out), background 160ms var(--ease-out);
  }

  .filter-toggle-mobile:hover {
    border-color: var(--primary-bright);
    background: var(--surface-2);
  }

  .filter-toggle-mobile::after {
    content: "▼";
    font-size: 0.7rem;
    transition: transform 200ms var(--ease-out);
  }

  .filter-toggle-mobile[aria-expanded="true"]::after {
    transform: rotate(180deg);
  }

  .filter-clear {
    grid-column: 1 / -1;
  }

  .evidence-card {
    grid-template-columns: minmax(0, 1fr) minmax(120px, 200px);
  }

  .progress-value {
    text-align: left;
  }
}

@media (max-width: 640px) {
  .hero-inner,
  .section-inner,
  .detail-shell,
  .topic-shell {
    width: min(var(--max), calc(100% - 24px));
  }

  .hero {
    min-height: clamp(420px, 60dvh, 560px);
  }

  .hero-copy p {
    font-size: 1rem;
  }

  .hero-actions {
    flex-direction: column;
    gap: 8px;
  }

  .hero-actions .button {
    width: 100%;
    justify-content: center;
  }

  h1,
  .topic-head h1 {
    font-size: 2.25rem;
  }

  .detail-hero h1 {
    font-size: 2rem;
  }

  .kicker {
    font-size: 11px;
  }

  /* 目录页筛选单列 */
  .directory-filters {
    grid-template-columns: 1fr;
  }

  /* 详情页 hero 图片缩小 */
  .detail-hero .image-panel {
    max-height: 280px;
  }

  .detail-hero .image-panel img {
    max-height: 280px;
  }

  /* 详情页 section-panel 移动端优化 */
  .section-panel {
    padding: 24px 0;
  }

  .section-panel h2 {
    font-size: 1.5rem;
    margin-bottom: 10px;
  }

  .section-panel p {
    font-size: 15px;
    line-height: 1.72;
  }

  .section-title h2,
  .section-panel h2,
  .related h2 {
    max-width: none;
    font-size: 1.75rem;
    line-height: 1.22;
    text-wrap: pretty;
  }

  .hero-index {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .index-line {
    flex-direction: column;
    gap: 4px;
    padding: 10px 0 0;
  }

  .index-line strong {
    font-size: 1.75rem;
  }

  .index-line span {
    font-size: 0.8rem;
    text-align: left;
  }

  .work-card {
    grid-template-columns: 96px minmax(0, 1fr);
    min-height: 0;
    gap: 10px;
  }

  .work-card-body {
    padding: 2px 2px 2px 0;
  }

  .work-card h3 {
    font-size: 18px;
  }

  .work-card p {
    -webkit-line-clamp: 2;
  }

  .tag-row {
    max-height: 30px;
  }

  .related-card {
    grid-template-columns: 64px minmax(0, 1fr);
  }

  .section-items-world,
  .section-items-society,
  .section-items-insight {
    grid-template-columns: 1fr;
  }

  .evidence-card {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  /* min-height:0：与桌面 5 种形态同治。移动端单列证据卡图框由 aspect-ratio:4/3 唯一定高，
     不再留 min-height 下限——残留下限会经 `.image-panel img { min-height:inherit }` 传到 img，
     窄列时 img 比占位卡内容盒高、纵向溢出（本切片要消除的 action-at-a-distance）。此处虽因
     单列满宽（width×3/4≫下限）当前不咬，但归零以锁死「无下限」不变量、与设计决策一致。 */
  .evidence-card .image-panel {
    min-height: 0;
  }

  .section-facts {
    grid-template-columns: 1fr;
  }

  .topic-note strong {
    font-size: 2.5rem;
  }

  .topic-head {
    gap: 16px;
    padding-bottom: 18px;
    margin-bottom: 18px;
  }

  .topic-head h1 {
    font-size: 2rem;
  }

  .topic-head p {
    font-size: 0.9rem;
  }

  .topic-switcher {
    gap: 6px;
  }

  .topic-switcher .chip {
    font-size: 0.85rem;
    padding: 6px 10px;
  }

  .topic-card-grid {
    grid-template-columns: 1fr;
  }

  .rail-item {
    flex: 0 0 280px;
    height: 42px;
    padding: 0 12px;
    gap: 8px;
  }

  .rail-item strong {
    font-size: 13px;
  }

  .rail-item span {
    font-size: 12px;
  }

  .chip {
    padding: 6px 10px;
    font-size: 0.85rem;
  }

  .topbar {
    grid-template-columns: auto 1fr;
    gap: 6px 10px;
    padding-inline: 12px;
    padding-block: 8px;
  }

  .brand {
    gap: 8px;
  }

  .brand strong {
    font-size: 12px;
    max-width: 5em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .brand small {
    display: none;
  }

  .brand-mark {
    width: 32px;
    height: 32px;
    font-size: 11px;
  }

  .topnav {
    grid-column: 1 / -1;
    order: 2;
    justify-self: start;
    flex-wrap: wrap;
    gap: 4px;
  }

  .topnav a {
    padding: 5px 8px;
    font-size: 12px;
  }

  .search-box {
    grid-column: 1 / -1;
    order: 3;
  }

  .search-results {
    position: fixed;
    inset: 110px 12px auto 12px;
  }

  #directory,
  #tech-map,
  #social-map,
  .section-panel,
  .related {
    scroll-margin-top: 184px;
  }
}

/* 图文反馈拉出条：固定贴右缘中部，竖向标签 + 可滑出面板。
   只在作品详情页由 JS 置 hidden=false 显示；配色全用 DESIGN token，满足 WCAG AA。 */
.feedback-widget {
  position: fixed;
  top: 50%;
  right: 0;
  z-index: 60;
  /* 标签是 widget 流内唯一占位的元素，widget 自身贴 right:0，故标签始终紧贴视口最右缘、
     竖直居中。面板绝对定位锚到标签左侧、脱离正常流（见下），故无论开合都不挤占标签宽度。 */
  transform: translateY(-50%);
}

.feedback-tab {
  /* 相对定位 + 抬层：面板展开时虽与标签同锚右缘，但标签始终画在面板之上、保持可见可点
     （点它即收起）；面板从其左侧露出。 */
  position: relative;
  z-index: 1;
  display: block;
  writing-mode: vertical-rl;
  text-orientation: upright;
  /* 视觉收敛：默认融入深色框架——深色表面底、muted 灰字、细 line 边框，低调不扎眼。
     竖排灰字在深底上对比度满足 WCAG AA；只有 hover/聚焦/面板打开（见下）时才用 primary
     钴蓝做强调。 */
  border: 1px solid var(--line);
  border-right: none;
  border-radius: var(--radius) 0 0 var(--radius);
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 720;
  letter-spacing: 0.12em;
  padding: 16px 8px;
  cursor: pointer;
  box-shadow: -2px 0 14px var(--shadow);
  /* 强调态只改 color + border-color（见下），背景始终是 --surface-2，故过渡列表里
     只列这两项；曾有的 background-color 项不动画任何东西，删去保持规则诚实最小。 */
  transition: color 160ms var(--ease-out), border-color 160ms var(--ease-out);
}

/* 强调态：hover / 键盘聚焦时，用 primary 钴蓝提亮边框与文字。 */
.feedback-tab:hover,
.feedback-tab:focus-visible {
  border-color: var(--primary-bright);
  color: var(--ink);
}

/* 打开态：右缘标签整体隐藏（display:none），让出位置给滑出的面板、绝不盖住它。
   display:none 一并完成视觉消失 + 移出无障碍树 + 移出 Tab 序/不可聚焦三件事（全浏览器一致），
   故无需 JS 再叠 aria-hidden/tabindex。关闭后该规则失效，标签复现且原生可聚焦。 */
.feedback-widget[data-open="true"] .feedback-tab {
  display: none;
}

.feedback-panel {
  /* 绝对定位锚到 widget 右沿、脱离标签所在的正常流：标签因此能贴视口最右缘。
     面板 right:0 使其右沿与 widget（也即标签外缘）对齐；展开时 transform 归零，
     面板从标签左侧向左展开；收起时平移出视口右侧并隐藏。 */
  position: absolute;
  top: 50%;
  right: 0;
  width: min(340px, 86vw);
  transform: translateY(-50%);
  border: 1px solid var(--line);
  border-right: none;
  border-radius: var(--radius) 0 0 var(--radius);
  background: var(--surface);
  color: var(--ink);
  padding: 18px 18px 16px;
  box-shadow: -8px 0 30px var(--shadow);
  transition: transform 160ms var(--ease-out), opacity 160ms var(--ease-out);
}

/* 收起态：面板始终在 DOM、保持 display:block 以便 transform 滑动；用 inert 属性
   （JS 同步翻转）把它从 Tab 序与无障碍树整体移除，而非 hidden 的 display:none——
   后者会扼杀 slide-out 过渡。data-open 驱动 transform+opacity，受全局 reduced-motion 降级。
   transform 须保留竖直居中的 translateY(-50%)，再叠加横向滑动量。 */
.feedback-widget[data-open="false"] .feedback-panel {
  transform: translate(100%, -50%);
  opacity: 0;
  pointer-events: none;
}

.feedback-widget[data-open="true"] .feedback-panel {
  transform: translate(0, -50%);
  opacity: 1;
  pointer-events: auto;
}

/* 右上角关闭叉：统一的关闭入口（点它或按 ESC 都收起，底部不再有重复的『收起』按钮）。
   低调融入——默认 muted 灰字、无底无边；hover/键盘聚焦时用 ink 提亮，与标签强调态同调。 */
.feedback-dismiss {
  position: absolute;
  top: 10px;
  right: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  transition: color 160ms var(--ease-out), background 160ms var(--ease-out);
}

.feedback-dismiss:hover,
.feedback-dismiss:focus-visible {
  color: var(--ink);
  background: var(--surface-2);
}

.feedback-dismiss:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.feedback-panel-title {
  /* 留出右侧空间给绝对定位的关闭叉，避免长标题压到叉上。 */
  margin: 0 28px 6px 0;
  font-size: 1.05rem;
}

.feedback-panel-work {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

.feedback-panel-work strong {
  color: var(--ink);
}

.feedback-panel-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.85rem;
}

.feedback-comment {
  width: 100%;
  min-height: 96px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-wash);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.6;
  padding: 10px 12px;
}

.feedback-comment:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.feedback-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.feedback-actions .button {
  flex: 1;
  min-height: 40px;
  padding: 8px 12px;
}

.feedback-status {
  margin: 12px 0 0;
  min-height: 1.4em;
  font-size: 0.85rem;
  color: var(--muted);
}

.feedback-status[data-tone="ok"] {
  color: var(--accent);
}

.feedback-status[data-tone="warn"] {
  color: var(--warning);
}

/* 窄屏：标签更紧凑、面板宽度退守视口比例，绝不横向溢出。 */
@media (max-width: 560px) {
  .feedback-widget {
    /* 小屏上反馈按钮移到底部，避免遮挡内容 */
    top: auto;
    bottom: 16px;
    transform: none;
  }

  .feedback-tab {
    padding: 10px 6px;
    letter-spacing: 0.08em;
    font-size: 11px;
  }

  .feedback-panel {
    width: min(280px, 85vw);
    bottom: 0;
    top: auto;
  }
}

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

  .marquee-track {
    animation: none;
    flex-wrap: nowrap;
    width: max-content;
  }
}

/* ============================================================
   作品视觉主题系统 (Work Visual Themes)
   当 .detail-shell 拥有 .themed 类时，以下规则通过 CSS 变量覆盖默认样式。
   变量由 app.js 的 renderDetail 函数在 inline style 中注入。
   ============================================================ */

/* 主题容器：覆盖全局 CSS 变量 */
.detail-shell.themed {
  --primary: var(--t-primary);
  --primary-bright: var(--t-primary);
  --accent: var(--t-accent);
  --surface: var(--t-surface);
  --surface-2: var(--t-surface-alt);
  --ink: var(--t-ink);
  --muted: var(--t-muted);
  --line: var(--t-line);
  --line-soft: var(--t-line);
  --radius: var(--t-border-radius);
  /* 背景：渐变 + 纹理叠加 */
  background: var(--t-bg-texture), var(--t-bg-gradient);
  background-size: var(--t-bg-texture-size), 100% 100%;
}

/* 主题标题字体 */
.detail-shell.themed .detail-hero h1 {
  font-family: var(--t-title-font), var(--font-body);
  color: var(--t-primary);
  text-shadow: 0 0 40px color-mix(in oklch, var(--t-primary) 20%, transparent);
}

/* Hero 区域叠加效果 */
.detail-shell.themed .detail-hero {
  background: var(--t-hero-overlay);
  border-radius: var(--t-border-radius);
  padding: 32px;
  margin: -32px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--t-line);
}

/* Kicker 和 meta-pill 主题化 */
.detail-shell.themed .kicker {
  color: var(--t-secondary);
  letter-spacing: 0.05em;
}

.detail-shell.themed .meta-pill {
  background: color-mix(in oklch, var(--t-primary) 12%, transparent);
  color: var(--t-primary);
  border: 1px solid color-mix(in oklch, var(--t-primary) 25%, transparent);
}

/* 标签主题化 */
.detail-shell.themed .tag {
  background: color-mix(in oklch, var(--t-accent) 10%, transparent);
  color: var(--t-accent);
  border: 1px solid color-mix(in oklch, var(--t-accent) 20%, transparent);
}

/* Section 面板主题化 */
.detail-shell.themed .section-panel {
  border-top-color: var(--t-line);
  background: linear-gradient(135deg, var(--t-section-glow) 0%, transparent 60%);
  border-radius: var(--t-border-radius);
  padding-left: 24px;
  padding-right: 24px;
}

.detail-shell.themed .section-panel h2 {
  color: var(--t-primary);
  font-family: var(--t-title-font), var(--font-body);
}

.detail-shell.themed .section-panel p {
  color: var(--t-ink);
}

/* TOC 和侧栏主题化 */
.detail-shell.themed .toc,
.detail-shell.themed .mini-directory {
  border-top-color: var(--t-line);
}

.detail-shell.themed .toc a,
.detail-shell.themed .mini-directory a {
  color: var(--t-muted);
}

.detail-shell.themed .toc a:hover,
.detail-shell.themed .mini-directory a:hover {
  color: var(--t-primary);
}

/* 证据卡片主题化 */
.detail-shell.themed .evidence-card {
  border-color: var(--t-line);
  background: var(--t-surface);
}

.detail-shell.themed .evidence-card:hover {
  border-color: color-mix(in oklch, var(--t-primary) 40%, transparent);
  box-shadow: 0 4px 24px color-mix(in oklch, var(--t-primary) 10%, transparent);
}

/* 相关作品区域主题化 */
.detail-shell.themed .related h2 {
  color: var(--t-primary);
  font-family: var(--t-title-font), var(--font-body);
}

/* Wiki 链接主题化 */
.detail-shell.themed .wiki-link {
  color: var(--t-secondary);
  border-bottom-color: color-mix(in oklch, var(--t-secondary) 30%, transparent);
}

.detail-shell.themed .wiki-link:hover {
  color: var(--t-primary);
  border-bottom-color: var(--t-primary);
}

/* 图片面板边框主题化 */
.detail-shell.themed .image-panel img {
  border-radius: var(--t-border-radius);
  border: 1px solid var(--t-line);
}

/* 主题过渡动画 */
.detail-shell.themed {
  animation: themeReveal 0.6s cubic-bezier(0.23, 1, 0.32, 1) both;
}

@keyframes themeReveal {
  from {
    opacity: 0.7;
    filter: saturate(0.3);
  }
  to {
    opacity: 1;
    filter: saturate(1);
  }
}



/* ===== 仪表盘页面 ===== */
.dashboard-shell {
  padding: clamp(36px, 6vw, 72px) clamp(16px, 4vw, 48px);
  max-width: var(--max);
  margin: 0 auto;
}

.dashboard-head {
  margin-bottom: 40px;
}

.dashboard-head h1 {
  font-size: clamp(2rem, 5vw, 4rem);
  margin: 0 0 12px;
}

.dashboard-head p {
  color: var(--muted);
  max-width: 72ch;
  margin: 0;
}

/* 雷达图区域 */
.radar-section {
  margin-bottom: 48px;
}

.radar-section h2 {
  font-size: 1.5rem;
  margin: 0 0 8px;
}

.radar-section > p {
  color: var(--muted);
  margin: 0 0 24px;
}

.radar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

.radar-card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.radar-card h3 {
  font-size: 0.9rem;
  margin: 0;
  text-align: center;
}

.radar-card canvas {
  width: 200px;
  height: 200px;
}

.radar-card .radar-stats {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  font-size: 0.72rem;
  color: var(--muted);
}

.radar-card .radar-stats span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.radar-card .radar-stats .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

/* 散点矩阵 */
.scatter-section {
  margin-bottom: 48px;
}

.scatter-section h2 {
  font-size: 1.5rem;
  margin: 0 0 8px;
}

.scatter-section > p {
  color: var(--muted);
  margin: 0 0 24px;
}

.scatter-canvas-wrap {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 24px;
  overflow-x: auto;
}

.scatter-canvas-wrap canvas {
  width: 100%;
  min-width: 600px;
  height: 400px;
}

/* 社会模型对比面板 */
.compare-section {
  margin-bottom: 48px;
}

.compare-section h2 {
  font-size: 1.5rem;
  margin: 0 0 8px;
}

.compare-section > p {
  color: var(--muted);
  margin: 0 0 24px;
}

.compare-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
}

.compare-card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 20px;
  transition: border-color 0.2s var(--ease-out), transform 0.2s var(--ease-out);
}

.compare-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
}

.compare-card h3 {
  font-size: 1rem;
  margin: 0 0 6px;
  color: var(--ink);
}

.compare-card .formula {
  font-size: 0.8rem;
  color: var(--accent);
  margin: 0 0 12px;
}

.compare-card .compare-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0;
}

.compare-card .compare-bar label {
  font-size: 0.72rem;
  color: var(--muted);
  min-width: 60px;
}

.compare-card .compare-bar .bar-track {
  flex: 1;
  height: 6px;
  background: var(--surface-2);
  border-radius: 3px;
  overflow: hidden;
}

.compare-card .compare-bar .bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s var(--ease-out);
}

.compare-card .compare-bar .bar-value {
  font-size: 0.72rem;
  color: var(--muted-2);
  min-width: 28px;
  text-align: right;
}

.compare-card .compare-works {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line-soft);
  font-size: 0.75rem;
  color: var(--muted);
}

/* 风险仪表盘 */
.risk-section {
  margin-bottom: 48px;
}

.risk-section h2 {
  font-size: 1.5rem;
  margin: 0 0 8px;
}

.risk-section > p {
  color: var(--muted);
  margin: 0 0 24px;
}

.risk-tier {
  margin-bottom: 24px;
}

.risk-tier-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.risk-tier-header .risk-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 16px;
  font-size: 0.8rem;
  font-weight: 700;
}

.risk-badge.high {
  background: oklch(0.64 0.15 20 / 0.15);
  color: oklch(0.72 0.15 20);
  border: 1px solid oklch(0.64 0.15 20 / 0.3);
}

.risk-badge.medium {
  background: oklch(0.72 0.13 55 / 0.15);
  color: oklch(0.78 0.13 55);
  border: 1px solid oklch(0.72 0.13 55 / 0.3);
}

.risk-badge.low {
  background: oklch(0.78 0.16 155 / 0.15);
  color: oklch(0.82 0.16 155);
  border: 1px solid oklch(0.78 0.16 155 / 0.3);
}

.risk-tier-header .risk-count {
  font-size: 0.8rem;
  color: var(--muted);
}

.risk-works-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}

.risk-work-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  text-decoration: none;
  color: var(--ink);
  font-size: 0.8rem;
  transition: border-color 0.18s var(--ease-out), transform 0.18s var(--ease-out);
}

.risk-work-chip:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
}

.risk-work-chip .risk-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.risk-work-chip .risk-dot.high { background: oklch(0.64 0.15 20); }
.risk-work-chip .risk-dot.medium { background: oklch(0.72 0.13 55); }
.risk-work-chip .risk-dot.low { background: oklch(0.78 0.16 155); }

.risk-work-chip .chip-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.risk-work-chip .chip-year {
  font-size: 0.7rem;
  color: var(--muted-2);
}

/* 仪表盘响应式 */
@media (max-width: 980px) {
  .radar-grid {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  }
}

@media (max-width: 640px) {
  .radar-card canvas {
    width: 160px;
    height: 160px;
  }
  .compare-grid {
    grid-template-columns: 1fr;
  }
  .risk-works-grid {
    grid-template-columns: 1fr;
  }
}
