﻿/* =============================================================================
 * 明代服饰藏品库 · Demo v1.1
 * 双主题：墨（夜）/ 宣纸（昼），整套色板走 CSS 变量，切换只改 data-theme。
 * 古风取向：墨褐与宣纸底、朱砂与描金点缀、宋体标题、双线边框、纸纹噪声。
 * ========================================================================== */

/* ---------------------------------------------------------------- 主题：墨（夜） */
:root,
html[data-theme="dark"] {
  color-scheme: dark;

  --bg:            #14110e;
  --bg-2:          #191510;
  --panel:         #1c1813;
  --panel-2:       #241e17;
  --panel-3:       #2b241c;
  --line:          #3a3025;
  --line-soft:     #2a231b;
  --hair:          #4a3d2d;

  --ink:           #eee3cd;
  --ink-2:         #bcae95;
  --ink-3:         #8b7f6b;
  --ink-4:         #6a5f4f;

  --accent:        #b4553f;   /* 赭红 */
  --accent-2:      #c9a227;   /* 描金 */
  --accent-soft:   #37211a;
  --accent-line:   #5e3328;

  --ok:            #6f9d74;
  --warn:          #c9a227;
  --idle:          #7c7365;

  --stage-1:       #2a241c;
  --stage-2:       #100d0b;
  --thumb-1:       #241f18;
  --thumb-2:       #171310;

  --shadow-1:      0 10px 26px -18px #000;
  --shadow-2:      0 40px 90px -50px #000;
  --veil:          rgba(10, 8, 6, .78);

  --font-sans: "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", system-ui, sans-serif;
  --font-serif: "Songti SC", "SimSun", "Source Han Serif SC", "Noto Serif CJK SC", serif;
  /* 顶栏标题字体：楷体（Windows 自带 KaiTi，macOS 走 STKaiti）。想换字体只改这一行 */
  --font-brand: "KaiTi", "STKaiti", "Kaiti SC", "Songti SC", "SimSun", serif;
  --font-mono: Consolas, "Cascadia Mono", monospace;
  --radius: 8px;
}

/* ---------------------------------------------------------------- 主题：宣纸（昼） */
html[data-theme="light"] {
  color-scheme: light;

  --bg:            #efe5d2;
  --bg-2:          #f4ecdd;
  --panel:         #f9f3e7;
  --panel-2:       #f2e9d8;
  --panel-3:       #ebdfc9;
  --line:          #d8c8ab;
  --line-soft:     #e3d7bf;
  --hair:          #c9b795;

  --ink:           #2e2721;
  --ink-2:         #5d5145;
  --ink-3:         #8a7c68;
  --ink-4:         #a2947e;

  --accent:        #9c3d2c;   /* 朱砂 */
  --accent-2:      #a8823a;   /* 描金 */
  --accent-soft:   #f0dfd4;
  --accent-line:   #d9b3a4;

  --ok:            #4c7d5c;
  --warn:          #a8823a;
  --idle:          #9a8d79;

  --stage-1:       #ded1b6;
  --stage-2:       #cdbd9d;
  --thumb-1:       #efe6d4;
  --thumb-2:       #e4d7bf;

  --shadow-1:      0 10px 22px -18px #7c6342;
  --shadow-2:      0 30px 70px -46px #7c6342;
  --veil:          rgba(46, 36, 26, .55);

  --font-sans: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  --font-serif: "Songti SC", "SimSun", "Source Han Serif SC", serif;
  --font-brand: "KaiTi", "STKaiti", "Kaiti SC", "Songti SC", "SimSun", serif;
  --font-mono: Consolas, "Cascadia Mono", monospace;
  --radius: 8px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  letter-spacing: .01em;
  -webkit-font-smoothing: antialiased;
}

body {
  overflow: hidden;
  background:
    radial-gradient(1200px 620px at 72% -12%, var(--stage-1) 0%, transparent 62%),
    radial-gradient(900px 520px at 8% 112%, var(--panel-2) 0%, transparent 58%),
    var(--bg);
  transition: background-color .25s ease, color .25s ease;
}

/* 纸纹：一层极淡的噪声，让平色有「纸」的颗粒 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='.5'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
  opacity: .035;
}
html[data-theme="dark"] body::before { mix-blend-mode: screen; opacity: .04; }

button, input { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
[hidden] { display: none !important; }
kbd {
  font-family: var(--font-mono);
  font-size: 10.5px;
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 0 4px;
  color: var(--ink-3);
}

/* ---------------------------------------------------------------- 顶栏 */
.topbar {
  position: relative;
  z-index: 20;
  height: 58px;
  padding: 0 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line-soft);
}
/* 双线：古书页框的味道 */
.topbar::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -4px;
  height: 1px;
  background: var(--line-soft);
  opacity: .7;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-brand);
  font-size: 18px;
  font-weight: 400;
  letter-spacing: .22em;
  text-indent: .1em;
  color: var(--ink);
  -webkit-font-smoothing: auto;
  padding: 2px 4px 2px 0;
  border-radius: 4px;
  transition: opacity .15s;
}
.brand:hover { opacity: .82; }
.brand #brand-name {
  display: inline-block;
  transition: opacity .13s ease, transform .13s ease;
}
.brand #brand-name.is-swap { opacity: 0; transform: translateY(-5px); }
.brand-mark {
  width: 20px; height: 20px;
  border: 1px solid var(--accent);
  border-radius: 2px;
  position: relative;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 28%, transparent);
}
.brand-mark::after {
  content: "";
  position: absolute; inset: 4px;
  background: var(--accent);
  opacity: .82;
}

.crumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--ink-4);
  min-width: 0;
  font-family: var(--font-serif);
  letter-spacing: .06em;
}
.crumbs b { color: var(--ink-2); font-weight: 500; }
.crumbs .sep { color: var(--line); }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.icon-btn {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink-2);
  transition: .15s;
}
.icon-btn:hover { color: var(--ink); border-color: var(--hair); background: var(--panel-2); }

.viewswitch {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}
.viewswitch button {
  padding: 5px 13px;
  font-size: 12.5px;
  color: var(--ink-3);
  border-right: 1px solid var(--line);
  transition: .15s;
  font-family: var(--font-serif);
  letter-spacing: .08em;
}
.viewswitch button:last-child { border-right: none; }
.viewswitch button:hover { color: var(--ink-2); background: var(--panel-2); }
.viewswitch button.is-on {
  color: var(--ink);
  background: var(--accent-soft);
  box-shadow: inset 0 -2px 0 var(--accent);
}

.theme-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink-2);
  font-size: 12.5px;
  font-family: var(--font-serif);
  letter-spacing: .1em;
  transition: .15s;
}
.theme-toggle:hover { color: var(--ink); border-color: var(--hair); background: var(--panel-2); }
.theme-toggle .ico { font-size: 13px; color: var(--accent-2); }

/* ---------------------------------------------------------------- 页面容器 */
.page { height: calc(100vh - 58px); position: relative; z-index: 1; }

/* ---------------------------------------------------------------- 库页 */
#page-browse { display: grid; grid-template-columns: 236px 1fr; }

.filters {
  border-right: 1px solid var(--line-soft);
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}
.filters h2 {
  font-size: 11px;
  letter-spacing: .22em;
  color: var(--ink-4);
  font-weight: 500;
  margin: 0 0 2px;
  font-family: var(--font-serif);
}

.chips { display: flex; flex-direction: column; gap: 5px; }
.chips button {
  text-align: left;
  padding: 7px 10px;
  border-radius: 6px;
  color: var(--ink-2);
  font-size: 13px;
  border: 1px solid transparent;
  display: flex;
  justify-content: space-between;
  transition: .15s;
  font-family: var(--font-serif);
  letter-spacing: .04em;
}
.chips button:hover { background: var(--panel); color: var(--ink); }
.chips button.is-on {
  background: var(--panel-2);
  border-color: var(--line);
  color: var(--ink);
  box-shadow: inset 2px 0 0 var(--accent);
}
.chips button span { color: var(--ink-4); font-variant-numeric: tabular-nums; font-family: var(--font-mono); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 11px; letter-spacing: .18em; color: var(--ink-4); font-family: var(--font-serif); }
.field input {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
  outline: none;
  transition: .15s;
}
.field input::placeholder { color: var(--ink-4); opacity: .8; }
.field input:focus { border-color: var(--hair); background: var(--panel-2); }

.stat { font-size: 12px; color: var(--ink-4); line-height: 1.75; white-space: nowrap; }
.stat b { color: var(--ink-2); font-weight: 500; font-variant-numeric: tabular-nums; font-family: var(--font-mono); }

.hint {
  margin: auto 0 0;
  font-size: 11.5px;
  line-height: 1.8;
  color: var(--ink-4);
  border-top: 1px solid var(--line-soft);
  padding-top: 12px;
}

.grid {
  padding: 22px 24px 44px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(214px, 1fr));
  gap: 18px;
  align-content: start;
}

.card-tile {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  overflow: hidden;
  text-align: left;
  transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
  display: flex;
  flex-direction: column;
}
.card-tile:hover {
  transform: translateY(-3px);
  border-color: var(--hair);
  box-shadow: var(--shadow-1);
}
.card-tile:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.thumb {
  position: relative;
  aspect-ratio: 4 / 5;
  background: radial-gradient(120% 92% at 50% 0%, var(--thumb-1) 0%, var(--thumb-2) 62%);
  display: grid;
  place-items: center;
  border-bottom: 1px solid var(--line-soft);
}
/* 裱框：内嵌一道细线 */
.thumb::after {
  content: "";
  position: absolute;
  inset: 7px;
  border: 1px solid color-mix(in srgb, var(--hair) 45%, transparent);
  border-radius: 3px;
  pointer-events: none;
}
.thumb svg { width: 58%; height: 78%; position: relative; z-index: 1; color: var(--ink-4); }
.thumb .tag {
  position: absolute;
  left: 12px; bottom: 11px;
  font-size: 10px;
  letter-spacing: .12em;
  color: var(--ink-4);
  background: color-mix(in srgb, var(--panel) 78%, transparent);
  border: 1px solid var(--line-soft);
  border-radius: 3px;
  padding: 2px 6px;
  font-family: var(--font-serif);
}
.thumb .badge {
  position: absolute;
  right: 12px; top: 12px;
  width: 7px; height: 7px;
  border-radius: 50%;
  z-index: 2;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--panel) 60%, transparent);
}
.badge.done { background: var(--ok); }
.badge.building { background: var(--warn); }
.badge.data-only { background: var(--idle); }

.tile-body { padding: 12px 13px 14px; display: flex; flex-direction: column; gap: 5px; }
.tile-title {
  font-family: var(--font-serif);
  font-size: 16.5px;
  letter-spacing: .08em;
}
.tile-title small {
  margin-left: 8px;
  font-family: var(--font-sans);
  font-size: 11px;
  color: var(--ink-4);
  letter-spacing: .02em;
}
.tile-sub { font-size: 11.5px; color: var(--ink-4); display: flex; gap: 8px; }
.tile-sub em { font-style: normal; color: var(--line); }

.card-ghost {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: transparent;
  overflow: hidden;
  opacity: .8;
}
.ghost-frame {
  position: relative;
  aspect-ratio: 4 / 5;
  display: grid;
  place-items: center;
  background: repeating-linear-gradient(135deg,
    var(--bg-2) 0 10px, var(--bg) 10px 20px);
}
.ghost-frame svg { width: 54%; height: 74%; opacity: .55; color: var(--ink-4); }
.ghost-frame span {
  position: absolute;
  left: 12px; bottom: 11px;
  font-size: 10px;
  letter-spacing: .12em;
  color: var(--ink-4);
  font-family: var(--font-serif);
}
.card-ghost .tile-title { font-size: 14px; color: var(--ink-2); }
.card-ghost .tile-sub { color: var(--ink-4); }
.card-ghost code {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-3);
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: 3px;
  padding: 1px 4px;
}

/* ---------------------------------------------------------------- 详情页 */
#page-viewer { display: grid; grid-template-columns: 258px minmax(0, 1fr) 340px; }

.panel { background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
.panel-left { border-right: 1px solid var(--line-soft); }
.panel-right { border-left: 1px solid var(--line-soft); overflow-y: auto; text-align: left; }

.panel-head {
  padding: 15px 14px 11px 16px;
  font-size: 11px;
  letter-spacing: .2em;
  color: var(--ink-4);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--line-soft);
  font-family: var(--font-serif);
}
.panel-head .ph-title { letter-spacing: .2em; }
.panel-head .ph-right { display: flex; align-items: center; gap: 7px; }
.panel-head #layer-count {
  letter-spacing: .02em;
  color: var(--ink-4);
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
  font-size: 10.5px;
}
.order-btn {
  font-family: var(--font-serif);
  font-size: 10.5px;
  letter-spacing: .06em;
  color: var(--ink-3);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px 7px;
  transition: .15s;
  white-space: nowrap;
}
.order-btn:hover { color: var(--ink); border-color: var(--hair); background: var(--panel-2); }

.list-wrap { position: relative; flex: 1; min-height: 0; display: flex; }

/* 层次轴：一条竖线，两端标「外 / 内」；随清单方向翻转 */
.list-axis {
  position: absolute;
  left: 14px;
  top: 16px;
  bottom: 16px;
  width: 1px;
  background: linear-gradient(180deg,
    transparent 0%, var(--line) 10%, var(--line) 90%, transparent 100%);
  pointer-events: none;
}
.list-axis span {
  position: absolute;
  left: -8px;
  width: 17px;
  text-align: center;
  font-family: var(--font-serif);
  font-size: 9px;
  letter-spacing: 0;
  line-height: 13px;
  color: var(--ink-4);
  background: var(--panel);
}
.list-axis .axis-top { top: -7px; }
.list-axis .axis-bottom { bottom: -7px; }

.layer-list {
  list-style: none;
  margin: 0;
  padding: 10px 8px 10px 30px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

/* 层与层之间的「深浅」：越靠内缩进越多、越淡，拆解时整体再拉开一次 */
.layer-list li {
  --d: 0;
  margin-left: calc(var(--d) * 5px);
  opacity: calc(1 - var(--d) * 0.04);
  transition: margin-left .5s cubic-bezier(.2, .7, .2, 1),
              opacity .4s ease;
  transition-delay: calc(var(--d) * 45ms);
}
.layer-list.is-exploded li { margin-left: calc(var(--d) * 14px); }
.layer-item {
  position: relative;
  display: grid;
  grid-template-columns: 26px 1fr auto;
  align-items: center;
  gap: 9px;
  padding: 9px;
  border-radius: 6px;
  border: 1px solid transparent;
  color: var(--ink-2);
  width: 100%;
  text-align: left;
  transition: .15s;
}
.layer-item:hover { background: var(--panel-2); color: var(--ink); }
/* 从层次轴引出的刻度线：一行一根，越往下越短，读起来像剖面 */
.layer-item::before {
  content: "";
  position: absolute;
  left: -13px;
  top: 50%;
  width: calc(9px - var(--d, 0) * 1px);
  height: 1px;
  background: var(--line);
}
.layer-item.is-on::before { background: var(--accent); }
.layer-item.is-on {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--ink);
  box-shadow: inset 2px 0 0 var(--accent);
}
.layer-item .no {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-4);
  border: 1px solid var(--line);
  border-radius: 4px;
  text-align: center;
  line-height: 17px;
}
.layer-item.is-on .no { color: var(--accent); border-color: var(--accent-line); }
.layer-item .nm { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.layer-item .nm b { font-weight: 500; font-size: 13.5px; font-family: var(--font-serif); letter-spacing: .05em; }
.layer-item .nm b .zone {
  font-style: normal;
  margin-left: 6px;
  padding: 0 4px;
  font-size: 9px;
  line-height: 14px;
  border: 1px solid var(--accent-line);
  border-radius: 2px;
  color: var(--accent);
  letter-spacing: 0;
  vertical-align: 1px;
}
.layer-item .nm small {
  font-size: 9.5px;
  letter-spacing: .1em;
  color: var(--ink-4);
  font-family: var(--font-mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.layer-item .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--ink) 18%, transparent);
}

.panel-foot {
  padding: 10px 16px 13px;
  border-top: 1px solid var(--line-soft);
  font-size: 11px;
  color: var(--ink-4);
  line-height: 1.8;
}

/* ---------------------------------------------------------------- 3D 舞台 */
.stage {
  position: relative;
  min-width: 0;
  overflow: hidden;
  background:
    radial-gradient(68% 54% at 50% 20%, var(--stage-1) 0%, transparent 72%),
    radial-gradient(52% 40% at 50% 102%, var(--stage-2) 0%, transparent 72%);
  transition: background .25s ease;
}
#canvas { display: block; width: 100%; height: 100%; }

.stage-note {
  position: absolute;
  right: 14px;
  top: 12px;
  font-size: 11px;
  color: var(--ink-4);
  border: 1px solid var(--line-soft);
  background: color-mix(in srgb, var(--panel) 68%, transparent);
  border-radius: 4px;
  padding: 3px 8px;
  pointer-events: none;
  font-family: var(--font-serif);
  letter-spacing: .08em;
}

.stage-hint {
  position: absolute;
  left: 50%;
  bottom: 76px;
  transform: translateX(-50%);
  font-size: 11.5px;
  color: var(--ink-4);
  letter-spacing: .06em;
  pointer-events: none;
  transition: opacity .3s;
  font-family: var(--font-serif);
}

.stage-tools {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  padding: 6px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-1);
  backdrop-filter: blur(6px);
}
.btn {
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--ink-2);
  border: 1px solid transparent;
  transition: .15s;
  white-space: nowrap;
  font-family: var(--font-serif);
  letter-spacing: .06em;
}
.btn:hover { color: var(--ink); background: var(--panel-2); }
.btn.primary { background: var(--accent-soft); border-color: var(--accent-line); color: var(--ink); }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 22%, var(--panel)); }
.btn.ghost { border-color: var(--line); color: var(--ink-2); }
.btn.ghost:hover { border-color: var(--hair); }
.btn.accent { background: var(--accent); color: #fff8ee; border-color: transparent; }
.btn.accent:hover { background: color-mix(in srgb, var(--accent) 84%, #000); }
.btn.is-on {
  background: var(--accent);
  color: #fff8ee;
  border-color: transparent;
}
.btn:disabled { opacity: .32; cursor: default; }
.btn:disabled:hover { background: none; color: var(--ink-2); }

/* 选中层的浮标（锚在层顶） */
.layer-label {
  position: absolute;
  transform: translate(-50%, -116%);
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  padding: 4px 9px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--accent) 88%, #000);
  color: #fff6ea;
  font-size: 11.5px;
  letter-spacing: .06em;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 6px 18px -12px #000;
  z-index: 6;
}
.layer-label b { font-family: var(--font-mono); font-size: 10.5px; opacity: .85; }
.layer-label span { font-family: var(--font-serif); font-size: 12.5px; }
.layer-label i { font-style: normal; font-size: 10px; opacity: .7; }
.layer-label::after {
  content: "";
  position: absolute;
  left: 50%; bottom: -4px;
  width: 8px; height: 8px;
  transform: translateX(-50%) rotate(45deg);
  background: inherit;
}

/* ---------------------------------------------------------------- 样本卡 */
.cards { position: absolute; inset: 0; pointer-events: none; z-index: 5; }

.cards-col {
  position: absolute;
  width: 190px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  left: 0; top: 0;
}

.card-sample {
  position: relative;
  width: 100%;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--panel) 96%, transparent);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-1);
  padding: 9px;
  pointer-events: auto;
  cursor: pointer;
  opacity: 0;
  transform: translateY(8px) scale(.985);
  transition: opacity .32s ease, transform .32s ease, border-color .15s;
}
.card-sample.is-in { opacity: 1; transform: none; }
.card-sample:hover { border-color: var(--hair); }
.card-sample .cap {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 10px;
  letter-spacing: .16em;
  color: var(--ink-4);
  margin-bottom: 7px;
  font-family: var(--font-serif);
}
.card-sample .cap b {
  color: var(--ink-2);
  font-weight: 500;
  letter-spacing: .04em;
  font-size: 11.5px;
  font-family: var(--font-sans);
}
.card-sample .vis {
  border-radius: 5px;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: #0f1114;      /* 纹样「标本」统一深底，明暗主题都用它 */
  border: 1px solid var(--line-soft);
}
.card-sample .vis.pattern { aspect-ratio: 1 / 1; }
.card-sample .vis.material { aspect-ratio: 4 / 3; }
.card-sample .vis figure { margin: 0; width: 100%; height: 100%; }
.card-sample .vis img {
  display: block;
  width: 100%; height: 100%;
  object-fit: cover;
}
.card-sample .vis.pattern img { object-fit: contain; padding: 4px; }

.img-cap {
  margin-top: 7px;
  font-size: 10.5px;
  line-height: 1.6;
  color: var(--ink-4);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-sample .foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
  font-size: 10.5px;
  color: var(--ink-4);
  font-family: var(--font-mono);
}
.card-sample .foot .arrow {
  width: 16px; height: 16px;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--ink-2);
  font-size: 10px;
}

.swatches { display: flex; gap: 8px; padding: 10px; width: 100%; }
.swatch { flex: 1; display: flex; flex-direction: column; gap: 5px; align-items: center; }
.swatch i {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 4px;
  border: 1px solid color-mix(in srgb, var(--ink) 12%, transparent);
}
.swatch span { font-size: 10.5px; color: var(--ink-3); letter-spacing: .06em; font-family: var(--font-serif); }
.swatch em {
  font-style: normal;
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--ink-4);
}

.sphere-wrap { padding: 14px; width: 100%; display: grid; place-items: center; }
.sphere { width: 74px; height: 74px; border-radius: 50%; position: relative; box-shadow: inset -10px -14px 24px rgba(0, 0, 0, .5); }
.sphere::after {
  content: "";
  position: absolute;
  left: 22%; top: 16%;
  width: 26%; height: 20%;
  border-radius: 50%;
  background: rgba(255, 255, 255, .55);
  filter: blur(6px);
}

.text-vis {
  padding: 12px 10px;
  font-size: 11.5px;
  line-height: 1.8;
  color: var(--ink-3);
  max-height: 128px;
  overflow: hidden;
}

/* ---------------------------------------------------------------- 右栏 */
/* 右栏：加宽左内边距、拉开段间距，读起来像解说页而不是表单 */
.p-right {
  padding: 24px 22px 32px 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  text-align: left;
}
.p-right * { text-align: left; }

.p-title { display: flex; flex-direction: column; gap: 8px; }
.p-title h2 {
  font-family: var(--font-serif);
  font-size: 23px;
  margin: 0;
  letter-spacing: .14em;
  font-weight: 600;
  line-height: 1.3;
}
.p-meta {
  margin: 0;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  font-size: 11.5px;
  color: var(--ink-3);
  letter-spacing: .08em;
  font-family: var(--font-serif);
}
.p-meta i { font-style: normal; color: var(--line); letter-spacing: 0; }

/* 分节：小标题 + 细分隔线，段落之间靠 gap 撑开，不再挤成一坨 */
.p-section { display: flex; flex-direction: column; gap: 0; }
.p-sec-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--line-soft);
  font-family: var(--font-serif);
  font-size: 10.5px;
  letter-spacing: .24em;
  color: var(--ink-4);
}
.p-count { font-family: var(--font-mono); font-size: 10px; letter-spacing: .02em; color: var(--ink-4); }

.p-list { margin: 0; display: flex; flex-direction: column; }
.p-row {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr);
  gap: 16px;
  padding: 11px 0;
  border-bottom: 1px dashed color-mix(in srgb, var(--hair) 40%, transparent);
}
.p-row:last-child { border-bottom: none; }
.p-row dt {
  font-family: var(--font-serif);
  font-size: 11.5px;
  letter-spacing: .14em;
  color: var(--ink-4);
  padding-top: 3px;
}
.p-row dd { margin: 0; font-size: 13px; line-height: 1.95; color: var(--ink-2); }
.p-row dd b { color: var(--ink); font-weight: 500; }
.p-row dd.p-src { font-size: 12.5px; line-height: 1.9; color: var(--ink-3); }

/* 藏品状态前的圆点，颜色跟着状态走 */
.p-status { display: inline-flex; align-items: center; gap: 7px; }
.p-status::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--idle);
}
.p-status.s-done::before { background: var(--ok); }
.p-status.s-building::before { background: var(--warn); }
.p-status.s-data-only::before { background: var(--idle); }

/* 提示块：浅底卡片，和正文拉开层次 */
.p-note {
  margin: 0;
  padding: 13px 15px;
  border-radius: 8px;
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
  font-family: var(--font-serif);
  font-size: 12.5px;
  line-height: 2;
  letter-spacing: .04em;
  color: var(--ink-2);
}

/* 快捷键：独立成行、间距均匀，不再用「·」硬拼 */
.p-keys { display: flex; flex-wrap: wrap; gap: 9px 16px; }
.p-key {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  letter-spacing: .04em;
  color: var(--ink-3);
}
.p-key kbd {
  font-size: 10px;
  padding: 1px 5px;
  border-color: color-mix(in srgb, var(--hair) 70%, transparent);
  color: var(--ink-3);
}
.p-footnote {
  margin: 0;
  font-size: 11.5px;
  line-height: 1.95;
  color: var(--ink-4);
  letter-spacing: .04em;
}

/* 属性 chip */
.p-chips { display: flex; flex-wrap: wrap; gap: 7px; padding-top: 11px; }
.p-chips span {
  font-family: var(--font-serif);
  font-size: 11px;
  letter-spacing: .08em;
  color: var(--ink-3);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 3px 9px;
}

.quote {
  margin: 0;
  font-size: 12.5px;
  line-height: 2.05;
  letter-spacing: .04em;
  color: var(--ink-2);
  border-left: 2px solid var(--accent-line);
  padding: 3px 0 3px 15px;
  font-family: var(--font-serif);
}

.p-empty { font-size: 12.5px; color: var(--ink-4); line-height: 2; }

.p-actions { display: flex; flex-direction: column; gap: 9px; margin-top: 2px; }
.p-actions .btn { width: 100%; text-align: center; }

/* ---------------------------------------------------------------- Overlay */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: var(--veil);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding: 40px;
  animation: fade .18s ease both;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.ov-box {
  width: min(70vw, 900px);
  max-height: 82vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 252px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--shadow-2);
}
.ov-vis {
  background: #0d0f12;
  display: grid;
  place-items: center;
  padding: 24px;
  min-height: 340px;
}
.ov-vis figure { margin: 0; width: 100%; height: 100%; display: grid; place-items: center; }
.ov-vis img {
  max-width: 100%;
  max-height: 52vh;
  object-fit: contain;
  border-radius: 4px;
}
.ov-vis svg { width: 78%; height: auto; max-height: 52vh; }
.ov-vis .swatches { padding: 0; gap: 14px; max-width: 340px; margin: 0 auto; }
.ov-vis .swatch i { aspect-ratio: 1 / 1; }
.ov-vis .sphere { width: 150px; height: 150px; }
.ov-vis .text-vis { max-height: none; font-size: 14px; line-height: 2; padding: 24px 8px; color: var(--ink-2); }

.ov-side { border-left: 1px solid var(--line-soft); padding: 22px 20px; overflow-y: auto; }
.ov-side h3 {
  font-family: var(--font-serif);
  font-size: 18px;
  margin: 0 0 4px;
  letter-spacing: .1em;
  font-weight: 600;
}
.ov-side .kind { font-size: 10.5px; letter-spacing: .18em; color: var(--ink-4); margin-bottom: 16px; }
.ov-side dl { margin: 0; display: flex; flex-direction: column; gap: 13px; }
.ov-side dt { font-size: 10.5px; letter-spacing: .16em; color: var(--ink-4); margin-bottom: 3px; font-family: var(--font-serif); }
.ov-side dd { margin: 0; font-size: 12.5px; line-height: 1.8; color: var(--ink-2); }

.ov-close {
  position: absolute;
  right: 22px; top: 18px;
  width: 32px; height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  display: grid; place-items: center;
  color: var(--ink-2);
  background: color-mix(in srgb, var(--panel) 80%, transparent);
}
.ov-close:hover { color: var(--ink); border-color: var(--hair); }

/* ---------------------------------------------------------------- 加载 */
.loading {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--ink-4);
  font-size: 13px;
  letter-spacing: .2em;
  background: var(--bg);
  z-index: 90;
  font-family: var(--font-serif);
}

@media (max-width: 1180px) {
  #page-viewer { grid-template-columns: 214px minmax(0, 1fr) 300px; }
  .ov-box { grid-template-columns: 1fr; }
  .ov-side { border-left: none; border-top: 1px solid var(--line-soft); }
}
