:root {
  color-scheme: dark;
  --bg: #0a0a0b;
  --panel: #121214;
  --raise: #18181b;
  --hover: #1f1f23;
  --line: #26262b;
  --line-2: #34343a;
  --text: #e7e7e9;
  --dim: #8d8d96;
  --faint: #5c5c64;
  --accent: #f5c542;
  --accent-soft: rgba(245, 197, 66, 0.14);
  --ink: #141414;
  --ok: #45d483;
  --bad: #ff6159;
  --wait: #f5c542;
  --h: 30px;
  --mono: "JetBrains Mono", "Cascadia Mono", Consolas, ui-monospace, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { background: var(--bg); }
body {
  min-height: 100vh; display: grid; place-items: center; padding: 32px 16px; color: var(--text);
  font: 500 13px/20px var(--mono); font-variant-numeric: tabular-nums;
  background-image: radial-gradient(circle at 1px 1px, #1b1b1f 1px, transparent 0);
  background-size: 24px 24px;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
[hidden] { display: none !important; }
::selection { background: var(--accent); color: var(--ink); }

.layout { width: 100%; max-width: 1240px; display: grid; grid-template-columns: 420px minmax(0, 1fr); gap: 16px; align-items: start; }
.layout.single { max-width: 440px; grid-template-columns: minmax(0, 1fr); }
.stack { display: grid; gap: 16px; }

.win { width: 100%; max-width: 440px; background: var(--panel); border: 1px solid var(--line-2); border-radius: 3px; overflow: hidden; }
.layout .win { max-width: none; }
#live-section { position: sticky; top: 32px; }
.win.wide { max-width: 1000px; }

.title {
  display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 12px; background: var(--bg);
  border-bottom: 1px solid var(--line); font-weight: 700; white-space: nowrap;
}
.title .mark b { color: var(--accent); }
.title .sub { color: var(--faint); font-weight: 500; }
.title .state { flex: 1; min-width: 0; text-align: right; color: var(--dim); font-weight: 500; overflow: hidden; text-overflow: ellipsis; }

.tabs { display: flex; border-bottom: 1px solid var(--line); background: var(--bg); }
.tabs a, .tabs button {
  height: 32px; padding: 0 14px; display: inline-flex; align-items: center; border: 0; border-right: 1px solid var(--line); border-radius: 0;
  background: transparent; color: var(--dim); font: 500 12px var(--mono); cursor: pointer; text-decoration: none;
}
.tabs a:hover, .tabs button:hover { color: var(--text); background: var(--raise); filter: none; }
.tabs [aria-current="page"], .tabs [aria-selected="true"] { color: var(--accent); background: var(--panel); box-shadow: inset 0 -2px 0 var(--accent); }
.tabs .push { margin-left: auto; border-right: 0; border-left: 1px solid var(--line); }

.body { display: grid; gap: 8px; }
.win > .body { padding: 12px; }

.dim { color: var(--dim); }
.ok { color: var(--ok); }
.bad { color: var(--bad); }
.wait { color: var(--wait); }
.message { color: var(--bad); }
.message::before { content: "! "; }
.message:empty { display: none; }
.message.ok { color: var(--ok); }
.message.ok::before { content: "> "; }
.mono { font-family: var(--mono); }

.row { display: grid; grid-template-columns: 10ch minmax(0, 1fr); gap: 10px; align-items: center; }
.row > span { color: var(--dim); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kv { display: grid; grid-template-columns: 10ch 1fr; gap: 10px; align-items: baseline; padding: 4px 0; }
.kv > span:first-child { color: var(--faint); font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; }
.kv + .kv { border-top: 1px dashed var(--line); }

input:not([type="checkbox"]), select {
  width: 100%; height: var(--h); padding: 0 8px; border: 1px solid var(--line-2); border-radius: 2px; outline: 0;
  background: var(--bg); color: var(--text); font: 500 13px var(--mono); appearance: none;
}
input:not([type="checkbox"]):hover, select:hover { border-color: #46464d; }
input:not([type="checkbox"]):focus, select:focus { border-color: var(--accent); }
input::placeholder { color: var(--faint); }
select:disabled, input:disabled { opacity: 0.5; }
select {
  padding-right: 28px; background-repeat: no-repeat; background-position: right 8px center; background-size: 10px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M1 3h8L5 8z' fill='%238d8d96'/%3E%3C/svg%3E");
}
option { background: var(--panel); }

.check { display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; width: max-content; min-height: 24px; }
.check input { position: absolute; opacity: 0; width: 0; height: 0; }
.check .box { flex: none; width: 34px; height: 18px; display: grid; place-items: center; border: 1px solid var(--line-2); border-radius: 2px; color: var(--faint); font-size: 11px; line-height: 1; }
.check .box::after { content: "off"; }
.check:hover .box { border-color: #46464d; }
.check input:focus-visible + .box { outline: 1px solid var(--accent); outline-offset: 2px; }
.check input:checked + .box { background: var(--accent); border-color: var(--accent); color: var(--ink); font-weight: 700; }
.check input:checked + .box::after { content: "on"; }
.check input:disabled + .box { opacity: 0.45; }

button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: var(--h); padding: 0 14px;
  border: 1px solid var(--accent); border-radius: 2px; color: var(--ink); background: var(--accent);
  font: 700 12px/1 var(--mono); cursor: pointer; white-space: nowrap; text-decoration: none;
}
button:hover, .btn:hover { filter: brightness(1.08); color: var(--ink); text-decoration: none; }
button:disabled { opacity: 0.4; cursor: default; filter: none; }
button.ghost { background: var(--raise); border-color: var(--line-2); color: var(--text); }
button.ghost:hover { background: var(--hover); color: var(--text); filter: none; }
button.danger { background: transparent; border-color: var(--bad); color: var(--bad); }
button.danger:hover { background: rgba(255, 97, 89, 0.12); color: var(--bad); filter: none; }
.buttons button:not(.danger):not(.on):not([type="submit"]) { background: var(--raise); border-color: var(--line-2); color: var(--text); }
.buttons button:not(.danger):not(.on):not([type="submit"]):hover { background: var(--hover); filter: none; }
.buttons button.on, .buttons button.on:disabled { opacity: 1; background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.buttons #bot-power:not(.danger) { background: var(--accent); border-color: var(--accent); color: var(--ink); }
.buttons { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.buttons .grow { flex: 1; }

details { display: grid; border: 1px solid var(--line); border-radius: 2px; background: var(--panel); }
details > summary {
  list-style: none; display: flex; align-items: center; gap: 8px; height: 32px; padding: 0 10px; cursor: pointer; user-select: none;
  color: var(--dim); font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; background: var(--bg);
}
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: "+"; width: 1ch; color: var(--faint); }
details[open] > summary::before { content: "\2212"; color: var(--accent); }
details[open] > summary { border-bottom: 1px solid var(--line); color: var(--text); }
details > summary:hover { color: var(--text); }
details > .body { padding: 10px; }

kbd { font: 11px var(--mono); padding: 0 5px; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 2px; color: var(--text); background: var(--raise); }
ol { list-style: none; counter-reset: step; display: grid; gap: 6px; }
ol li { counter-increment: step; display: grid; grid-template-columns: 3ch 1fr; }
ol li::before { content: counter(step, decimal-leading-zero); color: var(--accent); }

table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { text-align: left; font-weight: 500; color: var(--faint); font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; padding: 6px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 5px 10px; border-bottom: 1px dashed var(--line); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--raise); }
.scroll { overflow-x: auto; }
#list { gap: 6px; }
.user > summary { height: auto; min-height: 38px; flex-wrap: wrap; padding: 6px 10px; text-transform: none; letter-spacing: 0; font-size: 13px; color: var(--text); }
.user > summary .meta { color: var(--faint); font-size: 12px; white-space: pre; }
.user > summary .buttons { margin-left: auto; }
.user > summary button { height: 24px; padding: 0 10px; font-size: 11px; }
#cloud-ip { gap: 6px; }
#cloud-ip button { height: 24px; font-size: 11px; font-weight: 500; }

.timer { font: 700 32px/1 var(--mono); letter-spacing: -0.02em; color: var(--accent); padding: 4px 0 6px; }
.pill { display: inline-flex; align-items: center; gap: 6px; height: 20px; padding: 0 2px; font-size: 12px; color: var(--dim); text-transform: lowercase; }
.pill::before { content: ""; width: 7px; height: 7px; background: currentColor; }
.pill.ok { color: var(--ok); }
.pill.wait { color: var(--wait); }
.pill.bad { color: var(--bad); }
.pill:empty { display: none; }

.live { display: grid; grid-template-columns: minmax(0, 1fr) 240px; }
.stage { position: relative; background: #060607; min-height: 420px; }
.stage canvas { display: block; width: 100%; height: 100%; min-height: 420px; }
.hud { position: absolute; left: 12px; top: 12px; display: grid; gap: 2px; pointer-events: none; padding: 8px 10px; background: rgba(10, 10, 11, 0.8); border: 1px solid var(--line-2); border-radius: 2px; }
.hud .timer { font-size: 24px; padding: 0; }
.empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--faint); text-align: center; padding: 20px; }
.board { border-left: 1px solid var(--line); max-height: 560px; overflow-y: auto; padding: 0 0 8px; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
.board h3 { font-size: 11px; font-weight: 500; color: var(--faint); text-transform: uppercase; letter-spacing: 0.1em; padding: 10px 12px 4px; }
.board .p { display: flex; align-items: baseline; gap: 8px; padding: 2px 12px; font-size: 12px; }
.board .p span:first-child { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board .p span:last-child { color: var(--dim); }
.board .p.down span:first-child { color: var(--bad); }
.board .p.me { background: var(--accent-soft); box-shadow: inset 2px 0 0 var(--accent); }

.lead { color: var(--dim); }
.lead b { color: var(--text); font-weight: 600; }
.foot { display: flex; flex-wrap: wrap; gap: 4px 14px; padding: 8px 12px; border-top: 1px solid var(--line); background: var(--bg); color: var(--faint); font-size: 11px; }

@media (max-width: 980px) {
  .layout { grid-template-columns: minmax(0, 1fr); max-width: 560px; }
  #live-section { position: static; }
  .live { grid-template-columns: minmax(0, 1fr); }
  .board { border-left: 0; border-top: 1px solid var(--line); max-height: 300px; }
}
@media (max-width: 600px) {
  body { padding: 16px; place-items: start center; }
  .row { grid-template-columns: 9ch minmax(0, 1fr); }
  .kv { grid-template-columns: 9ch 1fr; }
  .stage, .stage canvas { min-height: 300px; }
}
