/* Paul's Baby Monitor: a dark, low-glare screen for a night nursery. */
@font-face { font-family: "Pilcrow Rounded"; src: url(/fonts/pilcrow-rounded-500.woff2) format("woff2"); font-weight: 400 500; font-display: swap; }
@font-face { font-family: "Pilcrow Rounded"; src: url(/fonts/pilcrow-rounded-700.woff2) format("woff2"); font-weight: 600 800; font-display: swap; }

:root {
  --bg: #14110f;
  --surface: #221c17;
  --line: #3a3029;
  --ink: #f3e6d6;
  --muted: #b9a792;
  --accent: #f59b2b;      /* Paul's tortoiseshell amber */
  --accent-ink: #2a160c;
  --ok: #8fd19a;
  --alert: #ff6f5e;
  --margin: clamp(16px, 3vw, 32px);
  color-scheme: dark;
  font-family: "Pilcrow Rounded", ui-rounded, system-ui, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); }
body { min-height: 100dvh; font-size: 17px; line-height: 1.45; -webkit-tap-highlight-color: transparent; }
b { font-weight: 700; }

.top { display: flex; align-items: center; justify-content: space-between; padding: 14px var(--margin); }
.mark { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 700; font-size: 19px; }
.mark img { border-radius: 50%; }
.role { color: var(--muted); font-weight: 600; }
.wrap { width: min(100%, 980px); margin: 0 auto; padding: 8px var(--margin) 48px; }

h1 { font-size: clamp(2rem, 1.4rem + 2.6vw, 3.2rem); line-height: 1.05; margin: 12px 0 14px; letter-spacing: -0.01em; }
h2 { font-size: 1.4rem; margin: 0 0 12px; }
.lead { font-size: 1.2rem; color: var(--ink); max-width: 36em; margin: 0 0 24px; }
.label { color: var(--muted); font-weight: 600; margin: 0 0 6px; }
.hint, .note { color: var(--muted); font-size: 15px; }
.error { color: var(--alert); font-weight: 600; }

.btn {
  appearance: none; border: 2px solid var(--line); background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 700; font-size: 17px; min-height: 52px; padding: 0 22px; border-radius: 999px;
  cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
}
.btn:focus-visible, .choice:focus-visible, .codein:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.btn.go { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.quiet { background: none; border-color: transparent; color: var(--muted); }
.btn[aria-pressed="true"] { border-color: var(--accent); }
.btn.chip { min-height: 44px; padding: 0 18px; font-size: 16px; }
.btn.chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
#talk[aria-pressed="true"] { background: var(--ok); border-color: var(--ok); color: var(--accent-ink); }
.row { display: flex; flex-wrap: wrap; gap: 10px; }

/* Home */
.pick { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 8px 0 40px; }
.choice {
  display: flex; flex-direction: column; gap: 10px; padding: 28px; min-height: 200px; border-radius: 24px;
  background: var(--surface); border: 2px solid var(--line); color: var(--muted); text-decoration: none;
}
.choice:hover { border-color: var(--accent); }
.choice .big { font-size: clamp(2rem, 1.5rem + 2vw, 3rem); font-weight: 800; color: var(--accent); line-height: 1; }
.how ol { padding-left: 1.3em; max-width: 40em; }
.how li { margin-bottom: 8px; }

/* Setup screens */
.setup { max-width: 640px; }
.setup .btn.go { min-width: 220px; }
.tips { list-style: none; padding: 0; margin: 32px 0 0; display: grid; gap: 12px; color: var(--muted); }
.tips b { color: var(--ink); }
.codein {
  display: block; width: 100%; max-width: 360px; margin: 0 0 16px; padding: 14px 18px; border-radius: 16px;
  border: 2px solid var(--line); background: var(--surface); color: var(--ink);
  font: inherit; font-size: 28px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
}

/* Live view */
.live { display: grid; gap: 18px; }
.view { position: relative; border-radius: 22px; overflow: hidden; background: #000; aspect-ratio: 16 / 9; max-height: 70dvh; }
.view video { width: 100%; height: 100%; object-fit: contain; display: block; }
#preview.mirror { transform: scaleX(-1); }
.pill {
  position: absolute; top: 12px; left: 12px; margin: 0; padding: 6px 14px; border-radius: 999px;
  background: rgb(20 17 15 / .8); color: var(--ink); font-weight: 700; font-size: 15px;
}
.pill::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--muted); margin-right: 8px; }
.pill.on::before { background: var(--ok); }
.tap { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); }
.audioonly { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; color: var(--muted); font-weight: 700; font-size: 22px; }

.pair { background: var(--surface); border-radius: 22px; padding: 22px; }
.code { font-size: clamp(2.4rem, 1.6rem + 3vw, 3.6rem); font-weight: 800; letter-spacing: 0.08em; color: var(--accent); margin: 0 0 6px; font-variant-numeric: tabular-nums; }

.meter { position: relative; height: 14px; border-radius: 999px; background: var(--surface); overflow: hidden; }
.meter span { position: absolute; inset: 0 auto 0 0; width: 0; background: linear-gradient(90deg, var(--ok), var(--accent) 70%, var(--alert)); transition: width .1s linear; }
.meter i { position: absolute; top: 0; bottom: 0; width: 3px; background: var(--ink); }
.meter.small { width: 160px; height: 8px; margin: 12px auto 0; background: #111; }

.alerts .row { margin-bottom: 8px; }
.log { list-style: none; padding: 0; margin: 0; color: var(--muted); font-size: 15px; }

.cover { position: fixed; inset: 0; background: #000; display: grid; place-content: center; text-align: center; z-index: 10; }
.cover p { color: #3b332c; margin: 0; font-weight: 600; }
.alarm {
  position: fixed; inset: 0; z-index: 20; display: grid; place-content: center; justify-items: center; gap: 20px;
  background: rgb(80 14 8 / .94); padding: var(--margin); text-align: center;
  animation: flash 1s ease-in-out infinite alternate;
}
.alarm p { font-size: clamp(1.6rem, 1.2rem + 2vw, 2.6rem); font-weight: 800; margin: 0; max-width: 18em; }
@keyframes flash { to { background: rgb(150 26 14 / .94); } }
@media (prefers-reduced-motion: reduce) { .alarm { animation: none; } }

@media (max-width: 640px) {
  .pick { grid-template-columns: 1fr; }
  .choice { min-height: 0; }
  .view { aspect-ratio: 4 / 3; }
  .controls .btn { flex: 1 1 calc(50% - 10px); }
}
