:root {
  color-scheme: dark;
  --bg: #08111d;
  --card: #101d2c;
  --card-2: #132235;
  --line: #22364b;
  --text: #edf5fc;
  --muted: #95a9bd;
  --mint: #65e6c3;
  --mint-dark: #123d3b;
  --amber: #ffc56b;
  --red: #ff737e;
  font-family: Manrope, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(ellipse at 88% 0%, #18334a 0, transparent 35rem), var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; }
.shell { width: min(100% - 28px, 760px); margin: 0 auto; padding: max(22px, env(safe-area-inset-top)) 0 max(26px, env(safe-area-inset-bottom)); }
.topbar { display: flex; align-items: center; gap: 13px; margin: 4px 2px 22px; }
.brand-mark { width: 43px; height: 43px; border: 1px solid #327a73; border-radius: 14px; display: grid; place-items: center; color: var(--mint); background: #103032; font-weight: 800; font-size: 20px; }
.eyebrow { margin: 0 0 4px; color: #84a0b6; font-size: 10px; font-weight: 800; letter-spacing: .16em; }
h1 { margin: 0; font-size: clamp(20px, 5vw, 25px); letter-spacing: -.04em; }
h2 { margin: 0; font-size: 19px; letter-spacing: -.035em; }
.pill { margin-left: auto; padding: 7px 11px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 11px; font-weight: 700; }
.pill.connected { border-color: #277765; color: var(--mint); background: #102a2b; }
.pill.connecting { border-color: #876634; color: var(--amber); }
.pill.error { border-color: #80404a; color: var(--red); background: #321821; }
.card { margin: 12px 0; padding: 20px; border: 1px solid var(--line); border-radius: 20px; background: linear-gradient(145deg, rgba(20, 37, 55, .97), rgba(13, 26, 41, .98)); box-shadow: 0 12px 32px #0002; }
.connect-card { border-color: #315167; }
.section-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 11px; }
.muted { margin: 0 0 16px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.api-badge { border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; color: var(--muted); font-family: "DM Mono", monospace; font-size: 10px; white-space: nowrap; }
.api-badge.good { color: var(--mint); border-color: #277765; }
.api-badge.bad { color: var(--amber); border-color: #806438; }
.device-row { display: flex; align-items: center; gap: 13px; padding: 13px; border: 1px solid #263d52; border-radius: 14px; background: #0a1724; }
.device-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; color: var(--mint); background: #143537; font-size: 25px; }
.device-meta { display: grid; gap: 5px; min-width: 0; }
.device-meta strong { font-size: 13px; }
.device-meta span { color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.connect-status { margin-top: 10px; padding: 10px 12px; border: 1px solid #263d52; border-radius: 12px; color: var(--muted); background: #0a1724; font-size: 11px; line-height: 1.5; overflow-wrap: anywhere; }
.connect-status.error { border-color: #80404a; color: #ffb6bc; background: #28151f; }
.connect-status.success { border-color: #277765; color: var(--mint); background: #102a2b; }
code { color: #a7d7e7; font-family: "DM Mono", monospace; font-size: .94em; }
.button-row { display: flex; gap: 10px; margin-top: 14px; }
.button { min-height: 46px; padding: 0 16px; border: 1px solid transparent; border-radius: 12px; font-size: 13px; font-weight: 800; cursor: pointer; transition: transform .15s, opacity .15s, background .15s; }
.button:active, .command-button:active { transform: scale(.985); }
.button:disabled, .command-button:disabled { cursor: not-allowed; opacity: .43; }
.button.primary { flex: 1; color: #05211e; background: var(--mint); }
.button.primary:not(:disabled):active { background: #8df3d7; }
.button.secondary { color: var(--text); background: var(--card-2); border-color: #30475b; }
.button.caution { flex: 1; color: #2b1b08; background: var(--amber); }
.command-grid { display: grid; gap: 9px; }
.command-button { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 60px; padding: 10px 13px; border: 1px solid #263d52; border-radius: 14px; color: var(--text); background: #0b1927; text-align: left; cursor: pointer; }
.command-icon { display: grid; flex: 0 0 34px; height: 34px; place-items: center; border-radius: 11px; color: var(--mint); background: #153237; font-size: 17px; }
.command-button > span:nth-child(2) { display: grid; flex: 1; gap: 4px; }
.command-button strong { font-size: 12px; }
.command-button small { color: var(--muted); font-size: 10px; }
.arrow { color: #7691a8; }
.step-number { color: #5e7b94; font: 500 13px "DM Mono", monospace; }
.preview-card { border-color: #4d4434; }
.preview-actions { margin-top: 4px; }
.stream-steps, .stream-url-list { margin-top: 15px; padding: 13px; border: 1px solid #3b3a34; border-radius: 13px; background: #171d24; color: #d6dfeb; font-size: 11px; line-height: 1.6; }
.stream-steps > strong { color: var(--amber); font-size: 12px; }
.stream-steps ol { margin: 8px 0 0; padding-left: 20px; }
.stream-steps li { padding: 2px 0; }
.stream-url-list { display: grid; gap: 7px; }
.stream-url-list .eyebrow { margin: 0 0 2px; }
.stream-url-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 8px; border-radius: 8px; background: #0b1520; }
.stream-url-row code { min-width: 0; overflow-wrap: anywhere; font-size: 9px; }
.stream-url-row .text-button { flex: 0 0 auto; }
.small-note { margin: 11px 0 0; color: #9c8d75; font-size: 10px; line-height: 1.5; }
.result-box { margin-top: 12px; padding: 12px 14px; border: 1px solid #287366; border-radius: 12px; color: var(--mint); background: #0d2929; font-size: 12px; line-height: 1.6; overflow-wrap: anywhere; }
.result-box strong { display: block; margin-bottom: 3px; color: #b7ffe8; }
.hidden { display: none !important; }
.notice { margin: 0 0 13px; padding: 14px 15px; border: 1px solid #806438; border-radius: 14px; color: #f8d9a6; background: #332718; font-size: 12px; line-height: 1.6; }
.notice strong { display: block; margin-bottom: 4px; color: #ffe7bf; }
.notice a { color: #ffe0a5; }
.log-heading { margin-bottom: 13px; }
.log-actions { display: flex; gap: 12px; }
.text-button { padding: 5px 0 5px 6px; border: 0; color: #8fb2c7; background: none; font-size: 11px; font-weight: 800; cursor: pointer; }
.event-log { display: flex; flex-direction: column; gap: 7px; max-height: 310px; min-height: 80px; overflow: auto; padding: 12px; border: 1px solid #203448; border-radius: 12px; background: #07111b; overscroll-behavior: contain; }
.empty-state { margin: auto; color: #71879a; text-align: center; font-size: 11px; }
.log-line { display: grid; grid-template-columns: 66px 1fr; gap: 8px; font: 10px/1.5 "DM Mono", monospace; overflow-wrap: anywhere; }
.log-time { color: #627a8e; }
.log-message { color: #c2d4e1; white-space: pre-wrap; }
.log-line.tx .log-message { color: var(--mint); }
.log-line.rx .log-message { color: #a6d8f6; }
.log-line.error .log-message { color: var(--red); }
footer { display: flex; justify-content: space-between; gap: 15px; margin: 18px 4px 0; color: #667d91; font-size: 9px; }

@media (min-width: 650px) {
  .shell { padding-top: 34px; }
  .card { padding: 23px; }
  .command-grid { grid-template-columns: repeat(3, 1fr); }
  .command-button { min-height: 90px; align-items: flex-start; flex-wrap: wrap; }
  .command-button > span:nth-child(2) { flex-basis: calc(100% - 50px); }
  .arrow { display: none; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; } }
