:root,
html[data-studio-theme="light"] {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --studio-bg: #efece6;
  --ink: #1a1a18;
  --mut: #57544d;
  --acc: #c85a32;
  --gold: #9e7b47;
  --paper: #f7f5f0;
  --panel: rgba(255, 253, 248, 0.84);
  --panel-solid: #f4f1ea;
  --line: rgba(26, 26, 24, 0.14);
  --line-strong: rgba(26, 26, 24, 0.28);
  --pill-bg: rgba(255, 253, 249, 0.78);
  --pill-hover: rgba(255, 255, 255, 0.96);
  --pill-ink: #1a1a18;
  --focus: #c85a32;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --type-caption: clamp(22px, 1.7vw, 28px);
  --type-body: 14px;
  --type-small: 11px;
  --f-d: "Manrope", "PingFang SC", sans-serif;
  --f-b: "Noto Sans SC", "PingFang SC", sans-serif;
  --f-serif: "Cormorant Garamond", "Noto Serif SC", "Songti SC", Georgia, serif;
  --f-mono: "JetBrains Mono", "Manrope", monospace;
  --z-backdrop: 1;
  --z-canvas: 2;
  --z-hud: 38;
  --z-dock: 39;
  --z-header: 40;
  --z-boot: 60;
  --z-fullscreen: 100;
  --z-drawer: 7500;
  --z-modal: 8200;
}

html[data-studio-theme="dark"] {
  --studio-bg: #13151a;
  --ink: #f3f1ea;
  --mut: #a3a8b6;
  --acc: #e8683f;
  --gold: #d9b173;
  --paper: #171a22;
  --panel: rgba(18, 20, 27, 0.86);
  --panel-solid: #1a1d25;
  --line: rgba(255, 255, 255, 0.12);
  --line-strong: rgba(255, 255, 255, 0.24);
  --pill-bg: rgba(20, 23, 31, 0.88);
  --pill-hover: rgba(30, 34, 45, 0.96);
  --pill-ink: #f3f1ea;
  --focus: #f2a17f;
}

body {
  background: var(--studio-bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  height: 100dvh;
  transition: background-color 0.45s ease, color 0.35s ease;
}

html[data-studio-theme="light"] body::after {
  background: radial-gradient(ellipse at 54% 44%, transparent 56%, rgba(45, 38, 28, 0.08));
}
html[data-studio-theme="dark"] body::after {
  background: radial-gradient(ellipse at 54% 42%, transparent 48%, rgba(4, 5, 8, 0.34));
}

.topline {
  padding: calc(20px + var(--safe-top)) calc(34px + var(--safe-right)) 0 calc(34px + var(--safe-left));
}
.backlink {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  font-size: 14px;
  letter-spacing: .08em;
  gap: 12px;
  min-height: 44px;
}
.sound-toggle {
  min-width: calc(32px * var(--archive-unit, 1));
  min-height: calc(30px * var(--archive-unit, 1));
  padding: calc(4px * var(--archive-unit, 1)) 2px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: calc(5px * var(--archive-unit, 1));
  border: 0;
  border-bottom: 1px solid transparent;
  border-radius: 0;
  color: var(--ink);
  background: transparent;
  backdrop-filter: none;
  font: 600 calc(11px * var(--archive-unit, 1))/1 var(--f-d);
  letter-spacing: .06em;
  transition: color .2s, border-color .2s, opacity .2s;
}
.sound-toggle svg {
  width: calc(15px * var(--archive-unit, 1));
  height: calc(15px * var(--archive-unit, 1));
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sound-toggle svg path:first-child {
  fill: currentColor;
  stroke: none;
}
.sound-toggle:hover {
  color: var(--acc);
  border-bottom-color: var(--acc);
  background: transparent;
}
.sound-toggle.is-muted {
  color: var(--mut);
}
.sound-toggle.is-muted .sound-wave {
  opacity: .18;
}

.media-retry {
  pointer-events: auto;
  min-height: calc(38px * var(--archive-unit, 1));
  padding: calc(7px * var(--archive-unit, 1)) calc(14px * var(--archive-unit, 1));
  border: 1px solid var(--line-strong);
  border-radius: 99px;
  color: var(--ink);
  background: var(--panel);
  font: 500 calc(11px * var(--archive-unit, 1))/1.3 var(--f-b);
  letter-spacing: .04em;
}
.media-retry:hover {
  border-color: var(--acc);
  color: var(--acc);
}

.hud-right {
  left: var(--archive-caption-left, var(--archive-left, 40px));
  right: var(--archive-caption-right, var(--archive-right, 40px));
  top: var(--archive-top, 72px);
  bottom: auto;
  gap: calc(6px * var(--archive-unit, 1));
}
.cat-cap {
  justify-content: space-between;
  align-items: baseline;
  gap: calc(24px * var(--archive-unit, 1));
  padding: 0;
  overflow: hidden;
}
.cat-cap b {
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
  font-family: "Noto Serif SC", "Songti SC", var(--f-b);
  font-size: clamp(25px, 2.0vw, 33px);
  font-weight: 600;
  letter-spacing: .02em;
  color: var(--ink);
  animation: zaTitleReveal 0.55s cubic-bezier(0.16, 1, 0.3, 1) both;
}
body[data-category="photo"] .cat-cap b::before { content: "02"; }
body[data-category="motion"] .cat-cap b::before { content: "03"; }
body[data-category="digital"] .cat-cap b::before { content: "04"; }
body[data-category="strategy"] .cat-cap b::before { content: "05"; }
.cat-cap b::before {
  font-family: var(--f-serif);
  font-style: italic;
  font-weight: 500;
  font-size: 0.92em;
  color: var(--acc);
  letter-spacing: 0.02em;
}
@keyframes zaTitleReveal {
  from { transform: translateY(105%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.cat-cap :is(span, .archive-meta) {
  font-family: var(--f-mono);
  font-size: calc(11px * var(--archive-unit, 1));
  letter-spacing: .06em;
  color: var(--mut);
  background: transparent;
  backdrop-filter: none;
  border: 0;
  border-radius: 0;
  padding: 2px 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
  line-height: 1.45;
  max-width: 58%;
}
.ctrl-row {
  position: fixed;
  left: var(--archive-left, 40px);
  right: var(--archive-right, 40px);
  bottom: calc(60px + var(--safe-bottom));
  gap: 8px;
  padding: 0;
}
.ctrl-row .cbtn,
.shelf {
  display: none !important;
}
.ctrl-note {
  display: inline-block;
  font-family: var(--f-b);
  font-size: calc(11.5px * var(--archive-unit, 1));
  letter-spacing: .04em;
  color: var(--ink);
  opacity: 1;
  background: color-mix(in srgb, var(--studio-bg) 82%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: 4px 12px;
  text-wrap: pretty;
  max-width: 100%;
  line-height: 1.4;
}

.undock {
  position: static;
  min-height: 30px;
  padding: 4px 2px;
  background: transparent;
  backdrop-filter: none;
  border: 0;
  border-bottom: 1px solid transparent;
  border-radius: 0;
  color: var(--ink);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .06em;
}
.undock.on {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.undock:hover {
  background: transparent;
  border-bottom-color: var(--acc);
  color: var(--acc);
}

.hint {
  bottom: calc(26px + var(--safe-bottom));
  left: 50%;
  padding: 0;
  background: none;
  border: 0;
  backdrop-filter: none;
  font-size: calc(11.5px * var(--archive-unit, 1));
  letter-spacing: .04em;
  color: var(--mut);
}
.hint b {
  color: var(--acc);
  font-weight: 600;
}

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

nav.sr-only:focus-within {
  position: fixed;
  z-index: 50;
  top: 65px;
  left: 100px;
  width: auto;
  height: auto;
  padding: 12px;
  margin: 0;
  clip-path: none;
  display: flex;
  gap: 12px;
  background: var(--panel-solid);
  border: 1px solid var(--line);
}
nav.sr-only button {
  border: 0;
  padding: 8px;
  color: var(--ink);
  background: none;
}
nav.sr-only button span {
  margin-right: 7px;
  color: var(--acc);
}

#artifactAccess:focus-within {
  top: auto;
  bottom: calc(54px + var(--safe-bottom));
  left: var(--archive-left);
  right: var(--archive-right);
  flex-wrap: wrap;
  gap: 4px;
  max-height: 42vh;
  overflow: auto;
  white-space: normal;
}
#artifactAccess button {
  min-height: 44px;
  border: 1px solid var(--line);
  text-align: left;
  line-height: 1.5;
  color: var(--ink);
  background: var(--panel-solid);
}
#artifactAccess button:focus-visible {
  outline: 2px solid var(--acc);
  outline-offset: -2px;
}
#b3d:focus-visible {
  outline: 2px solid var(--acc);
  outline-offset: -3px;
}
#vignette {
  display: none;
}

/* Metadata opens archive note modal */
.cat-cap .archive-meta {
  pointer-events: auto;
  appearance: none;
  border: 0;
  border-radius: 0;
  background: none;
  padding: 4px 0;
  min-height: 32px;
  font-family: var(--f-d);
  font-weight: 500;
  line-height: 1.45;
  cursor: pointer;
  text-decoration: none;
  transition: color .2s;
}
.cat-cap .archive-meta::after {
  content: ' · 详情 ↗';
  color: var(--acc);
  font-size: .95em;
  font-weight: 600;
  letter-spacing: .04em;
}
.cat-cap .archive-meta:hover {
  color: var(--ink);
}
.archive-meta:focus-visible,
.archive-notes button:focus-visible {
  outline: 2px solid var(--acc);
  outline-offset: 4px;
}

.archive-notes {
  position: fixed;
  inset: 0;
  margin: auto;
  box-sizing: border-box;
  width: min(460px, calc(100vw - 32px));
  max-height: calc(100dvh - 40px);
  overflow: auto;
  padding: 32px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.28);
  font-family: var(--f-b);
}
.archive-notes::backdrop {
  background: rgba(10, 12, 16, 0.55);
  backdrop-filter: blur(8px);
}
.archive-notes-close {
  position: absolute;
  right: 12px;
  top: 10px;
  width: 40px;
  height: 40px;
  border: 0;
  background: transparent;
  font-size: 28px;
  line-height: 1;
  color: var(--mut);
  cursor: pointer;
}
.archive-notes-close:hover {
  color: var(--acc);
}
.archive-notes-kicker {
  margin: 0 32px 14px 0;
  font: 700 11px/1.5 var(--f-d);
  letter-spacing: .1em;
  color: var(--acc);
}
.archive-notes h2 {
  margin: 0 0 14px;
  font-size: 24px;
  line-height: 1.35;
  font-weight: 700;
  letter-spacing: -.02em;
}
.archive-notes-description {
  margin: 0 0 22px;
  font-size: 14.5px;
  line-height: 1.75;
  color: var(--mut);
}
.archive-notes dl {
  display: grid;
  grid-template-columns: 76px 1fr;
  gap: 12px 16px;
  padding: 18px 0;
  border-block: 1px solid var(--line);
  font-size: 13px;
  line-height: 1.75;
}
.archive-notes dt {
  color: var(--mut);
}
.archive-notes dd {
  margin: 0;
  color: var(--ink);
}
.archive-notes-help {
  margin: 20px 0 0;
  font-size: 12.5px;
  line-height: 1.8;
  color: var(--mut);
}

.archive-object-tag {
  position: fixed;
  z-index: 30;
  max-width: min(260px, calc(100vw - 32px));
  padding: 7px 12px;
  border-radius: 6px;
  border-left: 3px solid var(--acc);
  background: var(--panel-solid);
  color: var(--ink);
  border-top: 1px solid var(--line);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
  font: 500 12px/1.55 var(--f-b);
  pointer-events: none;
}
.archive-object-tag[hidden] {
  display: none;
}

@media (max-width: 1000px) and (min-width: 701px) {
  .topline { padding: calc(20px + var(--safe-top)) calc(24px + var(--safe-right)) 0 calc(24px + var(--safe-left)); }
  .hud-right, .ctrl-row { left: calc(76px + var(--safe-left)); right: calc(24px + var(--safe-right)); }
}
@media (max-width: 700px) {
  .hud-right { left: calc(16px + var(--safe-left)); right: calc(16px + var(--safe-right)); top: var(--archive-top, calc(114px + var(--safe-top))); gap: 5px; }
  .cat-cap { align-items: flex-start; flex-direction: column; gap: 3px; }
  .cat-cap b { font-size: 22px; line-height: 1.2; }
  .cat-cap :is(span, .archive-meta) { text-align: left; font-size: 11px; max-width: 100%; letter-spacing: .02em; line-height: 1.45; }
  .ctrl-row { left: calc(16px + var(--safe-left)); right: calc(16px + var(--safe-right)); bottom: calc(76px + var(--safe-bottom)); }
  .ctrl-note { font-size: 11px; line-height: 1.35; padding: 4px 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .hint { font-size: 11px; line-height: 1.55; max-width: calc(100vw - 32px); width: max-content; text-align: center; white-space: normal; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
