/* ==========================================================================
   最后的 Token · 样式
   --------------------------------------------------------------------------
   分两部分：
     一、画面层 —— 照片、光柱、窗户、尘埃、暗角、颗粒（坐标基于原图 2880x1440 的百分比）
     二、界面层 —— 面板、按钮、列表、表格，用的是 GitHub 式的克制语言：
         实底、1px 描边、系统字体、单一蓝色强调，深度只靠细线不靠阴影。
   ========================================================================== */

/* ========== 一、画面层 ========== */

:root {
  --warm: 255 202 148;
  --intensity: 1;
  --light: 1;
  --glow: 1;
}

#stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #05040a;
  z-index: 0;
  /* 画面是一整块可拖动的面：交给 Pointer Events 处理，浏览器别自己滚/缩 */
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
}
#stage.is-dragging { cursor: grabbing; }
#stage.is-dragging .spot { cursor: grabbing; }

#space {
  position: absolute;
  transform-origin: 50% 50%;
  will-change: transform;
}

.photo {
  position: absolute;
  inset: 0;
  background: #000 url("assets/bg.jpg") center / 100% 100% no-repeat;
  filter: saturate(1.07) contrast(1.07) brightness(0.99);
}

/* 阳光光柱 */
.beams { position: absolute; inset: 0; mix-blend-mode: screen; pointer-events: none; }
.beam { position: absolute; filter: blur(26px); will-change: opacity; }

/* 后墙三扇窗 */
.windows { position: absolute; inset: 0; pointer-events: none; }
.winwrap { position: absolute; }
.win-halo {
  position: absolute;
  inset: -55%;
  mix-blend-mode: screen;
  filter: blur(16px);
  background: radial-gradient(closest-side, rgb(var(--warm) / .24), rgb(var(--warm) / .08) 55%, transparent 78%);
  will-change: opacity;
}
.win { position: absolute; inset: 0; overflow: hidden; mix-blend-mode: screen; }
.win-sky {
  position: absolute;
  inset: -18% -26%;
  background: radial-gradient(112% 78% at 50% 46%, rgb(255 214 170 / .34), rgb(255 168 122 / .13) 52%, transparent 80%);
  animation: skyDrift 26s ease-in-out infinite alternate;
  will-change: transform, opacity;
}
@keyframes skyDrift {
  from { transform: translate3d(-2.5%, 0, 0); }
  to   { transform: translate3d(2.5%, .8%, 0); }
}
.win-tw { position: absolute; left: 0; right: 0; bottom: 0; height: 44%; }
.win-tw i {
  position: absolute;
  width: 4px; height: 4px;
  margin: -2px 0 0 -2px;
  border-radius: 50%;
  background: rgb(255 228 180);
  box-shadow: 0 0 5px 1px rgb(255 190 120 / .85);
  filter: blur(.4px);
  animation: twinkle 5s ease-in-out infinite;
  will-change: opacity;
}
@keyframes twinkle {
  0%, 100% { opacity: .10; }
  42%      { opacity: .92; }
  68%      { opacity: .38; }
}

/* 尘埃 */
#motes {
  position: absolute;
  inset: -6%;
  width: 112%; height: 112%;
  mix-blend-mode: screen;
  pointer-events: none;
}
#cool {
  position: absolute;
  inset: -4%;
  background: linear-gradient(118deg, transparent 40%, rgb(92 118 186 / .17) 86%);
  mix-blend-mode: multiply;
  opacity: .85;
  pointer-events: none;
}
#wash {
  position: absolute;
  inset: -6%;
  mix-blend-mode: screen;
  pointer-events: none;
  background:
    radial-gradient(58% 64% at 3% 14%, rgb(var(--warm) / .34), rgb(var(--warm) / .09) 48%, transparent 76%),
    radial-gradient(48% 42% at 9% 94%, rgb(var(--warm) / .18), transparent 72%);
  will-change: opacity, transform;
}
#ambient {
  position: absolute;
  inset: 0;
  background: rgb(var(--warm) / .03);
  mix-blend-mode: screen;
  pointer-events: none;
  will-change: opacity;
}
#lantern {
  position: absolute;
  left: 0; top: 0;
  width: 42vmax; height: 42vmax;
  margin: -21vmax 0 0 -21vmax;
  background: radial-gradient(closest-side, rgb(var(--warm) / .28), rgb(var(--warm) / .07) 48%, transparent 74%);
  mix-blend-mode: screen;
  opacity: 0;
  pointer-events: none;
  will-change: transform, opacity;
}
#vignette {
  position: absolute;
  inset: -6%;
  pointer-events: none;
  will-change: transform, opacity;
  background:
    radial-gradient(116% 102% at 42% 46%, rgba(0,0,0,0) 36%, rgb(10 6 18 / .46) 74%, rgb(6 4 12 / .80) 100%),
    linear-gradient(to top, rgb(10 5 2 / .36), rgba(0,0,0,0) 38%);
}
#grain {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  opacity: .05;
  mix-blend-mode: overlay;
  pointer-events: none;
}
#fade {
  position: absolute;
  inset: 0;
  background: #05040a;
  opacity: 1;
  transition: opacity 1.8s ease-out;
  pointer-events: none;
}

/* ---------- 角色热区：跟着 #space 一起平移缩放 ---------- */

.hotspots { position: absolute; inset: 0; }

.spot {
  position: absolute;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 18px;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  transition: background-color 160ms var(--ease), border-color 160ms var(--ease);
}
.spot::after {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  background: radial-gradient(58% 62% at 50% 46%, rgb(var(--warm) / .22), transparent 72%);
  opacity: 0;
  transition: opacity 180ms var(--ease);
  pointer-events: none;
}
.spot:hover, .spot:focus-visible {
  border-color: rgb(var(--warm) / .55);
  background: rgb(255 240 220 / .05);
  outline: none;
}
.spot:hover::after, .spot:focus-visible::after { opacity: 1; }
.spot:focus-visible { box-shadow: 0 0 0 3px rgb(255 214 170 / .45); }

.spot-tag {
  position: absolute;
  left: 50%;
  bottom: 8px;
  transform: translateX(-50%);
  white-space: nowrap;
  padding: 3px 9px;
  border-radius: 9999px;
  background: rgb(8 6 4 / .78);
  border: 1px solid rgb(var(--warm) / .40);
  color: #ffe9cf;
  font-size: 12px;
  line-height: 1.4;
  letter-spacing: .01em;
  opacity: 0;
  transition: opacity 160ms var(--ease);
  pointer-events: none;
}
.spot:hover .spot-tag, .spot:focus-visible .spot-tag { opacity: 1; }
.spot.is-active { border-color: rgb(var(--warm) / .75); background: rgb(255 240 220 / .07); }
.spot.is-active .spot-tag { opacity: 1; }

/* ========== 二、界面层 ========== */

:root {
  color-scheme: dark;
  --brand-300: #8ab4f8; --brand-500: #4285f4; --brand-600: #8ab4f8; --brand-700: #8ab4f8;
  --gray-100: #f3f4f6; --gray-500: #6b7280;
  --bg: #000000; --surface: #0d0d0d; --surface-2: #121212;
  --border: #1f1f1f; --control-border: #303030;
  --fg: #f3f4f6; --fg-muted: #9ca3af; --fg-faint: #6b7280;
  --accent-bg: #f3f4f6; --accent-fg: #111827;
  --good: #4ade80; --warn: #fbbf24;
  --radius-control: 6px; --radius-card: 12px;
  --ease: cubic-bezier(0.2, 0.7, 0.3, 1);
  --panel-w: 460px;
}

html:not(.dark) {
  color-scheme: light;
  --brand-600: #1a73e8; --brand-700: #0b57d0;
  --bg: #ffffff; --surface: #ffffff; --surface-2: #f9fafb;
  --border: #e5e7eb; --control-border: #d1d5db;
  --fg: #111827; --fg-muted: #4b5563; --fg-faint: #6b7280;
  --accent-bg: #111827; --accent-fg: #ffffff;
  --good: #15803d; --warn: #b45309;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #05040a;
}

body {
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  color: var(--fg);
  font-size: 14px;
  line-height: 1.5;
}

h1, h2, h3 { font-weight: 600; letter-spacing: -0.025em; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

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

:focus-visible { outline: 3px solid rgb(107 114 128 / .55); outline-offset: 2px; }

/* ---------- 右上角按钮 ---------- */

#controls {
  position: fixed;
  right: 20px; top: 18px;
  z-index: 12;
  display: flex;
  gap: 8px;
}
.ctl {
  height: 36px;
  padding: 0 13px;
  border-radius: 9999px;
  border: 1px solid var(--control-border);
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--fg);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: background-color 150ms var(--ease), border-color 150ms var(--ease);
}
.ctl:hover { background: var(--surface-2); }
.ctl.icon { width: 36px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
#btn-theme { font-size: 15px; }

/* ---------- 操作提示 ---------- */

#hint {
  position: fixed;
  left: 50%; bottom: 28px;
  transform: translateX(-50%);
  pointer-events: none;
  z-index: 12;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 9999px;
  background: color-mix(in srgb, var(--bg) 74%, transparent);
  border: 1px solid var(--border);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--fg-muted);
  font-size: 13px;
  transition: opacity 400ms var(--ease), transform 400ms var(--ease);
}
#hint .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--brand-600);
  animation: breathe 2.6s ease-in-out infinite;
}
@keyframes breathe { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }
#hint.is-gone { opacity: 0; transform: translate(-50%, 8px); pointer-events: none; }

/* ---------- 右下角：版权与数据状态搬进了「图鉴与来源」窗口 ---------- */

#data-status {
  border: 0;
  padding: 0;
  background: none;
  font: inherit;
  font-size: 12px;
  color: var(--brand-700);
  cursor: pointer;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 150ms var(--ease);
}
#data-status:hover { color: var(--fg); }
#data-status .ok { color: var(--good); }
#data-status .warn { color: var(--warn); }

/* 浮在画面上的小标签，字要能顶住明亮的背景 */
#controls .ctl, #hint { text-shadow: none; }

/* 面板停在哪一边，右上角那排按钮就整体让位，别被盖住 */
#controls { transition: opacity 400ms var(--ease), right 240ms var(--ease); }
body.panel-right #controls { right: calc(var(--panel-w) + 20px); }

/* 壁纸模式：鼠标停下几秒就把浮层收干净，桌面上只剩画面 */
body.idle #controls, body.idle #hint { opacity: 0; pointer-events: none; }

/* ---------- 遮罩 ---------- */

#scrim {
  position: fixed;
  inset: 0;
  z-index: 14;
  background: rgb(0 0 0 / .42);
  opacity: 0;
  transition: opacity 160ms var(--ease);
}
#scrim.is-on { opacity: 1; }
#scrim[hidden] { display: none; }

/* ---------- 角色档案面板 ---------- */

#panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  z-index: 16;
  width: var(--panel-w);
  max-width: 100vw;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-left: 1px solid var(--border);
  transform: translateX(102%);
  transition: transform 240ms var(--ease);
}
#panel[hidden] { display: none; }
#panel.is-open { transform: translateX(0); }

/* 点到画面右半边的人物时，面板改停到左边，免得把刚点开的角色盖住 */
#panel.dock-left {
  right: auto;
  left: 0;
  border-left: 0;
  border-right: 1px solid var(--border);
  transform: translateX(-102%);
}
#panel.dock-left.is-open { transform: translateX(0); }
/* 换边的一瞬间关掉动画，不然会看到它从一边“飘”到另一边 */
#panel.no-anim, #panel.no-anim * { transition: none !important; }

.panel-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 20px 0;
}
.eyebrow {
  font-size: 10px;
  letter-spacing: .16em;
  text-transform: uppercase;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--brand-600);
  margin-bottom: 6px;
}
.panel-top h2 { font-size: 24px; line-height: 1.2; }
.panel-org { font-size: 12px; color: var(--fg-faint); margin-top: 3px; }
.panel-look {
  padding: 12px 20px 0;
  font-size: 13px;
  color: var(--fg-muted);
}
.icon-btn {
  flex: none;
  width: 32px; height: 32px;
  border-radius: var(--radius-control);
  border: 1px solid var(--control-border);
  background: transparent;
  color: var(--fg-muted);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: color 150ms var(--ease), border-color 150ms var(--ease), background-color 150ms var(--ease);
}
.icon-btn:hover { color: var(--fg); border-color: var(--fg-faint); background: var(--surface-2); }

.panel-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 18px 20px 28px;
  scrollbar-width: thin;
  scrollbar-color: var(--control-border) transparent;
}
.panel-body::-webkit-scrollbar { width: 8px; }
.panel-body::-webkit-scrollbar-thumb { background: var(--control-border); border-radius: 9999px; }

/* 分区 */
.sec { margin-bottom: 22px; }
.sec:last-child { margin-bottom: 4px; }
.sec-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.sec-head h3 { font-size: 13px; letter-spacing: 0; }
.sec-head span { font-size: 11px; color: var(--fg-faint); }

/* 综合能力卡 */
.ability {
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 16px;
  background: var(--surface-2);
}
.ability-top { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.ability-num {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 34px;
  line-height: 1;
  font-weight: 600;
  letter-spacing: -0.03em;
}
.ability-num small { font-size: 12px; font-weight: 400; color: var(--fg-faint); margin-left: 6px; letter-spacing: 0; }
.ability-who { text-align: right; font-size: 12px; color: var(--fg-muted); }
.ability-who b { display: block; color: var(--fg); font-size: 13px; font-weight: 500; }
.bar {
  position: relative;
  height: 6px;
  margin-top: 14px;
  border-radius: 9999px;
  background: color-mix(in srgb, var(--fg-faint) 25%, transparent);
  overflow: hidden;
}
.bar > i {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: 9999px;
  background: var(--brand-600);
}
.bar-note { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 12px; margin-top: 6px; font-size: 11px; color: var(--fg-faint); }

/* 版本列表 */
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border-radius: 9999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--fg-muted);
  padding: 4px 10px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  transition: color 150ms var(--ease), border-color 150ms var(--ease), background-color 150ms var(--ease);
}
.chip:hover { background: var(--surface-2); color: var(--fg); }
.chip[aria-pressed="true"] { background: #e8f0fe14; border-color: var(--brand-600); color: var(--brand-600); }

.vlist {
  margin-top: 10px;
  max-height: 18rem;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  scrollbar-width: thin;
  scrollbar-color: var(--control-border) transparent;
}
.vrow {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background-color 150ms var(--ease);
}
.vrow:last-child { border-bottom: 0; }
.vrow:hover { background: var(--surface-2); }
.vrow[aria-current="true"] { background: #e8f0fe12; }
.vrow[aria-current="true"] .vname { color: var(--brand-600); }
.vname { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vdate { font-size: 11px; color: var(--fg-faint); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.vscore {
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--fg);
  min-width: 40px;
  text-align: right;
}
.vscore.is-none { color: var(--fg-faint); }

/* 详情：键值表 */
.kv {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 7px 14px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  font-size: 13px;
}
.kv dt { color: var(--fg-faint); white-space: nowrap; font-size: 12px; }
.kv dd { text-align: right; }

/* 基准分 */
.bench { margin-top: 12px; }
.bench-row {
  display: grid;
  grid-template-columns: 1fr 46px;
  gap: 4px 10px;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.bench-row:last-child { border-bottom: 0; }
.bench-name { font-size: 12px; }
.bench-name em { font-style: normal; color: var(--fg-faint); font-size: 11px; margin-left: 6px; }
.bench-val {
  font-size: 12px;
  text-align: right;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.bench-bar {
  grid-column: 1 / -1;
  height: 4px;
  border-radius: 9999px;
  background: color-mix(in srgb, var(--fg-faint) 22%, transparent);
  overflow: hidden;
}
.bench-bar > i { display: block; height: 100%; border-radius: 9999px; background: var(--brand-500); }

/* 价格表 */
table.price {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow: hidden;
}
table.price th, table.price td {
  padding: 8px 12px;
  text-align: right;
  border-bottom: 1px solid var(--border);
  font-weight: 400;
}
table.price th:first-child, table.price td:first-child { text-align: left; }
table.price thead th { color: var(--fg-faint); font-size: 11px; font-weight: 500; }
table.price tbody tr:last-child td { border-bottom: 0; }
table.price td.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
table.price .total { font-weight: 600; }

.note { margin-top: 8px; font-size: 11px; color: var(--fg-faint); line-height: 1.6; }
.empty {
  padding: 14px;
  border: 1px dashed var(--control-border);
  border-radius: var(--radius-card);
  font-size: 13px;
  color: var(--fg-muted);
}
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 11px;
  border: 1px solid var(--border);
  color: var(--fg-muted);
  margin-right: 6px;
}
.badge.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }

/* ---------- 关于对话框 ---------- */

#about {
  z-index: 20;
  margin: auto;
  width: min(660px, calc(100vw - 32px));
  max-height: min(78vh, 720px);
  overflow-y: auto;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
  color: var(--fg);
  scrollbar-width: thin;
}
#about::backdrop { background: rgb(0 0 0 / .62); }
#about[open] { animation: rise 280ms var(--ease); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.about-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.about-top h2 { font-size: 20px; }
.about-lead { margin: 12px 0 16px; font-size: 13px; color: var(--fg-muted); }
#about h3 { font-size: 13px; margin: 20px 0 8px; }
.about-list {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}
.about-list button {
  width: 100%;
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 150ms var(--ease), background-color 150ms var(--ease);
}
.about-list button:hover { border-color: var(--brand-600); background: var(--surface-2); }
.about-list .num {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  color: var(--brand-600);
}
.about-list .who { font-size: 13px; }
.about-list .where { margin-left: auto; font-size: 11px; color: var(--fg-faint); }
.about-sources { list-style: none; display: grid; gap: 8px; }
.about-sources li { font-size: 12px; color: var(--fg-muted); }
.about-sources a { color: var(--brand-700); }
.about-note { font-size: 12px; color: var(--fg-muted); margin-top: 8px; }
.about-note a { color: var(--brand-700); }

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

@media (max-width: 640px) {
  :root { --panel-w: 100vw; }
  #controls { right: 12px; top: 12px; }
  #hint { width: calc(100vw - 24px); justify-content: center; font-size: 12px; bottom: 24px; }
  #panel, #panel.dock-left {
    top: auto;
    left: 0;
    right: 0;
    height: 78vh;
    border-left: 0;
    border-right: 0;
    border-top: 1px solid var(--border);
    border-radius: 14px 14px 0 0;
    transform: translateY(102%);
  }
  #panel.is-open, #panel.dock-left.is-open { transform: translateY(0); }
  /* 手机上右上角那排按钮不跟着面板跑 */
  body.panel-right #controls { right: 12px; }
  .about-list { grid-template-columns: 1fr; }
  .panel-top h2 { font-size: 21px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
