:root {
  --bg: #0b0b0d; --panel: #131316; --line: #242429; --fg: #ededf0; --mute: #85858f;
  --ok: #34d399; --bad: #e5484d; --hover: #1a1a1e;
  --sans: system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; background: var(--bg); color: var(--fg); overscroll-behavior: none; }
body { font: 14px/1.4 var(--sans); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
i { font-style: normal; }
.mono { font-family: var(--mono); font-size: 12px; letter-spacing: .04em; }
.muted { color: var(--mute); }

/* control sheet */
#ctl { min-height: 100dvh; display: grid; place-items: center; padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom)); }
.sheet { width: 100%; max-width: 420px; background: var(--panel); border: 1px solid var(--line); border-radius: 2px; }
.sheet > :not([hidden]) ~ :not([hidden]) { border-top: 1px solid var(--line); }
.row { display: flex; align-items: center; gap: 10px; padding: 14px 16px; }
.state { flex: 1; color: var(--fg); letter-spacing: .1em; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #3a3a41; flex: none; }
.dot.on { background: var(--ok); }
.dot.ring { background: none; border: 1.5px solid var(--mute); }
.dot.busy { animation: blink 1.2s steps(2, jump-none) infinite; }
@keyframes blink { 50% { opacity: .25; } }

.act { display: grid; gap: 12px; padding: 16px; }
.line { display: flex; gap: 8px; }
.line input { flex: 1; min-width: 0; }
.field { display: grid; grid-template-columns: 96px 1fr; align-items: center; gap: 12px; }
.field > span { color: var(--mute); font: 11px var(--mono); letter-spacing: .1em; text-transform: uppercase; }
.sel { position: relative; display: block; }
.sel::after { content: ""; position: absolute; right: 13px; top: 50%; width: 5px; height: 5px; border: solid var(--mute); border-width: 0 1px 1px 0; transform: translate(0, -70%) rotate(45deg); pointer-events: none; }
select, input { width: 100%; height: 36px; padding: 0 10px; background: var(--bg); border: 1px solid var(--line); border-radius: 2px; outline: none; -webkit-appearance: none; appearance: none; }
select { padding-right: 30px; cursor: pointer; }
input::placeholder { color: #55555d; }
select:focus-visible, input:focus, .btn:focus-visible { border-color: #45454d; }

.btn { height: 36px; padding: 0 14px; display: inline-flex; align-items: center; justify-content: center; background: none; border: 1px solid var(--line); border-radius: 2px; cursor: pointer; text-decoration: none; white-space: nowrap; outline: none; }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--fg); border-color: var(--fg); color: var(--bg); font-weight: 500; }
.btn.primary:hover { background: #d4d4d9; }
.btn:disabled { opacity: .4; cursor: default; pointer-events: none; }

.quiet { padding: 6px 8px; gap: 2px; }
.quiet .btn { height: 30px; padding: 0 8px; border-color: transparent; color: var(--mute); font-size: 13px; }
.quiet .btn:hover { background: none; color: var(--fg); }
.quiet .btn.arm { color: var(--bad); border-color: #4a2226; }
.sp { flex: 1; }
.msg { padding: 10px 16px; color: var(--mute); word-break: break-word; }
.msg.err { color: var(--bad); }

/* operator console */
.console { max-width: 640px; }
.console h2 { font: 14px var(--mono); }
.console table { width: 100%; border-collapse: collapse; }
.console th, .console td { padding: 6px 0; text-align: right; font-weight: normal; }
.console th:first-child { text-align: left; }
.console thead, .console small { color: var(--mute); }
.console ul, .console ol { list-style: none; padding: 0; }
.console li { padding: 5px 0; }
.console ul li { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.console small { display: block; }
.console ol { max-height: 18rem; overflow: auto; }
.console .msg:empty { display: none; }

/* stream */
#stage { position: fixed; inset: 0; width: 100dvw; height: 100dvh; background: #000; overflow: hidden; }
#surf, #stage { touch-action: none; overscroll-behavior: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
#surf { position: absolute; inset: 0; cursor: none; }
#v { width: 100%; height: 100%; display: block; object-fit: contain; pointer-events: none; }
.wait { position: absolute; inset: 0; display: grid; place-items: center; color: var(--mute); pointer-events: none; letter-spacing: .14em; }

.hud { position: fixed; top: 0; left: 50%; transform: translateX(-50%); z-index: 3; display: flex; flex-direction: column; align-items: center; padding: 0 28px 14px; max-width: 100vw; cursor: default; }
.handle { display: block; width: 36px; height: 4px; background: rgba(237, 237, 240, .28); border-radius: 0 0 2px 2px; }
.bar { display: none; align-items: center; gap: 2px; height: 34px; padding: 0 4px 0 12px; max-width: calc(100vw - 16px); overflow-x: auto; scrollbar-width: none; background: var(--panel); border: 1px solid var(--line); border-top: 0; border-radius: 0 0 2px 2px; }
.hud.open .bar { display: flex; }
.hud.open .handle { display: none; }
@media (hover: hover) {
  .hud:hover .bar { display: flex; }
  .hud:hover .handle { display: none; }
}
.stats { font: 11px var(--mono); white-space: nowrap; padding-right: 10px; margin-right: 4px; border-right: 1px solid var(--line); }
.bar button { flex: none; height: 26px; padding: 0 9px; background: none; border: 0; border-radius: 2px; color: var(--mute); font: 11px var(--mono); letter-spacing: .06em; text-transform: uppercase; cursor: pointer; white-space: nowrap; }
.bar button:hover { color: var(--fg); background: var(--hover); }
.bar button.on { color: var(--ok); }
.bar button.end { color: var(--bad); }
html:not(.coarse) .touch { display: none !important; }

.handle.bottom { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); z-index: 3; border-radius: 2px 2px 0 0; }
.handle.bottom::before { content: ""; position: absolute; inset: -18px -28px 0; }
.strip { position: fixed; left: 0; right: 0; bottom: 0; z-index: 3; display: flex; gap: 1px; background: var(--line); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.strip button { flex: 1; min-width: 0; height: 44px; background: var(--panel); border: 0; color: var(--fg); font: 11px var(--mono); letter-spacing: .08em; text-transform: uppercase; }
.strip button:active { background: var(--hover); }
.strip button.on { color: var(--ok); box-shadow: inset 0 -2px var(--ok); }
.strip .gap { flex: .25; background: var(--panel); }
.kbd { position: fixed; left: 0; bottom: 0; width: 1px; height: 1px; opacity: 0; border: 0; padding: 0; pointer-events: none; }
