:root {
  --bg: #0b1020;
  --card: #141a2e;
  --line: #242c47;
  --text: #e8ecf8;
  --muted: #9aa3bf;
  --accent: #8fb3ff;
  --good: #3ecf8e;
  --warn: #f5b84a;
  --bad: #ff6b6b;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) calc(env(safe-area-inset-bottom) + 24px) env(safe-area-inset-left);
  max-width: 720px;
  margin: 0 auto;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
h1 { font-size: 20px; margin: 0; font-weight: 650; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 14px 0 8px; font-weight: 600; }

/* ---------- buttons ---------- */
.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  min-height: 52px;
  padding: 0 14px;
  border-radius: 14px;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
.btn:active { background: #1d2540; transform: scale(.98); }
.btn:disabled { opacity: .55; }
.btn.on, .btn[aria-pressed="true"].on { background: #1e3a2e; border-color: var(--good); }
.btn.primary { background: var(--accent); color: #0b1020; border: 0; }
.btn.big { min-height: 56px; width: 100%; font-size: 18px; }
.link {
  background: none; border: 0; color: var(--muted); font: inherit; text-decoration: underline;
  padding: 14px; min-height: 48px; cursor: pointer;
}

/* ---------- header ---------- */
.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 10px;
}
.pill {
  font-size: 14px; font-weight: 700; padding: 6px 12px; border-radius: 999px;
  border: 1px solid currentColor;
}
.pill::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: currentColor; margin-right: 7px; vertical-align: 1px; }
.pill.connecting { color: var(--warn); }
.pill.reconnecting { color: var(--bad); }
.pill.paused { color: var(--muted); }
.pill.live { color: var(--good); }

/* ---------- video ---------- */
.stage { position: relative; width: 100%; aspect-ratio: 16 / 9; background: #000; }
.player, .player video-stream, .player video { display: block; width: 100%; height: 100%; }
.player video { object-fit: contain; background: #000; }
.sound-big {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);
  min-height: 56px; padding: 0 26px; border-radius: 999px; border: 0;
  background: rgba(143, 179, 255, .95); color: #0b1020; font: inherit; font-size: 18px; font-weight: 700;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .5); cursor: pointer; touch-action: manipulation;
}

/* ---------- controls ---------- */
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 10px; padding: 14px 16px 4px; }
.panel { margin: 10px 16px 0; padding: 4px 14px 14px; background: #0f1528; border: 1px solid var(--line); border-radius: 18px; }
.dpad {
  display: grid; grid-template-columns: repeat(3, 72px); grid-template-rows: repeat(3, 64px);
  gap: 8px; justify-content: center; padding: 4px 0 6px;
}
.arrow { font-size: 22px; min-height: 64px; padding: 0; }
.arrow.up { grid-column: 2; grid-row: 1; }
.arrow.left { grid-column: 1; grid-row: 2; }
.arrow.right { grid-column: 3; grid-row: 2; }
.arrow.down { grid-column: 2; grid-row: 3; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.seg.one { grid-template-columns: 1fr; margin-top: 14px; }
.logout { text-align: center; margin-top: 12px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 24px);
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: #e8ecf8; color: #0b1020; font-weight: 600;
  padding: 12px 18px; border-radius: 12px; transition: opacity .15s, transform .15s;
  max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--bad); color: #fff; }

/* ---------- login ---------- */
body.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { width: 100%; max-width: 380px; padding: 28px 22px; }
.login-logo { display: block; margin: 0 auto 10px; border-radius: 18px; }
.login-card h1 { text-align: center; font-size: 24px; margin-bottom: 18px; }
.login-card form { display: flex; flex-direction: column; }
.login-card label { font-size: 14px; color: var(--muted); margin: 12px 0 6px; }
.login-card input {
  font: inherit; font-size: 18px; min-height: 54px; padding: 0 14px;
  background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 14px;
}
.login-card input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.login-card .btn { margin-top: 22px; }
.error {
  background: rgba(255, 107, 107, .12); border: 1px solid var(--bad); color: #ffd0d0;
  padding: 12px 14px; border-radius: 12px; margin: 0 0 6px;
}

/* Hide go2rtc player debug overlay (mode label, status text). */
.player video-stream .info { display: none !important; }

/* Background listening: full-width main action. */
.btn.listen { grid-column: 1 / -1; min-height: 56px; font-size: 17px; }
.btn.listen[aria-pressed="true"] { background: var(--good); }
.pill.listening { color: var(--good); }
