:root {
  color-scheme: dark;
  --bg: #0b0815;
  --bg-deep: #120d22;
  --panel: rgba(27, 18, 47, 0.88);
  --panel-2: rgba(38, 26, 64, 0.82);
  --line: #3d2b61;
  --line-bright: #6c4ea7;
  --text: #f1ecff;
  --muted: #a99bbf;
  --accent: #b895ff;
  --steel: #8ee8db;
  --gold: #f3ca73;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background:
    radial-gradient(900px 500px at 50% -8%, #312052 0%, transparent 70%),
    radial-gradient(600px 500px at 92% 72%, #1b1232 0%, transparent 72%),
    var(--bg);
  color: var(--text);
}
a { color: var(--steel); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input { font: inherit; }
code {
  font-size: .85em;
  color: var(--accent);
}

.app { max-width: 1180px; margin: 0 auto; padding: 18px 20px 54px; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  padding: 3px 0 18px; border-bottom: 1px solid rgba(108, 78, 167, .35);
}
.brand h1 { margin: 0; font-size: 1.55rem; letter-spacing: .045em; }
.brand .tag {
  display: block; margin-top: 4px; color: var(--muted); font-size: .7rem;
  letter-spacing: .14em; text-transform: uppercase;
}
.nav { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 12px; font-size: .88rem; }
.nav a { color: var(--muted); }
.nav a.active { color: var(--text); font-weight: 700; }

.intro { padding: 28px 0 18px; }
.eyebrow { margin: 0 0 8px; color: var(--gold); font-size: .72rem; letter-spacing: .16em; text-transform: uppercase; }
h2 { margin: 0; font-size: clamp(1.55rem, 3vw, 2.3rem); }
.intro p { max-width: 720px; margin: 10px 0 0; color: var(--muted); line-height: 1.55; }

.lab-grid { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 22px; align-items: start; }
.stage {
  position: relative; overflow: hidden; min-width: 0; aspect-ratio: 1792 / 1008;
  border: 1px solid var(--line-bright); border-radius: 18px;
  background: #181125; box-shadow: 0 18px 60px rgba(0,0,0,.42), 0 0 0 5px rgba(65,40,104,.16);
}
.stage .sheet {
  display: block; width: 100%; height: 100%; object-fit: contain;
}
.stage-caption { margin: 9px 2px 0; color: var(--muted); font-size: .76rem; }

.controls {
  padding: 20px; border: 1px solid var(--line); border-radius: 16px;
  background: linear-gradient(145deg, var(--panel-2), var(--panel)); box-shadow: 0 14px 40px rgba(0,0,0,.24);
}
.controls h3 { margin: 0; font-size: .82rem; letter-spacing: .13em; text-transform: uppercase; }
.mode-banner {
  margin: 10px 0 8px; padding: 9px 11px;
  border: 1px solid rgba(142, 232, 219, .35); border-radius: 9px;
  color: var(--steel); background: rgba(142, 232, 219, .08);
  font-size: .78rem; font-weight: 600; line-height: 1.4;
}
.controls .sub { margin: 0 0 15px; color: var(--muted); font-size: .82rem; line-height: 1.45; }
.toggle-list { display: grid; gap: 9px; }
.toggle {
  display: flex; align-items: center; gap: 11px; padding: 12px 11px; cursor: pointer;
  border: 1px solid #413062; border-radius: 11px; background: rgba(11,8,21,.36);
  transition: border-color .16s ease, background .16s ease, transform .16s ease;
}
.toggle:hover { border-color: var(--accent); transform: translateY(-1px); }
.toggle:has(input:checked) { border-color: var(--steel); background: rgba(63, 180, 164, .12); }
.toggle input { width: 17px; height: 17px; accent-color: var(--steel); }
.toggle-copy { display: grid; gap: 2px; }
.toggle-copy strong { font-size: .92rem; }
.toggle-copy small { color: var(--muted); font-size: .7rem; }
.reset {
  width: 100%; margin-top: 15px; padding: 9px 12px; cursor: pointer;
  border: 1px solid var(--line-bright); border-radius: 9px; color: var(--text); background: transparent;
}
.reset:hover { background: rgba(184,149,255,.11); }
.note {
  margin: 22px 0 0; padding: 13px 15px; border-left: 3px solid var(--gold);
  color: #c9bddb; background: rgba(243, 202, 115, .06); font-size: .82rem; line-height: 1.5;
}
.foot { margin: 28px 0 0; color: var(--muted); font-size: .78rem; }

@media (max-width: 780px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .nav { justify-content: flex-start; }
  .lab-grid { grid-template-columns: 1fr; }
  .controls { order: -1; }
}

/* Elf Starweave sheets are portrait 1008×1792 */
.stage.portrait:not(.fb-stage) {
  aspect-ratio: 1008 / 1792;
  max-height: min(78vh, 920px);
  margin-inline: auto;
}
.stage.portrait.fb-stage {
  aspect-ratio: auto;
  width: 100%;
  max-width: 760px;
  max-height: none;
  height: auto;
  padding: 12px;
  margin-inline: auto;
}
.stage.portrait.fb-stage .sheet {
  width: 100%;
  height: auto;
  max-height: min(70vh, 820px);
  object-fit: contain;
}
.lab-grid.elf {
  grid-template-columns: minmax(0, 780px) 310px;
  justify-content: center;
}
@media (max-width: 980px) {
  .lab-grid.elf { grid-template-columns: 1fr; }
}
