/* Underly — responsive styles
   Mobile-first; breakpoints: 431px (tablet), 769px (desktop) */

/* ========== Design tokens ========== */
:root {
  --bg: #f8f9fa;
  --bg-card: #ffffff;
  --text: #1a1a1a;
  --text-muted: #6c757d;
  --accent: #0d6efd;
  --accent-hover: #0b5ed7;
  --accent-from: #198754;
  --accent-to: #dc3545;
  --border: #dee2e6;
  --shadow: 0 1px 3px rgba(0,0,0,.08);
  --shadow-lg: 0 4px 14px rgba(0,0,0,.12);
  --radius: 12px;
  --radius-sm: 8px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, sans-serif;
  --tap-min: 44px;
  --header-h: 52px;
  --actions-h: 56px;
  --app-vh: 100dvh;
  --header-runtime-h: var(--header-h);
  --actions-runtime-h: var(--actions-h);
  --main-vh: calc(var(--app-vh) - var(--header-runtime-h));
  --sheet-max-h: 60vh;
}

[data-theme="dark"] {
  --bg: #121212;
  --bg-card: #1e1e1e;
  --text: #e9ecef;
  --text-muted: #adb5bd;
  --border: #343a40;
  --shadow: 0 1px 3px rgba(0,0,0,.3);
  --shadow-lg: 0 4px 14px rgba(0,0,0,.4);
}

/* ========== Base ========== */
*, *::before, *::after { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  font-size: 16px;
}
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.4;
  min-height: var(--app-vh);
  overflow: hidden;
}
body.modal-open { overflow: hidden; }

.app {
  height: var(--app-vh);
  min-height: var(--app-vh);
}
.app__inner {
  display: flex;
  flex-direction: column;
  height: var(--app-vh);
  min-height: var(--app-vh);
  max-width: 100%;
  overflow: hidden;
}

/* ========== Header ========== */
.app-header {
  position: relative;
  flex-shrink: 0;
  height: var(--header-h);
  padding: 0 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  z-index: 10;
}
.app-header__brand { display: flex; align-items: baseline; gap: .5rem; }
.app-header__logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent-to);
  letter-spacing: -0.02em;
}
.app-header__logo + .app-header__city { margin-left: .25rem; }
.app-header__city {
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-weight: 500;
}
.app-header__help {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.app-header__help:hover {
  color: var(--text);
  border-color: rgba(13, 110, 253, .35);
}
.app-header__modes {
  display: inline-flex;
  align-items: center;
  gap: .2rem;
  padding: .16rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
}
.app-header__mode {
  min-height: 26px;
  border: none;
  border-radius: 999px;
  padding: 0 .62rem;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
}
.app-header__mode.is-active {
  background: rgba(13, 110, 253, .12);
  color: #1d4ed8;
}

.pull-to-refresh {
  position: absolute;
  left: 50%;
  top: 0;
  transform: translate(-50%, -100%);
  padding: .5rem 1rem;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-size: 0.875rem;
  color: var(--text-muted);
  transition: opacity .2s, transform .2s;
  z-index: 11;
}
.pull-to-refresh.is-visible { transform: translate(-50%, 0); }
.pull-to-refresh.is-ready { color: var(--accent); }
.pull-to-refresh.is-refreshing .pull-to-refresh__text { font-style: italic; }

/* ========== Main layout ========== */
.app__main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: var(--main-vh);
  position: relative;
  overflow: hidden;
}

/* ========== Map area ========== */
.map-frame {
  flex: 1 1 auto;
  position: relative;
  min-height: 0;
  background: #e9ecef;
  touch-action: none;
}
.map-frame::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 54px;
  pointer-events: none;
  z-index: 4;
  background: linear-gradient(180deg, rgba(248, 249, 250, 0) 0%, rgba(248, 249, 250, 0.88) 78%, rgba(248, 249, 250, 1) 100%);
}
[data-theme="dark"] .map-frame::after {
  background: linear-gradient(180deg, rgba(18, 18, 18, 0) 0%, rgba(18, 18, 18, 0.86) 78%, rgba(18, 18, 18, 1) 100%);
}
.map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  z-index: 1;
}
.map-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  background: var(--bg);
  font-size: 0.875rem;
  color: var(--text-muted);
  z-index: 2;
}
.map-loading[hidden] { display: none !important; pointer-events: none; }
.map-loading__spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.map-hint,
.selection-hint {
  position: absolute;
  left: 1rem;
  right: 1rem;
  padding: .5rem .75rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  z-index: 5;
  transition: opacity .2s, transform .2s;
}
.map-hint {
  top: .75rem;
  background: rgba(0,0,0,.75);
  color: #fff;
  opacity: 0;
  transform: translateY(-6px);
}
.map-hint.is-visible { opacity: 1; transform: translateY(0); }
.map-hint[hidden], .selection-hint[hidden] { display: none !important; }
.selection-hint {
  top: .75rem;
  background: var(--accent);
  color: #fff;
  opacity: 0;
  transform: translateY(-6px);
}
.selection-hint.is-visible { opacity: 1; transform: translateY(0); }

/* Zoom controls */
.zoom-controls {
  position: absolute;
  top: .75rem;
  right: .75rem;
  display: flex;
  flex-direction: column;
  gap: .25rem;
  z-index: 6;
}
.zoom-controls__btn,
.zoom-controls__locate {
  width: var(--tap-min);
  height: 40px;
  min-width: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--shadow);
  -webkit-tap-highlight-color: transparent;
}
.zoom-controls__btn:hover, .zoom-controls__locate:hover { background: #f1f3f5; }
.zoom-controls__btn:active, .zoom-controls__locate:active { transform: scale(0.97); }
.zoom-controls__btn:disabled, .zoom-controls__locate:disabled { opacity: .6; cursor: not-allowed; }
.zoom-controls__locate { font-size: 1rem; }

/* ========== Route sheet ========== */
.route-sheet {
  --sheet-open-ratio: 0.62;
  --sheet-panel-max: calc((var(--main-vh) - var(--actions-runtime-h) - 10px) * var(--sheet-open-ratio));
  position: absolute;
  left: 0;
  right: 0;
  bottom: var(--actions-runtime-h);
  flex-shrink: 0;
  background: var(--bg-card);
  border-top: 1px solid rgba(15, 23, 42, 0.14);
  box-shadow: 0 -8px 24px rgba(15, 23, 42, 0.14), 0 -1px 0 rgba(255,255,255,.35) inset;
  z-index: 9;
  display: flex;
  flex-direction: column;
  max-height: var(--sheet-panel-max);
  transition: box-shadow .2s, max-height .22s ease;
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
  overflow: hidden;
}
[data-theme="dark"] .route-sheet {
  border-top-color: rgba(255,255,255,.18);
  box-shadow: 0 -10px 26px rgba(0,0,0,.45), 0 -1px 0 rgba(255,255,255,.06) inset;
}
.route-sheet--snap-compact { --sheet-open-ratio: 0.46; }
.route-sheet--snap-comfort { --sheet-open-ratio: 0.62; }
.route-sheet--snap-full { --sheet-open-ratio: 0.82; }
.route-sheet--collapsed {
  max-height: none;
}
.route-sheet--collapsed .route-sheet__body { display: none; }
.route-sheet--collapsed .route-sheet__collapsed { display: block; }
.route-sheet:not(.route-sheet--collapsed) .route-sheet__collapsed { display: none; }

.route-sheet__handle {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  padding: .5rem 1rem .75rem;
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}
.route-sheet__handle-bar {
  width: 36px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin-bottom: .4rem;
}
.route-sheet__summary {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: .15rem;
}
.route-sheet__stations {
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: .2rem;
}
.route-sheet__arrow { color: var(--text-muted); margin: 0 .25rem; }
.route-sheet__expand-label {
  font-size: 0.75rem;
  color: var(--accent);
  font-weight: 500;
}

.route-sheet__body {
  padding: 0 1rem 1rem;
  max-height: min(var(--sheet-max-h), max(180px, calc(var(--sheet-panel-max) - 88px)));
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: .55rem;
}
.route-sheet__body::-webkit-scrollbar { width: 6px; }
.route-sheet__body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.route-fields {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: 0;
  order: 8;
  position: sticky;
  bottom: 0;
  z-index: 2;
  padding: .52rem .12rem .08rem;
  background: linear-gradient(180deg, rgba(255,255,255,0) 0%, rgba(255,255,255,.94) 26%, rgba(255,255,255,1) 100%);
}
.route-empty { order: 1; }
.route-result { order: 2; }
.route-error { order: 3; }
.route-field {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: .25rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0 .5rem;
  min-height: 50px;
}
.route-field__trigger {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .5rem 0;
  background: none;
  border: none;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.route-field__dot {
  flex-shrink: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.route-field__dot--from { background: var(--accent-from); }
.route-field__dot--to { background: var(--accent-to); }
.route-field__value {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.9375rem;
}
.route-field__placeholder { color: var(--text-muted); }
.route-field--focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(13, 110, 253, .2); }
.route-field__clear {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: 50%;
  font-size: 1.25rem;
  color: var(--text-muted);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.route-field__clear:hover { background: rgba(0,0,0,.06); color: var(--text); }
.route-sheet__swap {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 1.125rem;
  color: var(--text-muted);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.route-sheet__swap:hover { background: #e9ecef; color: var(--text); }

.route-empty,
.route-result,
.route-error {
  margin-bottom: .75rem;
}
.route-empty__text {
  font-size: 0.9375rem;
  color: var(--text-muted);
  margin: 0 0 .75rem;
  line-height: 1.4;
}
.route-empty__demo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 .9rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--accent);
  background: rgba(13, 110, 253, .08);
  border: 1px solid rgba(13, 110, 253, .25);
  border-radius: var(--radius-sm);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.route-empty__demo:hover { background: rgba(13, 110, 253, .12); }

.route-result__head {
  margin-bottom: .6rem;
  padding: .5rem 0;
  border-bottom: 1px solid var(--border);
}
.route-result__time {
  display: block;
  font-size: 2rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1.15;
  letter-spacing: -0.02em;
}
.route-result__meta {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin: .35rem 0 .4rem;
}
.route-result__chips {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  margin-bottom: .25rem;
}
.route-chip {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .2rem .5rem;
  font-size: 0.75rem;
  font-weight: 500;
  background: var(--bg);
  border-radius: 999px;
  border: 1px solid var(--border);
}
.route-chip__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}
.route-result__note {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: .25rem 0 0;
}
.route-hero {
  margin: .16rem 0 .5rem;
}
.route-hero__title {
  margin: 0;
  font-size: 1.1rem;
  line-height: 1.28;
  font-weight: 800;
  letter-spacing: -0.015em;
}
.route-hero__meta {
  margin: .22rem 0 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}
.route-hero__status {
  margin: .18rem 0 0;
  font-size: 0.72rem;
  color: var(--text-muted);
}
.route-progress {
  margin: .45rem 0 .6rem;
  padding: .55rem .6rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: none !important;
}
.route-progress__head {
  display: flex;
  align-items: center;
  align-items: center;
  gap: .3rem;
  margin-top: .36rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}
.route-progress__current {
  color: var(--text);
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.route-progress__current:active { opacity: .8; }
.route-progress__inline { font-weight: 600; color: var(--text); font-size: 0.74rem; }
.route-progress__hint {
  margin: 0 0 .3rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.3;
}
.route-timeline {
  position: relative;
  padding-left: .95rem;
}
.route-timeline::before {
  content: "";
  position: absolute;
  left: .35rem;
  top: .08rem;
  bottom: .08rem;
  width: 2px;
  background: rgba(148, 163, 184, .34);
}
.route-timeline__item {
  position: relative;
  min-height: 22px;
  padding: .1rem 0 .25rem .55rem;
}
.route-timeline__dot {
  position: absolute;
  left: -.24rem;
  top: .38rem;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #94a3b8;
}
.route-timeline__label {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.route-timeline__item--passed .route-timeline__label { color: #9ca3af; }
.route-timeline__item--current .route-timeline__dot { background: #1d4ed8; transform: scale(1.18); }
.route-timeline__item--current .route-timeline__label { color: var(--text); font-weight: 700; }
.route-timeline__item--transfer .route-timeline__dot { background: #b45309; }
.route-timeline__item--end .route-timeline__dot { background: #334155; }
.route-timeline__tag {
  display: inline-flex;
  margin-left: .3rem;
  padding: 0 .33rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 0.64rem;
  font-weight: 700;
}
.route-timeline__tag--transfer { border-color: rgba(217,119,6,.35); color: #b45309; }
.route-timeline__tag--current { border-color: rgba(37,99,235,.35); color: #1d4ed8; }
.route-progress__toggle {
  margin-top: .28rem;
  border: none;
  background: transparent;
  color: #1d4ed8;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0;
  cursor: pointer;
}
.route-insights {
  margin: .45rem 0 .7rem;
  padding: .6rem .65rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(13, 110, 253, .05) 0%, rgba(13, 110, 253, .01) 100%);
}
.route-insights__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .45rem;
  margin-bottom: .35rem;
}
.route-insights__eta-wrap {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .3rem;
}
.route-insights__eta,
.route-insights__risk {
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 600;
}
.route-insights__eta {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.route-insights__eta-source {
  display: inline-flex;
  align-items: center;
  min-height: 18px;
  padding: 0 .4rem;
  border-radius: 999px;
  border: 1px solid rgba(217, 119, 6, .35);
  background: rgba(217, 119, 6, .12);
  color: #92400e;
  font-size: 0.68rem;
  font-weight: 700;
}
.route-insights__risk[data-risk="high"] { color: #dc2626; }
.route-insights__risk[data-risk="medium"] { color: #b45309; }
.route-insights__risk[data-risk="low"] { color: #047857; }
.route-insights__status-label {
  display: inline-block;
  margin-bottom: .28rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}
.route-legs {
  margin: .44rem 0 .42rem;
  display: flex;
  flex-direction: column;
  gap: .26rem;
}
.route-leg {
  font-size: 0.75rem;
  color: var(--text);
  line-height: 1.35;
}
.route-leg__chip {
  display: inline-flex;
  margin-left: .26rem;
  padding: 0 .3rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 0.62rem;
  font-weight: 700;
}
.route-leg__chip--good { color: #047857; border-color: rgba(4,120,87,.3); }
.route-leg__chip--warn { color: #b45309; border-color: rgba(180,83,9,.32); }
.route-leg__chip--bad { color: #dc2626; border-color: rgba(220,38,38,.3); }
.route-insights__lines {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
}
.route-service-pill {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  min-height: 24px;
  padding: 0 .5rem;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 0.75rem;
  font-weight: 700;
}
.route-service-pill__line {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 10px;
}
.route-service-pill--good {
  background: rgba(5, 150, 105, .12);
  border-color: rgba(5, 150, 105, .25);
  color: #065f46;
}
.route-service-pill--warn {
  background: rgba(217, 119, 6, .12);
  border-color: rgba(217, 119, 6, .25);
  color: #92400e;
}
.route-service-pill--bad {
  background: rgba(220, 38, 38, .12);
  border-color: rgba(220, 38, 38, .22);
  color: #991b1b;
}
.route-insights__alternative {
  margin: .35rem 0 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}
.route-insights__actions {
  margin-top: .5rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .35rem;
}
.route-insights__actions--secondary {
  margin-top: .34rem;
}
.route-insights__action {
  min-height: 32px;
  padding: 0 .45rem;
  font-size: 0.75rem;
  font-weight: 600;
}
.route-insights__offline {
  margin: .45rem 0 0;
  font-size: 0.7rem;
  color: var(--text-muted);
}
[data-theme="dark"] .route-insights {
  background: linear-gradient(180deg, rgba(59, 130, 246, .18) 0%, rgba(15, 23, 42, .2) 100%);
}
[data-theme="dark"] .route-service-pill--good { color: #a7f3d0; }
[data-theme="dark"] .route-service-pill--warn { color: #fcd34d; }
[data-theme="dark"] .route-service-pill--bad { color: #fecaca; }
.route-details__summary {
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: .35rem;
}
.route-details__steps {
  margin: 0;
  padding-left: 1.25rem;
  font-size: 0.875rem;
  color: var(--text);
}
.route-step {
  margin-bottom: .5rem;
  display: flex;
  gap: .5rem;
  align-items: flex-start;
}
.route-step__line {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
}
.route-step__content { min-width: 0; }
.route-step__title { font-weight: 500; }
.route-step__meta { font-size: 0.8125rem; color: var(--text-muted); margin-top: .1rem; }

.route-error {
  padding: .75rem;
  background: #fff5f5;
  border: 1px solid #feb2b2;
  border-radius: var(--radius-sm);
}
[data-theme="dark"] .route-error { background: rgba(220,53,69,.15); border-color: rgba(220,53,69,.4); }
.route-error__text { font-size: 0.875rem; margin: 0 0 .5rem; color: var(--text); }
.route-error__retry {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}
.route-skeleton { min-height: 60px; }

.route-sheet__primary {
  width: 100%;
  margin-top: .1rem;
  min-height: 48px;
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--radius);
  order: 7;
}
.route-sheet__primary:disabled {
  opacity: .65;
  cursor: not-allowed;
}

/* ========== Buttons ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  min-height: var(--tap-min);
  padding: 0 1rem;
  font-family: var(--font);
  font-size: 0.9375rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: background .2s, color .2s, transform .05s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: .6; cursor: not-allowed; transform: none; }
.btn--primary {
  background: var(--accent);
  color: #fff;
}
.btn--primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn--secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn--secondary:hover:not(:disabled) { background: #e9ecef; }
.btn--ghost {
  background: none;
  color: var(--text-muted);
}
.btn--ghost:hover:not(:disabled) { background: rgba(0,0,0,.05); color: var(--text); }
.btn.is-sending { pointer-events: none; }
.btn.is-success { background: var(--accent-from); }

/* ========== Actions row ========== */
.actions-row {
  flex-shrink: 0;
  flex: 0 0 auto;
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: .55rem;
  padding: .48rem 1rem;
  padding-bottom: max(.5rem, env(safe-area-inset-bottom));
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  box-shadow: 0 -1px 3px rgba(0,0,0,.03);
  z-index: 10;
}
.actions-row__btn { flex: 0 0 auto; }
.actions-row__btn--more { align-self: center; min-width: 86px; }
.actions-menu {
  display: flex;
  flex-wrap: nowrap;
  gap: .35rem;
}
.actions-menu__btn {
  min-height: 36px;
  font-size: 0.78rem;
  padding: 0 .8rem;
  min-width: 106px;
}

/* ========== Toast ========== */
.toast {
  position: fixed;
  bottom: calc(var(--actions-h) + 1rem);
  left: 1rem;
  right: 1rem;
  max-width: 320px;
  padding: .6rem .9rem;
  background: #1a1a1a;
  color: #fff;
  font-size: 0.875rem;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .25s, transform .25s;
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}
.toast[hidden] { display: none !important; }
.toast.is-visible { opacity: 1; transform: translateY(0); }
.toast--success { background: var(--accent-from); }
.toast--error { background: var(--accent-to); }
.toast--warning { background: #fd7e14; }
.toast__icon { flex-shrink: 0; }
.toast__close {
  margin-left: auto;
  background: none;
  border: none;
  color: inherit;
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0 .25rem;
  opacity: .85;
  -webkit-tap-highlight-color: transparent;
}
.toast__close:hover { opacity: 1; }

/* ========== Modals ========== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 500;
  opacity: 0;
  transition: opacity .2s;
  pointer-events: none;
}
.modal-backdrop.is-visible { opacity: 1; pointer-events: auto; }
.modal-backdrop[hidden] { display: none !important; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 501;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s;
}
.modal.is-visible {
  pointer-events: auto;
  opacity: 1;
}
.modal.is-visible .modal__box {
  transform: translateY(0);
}
.modal[hidden] { display: none !important; }

.modal__box {
  width: 100%;
  position: relative;
  max-height: 90vh;
  max-height: 90dvh;
  overflow-y: auto;
  background: var(--bg-card);
  border-radius: 18px 18px 0 0;
  border: 1px solid rgba(15, 23, 42, .08);
  box-shadow: 0 20px 48px rgba(15, 23, 42, .22);
  transform: translateY(100%);
  transition: transform .3s cubic-bezier(0.4, 0, 0.2, 1);
  -webkit-overflow-scrolling: touch;
}
.modal__head { position: relative; padding: 1.25rem 1rem .75rem; border-bottom: 1px solid var(--border); }
.modal__title { margin: 0; font-size: 1.125rem; font-weight: 600; }
.modal__subtitle { margin: .25rem 0 0; font-size: 0.8125rem; color: var(--text-muted); }
.modal__close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 50%;
  -webkit-tap-highlight-color: transparent;
}
.modal__close:hover { background: var(--bg); color: var(--text); }

/* Station search */
.station-search__input {
  width: 100%;
  margin-top: .75rem;
  padding: .6rem .75rem;
  font-size: 1rem;
  font-family: var(--font);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
}
.station-search__input::placeholder { color: var(--text-muted); }
.station-search__input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(13, 110, 253, .15);
}
.station-search__results {
  max-height: 50vh;
  overflow-y: auto;
  padding: .5rem 0;
}
.station-search__list { display: flex; flex-direction: column; }
.station-search__item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  padding: .65rem 1rem;
  text-align: left;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  font: inherit;
  color: var(--text);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.station-search__item:hover, .station-search__item.is-active { background: var(--bg); }
.station-search__item-name { font-weight: 500; font-size: 0.9375rem; }
.station-search__item-meta { font-size: 0.75rem; color: var(--text-muted); margin-top: .15rem; }
.station-search__empty {
  padding: 1rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  text-align: center;
}
.station-search__map-btn { width: 100%; margin-top: .75rem; }

/* Station popup */
.station-popup {
  position: fixed;
  left: 1rem;
  right: 1rem;
  bottom: 8rem;
  max-width: 320px;
  margin: 0 auto;
  padding: 1rem;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 100;
  transform: translateY(10px);
  opacity: 0;
  transition: opacity .2s, transform .2s;
}
.station-popup[hidden] { display: none !important; }
.station-popup:not([hidden]) { transform: translateY(0); opacity: 1; }
.station-popup__name { margin: 0; font-size: 1rem; font-weight: 600; }
.station-popup__subtitle { margin: .25rem 0 .5rem; font-size: 0.8125rem; color: var(--text-muted); }
.station-popup__actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* Feedback form */
.modal__box.feedback-form {
  padding: 1.05rem 1rem 1.05rem;
}
.modal__box.feedback-form .modal__title {
  font-size: 1.32rem;
  letter-spacing: -0.015em;
  padding-right: 2.4rem;
}
.modal__box.feedback-form .modal__subtitle {
  margin: .22rem 0 .7rem;
  font-size: 0.95rem;
}
.feedback-form__form { margin-top: .75rem; }
.feedback-form__label { display: block; font-size: 0.875rem; font-weight: 500; margin-bottom: .35rem; }
.feedback-form__textarea {
  width: 100%;
  padding: .8rem .85rem;
  font-size: 1rem;
  font-family: var(--font);
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  resize: vertical;
  min-height: 130px;
}
.feedback-form__textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(13, 110, 253, .15);
}
.feedback-form__counter {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: .25rem;
}
.feedback-form__error {
  font-size: 0.875rem;
  color: var(--accent-to);
  margin: .35rem 0 0;
}
.feedback-form__actions {
  display: flex;
  gap: .5rem;
  margin-top: 1rem;
}
.feedback-form__actions .btn {
  min-height: 46px;
  font-weight: 600;
}
.feedback-form__actions .btn--primary { flex: 1; }
.feedback-form__actions .btn--secondary { min-width: 120px; }

/* Help content */
.modal__box.help-modal {
  padding: 1.05rem 1.05rem 1rem;
}
.modal__box.help-modal .modal__title {
  font-size: 1.32rem;
  letter-spacing: -0.015em;
  padding-right: 2.4rem;
}
.help-content { padding: .55rem 0 .25rem; font-size: 1rem; line-height: 1.58; color: var(--text); }
.help-content p { margin: 0 0 .75rem; }
.help-content p:last-child { margin-bottom: 0; }
.help-modal #helpModalClose {
  min-height: 44px;
  min-width: 120px;
  margin-left: auto;
  font-weight: 600;
}

.plan-compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .45rem;
  margin: 0 0 .75rem;
}
.plan-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  padding: .5rem .55rem;
}
.plan-card--pro {
  border-color: rgba(13, 110, 253, .45);
  box-shadow: 0 0 0 1px rgba(13, 110, 253, .08) inset;
}
.plan-card__name {
  margin: 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}
.plan-card__price {
  margin: .1rem 0;
  font-size: 1.02rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.plan-card__meta {
  margin: 0;
  font-size: 0.7rem;
  line-height: 1.35;
}

/* Ride mode */
.ride-mode {
  position: fixed;
  inset: 0;
  z-index: 520;
  background: rgba(15, 23, 42, .42);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: .75rem;
}
.ride-mode[hidden] { display: none !important; }
.ride-mode__box {
  width: 100%;
  max-width: 460px;
  border-radius: 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: 0 12px 30px rgba(15, 23, 42, .22);
  padding: .9rem .95rem 1rem;
  position: relative;
}
.ride-mode__close {
  position: absolute;
  right: .65rem;
  top: .6rem;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: var(--bg);
  color: var(--text);
  font-size: 1.3rem;
  cursor: pointer;
}
.ride-mode__label {
  margin: 0 0 .28rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
}
.ride-mode__current {
  margin: 0;
  font-size: 1.75rem;
  line-height: 1.12;
  letter-spacing: -0.02em;
}
.ride-mode__next {
  margin: .35rem 0 0;
  font-size: 1.05rem;
  font-weight: 600;
}
.ride-mode__left {
  margin: .2rem 0 0;
  font-size: 0.86rem;
  color: var(--text-muted);
}
.ride-mode__hint {
  margin: .5rem 0 .65rem;
  padding: .45rem .55rem;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  background: rgba(13, 110, 253, .08);
  border: 1px solid rgba(13, 110, 253, .22);
}
.ride-mode__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .45rem;
}
[data-theme="dark"] .ride-mode {
  background: rgba(0, 0, 0, .55);
}
[data-theme="dark"] .ride-mode__hint {
  background: rgba(59, 130, 246, .18);
  border-color: rgba(96, 165, 250, .35);
}

/* ========== Leaflet overrides ========== */
.leaflet-container {
  font-family: var(--font);
  background: #e9ecef;
  touch-action: none;
  z-index: 0;
}
.leaflet-container a,
.leaflet-container button,
.leaflet-control-container { pointer-events: auto; }
.map .leaflet-marker-icon { pointer-events: auto !important; cursor: pointer; }
.label-badge {
  font-size: 11px !important;
  font-weight: 500;
  padding: 2px 5px !important;
  border-radius: 4px !important;
  white-space: nowrap;
  pointer-events: none;
}
.map--moving .label-badge {
  opacity: .2;
}
.station-dot {
  transition: opacity .15s;
  filter: drop-shadow(0 0 1px rgba(15, 23, 42, .18));
}
.station-dot--progress-focus {
  filter: drop-shadow(0 0 5px rgba(13, 110, 253, .78));
}
.station-dot--transfer {
  filter: drop-shadow(0 0 1px rgba(15, 23, 42, .24));
}
.route-stop { pointer-events: none; }
.route-stop-bubble {
  display: inline-flex;
  align-items: center;
  gap: .28rem;
  padding: .16rem .4rem;
  background: rgba(255,255,255,.94);
  border: 1px solid rgba(15, 23, 42, .16);
  border-radius: 999px;
  box-shadow: 0 3px 8px rgba(15, 23, 42, .15);
  transition: opacity .2s ease, transform .2s ease, border-color .2s ease;
  max-width: 240px;
}
[data-theme="dark"] .route-stop-bubble {
  background: rgba(20, 20, 20, .94);
  border-color: rgba(255,255,255,.22);
}
.route-stop-bubble--compact {
  padding: .06rem;
  gap: 0;
}
.route-stop-bubble__badge {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: var(--badge-color, #2563eb);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  flex-shrink: 0;
}
.route-stop-bubble--compact .route-stop-bubble__badge {
  width: 10px;
  height: 10px;
  font-size: 0;
}
.route-stop-bubble__name {
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 150px;
}
.route-stop-lines {
  display: inline-flex;
  align-items: center;
  gap: .2rem;
}
.route-stop-line {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 14px;
  height: 14px;
  padding: 0 .2rem;
  border-radius: 999px;
  background: rgba(255,255,255,.92);
  border: 1px solid var(--line-color, #2563eb);
  color: var(--line-color, #111);
  font-size: 9px;
  font-weight: 700;
}
.route-stop-bubble__meta {
  display: inline-flex;
  align-items: center;
  min-height: 14px;
  padding: 0 .28rem;
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, .18);
  background: rgba(255,255,255,.9);
  font-size: 9px;
  font-weight: 700;
  color: #334155;
}
.route-stop-bubble__meta--current {
  border-color: rgba(37, 99, 235, .28);
  color: #1d4ed8;
  background: rgba(37, 99, 235, .09);
}
.route-stop-bubble__meta--transfer {
  border-color: rgba(217, 119, 6, .3);
  color: #b45309;
  background: rgba(217, 119, 6, .1);
}
.route-stop-bubble[data-progress="passed"] {
  opacity: .5;
}
.route-stop-bubble[data-progress="current"] {
  opacity: 1;
  border-color: var(--accent);
  transform: translateY(-1px);
}
.route-stop-bubble[data-progress="upcoming"] {
  opacity: .92;
}
.route-stop-bubble--flash {
  animation: routeBubbleFlash .9s ease;
}
@keyframes routeBubbleFlash {
  0% { transform: translateY(-1px) scale(1); box-shadow: 0 3px 8px rgba(15, 23, 42, .15); }
  30% { transform: translateY(-2px) scale(1.06); box-shadow: 0 0 0 4px rgba(13, 110, 253, .18), 0 8px 16px rgba(15, 23, 42, .2); }
  100% { transform: translateY(-1px) scale(1); box-shadow: 0 3px 8px rgba(15, 23, 42, .15); }
}

/* ========== Tablet: 431px+ ========== */
@media (min-width: 431px) {
  :root {
    --header-h: 56px;
    --sheet-max-h: 55vh;
  }
  .app__inner { max-width: 100%; margin: 0; box-shadow: none; }
  .map-frame { min-height: 320px; }
  .route-sheet__body { padding: 0 1.25rem 1.25rem; }
  .route-result__time { font-size: 2rem; }
  .modal__box {
    max-width: 520px;
    margin: 0 auto 0;
    border-radius: 16px;
  }
  .modal { align-items: center; padding: 1rem; }
  .station-popup { bottom: 10rem; }
}

@media (max-width: 768px) {
  .route-sheet {
    --sheet-open-ratio: 0.44;
  }
  .route-sheet__collapsed,
  .route-sheet__handle {
    display: none !important;
  }
  .route-sheet--collapsed .route-sheet__body {
    display: flex !important;
  }
  .route-sheet__body {
    max-height: min(52vh, calc(var(--sheet-panel-max) - 10px));
    padding: .66rem .86rem .7rem;
  }
  .route-result__head {
    margin-bottom: .38rem;
    padding: .2rem 0 .35rem;
  }
  .route-details {
    max-height: 22vh;
    overflow: auto;
  }
  .actions-row {
    padding-left: .75rem;
    padding-right: .75rem;
    padding-top: .44rem;
    gap: .5rem;
  }
  .actions-menu__btn {
    min-width: 104px;
  }
}

/* ========== Desktop: 769px+ ========== */
@media (min-width: 769px) {
  :root {
    --header-h: 60px;
    --actions-h: 64px;
    --sheet-max-h: 380px;
  }
  .app__inner { max-width: 100%; }
  body { overflow: hidden; }
  .app { height: var(--app-vh); min-height: var(--app-vh); }
  .app__inner { height: var(--app-vh); min-height: var(--app-vh); overflow: hidden; }
  .app__main {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 420px;
    grid-template-rows: minmax(0, 1fr) auto;
    height: var(--main-vh);
    min-height: 0;
    overflow: hidden;
  }
  .map-frame {
    grid-column: 1;
    grid-row: 1;
    min-height: 0;
    height: 100%;
  }
  .route-sheet {
    grid-column: 2;
    grid-row: 1;
    position: relative;
    left: auto;
    right: auto;
    bottom: auto;
    --sheet-panel-max: 100%;
    flex: 0 0 420px;
    width: 420px;
    max-height: none;
    height: 100%;
    border-top: none;
    border-left: 1px solid var(--border);
    box-shadow: none;
    z-index: 5;
  }
  .route-sheet__collapsed { display: none !important; }
  .route-sheet--collapsed .route-sheet__body { display: block !important; }
  .route-sheet__body {
    max-height: none;
    height: 100%;
    padding: .9rem 1rem 1rem;
  }
  .actions-row {
    position: relative;
    grid-column: 1 / span 2;
    grid-row: 2;
    align-items: center;
    justify-content: center;
    gap: .6rem;
    padding: .5rem 1rem;
    padding-bottom: max(.75rem, env(safe-area-inset-bottom));
  }
  .actions-row__btn { flex: 0 1 auto; min-width: 110px; }
  .actions-menu { justify-content: center; }
  .toast { left: 50%; transform: translateX(-50%); max-width: 360px; }
  .toast[hidden] { transform: translateX(-50%) translateY(8px); }
  .modal__box { max-width: 540px; }
  .station-popup { left: 50%; transform: translateX(-50%); max-width: 360px; }
  .station-popup:not([hidden]) { transform: translateX(-50%) translateY(0); }
}
