:root {
  color-scheme: light;
  --bg: #f3eee4;
  --surface: #fbf8f1;
  --surface-2: #ebe4d6;
  --ink: #1c1814;
  --muted: #6c6355;
  --line: #d9cfbd;
  --red: #b42a18;
  --yellow: #a97c0c;
  --green: #17734e;
  --blue: #2c5a9e;
  --accent: var(--red);
  --stage: #1a1714;
  --mark: #f3d36e;
  --shadow: 0 1px 2px rgba(40, 30, 15, .08), 0 8px 24px rgba(40, 30, 15, .07);
  --serif: "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC", STSong, serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  --radius: 10px;
  --topbar: 64px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #14120f;
    --surface: #1e1b17;
    --surface-2: #2a261f;
    --ink: #efe7d8;
    --muted: #a99e8b;
    --line: #38322a;
    --red: #e8604a;
    --yellow: #e3b22d;
    --green: #4bbf8f;
    --blue: #7ba7e8;
    --mark: #7a5c00;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #14120f;
  --surface: #1e1b17;
  --surface-2: #2a261f;
  --ink: #efe7d8;
  --muted: #a99e8b;
  --line: #38322a;
  --red: #e8604a;
  --yellow: #e3b22d;
  --green: #4bbf8f;
  --blue: #7ba7e8;
  --mark: #7a5c00;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.6 var(--sans);
}
body.locked { overflow: hidden; }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
img { max-width: 100%; display: block; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
main { flex: 1; width: 100%; outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  min-height: var(--topbar);
  display: flex; align-items: center; gap: 14px;
  padding: 10px max(20px, env(safe-area-inset-right)) 10px max(20px, env(safe-area-inset-left));
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; flex-shrink: 0; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand strong { font-family: var(--serif); font-size: 19px; letter-spacing: .06em; }
.brand small { color: var(--muted); font-size: 12px; }
.dots { display: inline-flex; gap: 3px; }
.dots i { width: 9px; height: 9px; border-radius: 50%; }
.dots i:nth-child(1) { background: #c8321f; }
.dots i:nth-child(2) { background: #e3b22d; }
.dots i:nth-child(3) { background: #1f8a5f; }

.search { flex: 1; max-width: 520px; margin-left: auto; position: relative; display: flex; align-items: center; }
.search svg { position: absolute; left: 12px; width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.search input {
  width: 100%; height: 40px; padding: 0 12px 0 38px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg);
  font-size: 16px; /* 小于 16px 时 iOS 会自动放大页面 */
}
.topnav { display: flex; gap: 4px; }
.topnav a { padding: 7px 12px; border-radius: 7px; text-decoration: none; color: var(--muted); white-space: nowrap; }
.topnav a.active { color: var(--ink); background: var(--surface-2); }
.icon-btn {
  width: 40px; height: 40px; flex-shrink: 0;
  display: inline-grid; place-items: center;
  border: 0; border-radius: 8px; background: transparent;
}
.icon-btn:hover { background: var(--surface-2); }
.menu-btn { display: none; }

.layout {
  display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 28px;
  max-width: 1480px; margin: 0 auto; padding: 24px 20px 48px;
}
.sidebar { position: sticky; top: calc(var(--topbar) + 20px); align-self: start; max-height: calc(100dvh - var(--topbar) - 40px); overflow: auto; padding-right: 4px; }
.sidebar h2 { font: 600 13px var(--sans); color: var(--muted); margin: 20px 0 8px; letter-spacing: .08em; }
.sidebar h2:first-child { margin-top: 0; }
.cat-list, .cat-list ul { list-style: none; margin: 0; padding: 0; }
.cat-list ul { padding-left: 14px; }
.cat-link {
  width: 100%; display: flex; justify-content: space-between; gap: 10px;
  padding: 6px 10px; border: 0; border-radius: 6px; background: none; text-align: left;
}
.cat-link:hover { background: var(--surface-2); }
.cat-link.active { background: var(--ink); color: var(--bg); }
.cat-link .num { color: var(--muted); font-variant-numeric: tabular-nums; }
.cat-link.active .num { color: inherit; opacity: .7; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 3px 10px; border: 1px solid var(--line); border-radius: 999px;
  background: transparent; font-size: 13px;
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar h1 { font: 600 22px var(--serif); margin: 0; letter-spacing: .04em; }
.toolbar .count { color: var(--muted); font-size: 14px; margin-left: 8px; font-family: var(--sans); font-weight: 400; }
.sort { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.sort select { height: 34px; padding: 0 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; }
.card {
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  text-decoration: none; transition: transform .16s ease, box-shadow .16s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.card-media { position: relative; aspect-ratio: 1; background: var(--surface-2); overflow: hidden; }
.card-media img { width: 100%; height: 100%; object-fit: cover; }
.card .badge { position: absolute; left: 8px; top: 8px; }
.card-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 2px; }
.card-id { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.card-name { font: 600 16px/1.35 var(--serif); }
.card-cat { color: var(--muted); font-size: 13px; }
.card-hit { color: var(--muted); font-size: 12.5px; margin-top: 4px; overflow-wrap: anywhere; }
mark { background: var(--mark); color: inherit; border-radius: 2px; padding: 0 1px; }

.placeholder { width: 100%; height: 100%; display: grid; place-items: center; color: var(--muted); font-size: 13px; }
.placeholder .dots i { width: 14px; height: 14px; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 5px; font-size: 12px; font-weight: 600; line-height: 1.6;
  color: #fff; background: #4a443a; white-space: nowrap;
}
.badge.photo { background: #17734e; }
.badge.ai { background: #b42a18; }
.badge.provided { background: #2c5a9e; }
.badge.spin { background: #6b5a1f; }
.badge.none { background: #5d5850; }

.status { padding: 64px 20px; text-align: center; color: var(--muted); }
.more { height: 1px; }

.detail { max-width: 1320px; margin: 0 auto; padding: 16px 20px 48px; }
.crumb { display: flex; flex-wrap: wrap; gap: 4px 6px; color: var(--muted); font-size: 14px; margin-bottom: 12px; }
.crumb button { border: 0; background: none; padding: 0; color: inherit; text-decoration: underline; text-underline-offset: 3px; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 28px; align-items: start; }
.viewer { min-width: 0; }
.tabs { display: flex; gap: 4px; margin-bottom: 10px; overflow-x: auto; }
.tab { padding: 7px 14px; border: 0; border-radius: 7px; background: none; color: var(--muted); white-space: nowrap; }
.tab[aria-selected="true"] { background: var(--ink); color: var(--bg); }
.stage {
  position: relative; width: 100%; aspect-ratio: 4 / 3; max-height: 76dvh;
  background: var(--stage); border-radius: var(--radius); overflow: hidden;
}
.stage model-viewer { width: 100%; height: 100%; --poster-color: transparent; background: radial-gradient(ellipse at 50% 42%, #3a342c, #171411 75%); }
.stage.fake-full { position: fixed; inset: 0; z-index: 60; max-height: none; aspect-ratio: auto; border-radius: 0; }
.stage-tools {
  position: absolute; right: 10px; bottom: 10px; z-index: 2;
  display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end;
}
.tool {
  min-height: 34px; padding: 5px 11px; border: 1px solid rgba(255, 255, 255, .22); border-radius: 7px;
  background: rgba(20, 18, 15, .72); color: #f4eee2; font-size: 13px;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.tool[aria-pressed="true"] { background: #f4eee2; color: #14120f; }
.ar-btn { position: absolute; right: 10px; top: 10px; }
.progress { position: absolute; left: 0; right: 0; top: 0; height: 3px; background: transparent; z-index: 2; }
.progress i { display: block; height: 100%; width: 0; background: #e3b22d; transition: width .2s; }
.hint { position: absolute; left: 12px; top: 10px; z-index: 2; color: rgba(244, 238, 226, .78); font-size: 12.5px; pointer-events: none; }
.stage-note { position: absolute; inset: 0; display: grid; place-items: center; padding: 20px; text-align: center; color: #d8cfbf; }

.spin { position: absolute; inset: 0; touch-action: pan-y; cursor: grab; user-select: none; -webkit-user-select: none; }
.spin.dragging { cursor: grabbing; }
.spin canvas { width: 100%; height: 100%; display: block; }

.video-wrap { display: grid; gap: 10px; }
.video-wrap video { width: 100%; max-height: 76dvh; background: #000; border-radius: var(--radius); display: block; }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 8px; }
.gallery button { padding: 0; border: 0; border-radius: 6px; overflow: hidden; background: var(--surface-2); aspect-ratio: 1; }
.gallery img { width: 100%; height: 100%; object-fit: cover; }

.lightbox {
  position: fixed; inset: 0; z-index: 70; display: grid; place-items: center;
  background: rgba(10, 9, 7, .95); touch-action: pan-y;
}
.lightbox img { max-width: 100vw; max-height: 100dvh; object-fit: contain; }
.lightbox .icon-btn { position: absolute; color: #fff; background: rgba(255, 255, 255, .12); }
.lightbox .close { right: 12px; top: 12px; }
.lightbox .prev { left: 12px; top: calc(50% - 20px); }
.lightbox .next { right: 12px; top: calc(50% - 20px); }
.lightbox .pos { position: absolute; bottom: 14px; left: 0; right: 0; text-align: center; color: #ddd; font-size: 13px; }

.info { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.info .code { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.info h1 { font: 600 26px/1.3 var(--serif); margin: 2px 0 10px; letter-spacing: .03em; }
.source { display: grid; gap: 6px; padding: 10px 12px; margin: 10px 0 14px; border-radius: 8px; background: var(--surface-2); font-size: 13.5px; }
.source.ai { outline: 1.5px solid var(--red); outline-offset: -1.5px; }
.desc { margin: 0 0 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.facts { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 5px 14px; margin: 0 0 14px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.share { display: flex; gap: 14px; align-items: center; padding-top: 14px; border-top: 1px solid var(--line); }
.share img { width: 112px; height: 112px; border-radius: 6px; background: #fff; flex-shrink: 0; }
.share-text { display: grid; gap: 8px; color: var(--muted); font-size: 13px; }
.btn { padding: 7px 12px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-2); text-decoration: none; text-align: center; }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.pager a, .pager span { padding: 8px 10px; border: 1px solid var(--line); border-radius: 7px; text-decoration: none; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pager a:hover { background: var(--surface-2); }
.pager .next-link { text-align: right; }
.pager span { color: var(--muted); opacity: .6; }

.hall-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.hall-card { display: block; overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; }
.hall-card .cover { aspect-ratio: 16 / 9; background: var(--surface-2); }
.hall-card img { width: 100%; height: 100%; object-fit: cover; }
.hall-card div.text { padding: 12px 14px; }
.hall-card h2 { font: 600 18px var(--serif); margin: 0 0 4px; }
.hall-card p { margin: 0; color: var(--muted); font-size: 14px; }
.page { max-width: 1320px; margin: 0 auto; padding: 24px 20px 48px; }
.page > h1 { font: 600 24px var(--serif); margin: 0 0 16px; }
.hall-view { display: flex; flex-direction: column; height: calc(100dvh - var(--topbar)); }
.hall-bar { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; padding: 8px 16px; background: var(--surface); border-bottom: 1px solid var(--line); font-size: 13.5px; color: var(--muted); }
.hall-bar strong { color: var(--ink); font-family: var(--serif); font-size: 16px; }
.hall-bar .spacer { flex: 1; }
.hall-view iframe { flex: 1; width: 100%; border: 0; background: var(--stage); }

.footer { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 14px 20px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
body.hall-mode .footer { display: none; }
.update-bar {
  position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 80; transform: translateX(-50%);
  padding: 10px 18px; border: 0; border-radius: 999px; background: var(--yellow); color: #14120f;
  font-weight: 600; box-shadow: var(--shadow);
}
.scrim { position: fixed; inset: 0; z-index: 39; background: rgba(0, 0, 0, .45); }

@media (max-width: 1080px) {
  .detail-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 820px) {
  :root { --topbar: 104px; }
  .topbar { flex-wrap: wrap; gap: 8px 6px; padding: 8px 12px; }
  .menu-btn { display: inline-grid; }
  .brand { flex: 1; min-width: 0; }
  .brand-text { min-width: 0; }
  .brand strong { font-size: 17px; }
  .brand small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .search { order: 10; flex: 1 0 100%; max-width: none; margin: 0; }
  .search input { height: 38px; }
  .topnav a { padding: 6px 9px; }
  .layout { display: block; padding: 14px 12px 32px; }
  .sidebar {
    position: fixed; z-index: 40; left: 0; top: 0; bottom: 0;
    width: min(82vw, 310px); max-height: none;
    padding: 18px 14px calc(18px + env(safe-area-inset-bottom));
    background: var(--surface); box-shadow: var(--shadow);
    transform: translateX(-102%); visibility: hidden;
    transition: transform .2s ease, visibility .2s;
  }
  .sidebar.open { transform: none; visibility: visible; }
  .toolbar h1 { font-size: 19px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .card-body { padding: 8px 10px 10px; }
  .card-name { font-size: 15px; }
  .detail { padding: 10px 12px 32px; }
  .stage { aspect-ratio: 1; }
  .info { padding: 14px; }
  .page { padding: 16px 12px 32px; }
  .hall-grid { grid-template-columns: minmax(0, 1fr); }
  .footer { padding-left: 12px; padding-right: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .card, .sidebar, .progress i { transition: none; }
}
