:root {
  --bg: #F3F6F9; --card: #FFFFFF; --text: #0E1A26; --muted: #5B6B7B; --border: #DCE3EA; --accent: #0B5A8A;
  --down: #1E9E5A; --window: #3A7BD5; --likely: #C98608; --up: #D93636;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0A1520; --card: #13212E; --text: #EAF1F7; --muted: #93A4B5; --border: #22374A; --accent: #5DB3E6; color-scheme: dark; }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}
main {
  max-width: 560px; margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 40px max(16px, env(safe-area-inset-left));
}
h1 { font-size: 30px; font-weight: 800; margin: 8px 0 0; }
h2 { font-size: 17px; margin: 0 0 8px; }
.sub { color: var(--muted); font-size: 14px; margin: 2px 0 16px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 16px; margin-bottom: 14px; }
.loading { color: var(--muted); text-align: center; padding: 40px 0; }
.error { color: var(--up); font-weight: 600; }
.notice { color: var(--accent); font-weight: 600; }

.bridge .head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.bridge .name { font-size: 20px; margin: 0; }
.since { color: var(--muted); font-size: 13px; }
.banner { border-radius: 12px; padding: 14px 16px; color: #fff; }
.banner .label { font-size: 26px; font-weight: 800; }
.banner .hint { font-size: 14px; opacity: .95; margin-top: 2px; }
.state-down .banner { background: var(--down); }
.state-window .banner { background: var(--window); }
.state-likely .banner { background: var(--likely); }
.state-up .banner { background: var(--up); }
.state-closed .banner { background: #4A5563; }
.reasons { color: var(--muted); font-size: 13px; margin: 10px 0 0; }
.reasons:empty { display: none; }
.next { margin: 10px 0 0; font-size: 15px; }
.report { display: flex; align-items: center; gap: 8px; margin-top: 14px; }
.report span { flex: 1; color: var(--muted); font-size: 13px; }
.btn {
  font: inherit; font-weight: 700; font-size: 14px; background: none; border: 1.5px solid; border-radius: 20px;
  padding: 6px 14px; cursor: pointer; min-height: 36px;
}
.btn.up { color: var(--up); border-color: var(--up); }
.btn.down { color: var(--down); border-color: var(--down); }
.btn:disabled { opacity: .5; cursor: default; }

#schedule { list-style: none; margin: 0; padding: 0; }
#schedule li { display: flex; padding: 4px 0; font-size: 15px; }
#schedule time { width: 64px; font-weight: 700; }
#schedule span { color: var(--muted); }

.row { display: flex; align-items: center; gap: 12px; padding: 8px 0; cursor: pointer; }
.row span { flex: 1; }
.row b { display: block; font-size: 15px; }
.row small { display: block; color: var(--muted); font-size: 12px; }
.row:has(input:disabled) b { color: var(--muted); }
.switch {
  appearance: none; -webkit-appearance: none; width: 50px; height: 30px; border-radius: 15px;
  background: var(--border); position: relative; cursor: pointer; transition: background .2s; flex: none; margin: 0;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .2s;
}
.switch:checked { background: var(--down); }
.switch:checked::after { transform: translateX(20px); }
.switch:disabled { opacity: .5; cursor: default; }
.switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.install { background: color-mix(in srgb, var(--accent) 12%, transparent); border-radius: 10px; padding: 10px 12px; font-size: 14px; margin-bottom: 8px; }
.share { white-space: nowrap; font-weight: 700; }

.foot { color: var(--muted); font-size: 12px; line-height: 1.45; margin: 6px 0 0; }
.foot:empty { display: none; }
.sponsor {
  display: flex; flex-direction: column; align-items: center; gap: 6px; margin: 20px auto 0; width: fit-content;
  color: var(--muted); font-size: 12px; font-weight: 600; text-decoration: none;
}
.sponsor img { display: block; height: 48px; width: auto; background: #fff; border-radius: 10px; padding: 6px 12px; box-sizing: content-box; }
.sponsor:hover span, .sponsor:focus-visible span { text-decoration: underline; }
@media (prefers-reduced-motion: reduce) { .switch, .switch::after { transition: none; } }

/* diagnostics */
.diag { margin-top: 18px; font-size: 13px; }
.diag summary { cursor: pointer; font-weight: 700; font-size: 15px; color: var(--muted); }
.diag[open] summary { color: var(--text); margin-bottom: 8px; }
.diag h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 14px 0 4px; }
.diag dl { display: grid; grid-template-columns: max-content 1fr; gap: 3px 12px; margin: 0; }
.diag dt { color: var(--muted); }
.diag dd { margin: 0; overflow-wrap: anywhere; }
.diag ul { margin: 0; padding-left: 18px; }
.diag li { margin: 2px 0; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.dot.ok { background: var(--down); } .dot.warn { background: var(--likely); } .dot.bad { background: var(--up); }

/* harbour notices */
.notices:empty { display: none; }
.notice-item { display: block; margin-top: 10px; padding: 8px 12px; border-radius: 10px; font-size: 13px; text-decoration: none; color: var(--text);
  border-left: 4px solid var(--likely); background: color-mix(in srgb, var(--likely) 14%, transparent); }
.notice-item.upcoming, .notice-item.recent { border-left-color: var(--window); background: color-mix(in srgb, var(--window) 12%, transparent); }
.notice-item b { display: block; }
.notice-item small { color: var(--muted); }
#schedule .usual { margin-left: auto; color: var(--muted); font-size: 13px; }
.next .expected { display: inline-block; margin-top: 4px; color: var(--muted, #667); font-size: 13px; }

/* drive times */
.journey + .journey { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); }
.journey h3 { font-size: 15px; margin: 0 0 4px; }
.journey ul { list-style: none; margin: 0; padding: 0; }
.journey li { display: flex; align-items: center; gap: 12px; padding: 5px 8px; border-radius: 8px; font-size: 15px; }
.journey .via { flex: 1; }
.journey .via small { display: block; color: var(--muted); font-size: 12px; }
.journey .via small:empty { display: none; }
.journey .via .incident { color: var(--likely); }
.journey .via .incident.closure { color: var(--up); }
.journey b { font-variant-numeric: tabular-nums; white-space: nowrap; }
.journey .best { background: color-mix(in srgb, var(--down) 14%, transparent); }
.journey .best b { color: var(--down); }
.journey .shut { color: var(--muted); }
.journey .shut b { color: var(--up); }
