:root {
  /* ---- Brand (overridden by /brand.css from BRAND_* env vars) ---- */
  --brand: #1d4ed8;            /* ukcheckpoints primary */
  --brand-ink: #ffffff;        /* text on brand colour */

  /* ---- Light theme (matches ukcheckpoints.info's white theme) ---- */
  --bg: #f3f5f8; --panel: #ffffff; --panel-2: #eef1f5; --line: #dde2ea;
  --text: #0f172a; --muted: #5b6678;
  --accent: var(--brand); --accent-ink: var(--brand-ink);
  --mine: color-mix(in srgb, var(--brand) 13%, #ffffff);
  --theirs: #ffffff;
  --bot: color-mix(in srgb, var(--brand) 5%, #ffffff);
  --bot-line: color-mix(in srgb, var(--brand) 35%, transparent);
  --quote-bg: rgba(15, 23, 42, .05);
  --banner-bg: #fff4d6; --banner-ink: #7a4b00;
  --shadow: 0 1px 2px rgba(15, 23, 42, .08);
  --shadow-lg: 0 8px 28px rgba(15, 23, 42, .18);
  --name-l: 38%;
  --danger: #dc2626;

  /* ---- Status colours (road-sign style) ---- */
  --clear: #16a34a; --open: #16a34a; --active: #ea580c; --busy: #d97706; --delays: #f59e0b; --closed: #dc2626;

  --radius: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body { overscroll-behavior: none; -webkit-tap-highlight-color: transparent; }
button, input, textarea { font: inherit; color: inherit; }
code { background: var(--panel-2); padding: 1px 5px; border-radius: 5px; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.pad { padding: 0 16px 12px; }
.center { display: block; margin: 8px auto; }
.error { color: var(--danger); min-height: 1.2em; margin: 10px 0 0; }
.stack { display: grid; gap: 10px; }
.clip { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 70vw; }

/* Buttons & inputs */
.btn { border: 1px solid var(--line); background: var(--panel-2); border-radius: 12px; padding: 11px 14px; cursor: pointer; text-align: center; text-decoration: none; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .6; }
.icon-btn { background: none; border: 0; font-size: 1.25rem; padding: 8px; cursor: pointer; position: relative; color: var(--text); }
select { width: 100%; background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 11px; color: var(--text); font: inherit; }
.push-status { margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--panel-2); }
.push-status.on { color: var(--open); }
.push-status.warn { color: var(--busy); }
input, textarea { width: 100%; background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px; outline: none; }
input:focus, textarea:focus { border-color: var(--accent); }
#code { letter-spacing: .5em; text-align: center; font-size: 1.4rem; }

/* Screens */
.screen { height: 100dvh; display: flex; flex-direction: column; }
#login { align-items: center; justify-content: center; padding: 20px; }
.card { width: min(420px, 100%); background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow-lg); border-radius: 20px; padding: 28px 22px; text-align: center; }
.card .stack { margin-top: 18px; text-align: left; }
.logo { width: 64px; height: 64px; }
h1 { font-size: 1.35rem; margin: 10px 0 6px; }
.paywall { margin-top: 18px; display: grid; gap: 10px; padding: 14px; border-radius: 12px; background: var(--panel-2); }
.paywall p { margin: 0; }

/* Top bar */
.topbar { display: flex; align-items: center; gap: 10px; padding: calc(env(safe-area-inset-top, 0px) + 8px) 8px 8px 12px; background: var(--panel); border-bottom: 1px solid var(--line); }
.avatar { width: 38px; height: 38px; }
.title { flex: 1; min-width: 0; }
.title > div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge { position: absolute; top: 2px; right: 0; background: var(--accent); color: var(--accent-ink); border-radius: 9px; font-size: .7rem; padding: 1px 5px; font-weight: 700; }
.banner { background: var(--banner-bg); color: var(--banner-ink); text-align: center; padding: 6px; font-size: .85rem; }

/* Messages */
.messages { flex: 1; overflow-y: auto; padding: 10px 10px 4px; display: flex; flex-direction: column; gap: 4px; }
.day { align-self: center; font-size: .75rem; color: var(--muted); background: var(--panel); box-shadow: var(--shadow); padding: 3px 10px; border-radius: 10px; margin: 8px 0; }
.msg { max-width: min(80%, 560px); padding: 7px 10px 5px; border-radius: var(--radius); background: var(--theirs); box-shadow: var(--shadow); align-self: flex-start; word-wrap: break-word; white-space: pre-wrap; cursor: pointer; animation: pop .15s ease-out; }
.msg.mine { align-self: flex-end; background: var(--mine); }
.msg.bot { background: var(--bot); border: 1px solid var(--bot-line); }
.msg.system { align-self: center; background: var(--panel); box-shadow: none; border: 1px solid var(--line); color: var(--muted); font-size: .85rem; text-align: center; max-width: 92%; }
.msg .who { font-size: .8rem; font-weight: 600; margin-bottom: 2px; }
.msg .meta { font-size: .7rem; color: var(--muted); text-align: right; margin-top: 2px; }
.msg .quote { border-left: 3px solid var(--accent); padding: 3px 7px; margin-bottom: 4px; background: var(--quote-bg); border-radius: 6px; font-size: .82rem; color: var(--muted); }
.msg.flash { outline: 2px solid var(--accent); }
.typing { align-self: flex-start; color: var(--muted); font-size: .8rem; padding: 2px 8px; }
@keyframes pop { from { transform: scale(.97); opacity: .4; } to { transform: none; opacity: 1; } }

/* Composer */
.reply-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 12px; background: var(--panel); border-top: 1px solid var(--line); border-left: 3px solid var(--accent); }
.composer { display: flex; gap: 8px; align-items: flex-end; padding: 8px 8px calc(8px + var(--safe-b)); background: var(--panel); border-top: 1px solid var(--line); }
.composer textarea { resize: none; max-height: 140px; border-radius: 20px; padding: 10px 14px; }
.send { width: 44px; height: 44px; flex: none; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink); font-size: 1.1rem; cursor: pointer; }

/* Sheets */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 10; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; max-height: 80dvh; overflow-y: auto; background: var(--panel); border-radius: 18px 18px 0 0; border-top: 1px solid var(--line); z-index: 11; padding-bottom: var(--safe-b); animation: up .2s ease-out; }
@media (min-width: 720px) { .sheet { left: auto; top: 0; width: 380px; max-height: none; border-radius: 0; border-left: 1px solid var(--line); animation: none; } }
.sheet-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; position: sticky; top: 0; background: var(--panel); }
.sheet-head h2 { margin: 0; font-size: 1.1rem; }
@keyframes up { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }

.cp-list { list-style: none; margin: 0; padding: 0 16px 8px; display: grid; gap: 8px; }
.cp { background: var(--panel-2); border-radius: 12px; padding: 10px 12px; display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; }
.cp .name { font-weight: 600; }
.cp .detail, .cp .age { grid-column: 1 / -1; }
.cp.stale { opacity: .6; }
.pill { font-size: .75rem; font-weight: 700; text-transform: uppercase; padding: 3px 8px; border-radius: 10px; color: #fff; background: var(--muted); align-self: start; letter-spacing: .02em; }
.pill.open, .pill.clear { background: var(--clear); }
.pill.active { background: var(--active); }
.pill.busy { background: var(--busy); }
.pill.delays { background: var(--delays); }
.pill.closed { background: var(--closed); }

.actions { box-shadow: var(--shadow-lg); position: fixed; left: 50%; bottom: calc(20px + var(--safe-b)); transform: translateX(-50%); z-index: 11; display: grid; gap: 8px; width: min(320px, 90vw); background: var(--panel); padding: 12px; border-radius: 16px; border: 1px solid var(--line); }

/* Drive mode */
.drive-btn { opacity: .55; filter: grayscale(1); }
.drive-btn.on { opacity: 1; filter: none; }
.drive-btn.on::after { content: ''; position: absolute; right: 4px; bottom: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--panel); }
.check { display: flex; align-items: center; gap: 8px; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.hint { margin: 0; }

/* Pass prompt — compact card above the composer, never blocks the screen */
.pass { margin: 0 8px 6px; background: var(--panel); border: 1px solid var(--accent); border-radius: 16px; padding: 10px 10px 0; box-shadow: var(--shadow-lg); animation: up .2s ease-out; overflow: hidden; }
.pass-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.pass-head .icon-btn { padding: 2px 6px; font-size: 1rem; color: var(--muted); }
.pass-q { font-size: 1.05rem; margin-top: 2px; }
.pass-btns { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin: 10px 0; }
.pa { min-height: 56px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel-2); font-weight: 700; font-size: 1rem; cursor: pointer; touch-action: manipulation; }
.pa-active { background: var(--active); color: #fff; border-color: transparent; }
.pa-clear { background: var(--clear); color: #fff; border-color: transparent; }
.pa:active { transform: scale(.97); }
.pass-thanks { text-align: center; font-weight: 600; padding: 18px 0; }
.pass-track { height: 3px; margin: 0 -10px; background: var(--line); }
.pass-timer { height: 100%; width: 100%; background: var(--accent); transform-origin: left; }
.pass-timer.run { animation: drain 25s linear forwards; }
@keyframes drain { to { transform: scaleX(0); } }

/* ---- ukcheckpoints wordmark & brand chrome ---- */
.wordmark { font-weight: 800; letter-spacing: -.02em; color: var(--text); }
.wordmark .tld { color: var(--brand); }
.topbar { border-top: 3px solid var(--brand); }
.topbar .wordmark { font-size: 1.05rem; }
.live { display: inline-flex; align-items: center; gap: 4px; margin-left: 6px; padding: 1px 7px; border-radius: 999px; background: var(--active); color: #fff; font-size: .65rem; font-weight: 800; letter-spacing: .06em; vertical-align: 2px; }
.live::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: #fff; animation: blink 1.6s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .25; } }
#login .wordmark { font-size: 1.6rem; display: block; margin-top: 10px; }
.login-sub { font-weight: 600; margin: 2px 0 10px; }
.tagline { margin: 0 auto; max-width: 32ch; }
.brand-foot { margin-top: 16px; }
.brand-foot a { color: var(--brand); text-decoration: none; font-weight: 600; }
.live-sub::before { content: ''; display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: var(--clear); vertical-align: 1px; animation: blink 1.6s ease-in-out infinite; }
