:root {
  color-scheme: light;
  --ink: var(--aa-text); --muted: var(--aa-muted); --brand: #0b3b52; --brand-hover: #075b72;
  --accent: #f5c84c; --surface: var(--aa-surface); --canvas: var(--aa-page); --line: var(--aa-line);
  --focus: var(--aa-focus); --danger: #8b1e1e; --success: #17643a; --bus-outline: #142d3b;
  --shadow: var(--aa-shadow); --safe-top: max(.65rem, env(safe-area-inset-top));
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
:root[data-theme="dark"] { color-scheme: dark; --brand: #7bd4ee; --brand-hover: #a0e8fa; --accent: #ffcf69; --danger: #ff9e9e; --success: #81daa7; --bus-outline: #fff; }
:root[data-text-size="large"] { font-size: 1.15rem; }
:root[data-contrast="high"] { --line: #43545b; --muted: #3d4a50; --focus: #a33b00; }
:root[data-theme="dark"][data-contrast="high"] { --line: #d3e1e7; --muted: #d0dce1; --focus: #ffcf69; }
* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; }
body { color: var(--ink); background: var(--canvas); overflow: hidden; font-size: 1rem; line-height: 1.5; }
button, input, select { font: inherit; }
a { color: var(--brand-hover); text-underline-offset: .18em; }
a:hover { text-decoration-thickness: 2px; }
button, a, input, select, summary { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--focus) !important; outline-offset: 3px !important; }
.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0,0,0,0) !important; white-space: nowrap !important; border: 0 !important; }
.skip-link { position: fixed; z-index: 3000; top: var(--safe-top); left: .75rem; padding: .7rem 1rem; transform: translateY(-160%); background: var(--surface); border: 2px solid var(--brand); border-radius: .45rem; color: var(--ink); font-weight: 700; }
.skip-link:focus { transform: none; }
#main-content, #map { position: fixed; inset: 0; width: 100%; height: 100%; }
#map { z-index: 0; background: #dce8eb; }
.map-topbar { position: fixed; z-index: 1000; top: var(--safe-top); left: 50%; transform: translateX(-50%); width: min(76rem, calc(100% - 1.25rem)); padding: .65rem; border: 1px solid var(--line); border-radius: .9rem; background: var(--surface); box-shadow: var(--shadow); }
.brand-row { display: flex; align-items: center; gap: 1rem; min-height: 2.5rem; }
.brand { display: inline-flex; align-items: baseline; gap: .65rem; min-width: max-content; color: var(--brand); text-decoration: none; font-size: 1.15rem; font-weight: 850; letter-spacing: -.02em; }
.brand span { color: var(--muted); font-size: .92rem; font-weight: 600; letter-spacing: 0; }
.bus-details-heading { display: flex; align-items: center; gap: .8rem; clear: both; }
.bus-details-heading img { flex: 0 0 3.4rem; object-fit: contain; }
.eyebrow { margin: 0 .2rem; color: var(--muted); font-size: .8rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.bus-details-heading h2 { margin: .1rem .2rem; color: var(--brand); font-size: 1.3rem; }
.home-link { margin-left: auto; padding: .35rem .6rem; font-weight: 700; white-space: nowrap; }
.map-status { display: flex; align-items: center; gap: .45rem; margin: 0 auto 0 0; color: var(--muted); font-size: .88rem; }
.status-dot { width: .62rem; height: .62rem; flex: 0 0 .62rem; border-radius: 50%; background: #a86a00; box-shadow: 0 0 0 3px rgb(245 200 76 / 30%); }
.map-status[data-state="loading"] .status-dot { animation: status-pulse 1.4s ease-in-out infinite; }
@keyframes status-pulse { 50% { opacity: .35; transform: scale(.82); } }
.map-status[data-state="live"] .status-dot { background: var(--success); }
.map-status[data-state="error"] .status-dot { background: var(--danger); }
.toolbar-row { display: grid; grid-template-columns: minmax(13rem, 1fr) repeat(6, auto); align-items: center; gap: .5rem; margin-top: .55rem; }
#bus-search { width: 100%; min-width: 0; min-height: 2.75rem; padding: .55rem .75rem; border: 1px solid #718791; border-radius: .5rem; background: var(--surface); color: var(--ink); }
#bus-search::placeholder { color: var(--muted); opacity: 1; }
.toolbar-button, .icon-button { display: inline-flex; align-items: center; justify-content: center; min-height: 2.75rem; padding: .55rem .8rem; border: 1px solid var(--brand); border-radius: .5rem; background: var(--brand); color: var(--aa-button-text); text-align: center; text-decoration: none; font-weight: 700; cursor: pointer; white-space: nowrap; }
.toolbar-button:hover, .icon-button:hover { background: var(--brand-hover); color: var(--aa-button-text); text-decoration: none; }
.toolbar-button.secondary, .icon-button { background: var(--surface); color: var(--brand); }
.toolbar-button.secondary:hover, .icon-button:hover { background: color-mix(in srgb, var(--surface) 84%, var(--brand) 16%); }
.map-summary { position: fixed; z-index: 800; left: .9rem; bottom: max(.9rem, env(safe-area-inset-bottom)); display: grid; gap: .12rem; max-width: min(24rem, calc(100vw - 1.8rem)); padding: .6rem .8rem; border: 1px solid var(--line); border-radius: .65rem; background: var(--surface); box-shadow: var(--shadow); font-size: .88rem; }
.map-summary span { color: var(--muted); }
.map-summary #map-area-note { font-size: .82rem; }
.search-results { position: fixed; z-index: 1000; top: calc(var(--safe-top) + 7.25rem); left: max(.75rem, calc((100vw - 76rem) / 2)); width: min(23rem, calc(100vw - 1.5rem)); max-height: min(50vh, 30rem); overflow: auto; padding: .85rem; border: 1px solid var(--line); border-radius: .75rem; background: var(--surface); box-shadow: var(--shadow); }
.search-results[hidden] { display: none; }
.search-results h2 { margin: 0 0 .25rem; font-size: 1rem; }
.search-result-count { margin: 0 0 .45rem; color: var(--muted); font-size: .88rem; }
.search-results ul { display: grid; gap: .35rem; margin: 0; padding: 0; list-style: none; }
.search-results li button { display: grid; width: 100%; gap: .1rem; padding: .55rem .65rem; border: 1px solid var(--line); border-radius: .5rem; background: var(--surface); color: var(--ink); text-align: left; cursor: pointer; }
.search-results li button:hover { border-color: var(--brand); }
.search-results li strong { color: var(--brand); }
.search-results li span { color: var(--muted); font-size: .88rem; }
.map-help { position: fixed; z-index: 800; right: .9rem; bottom: max(.9rem, env(safe-area-inset-bottom)); width: min(19rem, calc(100vw - 1.8rem)); border: 1px solid var(--line); border-radius: .65rem; background: var(--surface); box-shadow: var(--shadow); }
.map-help summary { padding: .6rem .8rem; color: var(--brand); font-weight: 750; cursor: pointer; }
.map-help div { padding: 0 .8rem .8rem; font-size: .9rem; }
.map-help p { margin: .4rem 0; }
.leaflet-top { top: calc(var(--safe-top) + 7.35rem); }
.leaflet-left { left: .65rem; }
.leaflet-right { right: .65rem; }
.leaflet-control-zoom, .leaflet-control-layers, .leaflet-control-locate { border: 1px solid var(--line) !important; border-radius: .55rem !important; box-shadow: var(--shadow) !important; }
.leaflet-control-zoom a { color: var(--brand) !important; background: var(--surface) !important; }
.leaflet-control-layers { color: var(--ink); background: var(--surface); }
.leaflet-control-layers-toggle { width: 44px !important; height: 44px !important; background-size: 24px 24px; }
.leaflet-control-locate { display: none; }
.leaflet-control-attribution { background: var(--surface) !important; color: var(--muted) !important; }
:root[data-theme="dark"] .leaflet-popup-content-wrapper, :root[data-theme="dark"] .leaflet-popup-tip { background: var(--surface); color: var(--ink); }
.accessaid-bus-icon { border: 0 !important; background: transparent !important; }
.bus-marker { display: flex; width: 64px; height: 86px; flex-direction: column; align-items: center; justify-content: flex-end; gap: 1px; color: var(--route-colour, #075b72); filter: drop-shadow(0 1px 2px rgb(16 42 54 / 45%)); }
:root[data-marker-size="large"] .bus-marker { width: 80px; height: 108px; gap: 2px; }
.bus-marker--stale { opacity: .68; }
.follow-badge { display: inline-flex; min-height: 1.05rem; align-items: center; justify-content: center; gap: .18rem; margin-bottom: 1px; padding: .05rem .27rem; border: 1px solid #142d3b; border-radius: 999px; background: #ffdc67; color: #142d3b; font-size: .55rem; font-weight: 900; line-height: 1; text-transform: uppercase; white-space: nowrap; box-shadow: 0 1px 2px rgb(0 0 0 / 40%); }
.bus-direction { display: flex; min-height: 19px; align-items: center; justify-content: center; color: var(--route-colour, #075b72); font-size: 1.05rem; line-height: 1; text-shadow: 0 1px 2px #fff, 0 -1px 2px #fff; }
.bus-heading { transform-origin: 50% 50%; }
.route-number { display: block; max-width: 50px; overflow: hidden; padding: .12rem .38rem; border: 2px solid #fff; border-radius: .35rem; background: var(--route-colour, #075b72); color: #fff; font-size: .82rem; font-weight: 850; line-height: 1.2; text-shadow: 0 1px 1px #000; text-overflow: ellipsis; white-space: nowrap; }
.bus-symbol { color: var(--route-colour, #075b72); font-size: 1.6rem; line-height: 1; -webkit-text-stroke: 1px var(--bus-outline); }
:root[data-marker-size="large"] .route-number { max-width: 64px; font-size: 1rem; }
:root[data-marker-size="large"] .bus-direction { min-height: 24px; font-size: 1.3rem; }
:root[data-marker-size="large"] .bus-symbol { font-size: 2rem; }
:root[data-marker-size="large"] .follow-badge { min-height: 1.3rem; font-size: .68rem; }
:root[data-contrast="high"] .route-number { border: 2px solid #fff; box-shadow: 0 0 0 2px #111; }
.map-settings { position: relative; }
.history-control { position: relative; }
.history-control summary { display: grid; min-height: 2.75rem; place-items: center; padding: .55rem .8rem; border: 1px solid var(--brand); border-radius: .5rem; background: var(--surface); color: var(--brand); font-weight: 700; cursor: pointer; white-space: nowrap; }
.history-control[open] { z-index: 1300; }
.history-panel { position: absolute; top: calc(100% + .35rem); right: 0; display: grid; gap: .4rem; width: min(22rem, calc(100vw - 1.5rem)); padding: .8rem; border: 1px solid var(--line); border-radius: .65rem; background: var(--surface); box-shadow: var(--shadow); }
.history-panel p { display: grid; gap: .1rem; margin: 0; }
.history-panel p span { color: var(--muted); font-size: .84rem; }
.history-panel input[type="range"] { width: 100%; min-height: 2.4rem; accent-color: var(--brand-hover); }
.history-panel output { color: var(--brand); font-size: .9rem; font-weight: 750; }
.history-panel button { white-space: normal; }
.history-control[open] .history-panel, .map-settings[open] .settings-grid, .search-results:not([hidden]) { animation: accessaid-panel-in .16s ease-out; }
@keyframes accessaid-panel-in { from { opacity: 0; transform: translateY(-.25rem); } to { opacity: 1; transform: translateY(0); } }
.map-summary, .map-status, .accessaid-banner { transition: opacity .16s ease, background-color .16s ease; }
.bus-marker { transition: opacity .15s ease, filter .15s ease; }
.map-settings summary { display: grid; min-height: 2.75rem; place-items: center; padding: .55rem .8rem; border: 1px solid var(--brand); border-radius: .5rem; background: var(--surface); color: var(--brand); font-weight: 700; cursor: pointer; white-space: nowrap; }
.map-settings[open] { z-index: 1300; }
.map-settings label { display: block; padding: .65rem .75rem .2rem; color: var(--ink); font-weight: 700; }
.map-settings select { margin: 0 .65rem .65rem; padding: .5rem; border: 1px solid var(--line); border-radius: .4rem; background: var(--surface); color: var(--ink); }
.map-settings .settings-grid { position: absolute; top: calc(100% + .35rem); right: 0; display: grid; grid-template-columns: minmax(8rem, 1fr) minmax(10rem, 1.2fr); align-items: center; gap: .35rem .65rem; width: min(25rem, calc(100vw - 1.5rem)); padding: .75rem; border: 1px solid var(--line); border-radius: .65rem; background: var(--surface); box-shadow: var(--shadow); }
.map-settings .settings-grid label { padding: 0; }
.map-settings .settings-grid select { width: 100%; margin: 0; min-height: 2.5rem; }
.map-settings .settings-grid button { grid-column: 1 / -1; }
.tflo-setting { grid-column: 1 / -1; display: grid; grid-template-columns: auto 1fr; align-items: center; gap: .15rem .65rem; padding: .5rem; border-top: 1px solid var(--line); }
.tflo-setting label { font-weight: 750; }
.tflo-setting input { width: 1.25rem; height: 1.25rem; accent-color: var(--brand-hover); }
.tflo-setting span { grid-column: 2; color: var(--muted); font-size: .82rem; }
.operator-layer-setting { grid-column: 1 / -1; padding: .4rem .5rem; border-top: 1px solid var(--line); }
.operator-layer-setting summary { padding: .25rem 0; color: var(--brand); font-weight: 750; cursor: pointer; }
.operator-layer-setting #operator-layer-control .leaflet-control-layers { margin: .35rem 0 0; border: 0 !important; box-shadow: none !important; }
.operator-layer-setting #operator-layer-control .leaflet-control-layers-toggle { display: none; }
.operator-layer-setting #operator-layer-control > .leaflet-control-layers { width: 100%; }
.operator-layer-setting #operator-layer-control .leaflet-control-layers-list { max-height: 14rem; overflow: auto; }
.accessaid-banner { position: fixed; z-index: 1100; left: 50%; max-width: min(92vw, 42rem); transform: translateX(-50%); padding: .7rem .95rem; border: 1px solid var(--line); border-radius: .6rem; color: var(--aa-button-text); text-align: center; box-shadow: var(--shadow); }
.accessaid-banner.map-guidance { top: auto !important; bottom: max(5.5rem, env(safe-area-inset-bottom)); display: grid; gap: .6rem; width: min(38rem, calc(100vw - 1rem)); padding: .8rem; border-color: #6c4b00; background: #fff4cf; color: #2d260e; }
.map-guidance-message { margin: 0; font-weight: 750; }
.map-guidance-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: .5rem; }
.map-guidance-actions button, .map-guidance-actions a, .map-retry-button { display: inline-flex; min-height: 2.7rem; align-items: center; justify-content: center; padding: .45rem .8rem; border: 1px solid #563d00; border-radius: .45rem; background: #fff; color: #2d260e; font: inherit; font-weight: 750; text-decoration: underline; cursor: pointer; }
.map-retry-button { display: block; margin: .5rem auto 0; border-color: currentColor; }
:root[data-theme="dark"] .accessaid-banner.map-guidance { border-color: #f5ce68; background: #302a18; color: #fff4cf; }
:root[data-theme="dark"] .map-guidance-actions button, :root[data-theme="dark"] .map-guidance-actions a, :root[data-theme="dark"] .map-retry-button { border-color: #f5ce68; background: #1d1d1d; color: #fff4cf; }
:root[data-contrast="high"] .accessaid-banner.map-guidance { border-width: 2px; }
.warning-popup, #render-cap-popup { z-index: 1050; }
.modal { display: none; position: fixed; z-index: 2000; inset: 0; overflow: auto; padding: max(1rem, env(safe-area-inset-top)) 1rem max(1rem, env(safe-area-inset-bottom)); background: rgb(10 27 35 / 72%); }
.modal[aria-hidden="false"] { display: grid; place-items: center; }
.modal-content { position: relative; width: min(42rem, 100%); max-height: 92vh; overflow: auto; padding: clamp(1.1rem, 3vw, 1.75rem); border: 1px solid var(--line); border-radius: .9rem; background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.close { position: sticky; top: 0; float: right; display: grid; place-items: center; width: 2.75rem; height: 2.75rem; margin: -.4rem -.35rem .35rem .75rem; border: 1px solid var(--line); border-radius: .5rem; background: var(--surface); color: var(--ink); font-size: 1.65rem; cursor: pointer; }
.operator-name { margin: .3rem 0 .8rem; color: var(--brand); font-size: 1.35rem; font-weight: 800; }
.route-highlight { clear: both; margin: .75rem 0; padding: .85rem; border-radius: .6rem; background: var(--route-colour, var(--brand)); color: #fff; font-size: 1.08rem; font-weight: 750; }
.vehicle-details { display: grid; grid-template-columns: minmax(8rem, .75fr) 1.25fr; gap: .45rem 1rem; margin: 1rem 0; }
.vehicle-details dt { color: var(--muted); font-weight: 650; }
.vehicle-details dd { margin: 0; overflow-wrap: anywhere; }
.vehicle-section { margin: .8rem 0; padding: .75rem; border: 1px solid var(--line); border-radius: .6rem; }
.vehicle-section summary { color: var(--brand); font-weight: 750; cursor: pointer; }
.vehicle-section dl { margin-bottom: 0; }
.warning-text, .status-text { margin: .65rem 0; padding: .7rem .8rem; border-radius: .5rem; font-weight: 650; }
.warning-text { border: 1px solid var(--danger); background: color-mix(in srgb, var(--surface) 88%, var(--danger) 12%); color: var(--danger); }
.status-text { border: 1px solid #8a5d00; background: #fff7df; color: #583c00; }
.follow-button { width: 100%; min-height: 2.8rem; margin-top: .9rem; border: 0; border-radius: .55rem; background: var(--brand); color: var(--aa-button-text); font-weight: 750; cursor: pointer; }
.follow-button.secondary-follow { border: 1px solid var(--brand); background: var(--surface); color: var(--brand); }
.disclaimer { color: var(--muted); font-size: .9rem; }
.noscript-message { position: fixed; z-index: 3000; top: 1rem; left: 1rem; padding: 1rem; background: var(--surface); }
@media (max-width: 900px) {
  .toolbar-row { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .35rem; }
  #bus-search { grid-column: 1 / -1; }
  .toolbar-button, .icon-button { min-height: 2.5rem; padding: .45rem .5rem; font-size: .88rem; }
}
@media (min-width: 901px) and (max-width: 1100px) {
  .toolbar-row { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  #bus-search { grid-column: 1 / -1; }
  .toolbar-button, .icon-button, .history-control, .map-settings { width: 100%; }
}
@media (max-width: 760px) {
  .map-topbar { width: calc(100% - 1rem); padding: .55rem; border-radius: .7rem; }
  .brand-row { flex-wrap: wrap; gap: .2rem .7rem; min-height: auto; }
  .brand { font-size: 1.05rem; }
  .brand span { font-size: .82rem; }
  .map-status { order: 3; width: calc(100% - 5rem); font-size: .8rem; }
  .home-link { font-size: .9rem; }
  .leaflet-top { top: calc(var(--safe-top) + 12rem); }
  .time-travel { top: calc(var(--safe-top) + 12rem); }
  .leaflet-left { left: .4rem; }
  .leaflet-right { right: .4rem; }
  .search-results { top: calc(var(--safe-top) + 11.8rem); left: .5rem; }
  .map-summary { bottom: max(.55rem, env(safe-area-inset-bottom)); left: .5rem; font-size: .82rem; }
  .map-help { right: .5rem; bottom: max(.55rem, env(safe-area-inset-bottom)); width: auto; max-width: 13rem; }
  .vehicle-details { grid-template-columns: 1fr; gap: .1rem; }
  .vehicle-details dd { margin-bottom: .45rem; }
}
@media (max-width: 390px) {
  .toolbar-row { grid-template-columns: 1fr 1fr; }
  .toolbar-row #bus-search { grid-column: 1 / -1; }
  .toolbar-row .icon-button { grid-column: 1 / -1; }
  .toolbar-button, .icon-button { font-size: .82rem; }
  .map-status { font-size: .76rem; }
  .leaflet-top { top: calc(var(--safe-top) + 13.25rem); }
  .search-results { top: calc(var(--safe-top) + 13rem); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
:root[data-motion="reduced"] *, :root[data-motion="reduced"] *::before, :root[data-motion="reduced"] *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
