:root {
  color-scheme: dark;
  --bg: #070b12;
  --surface: #0f1621;
  --surface-2: #162130;
  --line: #24344a;
  --text: #e8f0f7;
  --muted: #93a6ba;
  --accent: #5fd4f4;
  --accent-ink: #04202b;
  --ok: #5fe0a4;
  --warn: #f5c563;
  --danger: #ff8a80;
  --radius: 14px;
  --top: env(safe-area-inset-top, 0px);
  --bottom: env(safe-area-inset-bottom, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--text); overscroll-behavior: none; }
body { font-size: 16px; line-height: 1.45; }
#app { height: 100dvh; display: flex; flex-direction: column; }
h1, h2, h3, p { margin: 0; }
h2 { font-size: 1.35rem; font-weight: 650; }
h3 { font-size: .8rem; font-weight: 650; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; margin: 18px 0 8px; }
button, input, textarea, select { font: inherit; color: inherit; }
input, textarea, select {
  width: 100%; font-size: 16px; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 12px; padding: 11px 12px; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { resize: none; display: block; }
button { min-height: 44px; border: 1px solid var(--line); background: var(--surface-2); border-radius: 12px; padding: 8px 14px; cursor: pointer; }
button:active { opacity: .75; }
button:disabled { opacity: .45; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 650; }
button.danger { color: var(--danger); border-color: #6b3a3a; }
button.quiet { background: transparent; border-color: transparent; color: var(--muted); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: calc(var(--top) + 10px) 16px 8px; }
.brand { font-size: 1rem; font-weight: 700; letter-spacing: .28em; color: var(--accent); }
.pills { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: .75rem; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 3px 9px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.dot.on { background: var(--ok); }
.dot.off { background: var(--danger); }
.dot.wait { background: var(--warn); }

.view { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 4px 16px 16px; }
.tabs { display: grid; grid-template-columns: repeat(5, 1fr); border-top: 1px solid var(--line); background: var(--surface); padding-bottom: var(--bottom); }
.tabs button { position: relative; min-height: 52px; border: 0; border-radius: 0; background: transparent; color: var(--muted); font-size: .72rem; padding: 6px 2px; }
.tabs button[aria-current="page"] { color: var(--accent); font-weight: 650; box-shadow: inset 0 2px 0 var(--accent); }
.badge { position: absolute; top: 6px; left: calc(50% + 14px); min-width: 16px; height: 16px; border-radius: 8px; background: var(--warn); color: #231a02; font-size: .65rem; line-height: 16px; font-weight: 700; padding: 0 4px; }

.home { display: flex; flex-direction: column; min-height: 100%; }
.stage { display: flex; flex-direction: column; align-items: center; padding: 8px 0 14px; }
.orb { position: relative; width: 148px; height: 148px; min-height: 0; padding: 0; border-radius: 50%; background: radial-gradient(circle, #123445 0%, #0b1622 62%, #070b12 100%); border: 2px solid var(--accent); box-shadow: 0 0 26px rgba(95, 212, 244, .3); }
.orb::before, .orb::after { content: ""; position: absolute; border-radius: 50%; inset: 15px; border: 1px solid rgba(95, 212, 244, .5); }
.orb::after { inset: 44px; background: radial-gradient(circle, #d8f6ff 0%, var(--accent) 45%, rgba(95, 212, 244, .08) 100%); border: 0; }
.orb.busy::before { border-style: dashed; animation: spin 3s linear infinite; }
.orb.listening { border-color: var(--danger); box-shadow: 0 0 32px rgba(255, 138, 128, .5); }
.orb.listening::after { background: radial-gradient(circle, #ffe2de 0%, var(--danger) 50%, rgba(255, 138, 128, .1) 100%); }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .orb.busy::before { animation: none; } }
.status-line { margin-top: 10px; min-height: 22px; font-size: .9rem; color: var(--muted); text-align: center; }
.reply { flex: 1; font-size: 1.05rem; white-space: pre-wrap; overflow-wrap: anywhere; padding: 4px 2px 12px; }
.reply.empty { color: var(--muted); text-align: center; }
.composer { position: sticky; bottom: -16px; background: var(--bg); padding: 8px 0 16px; display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { flex: 1; max-height: 120px; }
.composer button { flex: none; }
.hint { font-size: .85rem; color: var(--warn); text-align: center; padding-bottom: 6px; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.header-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 6px 0 10px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; overflow-wrap: anywhere; }
.card.alert { border-color: var(--warn); }
.card .title { font-weight: 620; }
.meta { font-size: .78rem; color: var(--muted); margin-top: 3px; }
.params { font: .82rem/1.4 ui-monospace, Menlo, monospace; white-space: pre-wrap; background: var(--bg); border-radius: 8px; padding: 8px; margin-top: 8px; overflow-x: auto; }
.event { display: grid; grid-template-columns: 10px 1fr; gap: 9px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.event .dot { margin-top: 7px; }
.event-text { overflow-wrap: anywhere; font-size: .93rem; }
.empty-note { color: var(--muted); padding: 14px 0; }
.metric { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: .93rem; }
.metric span:last-child { color: var(--muted); text-align: right; }
.check { display: flex; align-items: center; gap: 8px; font-size: .93rem; }
.check input { width: 20px; height: 20px; flex: none; }
.stack { display: grid; gap: 8px; }
.table-wrap { overflow-x: auto; margin-top: 8px; }
table { border-collapse: collapse; font-size: .82rem; }
th, td { border-bottom: 1px solid var(--line); padding: 5px 8px; text-align: left; white-space: nowrap; }
th { color: var(--muted); }

.pairing { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 14px; padding: calc(var(--top) + 24px) 24px calc(var(--bottom) + 24px); max-width: 480px; width: 100%; margin: 0 auto; }
.pairing .brand { font-size: 1.5rem; text-align: center; }
.pairing p { color: var(--muted); text-align: center; }
.approval-text { margin-top: 8px; }
.pairing p.install { color: var(--warn); border: 1px solid var(--warn); border-radius: 12px; padding: 10px 12px; }
.error { color: var(--danger); font-size: .9rem; text-align: center; }
