:root {
  color-scheme: dark;
  --bg: #0f1412;
  --card: #171e1b;
  --line: #26302c;
  --text: #e6ece9;
  --muted: #8d9a94;
  --green: #22a06b;
  --green-2: #1b8a5b;
  --red: #d9534f;
  --amber: #e0a526;
  --console: #0a0d0c;
  --radius: 12px;
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); }
#app { max-width: 1100px; margin: 0 auto; padding: 16px; display: grid; gap: 14px; }
h1, h2 { margin: 0; font-weight: 650; }
h2 { font-size: 1rem; }
.muted { color: var(--muted); }
.error { color: #ff8a85; margin: 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }

.btn { font: inherit; font-weight: 600; color: var(--text); background: #232c28; border: 1px solid #33403a; border-radius: 9px; padding: 9px 16px; cursor: pointer; }
.btn:hover:not(:disabled) { background: #2b3631; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--green-2); }
.btn.danger { background: #3a1f1e; border-color: #5c2a28; color: #ffb3b0; }
.btn.danger:hover:not(:disabled) { background: #4a2523; }
.link { font: inherit; background: none; border: 0; color: var(--muted); cursor: pointer; padding: 4px 6px; }
.link:hover { color: var(--text); text-decoration: underline; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); display: grid; gap: 14px; }
.login-card h1 { font-size: 1.3rem; }
.login-card h1 span { display: block; font-size: .9rem; color: var(--muted); font-weight: 500; }
label { display: grid; gap: 6px; font-size: .9rem; color: var(--muted); }
input, textarea { font: inherit; color: var(--text); background: var(--console); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; width: 100%; }
input:focus, textarea:focus { outline: 2px solid var(--green); outline-offset: -1px; }

.top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.brand { font-weight: 700; font-size: 1.1rem; }
.brand span { color: var(--muted); font-weight: 500; margin-left: 6px; }
.who { color: var(--muted); display: flex; align-items: center; gap: 6px; }

.status { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; }
.status-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.dot { width: 14px; height: 14px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.on { background: var(--green); box-shadow: 0 0 0 4px #22a06b33; }
.dot.off { background: var(--red); }
.dot.busy { background: var(--amber); animation: pulse 1s infinite alternate; }
@keyframes pulse { to { opacity: .4; } }
.state-text { font-weight: 700; font-size: 1.1rem; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.split { display: inline-flex; }
.split .btn:first-child { border-radius: 9px 0 0 9px; }
.split .icon { border-radius: 0 9px 9px 0; border-left: 1px solid #ffffff40; padding: 9px 11px; }
.job { width: 100%; padding: 9px 12px; border-radius: 8px; background: #2a2412; color: #f2d488; }
.job.fail { background: #3a1f1e; color: #ffb3b0; }

.console { display: grid; gap: 10px; }
.console-head { display: flex; justify-content: space-between; align-items: center; }
.console-tools { display: flex; align-items: center; gap: 8px; }
.check { display: flex; align-items: center; gap: 6px; font-size: .85rem; }
.check input { width: auto; }
.log { background: var(--console); border: 1px solid var(--line); border-radius: 8px; height: min(58vh, 560px); overflow: auto; padding: 10px 12px; font: 12.5px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; word-break: break-word; }
.log div { min-height: 1.5em; }
.log .l-warn { color: #f2c46d; }
.log .l-err { color: #ff8a85; }
.log .l-chat { color: #9fd8ff; }
.log .l-join { color: #8be0b5; }
.log .l-me { color: #c7b8ff; }
.log .l-reply { color: #d9e3de; border-left: 2px solid var(--green); padding-left: 8px; margin: 2px 0; }
.quick { display: flex; flex-wrap: wrap; gap: 6px; }
.quick button, .presets button { font: 12.5px ui-monospace, Menlo, Consolas, monospace; color: var(--text); background: #1e2622; border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; cursor: pointer; }
.quick button:hover, .presets button:hover { border-color: var(--green); }
.cmd { display: flex; align-items: center; gap: 8px; }
.cmd .prompt { color: var(--green); font: 700 16px ui-monospace, Menlo, monospace; }
.cmd input { font-family: ui-monospace, Menlo, Consolas, monospace; }

details summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; }
details summary::before { content: "▸"; color: var(--muted); }
details[open] summary::before { content: "▾"; }
.activity { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 4px; font-size: .88rem; }
.activity li { display: grid; grid-template-columns: 9.5em 6em 1fr; gap: 10px; padding: 5px 0; border-bottom: 1px solid var(--line); }
.activity code { font-size: .82rem; color: var(--muted); word-break: break-word; }

.dialog { background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; width: min(440px, calc(100vw - 32px)); }
.dialog.wide { width: min(640px, calc(100vw - 32px)); }
.dialog::backdrop { background: #000a; }
.dialog form { display: grid; gap: 12px; }
.warn { border: 1px solid var(--line); border-radius: 8px; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 10px; }
.warn legend { color: var(--muted); font-size: .85rem; padding: 0 4px; }
.warn label { display: flex; align-items: center; gap: 6px; color: var(--text); }
.warn input { width: auto; }
.dialog-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.grow { flex: 1; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; }
textarea { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; resize: vertical; }
.preview { display: grid; gap: 4px; font-size: .85rem; }
.preview code { background: var(--console); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; word-break: break-all; font-size: 12.5px; }

@media (max-width: 640px) {
  .status { flex-direction: column; align-items: stretch; }
  .actions { display: grid; grid-template-columns: 1fr 1fr 1fr; }
  .split .btn:first-child { flex: 1; }
  .activity li { grid-template-columns: 1fr; gap: 0; }
  .log { height: 55vh; }
  .warn { grid-template-columns: 1fr; }
}
