/* ============================================================
   GLSL Studies — WebGL2 stage
   Self-contained dark exhibition UI.
   ============================================================ */

:root {
  --bg: #07090b;
  --ink: #f0ece2;
  --ink-dim: #a8a59c;
  --ink-faint: #706f6b;
  --accent: #e6c583;
  --accent-bright: #f3dcaa;
  --accent-soft: rgba(230, 197, 131, 0.14);
  --cyan: #79c7bd;
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.16);
  --panel: rgba(13, 16, 19, 0.76);
  --panel-solid: #0d1013;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.58);
  --radius: 18px;
  --radius-sm: 11px;
  --serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, Georgia, "Songti SC", "Noto Serif CJK SC", serif;
  --sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --mono: "SFMono-Regular", "Cascadia Code", "Roboto Mono", Menlo, Consolas, monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body { overscroll-behavior: none; }

[hidden] { display: none !important; }

button,
input,
output { font: inherit; }

button {
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid rgba(230, 197, 131, 0.28);
  transition: color 0.2s ease, border-color 0.2s ease;
}
a:hover { color: var(--accent-bright); border-color: var(--accent-bright); }

::selection {
  background: rgba(230, 197, 131, 0.26);
  color: #fff;
}

/* ---------- stage ---------- */

#stage {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  background: radial-gradient(circle at 50% 42%, #121820 0%, #07090b 66%);
  touch-action: none;
}

.stage-glow,
.stage-vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}

.stage-glow {
  background:
    radial-gradient(ellipse at 18% 6%, rgba(230, 197, 131, 0.055), transparent 38%),
    radial-gradient(ellipse at 86% 88%, rgba(121, 199, 189, 0.045), transparent 42%);
  mix-blend-mode: screen;
}

.stage-vignette {
  background:
    linear-gradient(180deg, rgba(3, 4, 5, 0.48) 0%, transparent 18%, transparent 78%, rgba(3, 4, 5, 0.5) 100%),
    radial-gradient(ellipse at center, transparent 46%, rgba(3, 4, 5, 0.34) 100%);
}

/* ---------- shared chrome ---------- */

.chrome { z-index: 4; }

body.ui-hidden #brand,
body.ui-hidden #panel,
body.ui-hidden #rail,
body.ui-hidden #stageTag,
body.ui-hidden #drawer,
body.ui-hidden #drawerScrim {
  opacity: 0;
  pointer-events: none;
}

#brand,
#panel,
#rail,
#stageTag {
  transition: opacity 0.35s var(--ease), transform 0.45s var(--ease);
}

body.ui-hidden #brand { transform: translateY(-12px); }
body.ui-hidden #panel { transform: translateX(16px); }
body.ui-hidden #rail { transform: translateY(18px); }

.kbd,
kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border: 1px solid var(--line-strong);
  border-bottom-color: rgba(255, 255, 255, 0.24);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink-dim);
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1;
}

.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.eyebrow {
  color: var(--accent);
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

/* ---------- brand ---------- */

.brand {
  position: fixed;
  top: 24px;
  left: 26px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  pointer-events: none;
  filter: drop-shadow(0 4px 22px rgba(0, 0, 0, 0.5));
}

.brand-mark,
.boot-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 1px solid rgba(230, 197, 131, 0.48);
  border-radius: 50%;
  background:
    radial-gradient(circle at 34% 27%, rgba(230, 197, 131, 0.3), transparent 52%),
    rgba(10, 12, 14, 0.64);
  box-shadow: inset 0 0 18px rgba(230, 197, 131, 0.09), 0 0 28px rgba(230, 197, 131, 0.05);
  color: var(--accent);
  font-family: var(--serif);
  font-size: 15px;
  letter-spacing: -0.08em;
  line-height: 1;
}

.brand-mark span,
.boot-mark span { transform: translateY(-1px); }

.brand-kicker {
  color: rgba(240, 236, 226, 0.5);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.18em;
  margin: 3px 0 5px;
}

.brand h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(22px, 2.6vw, 32px);
  font-weight: 400;
  letter-spacing: 0.01em;
  line-height: 1.02;
}

.brand h1 em {
  color: var(--accent);
  font-style: italic;
  font-weight: 400;
}

.brand p {
  margin: 6px 0 0;
  color: var(--ink-dim);
  font-size: 10.5px;
  letter-spacing: 0.08em;
}

.stage-tag {
  position: fixed;
  top: 27px;
  right: 28px;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 30px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(8, 10, 12, 0.55);
  color: var(--ink-dim);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  pointer-events: none;
}

.live-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 9px rgba(121, 199, 189, 0.8);
  animation: pulse 2.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.55; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1.15); }
}

/* ---------- panel ---------- */

.panel {
  position: fixed;
  top: 72px;
  right: 24px;
  width: 326px;
  max-height: calc(100vh - 260px);
  padding: 20px 20px 16px;
  overflow-y: auto;
  overflow-x: hidden;
  border: 1px solid rgba(230, 197, 131, 0.16);
  border-radius: var(--radius);
  background:
    linear-gradient(155deg, rgba(255, 255, 255, 0.035), transparent 32%),
    var(--panel);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.055);
  backdrop-filter: blur(24px) saturate(1.15);
  -webkit-backdrop-filter: blur(24px) saturate(1.15);
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.16) transparent;
}

.panel::-webkit-scrollbar { width: 4px; }
.panel::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.16); border-radius: 4px; }

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.panel-title {
  margin-top: 4px;
  font-family: var(--serif);
  font-size: 21px;
  line-height: 1.1;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 31px;
  height: 31px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.025);
  color: var(--ink-dim);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.icon-btn svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-btn:hover {
  color: var(--accent-bright);
  border-color: rgba(230, 197, 131, 0.4);
  background: rgba(230, 197, 131, 0.07);
}

.now-playing {
  margin-top: 16px;
  padding: 14px 14px 13px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background:
    linear-gradient(150deg, rgba(230, 197, 131, 0.055), transparent 55%),
    rgba(255, 255, 255, 0.018);
}

.now-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.now-index {
  color: var(--ink-faint);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.08em;
}

.cat-tag {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 6px;
  border: 1px solid currentColor;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.11em;
  opacity: 0.9;
}

.cat-liquids { color: #8fc8d6; }
.cat-minerals { color: #d9b0d0; }
.cat-optics { color: #e6c583; }
.cat-animal { color: #c3cc8b; }
.cat-plants { color: #9cc79a; }

.now-playing h2 {
  margin: 9px 0 0;
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 400;
  line-height: 1.24;
  letter-spacing: 0.01em;
}

.now-en {
  margin: 1px 0 0;
  color: var(--ink-dim);
  font-family: var(--serif);
  font-size: 12px;
  font-style: italic;
  letter-spacing: 0.02em;
}

.now-desc {
  margin: 8px 0 0;
  color: var(--ink-dim);
  font-size: 10.5px;
  line-height: 1.65;
}

.uniform-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 10px;
}

.uniform-inline:empty { display: none; }

.uniform-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 19px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.025);
  color: var(--ink-dim);
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: 0.02em;
}

.uniform-chip.dynamic {
  border-color: rgba(121, 199, 189, 0.26);
  color: #9cdad2;
}

.uniform-chip.unused {
  border-style: dashed;
  opacity: 0.45;
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}

.control-block {
  margin-top: 17px;
  padding-top: 15px;
  border-top: 1px solid var(--line);
}

.block-label {
  margin-bottom: 9px;
  color: var(--ink-faint);
  font-family: var(--mono);
  font-size: 8.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.transport {
  display: flex;
  gap: 7px;
}

.play-btn {
  display: inline-flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 36px;
  padding: 0 13px;
  border: 1px solid rgba(230, 197, 131, 0.38);
  border-radius: 9px;
  background: linear-gradient(180deg, rgba(230, 197, 131, 0.17), rgba(230, 197, 131, 0.07));
  color: var(--accent-bright);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.12s;
}

.play-btn:hover {
  border-color: rgba(230, 197, 131, 0.62);
  background: linear-gradient(180deg, rgba(230, 197, 131, 0.24), rgba(230, 197, 131, 0.1));
}

.play-btn:active { transform: scale(0.985); }

.play-icon {
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 8px solid currentColor;
}

.play-btn .play-icon.pause {
  width: 9px;
  height: 11px;
  border: 0;
  background: linear-gradient(90deg, currentColor 0 34%, transparent 34% 66%, currentColor 66%);
}

.ghost-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.025);
  color: var(--ink-dim);
  font-size: 10.5px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.ghost-btn:hover {
  color: var(--ink);
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.055);
}

.ghost-btn svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ghost-btn.small { height: 28px; padding: 0 10px; font-size: 10px; }

.slider-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-top: 13px;
  color: var(--ink-dim);
  font-size: 10.5px;
}

.slider-row output {
  color: var(--accent);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.02em;
}

.range {
  --p: 33%;
  width: 100%;
  height: 22px;
  margin: 3px 0 0;
  padding: 0;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  cursor: pointer;
}

.range::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent) 0 var(--p), rgba(255, 255, 255, 0.13) var(--p) 100%);
}

.range::-moz-range-track {
  height: 3px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.13);
}

.range::-moz-range-progress {
  height: 3px;
  border-radius: 3px;
  background: var(--accent);
}

.range::-webkit-slider-thumb {
  width: 13px;
  height: 13px;
  margin-top: -5px;
  border: 2px solid #1b1e21;
  border-radius: 50%;
  background: var(--accent-bright);
  box-shadow: 0 0 0 1px rgba(230, 197, 131, 0.45), 0 0 12px rgba(230, 197, 131, 0.3);
  appearance: none;
  -webkit-appearance: none;
  transition: transform 0.15s;
}

.range::-moz-range-thumb {
  width: 11px;
  height: 11px;
  border: 2px solid #1b1e21;
  border-radius: 50%;
  background: var(--accent-bright);
  box-shadow: 0 0 0 1px rgba(230, 197, 131, 0.45);
}

.range:hover::-webkit-slider-thumb { transform: scale(1.12); }
.range:focus-visible { outline: none; }
.range:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 3px rgba(230, 197, 131, 0.22), 0 0 14px rgba(230, 197, 131, 0.4);
}

.accent-range::-webkit-slider-runnable-track {
  background: linear-gradient(90deg, var(--cyan) 0 var(--p), rgba(255, 255, 255, 0.13) var(--p) 100%);
}
.accent-range::-webkit-slider-thumb {
  background: #b5ece5;
  box-shadow: 0 0 0 1px rgba(121, 199, 189, 0.5), 0 0 12px rgba(121, 199, 189, 0.32);
}

.range-ticks {
  display: flex;
  justify-content: space-between;
  margin-top: -2px;
  color: var(--ink-faint);
  font-family: var(--mono);
  font-size: 8px;
}

.micro-note {
  margin: 5px 0 0;
  color: var(--ink-faint);
  font-size: 9.5px;
  line-height: 1.5;
}

.micro-note .mono { color: var(--ink-dim); }

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 11px;
  color: var(--ink-dim);
  font-size: 10.5px;
}

.switch { position: relative; display: inline-block; width: 34px; height: 19px; }
.switch input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.switch-track {
  display: block;
  width: 34px;
  height: 19px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  transition: background 0.22s, border-color 0.22s;
  pointer-events: none;
}
.switch-track::after {
  content: "";
  display: block;
  width: 13px;
  height: 13px;
  margin: 2px;
  border-radius: 50%;
  background: #b7b4ac;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  transition: transform 0.22s var(--ease), background 0.22s;
}
.switch input:checked + .switch-track {
  border-color: rgba(121, 199, 189, 0.55);
  background: rgba(121, 199, 189, 0.24);
}
.switch input:checked + .switch-track::after {
  transform: translateX(15px);
  background: var(--cyan);
  box-shadow: 0 0 9px rgba(121, 199, 189, 0.55);
}
.switch input:focus-visible + .switch-track {
  outline: 2px solid rgba(121, 199, 189, 0.45);
  outline-offset: 2px;
}

.segmented {
  display: grid;
  grid-template-columns: 0.8fr 0.8fr 0.8fr 1.5fr;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.22);
}

.segmented button {
  height: 27px;
  padding: 0 4px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-faint);
  font-family: var(--mono);
  font-size: 9px;
  cursor: pointer;
  transition: color 0.18s, background 0.18s;
}

.segmented button:hover { color: var(--ink); background: rgba(255, 255, 255, 0.05); }

.segmented button[aria-pressed="true"] {
  background: linear-gradient(180deg, rgba(230, 197, 131, 0.2), rgba(230, 197, 131, 0.09));
  box-shadow: inset 0 0 0 1px rgba(230, 197, 131, 0.3);
  color: var(--accent-bright);
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  margin-top: 17px;
  padding: 10px 0 0;
  border-top: 1px solid var(--line);
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 0 10px;
  border-left: 1px solid var(--line);
}
.stat:first-child { padding-left: 0; border-left: 0; }

.stat-label {
  color: var(--ink-faint);
  font-family: var(--mono);
  font-size: 7.5px;
  letter-spacing: 0.15em;
}

.stat-value {
  color: var(--ink);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.25;
}

.source-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  height: 38px;
  margin-top: 16px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.022);
  color: var(--ink-dim);
  font-size: 10.5px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, color 0.2s;
}

.source-btn:hover {
  border-color: rgba(230, 197, 131, 0.34);
  background: rgba(230, 197, 131, 0.055);
  color: var(--ink);
}

.source-btn > span:first-child {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.source-btn svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.source-file {
  overflow: hidden;
  max-width: 132px;
  color: var(--ink-faint);
  font-size: 8.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.credit {
  margin: 14px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--ink-faint);
  font-size: 9px;
  line-height: 1.7;
}

.license-pill {
  display: inline-block;
  margin-left: 3px;
  padding: 0 4px;
  border: 1px solid var(--line);
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.04em;
}

/* ---------- rail ---------- */

.rail {
  position: fixed;
  left: 24px;
  right: 24px;
  bottom: 16px;
  padding: 10px 12px 12px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 50%),
    rgba(10, 13, 16, 0.72);
  box-shadow: 0 18px 54px rgba(0, 0, 0, 0.48), inset 0 1px 0 rgba(255, 255, 255, 0.045);
  backdrop-filter: blur(20px) saturate(1.1);
  -webkit-backdrop-filter: blur(20px) saturate(1.1);
}

.rail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 3px 8px;
}

.rail-title {
  color: var(--ink-faint);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.17em;
}
.rail-title b { color: var(--accent); font-weight: 500; }

.rail-keys {
  color: var(--ink-faint);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.06em;
}
.rail-keys i { margin: 0 5px; font-style: normal; opacity: 0.5; }
.rail-keys kbd { margin: 0 1px; height: 15px; min-width: 15px; font-size: 8.5px; }

.rail-track {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px 2px 5px;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.16) transparent;
}

.rail-track::-webkit-scrollbar { height: 4px; }
.rail-track::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.15); border-radius: 4px; }
.rail-track::-webkit-scrollbar-track { background: transparent; }

.chip {
  position: relative;
  display: flex;
  flex: 0 0 286px;
  align-items: stretch;
  gap: 10px;
  min-height: 78px;
  padding: 8px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.018);
  color: inherit;
  text-align: left;
  cursor: pointer;
  scroll-snap-align: start;
  transition: background 0.22s, border-color 0.22s, transform 0.22s var(--ease);
}

.chip:hover {
  background: rgba(255, 255, 255, 0.048);
  border-color: rgba(255, 255, 255, 0.11);
}

.chip:active { transform: scale(0.992); }

.chip:focus-visible {
  outline: 2px solid rgba(230, 197, 131, 0.5);
  outline-offset: 1px;
}

.chip.active {
  border-color: rgba(230, 197, 131, 0.34);
  background:
    linear-gradient(135deg, rgba(230, 197, 131, 0.09), transparent 62%),
    rgba(255, 255, 255, 0.035);
  box-shadow: inset 0 0 0 1px rgba(230, 197, 131, 0.06);
}

.chip-thumb {
  position: relative;
  flex: 0 0 86px;
  width: 86px;
  height: 66px;
  overflow: hidden;
  border-radius: 7px;
  background: #111;
  box-shadow: 0 2px 9px rgba(0, 0, 0, 0.35);
}

.chip-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(0.66) brightness(0.72) contrast(1.03);
  transform: scale(1.015);
  transition: filter 0.35s var(--ease), transform 0.35s var(--ease);
}

.chip:hover .chip-thumb img { filter: saturate(0.85) brightness(0.86); }
.chip.active .chip-thumb img { filter: saturate(1.02) brightness(1); transform: scale(1.035); }

.chip-thumb::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 45%, rgba(0, 0, 0, 0.4));
  pointer-events: none;
}

.chip-num {
  position: absolute;
  top: 4px;
  left: 5px;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: rgba(5, 7, 8, 0.68);
  color: rgba(255, 255, 255, 0.7);
  font-family: var(--mono);
  font-size: 7.5px;
  backdrop-filter: blur(4px);
}

.chip.active .chip-num { background: var(--accent); color: #17130b; }

.chip-body {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  justify-content: center;
  padding: 1px 2px 1px 0;
}

.chip-cat {
  font-family: var(--mono);
  font-size: 7px;
  font-weight: 600;
  letter-spacing: 0.12em;
  line-height: 1.2;
}

.chip-title {
  margin-top: 3px;
  overflow: hidden;
  font-family: var(--serif);
  font-size: 13.5px;
  font-weight: 400;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip-sub {
  margin-top: 1px;
  overflow: hidden;
  color: var(--ink-faint);
  font-family: var(--serif);
  font-size: 9px;
  font-style: italic;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip-desc {
  display: -webkit-box;
  overflow: hidden;
  margin: 4px 0 0;
  color: rgba(168, 165, 156, 0.72);
  font-size: 8.5px;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

/* ---------- reveal ---------- */

.ui-reveal {
  position: fixed;
  right: 24px;
  bottom: 20px;
  z-index: 8;
  display: flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 12px 0 6px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(10, 13, 16, 0.66);
  color: var(--ink-dim);
  font-size: 9.5px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: opacity 0.3s var(--ease), transform 0.3s var(--ease), color 0.2s;
  cursor: pointer;
}

body.ui-hidden .ui-reveal { opacity: 1; pointer-events: auto; transform: none; }
.ui-reveal:hover { color: var(--accent-bright); }

.reveal-key {
  display: grid;
  place-items: center;
  width: 21px;
  height: 21px;
  border: 1px solid rgba(230, 197, 131, 0.32);
  border-radius: 50%;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 9px;
}

body:not(.ui-hidden) #uiReveal { display: none; }

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 128px;
  z-index: 9;
  padding: 7px 13px;
  border: 1px solid rgba(230, 197, 131, 0.28);
  border-radius: 999px;
  background: rgba(10, 13, 16, 0.88);
  color: var(--accent-bright);
  font-size: 10px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 8px);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: opacity 0.25s, transform 0.25s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- source drawer ---------- */

.drawer-scrim {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: rgba(2, 3, 4, 0.52);
  opacity: 0;
  transition: opacity 0.35s ease;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.drawer-scrim.visible { opacity: 1; }

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 11;
  display: flex;
  width: min(660px, 94vw);
  flex-direction: column;
  padding: 20px 22px 12px;
  border-left: 1px solid rgba(230, 197, 131, 0.18);
  background:
    linear-gradient(160deg, rgba(230, 197, 131, 0.045), transparent 26%),
    rgba(10, 12, 15, 0.94);
  box-shadow: -24px 0 72px rgba(0, 0, 0, 0.55);
  transform: translateX(102%);
  transition: transform 0.45s var(--ease), opacity 0.35s var(--ease);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
}
.drawer.open { transform: none; }

.drawer-head {
  display: flex;
  flex: none;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.drawer-head h2 {
  margin: 5px 0 0;
  font-family: var(--serif);
  font-size: 21px;
  font-weight: 400;
  line-height: 1.15;
}

.drawer-sub {
  margin: 3px 0 0;
  color: var(--ink-faint);
  font-size: 9.5px;
  letter-spacing: 0.02em;
}

.drawer-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.uniform-chips {
  display: flex;
  flex: none;
  flex-wrap: wrap;
  gap: 4px;
  margin: 14px 0 10px;
  padding-bottom: 11px;
  border-bottom: 1px solid var(--line);
}
.uniform-chips:empty { border: 0; margin-bottom: 0; padding: 0; }

.code-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.28);
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.14) transparent;
}

.code-wrap::-webkit-scrollbar { width: 6px; height: 6px; }
.code-wrap::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.14); border-radius: 6px; }

#sourceCode {
  margin: 0;
  padding: 12px 14px 22px;
  color: #cfd3d4;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.65;
  tab-size: 4;
}

.code-line { display: flex; min-height: 1.65em; }
.code-no {
  flex: 0 0 38px;
  padding-right: 12px;
  color: rgba(255, 255, 255, 0.2);
  text-align: right;
  user-select: none;
}
.code-text { white-space: pre; }

.drawer-foot {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  padding-top: 10px;
  color: var(--ink-faint);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.04em;
}

/* ---------- boot ---------- */

.boot {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 50% 42%, rgba(230, 197, 131, 0.055), transparent 38%),
    #07090b;
  transition: opacity 0.6s var(--ease), visibility 0.6s;
}

.boot.done { opacity: 0; visibility: hidden; pointer-events: none; }
.boot-mark { width: 58px; height: 58px; margin-bottom: 18px; font-size: 19px; }

.boot-title {
  font-family: var(--serif);
  font-size: 22px;
  letter-spacing: 0.01em;
}

.boot-sub {
  margin-top: 6px;
  color: var(--ink-faint);
  font-size: 10px;
  letter-spacing: 0.04em;
}

.boot-bar {
  width: 180px;
  height: 2px;
  margin-top: 22px;
  overflow: hidden;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.1);
}

.boot-bar span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--cyan));
  transition: width 0.35s var(--ease);
}

.boot-status {
  margin-top: 9px;
  color: var(--ink-faint);
  font-size: 8.5px;
  letter-spacing: 0.1em;
}

/* ---------- diagnostics ---------- */

.diagnostics {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(4, 5, 6, 0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.diag-card {
  width: min(720px, 100%);
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  padding: 26px 28px 24px;
  border: 1px solid rgba(230, 197, 131, 0.26);
  border-radius: 16px;
  background:
    linear-gradient(155deg, rgba(230, 197, 131, 0.06), transparent 36%),
    rgba(13, 16, 19, 0.96);
  box-shadow: 0 32px 90px rgba(0, 0, 0, 0.65);
}

.diag-card h2 {
  margin: 7px 0 0;
  font-family: var(--serif);
  font-size: 27px;
  font-weight: 400;
}

.diag-card p {
  margin: 10px 0 0;
  color: var(--ink-dim);
  font-size: 12px;
  line-height: 1.7;
}

.diag-card code {
  color: var(--accent-bright);
  font-family: var(--mono);
  font-size: 0.92em;
}

.diag-log {
  max-height: 270px;
  margin: 16px 0 0;
  padding: 12px 14px;
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.34);
  color: #e0b7a8;
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.diag-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.diag-btn {
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--ink);
  font-size: 10.5px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, color 0.2s;
}
.diag-btn:hover { border-color: rgba(230, 197, 131, 0.46); background: rgba(230, 197, 131, 0.08); }
.diag-btn.primary {
  border-color: rgba(230, 197, 131, 0.4);
  background: rgba(230, 197, 131, 0.14);
  color: var(--accent-bright);
}

/* ---------- responsive ---------- */

@media (max-width: 900px) {
  .brand { top: 16px; left: 16px; }
  .brand-mark { width: 38px; height: 38px; font-size: 12px; }
  .brand-kicker { font-size: 8px; }
  .brand h1 { font-size: 22px; }
  .brand p { display: none; }
  .stage-tag { top: 19px; right: 16px; }

  .panel {
    top: 68px;
    right: 12px;
    width: 298px;
    max-height: calc(100vh - 226px);
    padding: 16px;
  }

  .rail { left: 12px; right: 12px; bottom: 10px; }
  .rail-keys { display: none; }
  .chip { flex-basis: 252px; }
  .chip-thumb { flex-basis: 76px; width: 76px; height: 58px; }
  .drawer { width: 100%; padding: 16px; }
  .toast { bottom: 110px; }
}

@media (max-width: 620px) {
  .panel { top: 62px; right: 10px; left: 10px; width: auto; max-height: 46vh; }
  .brand { display: none; }
  .stage-tag { top: 10px; right: 10px; }
  .rail { padding: 8px 8px 9px; }
  .chip { flex-basis: 236px; min-height: 70px; }
  .chip-thumb { flex-basis: 70px; width: 70px; height: 54px; }
  .chip-desc { -webkit-line-clamp: 1; }
  .ui-reveal { right: 12px; bottom: 12px; }
}

@media (max-height: 700px) {
  .panel { top: 66px; max-height: calc(100vh - 210px); }
  .now-desc { display: none; }
  .control-block { margin-top: 12px; padding-top: 11px; }
}

@media (prefers-reduced-motion: reduce) {
  #brand, #panel, #rail, .chip, .chip-thumb img, .drawer, .boot, .ui-reveal, .toast {
    transition-duration: 0.01ms !important;
  }
  .live-dot { animation: none; }
}

/* Interactive Camera Stage Cursor */
#stage {
  cursor: grab;
  touch-action: none;
}

#stage.dragging {
  cursor: grabbing;
}
