.em {
  --em-border: var(--rule);
  --em-paper: color-mix(in srgb, var(--panel) 62%, var(--bg));
  --em-ring: color-mix(in srgb, var(--text) 18%, var(--bg));
  --em-grid: color-mix(in srgb, var(--text) 5%, transparent);
  --em-window: 540px;
  color: var(--text); min-width: 0; padding: 12px 0 30px;
}
.em *, .em *::before, .em *::after { box-sizing: border-box; }
.em h1, .em h2, .em h3, .em p { margin: 0; }
.em h1, .em h2, .em h3 { font-style: normal; color: var(--text); }
.em .em-head h1 { font-size: clamp(28px,4vw,42px); font-weight: 800; letter-spacing: .025em; line-height: 1.35; }
.em .em-head p, .em .em-plot-top p { margin-top: 7px; color: var(--muted); font-size: 13px; line-height: 1.8; }
.em button, .em select { font: inherit; }
.em button { color: var(--text); }
.em button:not(:disabled), .em select { cursor: pointer; }
.em button:focus-visible, .em select:focus-visible, .em [tabindex]:focus-visible {
  outline: 2px solid var(--lime); outline-offset: 2px;
}
.em .em-toolbar { display: flex; flex-wrap: wrap; gap: 7px; margin: 22px 0 17px; }
.em-toolbar button {
  display: inline-flex; align-items: center; gap: 6px; min-height: 37px; border: 1px solid var(--rule); border-radius: 7px;
  background: var(--panel); padding: 5px 11px; white-space: nowrap; font-size: 12px; font-weight: 600;
}
.em-toolbar button[aria-pressed=true] { color: var(--lime); background: var(--lime-soft); border-color: var(--lime); }
.em-badge {
  display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
  width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid var(--em-line);
  background: var(--bg); color: var(--text); font: 700 12px/1 var(--font-mono);
}
.em .em-picker { display: flex; align-items: center; gap: 10px; margin: 0 0 15px; }
.em-picker label { color: var(--muted); font-size: 12px; font-weight: 650; }
.em-picker select { flex: 0 1 auto; width: min(270px,72%); min-width: 0; background: var(--panel); border: 1px solid var(--rule);
  color: var(--text); font-size: 13px; border-radius: 6px; padding: 8px 11px; }
.em-layout { display: grid; grid-template-columns: minmax(0,2.4fr) minmax(250px,1fr); align-items: start; gap: 16px; }
.em-plot, .em-detail { min-width: 0; border-radius: 12px; background: var(--panel); border: 1px solid var(--em-border); }
.em-plot { overflow: hidden; }
.em-plot-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 18px 14px; }
.em-plot-top h2 { font-size: 17px; display: flex; align-items: center; gap: 8px; }
.em .em-plot-top p { font-size: 12px; margin-top: 3px; }
.em-zoom { display: flex; align-items: center; flex: 0 0 auto; gap: 4px; }
.em-zoom button {
  width: 34px; height: 34px; display: grid; place-items: center; color: var(--text); background: var(--bg);
  border: 1px solid var(--em-border); border-radius: 6px; font: 600 17px/1 var(--font-mono);
}
.em-zoom button:disabled { opacity: .4; }
.em-map-viewport {
  position: relative; min-width: 0; max-height: var(--em-window); overflow: auto; overscroll-behavior: contain;
  border-block: 1px solid var(--em-border);
  background: radial-gradient(var(--em-grid) 1px, transparent 1.1px) var(--em-paper);
  background-size: 18px 18px; scrollbar-color: var(--rule) var(--bg);
}
.em-map { display: block; height: auto; }
.em-map .em-node { cursor: pointer; }
.em-map .em-walk { stroke: var(--muted); stroke-width: 2.8; stroke-dasharray: 4 4; }
.em-map .em-hit { fill: transparent; }
.em-map .em-ring { fill: transparent; stroke: transparent; stroke-width: 2.2; }
.em-map .em-dot { fill: var(--bg); stroke: var(--text); stroke-width: 2; }
.em-map .em-transfer .em-dot { fill: var(--text); stroke: var(--bg); stroke-width: 2.2; }
.em-map text {
  font: 650 13px/1 var(--font-sans); fill: var(--text);
  paint-order: stroke fill; stroke: var(--em-paper); stroke-width: 4px; stroke-linejoin: round;
}
.em-map .em-node[aria-pressed=true] .em-ring, .em-map .em-node:focus-visible .em-ring { stroke: var(--lime); }
.em-map .em-node[aria-pressed=true] text, .em-map .em-node:hover text { fill: var(--lime); }
.em-map .em-node[aria-pressed=true] .em-dot { fill: var(--lime); }
.em .em-map .em-node:focus-visible { outline: none; }
.em-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 17px; padding: 11px 17px; }
.em-legend > span { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11px; }
.em-map .em-rent-mark { fill: var(--orange); stroke: var(--bg); stroke-width: 1.3; }
.em-legend-rent { display: inline-block; width: 7px; height: 7px; transform: rotate(45deg); background: var(--orange); }
.em-stop-rent { display: inline-flex; align-items: center; gap: 5px; font-size: 10px; color: var(--orange); white-space: nowrap; }
.em-legend-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text); }
.em-legend-walk { width: 21px; border-top: 2px dashed var(--muted); }
.em-legend .em-mobile-hint { display: none; }
.em-detail { padding: 18px; scroll-margin-top: 15px; }
.em-detail:focus { outline: none; }
.em-station-head > span { color: var(--lime); font-size: 11px; font-weight: 650; }
.em-station-head h2 { font-size: 26px; line-height: 1.4; margin-top: 3px; }
.em-station-head p { font-size: 12px; color: var(--muted); }
.em-detail h3 { margin: 17px 0 6px; font-size: 12px; }
.em-detail-lines, .em-walk-buttons { display: flex; flex-direction: column; gap: 3px; }
.em-detail-lines button, .em-walk-button { display: flex; align-items: center; gap: 6px; text-align: left; width: 100%;
  padding: 7px 8px; border: 1px solid transparent; border-radius: 6px; background: var(--bg); font-size: 12px; font-weight: 600; }
.em-detail-lines small { margin-left: auto; color: var(--muted); font: 600 11px var(--font-mono); }
.em-walk-button > span:last-child { margin-left: auto; color: var(--muted); }
.em [data-em-rent]:not(:empty) { border-top: 1px solid var(--rule); padding-top: 15px; margin-top: 17px; }
.em-list-scroll { overflow-y: auto; max-height: var(--em-window); scrollbar-color: var(--rule) var(--bg); border-top: 1px solid var(--rule); }
.em-stops { list-style: none; margin: 0; padding: 6px 15px; }
.em-stops li { position: relative; }
.em-stops li::before { content: ''; position: absolute; z-index: 1; top: 0; bottom: 0; left: 16px; width: 3px; background: var(--em-line); pointer-events: none; }
.em-stops li:first-child::before { top: 50%; }
.em-stops li:last-child::before { bottom: 50%; }
.em-stops button { display: flex; text-align: left; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; min-height: 55px;
  border: 1px solid transparent; border-radius: 6px; background: transparent; }
.em-stops button[aria-pressed=true] { background: var(--lime-soft); border-color: color-mix(in srgb,var(--lime) 58%,transparent); }
.em-line-dot { position: relative; z-index: 2; width: 13px; height: 13px; flex: 0 0 auto; border: 3px solid var(--em-line); border-radius: 50%; background: var(--panel); }
.em-code { flex: 0 0 auto; padding: 2px 4px; border: 1px solid var(--em-ring); border-radius: 4px; color: var(--muted); font: 600 11px/1.2 var(--font-mono); }
.em-stop { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 7px; min-width: 0; }
.em-stop b { font-size: 14px; }
.em-stop small { color: var(--muted); font-size: 11px; }
.em-line-links { margin-left: auto; display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 3px; }
.em-walk-label { font-size: 10px; color: var(--muted); white-space: nowrap; }
.em-loop { color: var(--muted); padding: 6px 16px 15px; font-size: 12px; }
@media (hover:hover) {
  .em-toolbar button:hover, .em-zoom button:not(:disabled):hover, .em-detail-lines button:hover, .em-walk-button:hover { border-color: var(--muted); }
  .em-stops button[aria-pressed=false]:hover { background: var(--panel2); }
}
@media (max-width: 920px) {
  .em-layout { grid-template-columns: minmax(0,1fr); }
  .em-legend .em-mobile-hint { display: inline; }
  .em { --em-window: 485px; }
}
@media (max-width: 600px) {
  .em { --em-window: 365px; padding-top: 4px; }
  .em .em-map { min-width: var(--em-mobile-min); }
  .em .em-toolbar { gap: 5px; margin: 16px 0 13px; }
  .em-toolbar button { font-size: 11px; padding: 4px 7px; }
  .em-toolbar .em-badge { width: 19px; height: 19px; font-size: 10px; }
  .em-plot-top, .em-detail { padding: 13px; }
  .em-legend { padding-inline: 12px; gap: 4px 9px; }
  .em-stops { padding: 4px; }
  .em-stops button { gap: 6px; }
  .em-stop { display: grid; }
}
