:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #17212b;
  background: #eef1f4;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }
body { margin: 0; }
button, input { font: inherit; }
button { cursor: pointer; }

.app-shell { display: grid; width: 100%; max-width: 100vw; grid-template-columns: clamp(300px, 24vw, 360px) minmax(0, 1fr); height: 100vh; height: 100dvh; min-height: 620px; overflow: hidden; }
.sidebar { display: flex; flex-direction: column; min-width: 0; background: #fff; border-right: 1px solid #dfe4e8; z-index: 1000; }
.brand { display: flex; align-items: center; gap: 13px; padding: 22px 20px; color: #fff; background: #d71920; }
.brand-mark { display: grid; place-items: center; width: 51px; height: 38px; border: 2px solid #fff; border-radius: 16px; font-size: 15px; font-weight: 900; letter-spacing: -.8px; }
h1, h2, p { margin: 0; }
h1 { font-size: 20px; letter-spacing: -.4px; }
.brand p { margin-top: 3px; color: #ffd9db; font-size: 11px; }
.sidebar-content { display: flex; flex: 1; min-height: 0; flex-direction: column; padding: 18px 16px 0; }
.search { display: flex; align-items: center; gap: 8px; padding: 0 12px; border: 1px solid #d7dde2; border-radius: 8px; color: #74808b; }
.search svg, button svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2; }
.search input { min-width: 0; width: 100%; padding: 11px 0; border: 0; outline: 0; color: #273440; font-size: 13px; }
.directions-form { margin-top: 12px; padding: 11px; border: 1px solid #eadbdd; border-radius: 8px; background: #fff8f8; }
.directions-form label { display: block; margin-bottom: 7px; color: #9e1a1f; font-size: 11px; font-weight: 800; letter-spacing: .6px; text-transform: uppercase; }
.directions-form div { display: flex; gap: 6px; }
.directions-form input { min-width: 0; width: 100%; padding: 9px; border: 1px solid #e1cfd1; border-radius: 6px; outline: 0; color: #273440; background: #fff; font-size: 12px; }
.directions-form button { border: 1px solid #d71920; border-radius: 6px; color: #fff; background: #d71920; font-size: 11px; font-weight: 800; }
.directions-form small { display: block; margin-top: 7px; color: #8a6e71; font-size: 10px; line-height: 1.35; }
.favorites-panel { margin-top: 12px; }
.section-title { margin-bottom: 7px; color: #6d7882; font-size: 10px; font-weight: 800; letter-spacing: .7px; text-transform: uppercase; }
.favorites-list { display: flex; flex-wrap: wrap; gap: 6px; }
.favorites-list button { padding: 6px 8px; border: 1px solid #e0e5e8; border-radius: 999px; color: #3d4a54; background: #fff; font-size: 11px; font-weight: 700; }
.favorites-list span { color: #8a949c; font-size: 11px; }
.filters { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin: 15px 0 18px; padding: 3px; border-radius: 7px; background: #f0f2f4; }
.filter { padding: 7px 4px; border: 0; border-radius: 5px; color: #68747f; background: transparent; font-size: 11px; font-weight: 700; }
.filter.active { color: #c8171d; background: #fff; box-shadow: 0 1px 3px #9da7b233; }
.visibility-toggle { display: flex; align-items: center; gap: 7px; margin: -5px 0 15px; color: #66737d; font-size: 11px; }
.visibility-toggle input { accent-color: #d71920; }
.mobile-route-picker { display: none; }
.mobile-status { display: none; }
.summary { display: flex; align-items: center; justify-content: space-between; padding-bottom: 12px; border-bottom: 1px solid #e6eaed; }
.summary span { display: block; color: #67737d; font-size: 11px; font-weight: 700; letter-spacing: .8px; text-transform: uppercase; }
.summary strong { display: block; margin-top: 3px; color: #202b34; font-size: 25px; }
.icon-button { display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid #e0e5e8; border-radius: 7px; color: #d71920; background: #fff; }
.route-list { flex: 1; min-height: 0; overflow-y: auto; }
.route-row { display: grid; width: 100%; grid-template-columns: 36px 1fr auto; gap: 10px; align-items: center; padding: 11px 2px; border: 0; border-bottom: 1px solid #edf0f2; text-align: left; background: #fff; }
.route-row:hover { background: #f7f9fa; }
.route-number { display: grid; place-items: center; width: 34px; height: 30px; border-radius: 5px; color: #fff; background: #d71920; font-size: 11px; font-weight: 800; }
.route-row strong { display: block; font-size: 13px; }
.route-row small, .route-count { color: #78838c; font-size: 11px; }
.sidebar-footer { display: flex; align-items: center; gap: 8px; padding: 13px 16px; border-top: 1px solid #e4e8eb; color: #77828b; font-size: 11px; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #2caf63; box-shadow: 0 0 0 3px #2caf6320; }
.install-app { margin-left: auto; padding: 5px 8px; border: 1px solid #d71920; border-radius: 999px; color: #d71920; background: #fff; font-size: 10px; font-weight: 900; }
.pwa-status { margin-left: auto; color: #9e1a1f; font-size: 10px; font-weight: 800; }
.install-app:not([hidden]) + .pwa-status { margin-left: 0; }

.map-panel { position: relative; min-width: 0; min-height: 0; background: #e8ecef; }
.map-header { position: absolute; z-index: 500; top: 18px; left: 18px; right: 18px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 16px; border: 1px solid #e2e6e8; border-radius: 9px; background: #fffffff5; box-shadow: 0 7px 24px #43515f1a; }
h2 { color: #1c2832; font-size: 19px; letter-spacing: -.3px; }
.map-header p { margin-top: 3px; color: #72808b; font-size: 12px; }
.header-actions { display: flex; gap: 8px; }
.primary-button, .secondary-button { display: flex; align-items: center; gap: 7px; padding: 9px 11px; border-radius: 7px; font-size: 12px; font-weight: 700; }
.primary-button { border: 1px solid #d71920; color: #fff; background: #d71920; }
.secondary-button { border: 1px solid #dce1e4; color: #47545e; background: #fff; }
.route-focus { position: absolute; z-index: 550; top: 95px; left: 18px; display: flex; align-items: center; gap: 14px; padding: 9px 11px; border: 1px solid #e4e8ea; border-radius: 8px; background: #fff; box-shadow: 0 4px 16px #43515f22; }
.route-focus[hidden], .nearby-panel[hidden] { display: none; }
.route-focus span, .nearby-panel header span { display: block; color: #77838d; font-size: 9px; font-weight: 800; letter-spacing: .7px; text-transform: uppercase; }
.route-focus strong, .nearby-panel header strong { display: block; margin-top: 2px; font-size: 13px; }
.route-focus button, .popup-focus { border: 0; color: #c8171d; background: transparent; font-size: 11px; font-weight: 800; }
.alerts-panel { position: absolute; z-index: 545; top: 95px; right: 18px; width: 310px; overflow: hidden; border: 1px solid #f0d9a7; border-radius: 8px; background: #fffbf1; box-shadow: 0 4px 16px #43515f1d; }
.alerts-panel[hidden] { display: none; }
.alerts-panel header { display: flex; justify-content: space-between; gap: 10px; padding: 10px 12px; border-bottom: 1px solid #f2dfb7; }
.alerts-panel header span { color: #8b5b00; font-size: 10px; font-weight: 900; letter-spacing: .7px; text-transform: uppercase; }
.alerts-panel header a { color: #9e1a1f; font-size: 10px; font-weight: 800; text-decoration: none; }
.alerts-panel p { margin: 0; padding: 10px 12px; color: #5f4a20; font-size: 11px; line-height: 1.4; }
#map { width: 100%; height: 100%; }
.leaflet-control-zoom { margin: 0 18px 23px 0 !important; border: 0 !important; box-shadow: 0 3px 15px #46515c25 !important; }
.leaflet-control-zoom a { color: #3e4c57 !important; border-color: #e1e6e9 !important; }
.vehicle-pin { display: grid; place-items: center; width: 23px; height: 23px; border: 2px solid #fff; border-radius: 50% 50% 50% 0; color: #fff; background: #d71920; box-shadow: 0 2px 6px #3c465844; transform: rotate(-45deg); }
.vehicle-pin svg { width: 12px; height: 12px; fill: #fff; transform: rotate(45deg); }
.vehicle-pin.streetcar { background: #2478b8; }
.vehicle-pin.subway { background: #7450a5; }
.vehicle-popup strong { display: block; margin-bottom: 5px; font-size: 14px; }
.vehicle-popup span { display: block; margin-top: 2px; color: #66717a; font-size: 12px; }
.vehicle-popup .vehicle-age { margin-top: 6px; color: #c8171d; font-size: 11px; font-weight: 700; }
.popup-focus { margin-top: 8px; padding: 0; }
.nearby-panel { position: absolute; z-index: 550; right: 18px; bottom: 22px; width: 285px; overflow: hidden; border: 1px solid #e2e6e8; border-radius: 9px; background: #fff; box-shadow: 0 7px 24px #43515f26; }
.nearby-panel header { display: flex; align-items: center; justify-content: space-between; padding: 12px; border-bottom: 1px solid #e8ecee; }
.panel-close { border: 0; color: #68747d; background: transparent; font-size: 22px; line-height: 1; }
.nearby-list { max-height: 285px; overflow-y: auto; }
.nearby-row { display: grid; width: 100%; grid-template-columns: 36px 1fr auto; gap: 9px; align-items: center; padding: 10px 12px; border: 0; border-bottom: 1px solid #edf0f2; text-align: left; background: #fff; }
.nearby-row:hover { background: #f7f9fa; }
.nearby-row strong, .nearby-row small { display: block; }
.nearby-row strong { color: #26333d; font-size: 12px; }
.nearby-row small { margin-top: 2px; color: #7a858e; font-size: 10px; }
.nearby-row b { color: #c8171d; font-size: 11px; }
.nearby-subtitle { padding: 10px 12px 4px; color: #6d7882; font-size: 10px; font-weight: 900; letter-spacing: .7px; text-transform: uppercase; }
.nearby-stops { border-top: 1px solid #e8ecee; }
.arrival-predictions { border-top: 1px solid #e8ecee; }
.nearby-empty { padding: 9px 12px 12px; color: #7a858e; font-size: 11px; }
.stop-code { display: grid; place-items: center; min-width: 34px; height: 30px; border-radius: 5px; color: #2478b8; background: #eaf4fb; font-size: 10px; font-weight: 900; }
.arrival-banner { position: absolute; z-index: 700; left: 50%; bottom: 22px; display: flex; align-items: center; gap: 12px; max-width: min(520px, calc(100% - 36px)); padding: 12px 14px; border-radius: 999px; color: #fff; background: #d71920; box-shadow: 0 8px 24px #5b1f2438; font-size: 13px; font-weight: 800; transform: translateX(-50%); }
.arrival-banner[hidden] { display: none; }
.arrival-banner button { border: 0; color: #fff; background: transparent; font-size: 20px; line-height: 1; }
.legend { position: absolute; z-index: 500; bottom: 22px; left: 18px; display: flex; gap: 15px; padding: 10px 12px; border: 1px solid #e2e6e8; border-radius: 7px; background: #fffffff5; box-shadow: 0 4px 16px #43515f18; color: #5d6a74; font-size: 11px; font-weight: 700; }
.legend span { display: flex; align-items: center; gap: 6px; }
.legend-marker { width: 9px; height: 9px; border-radius: 50%; background: #d71920; }
.legend-marker.streetcar { background: #2478b8; }
.legend-marker.subway { background: #7450a5; }
.loading { position: absolute; z-index: 600; inset: 50% auto auto 50%; padding: 10px 14px; border-radius: 7px; color: #48555f; background: #fff; box-shadow: 0 5px 22px #3d48562a; font-size: 13px; transform: translate(-50%, -50%); }
.loading.error { color: #b2171c; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.offline-page { display: grid; place-items: center; align-content: center; min-height: 100vh; padding: 28px; text-align: center; background: #fff; }
.offline-page h1 { margin-top: 18px; color: #1c2832; font-size: 28px; }
.offline-page p { max-width: 420px; margin-top: 10px; color: #65717b; line-height: 1.5; }
.offline-page a { margin-top: 18px; padding: 10px 14px; border-radius: 8px; color: #fff; background: #d71920; font-size: 13px; font-weight: 900; text-decoration: none; }
.offline-mark { color: #d71920; border-color: #d71920; }

@media (max-width: 1024px) and (min-width: 761px) {
  .app-shell { grid-template-columns: 300px minmax(0, 1fr); }
  .brand { padding: 18px 16px; }
  .sidebar-content { padding: 14px 12px 0; }
  .directions-form div { flex-direction: column; }
  .directions-form button { padding: 8px 10px; }
  .filters { grid-template-columns: repeat(2, 1fr); }
  .map-header { left: 14px; right: 14px; gap: 12px; padding: 12px 14px; }
  .route-focus { left: 14px; max-width: calc(100% - 28px); flex-wrap: wrap; }
  .alerts-panel { right: 14px; max-width: calc(100% - 330px); }
  .nearby-panel { right: 14px; width: min(300px, calc(100% - 28px)); }
}

@media (max-width: 760px) {
  .app-shell { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); min-height: 0; }
  .sidebar { display: block; max-height: min(45dvh, 370px); overflow-y: auto; overscroll-behavior: contain; border-right: 0; box-shadow: 0 2px 16px #2634401c; }
  .brand { position: sticky; top: 0; z-index: 2; padding: 11px 14px; }
  .brand-mark { width: 42px; height: 31px; border-radius: 13px; font-size: 12px; }
  h1 { font-size: 17px; }
  .brand p { display: none; }
  .sidebar-content { padding: 10px 12px 0; gap: 0; }
  .search input { padding: 9px 0; font-size: 12px; }
  .directions-form { margin-top: 8px; padding: 8px; }
  .directions-form label { margin-bottom: 5px; font-size: 10px; }
  .directions-form input { padding: 8px; }
  .directions-form button { min-width: 82px; padding: 0 8px; }
  .directions-form small { display: none; }
  .favorites-panel { margin-top: 8px; }
  .section-title { margin-bottom: 5px; font-size: 9px; }
  .favorites-list { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; }
  .favorites-list button { white-space: nowrap; padding: 5px 7px; font-size: 10px; }
  .filters { display: flex; gap: 4px; margin: 8px 0 7px; overflow-x: auto; scrollbar-width: none; }
  .filters::-webkit-scrollbar, .favorites-list::-webkit-scrollbar { display: none; }
  .filter { flex: 1 0 auto; min-width: 64px; padding: 7px 8px; }
  .visibility-toggle { margin: 0 2px 7px; font-size: 10px; }
  .mobile-route-picker { display: grid; grid-template-columns: 72px 1fr; gap: 8px; align-items: center; margin: 0 2px 7px; color: #66737d; font-size: 10px; font-weight: 800; text-transform: uppercase; }
  .mobile-route-picker select { min-width: 0; padding: 7px; border: 1px solid #d7dde2; border-radius: 6px; color: #273440; background: #fff; font-size: 12px; text-transform: none; }
  .mobile-status { display: flex; justify-content: space-between; padding: 0 2px 9px; color: #73808a; font-size: 10px; }
  .mobile-status strong { color: #c8171d; }
  .summary, .route-list { display: none; }
  .sidebar-footer { position: sticky; bottom: 0; display: flex; justify-content: flex-end; padding: 0 12px 7px; border-top: 0; background: #fff; }
  .sidebar-footer .live-dot, .sidebar-footer #updated-at { display: none; }
  .map-panel { min-height: 0; }
  .map-header { top: max(10px, env(safe-area-inset-top)); left: 10px; right: 10px; align-items: flex-start; gap: 10px; padding: 11px 12px; }
  .map-header p { display: none; }
  .map-header h2 { font-size: 16px; }
  .header-actions { flex-shrink: 0; gap: 6px; }
  .primary-button, .secondary-button { gap: 5px; padding: 8px 7px; font-size: 11px; }
  .primary-button svg, .secondary-button svg { width: 15px; height: 15px; }
  .legend { bottom: max(10px, env(safe-area-inset-bottom)); left: 10px; max-width: calc(100% - 20px); gap: 10px; padding: 8px 9px; overflow-x: auto; }
  .route-focus { top: 68px; right: 10px; left: 10px; flex-wrap: wrap; gap: 8px; padding: 8px 9px; }
  .route-focus > div { flex: 1 1 120px; min-width: 0; }
  .route-focus button { padding: 4px 0; }
  .alerts-panel { top: 120px; right: 10px; left: 10px; width: auto; max-height: 34dvh; overflow-y: auto; }
  .nearby-panel { right: 10px; bottom: max(10px, env(safe-area-inset-bottom)); left: 10px; display: flex; width: auto; max-height: min(58dvh, 430px); flex-direction: column; overflow-y: auto; }
  .nearby-panel[hidden] { display: none; }
  .nearby-panel header { position: sticky; top: 0; z-index: 1; background: #fff; }
  .nearby-list { max-height: none; overflow: visible; }
  .nearby-panel:not([hidden]) ~ .legend { display: none; }
  .nearby-panel:not([hidden]) ~ .arrival-banner { bottom: calc(min(58dvh, 430px) + 18px); }
  .arrival-banner { right: 10px; bottom: max(10px, env(safe-area-inset-bottom)); left: 10px; max-width: none; border-radius: 10px; font-size: 12px; transform: none; }
  .leaflet-control-zoom { margin: 0 10px 10px 0 !important; }
}

@media (max-width: 520px) {
  .directions-form { overflow: hidden; }
  .directions-form div { display: grid; grid-template-columns: minmax(0, 1fr) minmax(72px, auto); }
  .directions-form button { min-width: 0; }
  .filters { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); overflow: hidden; }
  .filter { min-width: 0; padding-right: 4px; padding-left: 4px; }
  .map-header { align-items: center; }
  .header-actions { gap: 5px; }
  .primary-button, .secondary-button { padding: 8px; }
}

@media (max-width: 520px) {
  .sidebar { max-height: 43dvh; }
  .directions-form button { min-width: 72px; font-size: 10px; }
  .mobile-route-picker { grid-template-columns: 62px 1fr; }
  .mobile-status { font-size: 9px; }
  .map-header { padding: 10px; }
  .map-header h2 { max-width: 105px; font-size: 15px; }
  .primary-button, .secondary-button { width: 36px; height: 36px; justify-content: center; gap: 0; padding: 0; overflow: hidden; font-size: 0; white-space: nowrap; }
  .primary-button svg, .secondary-button svg { flex: 0 0 auto; color: #fff; }
  .secondary-button svg { color: #47545e; }
  .route-focus { top: 64px; }
  .alerts-panel { top: 114px; }
}

@media (max-width: 760px) and (max-height: 700px) {
  .sidebar { max-height: 39dvh; }
  .brand { padding: 8px 12px; }
  .brand-mark { width: 38px; height: 28px; }
  .sidebar-content { padding-top: 8px; }
  .directions-form label, .favorites-panel, .visibility-toggle { display: none; }
  .directions-form { margin-top: 7px; }
  .filters { margin: 7px 0; }
  .mobile-status { padding-bottom: 7px; }
  .nearby-panel { max-height: 52dvh; }
  .nearby-panel:not([hidden]) ~ .arrival-banner { bottom: calc(52dvh + 18px); }
}

@media (max-width: 760px) and (orientation: landscape) {
  .app-shell { grid-template-columns: minmax(250px, 34vw) minmax(0, 1fr); grid-template-rows: 1fr; }
  .sidebar { max-height: none; height: 100dvh; border-right: 1px solid #dfe4e8; }
  .brand { position: static; }
  .sidebar-footer { position: static; }
  .map-header { left: 10px; right: 10px; }
  .route-focus { top: 66px; max-width: calc(100% - 20px); }
  .alerts-panel { top: 112px; left: auto; width: min(300px, calc(100% - 20px)); }
}
