/* STOPSTOP - base styles. Tokens come straight from the screen designs.
   Every size is in rem (addendum 29 gap 9): large text is one root multiplier.
   Minimum meaningful text 13px; body 15px. Touch targets 44px. Greys checked at 4.5:1. */

@import url('https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@500;600;700&family=IBM+Plex+Sans:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
  --ink: #F2EFE8; --ink-soft: #D6D2CA; --muted: #9EA5AA; --muted-strong: #8A8F93;
  --bg: #16181A; --bg-deep: #000000; --card: #0C0E0F; --map: #202427; --line: #31373B;
  --amber: #E8A944; --amber-dim: #A8822F; --amber-deep: #B4650C;
  --teal: #6FC0B1; --teal-deep: #1F6F63; --teal-ink: #06140F;
  --coral: #D98060; --coral-deep: #9A4A30;
  --sky: #7EA6E0;
  --paper: #F3F0E9; --paper-card: #FFFFFF; --paper-line: #D8D3C6; --paper-ink: #1D1F21; --paper-soft: #33363A; --paper-muted: #5C5F63;
  --accent: var(--amber);
  --display: 'Barlow Condensed', 'Arial Narrow', system-ui, sans-serif;
  --body: 'IBM Plex Sans', system-ui, -apple-system, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, Menlo, monospace;
  --r: 6px;
}
html { font-size: 100%; }                 /* respects the phone's own text size */
html[data-text="large"] { font-size: 125%; }
html[data-text="larger"] { font-size: 150%; }

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); color: var(--ink); font-family: var(--body); font-size: 0.9375rem; line-height: 1.5; -webkit-font-smoothing: antialiased; }
body.paper { background: var(--paper); color: var(--paper-ink); }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; }
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }

/* ---- type ---- */
.display { font-family: var(--display); font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em; line-height: 1.02; }
.display-sub { font-family: var(--display); font-weight: 500; text-transform: uppercase; letter-spacing: 0.1em; }
.label { font-family: var(--mono); font-size: 0.8125rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.mono { font-family: var(--mono); letter-spacing: 0.06em; }
.muted { color: var(--muted); }
.small { font-size: 0.8125rem; }
.teal { color: var(--teal); } .amber { color: var(--amber); } .coral { color: var(--coral); }

/* ---- app shell ---- */
.app { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; max-width: 480px; margin: 0 auto; }
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 0.875rem 1.125rem 0.5rem; font-family: var(--mono); font-size: 0.8125rem; color: var(--muted); letter-spacing: 0.06em; }
.hdr { padding: 0.8125rem 1.125rem; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 0.625rem; }
.hdr .title { font-family: var(--display); font-size: 1.1875rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.hdr .back { text-decoration: none; color: var(--muted); font-size: 1.25rem; line-height: 1; padding: 0.5rem 0.5rem 0.5rem 0; }
.bus-head { background: var(--bg-deep); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 0.75rem 1.125rem; }
.bus-head .name { font-family: var(--display); font-weight: 700; text-transform: uppercase; font-size: 1.75rem; line-height: 1.02; letter-spacing: 0.02em; color: var(--accent); }
.bus-head .route { font-family: var(--display); font-weight: 500; text-transform: uppercase; font-size: 0.9375rem; letter-spacing: 0.1em; color: var(--amber-dim); margin-top: 2px; }
.bus-head.stale .name { color: var(--coral); } .bus-head.stale .route { color: #8A5440; }
.body { flex: 1 1 auto; min-height: 0; padding: 1rem 1.125rem; display: flex; flex-direction: column; gap: 1rem; }
.foot { border-top: 1px solid var(--line); padding: 0.875rem 1.125rem 1.125rem; display: flex; flex-direction: column; gap: 0.5625rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 0.75rem 0.8125rem; }
.card.accent { border-color: var(--accent); } .card.teal { border-color: var(--teal); } .card.coral { border-color: var(--coral); }
.row { display: flex; justify-content: space-between; align-items: center; gap: 0.625rem; }
.plate { font-family: var(--mono); font-weight: 500; font-size: 0.875rem; letter-spacing: 0.09em; background: var(--ink); color: #111; padding: 3px 8px; border-radius: 2px; white-space: nowrap; }
.pill { font-family: var(--mono); font-size: 0.8125rem; letter-spacing: 0.1em; text-transform: uppercase; border: 1px solid var(--line); color: var(--muted-strong); padding: 2px 7px; border-radius: 2px; white-space: nowrap; }
.pill.live { color: var(--teal); border-color: var(--teal); }
.pill.stale { color: var(--coral); border-color: var(--coral); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted-strong); flex: none; display: inline-block; }
.dot.live { background: var(--teal); } .dot.stale { background: var(--coral); } .dot.amber { background: var(--amber); }
hr.rule { border: 0; border-top: 1px solid var(--line); margin: 0; }

/* ---- controls ---- */
.btn { display: flex; align-items: center; justify-content: center; gap: 0.5rem; min-height: 3rem; width: 100%; border: none; border-radius: var(--r); cursor: pointer; text-decoration: none; font-family: var(--display); font-size: 1.25rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; padding: 0 1rem; }
.btn.primary { background: var(--teal); color: var(--teal-ink); }
.btn.amber { background: var(--accent); color: var(--bg); }
.btn.coral { background: var(--coral); color: #fff; min-height: 4.25rem; font-size: 1.5625rem; letter-spacing: 0.07em; border-radius: 7px; }
.btn.big { min-height: 4.25rem; font-size: 1.5625rem; letter-spacing: 0.07em; border-radius: 7px; }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--muted); font-family: var(--body); font-size: 0.8125rem; font-weight: 400; text-transform: none; letter-spacing: 0; min-height: 2.75rem; }
.btn.outline { background: transparent; border: 1px solid var(--accent); color: var(--accent); font-weight: 600; }
.btn.dashed { background: transparent; border: 1px dashed var(--line); color: var(--muted); font-size: 1.0625rem; font-weight: 600; min-height: 2.875rem; }
.btn:disabled { opacity: 0.45; cursor: default; }
.field { display: flex; flex-direction: column; gap: 0.375rem; }
.field label, .field .q { font-size: 0.8125rem; }
.field .hint { font-size: 0.8125rem; color: var(--muted); }
.input { min-height: 2.875rem; background: var(--card); border: 1px solid var(--line); border-radius: 5px; color: var(--ink); padding: 0 0.75rem; width: 100%; }
.input.busname { color: var(--accent); font-family: var(--display); font-size: 1.3125rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.input.plate { background: var(--ink); color: #111; font-family: var(--mono); font-size: 1rem; letter-spacing: 0.08em; text-transform: uppercase; }
.input.mono { font-family: var(--mono); font-size: 1rem; }
.choice { display: flex; gap: 0.6875rem; align-items: flex-start; background: var(--card); border: 1px solid var(--line); border-radius: 5px; padding: 0.75rem; cursor: pointer; min-height: 2.75rem; }
.choice input { width: 1.25rem; height: 1.25rem; margin: 0; flex: none; accent-color: var(--accent); }
.choice.on { border-color: var(--accent); }
.tick { display: flex; gap: 0.6875rem; align-items: flex-start; font-size: 0.8125rem; line-height: 1.4; cursor: pointer; }
.tick input { width: 1.25rem; height: 1.25rem; margin: 0; flex: none; accent-color: var(--teal); }
.lang { display: flex; gap: 4px; }
.lang button { min-height: 1.875rem; padding: 4px 10px; background: transparent; border: 1px solid var(--line); color: var(--muted); border-radius: 3px; font-size: 0.84375rem; cursor: pointer; }
.lang button.on { background: var(--accent); border-color: var(--accent); color: var(--bg); font-weight: 600; }
.notice { background: var(--card); border: 1px solid var(--accent); border-radius: 8px; padding: 1.125rem 1rem; }
.notice p { margin: 0 0 0.6875rem; font-size: 0.875rem; line-height: 1.55; }

/* ---- map ---- */
.map-wrap { position: relative; background: var(--map); flex: 1 1 auto; min-height: 16rem; }
.map { position: absolute; inset: 0; }
.map-over { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 1.5rem; background: rgba(12,14,15,0.82); pointer-events: none; }
.map-over strong { font-family: var(--display); text-transform: uppercase; font-size: 1.5rem; letter-spacing: 0.05em; color: var(--coral); }
.map-over span { font-size: 0.8125rem; color: var(--muted); margin-top: 0.5rem; max-width: 28ch; line-height: 1.45; }
.map-over.offline strong { color: var(--muted); }
.attrib { position: absolute; right: 4px; bottom: 2px; font: 0.6875rem/1.3 var(--mono); color: #6b7378; background: rgba(32,36,39,0.7); padding: 1px 5px; border-radius: 2px; }
.attrib a { color: #8fa0a8; }
.distance { padding: 0.875rem 1.125rem 0.625rem; border-top: 1px solid var(--line); display: flex; align-items: flex-end; justify-content: space-between; gap: 0.75rem; }
.distance .km { font-family: var(--display); font-weight: 700; font-size: 2.875rem; line-height: 0.92; letter-spacing: 0.01em; }
.distance .km small { font-family: var(--body); font-size: 0.875rem; font-weight: 500; margin-left: 4px; color: var(--muted); }
.distance .eta { text-align: right; font-size: 0.8125rem; color: var(--muted); line-height: 1.35; }
.distance .eta b { display: block; font-family: var(--display); font-size: 1.625rem; font-weight: 600; color: var(--ink); letter-spacing: 0.02em; }
.distance.stale .km { color: var(--muted-strong); } .distance.stale .eta b { color: var(--coral); font-size: 1.375rem; }
.freshness { display: flex; align-items: center; gap: 8px; padding: 0 1.125rem 0.75rem; font-family: var(--mono); font-size: 0.8125rem; color: var(--muted); letter-spacing: 0.03em; }
.freshness.stale { color: var(--coral); }
.bus-marker { width: 28px; height: 28px; }

/* ---- advert strip (never auto-opens, always labelled) ---- */
.ad-strip { margin: 0 1.125rem 1rem; border: 1px dashed var(--line); border-radius: var(--r); padding: 0.6875rem 0.8125rem; display: flex; gap: 0.75rem; align-items: center; text-decoration: none; color: inherit; }
.ad-strip .tag { font-family: var(--mono); font-size: 0.8125rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); writing-mode: vertical-rl; transform: rotate(180deg); }
.ad-strip .copy { font-size: 0.84375rem; color: var(--muted); line-height: 1.4; min-width: 0; }
.ad-strip .copy b { color: var(--ink); font-weight: 600; }
.ad-strip img { height: 3rem; width: auto; max-width: 40%; border-radius: 3px; object-fit: cover; }
.ad-full { position: fixed; inset: 0; z-index: 50; background: #F7F4ED; color: var(--paper-ink); display: flex; flex-direction: column; overflow-y: auto; max-width: 480px; margin: 0 auto; }
.ad-full .bar { display: flex; justify-content: space-between; align-items: center; padding: 0.875rem 1.125rem; background: var(--bg); position: sticky; top: 0; }
.ad-full .bar .label { color: var(--muted); }
.ad-full .close { display: flex; align-items: center; gap: 7px; text-decoration: none; background: var(--line); color: var(--ink); font-size: 0.8125rem; font-weight: 500; padding: 0 0.875rem; border-radius: 22px; min-height: 2.75rem; border: none; cursor: pointer; }
.ad-full .strip { min-height: 9.375rem; background: #2E4A42; display: flex; align-items: center; justify-content: center; }
.ad-full .strip img { width: 100%; height: auto; }
.ad-full .content { padding: 1.25rem 1.125rem 1.5rem; display: flex; flex-direction: column; gap: 1rem; }
.ad-full h1 { margin: 0; font-family: var(--display); font-size: 1.875rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em; line-height: 1.03; }
.ad-full .facts { display: flex; flex-direction: column; gap: 0.5625rem; border-top: 1px solid var(--paper-line); border-bottom: 1px solid var(--paper-line); padding: 0.875rem 0; font-size: 0.84375rem; }
.ad-full .cta { display: flex; align-items: center; justify-content: center; min-height: 3rem; background: var(--amber-deep); color: #fff; text-decoration: none; border-radius: var(--r); font-family: var(--display); font-size: 1.1875rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.ad-full .why { font-size: 0.8125rem; color: var(--paper-muted); line-height: 1.5; }

/* ---- QR ---- */
.qr { background: var(--ink); padding: 6px; border-radius: 3px; width: 4.5rem; height: 4.5rem; image-rendering: pixelated; }
.qr.big { width: 15rem; height: 15rem; padding: 12px; }

/* ---- paper surfaces (apex, admin) ---- */
.paper .page { max-width: 1040px; margin: 0 auto; padding: 0 1.25rem; }
.paper .hero { background: var(--bg); color: var(--ink); padding: 2.75rem 0 2.5rem; }
.paper .hero h1 { margin: 0.75rem 0 0; font-family: var(--display); font-size: clamp(2.25rem, 6vw, 3.375rem); font-weight: 700; text-transform: uppercase; letter-spacing: 0.01em; line-height: 1; text-wrap: balance; max-width: 22ch; }
.paper .hero p { margin: 0.875rem 0 0; font-size: 1.0625rem; line-height: 1.6; color: #C5C9CC; max-width: 56ch; }
.paper .hero .label { color: var(--amber); }
.doors { display: grid; grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr)); gap: 1.125rem; padding: 2.25rem 0 1.25rem; }
.door { text-decoration: none; color: inherit; background: var(--paper-card); border: 1px solid var(--paper-line); border-radius: 9px; padding: 1.5rem 1.625rem; display: block; }
.door.lead { border-color: var(--amber-deep); }
.door .label { color: var(--paper-muted); } .door.lead .label { color: var(--amber-deep); }
.door h2 { margin: 0.5625rem 0 0.4375rem; font-family: var(--display); font-size: 1.8125rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em; line-height: 1.05; text-wrap: balance; }
.door p { margin: 0 0 0.75rem; font-size: 0.90625rem; line-height: 1.55; color: var(--paper-muted); }
.door .go { font-size: 0.90625rem; font-weight: 500; color: var(--amber-deep); }
.pcard { background: var(--paper-card); border: 1px solid var(--paper-line); border-radius: 7px; padding: 0.9375rem 1.0625rem; }
.pcard.lead { border-color: var(--amber-deep); } .pcard.teal { border-color: var(--teal-deep); } .pcard.coral { border-color: var(--coral-deep); }
.pcard h3 { margin: 0; font-family: var(--display); font-size: 1.25rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.pbtn { min-height: 2.75rem; padding: 0 1rem; border: none; border-radius: 5px; cursor: pointer; font-family: var(--display); font-size: 1rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; background: var(--teal-deep); color: #fff; }
.pbtn.dark { background: var(--paper-ink); color: var(--ink); }
.pbtn.quiet { background: transparent; border: 1px solid var(--paper-line); color: var(--paper-muted); font-family: var(--body); font-size: 0.8125rem; text-transform: none; letter-spacing: 0; font-weight: 400; }
.pbtn.danger { background: transparent; border: 1px solid var(--coral); color: var(--coral); }
.stat b { display: block; font-family: var(--display); font-size: 1.875rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.stat span { font-size: 0.84375rem; color: var(--paper-muted); }
table.plain { width: 100%; border-collapse: collapse; font-size: 0.84375rem; }
table.plain th { text-align: left; color: var(--paper-muted); font-weight: 500; padding: 0.75rem 1rem 0.5rem; }
table.plain td { padding: 0.6875rem 1rem; border-top: 1px solid #E8E3D7; }
.badge { font-family: var(--mono); font-size: 0.8125rem; letter-spacing: 0.1em; text-transform: uppercase; padding: 2px 7px; border-radius: 2px; border: 1px solid var(--paper-line); color: var(--paper-muted); }
.badge.public { color: var(--teal-deep); border-color: var(--teal-deep); } .badge.preview { color: var(--amber-deep); border-color: var(--amber-deep); }

/* ---- utilities ---- */
.stack { display: flex; flex-direction: column; gap: 0.625rem; }
.center { text-align: center; }
.toast { position: fixed; left: 50%; bottom: 1.25rem; transform: translateX(-50%); background: var(--ink); color: #111; padding: 0.75rem 1rem; border-radius: 6px; font-size: 0.875rem; z-index: 99; max-width: 90vw; }
.spin { display: inline-block; width: 1rem; height: 1rem; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation: none; } }
