/* Trainwatch: a strip map for each trip. Platform-grey ground, white panels, slate ink;
   the only strong colors are signal states. Overpass (highway/transit signage lineage). */
:root {
  --ground: #E9EDF1;
  --panel: #FFFFFF;
  --ink: #1B2430;
  --ink-2: #4A5563;
  --ink-3: #7B8694;
  --rule: #D3D9E0;
  --track: #C2CAD3;
  --go: #1F8A4C;
  --late: #C8322B;
  --unknown: #8A94A3;
  --warn: #A15C00;
  --amber: #E08A00;            /* a filled amber (the record's squares): --warn is dark enough for text, so brownish as a fill */
  --action: #2457C5;
  --action-ink: #FFFFFF;
  --focus: #2457C5;
  --radius-panel: 14px;
  --radius-ctl: 8px;
  --shadow: 0 1px 0 rgba(27, 36, 48, 0.06);
  font-family: "Overpass", system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--ground);
  -webkit-text-size-adjust: 100%;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ground: #18212B;
    --panel: #222D39;
    --ink: #E8EDF2;
    --ink-2: #B7C1CC;
    --ink-3: #8794A3;
    --rule: #34414F;
    --track: #46546385;
    --go: #3DBA74;
    --late: #F0645C;
    --unknown: #8794A3;
    --warn: #F0B44C;
    --amber: #F0A73C;
    --action: #6F9BFF;
    --action-ink: #0F1A2B;
    --focus: #8FB2FF;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--ground); }
h1, h2, h3, p { margin: 0; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.topbar {
  max-width: 680px; margin: 0 auto; padding: 18px 16px 6px;
  display: flex; align-items: center; justify-content: space-between;
}
.wordmark {
  display: inline-flex; align-items: center; gap: 10px;
  font-weight: 800; font-size: 1.15rem; letter-spacing: -0.01em;
  color: var(--ink); text-decoration: none;
}
.wordmark svg { width: 40px; height: 12px; }
.wordmark line { stroke: var(--ink); stroke-width: 3; }
.wordmark circle:first-of-type { fill: var(--go); }
.wordmark circle:last-of-type { fill: var(--ink); }
.account { position: relative; }
.account-btn {
  width: 36px; height: 36px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--panel); color: var(--ink); font-weight: 800; box-shadow: var(--shadow);
}
.account-menu {
  position: absolute; right: 0; top: 44px; z-index: 10; min-width: 220px;
  background: var(--panel); border: 1px solid var(--rule); border-radius: var(--radius-ctl);
  padding: 12px 14px; display: grid; gap: 8px;
}
.account-menu p { color: var(--ink-2); font-size: 0.9rem; overflow-wrap: anywhere; }

main { max-width: 680px; margin: 0 auto; padding: 8px 16px 64px; }

/* ---------- gates (loading / signed out / no access) ---------- */
.gate { padding: 48px 0; display: grid; gap: 16px; max-width: 34rem; }
.gate h1 { font-size: 2rem; line-height: 1.15; font-weight: 800; letter-spacing: -0.015em; }
.gate p { color: var(--ink-2); }
.gate .primary, .gate .secondary { justify-self: start; }
.quiet { color: var(--ink-3); }
.cmd {
  margin: 0; padding: 12px 14px; background: var(--panel); border: 1px solid var(--rule);
  border-radius: var(--radius-ctl); font-size: 0.85rem; white-space: pre-wrap; overflow-wrap: anywhere;
}

/* ---------- groups ---------- */
.group { margin-top: 22px; }
.group h2, .empty h2 { font-size: 1rem; font-weight: 800; color: var(--ink-2); margin: 0 4px 10px; }
.trips { display: grid; gap: 10px; }
.group-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin: 0 4px 10px; }
.group-head h2 { margin: 0; }
.banner {
  margin-top: 14px; padding: 10px 14px; border-radius: var(--radius-ctl);
  background: var(--panel); border-left: 4px solid var(--late); color: var(--ink-2); font-size: 0.95rem;
}
.empty { margin-top: 28px; padding: 0 4px; display: grid; gap: 6px; color: var(--ink-2); }

/* ---------- a trip: the strip map ---------- */
.trip {
  background: var(--panel); border-radius: var(--radius-panel); box-shadow: var(--shadow);
  padding: 16px 18px 14px; display: grid; gap: 12px;
  --from: var(--ink); --to: var(--ink); --done: 0;
}
.trip.paused { opacity: 0.6; }
/* all its dates have passed: grayed out, the trip as it was set up */
.trip.past { opacity: 0.6; filter: grayscale(1); --from: var(--unknown); --to: var(--unknown); }
.trip.past .trip-when { color: var(--ink-3); }
.strip.plain .stop .time { color: var(--ink-2); }
.trip.past { gap: 6px; padding-top: 12px; padding-bottom: 10px; }
.trip.past:has(.trip-edit) { opacity: 1; filter: none; }      /* editing: full color */
.trip-past { margin: 0; color: var(--ink-2); font-size: 0.95rem; overflow-wrap: anywhere; }
.trip-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.trip-when { font-weight: 600; color: var(--ink-2); font-size: 0.95rem; }
.trip-train { color: var(--ink-3); font-size: 0.9rem; font-variant-numeric: tabular-nums; }

.strip {
  display: grid; grid-template-columns: 16px 1fr 16px; align-items: center;
  row-gap: 8px; column-gap: 0;
}
.strip .node { width: 16px; height: 16px; border-radius: 50%; background: var(--panel);
  border: 4px solid var(--ink); }
.strip .node.from { border-color: var(--from); }
.strip .node.to { border-color: var(--to); }
.strip .node.filled.from { background: var(--from); }
.strip .node.filled.to { background: var(--to); }
.strip .track { position: relative; height: 4px; background: var(--track); margin: 0 -2px; }
.strip .track .run {
  position: absolute; inset: 0 auto 0 0; width: calc(var(--done) * 100%);
  background: var(--to);
}
.strip .track .marker {
  position: absolute; top: 50%; left: calc(var(--done) * 100%);
  width: 22px; height: 12px; margin: -6px 0 0 -11px; border-radius: 6px;
  background: var(--to); box-shadow: 0 0 0 3px var(--panel);
}
.trip.waiting .strip .track .marker { animation: dwell 2.4s ease-in-out infinite; }
.trip.arrived .strip .track .marker { display: none; }
@keyframes dwell { 50% { transform: translateX(6px); } }

.stop { display: grid; gap: 1px; min-width: 0; }
.stop.from { grid-column: 1 / 3; justify-items: start; text-align: left; }
.stop.to { grid-column: 2 / 4; justify-items: end; text-align: right; }
.stop-row { grid-column: 1 / 4; display: flex; justify-content: space-between; gap: 16px; }
.stop .name { color: var(--ink-2); font-size: 0.95rem; overflow-wrap: anywhere; }
.stop .time { font-size: 1.9rem; font-weight: 800; line-height: 1.05; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums; }
.stop .time small { font-size: 0.55em; font-weight: 600; letter-spacing: 0; margin-left: 1px; }
.stop .sched { color: var(--ink-3); font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.stop .sched.moved { text-decoration: line-through; }

.trip.compact { padding: 14px 18px 12px; gap: 10px; }
.trip.compact .stop .time { font-size: 1.35rem; }

.trip-status { font-weight: 600; font-size: 0.95rem; }
.trip-status.late { color: var(--late); }
.trip-status.go { color: var(--go); }
.trip-status.unknown { color: var(--ink-3); }
.trip-status.cut { color: var(--late); font-weight: 700; }
.trip-status.cut::before { content: "❌ "; }
.trip-via { color: var(--ink-3); font-size: 0.85rem; }
.trip-error { color: var(--ink-2); font-size: 0.95rem; }
.trip-text { color: var(--ink-3); font-size: 0.85rem; overflow-wrap: anywhere; }

.trip-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.trip-foot { flex-wrap: wrap; row-gap: 6px; }
.trip-foot .trip-text { min-width: 0; flex: 1 1 140px; overflow-wrap: normal; }
.trip-foot .trip-actions { flex: none; white-space: nowrap; margin-left: auto; }
.trip-edit { display: grid; gap: 10px; border-top: 1px solid var(--rule); padding-top: 12px; }

/* ---------- panels & forms ---------- */
.panel {
  margin-top: 28px; background: var(--panel); border-radius: var(--radius-panel); box-shadow: var(--shadow);
  padding: 18px;
}
.panel h2 { font-size: 1.15rem; font-weight: 800; margin-bottom: 12px; }
#settings-details > summary { cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: baseline; }
#settings-details > summary::-webkit-details-marker { display: none; }
#settings-details > summary h2 { margin: 0; }
#settings-details > summary::after { content: "Show"; color: var(--action); font-weight: 600; font-size: 0.95rem; }
#settings-details[open] > summary::after { content: "Hide"; }
#settings-details[open] > summary { margin-bottom: 14px; }
form { display: grid; gap: 8px; }
label { font-weight: 600; font-size: 0.95rem; }
input:not([type]), input[type="number"] {
  width: 100%; padding: 11px 12px; border-radius: var(--radius-ctl); border: 1px solid var(--rule);
  background: var(--ground); font-size: 1rem;
}
input[type="number"] { width: 5.5em; padding: 7px 8px; text-align: right; font-variant-numeric: tabular-nums; }
input:focus-visible { outline-offset: 0; }
.hint { color: var(--ink-3); font-size: 0.85rem; }

.help, .more { font-size: 0.92rem; color: var(--ink-2); }
.help summary, .more summary { cursor: pointer; color: var(--action); font-weight: 600; width: max-content; }
.help ul { margin: 8px 0 0; padding-left: 1.1em; display: grid; gap: 6px; }
code { font-family: inherit; font-weight: 600; color: var(--ink); background: var(--ground);
  padding: 1px 5px; border-radius: 4px; }

.options { display: grid; gap: 10px; margin-top: 10px; }
.walk.options { margin-top: 0; }

/* coffee shop mode: the ☕ in the footer, and while it's on, when to leave */
.cup { flex: none; width: 34px; height: 34px; margin: -4px 0; border-radius: 50%; border: 1px solid var(--rule);
  background: transparent; font-size: 1.15rem; line-height: 1; cursor: pointer; padding: 0;
  transition: background 0.15s; }
.cup:hover { background: color-mix(in srgb, var(--action) 12%, transparent); }
.cup:disabled { cursor: default; }
/* coffee shop mode on: a large mug, drained as the time to leave nears, and the minutes left */
.trip-coffee { display: flex; justify-content: center; align-items: center; gap: 24px; }
.coffee-cup { width: 84px; height: 84px; padding: 0; border: 0; background: none; cursor: pointer; color: var(--ink-2); }
.trip-leave { margin: 0; color: var(--ink); font-weight: 600; font-size: 0.95rem; }
.trip-leave.due { color: var(--late); }
.mug { width: 84px; height: 84px; display: block; }
.mug text { paint-order: stroke; stroke: var(--panel); stroke-width: 3px; stroke-linejoin: round; fill: var(--ink); }
.mug .left { font-size: 15px; font-weight: 800; font-variant-numeric: tabular-nums; }
.mug .unit { font-size: 7px; font-weight: 600; }
.trip-coffee.due .mug .left { fill: var(--late); }
.mug .body { fill: none; stroke: currentColor; stroke-width: 3; stroke-linejoin: round; }
.mug .coffee { fill: #8a5a33; transition: y 0.6s ease, height 0.6s ease; }
.mug .steam path { fill: none; stroke: var(--ink-3); stroke-width: 2; stroke-linecap: round; opacity: 0.7; }
/* gently: the steam rises and fades, one wisp after another; now and then the mug is lifted for a
   sip (sipNow() in app.js, at random intervals) */
.coffee-cup .mug { transform-origin: 70% 85%; }
.mug .steam path { transform-box: fill-box; animation: steam-rise 3s ease-in-out infinite; }
@keyframes steam-rise {
  0% { transform: translateY(3px); opacity: 0; }
  35% { opacity: 0.75; }
  100% { transform: translateY(-4px); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) { .mug .steam path { animation: none; } }
.coffee-text { margin: 0; color: var(--ink-2); font-size: 0.9rem; line-height: 1.4; }
.coffee-text b { color: var(--ink); font-size: 1rem; }
.trip-coffee.due .coffee-text b { color: var(--late); }

/* the train's record: a square a day, oldest first */
.trip-record { margin-top: 8px; font-size: 0.85rem; color: var(--ink-3); }
.trip-record summary { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; cursor: pointer; list-style: none; }
.trip-record summary::-webkit-details-marker { display: none; }
.rec-days { display: inline-flex; gap: 2px; flex: none; }
.rec-days i { width: 7px; height: 12px; border-radius: 2px; background: var(--go); }
.rec-days i.late { background: var(--amber); }
.rec-days i.bad { background: var(--late); }
.rec-text { min-width: 0; }
.rec-facts { margin: 10px 0 0; padding: 8px 10px; border-radius: 8px; background: var(--ground); }
.rec-facts .rec-cap { margin: 0 0 4px; color: var(--ink-3); font-size: 0.78rem; }
.rec-facts dl { display: grid; grid-template-columns: 1fr max-content; gap: 3px 14px; margin: 0; }
.rec-facts dt { color: var(--ink-2); min-width: 0; }
.rec-facts dd { margin: 0; color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.trip-record .rec-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 8px 0 0; font-size: 0.78rem; color: var(--ink-2); }
.trip-record .rec-note { margin: 4px 0 0; color: var(--ink-3); font-size: 0.78rem; line-height: 1.35; }
.rec-key { white-space: nowrap; }
.rec-key i { display: inline-block; width: 6px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; background: var(--go); }
.rec-key i.late { background: var(--amber); }
.rec-key i.bad { background: var(--late); }

/* service alerts: the train's or its stations' on the front, the line's on the back */
.trip-alert { margin-top: 10px; padding: 8px 10px; border-radius: 8px; font-size: 0.9rem;
  background: color-mix(in srgb, var(--late) 10%, transparent); color: var(--ink); }
.trip-alert summary { display: flex; gap: 8px; align-items: flex-start; cursor: pointer; font-weight: 600; list-style: none; }
.trip-alert summary::-webkit-details-marker { display: none; }
.trip-alert .alert-icon { flex: none; }
.trip-alert p { margin: 6px 0 0 26px; font-weight: 400; color: var(--ink-2); overflow-wrap: anywhere; }
.notice-count { display: inline-block; min-width: 1.35em; margin-left: 3px; padding: 0 5px; border-radius: 999px;
  background: var(--ground); color: var(--ink-2); font-size: 0.78em; font-weight: 600; line-height: 1.5;
  text-align: center; vertical-align: 1px; }
.notice-count.new { background: var(--late); color: #fff; }
.back-notices { display: grid; gap: 6px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--rule); font-size: 0.85rem; }
.back-notices h3 { margin: 0; font-size: 0.78rem; font-weight: 600; color: var(--ink-3); }
.back-notices h3 + details { margin-top: -2px; }
.back-notices details + h3 { margin-top: 6px; }
.back-notices summary { cursor: pointer; color: var(--ink-2); }
.back-notices p { margin: 4px 0 0; color: var(--ink-3); overflow-wrap: anywhere; }
.opt label { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-weight: 400; }
.opt label > span { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); white-space: nowrap; }
.opt label > span i { font-style: normal; width: 5.4em; }
.opt input[name="line"] { width: 5.5em; padding: 7px 8px; }
.opt.check label { justify-content: flex-start; }
.opt .hint { margin-top: 2px; }
.opt.check input { width: 18px; height: 18px; accent-color: var(--action); }

.preview { min-height: 0; }
.preview:not(:empty) { margin: 6px 0 2px; }
.preview .trip { box-shadow: none; border: 1px dashed var(--rule); }
.preview .msg { color: var(--ink-2); font-size: 0.92rem; }
.preview .msg.bad { color: var(--late); }

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
button { cursor: pointer; }
.primary, .secondary, .danger {
  border-radius: var(--radius-ctl); padding: 10px 16px; font-weight: 600; border: 1px solid transparent;
}
.primary { background: var(--action); color: var(--action-ink); }
.primary:disabled { opacity: 0.55; cursor: default; }
.secondary { background: transparent; color: var(--action); border-color: var(--rule); }
.danger { background: transparent; color: var(--late); border-color: var(--rule); }
.link-btn { border: 0; background: none; padding: 0; color: var(--action); font-weight: 600; justify-self: start; }

/* ---------- toast ---------- */
/* a message at the bottom: as wide as its text, up to the screen less 16px a side (centered with
   left/right and auto margins: left: 50% would let it shrink to half the screen and wrap narrowly) */
.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 20;
  width: fit-content; max-width: 480px; margin: 0 auto; box-sizing: border-box;
  background: var(--ink); color: var(--ground); padding: 12px 18px; border-radius: 14px;
  font-weight: 600; font-size: 0.95rem; line-height: 1.4; text-align: left; overflow-wrap: anywhere;
  box-shadow: 0 6px 24px rgb(0 0 0 / 0.25);
}
.toast.bad { background: var(--late); color: #fff; }

@media (min-width: 560px) {
  .gate h1 { font-size: 2.4rem; }
  .stop .time { font-size: 2.2rem; }
}
@media (prefers-reduced-motion: reduce) {
  .trip.waiting .strip .track .marker { animation: none; }
}

/* ---------- account page ---------- */
.back { display: inline-block; margin: 12px 4px 0; color: var(--action); font-weight: 600; text-decoration: none; }
.back::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 8px;
  border-left: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: translateY(-1px) rotate(45deg); }
.page-title { font-size: 1.9rem; font-weight: 800; letter-spacing: -0.015em; margin: 14px 4px 2px; }
#view-account > .quiet { margin: 0 4px; }
.small { font-size: 0.9rem; }
.group-head.flush { margin: 0 0 12px; }
.group-head.flush h2 { margin: 0; }
.panel .hint + .dests, .panel > .hint { margin-bottom: 4px; }

.dests { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 0; }
.dests li { display: grid; grid-template-columns: 16px 1fr auto; align-items: center; gap: 12px;
  padding: 12px 0; border-top: 1px solid var(--rule); }
.dests li:last-child { border-bottom: 1px solid var(--rule); }
.dests .dest-empty { display: block; color: var(--ink-3); font-size: 0.95rem; }

/* admin: feed checks */
.admin-more { margin: 12px 0 0; }
.admin-more a { font-weight: 600; }
.checks-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.checks-head select { font: inherit; padding: 6px 10px; border: 1px solid var(--rule); border-radius: var(--radius-ctl);
  background: var(--panel); color: var(--ink); }
.check { margin-top: 14px; }
.check-verdict { font-size: 0.85rem; font-weight: 600; }
.check-verdict.good { color: var(--ink-3); }
.check-verdict.bad { color: var(--bad, #b3261e); }
#checks-down { display: grid; gap: 8px; margin: 0 0 16px; }
#checks-down .banner { margin: 0; }
#checks-down .banner .hint { display: block; margin-top: 2px; overflow-wrap: anywhere; }
.check-counts { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin: 10px 0 4px; }
.check-counts div { padding: 8px 10px; border: 1px solid var(--rule); border-radius: var(--radius-ctl); }
.check-counts dt { font-size: 0.78rem; color: var(--ink-3); }
.check-counts dd { margin: 2px 0 0; font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.check-issue { margin-top: 10px; border-top: 1px solid var(--rule); padding-top: 8px; }
.check-issue summary { cursor: pointer; }
.check-issue summary .hint { display: block; margin-left: 18px; }
.check-issue ul { margin: 6px 0 0; padding-left: 18px; font-size: 0.88rem; color: var(--ink-2); }
.check-issue li { margin: 3px 0; overflow-wrap: anywhere; }
.dest-mark { width: 12px; height: 12px; border-radius: 50%; border: 3px solid var(--ink); background: var(--panel); }
.dest-mark.push { background: var(--ink); }
.dest-text { display: grid; min-width: 0; }
.dest-name { font-weight: 600; overflow-wrap: anywhere; }
.dest-kind { color: var(--ink-3); font-size: 0.85rem; }
.danger-link { color: var(--late); }
.dests li.request { grid-template-columns: 16px 1fr; align-items: start; }
.dests li.request .dest-mark { margin-top: 5px; }
.dest-kind { overflow-wrap: anywhere; }
.request .req-actions { grid-column: 2; display: flex; gap: 18px; }
#view-not-linked > div { display: grid; gap: 16px; }
#view-not-linked .primary { justify-self: start; }

.dest-add { display: grid; gap: 18px; margin-top: 18px; }
.dest-add .device { display: grid; gap: 6px; justify-items: start; }
.inline { display: flex; gap: 8px; }
.inline input { flex: 1; min-width: 0; }
.inline button { white-space: nowrap; }
#view-account .panel .actions { margin-top: 18px; }

/* ---------- trip notification choices ---------- */
fieldset.sendto { border: 0; margin: 6px 0 0; padding: 0; display: grid; gap: 6px; }
fieldset.sendto:empty { display: none; }
fieldset.sendto legend { font-weight: 600; font-size: 0.95rem; padding: 0; margin-bottom: 6px; }
.check-row { display: flex; align-items: center; gap: 10px; font-weight: 400; overflow-wrap: anywhere; }
.check-row input { width: 18px; height: 18px; flex: none; accent-color: var(--action); }
.trip-edit fieldset.sendto { margin-top: 2px; }

.banner.info { border-left-color: var(--action); }

/* ---------- device tips (install to Home Screen, turn on alerts) ---------- */
.tip {
  margin-top: 14px; padding: 14px 16px; border-radius: var(--radius-panel);
  background: var(--panel); box-shadow: var(--shadow); border: 1.5px solid var(--action);
  display: grid; gap: 10px;
}
.tip p { color: var(--ink-2); font-size: 0.95rem; }
.tip strong { color: var(--ink); display: block; margin-bottom: 2px; }
.tip-actions { display: flex; align-items: center; gap: 16px; }
.tip-close { justify-self: start; border: 0; background: none; padding: 0; color: var(--ink-3); font-weight: 600; }
.share-glyph { width: 15px; height: 18px; vertical-align: -3px; color: var(--action); margin: 0 1px; }
.nowrap { white-space: nowrap; font-weight: 600; color: var(--ink); }
.banner a, .hint a { color: var(--action); font-weight: 600; }

/* ---------- adding a trip ---------- */
.add { margin-top: 28px; }
/* "Add a trip" floats at the bottom right while the list scrolls under it (inside the page's
   680px column on a wide screen); the list leaves room for it at the end */
.add-closed { position: fixed; z-index: 15; bottom: calc(20px + env(safe-area-inset-bottom));
  right: max(16px, calc((100vw - 680px) / 2 + 16px)); }
.add-closed[hidden] { display: none; }
.add-closed .primary { border-radius: 999px; padding: 14px 20px; box-shadow: 0 6px 20px rgb(0 0 0 / 0.28); }
.add-closed .primary span { font-weight: 800; margin-right: 2px; }
.add-closed .trip-count { display: none; }
#view-main { padding-bottom: 72px; }
.add-form { margin-top: 0; }
.trip-fields { display: grid; gap: 12px; }
.trip-fields > label, .tf-stations label { display: grid; gap: 6px; }
.tf-stations { display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto; column-gap: 8px; row-gap: 10px; }
.tf-stations label:first-child { grid-column: 1; grid-row: 1; }
.tf-stations label:last-child { grid-column: 1; grid-row: 2; }
.tf-swap {
  grid-column: 2; grid-row: 1 / span 2; align-self: center; margin-top: 22px;
  width: 40px; height: 40px; border-radius: 999px; border: 1px solid var(--rule); background: var(--panel);
  color: var(--action); display: grid; place-items: center; padding: 0;
}
.tf-swap svg { width: 20px; height: 20px; }
.tf-row { display: flex; gap: 10px; align-items: stretch; flex-wrap: wrap; }
.tf-row .seg { flex: 1 1 auto; }
input[type="time"], input[type="date"] {
  padding: 9px 12px; border-radius: var(--radius-ctl); border: 1px solid var(--rule);
  background: var(--ground); font-size: 1rem; font-variant-numeric: tabular-nums; min-height: 44px;
}
input[type="time"] { flex: 0 0 auto; width: 8.5em; }
.tf-time-hint { margin-top: -6px; }
.tf-days { display: grid; gap: 8px; }
.tf-label { font-weight: 600; font-size: 0.95rem; }
.tf-days input[type="date"] { justify-self: start; }
.tf-train .quiet { font-weight: 400; }

/* segmented control: radios styled as one row of buttons */
.seg { display: flex; border: 1px solid var(--rule); border-radius: var(--radius-ctl); overflow: hidden; background: var(--ground); }
.seg label { flex: 1 1 auto; display: flex; font-weight: 600; min-width: 0; }
.seg label + label { border-left: 1px solid var(--rule); }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg span { flex: 1; text-align: center; padding: 10px 4px; font-size: 0.88rem; cursor: pointer; color: var(--ink-2); white-space: nowrap; }
.seg input:checked + span { background: var(--action); color: var(--action-ink); }
.seg input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: -3px; }

.day-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.day-chips label { flex: 1 0 40px; display: flex; }
.day-chips input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.day-chips span {
  flex: 1; text-align: center; padding: 8px 0; border-radius: var(--radius-ctl); border: 1px solid var(--rule);
  cursor: pointer; font-weight: 600; font-size: 0.88rem; color: var(--ink-2);
}
.day-chips input:checked + span { background: var(--action); border-color: var(--action); color: var(--action-ink); }
.day-chips input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 1px; }

.trip.fresh { animation: fresh 2.4s ease-out; }
@keyframes fresh { 0%, 40% { box-shadow: 0 0 0 3px var(--action); } 100% { box-shadow: 0 0 0 3px transparent; } }
@media (prefers-reduced-motion: reduce) { .trip.fresh { animation: none; } }
.seg label, .day-chips label { position: relative; }

/* trains around the trip's time, in the add/edit preview */
.choices { margin: 10px 0 2px; display: grid; gap: 6px; }
.choices-title { margin: 0; font-size: 0.85rem; color: var(--ink-2); }
.choices-title span { color: var(--ink-3); }
.choice { display: grid; grid-template-columns: auto 1fr auto; align-items: baseline; gap: 4px 12px;
  width: 100%; text-align: left; padding: 8px 12px; font: inherit; color: var(--ink);
  background: var(--panel); border: 1px solid var(--rule); border-radius: var(--radius-ctl); cursor: pointer; }
.choice:hover { border-color: var(--action); }
.choice:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.choice[aria-pressed="true"] { border-color: var(--action); box-shadow: inset 3px 0 0 var(--action); cursor: default; }
.choice-times { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.choice-times small { font-weight: 500; }
.choice-info { color: var(--ink-2); font-size: 0.88rem; min-width: 0; }
.choice-mark { font-size: 0.85rem; color: var(--action); font-weight: 600; }
.choice[aria-pressed="true"] .choice-mark { color: var(--ink-3); font-weight: 500; }
/* which of several stations with the name */
.places { margin: 10px 0 2px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.places .choices-title { flex-basis: 100%; }
.place { padding: 6px 12px; font: inherit; font-size: 0.9rem; color: var(--ink); background: var(--panel);
  border: 1px solid var(--rule); border-radius: 999px; cursor: pointer; }
.place:hover { border-color: var(--action); }
.place:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.place[aria-pressed="true"] { border-color: var(--action); background: var(--action); color: var(--panel); cursor: default; }
@media (max-width: 480px) {
  .choice { grid-template-columns: 1fr auto; }
  .choice-info { grid-column: 1 / -1; grid-row: 2; }
}

/* the station's current time under the marker (only when its clock isn't this device's) */
.now-row { grid-column: 1 / 4; position: relative; height: 1.1rem; margin: -2px 8px 2px; }
.now { position: absolute; left: calc(var(--done) * 100%); transform: translateX(calc(var(--done) * -100%));
  font-size: 0.78rem; color: var(--ink-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.now b { font-weight: 600; color: var(--ink-2); }

/* "Use my location" under the From field */
.tf-here-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; font-size: 0.85rem; }
.tf-here { font-size: 0.85rem; padding: 0; }
.tf-here:disabled { color: var(--ink-3); cursor: default; text-decoration: none; }
.tf-near { color: var(--ink-3); }
.tf-near .link-btn { font-size: 0.85rem; padding: 0; }

/* the back of a trip card (tap the card, or Details) */
.trip-actions { display: inline-flex; align-items: center; gap: 14px; }
.trip.flipped > :not(.trip-back) { display: none; }
.trip-back { display: grid; gap: 10px; }
.back-trip { margin: -4px 0 10px; font-weight: 600; color: var(--ink); overflow-wrap: anywhere; }
.back-trip .quiet { font-weight: 400; color: var(--ink-3); }
.back-body { display: grid; gap: 10px; min-width: 0; }
.back-stops { width: 100%; border-collapse: collapse; font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.back-stops th { text-align: left; font-weight: 600; color: var(--ink-3); font-size: 0.78rem; padding: 0 6px 4px 0; border-bottom: 1px solid var(--rule); }
.back-stops td { padding: 5px 6px 5px 0; border-bottom: 1px solid var(--rule); color: var(--ink-2); vertical-align: top; }
.back-stops td:first-child { overflow-wrap: anywhere; }
.back-stops tr.yours td { color: var(--ink); font-weight: 600; }
.back-stops tr.outside td { color: var(--ink-3); }
.back-stops td.moved, .back-stops tr.yours td.moved { color: var(--late); }
.back-how { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; font-size: 0.82rem; }
.back-how dt { color: var(--ink-3); white-space: nowrap; }
.back-how dd { margin: 0; color: var(--ink-2); overflow-wrap: anywhere; }
.back-ids { padding-top: 8px; border-top: 1px solid var(--rule); }
.back-ids code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; user-select: all; -webkit-user-select: all; }

/* ---------- admin: health, trips, one trip ---------- */
.adm-tabs { display: flex; gap: 4px; background: var(--panel); border: 1px solid var(--rule); border-radius: 12px; padding: 4px; margin: 4px 0 16px; }
.adm-tabs a { flex: 1; text-align: center; padding: 9px 0; border-radius: 9px; color: var(--ink-2); font-weight: 600; font-size: 0.9rem; text-decoration: none; }
.adm-tabs a[aria-current="page"] { background: var(--rule); color: var(--ink); font-weight: 700; }
#admin-body { display: grid; gap: 14px; }
.adm-h { margin: 0 0 8px; font-size: 0.78rem; font-weight: 700; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.06em; }
.adm-pad { padding: 12px 16px 4px; margin: 0; }
.adm-panel { display: grid; gap: 8px; }
.adm-flush { padding: 0 0 6px; gap: 0; }
.adm-risk { border: 1px solid var(--late); border-radius: var(--radius-panel); padding: 14px 16px; display: grid; gap: 10px;
  background: color-mix(in srgb, var(--late) 8%, var(--panel)); }
.adm-risk h2 { margin: 0; font-size: 1rem; color: var(--late); }
.adm-risk-item, .adm-trip { display: grid; gap: 3px; padding: 10px 12px; border-radius: 10px; text-decoration: none; color: var(--ink);
  background: var(--panel); border: 1px solid var(--rule); }
.adm-trip.risk { border-color: var(--late); }
.adm-trip.dim { opacity: 0.65; }
.adm-who { display: flex; justify-content: space-between; gap: 8px; font-size: 0.82rem; color: var(--ink-2); }
.adm-what { font-weight: 700; font-size: 0.98rem; overflow-wrap: anywhere; }
.adm-why { font-size: 0.85rem; color: var(--late); line-height: 1.4; }
.adm-meta { font-size: 0.82rem; color: var(--ink-3); overflow-wrap: anywhere; }
.adm-tag { font-weight: 700; }
.adm-tag.good { color: var(--go); } .adm-tag.warn { color: var(--warn); } .adm-tag.bad { color: var(--late); }
.adm-feeds { padding: 0 0 4px; }
.adm-feed { border-top: 1px solid var(--rule); }
.adm-feed:first-of-type { border-top: 0; }
.adm-feed-row { width: 100%; background: none; border: 0; color: inherit; text-align: left; cursor: pointer; font: inherit;
  padding: 11px 16px; display: grid; grid-template-columns: 12px 1fr 76px; gap: 2px 10px; align-items: center; min-height: 52px; }
.adm-feed-name { font-weight: 700; }
.adm-feed-line { font-size: 0.82rem; color: var(--ink-2); }
.adm-feed-line.down { color: var(--late); } .adm-feed-line.warn { color: var(--warn); }
.adm-feed-row .adm-spark { grid-row: span 2; }
.adm-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--unknown); }
.adm-dot.ok { background: var(--go); } .adm-dot.warn { background: var(--warn); } .adm-dot.down { background: var(--late); }
.adm-logs { margin: 0 16px 12px 38px; display: grid; gap: 6px; }
.adm-logs div, .adm-warn { font-size: 0.8rem; line-height: 1.45; color: var(--ink-2); overflow-wrap: anywhere; }
.adm-logs div { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--ground); border-radius: 8px; padding: 7px 9px; }
.adm-warn b { color: var(--warn); } .adm-warn b.bad, .adm-stats b.bad { color: var(--late); }
.adm-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.adm-stats div { display: grid; gap: 2px; } .adm-stats span { font-size: 0.75rem; color: var(--ink-3); }
.adm-stats b { font-size: 1.2rem; font-weight: 800; }
.adm-panel .adm-spark { width: 100%; height: 40px; }
.adm-search { display: grid; gap: 6px; font-size: 0.85rem; color: var(--ink-3); }
.adm-search input { font: inherit; font-size: 1rem; height: 46px; padding: 0 14px; border-radius: 12px;
  border: 1px solid var(--rule); background: var(--panel); color: var(--ink); }
.adm-dl a { color: var(--action); }
.adm-group { display: grid; gap: 8px; }
.adm-group .adm-h { margin: 6px 4px 0; }
.adm-trip-head { display: grid; gap: 4px; }
.adm-trip-head h2 { margin: 0; font-size: 1.35rem; line-height: 1.25; }
.adm-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.adm-chip { font-size: 0.8rem; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: var(--panel); border: 1px solid var(--rule); color: var(--ink-2); }
.adm-chip.good { color: var(--go); } .adm-chip.warn { color: var(--warn); } .adm-chip.bad { color: var(--late); border-color: var(--late); }
.adm-dl { margin: 0; display: grid; grid-template-columns: minmax(90px, 32%) 1fr; gap: 7px 12px; font-size: 0.9rem; }
.adm-dl dt { color: var(--ink-3); } .adm-dl dd { margin: 0; overflow-wrap: anywhere; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.82rem; }
.adm-ev { display: grid; grid-template-columns: 62px 10px 1fr; gap: 10px; align-items: start; font-size: 0.88rem; padding: 4px 0; }
.adm-ev-t { font-weight: 700; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.adm-ev-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; }
.adm-stop { display: grid; grid-template-columns: 1fr 76px 96px; gap: 8px; align-items: center; padding: 8px 16px; border-top: 1px solid var(--rule); font-size: 0.9rem; }
.adm-stop.yours { background: color-mix(in srgb, var(--action) 10%, var(--panel)); font-weight: 700; }
.adm-stop.outside { color: var(--ink-3); }
.adm-stop .num { font-variant-numeric: tabular-nums; }
.adm-raw summary { cursor: pointer; margin: 0; list-style: none; min-height: 28px; }
.adm-raw-doc { display: grid; gap: 4px; margin-top: 8px; }
.adm-raw pre { margin: 0; white-space: pre-wrap; word-break: break-all; font-size: 0.72rem; line-height: 1.45; color: var(--ink-2); background: var(--ground); border-radius: 8px; padding: 10px; max-height: 360px; overflow: auto; }

/* "Trains": the trains before and after this one today, to take another */
.trip-switch { display: grid; gap: 10px; border-top: 1px solid var(--rule); padding-top: 12px; }
.switch-title { margin: 0; font-weight: 700; font-size: 0.95rem; }
.switch-list { display: grid; gap: 6px; }
.switch-row { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: center; text-align: left;
  padding: 10px 12px; min-height: 52px; border-radius: 10px; border: 1px solid var(--rule); background: var(--panel);
  color: var(--ink); font: inherit; cursor: pointer; }
.switch-row[aria-checked="true"] { border-color: var(--action); box-shadow: inset 0 0 0 1px var(--action);
  background: color-mix(in srgb, var(--action) 10%, var(--panel)); }
.switch-row.current { background: var(--ground); cursor: default; }
.switch-row.left { opacity: 0.55; cursor: default; }
.switch-times { font-weight: 800; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.switch-train { grid-column: 1; font-size: 0.82rem; color: var(--ink-3); }
.switch-tag { grid-column: 2; grid-row: 1 / span 2; font-size: 0.85rem; font-weight: 600; color: var(--ink-2); }
.switch-row.current .switch-tag { color: var(--action); }
.switch-tag.late { color: var(--late); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- railroads right now ---------- */
.forecast-strip { display: grid; margin-top: 14px; border-radius: var(--radius-ctl); background: var(--panel);
  box-shadow: var(--shadow); overflow: hidden; }
.forecast-strip .fc-item { display: grid; grid-template-columns: 1.5em 1fr auto; gap: 8px; align-items: baseline;
  padding: 10px 14px; color: var(--ink-2); font-size: 0.92rem; text-decoration: none; }
.forecast-strip .fc-item + .fc-item { border-top: 1px solid var(--rule); }
.forecast-strip b { color: var(--ink); margin-right: 4px; }
.forecast-strip .fc-go { color: var(--action); font-size: 1.3rem; line-height: 1; align-self: center; }
.net-intro { margin: 0 4px; }
.net-agency { margin-top: 18px; }
.net-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.net-head h2 { margin: 0; }
.net-headline { margin: 6px 0 2px; font-size: 1.05rem; font-weight: 700; }
.net-agency > .banner { margin: 8px 0; }
.net-lines { margin-top: 12px; border-top: 1px solid var(--rule); }
.net-line { border-bottom: 1px solid var(--rule); }
.net-line summary { display: grid; grid-template-columns: 1.6em minmax(4.5em, auto) 1fr; gap: 4px 10px; align-items: baseline;
  padding: 10px 0; cursor: pointer; list-style: none; }
.net-line summary::-webkit-details-marker { display: none; }
.net-icon { text-align: center; }
.net-name { font-weight: 700; display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
/* a line's own color (its timetable's, as on its maps): a short stripe, not a dot, so it doesn't read as a status */
.net-name i { width: 4px; height: 1em; border-radius: 2px; flex: none; }
.net-yours { padding: 0 6px; border-radius: 999px; background: var(--ground); color: var(--ink-2); font-size: 0.72rem; font-weight: 600; }
.net-text { color: var(--ink-2); font-size: 0.92rem; min-width: 0; }
.net-line.stormy .net-text, .net-line.rough .net-text { color: var(--ink); }
.net-line.quiet .net-text { color: var(--ink-3); }
.net-more { padding: 0 0 12px calc(1.6em + 10px); font-size: 0.88rem; }
.net-more h4 { margin: 10px 0 4px; font-size: 0.78rem; font-weight: 600; color: var(--ink-3); }
.net-trains, .net-notes { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; }
.net-trains li { display: grid; grid-template-columns: 4.2em 5.5em 1fr; gap: 8px; }
.net-trains .ok { color: var(--go); } .net-trains .late { color: var(--warn); font-weight: 600; }
.net-trains .bad { color: var(--late); font-weight: 700; } .net-trains .unknown { color: var(--ink-3); }
.net-near { color: var(--ink-3); }
.net-notes li { color: var(--ink-2); overflow-wrap: anywhere; }
.net-notes .net-out { color: var(--late); font-weight: 600; }
.net-everywhere { margin-top: 8px; font-size: 0.88rem; }
@media (max-width: 420px) {
  .net-line summary { grid-template-columns: 1.6em 1fr; }
  .net-text { grid-column: 2; }
}
.net-dot { display: inline-block; width: 6px; height: 0.8em; border-radius: 3px; margin-right: 12px; vertical-align: -0.02em; }
.net-one { margin-top: 18px; font-size: 0.92rem; }
.net-one-head { display: flex; gap: 10px; font-size: 1.05rem; font-weight: 700; margin-bottom: 12px; }
.net-one .net-trains, .net-one .net-notes { margin-bottom: 4px; }
.net-why { display: block; font-weight: 400; color: var(--ink-2); }
.net-all { margin: 16px 4px; }
.net-all a { color: var(--action); font-weight: 600; text-decoration: none; }
.adm-legend { margin: -4px 0 6px; line-height: 1.4; }
