:root {
  --bg: #12100e;
  --ink: #1a1714;
  --plate: #221e19;
  --line: #3a342c;
  --text: #f3eadc;
  --muted: #b3a58f;
  --brass: #e2b15a;
  --brass-dim: #8c7344;
  --danger: #e07a6e;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(900px 420px at 12% -10%, rgba(226, 177, 90, 0.09), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: Outfit, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

button, input, select, textarea { font: inherit; color: inherit; }

button {
  background: #2a261f;
  border: 1px solid #4a4338;
  border-radius: 999px;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
}

button:hover { border-color: var(--brass); }

button:disabled {
  opacity: 0.38;
  cursor: default;
}

:focus { outline: none; }

:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}

input, select, textarea {
  background: #100e0c;
  border: 1px solid #4a4338;
  border-radius: 8px;
  padding: 0.35rem 0.5rem;
}

textarea { resize: vertical; width: 100%; }

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px 16px;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--line);
  background: #16130f;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-right: auto;
}

.mark {
  width: 36px;
  height: 36px;
  color: var(--brass);
}

.eyebrow {
  margin: 0;
  color: var(--brass);
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1, h2, .call h2 {
  font-family: "Cormorant Garamond", Palatino, Georgia, serif;
  font-weight: 600;
}

h1 {
  margin: 0;
  font-size: 2.15rem;
  line-height: 0.85;
  letter-spacing: 0.01em;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--muted);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.field input, .field select, .field textarea {
  color: var(--text);
  letter-spacing: 0;
  text-transform: none;
  font-size: 0.95rem;
}

#seq-name { width: 14rem; }
#library { width: 14rem; }

.bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.play {
  background: #6a4a16;
  border-color: #e2b15a;
  color: #fff6e4;
  min-width: 5.4rem;
}

.play[aria-pressed="true"] { background: #3a3228; }

main {
  width: min(1180px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(300px, 0.85fr);
  gap: 18px;
  padding: 18px;
  align-items: start;
}

.stage { display: flex; flex-direction: column; gap: 10px; }

.plate {
  position: relative;
  width: min(100%, 32rem);
  align-self: center;
  aspect-ratio: 1;
  border-radius: 18px;
  overflow: hidden;
  background: var(--plate);
  border: 1px solid #5c4e36;
  box-shadow:
    0 24px 50px rgba(0, 0, 0, 0.38),
    inset 0 0 0 1px rgba(226, 177, 90, 0.12);
}

.diagram { position: absolute; inset: 0; width: 100%; height: 100%; }

.letter {
  fill: #f3eadc;
  font-family: "Cormorant Garamond", Palatino, Georgia, serif;
  font-size: 22px;
  font-weight: 600;
  text-anchor: middle;
  dominant-baseline: central;
  stroke: #221e19;
  stroke-width: 4px;
  paint-order: stroke fill;
}

.zwerch-label, .ort-label {
  font-family: Outfit, "Segoe UI", sans-serif;
  text-anchor: middle;
  dominant-baseline: central;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  paint-order: stroke fill;
  stroke: #191714;
  stroke-width: 4px;
}

.zwerch-label { fill: var(--brass); font-size: 11px; }
.ort-label { fill: #c4b49a; font-size: 10px; letter-spacing: 0.22em; }

.cut-line { stroke: var(--brass-dim); stroke-width: 1.6; }
.cut-line.zwerch { stroke-dasharray: 5 6; }
.cut-line.hot { stroke: #f2c572; stroke-width: 2.4; }

#ort { fill: #3a3126; stroke: var(--brass-dim); stroke-width: 2; }
#ort.hot { fill: #ffe1a8; stroke: #fff6e4; }

#blade, #ghost, #next { fill: none; stroke-linecap: round; stroke-width: 5; }
#next { stroke-width: 4; }
#ember { filter: url(#glow); }

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

.lamp {
  position: absolute;
  width: clamp(34px, 9%, 48px);
  height: clamp(34px, 9%, 48px);
  transform: translate(-50%, -50%);
  border: 0;
  border-radius: 50%;
  padding: 0;
  background: transparent;
  display: grid;
  place-items: center;
}

.lamp .ring {
  position: absolute;
  inset: -5px;
  width: calc(100% + 10px);
  height: calc(100% + 10px);
  transform: rotate(-90deg);
  overflow: visible;
}

.ring-track, .ring-value { fill: none; stroke-width: 2; }
.ring-track { stroke: #3a342c; }
.lamp .ring-value { stroke: #ffd78a; }
.lamp.is-next .ring-value { stroke: #ffe1a8; }
.lamp.is-cued .ring-value, .lamp.is-on .ring-value { stroke: #ff8d7c; }
.ring-value { stroke-linecap: round; }

.lens {
  width: 78%;
  height: 78%;
  border-radius: 50%;
  display: grid;
  place-items: center;
  transition: box-shadow 80ms linear, background 80ms linear;
  background: radial-gradient(circle at 35% 30%, #4a3b24, #140f0a 72%);
  box-shadow: inset 0 1px 2px #000, 0 0 0 1px #5a4630;
}

.lamp:hover .lens, .lamp:focus-visible .lens {
  box-shadow: 0 0 0 1px var(--brass), 0 0 12px rgba(226, 177, 90, 0.35);
}

.lamp.is-next .lens {
  background: radial-gradient(circle at 35% 30%, #fff6d0, #e2b15a 48%, #6a4a16 78%);
  box-shadow: 0 0 12px 2px rgba(255, 210, 90, 0.65);
}

.lamp.is-cued .lens, .lamp.is-on .lens {
  background: radial-gradient(circle at 35% 30%, #ffe8e2, #ff5a42 42%, #8a1c12 78%);
  box-shadow: 0 0 16px 3px rgba(255, 90, 66, 0.9), 0 0 34px rgba(180, 30, 20, 0.4);
}

.code {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #c7b59a;
}

.lamp.is-on .code, .lamp.is-cued .code, .lamp.is-next .code { color: #2a1408; }

.plate.is-locked .lamp { cursor: default; }

.call { text-align: center; min-height: 8.6rem; }

#call-kicker {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.72rem;
  color: #d7c4a1;
}

.call.is-recover #call-kicker,
.call.is-recover #call-from { color: #d7c4a1; }

#call-name {
  margin: 0;
  font-size: clamp(2.7rem, 6vw, 4.15rem);
  line-height: 0.9;
  color: #f4ead8;
}

#call-from {
  margin: 0.1rem 0 0;
  font-family: "Cormorant Garamond", Palatino, Georgia, serif;
  font-style: italic;
  font-size: clamp(1.25rem, 2.4vw, 1.75rem);
  color: var(--brass);
}

#call-path { margin: 0.3rem 0 0; color: var(--muted); font-size: 0.92rem; }
.next-cut { display: block; margin-top: 0.2rem; color: #ffe1a8; }

.call.is-recover #call-name,
.call.is-recover #call-from,
.call.is-recover #call-path { opacity: 0.42; }

.clock {
  margin: 0.15rem 0 0;
  min-height: 1.2em;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

.transport { display: flex; flex-direction: column; gap: 8px; }

.transport-row, .defaults {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
  align-items: flex-end;
}

.check {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-bottom: 0.4rem;
  color: var(--text);
  font-size: 0.92rem;
  letter-spacing: 0;
  text-transform: none;
}

.round-label {
  padding-bottom: 0.45rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.timeline { display: flex; gap: 3px; min-height: 18px; }

.tick {
  position: relative;
  flex: var(--span) 1 0;
  min-width: 4px;
  height: 16px;
  padding: 0;
  border: 0;
  border-radius: 3px;
  overflow: hidden;
  background: #2a261f;
}

.tick-on {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: calc(var(--on) / var(--span) * 100%);
  background: #9a7430;
}

.tick.is-next .tick-on { background: #ffe1a8; }
.tick.is-current .tick-on { background: #ff6b58; }

.tick-play {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  background: rgba(255, 244, 220, 0.28);
}

.facing, .hint, .device-note, .empty, .reach-help, .blurb {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.hint { font-size: 0.82rem; }

.read {
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.read summary {
  cursor: pointer;
  color: var(--brass);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 0.75rem;
}

.read summary::-webkit-details-marker { display: none; }

.read ul { margin: 8px 0 0; padding-left: 1.1rem; color: var(--text); }
.read li { margin: 0.35rem 0; }
.read li strong { color: var(--brass); font-weight: 600; }

.planner {
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: calc(100vh - 108px);
  position: sticky;
  top: 12px;
}

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

.planner h2 { margin: 0; font-size: 1.8rem; line-height: 0.9; }

#summary { margin: 4px 0 0; color: var(--muted); font-variant-numeric: tabular-nums; }

.notes-field textarea { min-height: 3.2rem; }

.defaults {
  padding-bottom: 4px;
  border-bottom: 1px solid var(--line);
}

.defaults-label {
  color: var(--muted);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding-bottom: 0.45rem;
}

#def-on, #def-gap, #step-on, #step-gap, #rounds, #random-count { width: 5.4rem; }

#steps {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow: auto;
  min-height: 8rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overscroll-behavior: contain;
}

.step {
  display: grid;
  grid-template-columns: auto auto auto 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 7px 8px;
  border-radius: 10px;
  background: transparent;
  user-select: none;
}

.step.is-next { box-shadow: inset 3px 0 0 #ffe1a8; }
.step.is-current { background: #2a1814; box-shadow: inset 3px 0 0 #ff6b58; }
.step.drop-before { box-shadow: inset 0 2px 0 var(--brass); }
.step.drop-after { box-shadow: inset 0 -2px 0 var(--brass); }

.grip { color: #8a7d6a; cursor: grab; letter-spacing: -0.2em; font-size: 0.8rem; }

.index { color: var(--muted); font-variant-numeric: tabular-nums; width: 1.2rem; }

.pip {
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #3a2e18;
  color: #ffd78a;
  font-size: 0.78rem;
  font-weight: 600;
}

.step-name { display: block; }
.meta { display: block; color: var(--muted); font-size: 0.8rem; font-variant-numeric: tabular-nums; }

.step-actions { display: flex; gap: 4px; }

.step-actions button {
  width: 1.7rem;
  height: 1.7rem;
  padding: 0;
  border-radius: 7px;
}

#inspector {
  border-top: 1px solid var(--line);
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.inspector-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
  align-items: flex-end;
}

.reach { display: flex; gap: 6px; }

.reach button[aria-pressed="true"] {
  border-color: var(--brass);
  color: #fff1cc;
  background: #3a2e18;
}

.inspector-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.texty, .inspector-actions button, #restore {
  background: transparent;
  border-color: transparent;
  color: var(--brass);
  padding-left: 0;
  padding-right: 0;
}

#inspector [data-act="delete"], #del-seq { color: var(--danger); }

.lamp-no { margin: 0; color: var(--muted); font-size: 0.8rem; letter-spacing: 0.04em; }

.device-note { font-size: 0.8rem; }

.status {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  z-index: 5;
  margin: 0;
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  background: #2a2418;
  border: 1px solid var(--brass-dim);
  pointer-events: none;
}

.status:empty { display: none; }

.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;
}

@media (max-width: 900px) {
  main { grid-template-columns: 1fr; }
  .planner { position: static; max-height: none; }
  #steps { max-height: 50vh; }
  #seq-name, #library { width: min(14rem, 70vw); }
}

@media (prefers-reduced-motion: reduce) {
  .lens { transition: none; }
}
