:root {
  --bg: #f6f7f6;
  --fg: #16201d;
  --muted: #5b6763;
  --card: #ffffff;
  --accent: #1e6f5c;
  --accent-fg: #ffffff;
  --danger: #c62828;
  --border: #d9dedc;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101513;
    --fg: #e7ecea;
    --muted: #9aa6a1;
    --card: #19201d;
    --accent: #3fa58a;
    --accent-fg: #06110d;
    --border: #2b3531;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--fg);
  font: 17px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
[hidden] { display: none !important; }
.panel {
  max-width: 440px;
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 16px 24px;
}
header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
h1 { font-size: 1.5rem; margin: 0 0 16px; }
header h1 { margin: 0; }
form { display: grid; gap: 12px; }
input {
  font: inherit; padding: 12px 14px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--card); color: var(--fg);
}
button {
  font: inherit; border: 1px solid var(--border); background: var(--card); color: var(--fg);
  border-radius: 12px; padding: 12px 16px; cursor: pointer;
}
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-fg); border-color: transparent; }
button.danger { background: var(--danger); color: #fff; border-color: transparent; }
button.big { width: 100%; font-size: 1.2rem; padding: 20px; }
button.link { background: none; border: none; color: var(--muted); padding: 8px 0; text-decoration: underline; }
.actions { display: grid; gap: 12px; margin: 24px 0 12px; }
.muted { color: var(--muted); }
.small { font-size: .9rem; }
.error { color: var(--danger); min-height: 1.4em; margin: 0; }
.pill { font-size: .85rem; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.pill.online { background: #d7f2e8; color: #0c513f; }
.pill.offline { background: #eceeed; color: #5b6763; }
@media (prefers-color-scheme: dark) {
  .pill.online { background: #12392e; color: #9fe3cb; }
  .pill.offline { background: #252d2a; color: #9aa6a1; }
}

#session { position: fixed; inset: 0; background: #000; }
#remote { width: 100%; height: 100%; object-fit: contain; background: #000; }
#local {
  position: absolute; right: 12px; top: max(12px, env(safe-area-inset-top));
  width: 28vw; max-width: 160px; aspect-ratio: 3 / 4; object-fit: cover;
  border-radius: 10px; border: 2px solid rgba(255,255,255,.6); transform: scaleX(-1);
}
#local.rear { transform: none; }
.overlay-status {
  position: absolute; left: 0; right: 0; top: 40%; text-align: center; color: #fff;
  font-size: 1.1rem; text-shadow: 0 1px 3px #000; padding: 0 16px;
}
.session-controls {
  position: absolute; left: 0; right: 0; bottom: max(20px, env(safe-area-inset-bottom));
  display: flex; justify-content: center; gap: 12px; padding: 0 16px;
}
.session-controls button { min-width: 96px; padding: 14px 16px; }
