/* Map-first layout: map pane + scrolling panel on desktop, map on top and an overlapping sheet on mobile. */
.max-app { --max-header: 72px; display: grid; grid-template-columns: minmax(360px, 440px) 1fr; min-height: calc(100vh - var(--max-header)); }
.max-app.has-route { grid-template-columns: minmax(420px, 1fr) 34%; }
.max-map { position: sticky; top: var(--max-header); grid-column: 2; grid-row: 1; height: calc(100vh - var(--max-header)); }
.max-map-stage { position: absolute; inset: 0; background: #E9E2D7; }
.max-map-fallback { display: none; position: absolute; inset: 0; margin: 0; place-items: center; padding: 24px; text-align: center; color: var(--ui-ink-2); font-weight: 700; }
.max-map-stage[data-state="unavailable"] .max-map-fallback { display: grid; }
.max-legend { position: absolute; left: 16px; bottom: 16px; z-index: 2; margin: 0; display: flex; flex-wrap: wrap; gap: 10px; padding: 8px 12px; border-radius: 12px; background: rgba(255, 255, 255, 0.92); box-shadow: var(--ui-shadow); font-size: 12px; font-weight: 700; color: var(--ui-ink-2); }
.max-legend span { display: inline-flex; align-items: center; gap: 5px; }

.max-panel { grid-column: 1; grid-row: 1; position: relative; z-index: 3; padding: 24px 24px 40px; background: var(--ui-bg); border-right: 1px solid var(--ui-line); display: grid; align-content: start; gap: 16px; }
.max-panel-head h1 { font-size: clamp(30px, 3vw, 40px); }
.max-panel-head h1.is-compact { font-size: 24px; }
.max-panel-head .ui-eyebrow { margin-bottom: 10px; }
.max-lede { margin: 10px 0 0; color: var(--ui-ink-2); }

.max-edit { border: 1px solid var(--ui-line); border-radius: 18px; background: var(--ui-panel); box-shadow: var(--ui-shadow); }
.max-edit > summary { display: flex; align-items: center; gap: 10px; padding: 12px 16px; cursor: pointer; list-style: none; }
.max-edit > summary::-webkit-details-marker { display: none; }
.max-edit[open] > summary { display: none; }
.max-edit-route { display: grid; gap: 2px; min-width: 0; }
.max-edit-route span { font-size: 13px; color: var(--ui-ink-2); }
.max-edit-cta { margin-left: auto; color: var(--ui-copper); font-weight: 800; font-size: 14px; }
.max-form { display: grid; gap: 12px; padding: 16px; }
.max-fields { display: grid; gap: 8px; }
.max-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.max-field { display: grid; gap: 4px; min-width: 0; font-size: 12px; font-weight: 700; color: var(--ui-ink-2); }
.max-field input, .max-field select { width: 100%; min-width: 0; box-sizing: border-box; min-height: 46px; padding: 8px 12px; border: 1px solid var(--ui-line); border-radius: 12px; background: var(--ui-bg); color: var(--ui-ink); font: inherit; font-size: 16px; font-weight: 600; }
.max-field input[type="date"] { -webkit-appearance: none; appearance: none; display: block; text-align: left; }
.max-field input[type="date"]::-webkit-date-and-time-value { text-align: left; }
@media (max-width: 560px) { .max-dates { grid-template-columns: 1fr; } }
.max-field input:focus, .max-field select:focus { outline: none; border-color: var(--ui-copper); box-shadow: 0 0 0 3px var(--ui-copper-soft); }
.max-options summary { cursor: pointer; font-size: 14px; font-weight: 700; color: var(--ui-ink-2); }
.max-options[open] summary { margin-bottom: 10px; }
.max-check { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 14px; font-weight: 600; }
.max-check input { width: 20px; height: 20px; accent-color: var(--ui-copper); }
.max-note { margin: 0; font-size: 12px; color: var(--ui-ink-3); }

.max-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.max-scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -24px; padding: 2px 24px; }
.max-scroll::-webkit-scrollbar { display: none; }
.ui-chip.is-disabled { opacity: 0.4; }
.max-results { display: grid; gap: 12px; }
.max-count { margin: 0; font-size: 14px; font-weight: 700; color: var(--ui-ink-2); }
.max-column { display: grid; gap: 8px; }
.max-column-title { font-size: 17px; margin-top: 6px; }

.max-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--ui-line); border-radius: 18px; background: var(--ui-panel); overflow: hidden; }
.max-list > li + li { border-top: 1px solid var(--ui-line); }
.max-trip > details > summary, .max-dest { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 12px; padding: 12px 16px; cursor: pointer; list-style: none; text-decoration: none; }
.max-trip > details > summary::-webkit-details-marker { display: none; }
.max-trip > details > summary::after { content: ""; grid-column: 2; grid-row: 2; justify-self: end; width: 7px; height: 7px; border-right: 2px solid var(--ui-ink-3); border-bottom: 2px solid var(--ui-ink-3); transform: rotate(45deg); }
.max-trip > details[open] > summary::after { transform: rotate(-135deg); }
.max-trip > details > summary:hover, .max-dest:hover { background: #FCF8F3; }
.max-trip-times { font-family: var(--ui-display); font-size: 20px; font-weight: 750; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.max-trip-times sup { font-size: 12px; color: var(--ui-amber); }
.max-trip-meta { grid-column: 1; font-size: 14px; color: var(--ui-ink-2); }
.max-extra { color: var(--ui-copper); }
.max-places { justify-self: end; font-size: 13px; font-weight: 600; white-space: nowrap; }
.max-places.is-high { color: var(--ui-green); }
.max-places.is-medium { color: var(--ui-amber); }
.max-places.is-low { color: var(--ui-ink-2); }
.max-trip.is-picked { background: #FBF1E7; box-shadow: inset 3px 0 var(--ui-copper); }
.max-trip.is-paired { box-shadow: inset 3px 0 var(--ui-green); }
.max-trip.is-unpaired { opacity: 0.45; }

.max-legs { list-style: none; margin: 4px 16px 0; padding: 12px 0 4px; border-top: 1px solid var(--ui-line); display: grid; gap: 6px; }
.max-leg { display: grid; gap: 2px; padding: 12px 14px; border: 1px solid var(--ui-line); border-radius: 14px; background: var(--ui-bg); }
.max-leg-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin: 0 0 6px; font-size: 14px; font-weight: 700; color: var(--ui-ink-2); }
.max-leg-head img { width: auto; height: 16px; }
.max-leg-stop { margin: 0; display: grid; grid-template-columns: 64px 1fr; gap: 8px; align-items: baseline; }
.max-leg-stop time { font-family: var(--ui-display); font-size: 18px; font-weight: 750; font-variant-numeric: tabular-nums; }
.max-leg-stop time sup { font-size: 11px; color: var(--ui-amber); }
.max-leg-stop span { font-size: 15px; font-weight: 600; }
.max-leg-duration { display: flex; flex-wrap: wrap; gap: 4px 10px; margin: 0 0 0 24px; padding: 4px 0 4px 46px; border-left: 2px solid var(--ui-line); font-size: 13px; color: var(--ui-ink-2); }
.max-leg-duration em { font-style: normal; color: var(--ui-red); font-weight: 700; }
.max-leg a.max-leg-follow { justify-self: start; margin-top: 6px; font-size: 13px; font-weight: 700; color: var(--ui-copper); text-decoration: none; }
/* Connection caption between two trains, tinted like iOS MaxConnectionCaption: green comfortable, amber tight. */
.max-caption { --tint: var(--ui-ink-2); padding: 6px 12px; text-align: center; }
.max-caption.is-ok { --tint: var(--ui-green); }
.max-caption.is-tight { --tint: var(--ui-amber); }
.max-caption.is-impossible { --tint: var(--ui-red); }
.max-caption strong { font-size: 14px; color: var(--tint); }
.max-caption strong::before { content: ""; display: inline-block; margin-right: 6px; vertical-align: 0.05em; width: 8px; height: 8px; border-radius: 50%; background: var(--tint); }
.max-caption .max-live { display: block; margin-top: 2px; font-size: 12px; font-weight: 600; color: var(--ui-amber); overflow-wrap: anywhere; }
.max-trip-foot { margin: 0 16px; padding: 10px 0 14px; border-top: 1px solid var(--ui-line); display: grid; gap: 4px; font-size: 14px; color: var(--ui-ink-2); }
.max-trip-foot strong { color: var(--ui-ink); }
.max-book { display: grid; gap: 8px; margin-top: 8px; }
.max-book .ui-btn { text-align: center; }
.max-pair { margin: 0 16px 12px; min-height: 30px; font-size: 13px; }
.max-dest { grid-template-columns: auto 1fr; color: var(--ui-ink); }
.max-dest .max-dot { grid-row: 1 / span 2; }
.max-dest-city { font-weight: 800; }
.max-dest .max-trip-meta { grid-column: 2; }

/* Map dots and names mirror iOS MaxBandDot / MaxMapLabel: filled, white rim, haloed name. Map tiles are light-only. */
.max-app { --copper: #A86F2E; }
.max-dot { display: inline-block; box-sizing: border-box; width: 14px; height: 14px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); background: var(--ui-ink-3); }
.max-dot.band-0 { background: #0E9F8E; }
.max-dot.band-1 { background: #2F6FDB; }
.max-dot.band-2 { background: #8A5CF0; }
.max-dot.band-3 { background: #3D2466; }
.max-dot.hub { width: 10px; height: 10px; border-width: 2px; background: var(--copper); }
.max-dot.transfer { width: 12px; height: 12px; background: var(--ui-ink-2); }
.max-dot.origin, .max-dot.destination { width: 18px; height: 18px; border-width: 3px; background: var(--copper); }
.max-dot.destination { background: var(--ui-ink); }
.max-label { display: block; height: 16px; font: 600 12px/16px var(--ui-body); color: var(--ui-ink); white-space: nowrap; pointer-events: none; text-shadow: 0 0 2px #fff, 0 0 2px #fff, 0 0 4px #fff; }
.max-label.is-strong { font-weight: 800; font-size: 13px; }
a.max-dot { cursor: pointer; }

.max-empty { display: grid; gap: 10px; padding: 16px; border: 1px solid var(--ui-line); border-radius: 18px; background: var(--ui-panel); }
.max-empty-title { margin: 0; font-family: var(--ui-display); font-size: 18px; font-weight: 700; }
.max-empty p { margin: 0; }

.max-calendar { display: grid; gap: 6px; }
.max-calendar h2 { font-size: 18px; }
.max-calendar table { width: 100%; border-collapse: separate; border-spacing: 3px; table-layout: fixed; }
.max-calendar th { font-size: 11px; font-weight: 700; color: var(--ui-ink-3); text-transform: capitalize; }
.max-cal-day { display: grid; place-items: center; min-height: 46px; border-radius: 10px; background: rgba(0, 122, 70, 0.1); text-decoration: none; }
.max-cal-day.is-empty { background: var(--ui-panel); color: var(--ui-ink-3); }
.max-cal-day.is-best { background: var(--ui-green); color: #fff; }
.max-cal-day.is-past { opacity: 0.4; }
.max-cal-day.is-current { outline: 2px solid var(--ui-copper); }
.max-cal-date { font-size: 11px; font-weight: 600; }
.max-cal-count { font-family: var(--ui-display); font-size: 15px; font-weight: 750; }

.max-info { display: grid; gap: 10px; margin-top: 12px; }
.max-info h2 { font-size: 18px; }
.max-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; counter-reset: step; font-size: 15px; }
.max-steps li { display: grid; grid-template-columns: 26px 1fr; gap: 10px; align-items: start; counter-increment: step; }
.max-steps li::before { content: counter(step); display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--ui-ink); color: #fff; font-family: var(--ui-display); font-size: 14px; font-weight: 750; }
.max-sources { font-size: 11px; }
.max-sources a { color: var(--ui-ink-2); }
.max-page .site-footer { margin-top: 0; }

@media (max-width: 860px) {
  .max-app { --max-header: 64px; display: block; }
  .max-map { position: relative; top: 0; height: 42vh; min-height: 260px; }
  /* Sticky with a route: opening a journey lower in the list must still show its tracks. */
  .has-route .max-map { position: sticky; top: var(--max-header); z-index: 4; height: 25vh; min-height: 170px; }
  .has-route .max-panel { margin-top: 0; border-radius: 0; box-shadow: none; }
  .max-legend { bottom: 32px; left: 12px; right: 12px; justify-content: center; }
  .max-panel { margin-top: -20px; padding: 20px 16px 32px; border-right: 0; border-radius: 22px 22px 0 0; box-shadow: 0 -8px 24px rgba(76, 50, 31, 0.1); }
  .max-scroll { margin: 0 -16px; padding: 2px 16px; }
}

/* Stats: `/max/stats` and the route / city block. One neutral grey for data, green only for the best value, never copper. */
.stat-rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.stat-rows li { display: grid; grid-template-columns: 4.5rem 1fr auto; gap: 4px 10px; align-items: center; font-size: 14px; }
.stat-rows.is-wide-label li { grid-template-columns: minmax(0, 11rem) 1fr auto; }
.stat-label { font-weight: 700; color: var(--ui-ink); overflow-wrap: anywhere; text-decoration: none; }
a.stat-label:hover { text-decoration: underline; }
.stat-rows i { position: relative; height: 10px; border-radius: 999px; background: var(--ui-line); overflow: hidden; }
.stat-rows i::before { content: ""; position: absolute; inset: 0 auto 0 0; width: calc(var(--v) * 100%); border-radius: 999px; background: var(--ui-ink-3); }
.stat-rows .is-best i::before { background: var(--ui-green); }
.stat-rows strong { min-width: 3.2em; text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat-rows small { grid-column: 2 / -1; display: flex; flex-wrap: wrap; gap: 2px 10px; font-size: 12px; color: var(--ui-ink-3); }
.stat-rows small .max-places { font-size: 12px; }
@media (max-width: 560px) {
  .stat-rows.is-wide-label li { grid-template-columns: 1fr auto; }
  .stat-rows.is-wide-label i, .stat-rows.is-wide-label small { grid-column: 1 / -1; }
}
.stat-chart { margin: 0; }
.stat-cols { display: flex; align-items: flex-end; gap: 2px; height: 120px; }
.stat-cols span { flex: 1; height: calc(var(--v) * 100%); min-height: 2px; border-radius: 3px 3px 0 0; background: var(--ui-ink-3); }
.stat-cols .is-null { height: 100%; background: var(--ui-line); }
.stat-chart.is-tall .stat-cols { height: 160px; }
.stat-chart.is-small .stat-cols { height: 80px; }
.stat-ticks { display: flex; justify-content: space-between; margin: 6px 0 0; font-size: 11px; color: var(--ui-ink-3); }
.stat-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; margin: 0; }
.stat-kpis div { display: grid; gap: 4px; }
.stat-kpis dt { font-size: 12px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ui-ink-2); }
.stat-kpis dd { margin: 0; font-size: 22px; font-weight: 900; letter-spacing: -0.02em; }
.stat-kpis dd small { display: block; font-size: 12px; font-weight: 700; letter-spacing: 0; color: var(--ui-ink-2); }

.max-stats-block { display: grid; gap: 10px; padding: 16px; border: 1px solid var(--ui-line); border-radius: 18px; background: var(--ui-panel); }
.max-stats-block h2 { font-size: 18px; }
.max-stats-block h3 { margin-top: 6px; font-size: 15px; }
.max-stats-lead { margin: 0; font-size: 16px; font-weight: 600; }
.max-stats-headline { margin: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.max-stats-headline strong { font-family: var(--ui-display); font-size: 28px; font-weight: 800; letter-spacing: -0.03em; }
.max-stats-headline .ui-muted { margin: 0; }
.max-stats-foot { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; }
.max-stats-foot a { color: var(--ui-ink); font-weight: 700; }

.max-stats-page { box-sizing: border-box; max-width: 1080px; margin: 0 auto; padding: 32px 24px 56px; display: grid; gap: 16px; }
.max-stats-hero h1 { font-size: clamp(30px, 4.4vw, 52px); }
.max-stats-hero h1 strong { font-weight: 800; }
.max-stats-hero .ui-muted { margin-top: 12px; }
.max-stats-card { display: grid; gap: 12px; align-content: start; min-width: 0; padding: 20px; border: 1px solid var(--ui-line); border-radius: 18px; background: var(--ui-panel); }
.max-stats-card h2 { font-size: 18px; }
.max-stats-card .ui-eyebrow { margin: 0; }
.max-stats-card .max-places { margin-left: 10px; }
.max-stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: 16px; }
.max-stats-kpi { margin: 0; font-size: 17px; font-weight: 600; }
.max-stats-kpi strong { font-family: var(--ui-display); font-size: 40px; font-weight: 800; letter-spacing: -0.03em; }
.max-stats-method ul { margin: 0; padding-left: 18px; display: grid; gap: 6px; font-size: 15px; color: var(--ui-ink-2); }
@media (max-width: 560px) { .max-stats-page { padding: 24px 16px 40px; } .max-stats-card { padding: 16px; } }
