:root {
  --bg: #F2F5F0;
  --ink: #0E2A1F;
  --muted: #4E6358;
  --green: #006747;
  --gold: #CFC493;
  --line: #CBD6CD;
  --panel: #FFFFFF;
  --danger: #B3261E;
  --display: "Bowlby One", "Arial Black", Impact, sans-serif;
  --body: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0A2018; --ink: #EEF3EC; --muted: #9DB3A6; --green: #2FA36F;
    --gold: #D9CF9E; --line: #1F3D31; --panel: #10291F; --danger: #FF8A80;
  }
}
:root[data-theme="dark"] {
  --bg: #0A2018; --ink: #EEF3EC; --muted: #9DB3A6; --green: #2FA36F;
  --gold: #D9CF9E; --line: #1F3D31; --panel: #10291F; --danger: #FF8A80;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 18px/1.5 var(--body);
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}
.wrap { max-width: 560px; margin: 0 auto; padding: 24px 16px 64px; }

.masthead { padding: 8px 0 20px; border-bottom: 6px solid var(--gold); margin-bottom: 20px; }
.masthead h1 {
  font: 400 clamp(40px, 12vw, 64px)/0.92 var(--display);
  margin: 0; color: var(--green); letter-spacing: -0.5px;
}
.masthead p { margin: 10px 0 0; color: var(--muted); }

/* Sign-up panel */
.setup { background: var(--panel); border: 2px solid var(--line); border-radius: 14px; padding: 18px; margin-bottom: 24px; }
.setup h2 { font: 700 21px/1.25 var(--body); margin: 0 0 6px; }
.setup p { margin: 0 0 12px; color: var(--muted); }
.setup p:last-child { margin-bottom: 0; }
.steps { margin: 4px 0 0; padding-left: 22px; }
.steps li { margin: 6px 0; }
.share-glyph { display: inline-block; width: 18px; height: 18px; vertical-align: -3px; }

button, .btn {
  font: 700 18px/1 var(--body); border: 0; border-radius: 999px; cursor: pointer;
  padding: 16px 22px; min-height: 52px; background: var(--green); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none;
}
button.big { width: 100%; font-size: 20px; min-height: 60px; }
button.quiet { background: transparent; color: var(--green); border: 2px solid var(--line); }
button:disabled { opacity: 0.55; cursor: default; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.row-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.row-actions button { flex: 1 1 140px; }
.msg { margin-top: 10px; font-weight: 700; min-height: 1.5em; }
.msg.err { color: var(--danger); }

/* Bell list */
.bells { list-style: none; margin: 0; padding: 0; border-top: 2px solid var(--line); }
.bell {
  display: grid; grid-template-columns: 52px 1fr auto; align-items: center; gap: 12px;
  padding: 14px 10px; border-bottom: 2px solid var(--line); border-radius: 0;
  transition: background-color 0.4s ease;
}
.bell .emoji { font-size: 36px; line-height: 1; text-align: center; }
.bell .name { font-weight: 700; font-size: 19px; line-height: 1.2; }
.bell .when { color: var(--muted); font-size: 16px; margin-top: 2px; }
.bell.lit { background: color-mix(in srgb, var(--c) 22%, transparent); }
.bell.lit .when { color: var(--ink); font-weight: 700; }

/* Switch */
.switch { position: relative; width: 58px; height: 34px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span {
  position: absolute; inset: 0; border-radius: 999px; background: var(--line); transition: background 0.2s;
}
.switch span::after {
  content: ""; position: absolute; top: 4px; left: 4px; width: 26px; height: 26px; border-radius: 50%;
  background: #fff; transition: transform 0.2s; box-shadow: 0 1px 2px rgba(0,0,0,0.25);
}
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { transform: translateX(24px); }
.switch input:focus-visible + span { outline: 3px solid var(--gold); outline-offset: 3px; }
.switch-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.footnote { color: var(--muted); font-size: 15px; margin-top: 20px; }

/* The one loud moment: a bell rings while the page is open */
.flash {
  position: fixed; inset: 0; z-index: 50; display: none;
  flex-direction: column; align-items: center; justify-content: center; text-align: center;
  padding: 24px; background: var(--c, var(--green)); color: #fff; cursor: pointer;
}
.flash.on { display: flex; animation: flashIn 0.5s ease-out both; }
.flash .emoji { font-size: 120px; line-height: 1; animation: swing 0.6s ease-in-out 3; transform-origin: 50% 10%; }
.flash .title { font: 400 clamp(34px, 10vw, 56px)/1 var(--display); margin: 22px 0 10px; text-shadow: 0 2px 0 rgba(0,0,0,0.2); }
.flash .body { font-size: 24px; font-weight: 700; }
.flash .hint { margin-top: 30px; opacity: 0.85; font-size: 16px; }
@keyframes flashIn { from { opacity: 0; transform: scale(1.04); } to { opacity: 1; transform: none; } }
@keyframes swing { 0%,100% { transform: rotate(0); } 25% { transform: rotate(14deg); } 75% { transform: rotate(-14deg); } }

/* Host page */
.ringer { text-align: center; padding: 12px 0 8px; }
.ring-btn {
  width: min(78vw, 300px); height: min(78vw, 300px); border-radius: 50%;
  background: var(--c, var(--green)); color: #fff; flex-direction: column; gap: 6px;
  border: 8px solid color-mix(in srgb, var(--c, var(--green)) 55%, #fff);
  box-shadow: 0 10px 0 color-mix(in srgb, var(--c, var(--green)) 60%, #000);
  transition: transform 0.08s, box-shadow 0.08s;
}
.ring-btn:active:not(:disabled) { transform: translateY(8px); box-shadow: 0 2px 0 color-mix(in srgb, var(--c, var(--green)) 60%, #000); }
.ring-btn .emoji { font-size: 84px; line-height: 1; }
.ring-btn .label { font: 400 30px/1 var(--display); }
.field { display: block; margin: 18px 0 0; text-align: left; }
.field span { display: block; font-weight: 700; margin-bottom: 6px; }
.field input {
  width: 100%; font: 20px/1.2 var(--body); padding: 14px; border-radius: 12px;
  border: 2px solid var(--line); background: var(--panel); color: var(--ink);
}
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chips button { min-height: 40px; padding: 8px 14px; font-size: 16px; background: transparent; color: var(--ink); border: 2px solid var(--line); }
.picker { list-style: none; padding: 0; margin: 0; }
.picker a {
  display: grid; grid-template-columns: 48px 1fr; align-items: center; gap: 10px;
  padding: 14px 10px; border-bottom: 2px solid var(--line); color: var(--ink); text-decoration: none; font-weight: 700;
}
.picker a .emoji { font-size: 32px; text-align: center; }
.admin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.admin-grid button { flex-direction: column; min-height: 120px; border-radius: 16px; background: var(--c); gap: 8px; }
.admin-grid .emoji { font-size: 40px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
