@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Space+Grotesk:wght@500;600;700&display=swap');
:root {
  font-family: 'DM Sans', system-ui, sans-serif;
  color: #182c36;
  font-size: 14px;
  --teal: #007c78;
  --muted: #647780;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
#map {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  background: #dfe9ed;
}
.topbar {
  position: absolute;
  top: 18px;
  left: 22px;
  right: 360px;
  display: flex;
  align-items: center;
  gap: 20px;
  pointer-events: none;
  z-index: 3;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #16313b;
  text-decoration: none;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 22px;
  font-weight: 700;
  pointer-events: auto;
  background: #fffffff2;
  padding: 10px 15px;
  border-radius: 14px;
  box-shadow: 0 3px 20px #17343d16;
}
.brand small {
  display: block;
  font:
    11px 'DM Sans',
    sans-serif;
  letter-spacing: 0.08em;
  margin-top: 3px;
  color: #60737c;
}
.t-mark {
  border: 3px solid #182c36;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  font: bold 28px Arial;
}
.nav-button {
  pointer-events: auto;
  text-decoration: none;
  background: #fff;
  color: #153b45;
  padding: 13px 16px;
  border: 1px solid #dce5e7;
  border-radius: 10px;
  font-weight: 700;
  box-shadow: 0 3px 16px #17343d10;
}
.nav-button span {
  margin-left: 12px;
  color: var(--teal);
}
button,
input {
  font: inherit;
}
button {
  cursor: pointer;
  border: 1px solid #d5e1e4;
  background: #fff;
  color: #244650;
  border-radius: 7px;
  padding: 7px 10px;
}
button:hover,
.nav-button:hover {
  background: #edf8f6;
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
summary:focus-visible {
  outline: 3px solid #f6a800;
  outline-offset: 2px;
}
input[type='checkbox'] {
  accent-color: var(--teal);
  width: 16px;
  height: 16px;
  cursor: pointer;
  flex-shrink: 0;
}
input[type='search'],
input[type='url'] {
  width: 100%;
  border: 1px solid #ccdadd;
  border-radius: 8px;
  padding: 10px;
  background: #fafcfc;
  color: #244650;
}
.panel {
  position: absolute;
  right: 18px;
  top: 18px;
  bottom: 42px;
  width: 318px;
  background: #fffffff7;
  border: 1px solid #fff;
  border-radius: 18px;
  box-shadow: 0 8px 40px #12334024;
  z-index: 4;
  overflow: auto;
  padding: 23px 20px;
}
.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.panel-heading button {
  font-size: 20px;
  padding: 0;
  width: 28px;
  height: 28px;
}
.eyebrow {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.17em;
  color: var(--teal);
}
h1 {
  font-family: 'Space Grotesk', sans-serif;
  line-height: 1.08;
  font-size: 32px;
  letter-spacing: -1px;
  margin: 10px 0 3px;
}
.intro,
.footnote,
.connection p {
  font-size: 12px;
  line-height: 1.6;
  color: var(--muted);
}
.legend-key {
  display: flex;
  gap: 15px;
  padding: 12px 0;
  border-bottom: 1px solid #e4ecee;
  font-size: 11px;
}
.legend-key span {
  display: flex;
  align-items: center;
  gap: 6px;
}
.line-key {
  width: 18px;
  border-top: 3px solid var(--teal);
}
.stop-key {
  border: 2px solid var(--teal);
  background: white;
  width: 12px;
  height: 12px;
  border-radius: 50%;
}
.vehicle-key {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 0 4px #007c7824;
}
.global-layers {
  display: flex;
  justify-content: space-between;
  padding: 14px 0;
}
.global-layers label,
.mode-check,
.route-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.selection-actions {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
}
.selection-actions button {
  font-size: 11px;
  flex: 1;
  padding: 7px 4px;
}
.search-label {
  font-size: 11px;
  font-weight: 700;
  display: block;
  margin-bottom: 6px;
}
#route-search {
  margin-bottom: 14px;
}
.mode {
  border-top: 1px solid #e3ebed;
  padding: 12px 0;
}
.mode summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
}
.mode summary::-webkit-details-marker {
  display: none;
}
.mode summary:after {
  content: '+';
  margin-left: auto;
  font-size: 20px;
  color: #7c9197;
}
.mode[open] summary:after {
  content: '−';
}
.mode-check {
  flex: 1;
  font-weight: 700;
}
.mode-icon {
  width: 25px;
  height: 25px;
  background: var(--mode);
  border-radius: 7px;
  color: white;
  display: grid;
  place-items: center;
  font-size: 11px;
}
.mode-count {
  font-size: 10px;
  color: #70838a;
  margin-right: 4px;
}
.mode-layers {
  display: flex;
  gap: 10px;
  padding: 12px 0 7px;
  font-size: 11px;
}
.mode-layers label {
  display: flex;
  align-items: center;
  gap: 3px;
}
.mode-layers input {
  width: 13px;
  height: 13px;
}
.routes {
  max-height: 240px;
  overflow: auto;
}
.route-row {
  font-size: 12px;
  padding: 6px 0;
  border-bottom: 1px solid #f1f5f5;
}
.route-row .swatch {
  width: 20px;
  height: 4px;
  border-radius: 2px;
  flex-shrink: 0;
}
.route-row span:last-child {
  overflow-wrap: anywhere;
}
.connection {
  border-top: 1px solid #e3ebed;
  padding-top: 14px;
  margin-top: 8px;
}
.connection summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 12px;
}
.connection label {
  display: block;
  font-size: 11px;
  margin: 10px 0 5px;
}
.connection button {
  margin-top: 8px;
  font-size: 11px;
}
.status-card {
  position: absolute;
  bottom: 25px;
  left: 22px;
  background: #fffffff2;
  border-radius: 12px;
  padding: 12px 15px;
  display: flex;
  gap: 10px;
  align-items: center;
  box-shadow: 0 3px 20px #17343d20;
  max-width: calc(100vw - 380px);
  z-index: 3;
}
.status-card strong {
  display: block;
  font-size: 12px;
}
.status-card small {
  display: block;
  font-size: 10px;
  color: #60737c;
  margin-top: 4px;
  line-height: 1.5;
}
.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #83959b;
  flex-shrink: 0;
}
.live-dot.ok {
  background: #009979;
  box-shadow: 0 0 0 4px #00997918;
}
.live-dot.error {
  background: #d77436;
}
.ol-zoom {
  top: 110px;
  left: 22px;
  background: white;
  border-radius: 8px;
  padding: 4px;
  box-shadow: 0 2px 12px #17343d18;
}
.ol-zoom button {
  background: white;
  color: #23434b;
  font-size: 23px;
}
.ol-zoom button:hover {
  background: #edf8f6;
}
.ol-attribution {
  font-size: 10px;
  max-width: calc(100% - 15px);
}
.popup {
  background: white;
  border: 1px solid #d5e1e4;
  border-radius: 12px;
  box-shadow: 0 5px 25px #12334030;
  padding: 17px;
  min-width: 220px;
  max-width: 300px;
  font-size: 12px;
  line-height: 1.7;
}
.popup h2 {
  font-size: 16px;
  line-height: 1.3;
  margin: 0 15px 9px 0;
}
.popup button {
  position: absolute;
  right: 5px;
  top: 5px;
  border: 0;
  padding: 0 6px;
  font-size: 20px;
}
.popup .tag {
  color: var(--teal);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}
.panel.collapsed {
  bottom: auto;
}
.panel.collapsed #panel-body {
  display: none;
}
.panel.collapsed h1 {
  font-size: 22px;
}
.panel.collapsed h1 br {
  display: none;
}
@media (max-width: 750px) {
  .topbar {
    left: 12px;
    right: 12px;
    top: 12px;
    justify-content: space-between;
    gap: 8px;
  }
  .brand {
    font-size: 17px;
    padding: 8px 10px;
  }
  .brand small {
    font-size: 9px;
  }
  .t-mark {
    width: 30px;
    height: 30px;
    font-size: 23px;
  }
  .nav-button {
    font-size: 11px;
    padding: 12px 9px;
  }
  .nav-button span {
    margin-left: 4px;
  }
  .panel {
    right: 12px;
    top: 87px;
    bottom: auto;
    max-height: 52dvh;
    width: 270px;
    padding: 16px;
  }
  h1 {
    font-size: 26px;
  }
  .ol-zoom {
    left: 12px;
    top: 87px;
  }
  .status-card {
    left: 12px;
    bottom: 30px;
    max-width: calc(100vw - 24px);
  }
  .panel.collapsed {
    width: 210px;
  }
  .panel-heading .eyebrow {
    font-size: 8px;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
  }
}

/* Aligned controls and map-only theme */
:root {
  --surface: #fffffff7;
  --surface-solid: #fff;
  --ink: #182c36;
  --border: #d5e1e4;
  --field: #fafcfc;
}
body.dark {
  --surface: #14262df7;
  --surface-solid: #14262d;
  --ink: #e8f1f4;
  --muted: #a5b7be;
  --border: #3a5059;
  --field: #1b333c;
  --teal: #5ad7c5;
  color: var(--ink);
  background: #111c24;
}
body.dark .basemap-layer canvas {
  filter: invert(1) hue-rotate(180deg) saturate(0.6) brightness(0.8);
}
body.dark #map {
  background: #121f28;
}
body.dark .panel,
body.dark .brand,
body.dark .status-card,
body.dark .popup {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--border);
}
body.dark .brand {
  color: var(--ink);
}
body.dark .t-mark {
  border-color: var(--ink);
}
body.dark .brand small,
body.dark .status-card small {
  color: var(--muted);
}
body.dark button,
body.dark select,
body.dark .nav-button,
body.dark .ol-zoom,
body.dark .ol-zoom button {
  background: var(--surface-solid);
  color: var(--ink);
  border-color: var(--border);
}
body.dark button:hover,
body.dark .nav-button:hover {
  background: #274852;
}
body.dark input[type='search'] {
  background: var(--field);
  color: var(--ink);
  border-color: var(--border);
}
body.dark .mode,
body.dark .legend-key,
body.dark .route-row,
body.dark .live-controls {
  border-color: var(--border);
}
body.dark .mode-count {
  color: var(--muted);
}
body.dark .ol-attribution {
  background: #14262de0;
  color: var(--ink);
}
body.dark .ol-attribution a {
  color: #9ddfd9;
}
.theme-button {
  pointer-events: auto;
  white-space: nowrap;
  min-height: 43px;
  font-size: 12px;
  font-weight: 700;
  padding: 10px 13px;
}
.mode-layers,
.routes {
  padding-left: 12px;
}
.routes .route-row {
  gap: 7px;
}
.mode-check input,
.route-row input,
.global-layers input {
  margin-left: 0;
  margin-right: 0;
}
.live-controls {
  border-top: 1px solid var(--border);
  padding-top: 14px;
  margin-top: 10px;
}
.live-control-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 9px;
}
.live-control-heading h2 {
  font-size: 12px;
  margin: 0;
}
.live-control-heading span {
  font-size: 10px;
  color: var(--muted);
}
.live-switch,
.interval-row,
.update-actions button {
  min-height: 40px;
  width: 100%;
  font-size: 12px;
  line-height: 1.3;
}
.live-switch,
.interval-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.live-switch {
  padding: 9px 11px;
}
.switch-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  min-width: 55px;
  justify-content: flex-end;
}
.switch-track {
  display: block;
  width: 29px;
  height: 16px;
  background: #159582;
  border-radius: 9px;
  position: relative;
}
.switch-track:before {
  content: '';
  position: absolute;
  top: 3px;
  left: 16px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: white;
  transition: left 0.15s;
}
.live-switch[aria-checked='false'] .switch-track {
  background: #82939a;
}
.live-switch[aria-checked='false'] .switch-track:before {
  left: 3px;
}
.interval-row {
  padding: 8px 0;
  margin: 4px 0;
}
.interval-row select {
  font: inherit;
  border: 1px solid var(--border);
  background: var(--surface-solid);
  color: var(--ink);
  border-radius: 7px;
  padding: 7px 8px;
  min-width: 110px;
}
.update-actions {
  display: grid;
  gap: 8px;
}
.update-actions button {
  text-align: center;
  padding: 10px 8px;
}
.update-actions button:disabled {
  opacity: 0.55;
  cursor: wait;
}
#data-warning {
  font-size: 11px;
  line-height: 1.5;
  color: #b75c18;
}
body.dark #data-warning {
  color: #ffc78e;
}
@media (max-width: 750px) {
  .topbar {
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-start;
  }
  .brand {
    margin-right: auto;
  }
  .nav-button {
    font-size: 10px;
    padding: 10px 7px;
  }
  .theme-button {
    font-size: 10px;
    min-height: 36px;
    padding: 8px 7px;
  }
  .nav-button span {
    display: none;
  }
  .panel {
    top: 90px;
  }
  .ol-zoom {
    top: 90px;
  }
}
@media (max-width: 380px) {
  .brand {
    font-size: 15px;
    padding: 7px;
  }
  .brand small {
    font-size: 8px;
  }
  .t-mark {
    width: 26px;
    height: 26px;
    font-size: 21px;
  }
  .nav-button,
  .theme-button {
    font-size: 9px;
  }
}

/* OpenLayers sets `.ol-viewport canvas { all: unset; }`.
 * This selector must be more specific or the basemap can cover our canvas.
 */
.ol-viewport > canvas.vehicle-halos {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}
@media (max-width: 750px) {
  .topbar {
    flex-wrap: nowrap;
    gap: 6px;
  }
  .brand {
    font-size: 15px;
    gap: 7px;
    padding: 8px;
    min-width: 0;
    flex-shrink: 1;
  }
  .brand small {
    display: none;
  }
  .brand > span:last-child {
    white-space: nowrap;
  }
  .t-mark {
    width: 26px;
    height: 26px;
    font-size: 22px;
    flex-shrink: 0;
  }
  .nav-button {
    white-space: nowrap;
  }
  .theme-button {
    flex-shrink: 0;
  }
}
@media (max-width: 380px) {
  .brand {
    font-size: 13px;
    gap: 5px;
    padding: 7px;
  }
  .t-mark {
    width: 23px;
    height: 23px;
    font-size: 19px;
  }
  .theme-button,
  .nav-button {
    font-size: 9px;
    padding: 8px 5px;
  }
}

.appearance-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 14px 0 8px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-weight: 600;
}
.theme-choices {
  display: flex;
  gap: 5px;
}
.theme-choices button {
  font-size: 11px;
  min-height: 32px;
  padding: 7px 10px;
}
.theme-choices button[aria-pressed='true'] {
  background: #007c78;
  border-color: #007c78;
  color: white;
}
body.dark .theme-choices button[aria-pressed='true'] {
  background: #236d66;
  border-color: #5ad7c5;
  color: #fff;
}
.interval-value {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
}
.interval-value input {
  width: 68px;
  min-height: 36px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--field);
  color: var(--ink);
  padding: 6px;
  text-align: center;
  font-size: 13px;
}
#refresh-slider {
  width: 100%;
  margin: 5px 0;
  accent-color: var(--teal);
  cursor: pointer;
  min-height: 20px;
}
.slider-limits {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  color: var(--muted);
  margin-bottom: 12px;
}
.interaction-panel {
  position: absolute;
  left: 22px;
  top: 205px;
  width: 310px;
  max-height: calc(100dvh - 330px);
  overflow: auto;
  z-index: 5;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 8px 35px #12334030;
}
.interaction-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
}
.interaction-heading h2 {
  font:
    600 23px 'Space Grotesk',
    sans-serif;
  margin: 6px 0;
}
.interaction-heading button {
  width: 30px;
  height: 30px;
  font-size: 20px;
  padding: 0;
}
.interaction-intro,
#interaction-status {
  font-size: 12px;
  line-height: 1.6;
  color: var(--muted);
}
.custom-action {
  width: 100%;
  min-height: 40px;
  font-size: 12px;
}
.interaction-panel[hidden] {
  display: none;
}
@media (max-width: 750px) {
  .interaction-panel {
    left: 12px;
    right: 12px;
    top: 175px;
    width: auto;
    max-height: calc(100dvh - 280px);
  }
  .appearance-bar {
    margin-top: 10px;
  }
  .theme-choices button {
    font-size: 10px;
    padding: 7px 8px;
  }
  .topbar .theme-button {
    font-size: 10px;
    padding: 8px 7px;
  }
}
@media (max-width: 380px) {
  .topbar .theme-button {
    font-size: 9px;
    padding: 8px 5px;
  }
}
.appearance-bar {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface-solid);
}
@media (max-width: 750px) {
  .brand > span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

#smooth-movement {
  margin-top: 9px;
}
.movement-note {
  font-size: 10px;
  line-height: 1.5;
  color: var(--muted);
  margin: 7px 0 4px;
}

.mbta-brand-logo {
  width: 36px;
  height: 36px;
  object-fit: contain;
  flex-shrink: 0;
}
@media (max-width: 750px) {
  .mbta-brand-logo {
    width: 26px;
    height: 26px;
  }
}
@media (max-width: 380px) {
  .mbta-brand-logo {
    width: 23px;
    height: 23px;
  }
}

.interaction-panel {
  position: absolute;
  top: 90px;
  left: 58px;
  z-index: 30;
  width: min(300px, calc(100vw - 76px));
  max-height: calc(100dvh - 180px);
  overflow-y: auto;
  box-sizing: border-box;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 8px 28px #0003;
}

.interaction-panel [hidden],
.interaction-panel[hidden] {
  display: none;
}

.interaction-heading,
.interaction-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.interaction-tools,
.grid-settings {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.grid-settings {
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.grid-settings label {
  display: grid;
  gap: 6px;
  font-size: 14px;
}

.interaction-panel button,
.interaction-panel select,
.interaction-panel input {
  box-sizing: border-box;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--field);
  color: var(--ink);
  font: inherit;
}

.interaction-panel button {
  cursor: pointer;
}

.interaction-panel select,
.interaction-panel input {
  width: 100%;
}

.interaction-tools > button {
  text-align: left;
}

.interaction-actions > button {
  flex: 1;
}

#grid-message {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

/* Public architecture note; uses the panel palette in both themes. */
.site-architecture { margin: 10px 0 14px; font-size: 12px; line-height: 1.5; }
.site-architecture summary { cursor: pointer; font-weight: 600; }
.site-architecture p { margin: 7px 0 0; }
