:root {
  --forest: #102a43;
  --forest-2: #17466a;
  --cream: #f3f7fa;
  --paper: #ffffff;
  --lime: #b9e5fb;
  --coral: #e77b4a;
  --ink: #172e40;
  --muted: #62798a;
  --line: #d9e4ec;
  --shadow: 0 18px 50px rgba(16, 42, 67, .11);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: #e5edf3; color: var(--ink); font-family: "DM Sans", sans-serif; }
button, select { font: inherit; }
button { cursor: pointer; }
svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.app-shell { width: 100%; min-height: 100vh; background: var(--cream); overflow: hidden; }
.topbar { height: 70px; padding: 0 22px; display: flex; align-items: center; justify-content: space-between; background: var(--forest); color: white; }
.brand { min-width: 0; color: inherit; text-decoration: none; display: flex; align-items: center; gap: 10px; font: 800 15px/1 Manrope, sans-serif; letter-spacing: .13em; }
.brand span:last-child { overflow-wrap: anywhere; }
.brand-mark { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 9px; color: var(--forest); background: var(--lime); font-size: 19px; }
.brand-mark svg { width: 17px; height: 17px; stroke-width: 1.8; }
.icon-button { width: 42px; height: 42px; border-radius: 50%; border: 1px solid rgba(255,255,255,.15); background: rgba(255,255,255,.06); color: white; display: grid; place-items: center; }
.icon-button svg { width: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-button.spin svg { animation: spin .7s ease; }

.hero { position: relative; min-height: 226px; padding: 30px 22px 56px; color: white; background: var(--forest); }
.hero::after { content: ""; position: absolute; right: -60px; bottom: -25px; width: 230px; height: 150px; opacity: .14; transform: rotate(-10deg); background: repeating-linear-gradient(90deg, transparent 0 18px, var(--lime) 18px 21px); border-radius: 50%; }
.eyebrow { margin: 0 0 10px; color: var(--lime); font-size: 11px; font-weight: 700; letter-spacing: .17em; }
.eyebrow.dark { color: #536e83; }
.eyebrow.alert { color: #a44f2b; margin-bottom: 4px; }
h1, h2 { font-family: Manrope, sans-serif; }
h1 { position: relative; z-index: 1; margin: 0; font-size: clamp(42px, 12vw, 58px); line-height: .97; letter-spacing: -.05em; }
h1 em { color: var(--lime); font-style: normal; }
.hero-copy { position: relative; z-index: 1; margin: 15px 0 0; color: #bdcedb; font-size: 14px; }

.planner { position: relative; z-index: 2; margin: -30px 14px 0; padding: 10px 10px 20px; background: var(--paper); border-radius: 25px; box-shadow: var(--shadow); }
.direction-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 4px; border-radius: 17px; background: #e9f0f5; }
.direction-tab { padding: 12px 10px; border: 0; border-radius: 13px; background: transparent; color: #617688; display: flex; justify-content: center; align-items: center; gap: 9px; text-align: left; transition: .2s ease; }
.direction-tab.active { background: var(--forest); color: white; box-shadow: 0 4px 14px rgba(16,42,67,.2); }
.direction-tab .tab-icon { width: 20px; height: 20px; color: var(--forest-2); }
.direction-tab.active .tab-icon { color: var(--lime); }
.tab-icon svg { width: 20px; height: 20px; }
.direction-tab strong, .direction-tab small { display: block; }
.direction-tab strong { font-size: 13px; }
.direction-tab small { margin-top: 2px; font-size: 10px; opacity: .64; }
.field-group, .time-fieldset { margin: 22px 8px 0; }
label, legend { padding: 0; margin-bottom: 9px; color: #62798a; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.select-wrap { position: relative; display: flex; align-items: center; }
.field-icon { position: absolute; left: 14px; width: 19px; height: 19px; color: var(--forest-2); pointer-events: none; }
.field-icon svg { fill: none; stroke: currentColor; stroke-width: 1.7; width: 100%; }
select { width: 100%; height: 54px; padding: 0 42px; appearance: none; color: var(--ink); background: #eef4f8; border: 1px solid transparent; border-radius: 13px; font-weight: 600; outline: none; }
select:focus { border-color: #4b9dca; box-shadow: 0 0 0 3px rgba(185,229,251,.5); }
.chevron { position: absolute; right: 16px; width: 18px; height: 18px; pointer-events: none; }
.chevron svg { width: 100%; height: 100%; }
.time-fieldset { padding: 0; border: 0; }
.time-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.time-chip { height: 50px; border: 1px solid var(--line); border-radius: 13px; color: var(--ink); background: white; font-weight: 700; transition: .18s ease; }
.time-chip.active { color: var(--forest); border-color: #8bcbe9; background: var(--lime); box-shadow: 0 5px 14px rgba(84,165,206,.18); }
.search-button { width: calc(100% - 16px); height: 57px; margin: 22px 8px 0; padding: 0 18px; display: flex; align-items: center; justify-content: space-between; border: 0; border-radius: 15px; color: white; background: var(--forest); font-weight: 700; box-shadow: 0 8px 20px rgba(16,42,67,.2); }
.search-button span:last-child, .fallback-button span { display: grid; place-items: center; width: 22px; height: 22px; }
.search-button svg, .fallback-button svg { width: 21px; height: 21px; }
.route-rule { margin: 13px 8px 0; text-align: center; color: var(--muted); font-size: 11px; }
.route-rule svg { display: inline-block; width: 13px; height: 13px; margin-right: 3px; color: #25846f; vertical-align: -2px; }

.results { padding: 34px 22px 8px; }
.section-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.section-heading h2 { margin: 0; font-size: 21px; letter-spacing: -.03em; overflow-wrap: anywhere; }
.result-date { margin: 6px 0 0; color: var(--muted); font-size: 12px; font-weight: 600; }
.live-badge { flex: none; margin-bottom: 3px; padding: 6px 9px; border-radius: 50px; color: #246d60; background: #ddf3eb; font-size: 9px; font-weight: 800; letter-spacing: .12em; }
.live-badge i { display: inline-block; width: 6px; height: 6px; margin-right: 4px; background: #2e9e83; border-radius: 50%; box-shadow: 0 0 0 3px rgba(46,158,131,.16); }
.journey-card { margin-top: 15px; background: var(--paper); border-radius: 20px; box-shadow: 0 8px 30px rgba(16,42,67,.07); overflow: hidden; }
.journey-list .journey-card + .journey-card { margin-top: 14px; }
.journey-summary { padding: 17px; display: flex; justify-content: space-between; align-items: center; gap: 12px; border-bottom: 1px solid #e7eef3; }
.journey-time { font: 800 24px/1 Manrope, sans-serif; letter-spacing: -.04em; }
.summary-times { display: inline-flex; align-items: baseline; gap: 5px; flex-wrap: wrap; }
.summary-separator { color: var(--muted); }
.delayed-time { color: #bd4c27; }
.planned-time { color: var(--muted); font-size: 10px; font-weight: 500; text-decoration-thickness: 1px; }
.journey-time small { display: block; margin-top: 7px; color: var(--muted); font: 500 11px/1 DM Sans, sans-serif; letter-spacing: 0; }
.duration { text-align: right; color: var(--muted); font-size: 11px; }
.duration strong { display: block; margin-bottom: 4px; color: var(--ink); font-size: 13px; }
.timeline { padding: 19px 17px 7px; }
.leg { position: relative; display: grid; grid-template-columns: 92px 26px minmax(0, 1fr); min-height: 74px; }
.leg:not(:last-child)::after { content: ""; position: absolute; left: 104px; top: 24px; bottom: -2px; width: 2px; background: #c9d9e4; }
.leg-time { display: flex; align-items: baseline; gap: 4px; white-space: nowrap; font-weight: 700; font-size: 13px; padding-top: 1px; }
.dot { position: relative; z-index: 1; width: 12px; height: 12px; margin: 3px auto 0; border: 3px solid var(--paper); border-radius: 50%; background: var(--forest); box-shadow: 0 0 0 2px var(--forest); }
.leg:last-child .dot { background: var(--lime); }
.leg-main strong { display: block; font-size: 13px; line-height: 1.25; overflow-wrap: anywhere; }
.leg-main small { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; }
.line-pill { display: inline-block; margin-top: 7px; padding: 4px 7px; border-radius: 6px; color: white; background: #d43a2f; font-size: 10px; font-weight: 800; }
.line-pill.rb { background: #7457a5; }
.line-pill.s { background: #308a43; }
.line-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 7px; }
.line-meta .line-pill { margin-top: 0; }
.train-position { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px; max-width: 100%; padding: 4px 7px; border: 1px solid #c9e6f3; border-radius: 6px; color: #17466a; background: #edf8fd; font-size: 10px; font-weight: 700; line-height: 1.3; }
.train-position[hidden] { display: none; }
.position-arrow { flex: none; width: 16px; height: 16px; color: #3386ad; }
.warning { margin: 0 17px 17px; padding: 12px; display: flex; gap: 10px; color: #8b472a; background: #fff0e5; border-radius: 12px; font-size: 11px; line-height: 1.45; }
.warning-icon { flex: none; width: 16px; height: 16px; }
.warning-icon svg { width: 16px; height: 16px; }
.warning strong { display: block; }
.status-message { margin-top: 15px; padding: 11px 13px; color: #64552c; background: #fff5d9; border-radius: 11px; font-size: 11px; }
.loading-state { min-height: 260px; margin-top: 15px; padding-top: 95px; text-align: center; background: var(--paper); border-radius: 20px; }
.loading-state span { display: inline-block; width: 7px; height: 7px; margin: 2px; border-radius: 50%; background: var(--forest); animation: bounce .9s infinite alternate; }
.loading-state span:nth-child(2) { animation-delay: .2s; }.loading-state span:nth-child(3) { animation-delay: .4s; }
.loading-state p { color: var(--muted); font-size: 12px; }

.fallback { margin: 26px 14px; padding: 20px; border-radius: 21px; color: #673b2b; background: #ffe9dc; }
.fallback-heading { display: flex; align-items: center; gap: 12px; }
.fallback-heading h2 { margin: 0; font-size: 18px; }
.fallback-icon { width: 42px; height: 42px; flex: none; display: grid; place-items: center; color: white; background: var(--coral); border-radius: 13px; }
.fallback-icon svg { width: 21px; height: 21px; }
.fallback > p { color: #89604f; font-size: 12px; line-height: 1.5; }
.fallback-button { width: 100%; min-height: 48px; padding: 0 14px; display: flex; align-items: center; justify-content: space-between; border: 1px solid rgba(139,71,42,.2); border-radius: 12px; color: #783d26; background: rgba(255,255,255,.6); font-weight: 700; font-size: 12px; }
#fallbackResult .journey-card { box-shadow: none; margin-top: 14px; }
footer { padding: 26px 22px 35px; text-align: center; color: #7a8c99; }
footer p { margin: 0 0 6px; font-weight: 700; font-size: 12px; } footer span { font-size: 9px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes bounce { to { transform: translateY(-7px); opacity: .4; } }
@media (min-width: 720px) {
  body { padding: 24px; background: #e5edf3; }
  .app-shell {
    display: grid;
    grid-template-columns: minmax(290px, 370px) minmax(0, 1fr);
    grid-template-areas: "topbar topbar" "hero hero" "planner results" "planner fallback" "footer footer";
    grid-template-rows: auto auto auto auto 1fr;
    column-gap: 28px;
    max-width: 1180px;
    min-height: calc(100vh - 48px);
    margin: auto;
    border-radius: 24px;
    box-shadow: 0 30px 80px rgba(16,42,67,.13);
  }
  .topbar { grid-area: topbar; padding-inline: 32px; }
  .hero { grid-area: hero; min-height: 0; padding: 26px 32px 30px; }
  .hero::after { right: 5%; bottom: -65px; width: 320px; }
  h1 { font-size: clamp(42px, 5vw, 58px); }
  .planner { grid-area: planner; align-self: start; margin: 28px 0 0 32px; padding: 16px 16px 22px; box-shadow: 0 8px 28px rgba(16,42,67,.08); }
  .results { grid-area: results; min-width: 0; padding: 28px 32px 0 0; margin: 0; }
  .section-heading { min-height: 0; }
  .fallback { grid-area: fallback; align-self: start; margin: 20px 32px 0 0; }
  footer { grid-area: footer; align-self: end; padding: 26px 32px 28px; }
}
@media (min-width: 1024px) {
  body { padding: 36px; }
  .app-shell { grid-template-columns: minmax(350px, 410px) minmax(0, 1fr); column-gap: 40px; min-height: calc(100vh - 72px); }
  .topbar { padding-inline: 42px; }
  .hero { padding-inline: 42px; }
  .planner { margin-left: 42px; }
  .results { padding-right: 42px; }
  .fallback { margin-right: 42px; }
  .journey-summary { padding: 21px 24px; }
  .timeline { padding: 23px 24px 10px; }
  .leg { min-height: 82px; }
  .leg-main strong, .leg-time { font-size: 14px; }
  .warning { margin-inline: 24px; }
}
@media (max-width: 359px) {
  .topbar { padding-inline: 16px; }
  .brand { font-size: 12px; }
  .hero { padding-inline: 18px; }
  .planner { margin-inline: 10px; }
  .results { padding-inline: 16px; }
  .journey-time { font-size: 20px; }
  .duration { font-size: 10px; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; animation-duration: .01ms !important; } }
