:root {
  --bg: #1d2733;
  --surface: #283544;
  --surface-2: #33435a;
  --text: #eef1f4;
  --muted: #9aa8b6;
  --tag: #f2b24c;
  --live: #e5484d;
  --ok: #4cc38a;
  --radius-lg: 28px;
  --radius-sm: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 17px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }

.wrap {
  max-width: 760px;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 18px max(24px, env(safe-area-inset-bottom));
}
h1 {
  font-size: 30px;
  line-height: 1.15;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 8px 0 4px;
}
p.lede { color: var(--muted); margin: 0 0 22px; }

/* The video "window" is the one bold element */
.frame {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #121a23;
  aspect-ratio: 4 / 3;
  box-shadow: 0 0 0 6px var(--surface), 0 24px 48px -24px rgba(0, 0, 0, 0.6);
}
.frame video { width: 100%; height: 100%; object-fit: cover; display: block; background: #121a23; }
.frame .empty {
  position: absolute; top: 0; right: 0; bottom: 0; left: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 24px; color: var(--muted);
}
.frame .empty strong { color: var(--text); font-size: 20px; margin-bottom: 4px; }

.pill {
  position: absolute; top: 14px; left: 14px;
  display: inline-flex; align-items: center;
  padding: 6px 12px; border-radius: 999px;
  background: rgba(18, 26, 35, 0.72);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  font-size: 14px; font-weight: 700;
}
.pill .dot { margin-right: 8px; width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.pill.live .dot { background: var(--live); animation: pulse 1.6s ease-in-out infinite; }
.pill.ok .dot { background: var(--ok); }
@keyframes pulse { 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .pill.live .dot { animation: none; } }

.controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-top: 22px;
}
.controls button {
  display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-start;
  text-align: left; padding: 12px 14px; height: auto;
}
.controls .ctl-label { display: block; font-size: 16px; }
.controls .ctl-sub { display: block; margin-top: 3px; font-size: 13px; font-weight: 400; line-height: 1.3; color: var(--muted); }
.controls button[aria-pressed="true"] .ctl-sub { color: #c8d1da; }
button, .button {
  appearance: none; -webkit-appearance: none;
  font: inherit; font-weight: 700;
  color: var(--text);
  background: var(--surface);
  border: 0;
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  min-height: 52px;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}
button:active { background: var(--surface-2); }
button.primary { background: var(--tag); color: #2a1d06; }
button[aria-pressed="true"] { background: var(--surface-2); box-shadow: inset 0 0 0 2px var(--tag); }
button:focus-visible, .button:focus-visible, input:focus-visible { outline: 3px solid var(--tag); outline-offset: 2px; }
button:disabled { opacity: 0.45; }

.meta { margin-top: 18px; color: var(--muted); font-size: 15px; }
.meta a { color: var(--text); }

/* Password gate */
.gate {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 20;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.gate form { width: 100%; max-width: 360px; }
.gate label { display: block; font-weight: 700; margin: 18px 0 8px; }
.gate input {
  width: 100%; font: inherit; font-size: 18px;
  padding: 14px 16px; border-radius: var(--radius-sm);
  border: 2px solid var(--surface-2); background: var(--surface); color: var(--text);
}
.gate button { width: 100%; margin-top: 14px; }
.gate .error { color: #ff9b9e; min-height: 1.4em; margin: 10px 0 0; font-size: 15px; }

/* Home page choices */
.choices { display: grid; gap: 14px; margin-top: 8px; }
.choice {
  display: block; padding: 22px; border-radius: var(--radius-lg);
  background: var(--surface); color: var(--text); text-decoration: none;
}
.choice strong { display: block; font-size: 21px; margin-bottom: 4px; }
.choice span { color: var(--muted); }
.choice.main { box-shadow: inset 0 0 0 2px var(--tag); }

/* Camera page: black-out cover to save the screen */
.blackout {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 10; background: #000;
  display: flex; align-items: flex-end; justify-content: center;
  padding-bottom: 40px; color: #3a3a3a; font-size: 15px;
}

/* Older iPads without aspect-ratio support */
@supports not (aspect-ratio: 1 / 1) {
  .frame { height: 0; padding-top: 75%; }
  .frame video { position: absolute; top: 0; left: 0; }
}

/* Alerts */
.panel {
  margin-top: 28px;
  padding: 22px;
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.panel h2 { font-size: 21px; font-weight: 800; margin: 0 0 4px; }
.panel-note { color: var(--muted); font-size: 15px; margin: 0 0 16px; }
.panel button.wide, button.wide { width: 100%; }
.panel button:not(.primary) { background: var(--surface-2); }
.panel button[aria-pressed="true"] { background: var(--bg); }

fieldset { border: 0; margin: 20px 0 0; padding: 0; min-width: 0; }
legend { font-weight: 700; margin-bottom: 10px; padding: 0; }
.checks label {
  display: flex; align-items: center;
  min-height: 48px; padding: 0 4px;
  border-top: 1px solid var(--surface-2);
  cursor: pointer;
}
.checks label:last-child { border-bottom: 1px solid var(--surface-2); }
.checks input { width: 22px; height: 22px; margin: 0 14px 0 0; accent-color: var(--tag); }

.segments { display: flex; margin-bottom: 10px; }
.segments button { flex: 1; min-height: 46px; border-radius: 0; margin-right: 2px; }
.segments button:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.segments button:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; margin-right: 0; }

#test-alert { margin-top: 16px; }

.banner {
  position: fixed; left: 16px; right: 16px; z-index: 15;
  top: max(16px, env(safe-area-inset-top));
  max-width: 560px; margin: 0 auto;
  padding: 14px 18px; border-radius: var(--radius-sm);
  background: var(--tag); color: #2a1d06; font-weight: 700;
  box-shadow: 0 12px 30px -10px rgba(0, 0, 0, 0.6);
}

/* Problems on the camera page must be impossible to miss */
.problem {
  margin-top: 16px;
  padding: 16px 18px;
  border-radius: var(--radius-sm);
  background: #4a2427;
  box-shadow: inset 0 0 0 2px var(--live);
  color: #ffe3e4;
  font-weight: 700;
}

/* Camera name on the iPad */
.name-field { margin: 0 0 22px; }
.name-field label { display: block; font-weight: 700; margin-bottom: 8px; }
.name-field input {
  width: 100%; font: inherit; font-size: 18px;
  padding: 14px 16px; border-radius: var(--radius-sm);
  border: 2px solid var(--surface-2); background: var(--surface); color: var(--text);
}
.field-note { color: var(--muted); font-size: 15px; margin: 8px 0 0; }

/* Camera grid */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  grid-gap: 14px;
}
.grid.single { grid-template-columns: 1fr; }
.tile {
  display: block; width: 100%; padding: 0; text-align: left;
  background: transparent; border-radius: var(--radius-lg); min-height: 0;
}
.tile:active { background: transparent; }
.tile-frame {
  position: relative; display: block; overflow: hidden;
  border-radius: 22px; background: #121a23;
  padding-top: 75%;
  box-shadow: 0 0 0 4px var(--surface);
}
.grid.single .tile-frame { border-radius: var(--radius-lg); box-shadow: 0 0 0 6px var(--surface), 0 24px 48px -24px rgba(0, 0, 0, 0.6); }
.tile video { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; }
.tile-empty {
  position: absolute; top: 0; right: 0; bottom: 0; left: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-weight: 700; font-size: 15px;
}
.tile .pill { top: 10px; left: 10px; font-size: 13px; padding: 5px 10px; }
.tile.offline .tile-frame { opacity: 0.7; }
.tile-text { display: flex; align-items: center; padding: 10px 6px 0; }
.tile-info { display: block; flex: 1; min-width: 0; }
.tile-open {
  flex: none; display: inline-flex; align-items: center; margin-left: 12px;
  padding: 8px 14px; border-radius: 999px; background: var(--tag); color: #2a1d06;
  font-weight: 800; font-size: 15px;
}
.tile-open .chev {
  width: 8px; height: 8px; margin-left: 8px; border: solid currentColor;
  border-width: 2.5px 2.5px 0 0; transform: rotate(45deg);
}
.tile { cursor: pointer; }
.tile:hover .tile-frame, .tile:focus-visible .tile-frame { box-shadow: 0 0 0 4px var(--tag); }
.grid.single .tile:hover .tile-frame, .grid.single .tile:focus-visible .tile-frame { box-shadow: 0 0 0 6px var(--tag), 0 24px 48px -24px rgba(0, 0, 0, 0.6); }
.tile:focus-visible { outline: none; }
.grid:not(.single) .tile-text { align-items: flex-start; }
.grid:not(.single) .tile-open { width: 34px; height: 34px; padding: 0; justify-content: center; margin-left: 8px; }
.grid:not(.single) .open-word { display: none; }
.grid:not(.single) .tile-open .chev { margin-left: -3px; }
.tile-text strong { display: block; font-size: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-meta { display: block; color: var(--muted); font-size: 14px; font-weight: 400; }
/* First-run guidance: numbered steps with a bold line and a short explanation */
.onboard, .checklist {
  padding: 24px 22px; border-radius: var(--radius-lg); background: var(--surface);
  box-shadow: inset 0 0 0 2px var(--tag);
}
.checklist { margin-top: 22px; }
.onboard h2, .checklist h2 { margin: 0 0 8px; font-size: 22px; }
.onboard > p, .checklist > p { margin: 0 0 16px; color: #c8d1da; }
.onboard-steps { list-style: none; counter-reset: step; margin: 0 0 18px; padding: 0; }
.onboard-steps li { counter-increment: step; position: relative; padding: 0 0 14px 44px; min-height: 32px; }
.onboard-steps li::before {
  content: counter(step); position: absolute; left: 0; top: 0;
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 50%; background: var(--tag); color: #2a1d06; font-weight: 800; font-size: 15px;
}
.onboard-steps strong { display: block; color: var(--text); }
.onboard-steps span { display: block; color: var(--muted); font-size: 15px; }
.homescreen { margin: 4px 0 18px; padding: 16px; border-radius: var(--radius-sm); background: var(--surface-2); }
.homescreen > strong { display: block; margin-bottom: 14px; }
.homescreen .onboard-steps { margin-bottom: 0; }
.homescreen .onboard-steps li:last-child { padding-bottom: 0; }
.share-icon { width: 20px; height: 20px; vertical-align: -3px; margin-left: 4px; color: #6fb2ff; }
.welcome-list { margin: 0 0 20px; padding-left: 20px; color: #c8d1da; }
.welcome-list li { margin-bottom: 8px; }
.welcome-list strong { color: var(--text); }
.grid-empty {
  padding: 28px 22px; border-radius: var(--radius-lg);
  background: var(--surface); text-align: center; color: var(--muted);
}
.grid-empty strong { display: block; color: var(--text); font-size: 20px; margin-bottom: 4px; }

/* Single camera view */
.back {
  min-height: 44px; padding: 10px 16px 10px 12px; margin-top: 4px;
  background: var(--surface); font-size: 16px;
}
.back::before { content: "\2039"; font-size: 24px; line-height: 0; margin-right: 8px; position: relative; top: 2px; }

.panel-head { display: flex; align-items: baseline; justify-content: space-between; }
.text-button, .panel button.text-button {
  background: transparent; color: var(--tag); padding: 8px 0 8px 12px;
  min-height: 44px; font-size: 16px;
}
.text-button:active, .panel button.text-button:active { background: transparent; opacity: 0.7; }

button.danger { background: transparent; box-shadow: inset 0 0 0 2px #7a3b3f; color: #ff9b9e; margin-top: 20px; }
.panel button.danger { background: transparent; }
.panel .rename-row button { background: var(--surface-2); }

.rename { margin-top: 22px; }
.rename label { display: block; font-weight: 700; margin-bottom: 8px; }
.rename-row { display: flex; }
.rename-row input {
  flex: 1; min-width: 0; font: inherit; font-size: 17px;
  padding: 12px 14px; border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  border: 2px solid var(--surface-2); border-right: 0; background: var(--bg); color: var(--text);
}
.rename-row button { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; white-space: nowrap; }

/* Alert lists */
.alert-list { list-style: none; margin: 0; padding: 0; }
.alert-list li {
  display: flex; align-items: center; flex-wrap: wrap;
  padding: 10px 0; border-top: 1px solid var(--surface-2);
}
.alert-list li:first-child { border-top: 0; }
.alert-list li.focused { box-shadow: inset 3px 0 0 var(--tag); padding-left: 12px; }
.alert-open {
  flex: 1; min-width: 0; display: flex; align-items: center;
  padding: 0; background: transparent; text-align: left; min-height: 0; font-weight: 400;
}
.panel button.alert-open, .panel button.alert-open:active { background: transparent; }
.alert-open img, .no-photo {
  width: 112px; height: 84px; object-fit: cover; border-radius: 10px;
  margin-right: 14px; background: #121a23; flex-shrink: 0;
}
.no-photo { display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 14px; }
.alert-text strong { display: block; font-weight: 700; }
.alert-text span { color: var(--muted); font-size: 15px; }
.panel button.alert-delete {
  background: transparent; color: var(--muted); font-size: 15px;
  min-height: 44px; padding: 8px 4px 8px 12px;
}
.panel button.alert-delete:active { color: #ff9b9e; }

/* Tapping an alert in the camera view shows its photo full width */
.alert-list li.expanded .alert-open { flex-wrap: wrap; }
.alert-list li.expanded .alert-open img { width: 100%; height: auto; margin: 0 0 10px; }

/* Switching a device between watching and being a camera */
.switch-mode {
  display: block; margin-top: 28px; padding: 18px 22px;
  border-radius: var(--radius-lg); background: transparent;
  box-shadow: inset 0 0 0 2px var(--surface-2);
  color: var(--text); text-decoration: none;
}
.switch-mode strong { display: block; font-size: 18px; margin-bottom: 2px; }
.switch-mode span { color: var(--muted); font-size: 15px; }
.switch-mode:active { background: var(--surface); }
.switch-mode:focus-visible { outline: 3px solid var(--tag); outline-offset: 2px; }
fieldset:disabled label { opacity: 0.45; cursor: default; }

/* Photo mode: still pictures sent through the server when live video is blocked */
.frame img.photo, .tile img.photo {
  position: absolute; top: 0; left: 0;
  width: 100%; height: 100%; object-fit: cover; display: block;
  background: #121a23;
}

/* Upside-down cameras: turn the picture (not the labels) the right way up */
.flipped video, .flipped img.photo, .alert-list img.flipped { transform: rotate(180deg); }

/* Full screen view inside the page, used when the picture is turned or in photo mode */
.frame.full {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 30;
  width: 100%; height: 100%; aspect-ratio: auto;
  border-radius: 0; box-shadow: none; padding-top: 0;
  background: #000;
}
.frame.full video, .frame.full img.photo { object-fit: contain; background: #000; }
.frame.full .pill { top: max(14px, env(safe-area-inset-top)); }
.exit-full {
  position: absolute; z-index: 2;
  top: max(10px, env(safe-area-inset-top)); right: 12px;
  min-height: 44px; padding: 10px 16px;
  background: rgba(18, 26, 35, 0.78); color: var(--text);
}
body.no-scroll { overflow: hidden; }

/* ---------- Accounts and plans ---------- */
.spaced { margin-top: 14px; }
label.spaced { display: block; margin-top: 18px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 760px; margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 18px 0;
}
.brand { color: var(--text); font-weight: 800; font-size: 18px; text-decoration: none; }
.topbar-link { color: var(--text); font-weight: 700; text-decoration: none; padding: 10px 0 10px 14px; min-height: 44px; display: inline-flex; align-items: center; }
.topbar-link:focus-visible, .brand:focus-visible { outline: 3px solid var(--tag); outline-offset: 2px; border-radius: 6px; }

.plan-banner {
  margin: 8px 0 4px; padding: 12px 16px; border-radius: var(--radius-sm);
  background: var(--surface); box-shadow: inset 3px 0 0 var(--tag);
  font-size: 15px; cursor: pointer;
}
.paywall {
  margin: 8px 0 24px; padding: 24px; border-radius: var(--radius-lg);
  background: var(--surface); box-shadow: inset 0 0 0 2px var(--tag);
}
.paywall h2 { margin: 0 0 8px; font-size: 22px; }
.paywall p { margin: 0 0 16px; }
.plan-expired #grid, .plan-expired #grid-empty, .plan-expired #add-camera, .plan-expired #grid-view .panel { display: none !important; }

.add-camera { margin-top: 18px; }

/* Dialogs */
.modal {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 40;
  background: rgba(10, 14, 20, 0.72);
  display: flex; align-items: center; justify-content: center; padding: 16px;
  overflow-y: auto;
}
.modal-card {
  width: 100%; max-width: 440px; padding: 24px; border-radius: var(--radius-lg);
  background: var(--surface); box-shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.7);
}
.modal-card h2 { margin: 0 0 12px; font-size: 22px; }
.modal-card p { margin: 0 0 16px; }
.steps { margin: 0 0 16px; padding-left: 20px; color: var(--muted); font-size: 15px; }
.steps li { margin-bottom: 8px; }
.steps strong { color: var(--text); word-break: break-all; }
.qr { display: block; width: 220px; height: 220px; margin: 8px auto 12px; border-radius: 12px; background: #fff; padding: 8px; }
.pair-code {
  text-align: center; font-size: 30px; font-weight: 800; letter-spacing: 0.12em;
  font-variant-numeric: tabular-nums; margin: 0 0 6px;
}

/* Talk to your pet */
.talk {
  display: block; width: 100%; margin-top: 18px; min-height: 64px;
  font-size: 19px; border-radius: 999px;
  background: var(--surface-2);
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: none;
}
.talk.active { background: var(--tag); color: #2a1d06; box-shadow: 0 0 0 6px rgba(242, 178, 76, 0.25); }
.talk-hint { margin: 8px 4px 0; }
.away-usage { color: var(--muted); font-size: 15px; margin: -12px 0 18px; }

/* ---------- Forms on account pages ---------- */
.auth { max-width: 420px; margin: 0 auto; padding: max(28px, env(safe-area-inset-top)) 18px 40px; }
.auth h1 { margin-top: 18px; }
.field { margin-top: 16px; }
.field label { display: block; font-weight: 700; margin-bottom: 8px; }
.field input {
  width: 100%; font: inherit; font-size: 18px;
  padding: 14px 16px; border-radius: var(--radius-sm);
  border: 2px solid var(--surface-2); background: var(--surface); color: var(--text);
}
.field input:focus-visible { outline: 3px solid var(--tag); outline-offset: 2px; }
.field .hint { color: var(--muted); font-size: 14px; margin: 6px 0 0; }
.form-error { color: #ff9b9e; min-height: 1.4em; margin: 12px 0 0; font-size: 15px; }
.form-ok { color: var(--ok); margin: 12px 0 0; font-size: 15px; }
.auth .links { margin-top: 22px; color: var(--muted); font-size: 15px; }
.auth .links a, .meta a, .legal a, .panel a { color: var(--text); }
.auth button[type=submit] { width: 100%; margin-top: 20px; }

/* Account page */
.usage-bar { height: 10px; border-radius: 999px; background: var(--bg); overflow: hidden; margin: 6px 0 10px; }
.usage-bar span { display: block; height: 100%; background: var(--tag); border-radius: 999px; }
.kv { display: flex; justify-content: space-between; padding: 10px 0; border-top: 1px solid var(--surface-2); font-size: 15px; }
.kv:first-of-type { border-top: 0; }
.kv span:first-child { color: var(--muted); }
.button-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); grid-gap: 10px; margin-top: 16px; }
a.button { display: flex; align-items: center; justify-content: center; }

/* Admin */
.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-table th, .admin-table td { text-align: left; padding: 10px 6px; border-top: 1px solid var(--surface-2); vertical-align: top; }
.admin-table th { color: var(--muted); font-weight: 700; }
.admin-table button { min-height: 36px; padding: 6px 10px; font-size: 13px; }
.table-wrap { overflow-x: auto; }
.copy-box { word-break: break-all; background: var(--bg); padding: 10px 12px; border-radius: 10px; font-size: 14px; margin: 10px 0 0; }

/* Legal pages */
.legal { max-width: 720px; margin: 0 auto; padding: 24px 18px 48px; }
.legal h2 { font-size: 20px; margin-top: 28px; }
.legal p, .legal li { color: #d4dbe2; line-height: 1.6; }
.draft-note { background: var(--surface); padding: 12px 16px; border-radius: var(--radius-sm); box-shadow: inset 3px 0 0 var(--tag); }

/* A camera paused on the Free plan */
.tile.paused .tile-frame { opacity: 0.55; }
.tile.paused .tile-open { background: var(--surface-2); color: var(--text); }

/* Account page: Free and Plus side by side */
.plan-compare { display: grid; grid-template-columns: 1fr 1fr; grid-gap: 12px; margin: 16px 0 18px; }
.plan-col { padding: 16px; border-radius: var(--radius-sm); background: var(--surface-2); }
.plan-col.plan-plus { box-shadow: inset 0 0 0 2px var(--tag); }
.plan-col > strong { display: block; font-size: 18px; }
.plan-price { display: block; margin: 2px 0 10px; color: var(--muted); font-size: 14px; }
.plan-col ul { margin: 0; padding-left: 18px; color: #c8d1da; font-size: 14px; }
.plan-col li { margin-bottom: 6px; }
@media (max-width: 420px) { .plan-compare { grid-template-columns: 1fr; } }

/* USD / NZD switch */
.currency-row { display: flex; align-items: center; gap: 8px; margin: 0 0 14px; color: var(--muted); font-size: 15px; }
.currency-row button { min-height: 36px; padding: 6px 14px; border-radius: 999px; background: var(--surface-2); color: var(--text); font-weight: 700; }
.currency-row button[aria-pressed="true"] { background: var(--tag); color: #2a1d06; }
