:root {
  --bg: #050d12;
  --bg-deep: #02070a;
  --panel: rgba(7, 18, 24, 0.94);
  --panel-strong: #0a1a22;
  --surface: rgba(18, 39, 49, 0.74);
  --surface-hover: rgba(25, 52, 64, 0.88);
  --border: rgba(154, 214, 220, 0.18);
  --border-strong: rgba(154, 224, 225, 0.34);
  --text: #effcfa;
  --muted: #94aaa9;
  --faint: #607878;
  --cyan: #67e8e3;
  --green: #72dfb4;
  --amber: #f4c95d;
  --rose: #ef6f91;
  --amtrak: #55a7ff;
  --via: #f4c95d;
  --brightline: #f06fc2;
  --other: #72dfb4;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.48), 0 4px 18px rgba(0, 0, 0, 0.3);
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --mobile-panel-height: min(59dvh, 570px);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  color: var(--text);
  background: var(--bg-deep);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input {
  font: inherit;
}

button,
summary,
label {
  -webkit-tap-highlight-color: transparent;
}

.experiment,
#map {
  position: fixed;
  inset: 0;
  min-width: 320px;
}

#map,
.leaflet-container {
  background:
    radial-gradient(circle at 50% 46%, rgba(41, 103, 105, 0.16), transparent 39%),
    linear-gradient(145deg, #07151c 0%, #031017 52%, #061118 100%);
  font-family: inherit;
}

.radar-grid {
  position: fixed;
  z-index: 250;
  inset: 0;
  pointer-events: none;
  opacity: 0.72;
  background-image:
    repeating-radial-gradient(circle at 55% 44%, transparent 0 10.8vmin, rgba(103, 232, 227, 0.045) 10.9vmin 11vmin),
    linear-gradient(90deg, transparent calc(55% - 0.5px), rgba(103, 232, 227, 0.05) 55%, transparent calc(55% + 0.5px)),
    linear-gradient(0deg, transparent calc(56% - 0.5px), rgba(103, 232, 227, 0.05) 56%, transparent calc(56% + 0.5px));
  mix-blend-mode: screen;
}

.tracker-panel {
  position: fixed;
  z-index: 1000;
  top: 16px;
  bottom: 16px;
  left: 16px;
  display: flex;
  width: clamp(370px, 31vw, 430px);
  min-height: 0;
  flex-direction: column;
  padding: 16px;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.025), transparent 38%),
    var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px) saturate(1.2);
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  flex: 0 0 auto;
}

.back-link {
  display: inline-flex;
  min-height: 22px;
  align-items: center;
  color: var(--cyan);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-decoration: none;
  text-transform: uppercase;
}

.back-link::before {
  content: "←";
  margin-right: 6px;
}

.back-link:hover {
  color: #a8fffa;
}

.eyebrow {
  margin: 8px 0 3px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(25px, 3vw, 32px);
  line-height: 1;
  font-weight: 780;
  letter-spacing: -0.035em;
}

.connection-badge {
  display: inline-flex;
  min-height: 27px;
  align-items: center;
  gap: 7px;
  margin-top: 2px;
  padding: 0 9px;
  flex: 0 0 auto;
  border: 1px solid rgba(114, 223, 180, 0.28);
  border-radius: 999px;
  color: var(--green);
  background: rgba(114, 223, 180, 0.08);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.connection-badge span,
.sync-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 12px currentColor;
}

.connection-badge.is-loading {
  color: var(--amber);
  border-color: rgba(244, 201, 93, 0.28);
  background: rgba(244, 201, 93, 0.08);
}

.connection-badge.is-stale,
.connection-badge.is-error {
  color: var(--rose);
  border-color: rgba(239, 111, 145, 0.3);
  background: rgba(239, 111, 145, 0.09);
}

.connection-badge:not(.is-error) span {
  animation: status-pulse 2.1s ease-out infinite;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  margin-top: 15px;
  flex: 0 0 auto;
}

.summary-grid > div {
  min-width: 0;
  padding: 9px 10px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(16, 36, 45, 0.64);
}

.summary-grid span,
.summary-grid small {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.summary-grid strong {
  display: inline-block;
  margin: 2px 5px 0 0;
  color: var(--cyan);
  font-family: var(--mono);
  font-size: 21px;
  line-height: 1;
}

.summary-grid small {
  display: inline;
  letter-spacing: 0;
  text-transform: none;
}

.filters {
  display: grid;
  gap: 9px;
  margin-top: 11px;
  flex: 0 0 auto;
}

.search-field {
  position: relative;
  display: flex;
  min-width: 0;
  align-items: center;
}

.search-field > svg {
  position: absolute;
  left: 11px;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: var(--muted);
  stroke-linecap: round;
  stroke-width: 1.8;
  pointer-events: none;
}

.search-field input {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  padding: 0 38px 0 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: 0;
  color: var(--text);
  background: rgba(3, 12, 17, 0.72);
  font-size: 13px;
}

.search-field input::placeholder {
  color: #78908f;
}

.search-field input:focus {
  border-color: rgba(103, 232, 227, 0.5);
  box-shadow: 0 0 0 3px rgba(103, 232, 227, 0.08);
}

.clear-search {
  position: absolute;
  right: 7px;
  display: inline-grid;
  width: 27px;
  height: 27px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

.clear-search:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
}

.operator-filters {
  display: flex;
  min-width: 0;
  gap: 6px;
  margin: 0;
  padding: 0;
  overflow-x: auto;
  border: 0;
  scrollbar-width: none;
}

.operator-filters::-webkit-scrollbar {
  display: none;
}

.operator-filters legend {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.operator-toggle {
  position: relative;
  display: block;
  flex: 0 0 auto;
  cursor: pointer;
}

.operator-toggle input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.operator-toggle span {
  display: inline-flex;
  min-height: 29px;
  align-items: center;
  gap: 6px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--faint);
  background: rgba(7, 19, 25, 0.76);
  font-size: 10px;
  font-weight: 750;
  transition: color 140ms ease, border-color 140ms ease, background-color 140ms ease;
}

.operator-toggle input:checked + span {
  color: var(--text);
  border-color: rgba(154, 224, 225, 0.28);
  background: rgba(27, 52, 61, 0.82);
}

.operator-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--other);
  box-shadow: 0 0 9px currentColor;
}

.operator-amtrak {
  color: var(--amtrak);
  background: var(--amtrak);
}

.operator-via {
  color: var(--via);
  background: var(--via);
}

.operator-brightline {
  color: var(--brightline);
  background: var(--brightline);
}

.operator-other {
  color: var(--other);
  background: var(--other);
}

.sync-row {
  display: flex;
  min-height: 39px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  padding: 7px 0;
  flex: 0 0 auto;
  border-top: 1px solid rgba(154, 214, 220, 0.1);
  border-bottom: 1px solid rgba(154, 214, 220, 0.1);
}

.sync-status {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
}

.sync-status > span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sync-status .sync-dot {
  color: var(--green);
}

.sync-status.is-loading .sync-dot {
  color: var(--amber);
  animation: status-pulse 1.4s ease-out infinite;
}

.sync-status.is-stale .sync-dot,
.sync-status.is-error .sync-dot {
  color: var(--rose);
}

.refresh-button {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  gap: 5px;
  padding: 0 8px;
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--cyan);
  background: rgba(20, 44, 53, 0.66);
  cursor: pointer;
  font-size: 10px;
  font-weight: 750;
}

.refresh-button svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.refresh-button:hover {
  border-color: rgba(103, 232, 227, 0.4);
  background: rgba(31, 62, 70, 0.78);
}

.refresh-button:disabled {
  opacity: 0.55;
  cursor: wait;
}

.refresh-button:disabled svg {
  animation: spin 1s linear infinite;
}

.train-detail {
  margin-top: 8px;
  padding: 11px;
  flex: 0 0 auto;
  border: 1px solid rgba(103, 232, 227, 0.25);
  border-radius: 9px;
  background: linear-gradient(135deg, rgba(30, 67, 74, 0.78), rgba(8, 27, 35, 0.86));
  box-shadow: inset 3px 0 0 var(--detail-color, var(--cyan));
}

.train-detail[hidden] {
  display: none;
}

.train-detail header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.train-detail h2 {
  margin: 1px 0 0;
  font-size: 18px;
  line-height: 1.1;
}

.detail-operator {
  margin-bottom: 0;
  color: var(--detail-color, var(--cyan));
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.train-detail header button {
  display: inline-grid;
  width: 28px;
  height: 28px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.16);
  cursor: pointer;
  font-size: 20px;
}

.detail-route {
  margin: 7px 0 0;
  overflow: hidden;
  color: var(--text);
  font-size: 11px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  margin: 10px 0 0;
}

.detail-facts div {
  min-width: 0;
}

.detail-facts dt {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.detail-facts dd {
  margin: 2px 0 0;
  overflow: hidden;
  color: var(--text);
  font-size: 10px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.train-list-section {
  display: flex;
  min-height: 92px;
  flex: 1 1 auto;
  flex-direction: column;
  margin-top: 8px;
  overflow: hidden;
}

.list-heading {
  display: flex;
  min-height: 25px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex: 0 0 auto;
}

.list-heading h2 {
  margin: 0;
  font-size: 12px;
  font-weight: 780;
  letter-spacing: 0.02em;
}

.list-heading span {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
}

.train-list {
  min-height: 0;
  margin: 0;
  padding: 0 3px 0 0;
  overflow-y: auto;
  list-style: none;
  scrollbar-color: rgba(103, 232, 227, 0.25) transparent;
  scrollbar-width: thin;
}

.train-list li + li {
  margin-top: 5px;
}

.train-list-button {
  display: grid;
  width: 100%;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 8px 9px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text);
  background: rgba(16, 35, 43, 0.6);
  cursor: pointer;
  text-align: left;
}

.train-list-button:hover {
  border-color: var(--border);
  background: var(--surface-hover);
}

.train-list-button.is-selected {
  border-color: color-mix(in srgb, var(--train-color) 48%, transparent);
  background: color-mix(in srgb, var(--train-color) 11%, rgba(15, 36, 44, 0.9));
}

.list-bearing {
  position: relative;
  display: inline-grid;
  width: 25px;
  height: 25px;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--train-color) 58%, transparent);
  border-radius: 50%;
  color: var(--train-color);
  background: color-mix(in srgb, var(--train-color) 12%, transparent);
}

.list-bearing svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
  filter: drop-shadow(0 0 4px currentColor);
  transform: rotate(var(--heading));
}

.list-bearing.is-unknown svg {
  transform: none;
}

.list-copy {
  min-width: 0;
}

.list-title-row {
  display: flex;
  min-width: 0;
  align-items: baseline;
  gap: 7px;
}

.list-title-row strong {
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-title-row span {
  overflow: hidden;
  color: var(--train-color);
  font-size: 9px;
  font-weight: 800;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.list-route {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  color: var(--muted);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-age {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 8px;
  text-align: right;
  white-space: nowrap;
}

.list-age.is-stale {
  color: var(--rose);
}

.list-age.is-aging {
  color: var(--amber);
}

.empty-state {
  margin: auto;
  padding: 18px 16px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
  text-align: center;
}

.empty-state[hidden] {
  display: none;
}

.source-disclosure {
  margin-top: 8px;
  flex: 0 0 auto;
  border-top: 1px solid rgba(154, 214, 220, 0.12);
}

.source-disclosure summary {
  padding: 8px 1px 0;
  color: var(--muted);
  cursor: pointer;
  font-size: 10px;
  font-weight: 700;
  list-style-position: inside;
}

.source-disclosure[open] {
  max-height: 44%;
  overflow-y: auto;
}

.source-body {
  padding: 9px 1px 2px;
}

.source-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin: 0;
}

.source-grid dt {
  color: var(--faint);
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.source-grid dd {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.4;
}

.source-grid a {
  color: var(--cyan);
  text-decoration-color: rgba(103, 232, 227, 0.4);
  text-underline-offset: 2px;
}

.coverage-list {
  margin: 8px 0 0;
  padding: 0;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.45;
  list-style: none;
}

.coverage-list li::before {
  content: "•";
  margin-right: 6px;
  color: var(--cyan);
}

.coverage-note {
  margin: 8px 0 0;
  color: var(--faint);
  font-size: 8px;
  line-height: 1.45;
}

.map-legend {
  position: fixed;
  z-index: 700;
  right: 16px;
  bottom: 16px;
  display: flex;
  max-width: min(620px, calc(100vw - 470px));
  flex-wrap: wrap;
  gap: 12px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(5, 15, 20, 0.82);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
  font-family: var(--mono);
  font-size: 9px;
  backdrop-filter: blur(12px);
}

.map-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.rail-line-swatch {
  display: inline-block;
  width: 18px;
  height: 2px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: #6eb7b7;
  box-shadow: 0 0 7px rgba(110, 183, 183, 0.65);
}

.route-line-swatch {
  display: inline-block;
  width: 18px;
  height: 3px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
}

.route-line-swatch.route-via {
  color: var(--via);
}

.route-line-swatch.route-brightline {
  color: var(--brightline);
}

.map-message {
  position: fixed;
  z-index: 720;
  top: 50%;
  left: calc(50% + 110px);
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  gap: 9px;
  max-width: min(360px, calc(100vw - 32px));
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(5, 16, 21, 0.9);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.4);
  font-family: var(--mono);
  font-size: 10px;
  transform: translate(-50%, -50%);
  backdrop-filter: blur(12px);
}

.map-message[hidden] {
  display: none;
}

.map-message.is-error {
  color: #ffd2dd;
  border-color: rgba(239, 111, 145, 0.36);
}

.map-message-pulse {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  color: var(--cyan);
  background: currentColor;
  box-shadow: 0 0 14px currentColor;
  animation: status-pulse 1.5s ease-out infinite;
}

.map-message.is-error .map-message-pulse {
  color: var(--rose);
  animation: none;
}

.leaflet-top.leaflet-right {
  top: 6px;
  right: 6px;
}

.leaflet-bar {
  overflow: hidden;
  border: 1px solid var(--border-strong) !important;
  border-radius: 8px !important;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.34) !important;
}

.leaflet-bar a,
.leaflet-bar a:hover {
  width: 36px;
  height: 36px;
  border-bottom-color: var(--border) !important;
  color: var(--text);
  background: rgba(6, 20, 26, 0.91);
  line-height: 36px;
}

.leaflet-bar a:hover {
  color: var(--cyan);
  background: rgba(19, 44, 52, 0.96);
}

.leaflet-control-scale-line {
  border-color: rgba(148, 184, 183, 0.45);
  color: var(--muted);
  background: rgba(4, 14, 19, 0.7);
  font-family: var(--mono);
  font-size: 8px;
  text-shadow: none;
}

.leaflet-bottom.leaflet-left {
  left: calc(clamp(370px, 31vw, 430px) + 24px);
  bottom: 8px;
}

.city-label-icon {
  width: auto !important;
  height: auto !important;
  border: 0;
  background: transparent;
}

.city-label-icon span {
  display: inline-block;
  padding: 2px 4px;
  color: rgba(190, 213, 211, 0.7);
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-shadow: 0 1px 3px #02070a, 0 0 8px #02070a;
  text-transform: uppercase;
  white-space: nowrap;
}

.line-tooltip,
.train-tooltip {
  border: 1px solid var(--border-strong) !important;
  border-radius: 7px !important;
  color: var(--text) !important;
  background: rgba(5, 17, 23, 0.94) !important;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4) !important;
  font-family: inherit;
}

.line-tooltip::before,
.train-tooltip::before {
  border-top-color: rgba(5, 17, 23, 0.94) !important;
}

.tooltip-content strong {
  display: block;
  color: var(--tooltip-color, var(--cyan));
  font-size: 11px;
}

.tooltip-content span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 9px;
}

.train-marker-wrap {
  border: 0;
  background: transparent;
}

.train-marker-hitbox {
  position: relative;
  display: grid;
  width: 46px;
  height: 38px;
  place-items: center;
}

.train-bearing {
  position: relative;
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--train-color) 70%, white 8%);
  border-radius: 50%;
  color: var(--train-color);
  background: color-mix(in srgb, var(--train-color) 18%, rgba(3, 13, 17, 0.95));
  box-shadow: 0 0 0 3px rgba(3, 13, 17, 0.7), 0 0 16px color-mix(in srgb, var(--train-color) 48%, transparent);
}

.train-bearing svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
  filter: drop-shadow(0 0 4px currentColor);
  transform: rotate(var(--heading));
}

.train-bearing.is-unknown {
  width: 20px;
  height: 20px;
}

.train-bearing.is-unknown svg {
  width: 9px;
  height: 9px;
  transform: none;
}

.train-marker-number {
  position: absolute;
  right: -2px;
  bottom: -1px;
  max-width: 38px;
  padding: 1px 4px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--train-color) 55%, transparent);
  border-radius: 4px;
  color: var(--text);
  background: rgba(4, 14, 19, 0.94);
  font-family: var(--mono);
  font-size: 7px;
  font-weight: 800;
  line-height: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.train-marker-wrap.is-selected .train-bearing {
  border-color: #ffffff;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--train-color) 32%, transparent), 0 0 22px var(--train-color);
  transform: scale(1.12);
}

.train-marker-wrap:focus {
  outline: 0;
}

.train-marker-wrap:focus-visible .train-bearing {
  outline: 3px solid rgba(255, 255, 255, 0.9);
  outline-offset: 4px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

button:focus-visible,
input:focus-visible,
summary:focus-visible,
a:focus-visible,
.operator-toggle input:focus-visible + span {
  outline: 3px solid rgba(103, 232, 227, 0.48);
  outline-offset: 2px;
}

@keyframes status-pulse {
  0% { box-shadow: 0 0 0 0 currentColor; opacity: 1; }
  70% { box-shadow: 0 0 0 7px transparent; opacity: 0.8; }
  100% { box-shadow: 0 0 0 0 transparent; opacity: 1; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 760px) {
  #map,
  .radar-grid {
    bottom: var(--mobile-panel-height);
  }

  .tracker-panel {
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    width: auto;
    height: var(--mobile-panel-height);
    min-height: 330px;
    padding: 13px 14px calc(11px + env(safe-area-inset-bottom));
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 14px 14px 0 0;
  }

  .tracker-panel::before {
    content: "";
    position: absolute;
    top: 6px;
    left: 50%;
    width: 38px;
    height: 3px;
    border-radius: 999px;
    background: rgba(194, 230, 227, 0.28);
    transform: translateX(-50%);
  }

  .panel-header {
    padding-top: 3px;
  }

  .back-link {
    min-height: 18px;
    font-size: 9px;
  }

  .eyebrow {
    display: none;
  }

  h1 {
    margin-top: 3px;
    font-size: 22px;
  }

  .connection-badge {
    min-height: 24px;
    font-size: 8px;
  }

  .summary-grid {
    position: absolute;
    top: 13px;
    right: 95px;
    display: flex;
    gap: 10px;
    margin: 0;
  }

  .summary-grid > div {
    padding: 0;
    border: 0;
    background: transparent;
  }

  .summary-grid span {
    display: none;
  }

  .summary-grid small {
    display: inline;
    margin-left: 2px;
    font-size: 7px;
    letter-spacing: 0;
    text-transform: lowercase;
  }

  .summary-grid strong {
    margin: 0;
    font-size: 16px;
  }

  .filters {
    grid-template-columns: minmax(130px, 1fr) minmax(0, 1.35fr);
    gap: 7px;
    margin-top: 9px;
  }

  .search-field input {
    min-height: 36px;
    font-size: 11px;
  }

  .operator-filters {
    align-items: center;
  }

  .operator-toggle span {
    min-height: 27px;
    padding: 0 8px;
    font-size: 9px;
  }

  .sync-row {
    min-height: 34px;
    margin-top: 6px;
    padding: 4px 0;
  }

  .train-detail {
    padding: 8px 10px;
  }

  .detail-facts {
    margin-top: 7px;
  }

  .source-disclosure {
    margin-top: 5px;
  }

  .source-disclosure summary {
    padding-top: 6px;
  }

  .map-legend {
    display: none;
  }

  .map-message {
    top: calc((100dvh - var(--mobile-panel-height)) / 2);
    left: 50%;
  }

  .leaflet-bottom.leaflet-left {
    bottom: 5px;
    left: 4px;
  }
}

@media (max-width: 480px) {
  :root {
    --mobile-panel-height: min(62dvh, 590px);
  }

  .summary-grid {
    right: 91px;
    gap: 7px;
  }

  .summary-grid > div:nth-child(3) {
    display: none;
  }

  .filters {
    grid-template-columns: minmax(135px, 1fr) minmax(0, 1fr);
  }

  .operator-toggle span {
    width: 28px;
    justify-content: center;
    padding: 0;
    font-size: 0;
  }

  .operator-toggle .operator-dot {
    width: 8px;
    height: 8px;
  }

  .sync-status {
    font-size: 9px;
  }

  .refresh-button {
    width: 29px;
    padding: 0;
    justify-content: center;
    font-size: 0;
  }

  .refresh-button svg {
    width: 14px;
    height: 14px;
  }

  .detail-facts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .detail-facts div:nth-child(n+5) {
    display: none;
  }
}

@media (max-height: 650px) and (min-width: 761px) {
  .tracker-panel {
    top: 8px;
    bottom: 8px;
  }

  .summary-grid {
    margin-top: 9px;
  }

  .summary-grid > div {
    padding-top: 6px;
    padding-bottom: 6px;
  }

  .filters {
    margin-top: 8px;
  }

  .train-detail {
    padding-top: 8px;
    padding-bottom: 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
