/* Night-friendly palette: low glare in a dark nursery, one warm "moonlight" accent for live. */
:root {
  --night: #131a2c;
  --dusk: #1d2542;
  --line: #2c3660;
  --ink: #e6e3f0;
  --mist: #9097b4;
  --moon: #f3cf7a;
  --rose: #e8838f;

  --radius-stage: 28px;
  --radius-btn: 16px;
  --font: ui-rounded, "SF Pro Rounded", "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;

  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--night);
  color: var(--ink);
  font: 17px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }

button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--moon); outline-offset: 3px; }

/* ---------- sign in ---------- */
.login {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}
.login-card {
  width: min(360px, 100%);
  display: grid;
  gap: 16px;
}
.login-card h1 { margin: 8px 0 0; font-size: 30px; font-weight: 700; letter-spacing: -0.01em; }
.login-card .hint { margin: -8px 0 8px; color: var(--mist); }
.login-card label { display: grid; gap: 6px; color: var(--mist); font-size: 15px; }
.login-card input {
  background: var(--dusk);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px 14px;
  color: var(--ink);
}
.moon {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--moon);
  box-shadow: inset -14px -6px 0 0 var(--night), 0 0 40px rgba(243, 207, 122, 0.25);
}
.form-error { margin: 0; min-height: 1.4em; color: var(--rose); }

/* ---------- viewer ---------- */
.viewer {
  max-width: 720px;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 16px max(20px, env(safe-area-inset-bottom));
  display: grid;
  gap: 16px;
}

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.camera-name { display: flex; align-items: center; gap: 10px; font-size: 20px; font-weight: 650; min-width: 0; }
.camera-name select {
  background: transparent; border: 0; font-weight: 650; font-size: 20px; padding: 0; max-width: 60vw;
}
.link-btn { background: none; border: 0; color: var(--mist); padding: 8px 4px; cursor: pointer; }

.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--line); flex: none; }
.dot.online { background: var(--mist); }
.dot.live { background: var(--moon); animation: breathe 3.2s ease-in-out infinite; }
@keyframes breathe {
  0%, 100% { box-shadow: 0 0 0 0 rgba(243, 207, 122, 0.55); }
  50%      { box-shadow: 0 0 0 7px rgba(243, 207, 122, 0); }
}

/* The video window is the page. */
.stage {
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-stage);
  overflow: hidden;
  background: radial-gradient(120% 90% at 70% 15%, #232c50 0%, var(--dusk) 55%, #161d35 100%);
  border: 1px solid var(--line);
}
.stage.live { border-color: rgba(243, 207, 122, 0.55); }
.stage img { width: 100%; height: 100%; object-fit: contain; display: block; background: #000; }
.placeholder {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  padding: 24px; text-align: center; color: var(--mist);
}
.placeholder p { margin: 0; max-width: 28ch; }

/* sound-only indicator: five soft bars, scaled by live audio level */
.listening {
  position: absolute; left: 50%; bottom: 22%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 6px; height: 44px;
}
.listening span {
  width: 7px; height: 100%; border-radius: 4px; background: var(--moon);
  transform: scaleY(0.12); transform-origin: center; transition: transform 90ms linear;
}

.facts {
  margin: 0;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
}
.facts div { min-width: 0; }
.facts dt { color: var(--mist); font-size: 14px; }
.facts dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }

.error {
  margin: 0; padding: 12px 14px; border-radius: 12px;
  background: rgba(232, 131, 143, 0.12); color: var(--rose);
}

.controls { display: grid; gap: 12px; }
.modes { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }

.btn {
  border: 1px solid var(--line);
  background: var(--dusk);
  border-radius: var(--radius-btn);
  padding: 16px 10px;
  min-height: 56px;
  font-weight: 650;
  cursor: pointer;
  touch-action: manipulation;
}
.btn:disabled { opacity: 0.4; cursor: default; }
.btn.mode[aria-pressed="true"] { background: var(--moon); border-color: var(--moon); color: var(--night); }
.btn-primary { background: var(--moon); border-color: var(--moon); color: var(--night); }
.btn-stop {
  background: transparent; border: 2px solid var(--rose); color: var(--rose);
  font-size: 19px; min-height: 60px;
}

.volume { display: flex; align-items: center; gap: 12px; color: var(--mist); font-size: 15px; }
.volume input { flex: 1; accent-color: var(--moon); }

.conn { margin: 0; color: var(--mist); font-size: 14px; text-align: center; }

@media (max-width: 380px) {
  .modes { grid-template-columns: 1fr 1fr; }
  .modes .btn:last-child { grid-column: span 2; }
}

@media (prefers-reduced-motion: reduce) {
  .dot.live { animation: none; box-shadow: 0 0 0 3px rgba(243, 207, 122, 0.35); }
  .listening span { transition: none; }
}
