:root {
  color-scheme: dark;
  --bg: #080b0d;
  --panel: #101518;
  --panel-2: #161c1f;
  --ink: #f3f0e8;
  --muted: #899397;
  --line: rgba(255, 255, 255, 0.1);
  --lime: #d7ff64;
  --orange: #ff855f;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); }
body { font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, textarea, input { font: inherit; }
button { color: inherit; }

.app { min-height: 100vh; }
.app.locked { display: none; }
.auth-gate { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 75% 15%, rgba(215,255,100,.08), transparent 30%), radial-gradient(circle at 15% 90%, rgba(255,133,95,.07), transparent 28%); }
.auth-gate.hidden { display: none; }
.auth-card { width: min(420px, 100%); padding: 38px; border: 1px solid var(--line); border-radius: 20px; background: rgba(16,21,24,.94); box-shadow: 0 35px 110px rgba(0,0,0,.45); }
.auth-mark { margin-bottom: 26px; }
.auth-card h1 { font-size: 42px; }
.auth-copy { margin: 16px 0 28px; color: var(--muted); line-height: 1.55; font-size: 14px; }
.auth-card label { display: block; margin-bottom: 8px; color: var(--muted); font-size: 12px; font-weight: 750; }
.auth-card input { width: 100%; height: 48px; padding: 0 14px; color: var(--ink); background: #090d0f; border: 1px solid var(--line); border-radius: 10px; outline: none; }
.auth-card input:focus { border-color: rgba(215,255,100,.6); box-shadow: 0 0 0 3px rgba(215,255,100,.08); }
.auth-submit { width: 100%; margin-top: 12px; height: 46px; }
.auth-error { min-height: 18px; margin: 12px 0 0; color: var(--orange); text-align: center; font-size: 12px; }
.topbar {
  height: 72px;
  display: grid;
  grid-template-columns: 1fr auto auto 1fr;
  align-items: center;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(8, 11, 13, 0.9);
  backdrop-filter: blur(16px);
  position: relative;
  z-index: 5;
}
.brand { display: flex; align-items: center; gap: 11px; color: inherit; text-decoration: none; font-weight: 750; letter-spacing: -0.02em; }
.brand-mark { width: 32px; height: 32px; display: grid; place-items: center; color: #10140d; background: var(--lime); border-radius: 9px; font-size: 11px; font-weight: 900; }
.connection { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--orange); box-shadow: 0 0 0 4px rgba(255, 133, 95, 0.1); }
.connection.online .status-dot { background: var(--lime); box-shadow: 0 0 0 4px rgba(215, 255, 100, 0.1); }
.actions { display: flex; justify-content: flex-end; gap: 10px; }
.room-tools { display: flex; align-items: center; gap: 6px; margin-left: 22px; }
.room-tools select { height: 36px; min-width: 145px; padding: 0 30px 0 10px; color: var(--ink); background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; outline: none; font-size: 12px; font-weight: 700; }
.icon-button { width: 36px; height: 36px; display: grid; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: 9px; color: var(--muted); background: var(--panel-2); cursor: pointer; font-size: 18px; }
.icon-button:hover { color: var(--ink); border-color: rgba(255,255,255,.2); }
.icon-button.danger:hover { color: var(--orange); border-color: rgba(255,133,95,.35); }
.icon-button.logout { font-size: 15px; }
.button { border: 0; border-radius: 10px; padding: 10px 15px; cursor: pointer; font-weight: 700; font-size: 13px; transition: transform .15s, background .15s; }
.button:hover { transform: translateY(-1px); }
.button.primary { color: #11150c; background: var(--lime); }
.button.secondary { background: var(--panel-2); border: 1px solid var(--line); }

.workspace { min-height: calc(100vh - 72px); display: grid; grid-template-columns: minmax(320px, 390px) 1fr; }
.sidebar { padding: 38px 30px 24px; border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 20px; background: linear-gradient(150deg, rgba(215,255,100,.035), transparent 30%); }
.eyebrow { margin: 0 0 8px; color: var(--lime); font-size: 11px; font-weight: 850; letter-spacing: .16em; text-transform: uppercase; }
h1 { margin: 0; font-size: clamp(34px, 3vw, 49px); line-height: .98; letter-spacing: -.055em; }
h1 em { color: var(--lime); font-family: Georgia, serif; font-weight: 400; }
.intro { margin: 18px 0 0; max-width: 33ch; color: var(--muted); line-height: 1.55; font-size: 14px; }
.editor-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: -13px; }
.script-label { color: var(--muted); font-size: 12px; font-weight: 700; }
.editor-head span { color: #596266; font-size: 10px; font-weight: 750; text-transform: uppercase; letter-spacing: .1em; }
.format-bar { display: flex; gap: 5px; align-items: center; margin-bottom: -14px; position: relative; z-index: 1; padding: 7px; border: 1px solid var(--line); border-bottom: 0; border-radius: 12px 12px 0 0; background: var(--panel-2); }
.format-bar button { min-width: 29px; height: 28px; padding: 0 7px; border: 0; border-radius: 6px; color: #a8b0b3; background: transparent; cursor: pointer; }
.format-bar button:hover, .format-bar button.active { color: #10140d; background: var(--lime); }
.format-divider { width: 1px; height: 18px; margin: 0 3px; background: var(--line); }
.format-bar input { min-width: 0; flex: 1; height: 28px; padding: 0 8px; color: var(--ink); background: #0c1012; border: 1px solid var(--line); border-radius: 6px; outline: none; font-size: 11px; }
.format-bar .marker-button { min-width: 68px; color: var(--lime); font-size: 10px; font-weight: 800; }
.editor { width: 100%; min-height: 190px; max-height: 31vh; flex: 1; overflow: auto; padding: 16px; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 0 0 12px 12px; line-height: 1.5; outline: none; font-size: 14px; }
.editor:focus { border-color: rgba(215,255,100,.55); box-shadow: 0 0 0 3px rgba(215,255,100,.08); }
.editor p { margin: 0 0 .85em; }
.editor .script-marker { margin: 16px 0; padding: 6px 9px; border-left: 3px solid var(--orange); border-radius: 0 5px 5px 0; color: var(--orange); background: rgba(255,133,95,.08); font-size: 10px; font-weight: 900; letter-spacing: .14em; text-transform: uppercase; user-select: all; }
.controls { display: grid; gap: 15px; }
.control label { display: flex; justify-content: space-between; margin-bottom: 8px; color: var(--muted); font-size: 12px; font-weight: 700; }
.control output { color: var(--ink); }
input[type="range"] { width: 100%; accent-color: var(--lime); }
.toggle-row { display: flex; gap: 18px; }
.auto-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 11px; border: 1px solid var(--line); border-radius: 9px; background: rgba(215,255,100,.025); }
.auto-toggle { color: var(--ink) !important; }
.auto-status { color: var(--muted); font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.auto-status.running { color: var(--lime); }
.auto-status.paused { color: var(--orange); }
.speed-control.disabled, .pause-control.disabled { opacity: .42; }
.toggle { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; font-weight: 700; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; }
.toggle span { width: 30px; height: 18px; background: #293034; border-radius: 20px; position: relative; transition: .2s; }
.toggle span::after { content: ""; position: absolute; width: 12px; height: 12px; border-radius: 50%; left: 3px; top: 3px; background: #838d91; transition: .2s; }
.toggle input:checked + span { background: var(--lime); }
.toggle input:checked + span::after { left: 15px; background: #111; }
.hint { margin: 0; color: #626b6f; font-size: 11px; }
kbd { padding: 2px 5px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 4px; color: #9da6a9; }

.stage-wrap { position: relative; min-width: 0; padding: 28px; display: flex; flex-direction: column; background: radial-gradient(circle at 80% 0, rgba(255,133,95,.06), transparent 35%); }
.stage-label { display: flex; justify-content: space-between; margin: 0 2px 12px; color: var(--muted); font-size: 11px; font-weight: 750; text-transform: uppercase; letter-spacing: .12em; }
.stage-label strong { color: var(--lime); }
.stage { flex: none; min-height: 0; align-self: center; overflow: hidden; position: relative; cursor: grab; touch-action: none; background: #030506; border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 30px 90px rgba(0,0,0,.35); }
.stage.dragging { cursor: grabbing; }
.stage.wheel-steering { cursor: ns-resize; }
.prompt { position: absolute; top: 50%; left: 7%; width: 86%; white-space: pre-wrap; font-weight: 750; letter-spacing: -.035em; transform-origin: center top; will-change: transform; user-select: none; }
.prompt p { margin: 0 0 .8em; }
.prompt .script-marker { margin: 1.25em 0 .9em; padding: .35em .7em; color: var(--orange); border-top: 2px solid currentColor; border-bottom: 2px solid currentColor; font-size: .32em; font-weight: 900; letter-spacing: .16em; text-align: center; text-transform: uppercase; }
.viewer .stage.mirrored .prompt { transform: scaleX(-1); }
.empty { position: absolute; inset: 0; display: grid; place-items: center; color: #3d4548; font-size: 15px; }
.guide { position: absolute; left: 3.5%; right: 3.5%; height: 1px; z-index: 2; background: linear-gradient(90deg, transparent, rgba(215,255,100,.55) 15%, rgba(215,255,100,.55) 85%, transparent); pointer-events: none; }
.guide.top { top: 50%; }
.guide.bottom { display: none; }
.drag-pill { position: absolute; bottom: 42px; left: 50%; transform: translateX(-50%); pointer-events: none; padding: 8px 12px; border: 1px solid var(--line); border-radius: 99px; background: rgba(16,21,24,.72); color: var(--muted); font-size: 11px; backdrop-filter: blur(8px); }
.wheel-anchor { position: absolute; z-index: 4; display: none; width: 34px; height: 62px; translate: -50% -50%; place-items: center; grid-template-rows: 1fr 18px 1fr; color: var(--lime); pointer-events: none; filter: drop-shadow(0 3px 8px #000); }
.wheel-anchor.active { display: grid; }
.wheel-core { width: 17px; height: 17px; border: 2px solid var(--lime); border-radius: 50%; background: #111719; box-shadow: 0 0 0 5px rgba(215,255,100,.11); }
.wheel-arrow { font-size: 9px; opacity: .85; }
.wheel-arrow.up { align-self: end; margin-bottom: 5px; }
.wheel-arrow.down { align-self: start; margin-top: 5px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); padding: 10px 15px; background: var(--ink); color: #111; border-radius: 9px; font-size: 12px; font-weight: 800; opacity: 0; pointer-events: none; transition: .2s; z-index: 10; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

body.viewer .topbar,
body.viewer .sidebar,
body.viewer .stage-label,
body.viewer .drag-pill,
body.viewer .guide,
body.viewer .empty,
body.viewer .wheel-anchor { display: none; }
body.viewer .workspace { display: block; min-height: 100vh; }
body.viewer .stage-wrap { padding: 0; height: 100vh; }
body.viewer .stage { width: 100%; height: 100vh; min-height: 100vh; border: 0; border-radius: 0; }
body.viewer .prompt { left: 7%; width: 86%; }
body.viewer.dim .stage { filter: brightness(.45); }

@media (max-width: 860px) {
  .topbar { height: auto; min-height: 72px; grid-template-columns: 1fr auto; gap: 10px; padding-block: 12px; }
  .connection { display: none; }
  .room-tools { order: 3; grid-column: 1 / -1; margin-left: 0; }
  .room-tools select { flex: 1; }
  .actions .secondary, .actions .logout { display: none; }
  .workspace { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .stage-wrap { min-height: 70vh; }
}
