:root {
  --app-width: 560px;
  --bg: #eef1f5;
  --bg-deep: #e5e9ef;
  --surface: #ffffff;
  --surface-2: #f5f6f8;
  --surface-3: #eceef2;
  --ink: #171a20;
  --muted: #717883;
  --line: rgba(23, 26, 32, 0.09);
  --line-strong: rgba(23, 26, 32, 0.15);
  --accent: #0a84ff;
  --accent-soft: rgba(10, 132, 255, 0.12);
  --to: #1f9d55;
  --to-tint: rgba(31, 157, 85, 0.09);
  --from: #d64545;
  --from-tint: rgba(214, 69, 69, 0.08);
  --dir-from: #3b82c4;
  --dir-from-tint: rgba(59, 130, 196, 0.09);
  --warning: #b26a00;
  --warning-tint: rgba(255, 149, 0, 0.15);
  --glass: rgba(238, 241, 245, 0.84);
  --shadow: 0 12px 32px rgba(23, 32, 48, 0.1);
  --shadow-soft: 0 2px 10px rgba(23, 32, 48, 0.05);
  --radius: 18px;
  --radius-small: 12px;
  --anim: 340ms;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html[data-theme="dark"] {
  --bg: #0b0e13;
  --bg-deep: #080a0e;
  --surface: #171b22;
  --surface-2: #1e232b;
  --surface-3: #262c36;
  --ink: #f3f5f8;
  --muted: #9aa3ae;
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.16);
  --accent: #4fa3ff;
  --accent-soft: rgba(79, 163, 255, 0.16);
  --to: #4dcb80;
  --to-tint: rgba(77, 203, 128, 0.1);
  --from: #ff7070;
  --from-tint: rgba(255, 112, 112, 0.1);
  --dir-from: #7cc0f5;
  --dir-from-tint: rgba(124, 192, 245, 0.11);
  --warning: #ffb84d;
  --warning-tint: rgba(255, 184, 77, 0.14);
  --glass: rgba(11, 14, 19, 0.82);
  --shadow: 0 16px 36px rgba(0, 0, 0, 0.4);
  --shadow-soft: 0 2px 12px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
  background: var(--bg-deep);
  -webkit-text-size-adjust: 100%;
  scrollbar-color: var(--line-strong) transparent;
}

body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background:
    radial-gradient(1100px 600px at 50% -20%, rgba(10, 132, 255, 0.1), transparent 60%),
    var(--bg-deep);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
  cursor: pointer;
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.app {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: var(--app-width);
  height: 100vh;
  height: 100dvh;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(900px 420px at 100% 0%, var(--accent-soft), transparent 60%),
    var(--bg);
}

@media (min-width: 620px) {
  body {
    display: grid;
    place-items: center;
    padding: 18px;
  }

  .app {
    height: min(940px, calc(100dvh - 36px));
    min-height: 0;
    border: 1px solid var(--line);
    border-radius: 26px;
    box-shadow: 0 30px 90px rgba(10, 18, 32, 0.28);
  }
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(var(--safe-top) + 12px) 18px 6px;
  flex: 0 0 auto;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.brand-mark {
  font-size: 19px;
  font-weight: 850;
  letter-spacing: 0.06em;
  color: var(--ink);
}

.brand-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.net-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 650;
  color: var(--muted);
  white-space: nowrap;
}

.net-state::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--to);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--to) 16%, transparent);
}

html.is-offline .net-state::before {
  background: var(--from);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--from) 16%, transparent);
}

html.is-offline .net-state {
  color: var(--from);
}

.pager {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 14px 10px;
  flex: 0 0 auto;
  overflow-x: auto;
  scrollbar-width: none;
}

.pager::-webkit-scrollbar {
  display: none;
}

.pager-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 1 1 0;
  min-width: 50px;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.02em;
  box-shadow: var(--shadow-soft);
  transition: background 180ms ease, color 180ms ease, transform 180ms ease, border-color 180ms ease;
  -webkit-tap-highlight-color: transparent;
}

.pager-btn svg {
  width: 19px;
  height: 19px;
}

.pager-btn.is-active {
  background: var(--pager-color, var(--accent));
  border-color: transparent;
  color: var(--pager-ink, #fff);
  box-shadow: 0 8px 22px color-mix(in srgb, var(--pager-color, var(--accent)) 32%, transparent);
}

.pager-btn:active {
  transform: scale(0.96);
}

.pages {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  touch-action: pan-y;
  overscroll-behavior: contain;
}

.page {
  position: absolute;
  inset: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 2px 14px calc(26px + var(--safe-bottom));
  touch-action: pan-y;
  overscroll-behavior: contain;
  pointer-events: none;
  will-change: transform;
  transition: transform var(--anim) cubic-bezier(0.22, 0.8, 0.24, 1);
  scrollbar-width: none;
}

.page::-webkit-scrollbar {
  display: none;
}

.page.is-active {
  pointer-events: auto;
}

.pages.no-transition .page {
  transition: none !important;
}

.page-head {
  position: sticky;
  top: 0;
  z-index: 10;
  margin: -2px -14px 12px;
  padding: 8px 14px 11px;
  background: var(--glass);
  border-bottom: 1px solid var(--line);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  backdrop-filter: blur(16px) saturate(140%);
}

.station-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.line-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  min-width: 40px;
  height: 28px;
  padding: 0 9px;
  border-radius: 9px;
  background: var(--chip-color, var(--page-color, var(--accent)));
  color: var(--chip-ink, #fff);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.03em;
  box-shadow: 0 5px 14px color-mix(in srgb, var(--chip-color, var(--page-color, var(--accent))) 26%, transparent);
}

.station-button {
  display: flex;
  align-items: center;
  gap: 5px;
  flex: 1 1 auto;
  min-width: 0;
  padding: 4px 2px;
  border: 0;
  background: transparent;
  text-align: left;
}

.station-name {
  overflow: hidden;
  color: var(--ink);
  font-size: clamp(18px, 4.8vw, 22px);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.12;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chevron {
  display: inline-flex;
  flex: 0 0 auto;
  width: 15px;
  height: 15px;
  color: var(--muted);
  transform: rotate(90deg);
}

.chevron svg {
  width: 100%;
  height: 100%;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-soft);
  transition: transform 160ms ease, background 160ms ease;
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

.icon-btn:active {
  transform: scale(0.94);
}

.favorite-btn svg {
  transform: rotate(45deg);
}

.favorite-btn.is-favorite {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 32%, var(--line));
}

.refresh-btn:active svg {
  transform: rotate(45deg);
}

.refresh-btn svg {
  transition: transform 220ms ease;
}

.refresh-btn.is-busy svg {
  animation: spin 800ms linear infinite;
}

.location-refresh-btn.is-busy {
  opacity: 0.55;
}

.location-refresh-btn.is-busy svg {
  animation: pin-pulse 700ms ease-in-out infinite alternate;
}

@keyframes pin-pulse {
  from { transform: scale(1); }
  to { transform: scale(0.78); }
}

.station-sub {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 5px;
  padding-left: 2px;
  min-height: 16px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 550;
}

.distance {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--ink);
  font-weight: 700;
}

.distance::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: var(--page-color, var(--accent));
}

.status-text {
  transition: color 160ms ease;
}

.location-btn {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.location-btn:disabled {
  color: var(--muted);
  text-decoration: none;
  cursor: default;
}

.location-note {
  color: var(--warning);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.3;
}

.status-text.is-stale {
  color: var(--warning);
}

.status-text.is-error {
  color: var(--from);
}

.status-text.is-estimated {
  color: var(--accent);
}

.directions {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.direction {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.direction--to {
  --dir-color: var(--to);
  --dir-tint: var(--to-tint);
}

.direction--from {
  --dir-color: var(--dir-from);
  --dir-tint: var(--dir-from-tint);
}

.direction-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  background: var(--dir-tint);
  color: var(--dir-color);
  font-size: 15px;
  font-weight: 850;
  letter-spacing: 0.01em;
}

.direction-head::before {
  content: "";
  width: 7px;
  height: 7px;
  margin-right: -4px;
  border-radius: 999px;
  background: var(--dir-color);
}

.direction-head span:first-child {
  flex: 1 1 auto;
}

.direction-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--dir-color) 14%, transparent);
  color: var(--dir-color);
  font-size: 11px;
  font-weight: 800;
}

.direction-count:empty {
  display: none;
}

.direction-body {
  padding: 12px;
}

.direction-content {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.train-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease;
}

.train-card:hover {
  border-color: var(--line-strong);
}

.train-card:active {
  background: var(--surface-3);
}

.train-card:focus-visible {
  outline: 2px solid var(--page-color, var(--accent));
  outline-offset: 2px;
}

.train-card--estimated {
  border-style: dashed;
  border-color: color-mix(in srgb, var(--accent) 36%, var(--line));
}

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

.train-time {
  flex: 0 0 auto;
  color: var(--ink);
  font-size: clamp(26px, 7vw, 32px);
  font-variant-numeric: tabular-nums;
  font-weight: 850;
  letter-spacing: -0.04em;
  line-height: 1;
}

.delay {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--from);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0;
  vertical-align: middle;
  white-space: nowrap;
}

.train-dest {
  max-width: 64%;
  color: var(--ink);
  font-size: 14px;
  font-weight: 750;
  line-height: 1.25;
  text-align: right;
  overflow-wrap: anywhere;
}

.train-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 7px;
}

.train-no {
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.badge {
  display: inline-flex;
  align-items: center;
  max-width: 190px;
  padding: 3px 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--ink);
  font-size: 10.5px;
  font-weight: 750;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge--class {
  background: color-mix(in srgb, var(--page-color, var(--accent)) 15%, transparent);
  color: var(--page-color, var(--accent));
}

.badge--short {
  background: var(--warning-tint);
  color: var(--warning);
}

.badge--estimated {
  background: var(--accent-soft);
  color: var(--accent);
}

.stops {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 9px;
}

.stop {
  max-width: 100%;
  padding: 3px 7px;
  border-radius: 8px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 550;
  line-height: 1.25;
  overflow-wrap: anywhere;
  white-space: normal;
}

.stale-note {
  margin-top: 2px;
  padding: 7px 9px;
  border-radius: 9px;
  background: var(--warning-tint);
  color: var(--warning);
  font-size: 10.5px;
  font-weight: 650;
  line-height: 1.3;
}

.estimate-note {
  margin-bottom: 9px;
  padding: 7px 9px;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 10.5px;
  font-weight: 650;
  line-height: 1.3;
}

.more-btn {
  width: 100%;
  min-height: 38px;
  margin-top: 10px;
  border: 1px dashed var(--line-strong);
  border-radius: 11px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  transition: background 160ms ease, color 160ms ease;
}

.more-btn:active {
  background: var(--surface-2);
}

.state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 86px;
  padding: 14px;
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
}

.state--error {
  background: color-mix(in srgb, var(--from) 9%, transparent);
  color: var(--from);
}

.state-muted {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.state--empty {
  font-style: italic;
}

.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--line-strong);
  border-top-color: var(--page-color, var(--accent));
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

.spinner--large {
  width: 28px;
  height: 28px;
  border-width: 3px;
}

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

.retry-btn {
  min-height: 32px;
  padding: 0 13px;
  border: 1px solid color-mix(in srgb, var(--from) 30%, transparent);
  border-radius: 9px;
  background: transparent;
  color: var(--from);
  font-size: 11px;
  font-weight: 750;
}

.boot {
  position: absolute;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: var(--bg);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  transition: opacity 300ms ease, visibility 300ms ease;
}

.boot.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.settings-page {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 4px;
}

.settings-head {
  padding: 8px 4px 6px;
}

.settings-kicker {
  display: block;
  margin-bottom: 4px;
  color: var(--page-color, var(--accent));
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.settings-head h1 {
  margin: 0;
  font-size: clamp(26px, 7vw, 32px);
  font-weight: 850;
  letter-spacing: -0.04em;
}

.settings-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.settings-card {
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.settings-card h2 {
  margin: 0 0 9px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.settings-text {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.start-options {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.start-options--two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.start-option {
  min-height: 42px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
  letter-spacing: 0.03em;
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.start-option.is-active {
  border-color: transparent;
  background: var(--option-color, var(--accent));
  color: var(--option-ink, #fff);
  box-shadow: 0 6px 16px color-mix(in srgb, var(--option-color, var(--accent)) 26%, transparent);
}

.start-option:active {
  transform: scale(0.97);
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.setting-title {
  font-size: 14px;
  font-weight: 750;
}

.setting-note {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.switch {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
  cursor: pointer;
}

.switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.switch-track {
  position: relative;
  display: block;
  width: 48px;
  height: 28px;
  border-radius: 999px;
  background: var(--surface-3);
  border: 1px solid var(--line);
  transition: background 180ms ease, border-color 180ms ease;
}

.switch-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.22);
  transition: transform 180ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.switch input:checked + .switch-track {
  background: var(--accent);
  border-color: transparent;
}

.switch input:checked + .switch-track .switch-thumb {
  transform: translateX(20px);
}

.switch input:focus-visible + .switch-track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.primary-btn,
.secondary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 800;
  transition: transform 150ms ease, opacity 150ms ease, background 150ms ease;
}

.primary-btn {
  border: 0;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 100%, #fff 8%), var(--accent));
  color: #fff;
  box-shadow: 0 8px 20px color-mix(in srgb, var(--accent) 26%, transparent);
}

.secondary-btn {
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--ink);
}

.primary-btn:active,
.secondary-btn:active {
  transform: scale(0.985);
}

.primary-btn:disabled,
.secondary-btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.progress {
  height: 6px;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-3);
}

.progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 180ms ease;
}

.settings-status {
  min-height: 17px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.settings-status.is-info {
  color: var(--accent);
}

.settings-status.is-success {
  color: var(--to);
}

.settings-status.is-error {
  color: var(--from);
}

.settings-facts {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-top: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--line);
}

.fact-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 11px;
  background: var(--surface-2);
  font-size: 11.5px;
}

.fact-row span {
  color: var(--muted);
}

.fact-row strong {
  color: var(--ink);
  font-size: 11.5px;
  font-weight: 750;
  text-align: right;
}

.fact-row strong.is-bad {
  color: var(--from);
}

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(4, 8, 14, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

.sheet-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.sheet {
  position: fixed;
  bottom: 0;
  left: 50%;
  z-index: 81;
  display: flex;
  flex-direction: column;
  width: min(100%, var(--app-width));
  max-height: 84dvh;
  padding-bottom: var(--safe-bottom);
  overflow: hidden;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 24px 24px 0 0;
  background: var(--surface);
  box-shadow: 0 -24px 60px rgba(0, 0, 0, 0.28);
  transform: translate3d(-50%, 104%, 0);
  transition: transform 280ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.sheet.is-open {
  transform: translate3d(-50%, 0, 0);
}

.sheet-handle {
  width: 40px;
  height: 4px;
  margin: 8px auto 4px;
  border-radius: 999px;
  background: var(--line-strong);
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 14px 10px;
}

.sheet-title-wrap {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.sheet-title-wrap h2 {
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.02em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sheet-tools {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 14px 10px;
}

.search-field {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
}

.search-icon {
  display: inline-flex;
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  color: var(--muted);
}

.search-icon svg {
  width: 100%;
  height: 100%;
}

.search-field input {
  flex: 1 1 auto;
  min-width: 0;
  height: 40px;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
}

.search-field input::placeholder {
  color: var(--muted);
}

.search-field input::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

.locate-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  border: 1px solid color-mix(in srgb, var(--accent) 26%, transparent);
  border-radius: 11px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 750;
}

.locate-btn svg {
  width: 16px;
  height: 16px;
}

.locate-btn.is-busy {
  opacity: 0.65;
}

.sheet-list {
  flex: 1 1 auto;
  min-height: 120px;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-top: 1px solid var(--line);
  scrollbar-width: none;
}

.sheet-list::-webkit-scrollbar {
  display: none;
}

.station-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 52px;
  padding: 10px 16px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  text-align: left;
}

.station-item:active {
  background: var(--surface-2);
}

.station-item.is-selected {
  background: var(--accent-soft);
}

.station-item-main {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.station-item-name {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 700;
}

.station-name-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.favorite-mark {
  display: inline-flex;
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  color: var(--accent);
}

.favorite-mark svg {
  width: 100%;
  height: 100%;
  transform: rotate(45deg);
}

.station-item-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 550;
}

.mini-badge {
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--to-tint);
  color: var(--to);
  font-size: 9.5px;
  font-weight: 800;
}

.mini-badge--muted {
  background: var(--surface-3);
  color: var(--muted);
}

.mini-badge--estimate {
  background: var(--accent-soft);
  color: var(--accent);
}

.station-item-side {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  flex: 0 0 auto;
  width: 26px;
}

.station-check {
  display: inline-flex;
  width: 20px;
  height: 20px;
  padding: 3px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
}

.station-check svg {
  width: 100%;
  height: 100%;
}

.sheet-empty {
  padding: 28px 16px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.sheet-note {
  min-height: 21px;
  padding: 6px 16px 10px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 600;
}

.noscript {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  text-align: center;
}


.badge--delay {
  background: var(--from);
  color: #fff;
}

.train-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(4, 8, 14, 0.58);
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}

.train-modal-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.train-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 91;
  display: flex;
  flex-direction: column;
  width: min(calc(100% - 24px), var(--app-width));
  max-height: 88dvh;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.38);
  opacity: 0;
  pointer-events: none;
  transform: translate3d(-50%, -46%, 0) scale(0.97);
  transition: opacity 220ms ease, transform 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.train-modal.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translate3d(-50%, -50%, 0) scale(1);
}

.train-modal:focus,
.train-modal:focus-visible,
.sheet:focus,
.sheet:focus-visible {
  outline: none;
}

.train-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--glass);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  backdrop-filter: blur(16px) saturate(140%);
}

.train-modal-head-main {
  min-width: 0;
}

.train-modal-kicker {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 700;
}

.train-modal-kicker .line-chip {
  height: 24px;
  min-width: 34px;
  padding: 0 8px;
  border-radius: 7px;
  font-size: 10.5px;
}

#train-modal-subtitle {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.train-modal-head h2 {
  margin: 6px 0 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 20px;
  font-weight: 850;
  letter-spacing: -0.03em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.train-modal-body {
  display: flex;
  flex-direction: column;
  gap: 15px;
  flex: 1 1 auto;
  min-height: 0;
  padding: 14px 16px calc(18px + var(--safe-bottom));
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
}

.train-modal-body::-webkit-scrollbar {
  display: none;
}

.estimate-banner {
  padding: 9px 11px;
  border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--line));
  border-radius: 11px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.35;
}

.train-modal-hero {
  padding: 15px;
  border: 1px solid color-mix(in srgb, var(--modal-line) 28%, var(--line));
  border-radius: 16px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--modal-line) 16%, transparent), transparent 70%),
    var(--surface-2);
}

.train-modal-hero-top {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.train-modal-time {
  color: var(--ink);
  font-size: clamp(34px, 10vw, 46px);
  font-variant-numeric: tabular-nums;
  font-weight: 850;
  letter-spacing: -0.05em;
  line-height: 1;
}

.train-modal-dest {
  margin-top: 7px;
  color: var(--ink);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.train-modal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 11px;
}

.train-modal-meta .badge {
  font-size: 10.5px;
}

.detail-section {
  min-width: 0;
}

.detail-section h3 {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 850;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.detail-grid {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--line);
}

.detail-row {
  display: grid;
  grid-template-columns: minmax(108px, 0.85fr) minmax(0, 1.15fr);
  gap: 12px;
  padding: 9px 11px;
  background: var(--surface-2);
}

.detail-row dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.35;
}

.detail-row dd {
  margin: 0;
  color: var(--ink);
  font-size: 11.5px;
  font-weight: 650;
  line-height: 1.35;
  text-align: right;
  overflow-wrap: anywhere;
}

.detail-raw {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 9.5px;
  font-weight: 500;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.train-modal-body .stops {
  margin-top: 0;
}

.raw-block {
  margin-top: 9px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
}

.raw-block > span {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 750;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.raw-block p {
  margin: 0;
  color: var(--ink);
  font-size: 11px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.detail-collapsible {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
}

.detail-collapsible summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 12px;
  color: var(--ink);
  font-size: 11.5px;
  font-weight: 750;
  cursor: pointer;
  list-style: none;
}

.detail-collapsible summary::-webkit-details-marker {
  display: none;
}

.detail-collapsible summary::after {
  content: "+";
  color: var(--muted);
  font-size: 16px;
  font-weight: 500;
  line-height: 1;
}

.detail-collapsible[open] summary::after {
  content: "−";
}

.collapsible-inner {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 10px 10px;
}

.i18n-block {
  min-width: 0;
}

.i18n-block + .i18n-block {
  margin-top: 10px;
}

.i18n-block h4 {
  margin: 0 0 6px;
  color: var(--page-color, var(--accent));
  font-size: 10.5px;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.json-pre {
  max-height: 320px;
  margin: 0;
  padding: 10px;
  overflow: auto;
  border-radius: 9px;
  background: var(--bg-deep);
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.train-modal-source {
  padding-top: 2px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 550;
  text-align: center;
}

html.train-modal-open .page {
  overflow: hidden;
}

html.sheet-open .page {
  overflow: hidden;
}

@media (max-width: 360px) {
  .station-name {
    font-size: 17px;
  }

  .train-dest {
    max-width: 58%;
    font-size: 13px;
  }

  .pager-btn {
    min-width: 44px;
    padding: 0 7px;
  }
}

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

.share-url {
  width: 100%;
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  text-overflow: ellipsis;
}

.share-url:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.share-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.donate-card {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.donate-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 12px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 100%, #fff 8%), var(--accent));
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  text-align: center;
  text-decoration: none;
  box-shadow: 0 8px 20px color-mix(in srgb, var(--accent) 26%, transparent);
  transition: transform 150ms ease;
}

.donate-link:active {
  transform: scale(0.985);
}

.donate-qr-wrap {
  display: flex;
  justify-content: center;
  margin-top: 13px;
}

.donate-qr {
  display: block;
  width: min(180px, 60vw);
  height: auto;
  padding: 8px;
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--shadow-soft);
}

.donate-hint {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
  text-align: center;
}
