:root {
  --night: #120d2b;
  --dusk: #2c1b4e;
  --plum: #5a2460;
  --ember: #e2663c;
  --saffron: #f4a62a;
  --cream: #fbeed2;
  --ink: #17112e;
  --rail: #18122f;
  --rail-line: #33295a;
  --muted: #a99fc9;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--night); color: var(--cream); font-family: "JetBrains Mono", ui-monospace, Menlo, monospace; font-size: 13px; }
.app { display: grid; grid-template-columns: 1fr 300px; height: 100%; }

.stage { position: relative; overflow: hidden; touch-action: none; cursor: crosshair; user-select: none; -webkit-user-select: none; background: var(--night); }
.sky { position: absolute; inset: 0; background: linear-gradient(180deg, #0e0a26 0%, #281a55 42%, #6a2a66 68%, #d5603f 88%, #f4a62a 100%); }
.sky canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.moon { position: absolute; top: 9%; right: 14%; width: clamp(50px, 8vw, 96px); aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle at 38% 38%, #fff6df, #f3d9a8 70%); box-shadow: 0 0 60px 14px #f6d9a433; }
.range { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 46%; }
.range .far { fill: #4a2460; opacity: .85; }
.range .near { fill: #1f1440; }

.hero, .ghost { position: absolute; bottom: 0; aspect-ratio: 600 / 780; pointer-events: none; }
.hero { left: 50%; height: 84%; transform: translateX(-50%); transform-origin: 50% 100%; }
.hero svg, .ghost svg { width: 100%; height: 100%; display: block; overflow: visible; }
.ghost { left: 50%; height: 84%; opacity: 0; filter: sepia(.2) hue-rotate(205deg) saturate(1.4) brightness(.85); will-change: opacity; }

.touch { position: absolute; width: 180px; height: 180px; margin: -90px 0 0 -90px; border-radius: 50%; background: radial-gradient(circle, #ffd27a88, #ffd27a00 68%); opacity: 0; pointer-events: none; transition: opacity .16s; }
.touch.on { opacity: 1; }

.axis-x { position: absolute; left: 0; right: 0; bottom: 8px; height: 18px; pointer-events: none; }
.axis-x span { position: absolute; transform: translateX(-50%); color: #fbeed2aa; font-size: 11px; }
.axis-x span.root { color: var(--cream); font-weight: 500; }
.axis-y { position: absolute; left: 14px; top: 0; bottom: 0; pointer-events: none; }
.axis-y span { position: absolute; transform: translateY(-50%); color: #fbeed2bb; font-size: 12px; }

.brand { position: absolute; left: 22px; top: 16px; pointer-events: none; }
.brand h1 { margin: 0; font: 700 clamp(26px, 3.4vw, 42px)/1 Fraunces, Georgia, serif; letter-spacing: -.01em; }
.brand p { margin: 8px 0 0; color: #e8def4; min-height: 1.3em; font-size: 13px; }

.wake { position: absolute; left: 50%; bottom: 13%; transform: translateX(-50%); padding: 16px 28px; border: 0; border-radius: 999px; background: var(--saffron); color: var(--ink); font: 700 20px/1 Fraunces, Georgia, serif; white-space: nowrap; cursor: pointer; box-shadow: 0 10px 40px #0007; }
.wake:hover { background: #ffbd4d; }
.wake:focus-visible, .chip:focus-visible, input:focus-visible { outline: 2px solid var(--cream); outline-offset: 2px; }
.wake[hidden] { display: none; }

.log { position: absolute; left: 52px; bottom: 34px; width: min(360px, 42%); pointer-events: none; color: #fff3dc; font-size: 11.5px; line-height: 1.55; text-shadow: 0 1px 3px #0009; }
.log div { opacity: .92; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.rail { background: var(--rail); border-left: 1px solid var(--rail-line); overflow-y: auto; padding: 8px 16px 14px; display: flex; flex-direction: column; }
.compose-link { display: block; margin: 8px 0 4px; padding: 9px 12px; border-radius: 999px; background: var(--saffron); color: var(--ink); text-align: center; text-decoration: none; font: 700 15px/1 Fraunces, Georgia, serif; }
.compose-link:hover { background: #ffbd4d; }
.group { padding: 12px 0; border-bottom: 1px solid var(--rail-line); }
.group h2 { margin: 0 0 10px; font: 700 15px/1 Fraunces, Georgia, serif; color: var(--saffron); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips + .chips, .chips + div { margin-top: 8px; }
.chip { background: transparent; color: var(--cream); border: 1px solid var(--rail-line); border-radius: 999px; padding: 5px 10px; font: inherit; font-size: 12px; cursor: pointer; text-transform: capitalize; }
.chip:hover { border-color: var(--muted); }
.chip[aria-pressed="true"] { background: var(--saffron); border-color: var(--saffron); color: var(--ink); font-weight: 500; }
.slider { display: grid; grid-template-columns: 74px 1fr 42px; gap: 8px; align-items: center; height: 26px; }
.slider label { color: var(--muted); font-size: 12px; }
.slider output { text-align: right; font-size: 11.5px; color: var(--cream); }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 18px; background: transparent; margin: 0; cursor: pointer; }
input[type=range]::-webkit-slider-runnable-track { height: 3px; background: var(--rail-line); border-radius: 2px; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 13px; height: 13px; margin-top: -5px; border-radius: 50%; background: var(--saffron); border: 0; }
input[type=range]::-moz-range-track { height: 3px; background: var(--rail-line); }
input[type=range]::-moz-range-thumb { width: 13px; height: 13px; border-radius: 50%; background: var(--saffron); border: 0; }
.slider.off { opacity: .35; }
.hint { color: var(--muted); font-size: 11.5px; line-height: 1.5; margin: 10px 0 0; }
.agent { margin-top: auto; padding-top: 12px; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 11.5px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #6b6187; flex: none; }
.agent.on .dot { background: #63e2a0; box-shadow: 0 0 8px #63e2a0; }

@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 62dvh 1fr; }
  .rail { border-left: 0; border-top: 1px solid var(--rail-line); padding: 4px 16px 16px; }
  .log { display: none; }
  .hero, .ghost { height: 76%; }
}
@media (prefers-reduced-motion: reduce) { .ghost { display: none; } }
