:root {
  --blue: #1F4E8C;
  --blue-dark: #163A69;
  --blue-soft: #E8EFF8;
  --blue-light: #8BAAD6;
  --ink: #1C2430;
  --muted: #4A5464;
  --ground: #FBF8F2;
  --line: #D9D2C3;
  --line-soft: #E8E2D6;
  --card: #FFFFFF;
  --ok: #1E6B3A;
  --ok-bg: #EEF6F0;
  --wait: #8A4B00;
  --wait-bg: #FFF6E5;
  --back: #9B2C2C;
  --back-bg: #FDF0EF;
  --sand: #F3EEE3;
  --scale: 1.1;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--ground); color: var(--ink); font-family: 'Atkinson Hyperlegible', system-ui, sans-serif; font-size: 16px; line-height: 1.4; }
a { color: var(--blue); }
a:hover { color: var(--blue-dark); }
button { font-family: inherit; cursor: pointer; }
h1, h2, h3, p { margin: 0; }
:focus-visible { outline: 3px solid #F2B705; outline-offset: 2px; }

/* Top bar */
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 20px; background: #FFFFFF; border-bottom: 1px solid var(--line-soft); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--blue); font-weight: 700; font-size: 20px; }
.brand img { width: 40px; height: auto; }
.topbar .role { color: var(--muted); font-size: 15px; }

/* Landing */
.landing { max-width: 1040px; margin: 0 auto; padding: 56px 24px 40px; display: flex; flex-direction: column; gap: 32px; }
.landing .hero { display: flex; align-items: center; gap: 20px; }
.landing .hero img { width: 120px; height: auto; }
.landing h1 { font-size: 48px; color: var(--blue); letter-spacing: -0.5px; }
.landing .lede { font-size: 20px; max-width: 680px; }
.roles { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.role-card { display: flex; flex-direction: column; gap: 6px; padding: 22px; border: 1px solid var(--line); border-radius: 16px; background: var(--card); color: var(--ink); text-decoration: none; }
.role-card:hover { border-color: var(--blue); color: var(--ink); }
.role-card strong { font-size: 20px; color: var(--blue); }
.role-card span { color: var(--muted); }
.fineprint { color: var(--muted); font-size: 14px; }

/* Phone frame for mobile apps */
.phone-stage { display: flex; justify-content: center; padding: 24px 12px 48px; }
.phone { width: 100%; max-width: 420px; min-height: 820px; background: var(--ground); border: 1px solid var(--line); border-radius: 28px; overflow: hidden; overflow: clip; display: flex; flex-direction: column; box-shadow: 0 10px 30px rgba(28, 36, 48, 0.08); }
@media (max-width: 480px) { .phone-stage { padding: 0; } .phone { border: none; border-radius: 0; box-shadow: none; } }

/* Resident app: everything in em so text size scales */
.res { font-size: calc(18px * var(--scale)); padding: 1.1em 1.1em 1.6em; display: flex; flex-direction: column; gap: 0.9em; flex: 1; }
.res .bar { display: flex; justify-content: space-between; align-items: center; gap: 0.5em; }
.res h1 { font-size: 1.75em; line-height: 1.15; }
.res h2 { font-size: 1.25em; }
.res .muted { color: var(--muted); }
.res .small { font-size: 0.9em; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.5em; min-height: 3.2em; padding: 0 1em; border-radius: 0.75em; border: 2px solid var(--blue); background: #FFFFFF; color: var(--blue); font-size: 1em; font-weight: 700; text-decoration: none; }
.btn:hover { color: var(--blue-dark); }
.btn.primary { background: var(--blue); color: #FFFFFF; }
.btn.primary:hover { background: var(--blue-dark); color: #FFFFFF; }
.btn.big { min-height: 3.6em; font-size: 1.15em; width: 100%; }
.btn.slim { min-height: 2.6em; font-size: 0.9em; }
.btn.plain { border-color: var(--muted); color: var(--ink); }
.btn[disabled] { opacity: 0.5; cursor: default; }
.link-back { display: inline-flex; align-items: center; gap: 0.3em; min-height: 2.6em; font-weight: 700; text-decoration: none; }
.card { padding: 0.9em; border: 2px solid var(--line); border-radius: 1em; background: var(--card); display: flex; flex-direction: column; gap: 0.4em; }
.card.alert { border-color: var(--back); background: var(--back-bg); }
.card.good { border-color: var(--ok); background: var(--ok-bg); }
.card.waitc { border-color: var(--wait); background: var(--wait-bg); }
.status { display: flex; align-items: flex-start; gap: 0.4em; font-weight: 700; }
.status svg { flex-shrink: 0; margin-top: 0.1em; width: 1.1em; height: 1.1em; }
.ok { color: var(--ok); } .wait { color: var(--wait); } .back { color: var(--back); }
.stack { display: flex; flex-direction: column; gap: 0.7em; }
.push { margin-top: auto; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.5em; }
.chip { min-height: 3em; border-radius: 0.7em; border: 2px solid var(--muted); background: #FFFFFF; color: var(--ink); font-size: 1em; font-weight: 700; }
.chip[aria-pressed="true"] { border: 3px solid var(--blue); background: var(--blue-soft); }
.field label { display: block; font-weight: 700; margin-bottom: 0.3em; }
.field .row { display: flex; gap: 0.5em; }
.field input { flex: 1; min-width: 0; min-height: 3.2em; padding: 0 0.7em; border: 2px solid var(--muted); border-radius: 0.7em; font-family: inherit; font-size: 1.05em; color: var(--ink); }
.mic { width: 4em; flex-direction: column; gap: 0.1em; font-size: 0.8em; }
.result { display: flex; gap: 0.8em; padding: 0.7em; border: 2px solid var(--line); border-radius: 1em; background: var(--card); color: var(--ink); text-decoration: none; }
.result:hover { border-color: var(--blue); color: var(--ink); }
.result .meta { display: flex; flex-direction: column; gap: 0.2em; }
.result .t { font-weight: 700; font-size: 1.1em; line-height: 1.2; }
.toggle { display: flex; justify-content: space-between; align-items: center; gap: 0.8em; min-height: 3em; }
.toggle input { width: 1.6em; height: 1.6em; accent-color: var(--blue); flex-shrink: 0; }
.done-icon { width: 5.5em; height: 5.5em; border-radius: 50%; border: 3px solid var(--ok); background: var(--ok-bg); display: flex; align-items: center; justify-content: center; margin: 1.5em auto 0; }

/* Covers */
.cover { position: relative; flex-shrink: 0; border-radius: 6px; overflow: hidden; background: #E4DCCB; display: inline-flex; align-items: center; justify-content: center; text-align: center; }
.cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cover .ph { padding: 4px; font-size: 11px; color: var(--muted); line-height: 1.2; }
.cover.missing img { display: none; }
.cover-s { width: 3.4em; height: 5em; }
.cover-m { width: 6.5em; height: 9.6em; }
.cover-xs { width: 36px; height: 52px; border-radius: 4px; }

/* Desktop apps */
.desk { display: flex; flex-wrap: wrap; min-height: calc(100vh - 61px); }
.side { flex: 1 1 220px; max-width: 250px; padding: 24px 14px; display: flex; flex-direction: column; gap: 4px; background: var(--ink); color: #FFFFFF; }
.side .org { padding: 0 12px; font-size: 19px; font-weight: 700; }
.side .sub { padding: 0 12px 16px; font-size: 14px; color: #C9D2DE; }
.side a { padding: 11px 12px; border-radius: 10px; color: #E4E9F0; text-decoration: none; }
.side a.on { background: #33415A; color: #FFFFFF; font-weight: 700; }
.desk main { flex: 999 1 560px; min-width: 0; padding: 32px 40px; display: flex; flex-direction: column; gap: 22px; }
@media (max-width: 700px) { .side { max-width: none; flex-direction: row; flex-wrap: wrap; } .desk main { padding: 20px; } }
.desk h1 { font-size: 30px; }
.desk h2 { font-size: 19px; }
.head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 16px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.tile { padding: 16px 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); display: flex; flex-direction: column; gap: 2px; }
.tile .n { font-size: 30px; font-weight: 700; }
.tile span { color: var(--muted); }
.panel { border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
.panel > h2, .panel > .panel-head { padding: 14px 20px; border-bottom: 1px solid var(--line-soft); }
.panel-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; }
.panel .note { padding: 12px 20px; border-top: 1px solid var(--line-soft); color: var(--muted); }
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; color: var(--muted); padding: 10px 14px; font-weight: 700; }
td { padding: 12px 14px; border-top: 1px solid var(--line-soft); vertical-align: middle; }
th:first-child, td:first-child { padding-left: 20px; }
th:last-child, td:last-child { padding-right: 20px; }
.dbtn { min-height: 40px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--blue); background: #FFFFFF; color: var(--blue); font-size: 15px; font-weight: 700; white-space: nowrap; text-decoration: none; display: inline-flex; align-items: center; }
.dbtn.primary { background: var(--blue); color: #FFFFFF; }
.dbtn.danger { border-color: var(--back); color: var(--back); }
.dbtn.danger.fill { background: var(--back); color: #FFFFFF; }
.cols { display: flex; flex-wrap: wrap; gap: 22px; align-items: flex-start; }
.cols > .wide { flex: 999 1 520px; min-width: 0; }
.cols > .narrow { flex: 1 1 280px; display: flex; flex-direction: column; gap: 12px; }
.box { padding: 14px; border-radius: 10px; display: flex; flex-direction: column; gap: 6px; }
.box.back { background: var(--back-bg); color: var(--ink); }
.box.wait { background: var(--wait-bg); color: var(--ink); }
.box.sand { background: var(--sand); }
.box.good { background: var(--ok-bg); border: 1px solid var(--ok); }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.namecell { display: flex; align-items: center; gap: 10px; }

/* Driver */
.drv { font-size: 17px; padding: 20px; display: flex; flex-direction: column; gap: 14px; flex: 1; }
.drv h1 { font-size: 27px; }
.map { position: relative; height: 200px; border-radius: 16px; overflow: hidden; background: #E6EBE2; border: 1px solid var(--line); }
.map span { position: absolute; padding: 3px 8px; border-radius: 6px; background: #FFFFFF; font-size: 14px; font-weight: 700; }
.step { display: flex; gap: 12px; padding: 13px; border: 2px solid var(--line); border-radius: 14px; background: #FFFFFF; }
.step.on { border-color: var(--blue); }
.step .num { flex-shrink: 0; width: 32px; height: 32px; border-radius: 50%; background: var(--line-soft); display: flex; align-items: center; justify-content: center; font-weight: 700; }
.step.on .num { background: var(--blue); color: #FFFFFF; }
.counter { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 18px; border: 2px solid var(--blue); border-radius: 16px; background: #FFFFFF; }
.counter.done { border-color: var(--ok); }
.counter .big { font-size: 54px; font-weight: 700; line-height: 1; }
.code { display: flex; justify-content: space-between; padding: 11px 14px; border: 1px solid var(--line); border-radius: 10px; background: #FFFFFF; }
.code span:first-child { font-family: ui-monospace, Menlo, monospace; }

/* Sign-up */
.signup { max-width: 1080px; margin: 0 auto; padding: 40px 24px 60px; display: flex; flex-direction: column; gap: 26px; }
.signup h1 { font-size: 38px; line-height: 1.15; }
.form { display: flex; flex-direction: column; gap: 16px; padding: 26px; border: 1px solid var(--line); border-radius: 16px; background: #FFFFFF; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.form label.f { display: flex; flex-direction: column; gap: 6px; font-weight: 700; }
.form input, .form select { min-height: 46px; padding: 0 12px; border: 1px solid var(--muted); border-radius: 8px; font-family: inherit; font-size: 16px; background: #FFFFFF; }
.freq { min-height: 70px; padding: 10px; border-radius: 10px; text-align: left; border: 1px solid var(--muted); background: #FFFFFF; font-size: 16px; color: var(--ink); }
.freq[aria-pressed="true"] { border: 3px solid var(--blue); background: var(--blue-soft); }
.price { padding: 22px; border: 2px solid var(--blue); border-radius: 16px; background: #FFFFFF; display: flex; flex-direction: column; gap: 10px; }
.price td { padding: 9px 0; }
.price td:last-child { text-align: right; font-weight: 700; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #FFFFFF; padding: 12px 18px; border-radius: 10px; font-weight: 700; z-index: 10; }
.panel.pad { padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.panel.pad > h2 { padding: 0; border: 0; }
.cover-xs .ph { display: none; }
.mic .wave path { transform-box: fill-box; transform-origin: center; animation: br-wave 0.9s ease-in-out infinite; }
.mic .wave path:nth-child(2) { animation-delay: 0.15s; }
.mic .wave path:nth-child(3) { animation-delay: 0.3s; }
.mic .wave path:nth-child(4) { animation-delay: 0.45s; }
.mic .wave path:nth-child(5) { animation-delay: 0.6s; }
@keyframes br-wave { 0%, 100% { transform: scaleY(0.5); } 50% { transform: scaleY(1); } }
@media (prefers-reduced-motion: reduce) { .mic .wave path { animation: none; } }
.res .bar .btn.slim { font-size: 17px; white-space: nowrap; }

/* Resident bottom navigation */
.tabbar { position: sticky; bottom: 0; display: grid; grid-template-columns: repeat(4, 1fr); background: #FFFFFF; border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 60px; justify-content: center; border-radius: 12px; color: var(--muted); text-decoration: none; font-weight: 700; font-size: calc(15px * min(var(--scale), 1.2)); }
.tabbar a.on { color: var(--blue); background: var(--blue-soft); }
.tabbar a:hover { color: var(--blue); }

/* Splash */
.splash { min-height: 100vh; min-height: 100dvh; background: var(--blue); color: #FFFFFF; display: flex; flex-direction: column; align-items: center; padding: 24px 24px calc(40px + env(safe-area-inset-bottom)); }
.splash-mid { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center; }
.splash-logo { width: 150px; height: auto; margin-bottom: 14px; animation: splash-pop 0.7s cubic-bezier(.2,.9,.3,1.3) both; }
.splash h1 { font-size: 44px; letter-spacing: -0.5px; animation: splash-up 0.6s ease 0.5s both; }
.splash p { font-size: 19px; font-weight: 700; color: #DCE6F4; animation: splash-up 0.6s ease 0.7s both; }
.splash-btn { width: 100%; max-width: 360px; min-height: 58px; border: none; border-radius: 14px; background: #FFFFFF; color: var(--blue); font-size: 18px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; box-shadow: 0 4px 0 var(--blue-dark); animation: splash-up 0.6s ease 1.2s both; }
.splash-btn:hover { background: var(--blue-soft); }
.splash-btn:focus-visible { outline-color: #F2B705; }
@keyframes splash-pop { from { opacity: 0; transform: scale(0.6); } to { opacity: 1; transform: scale(1); } }
@keyframes splash-up { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .splash-logo, .splash h1, .splash p, .splash-btn { animation: none; } }
@media (max-width: 560px) {
  .landing { padding: 32px 20px; gap: 24px; }
  .landing .hero { flex-direction: column; align-items: flex-start; gap: 12px; }
  .landing .hero img { width: 84px; }
  .landing h1 { font-size: 38px; }
  .landing .lede { font-size: 18px; }
}
