:root {
  --ground: #F6F3EC; --surface: #FFFFFF; --ink: #1B2430; --muted: #55606E; --line: #E3DED2;
  --brand: #1F6F63; --brand-ink: #164F47; --brand-soft: #DDEBE8; --glow: #F2C46D; --glow-soft: #FBF0D9;
  --warn: #9A3412; --warn-soft: #FBE3D6; --strong: #1B2430; --on-strong: #FFFFFF;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ground: #11181F; --surface: #18222B; --ink: #EEF1F3; --muted: #A7B1BC; --line: #2A3540;
    --brand: #5CB8A8; --brand-ink: #8ED2C5; --brand-soft: #1C3532; --glow: #F2C46D; --glow-soft: #2B2618;
    --warn: #F3A37E; --warn-soft: #3A2219; --strong: #EEF1F3; --on-strong: #11181F;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--ground); color: var(--ink);
  font-family: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 17px; line-height: 1.5; -webkit-font-smoothing: antialiased;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}
a { color: var(--brand-ink); }
h1 { font-size: 26px; line-height: 1.2; margin: 4px 0 12px; }
h2 { font-size: 19px; margin: 0 0 8px; }
.section { font-size: 15px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 24px 4px 8px; }
ul, ol { padding-left: 22px; margin: 8px 0; }
li { margin: 6px 0; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

header.top {
  position: sticky; top: 0; z-index: 5; padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--ground) 90%, transparent); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-weight: 800; font-size: 20px; }
.brand img { border-radius: 50%; }
main { max-width: 640px; margin: 0 auto; padding: 16px; }

nav.bottom {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; gap: 8px;
  padding: 8px 16px calc(8px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line);
}
nav.bottom a { flex: 1; max-width: 200px; text-align: center; padding: 10px; border-radius: 12px; text-decoration: none; color: var(--muted); font-weight: 700; }
nav.bottom a.active { background: var(--brand-soft); color: var(--brand-ink); }

.card { display: block; background: var(--surface); border-radius: 18px; padding: 18px 20px; margin: 12px 0; border: 1px solid var(--line); color: inherit; text-decoration: none; }
.card.glow { background: var(--glow-soft); }
.card.warn { background: var(--warn-soft); border-color: transparent; }
.card.brand-soft { background: var(--brand-soft); border-color: transparent; }
.card.strong { background: var(--strong); color: var(--on-strong); border-color: transparent; }
.card.strong a { color: var(--on-strong); }
.hero { padding: 24px 4px; }

.btn {
  display: block; width: 100%; min-height: 54px; margin: 12px 0 4px; padding: 14px 18px; border: 0; border-radius: 16px;
  background: var(--brand); color: #fff; font: inherit; font-weight: 800; text-align: center; text-decoration: none; cursor: pointer;
}
.btn.secondary { background: var(--ink); color: var(--ground); }
.btn:disabled { opacity: .6; }
.link-btn { display: inline-block; background: none; border: 0; padding: 12px 4px; font: inherit; font-weight: 700; color: var(--brand-ink); text-decoration: none; cursor: pointer; }
.link-btn.danger { color: var(--warn); }

input {
  width: 100%; min-height: 50px; margin: 6px 0; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--ground); color: var(--ink); font: inherit;
}
#code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: .05em; text-transform: uppercase; }
label { display: block; margin-top: 16px; font-weight: 700; font-size: 15px; }
.code-form { margin-top: 8px; }
.error { color: var(--warn); font-weight: 700; }
.warn-text { color: var(--warn); }

.badge { display: inline-block; padding: 4px 12px; border-radius: 999px; font-size: 14px; font-weight: 800; white-space: nowrap; }
.lvl-high { background: var(--warn-soft); color: var(--warn); }
.lvl-medium { background: var(--glow-soft); color: var(--ink); }
.lvl-low { background: var(--brand-soft); color: var(--brand-ink); }
.alert-row { display: flex; align-items: center; gap: 14px; }
.alert-row.unseen { border-color: var(--brand); border-width: 2px; }
.alert-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chev { font-size: 26px; color: var(--muted); }
.alert-title { margin-top: 12px; }
.back { display: inline-block; padding: 8px 0; font-weight: 700; text-decoration: none; }

.child-name { font-weight: 800; font-size: 19px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 8px; vertical-align: 1px; }
.dot.ok { background: var(--brand); }
.dot.bad { background: var(--warn); }
.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.row:first-of-type { border-top: 0; }
.row-actions { display: flex; gap: 6px; flex-shrink: 0; }

.sas { font-size: 44px; font-weight: 800; letter-spacing: .12em; text-align: center; margin: 12px 0; font-variant-numeric: tabular-nums; }
#scan-box video { width: 100%; border-radius: 14px; background: #000; aspect-ratio: 1; object-fit: cover; }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin 1s linear infinite; vertical-align: -2px; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

#toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(84px + env(safe-area-inset-bottom)); max-width: 560px; margin: 0 auto;
  background: var(--ink); color: var(--ground); padding: 14px 18px; border-radius: 14px; font-weight: 700; z-index: 10;
}
.msg { background: var(--ground); border-radius: 14px; padding: 10px 14px; margin: 10px 0; }
.msg-child { background: var(--brand-soft); }
.msg-who { font-size: 14px; font-weight: 800; color: var(--muted); }
.msg-text { white-space: pre-wrap; overflow-wrap: anywhere; }
