/* ==========================================================================
   Transitron · Material Design 3 theme
   - Tonal color roles (light + dark, follows the system setting)
   - M3 shape scale, elevation, type scale, state layers
   - Element IDs / class names are unchanged, so no JS changes are needed
   ========================================================================== */
@import url("https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap");

:root {
  color-scheme: light;

  /* Neutral color roles — route colors remain semantic. */
  --md-primary: #515151;
  --md-on-primary: #ffffff;
  --md-primary-container: #e0e0e0;
  --md-on-primary-container: #202020;
  --md-secondary: #5d5d5d;
  --md-on-secondary: #ffffff;
  --md-secondary-container: #e2e2e2;
  --md-on-secondary-container: #242424;
  --md-tertiary: #5f5f5f;
  --md-tertiary-container: #e7e7e7;
  --md-on-tertiary-container: #252525;
  --md-error: #ba1a1a;
  --md-error-container: #ffdad6;
  --md-on-error-container: #410002;
  --md-surface: #f7f7f7;
  --md-on-surface: #202020;
  --md-surface-variant: #e5e5e5;
  --md-on-surface-variant: #484848;
  --md-outline: #777777;
  --md-outline-variant: #c8c8c8;
  --md-surface-container-lowest: #ffffff;
  --md-surface-container-low: #f1f1f1;
  --md-surface-container: #ebebeb;
  --md-surface-container-high: #e5e5e5;
  --md-surface-container-highest: #dfdfdf;
  --md-scrim: rgb(0 0 0 / 0.32);

  /* Elevation */
  --e1: 0 1px 2px rgb(0 0 0 / 0.3), 0 1px 3px 1px rgb(0 0 0 / 0.15);
  --e2: 0 1px 2px rgb(0 0 0 / 0.3), 0 2px 6px 2px rgb(0 0 0 / 0.15);
  --e3: 0 1px 3px rgb(0 0 0 / 0.3), 0 4px 8px 3px rgb(0 0 0 / 0.15);

  /* Shape scale */
  --r-xs: 4px;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 28px;
  --r-full: 999px;

  --logo-filter: none;
  --map-ctrl-icon-filter: none;
  --font: "Google Sans", "Roboto", system-ui, -apple-system, "Segoe UI", sans-serif;

  /* Legacy aliases still referenced by a few rules */
  --bg: var(--md-surface);
  --panel: var(--md-surface-container-high);
  --line: var(--md-outline-variant);
  --muted: var(--md-on-surface-variant);
  --accent: var(--md-primary);
}
:root[data-theme="dark"] {
    color-scheme: dark;
    --md-primary: #d0d0d0;
    --md-on-primary: #292929;
    --md-primary-container: #454545;
    --md-on-primary-container: #e0e0e0;
    --md-secondary: #c5c5c5;
    --md-on-secondary: #303030;
    --md-secondary-container: #454545;
    --md-on-secondary-container: #e2e2e2;
    --md-tertiary: #cacaca;
    --md-tertiary-container: #464646;
    --md-on-tertiary-container: #e7e7e7;
    --md-error: #ffb4ab;
    --md-error-container: #93000a;
    --md-on-error-container: #ffdad6;
    --md-surface: #151515;
    --md-on-surface: #dfdfdf;
    --md-surface-variant: #484848;
    --md-on-surface-variant: #c8c8c8;
    --md-outline: #999999;
    --md-outline-variant: #484848;
    --md-surface-container-lowest: #101010;
    --md-surface-container-low: #202020;
    --md-surface-container: #232323;
    --md-surface-container-high: #2c2c2c;
    --md-surface-container-highest: #363636;
    --md-scrim: rgb(0 0 0 / 0.5);
    --logo-filter: brightness(0) invert(1);
    --map-ctrl-icon-filter: invert(0.9);
}

* {
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: var(--md-outline-variant) transparent;
}
body {
  margin: 0;
  background: var(--md-surface);
  color: var(--md-on-surface);
  font: 400 14px/20px var(--font);
  letter-spacing: 0.25px;
  -webkit-font-smoothing: antialiased;
}
button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: inherit;
}
a {
  color: inherit;
  text-decoration: none;
  touch-action: manipulation;
}
:focus-visible {
  outline: 2px solid var(--md-primary);
  outline-offset: 2px;
}
[hidden] {
  display: none !important;
}
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}

/* ---------- Buttons (default = outlined) ---------- */
button {
  cursor: pointer;
  touch-action: manipulation;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 20px;
  border: 1px solid var(--md-outline);
  border-radius: var(--r-full);
  background: transparent;
  color: var(--md-primary);
  font-weight: 500;
  font-size: 14px;
  line-height: 20px;
  letter-spacing: 0.1px;
  transition:
    box-shadow 0.15s,
    background-color 0.15s;
}
button:hover:not(:disabled) {
  box-shadow: inset 0 0 0 999px color-mix(in srgb, currentColor 8%, transparent);
}
button:active:not(:disabled) {
  box-shadow: inset 0 0 0 999px color-mix(in srgb, currentColor 12%, transparent);
}
button:disabled {
  opacity: 0.6;
  cursor: wait;
}
.primary {
  background: var(--md-primary);
  color: var(--md-on-primary);
  border-color: transparent;
}
.primary:hover:not(:disabled) {
  box-shadow:
    var(--e1),
    inset 0 0 0 999px color-mix(in srgb, currentColor 8%, transparent);
}

/* ---------- Top app bar ---------- */
header {
  height: 64px;
  padding: 0 16px 0 20px;
  display: flex;
  align-items: center;
  gap: 24px;
  background: var(--md-surface);
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font: 500 22px/28px var(--font);
  letter-spacing: 0.5px;
  white-space: nowrap;
}
.brand strong {
  font-weight: 500;
}
.brand-symbol {
  width: 36px;
  height: 36px;
  object-fit: contain;
  filter: var(--logo-filter);
  flex-shrink: 0;
}
nav {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--md-surface-container);
  border-radius: var(--r-full);
}
.nav {
  min-height: 40px;
  padding: 0 20px;
  border: 0;
  background: transparent;
  color: var(--md-on-surface-variant);
}
.nav.active {
  background: var(--md-secondary-container);
  color: var(--md-on-secondary-container);
}
.nav.active:hover:not(:disabled) {
  box-shadow: inset 0 0 0 999px color-mix(in srgb, currentColor 8%, transparent);
}
#account {
  margin-left: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}
.account-name {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--md-on-surface-variant);
  font-weight: 500;
}
.discord {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 40px;
  padding: 0 20px 0 16px;
  background: #5865f2;
  color: #fff;
  border-radius: var(--r-full);
  font-weight: 500;
  white-space: nowrap;
  transition: box-shadow 0.15s, background-color 0.15s;
}
.discord img {
  width: 22px;
  height: 18px;
  object-fit: contain;
  flex-shrink: 0;
}
.discord:hover {
  background: #4752c4;
  box-shadow: var(--e1);
}

/* ---------- Banner / snackbar ---------- */
#notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 48px;
  margin: 0 16px 8px;
  padding: 8px 8px 8px 20px;
  border-radius: var(--r-lg);
  background: var(--md-tertiary-container);
  color: var(--md-on-tertiary-container);
}
#noticeText {
  flex: 1;
}
#dismissNotice {
  flex-shrink: 0;
  width: 40px;
  min-height: 40px;
  padding: 0;
  border: 0;
  color: inherit;
  font-size: 22px;
}

/* ---------- Page layout ---------- */
main {
  height: calc(100dvh - 64px);
  display: grid;
  grid-template-columns: 360px 1fr;
  padding: 0 16px 16px 0;
}
.has-notice main {
  height: calc(100dvh - 120px);
}
aside {
  padding: 8px 16px 8px 20px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
/* Keep sidebar controls visible when the vehicle list is long. */
aside > :not(#results) {
  flex-shrink: 0;
}

.aside-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--md-primary);
  font: 500 12px/16px var(--font);
  letter-spacing: 0.8px;
}
.dot {
  width: 8px;
  height: 8px;
  background: var(--md-primary);
  border-radius: 50%;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--md-primary) 20%, transparent);
}

/* Search bar */
.search {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 56px;
  padding: 0 20px;
  background: var(--md-surface-container-high);
  border-radius: var(--r-full);
  color: var(--md-on-surface-variant);
}
.search:focus-within {
  box-shadow: inset 0 0 0 2px var(--md-primary);
}
.search span {
  font-size: 24px;
  line-height: 1;
}
.search input {
  flex: 1;
  min-width: 0;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  color: var(--md-on-surface);
  font-size: 16px;
  outline: none;
}
.search input::placeholder {
  color: var(--md-on-surface-variant);
}

/* Text fields */
label {
  display: block;
  color: var(--md-on-surface-variant);
  font-size: 12px;
  line-height: 16px;
  font-weight: 500;
}
input,
select,
textarea {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--md-outline);
  border-radius: var(--r-md);
  background: transparent;
  color: var(--md-on-surface);
}
label input,
label select,
label textarea {
  margin-top: 6px;
}
select {
  background: var(--md-surface);
}
input:hover,
select:hover,
textarea:hover {
  border-color: var(--md-on-surface);
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--md-primary);
  box-shadow: inset 0 0 0 1px var(--md-primary);
}
input[type="checkbox"] {
  accent-color: var(--md-primary);
  width: 18px;
  height: 18px;
}
.filters {
  display: grid;
  gap: 12px;
}

/* Segmented button */
.segments {
  display: flex;
  height: 40px;
  border: 1px solid var(--md-outline);
  border-radius: var(--r-full);
  overflow: hidden;
}
.segments button {
  flex: 1;
  min-height: 0;
  height: 100%;
  padding: 0 8px;
  border: 0;
  border-left: 1px solid var(--md-outline);
  border-radius: 0;
  color: var(--md-on-surface);
  font-size: 13px;
  white-space: nowrap;
}
.segments button:first-child {
  border-left: 0;
}
.segments .active {
  background: var(--md-secondary-container);
  color: var(--md-on-secondary-container);
}

/* Vehicle list */
#results {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.bus-result {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  justify-content: stretch;
  text-align: left;
  gap: 4px 12px;
  padding: 12px 16px;
  min-height: 0;
  border: 0;
  border-radius: var(--r-lg);
  color: var(--md-on-surface);
}
.bus-result.selected {
  background: var(--md-secondary-container);
  color: var(--md-on-secondary-container);
}
.bus-number {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font: 500 18px/24px var(--font);
  letter-spacing: 0;
}
.depot-stickers {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.filter-option-group {
  padding: 12px 10px 4px;
  color: var(--md-on-surface-variant);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.depot-stickers:empty {
  display: none;
}
.depot-sticker {
  display: block;
  width: 28px;
  height: 28px;
  flex: none;
  object-fit: contain;
}
#busTitle, .vehicle-pick {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
#busTitle .depot-sticker {
  width: 36px;
  height: 36px;
}
.bus-dest {
  grid-column: 1 / -1;
  color: var(--md-on-surface-variant);
  font-size: 13px;
  font-weight: 400;
}
.bus-result.selected .bus-dest,
.bus-result.selected .bus-age {
  color: var(--md-on-secondary-container);
}
.bus-age {
  font-size: 11px;
  font-weight: 400;
  color: var(--md-on-surface-variant);
  align-self: center;
}
.empty {
  padding: 24px 8px;
  color: var(--md-on-surface-variant);
  line-height: 1.7;
}
#more {
  background: var(--md-secondary-container);
  color: var(--md-on-secondary-container);
  border-color: transparent;
}
footer {
  margin-top: auto;
  padding: 24px 8px 8px;
  color: var(--md-on-surface-variant);
  font-size: 11px;
  letter-spacing: 0.5px;
  line-height: 18px;
}
footer span {
  letter-spacing: 0.25px;
  font-size: 12px;
}

/* Route badges (semantic service colors stay constant) */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  min-width: 64px;
  min-height: 28px;
  white-space: nowrap;
  text-align: center;
  background: #1874f5;
  color: #fff;
  border-radius: var(--r-sm);
  padding: 4px 10px;
  font: 700 13px/18px Helvetica, "Helvetica Neue", Arial, sans-serif;
  letter-spacing: 0;
}
.service-local {
  background: #1874f5;
  color: #fff;
}
.service-limited {
  background: #8854d0;
  color: #fff;
}
.service-sbs {
  background: #33d6e8;
  color: #072c34;
}
.service-express {
  background: #208348;
  color: #fff;
}
.service-rush {
  background: #c5a4ef;
  color: #26133e;
}

/* ---------- Map workspace ---------- */
.workspace {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border-radius: var(--r-xl);
  background: var(--md-surface-container-high);
}
#map {
  position: absolute;
  inset: 0;
}
#mapFallback {
  position: absolute;
  top: 88px;
  left: 24px;
  right: 24px;
  padding: 20px;
  border-radius: var(--r-lg);
  background: var(--md-surface-container-high);
  color: var(--md-on-surface);
  box-shadow: var(--e1);
}
.map-top {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  pointer-events: none;
}
.pill {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 16px;
  border: 0;
  border-radius: var(--r-full);
  background: var(--md-surface-container-lowest);
  color: var(--md-on-surface);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--e2);
}
button.pill {
  color: var(--md-primary);
}
.map-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
}
.map-tools select {
  width: auto;
  max-width: 150px;
  min-height: 40px;
  margin: 0;
  padding: 0 16px;
  border: 0;
  border-radius: var(--r-full);
  background: var(--md-surface-container-lowest);
  color: var(--md-on-surface);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--e2);
}
.map-tools select:focus {
  box-shadow: var(--e2), inset 0 0 0 2px var(--md-primary);
}

.service-legend {
  position: absolute;
  left: 16px;
  bottom: 32px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  max-width: calc(100% - 32px);
  padding: 8px 14px;
  border-radius: var(--r-md);
  background: var(--md-surface-container-lowest);
  color: var(--md-on-surface);
  box-shadow: var(--e1);
  font: 700 11px/16px Helvetica, "Helvetica Neue", Arial, sans-serif;
}
.service-legend span {
  display: flex;
  align-items: center;
  gap: 6px;
}
.service-legend span::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--service-color);
}
.legend-local {
  --service-color: #1874f5;
}
.legend-limited {
  --service-color: #8854d0;
}
.legend-sbs {
  --service-color: #33d6e8;
}
.legend-express {
  --service-color: #208348;
}
.legend-rush {
  --service-color: #c5a4ef;
}

/* MapLibre widgets */
.maplibregl-ctrl-top-right {
  top: 72px;
  right: auto;
  left: 8px;
}
.maplibregl-ctrl-group {
  border-radius: var(--r-lg) !important;
  background: var(--md-surface-container-lowest) !important;
  box-shadow: var(--e2) !important;
  overflow: hidden;
}
.maplibregl-ctrl-group button {
  min-height: 0;
  border-radius: 0;
}
.maplibregl-ctrl-group button + button {
  border-top: 1px solid var(--md-outline-variant);
}
.maplibregl-ctrl-icon {
  filter: var(--map-ctrl-icon-filter);
}
.maplibregl-popup-content {
  padding: 12px 16px;
  border-radius: var(--r-lg);
  color: #1b1b1f;
  font: 14px/20px var(--font);
  box-shadow: var(--e3);
}

/* ---------- Vehicle detail card ---------- */
#detail {
  position: absolute;
  right: 16px;
  bottom: 56px;
  width: 360px;
  max-height: calc(100% - 140px);
  overflow: auto;
  padding: 24px;
  border-radius: var(--r-xl);
  background: var(--md-surface-container);
  color: var(--md-on-surface);
  box-shadow: var(--e3);
}
#detail:has(#infoPanel:not([hidden])) {
  max-height: calc(100% - 110px);
}
#detail:has(#schedulePanel:not([hidden])) {
  width: min(470px, calc(100% - 32px));
  max-height: calc(100% - 100px);
  bottom: 48px;
}
.detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.detail-head button {
  width: 40px;
  min-height: 40px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--md-on-surface-variant);
  font-size: 24px;
  line-height: 1;
}
.eyebrow {
  color: var(--md-primary);
  font: 500 11px/16px var(--font);
  letter-spacing: 0.8px;
}
h1 {
  margin: 4px 0 16px;
  font: 400 28px/36px var(--font);
  letter-spacing: 0;
}
h2 {
  margin: 0 0 12px;
  font: 400 22px/28px var(--font);
  letter-spacing: 0;
}
.destination {
  display: flex;
  align-items: center;
  gap: 12px;
  line-height: 1.5;
}
.destination strong {
  font-weight: 500;
  min-width: 0;
  overflow-wrap: anywhere;
}
.status {
  display: inline-flex;
  align-items: center;
  margin: 16px 0 4px;
  padding: 4px 12px;
  border-radius: var(--r-sm);
  background: var(--md-primary-container);
  color: var(--md-on-primary-container);
  font-size: 12px;
  font-weight: 500;
  line-height: 20px;
}
.status.memory {
  background: var(--md-surface-variant);
  color: var(--md-on-surface-variant);
}
.detail-feed {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
  color: var(--md-on-surface-variant);
  font-size: 12px;
}
.detail-feed span {
  flex: 1;
}
.detail-feed button {
  width: 36px;
  min-height: 36px;
  padding: 0;
  border: 0;
  font-size: 20px;
  line-height: 1;
}
dl {
  margin: 8px 0;
}
dl > div {
  padding: 12px 0;
  border-top: 1px solid var(--md-outline-variant);
}
dt {
  margin-bottom: 4px;
  color: var(--md-on-surface-variant);
  font-size: 12px;
  font-weight: 500;
}
dd {
  margin: 0;
  line-height: 1.5;
}
.detail-tabs {
  display: flex;
  gap: 0;
  margin: 16px 0 8px;
  padding: 0;
  border-bottom: 1px solid var(--md-outline-variant);
}
.detail-tabs button {
  flex: 1;
  min-height: 48px;
  padding: 0 8px;
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  color: var(--md-on-surface-variant);
  font-size: 12px;
}
.detail-tabs .active {
  border-bottom-color: var(--md-primary);
  color: var(--md-primary);
  background: transparent;
}
.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}
.detail-actions button,
.detail-actions .map-link-button {
  min-height: 40px;
  padding: 0 16px;
  font-size: 13px;
}
#saveFavorite {
  width: 40px;
  padding: 0;
  font-size: 18px;
}
.detail-actions .map-link-button,
.detail-actions #detailMapLink {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--md-outline);
  border-radius: var(--r-full);
  background: transparent;
  color: var(--md-primary);
  font-weight: 500;
  font-size: 13px;
}
.detail-actions .map-link-button:hover,
.detail-actions #detailMapLink:hover {
  background: color-mix(in srgb, var(--md-primary) 8%, transparent);
}
.detail-actions .location-emoji {
  width: 18px;
  height: 18px;
}
#edit {
  width: 100%;
  margin-top: 12px;
}
#metadata {
  font-size: 14px;
  line-height: 1.6;
}
#metadata h3 {
  margin: 16px 0 8px;
  font: 500 14px/20px var(--font);
}
#metadata a,
#detailMapLink {
  color: var(--md-primary);
}
#metadata a {
  display: inline-block;
  margin-top: 8px;
}
.vehicle-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 16px;
}
.vehicle-info-grid dd {
  font-weight: 500;
}
.vehicle-notes {
  white-space: pre-wrap;
  line-height: 1.6;
}
.image-credit {
  color: var(--md-on-surface-variant);
  font-size: 12px;
}

/* Trip schedule panel */
.schedule-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 16px 0;
}
.schedule-panel-head h2 {
  margin: 0;
  font-size: 18px;
  line-height: 24px;
}
.schedule-panel-head button {
  width: 36px;
  min-height: 36px;
  padding: 0;
  border: 0;
  font-size: 20px;
}
.schedule-note {
  color: var(--md-on-surface-variant);
  font-size: 12px;
  line-height: 1.6;
}
.schedule-stops,
.block-trips {
  list-style: none;
  margin: 12px 0;
  padding: 0;
}
.schedule-stops li {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-top: 1px solid var(--md-outline-variant);
  font-size: 12px;
  line-height: 1.5;
}
.schedule-stop-time {
  flex-shrink: 0;
  color: var(--md-primary);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}
.block-trips li {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 8px 0;
  padding: 12px 16px;
  border: 1px solid var(--md-outline-variant);
  border-radius: var(--r-md);
  font-size: 12px;
}
.block-trips .current-trip {
  border-color: transparent;
  background: var(--md-primary-container);
  color: var(--md-on-primary-container);
}
.block-trips small {
  color: var(--md-on-surface-variant);
  overflow-wrap: anywhere;
}
.schedule-trip-id,
#scheduleContent dd {
  overflow-wrap: anywhere;
}
#scheduleContent h3 {
  margin: 20px 0 8px;
  font: 500 14px/20px var(--font);
}
#scheduleContent > dl {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 16px;
  margin: 8px 0;
}
#scheduleContent > dl > div {
  padding: 8px 0;
}
#scheduleContent > dl dt {
  font-size: 11px;
}
#scheduleContent > dl dd {
  font-size: 11px;
  line-height: 1.5;
}
#scheduleContent > dl > div:last-child {
  grid-column: 1 / -1;
}

/* ---------- Vehicles table view ---------- */
#tableView {
  position: absolute;
  inset: 72px 0 0;
  overflow: auto;
  padding: 24px 24px 32px;
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  background: var(--md-surface-container-low);
}
#tableView h1 {
  margin-top: 0;
}
.table-wrap {
  overflow: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}
th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--md-outline-variant);
}
th {
  color: var(--md-on-surface-variant);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.5px;
}
tbody tr:hover {
  background: color-mix(in srgb, var(--md-primary) 6%, transparent);
}
td button {
  min-height: 32px;
  padding: 0 14px;
  border: 0;
  background: var(--md-secondary-container);
  color: var(--md-on-secondary-container);
  font-size: 13px;
}

/* ---------- Dialog ---------- */
dialog {
  width: min(560px, 95vw);
  max-height: 90dvh;
  padding: 24px;
  border: 0;
  border-radius: var(--r-xl);
  background: var(--md-surface-container-high);
  color: var(--md-on-surface);
  box-shadow: var(--e3);
}
dialog::backdrop {
  background: var(--md-scrim);
}
dialog h2 {
  font-size: 24px;
  line-height: 32px;
}
dialog p {
  color: var(--md-on-surface-variant);
  line-height: 1.5;
}
dialog label {
  margin: 12px 0;
}
dialog form > .primary {
  margin-top: 8px;
  float: right;
}
.check {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: var(--md-on-surface);
}
.check input {
  width: 18px;
  margin: 0;
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
#editError {
  color: var(--md-error);
}

/* ---------- Embed settings view ---------- */
.settings-open main {
  grid-template-columns: 1fr;
  padding-left: 16px;
}
.settings-open aside {
  display: none;
}
.settings-open .workspace > #map,
.settings-open .map-top,
.settings-open #detail,
.settings-open #mapFallback,
.settings-open .service-legend {
  display: none;
}
#settingsView {
  position: absolute;
  inset: 0;
  z-index: 5;
  overflow: auto;
  padding: 36px 40px 60px;
  background: var(--md-surface-container-low);
}
.settings-heading {
  max-width: 1250px;
  margin: 0 auto 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.settings-heading h1 {
  margin: 4px 0 8px;
  font-size: 36px;
  line-height: 44px;
}
.settings-heading p,
.settings-controls > p,
.preview-help {
  color: var(--md-on-surface-variant);
  line-height: 1.6;
  margin-top: 0;
}
.settings-chip {
  padding: 6px 14px;
  border-radius: var(--r-sm);
  background: var(--md-tertiary-container);
  color: var(--md-on-tertiary-container);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.8px;
  white-space: nowrap;
}
.settings-layout {
  display: grid;
  grid-template-columns: minmax(320px, 440px) minmax(340px, 1fr);
  gap: 32px;
  max-width: 1250px;
  margin: auto;
  align-items: start;
}
.settings-controls {
  padding: 24px;
  border-radius: var(--r-xl);
  background: var(--md-surface-container);
}
.settings-controls h2 {
  font-size: 22px;
}
.settings-controls > p {
  margin: 0 0 16px;
  font-size: 13px;
}
.embed-toggle-group {
  min-width: 0;
  margin: 24px 0 0;
  padding: 0;
  border: 0;
}
.embed-toggle-group:first-child {
  margin-top: 0;
}
.embed-toggle {
  position: relative;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 0;
  border-top: 1px solid var(--md-outline-variant);
  cursor: pointer;
}
.toggle-copy {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.toggle-copy strong {
  color: var(--md-on-surface);
  font-size: 14px;
  font-weight: 500;
}
.toggle-copy > span {
  font-size: 12px;
  line-height: 1.5;
}
.embed-toggle input {
  position: absolute;
  right: 0;
  width: 52px;
  height: 32px;
  margin: 0;
  padding: 0;
  opacity: 0;
  cursor: pointer;
}
/* M3 switch */
.toggle-track {
  position: relative;
  flex-shrink: 0;
  width: 52px;
  height: 32px;
  border: 2px solid var(--md-outline);
  border-radius: var(--r-full);
  background: var(--md-surface-container-highest);
  pointer-events: none;
  transition:
    background-color 0.2s,
    border-color 0.2s;
}
.toggle-track::after {
  content: "";
  position: absolute;
  top: 6px;
  left: 6px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--md-outline);
  transition:
    transform 0.2s,
    width 0.2s,
    height 0.2s,
    top 0.2s,
    left 0.2s,
    background-color 0.2s;
}
.embed-toggle input:checked + .toggle-track {
  background: var(--md-primary);
  border-color: var(--md-primary);
}
.embed-toggle input:checked + .toggle-track::after {
  top: 2px;
  left: 20px;
  width: 24px;
  height: 24px;
  background: var(--md-on-primary);
}
.embed-toggle:hover input:not(:checked) + .toggle-track::after {
  background: var(--md-on-surface-variant);
}
.embed-toggle input:focus-visible + .toggle-track {
  outline: 2px solid var(--md-primary);
  outline-offset: 2px;
}
.embed-toggle-group .toggle-copy strong {
  font-size: 13px;
}
.embed-toggle-group .toggle-copy > span {
  font-size: 11px;
}
.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 24px 0 12px;
}
#settingsMessage {
  min-height: 20px;
  margin: 0;
  color: var(--md-primary);
}
.preview-column {
  position: sticky;
  top: 0;
}
.preview-label {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin: 2px 0 12px;
  color: var(--md-on-surface-variant);
  font-size: 12px;
}
.preview-label > span:first-child {
  color: var(--md-primary);
  font-weight: 500;
  letter-spacing: 0.8px;
}
.preview-help {
  max-width: 600px;
  margin: 16px 0;
  font-size: 12px;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------- Discord embed preview ----------
   Deliberately kept faithful to how Discord renders the embed, so users see
   what their members will see; only the surrounding frame is themed. */

.discord-preview {
  padding: 24px;
  background: #313338;
  border: 1px solid #4c4e54;
  border-radius: 14px;
  color: #dbdee1;
  font-family: Helvetica, Arial, sans-serif;
}
.preview-author {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  font-size: 12px;
  flex-wrap: wrap;
}
.preview-author img {
  width: 32px;
  height: 32px;
  filter: brightness(0) invert(1);
  margin-right: 3px;
}
.preview-author strong {
  font-size: 16px;
  color: #61b9eb;
}
.preview-author > span:last-child {
  color: #a8aab1;
}
.app-tag {
  background: #5865f2;
  color: white;
  border-radius: 4px;
  padding: 2px 5px;
  font-size: 10px;
  font-weight: bold;
}
.embed-card {
  border-left: 4px solid #23c76b;
  border-radius: 5px;
  background: #2b2d31;
  padding: 22px;
  box-shadow: 0 2px 4px #0001;
}
.embed-card h2 {
  font-size: 21px;
  color: #f2f3f5;
  margin: 0 0 18px;
}
.embed-card h3 {
  font-size: 15px;
  color: #f2f3f5;
  margin: 0 0 6px;
}
.embed-card p {
  font-size: 14px;
  line-height: 1.6;
  margin: 0;
  white-space: pre-line;
}
.embed-card section {
  margin: 17px 0;
}
.embed-status {
  color: #84e5ac;
}
.embed-route {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 15px 0;
}
.embed-route strong {
  font-size: 14px;
}
#embedMap {
  height: 245px;
  border-radius: 8px;
  overflow: hidden;
  margin: 18px 0;
  background: #dedede;
}
#previewMapLink {
  color: #8ebaff;
  display: block;
  margin: 15px 0;
  font-size: 13px;
}
.embed-footer {
  font-size: 11px;
  color: #9ca0a7;
  border-top: 1px solid #44464d;
  padding-top: 13px;
  margin-top: 20px;
}
@media (max-width: 950px) {
  .discord-preview {
    padding: 18px;
  }
  .embed-card {
    padding: 16px;
  }
}
.discord-preview {
  background: #f0f0f2;
  border-color: #dcdde0;
  color: #313239;
  color-scheme: light;
  border-radius: 10px;
}
.preview-author strong {
  color: #269be7;
}
.preview-author > span:last-child {
  color: #747681;
}
.preview-author img {
  filter: none;
  background: white;
  border-radius: 50%;
  padding: 5px;
}
.embed-card {
  background: #fff;
  border: 1px solid #e1e1e5;
  border-left: 5px solid #22ce66;
  border-radius: 10px;
  padding: 20px;
  color: #313239;
  box-shadow: none;
}
.embed-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid #e5e5e8;
  padding: 0 0 15px;
  margin: 0 0 17px;
}
.embed-card .embed-title h2 {
  color: #292a30;
  font-weight: 750;
  font-size: 23px;
  margin: 0;
}
.embed-bus-icon {
  font-size: 23px;
}
.embed-title button {
  background: #f2f2f4;
  border-color: #e0e0e4;
  color: #33343b;
  padding: 9px 12px;
  border-radius: 10px;
  white-space: nowrap;
}
.embed-card button:disabled,
.embed-card select:disabled {
  cursor: default;
  opacity: 1;
}
.embed-card h3 {
  font-size: 23px;
  font-weight: 750;
  color: #292a30;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 11px;
}
.embed-activities h3 > span:last-child,
.embed-insights h3 > span:last-child {
  text-decoration: underline;
}
.embed-section-icon {
  font-size: 27px;
  line-height: 1;
  color: #abadb1;
  display: inline-block;
  margin-right: 5px;
}
.embed-card section {
  margin: 19px 0;
}
.embed-card p {
  font-size: 16px;
  line-height: 1.5;
}
.embed-card .embed-status {
  border-left: 4px solid #c9cacf;
  padding-left: 15px;
  color: #5f616c;
  margin: 0 0 23px;
}
.trackable-word {
  text-decoration: underline;
}
.signal-icon {
  color: #4bd878;
  font-size: 23px;
}
.embed-card .embed-updated {
  margin: 23px 0 15px;
}
.embed-updated p {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 17px;
}
.embed-time {
  display: inline-block;
  background: #eeeef1;
  padding: 2px 5px;
  border-radius: 4px;
  font-weight: 700;
}
.insight-label {
  display: block;
  font-size: 16px;
  margin-top: 2px;
}
.embed-card .embed-route {
  gap: 0;
  margin: 0;
  display: block;
}
.embed-route code {
  font:
    14px Helvetica,
    Arial,
    sans-serif;
  border: 1px solid #d7d7dc;
  border-radius: 3px;
  background: #f8f8fa;
  padding: 2px 4px;
}
.embed-predictions {
  border-top: 1px solid #e4e4e8;
  border-bottom: 1px solid #e4e4e8;
  padding: 16px 0;
}
.embed-predictions ul {
  padding-left: 20px;
  margin: 8px 0 0;
  font-size: 16px;
  line-height: 1.6;
}
.embed-predictions .embed-section-icon {
  color: #ffb52b;
}
.embed-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 12px 0;
}
.embed-controls button {
  background: #f8f8fa;
  color: #9b9ca3;
  border: 1px solid #eeeef1;
  border-radius: 9px;
  padding: 9px 12px;
  font-weight: 600;
}
.embed-snapshots select {
  background: #fff;
  color: #a5a6ad;
  border: 1px solid #e8e8ec;
  font-size: 15px;
  padding: 13px;
}
.embed-footer {
  color: #95969f;
  border-color: #eeeef1;
  font-size: 11px;
  margin-top: 14px;
  padding-top: 12px;
}
#embedMap {
  height: 300px;
  border-radius: 10px;
}
#previewMapLink {
  color: #1675c9;
}
@media (max-width: 950px) {
  .embed-card .embed-title h2 {
    font-size: 19px;
  }
  .embed-card h3 {
    font-size: 21px;
  }
  .embed-title {
    flex-wrap: wrap;
  }
  .embed-card p,
  .embed-predictions ul {
    font-size: 14px;
  }
}
@media (max-width: 700px) {
  .embed-title {
    flex-wrap: nowrap;
  }
  .embed-card .embed-title h2 {
    font-size: 18px;
  }
  .embed-title button {
    font-size: 12px;
    padding: 8px;
  }
}
.discord-preview {
  background: #313338;
  border-color: #484b52;
  color: #dbdee1;
  color-scheme: dark;
}
.preview-author strong {
  color: #59b6ed;
}
.preview-author > span:last-child {
  color: #a5a8b0;
}
.preview-author img {
  filter: brightness(0) invert(1);
  background: none;
  padding: 3px;
}
.embed-card {
  background: #2b2d31;
  border-color: #41434a;
  border-left-color: #23ce6b;
  color: #dbdee1;
}
.embed-title {
  border-color: #42454d;
}
.embed-card .embed-title h2,
.embed-card h3 {
  color: #f2f3f5;
}
.embed-title button {
  background: #383a40;
  border-color: #494c55;
  color: #e0e1e5;
}
.embed-card .embed-status {
  border-left-color: #565a65;
  color: #b8bbc5;
}
.embed-section-icon {
  color: #a7aab3;
}
.embed-time {
  background: #404249;
  color: #f0f1f3;
}
.embed-route code {
  background: #383a40;
  border-color: #555862;
  color: #e5e7ed;
}
.embed-predictions {
  border-color: #42454d;
}
.embed-controls button {
  background: #33353b;
  border-color: #43464f;
  color: #969aa5;
}
.embed-snapshots select {
  background: #303238;
  color: #a1a5af;
  border-color: #454852;
}
.embed-footer {
  color: #9398a5;
  border-color: #41444b;
}
#previewMapLink {
  color: #9bd9ce;
}
.embed-card .embed-emoji {
  width: 27px;
  height: 27px;
  object-fit: contain;
  display: inline-block;
  flex-shrink: 0;
  vertical-align: middle;
  filter: invert(1) brightness(1.7);
  mix-blend-mode: screen;
  margin-right: 5px;
}
.embed-card .embed-emoji.colored {
  filter: invert(1) hue-rotate(180deg) brightness(1.1);
}
.embed-status .embed-emoji {
  width: 22px;
  height: 22px;
  margin-left: 7px;
  margin-right: 0;
}
.embed-title button,
.embed-controls button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
.embed-title button .embed-emoji,
.embed-controls button .embed-emoji {
  width: 22px;
  height: 22px;
  margin: 0;
}
.embed-predictions li {
  list-style: none;
}
.embed-predictions ul {
  padding-left: 0;
}
.embed-predictions li .embed-emoji {
  width: 20px;
  height: 20px;
  margin-right: 8px;
}
.embed-card .embed-bus-badge {
  display: inline-block;
  width: 23px;
  height: 23px;
  border-radius: 50%;
  object-fit: contain;
  vertical-align: middle;
  margin: 0 4px;
}
.embed-title .embed-bus-badge {
  width: 32px;
  height: 32px;
  margin-left: 4px;
}
.embed-card .embed-route .embed-bus-badge {
  width: 23px;
  height: 23px;
  margin: 0 4px;
}
.embed-card .embed-predictions .embed-bus-badge {
  width: 22px;
  height: 22px;
}
.embed-card img[src="/emojis/insights.png"] {
  filter: none;
  mix-blend-mode: normal;
}
.map-link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid #43464f;
  background: #33353b;
  color: #dbdee1;
  padding: 9px 12px;
  border-radius: 9px;
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
}
.map-link-button:hover {
  background: #42454d;
}
.location-emoji {
  width: 22px;
  height: 22px;
  object-fit: contain;
  flex-shrink: 0;
}
.embed-controls-secondary {
  display: contents;
}
#previewMapLink {
  display: inline-flex;
  margin: 0;
  color: #dbdee1;
  font-size: 14px;
}

.discord-preview {
  border-radius: var(--r-xl);
  border: 0;
  padding: 20px;
}
.embed-card {
  border-radius: var(--r-lg);
}
#embedMap {
  border-radius: var(--r-md);
}

/* ---------- Responsive ---------- */
@media (max-width: 950px) {
  #settingsView {
    padding: 28px 20px;
  }
  .settings-layout {
    gap: 20px;
    grid-template-columns: minmax(280px, 1fr) minmax(320px, 1fr);
  }
  .settings-controls {
    padding: 20px;
  }
  .settings-chip {
    display: none;
  }
}
@media (max-width: 900px) {
  header {
    gap: 12px;
    padding: 0 12px;
  }
  .brand {
    font-size: 19px;
  }
  main {
    grid-template-columns: 290px 1fr;
  }
  aside {
    padding-left: 12px;
  }
  #detail {
    width: 300px;
    right: 12px;
    padding: 20px;
  }
  .nav {
    padding: 0 14px;
  }
}
@media (max-width: 700px) {
  .settings-open .workspace {
    height: auto;
    min-height: 1000px;
  }
  .settings-open #settingsView {
    position: relative;
    min-height: 1000px;
  }
  .settings-layout {
    grid-template-columns: 1fr;
  }
  .preview-column {
    position: static;
  }
  .settings-heading h1 {
    font-size: 28px;
    line-height: 36px;
  }
  .preview-label {
    flex-wrap: wrap;
  }
}
@media (max-width: 650px) {
  header {
    height: auto;
    min-height: 64px;
    flex-wrap: wrap;
    padding: 8px 12px 12px;
  }
  .brand {
    gap: 8px;
    font-size: 18px;
  }
  .brand-symbol {
    width: 30px;
    height: 30px;
  }
  nav {
    order: 3;
    width: 100%;
    overflow-x: auto;
  }
  .nav {
    flex: 1;
    padding: 0 10px;
    white-space: nowrap;
  }
  .discord {
    padding: 0 14px 0 12px;
    gap: 8px;
    font-size: 13px;
  }
  #notice {
    margin: 0 12px 8px;
  }
  main,
  .settings-open main {
    height: auto;
    display: flex;
    flex-direction: column;
    padding: 0 12px 12px;
  }
  .has-notice main {
    height: auto;
  }
  .workspace {
    height: 640px;
    order: 0;
    border-radius: var(--r-xl);
  }
  aside {
    order: 1;
    max-height: 600px;
    padding: 16px 0 0;
  }
  .map-top {
    top: 10px;
    left: 10px;
    right: 10px;
  }
  .pill,
  .map-tools select {
    min-height: 36px;
    padding: 0 12px;
    font-size: 12px;
  }
  .map-tools {
    gap: 6px;
  }
  .map-tools select {
    max-width: 112px;
  }
  #detail,
  #detail:has(#schedulePanel:not([hidden])) {
    width: calc(100% - 24px);
    right: 12px;
    bottom: 56px;
    padding: 20px;
  }
  .service-legend {
    left: 10px;
    bottom: 32px;
    gap: 4px 10px;
    font-size: 10px;
  }
  .filters {
    grid-template-columns: 1fr 1fr;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .maplibregl-ctrl-top-right {
    top: 56px;
  }
  .schedule-stops li {
    flex-direction: column;
    gap: 4px;
  }
}

.legend-inactive { --service-color: #8b9098; }

/* Neutral appearance control and themed filter menus. */
.appearance-toggle {
  margin-left: auto;
  width: 40px;
  min-width: 40px;
  padding: 8px;
  border: 0;
  color: var(--md-on-surface);
}
.appearance-toggle svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.filter-field { min-width: 0; }
.filter-label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--md-on-surface-variant);
}
.filter-select {
  display: flex;
  width: 100%;
  min-height: 44px;
  padding: 10px 16px;
  justify-content: space-between;
  border-radius: var(--r-md);
  border-color: var(--md-outline);
  color: var(--md-on-surface);
  background: var(--md-surface-container-low);
  text-align: left;
}
.filter-select[aria-expanded="true"] { border-color: var(--md-primary); }
.select-chevron { font-size: 20px; line-height: 16px; color: var(--md-on-surface-variant); }
.filter-popup {
  position: fixed;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  padding: 8px;
  border: 1px solid var(--md-outline-variant);
  border-radius: var(--r-lg);
  background: var(--md-surface-container-lowest);
  color: var(--md-on-surface);
  box-shadow: var(--e3);
  overflow: hidden;
}
.filter-popup input { flex-shrink: 0; padding: 10px 12px; font-size: 13px; }
.filter-options { min-height: 0; overflow-y: auto; margin-top: 6px; }
.filter-option {
  width: 100%;
  min-height: 40px;
  justify-content: flex-start;
  padding: 8px 12px;
  border: 0;
  border-radius: var(--r-sm);
  color: var(--md-on-surface);
  text-align: left;
  font-weight: 400;
}
.filter-option[aria-selected="true"] {
  background: var(--md-secondary-container);
  font-weight: 700;
}
.filter-option[aria-selected="true"]::after { content: "✓"; margin-left: auto; }
.filter-empty { padding: 4px 12px; font-size: 13px; color: var(--muted); }
