/* TrainYaar - station-board yellow on platform grey, coach blue ink.
   One family (Archivo) across its width axis: wide + heavy for the boards,
   normal for reading, condensed tabular for times. */

/* Archivo (SIL Open Font License, see fonts/OFL.txt), self-hosted: variable
   width 62-125 and weight 100-900. */
@font-face {
  font-family: "Archivo";
  font-style: normal;
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
  src: url("fonts/archivo-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Archivo";
  font-style: normal;
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
  src: url("fonts/archivo-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --board: #F5C400;          /* station name board */
  --board-ink: #000;
  --board-frame: #000;       /* frame and posts; lit up in dark mode */
  --coach: #1F4A8A;          /* ICF coach blue: trains, primary actions */
  --coach-deep: #14305C;
  --coach-soft: #DCE6F4;
  --platform: #EEF1F4;       /* page */
  --surface: #FFFFFF;
  --ink: #14263F;            /* text */
  --muted: #52627A;
  --line: #D3DAE3;
  --signal-red: #C62828;
  --signal-red-soft: #FBE9E9;
  --signal-green: #1E7B4A;
  --signal-green-soft: #E4F3EA;
  --drive: #7B8797;

  --wide: 125;
  --normal: 100;
  --narrow: 72;

  --s-1: 0.75rem;   /* 12 */
  --s0: 0.875rem;   /* 14 */
  --s1: 1rem;       /* 16 */
  --s2: 1.125rem;   /* 18 */
  --s3: 1.3125rem;  /* 21 */
  --s4: 1.5rem;     /* 24 */
  --s5: 2.25rem;    /* 36 */
  --s6: 3rem;       /* 48 */

  --radius: 6px;
  --gutter: clamp(16px, 4vw, 40px);
  --maxw: 1240px;
  color-scheme: light;
}

:root[data-theme="dark"] {
    --coach: #8FB2EE;
    --coach-deep: #BCD0F4;
    --coach-soft: #1D3354;
    --platform: #0E1A2B;
    --surface: #15243A;
    --ink: #E7EDF5;
    --muted: #9AA9BE;
    --line: #2A3C57;
    --signal-red: #FF8A80;
    --signal-red-soft: #3A1E24;
    --signal-green: #7FD3A2;
    --signal-green-soft: #16342A;
    --drive: #8D9AAE;
    --board-frame: #E7EDF5;
    color-scheme: dark;
  }
@media (prefers-color-scheme: dark) {
:root:not([data-theme="light"]) {
    --coach: #8FB2EE;
    --coach-deep: #BCD0F4;
    --coach-soft: #1D3354;
    --platform: #0E1A2B;
    --surface: #15243A;
    --ink: #E7EDF5;
    --muted: #9AA9BE;
    --line: #2A3C57;
    --signal-red: #FF8A80;
    --signal-red-soft: #3A1E24;
    --signal-green: #7FD3A2;
    --signal-green-soft: #16342A;
    --drive: #8D9AAE;
    --board-frame: #E7EDF5;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--platform);
  color: var(--ink);
  font-family: "Archivo", system-ui, sans-serif;
  font-variation-settings: "wdth" var(--normal);
  font-size: var(--s1);
  line-height: 1.5;
  font-feature-settings: "tnum" 0;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

:focus-visible {
  outline: 3px solid var(--coach);
  outline-offset: 2px;
}

.skip {
  position: absolute; left: -999px; top: 8px;
  background: var(--surface); padding: 8px 12px; z-index: 50;
}
.skip:focus { left: 8px; }

[hidden] { display: none !important; }

/* One link style everywhere: the brand blue, a thin underline set a little
   below the text, a deeper blue and a firmer line on hover. Visited links
   don't change colour. (Buttons that happen to be links, like "Check on
   IRCTC", keep their button look.) */
a {
  color: var(--coach);
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
a:hover { color: var(--coach-deep); text-decoration-thickness: 2px; }
a:focus-visible, .link:focus-visible, .report-toggle:focus-visible {
  outline: 2px solid var(--coach); outline-offset: 2px; border-radius: 2px;
}

/* ---------- masthead ---------- */

.masthead {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 20px var(--gutter) 0;
  display: flex;
  align-items: baseline;
  gap: 16px;
  flex-wrap: wrap;
}

.wordmark {
  font-variation-settings: "wdth" var(--wide);
  font-weight: 800;
  font-size: var(--s3);
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
}
.wordmark:hover { color: var(--ink); }

/* The board sits on the text baseline; its posts hang just below it. Drawn
   inline (not an <img>) so its frame follows the page's theme, chosen or not. */
.wordmark-mark {
  height: 1.05em;
  width: 1.2075em;  /* 92:80 */
  margin-right: 0.3em;
  vertical-align: -0.3em;
}
.wordmark-mark .post { fill: var(--board-frame); }
.wordmark-mark .frame { fill: var(--board); stroke: var(--board-frame); }
.wordmark-mark .letters { fill: #000; }

/* Light / dark switch (theme.js). Shows what it will switch to. */
.theme-toggle {
  display: inline-grid; place-items: center; flex: none;
  width: 38px; height: 38px; margin-left: 14px; padding: 0;
  border: 1.5px solid var(--line); border-radius: 50%;
  background: var(--surface); color: var(--ink); cursor: pointer;
  align-self: center;
}
.theme-toggle:hover { border-color: var(--coach); color: var(--coach); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .i-sun, .theme-toggle[data-now="dark"] .i-moon { display: none; }
.theme-toggle[data-now="dark"] .i-sun { display: block; }

.masthead-note {
  margin: 0;
  color: var(--muted);
  font-size: var(--s0);
}

.masthead-link {
  margin-left: auto;
  font-size: var(--s0); font-weight: 600;
  color: var(--coach);
}

/* ---------- search: the boards ---------- */

.search {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 28px var(--gutter) 8px;
}

.boards {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  gap: 0 20px;
}

.board-wrap { position: relative; }

/* A station name board: yellow panel, black frame, two posts. */
.board {
  display: block;
  position: relative;
  background: var(--board);
  color: var(--board-ink);
  border: 4px solid var(--board-frame);
  border-radius: 3px;
  padding: 10px 18px 12px;
  cursor: text;
  margin-bottom: 18px;
}

.board::before, .board::after {
  content: "";
  position: absolute;
  bottom: -22px;
  width: 8px;
  height: 18px;
  background: var(--board-frame);
}
.board::before { left: 18%; }
.board::after { right: 18%; }

.board-label {
  display: block;
  font-size: var(--s0);
  font-weight: 600;
  line-height: 1.2;
}

.board-input {
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--board-ink);
  padding: 2px 0 0;
  font-variation-settings: "wdth" var(--wide);
  font-weight: 850;
  font-size: clamp(1.75rem, 4.2vw, 3.25rem);
  line-height: 1.05;
  text-transform: uppercase;
  letter-spacing: 0.01em;
  text-overflow: ellipsis;
}
.board-input::placeholder {
  color: rgba(0, 0, 0, 0.42);
  text-transform: none;
  font-weight: 600;
  letter-spacing: 0;
  font-size: 0.62em;  /* a hint, not a station name: must fit the board */
}
.board-input:focus { outline: none; }
.board:focus-within { outline: 3px solid var(--coach); outline-offset: 4px; }

.board-hint {
  margin: 0;
  min-height: 1.5em;
  padding-top: 6px;
  font-size: var(--s0);
  color: var(--muted);
}
.board-hint.error { color: var(--signal-red); }

.swap {
  margin-top: 28px;
  width: 48px; height: 48px;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  display: grid; place-items: center;
  transition: transform 0.25s ease;
}
.swap svg { width: 22px; height: 22px; }
.swap:hover { border-color: var(--coach); }
.swap.turned { transform: rotate(180deg); }

.suggestions {
  position: absolute;
  z-index: 20;
  left: 0; right: 0;
  top: calc(100% - 26px);
  margin: 0; padding: 6px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(20, 38, 63, 0.18);
  max-height: 360px;
  overflow: auto;
}
.suggestions li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 12px;
  padding: 8px 10px;
  border-radius: 4px;
  cursor: pointer;
}
.suggestions li[aria-selected="true"], .suggestions li:hover { background: var(--coach-soft); }
.suggestions .s-label { font-weight: 600; }
.suggestions .s-kind { font-size: var(--s-1); color: var(--muted); align-self: center; }
.suggestions .s-detail { grid-column: 1 / -1; font-size: var(--s0); color: var(--muted); }
.suggestions mark { background: none; color: inherit; text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 2px; }

/* ---------- trip controls ---------- */

.trip {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 16px 28px;
  margin-top: 8px;
}

fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend, .trip-field > label {
  display: block;
  font-size: var(--s0);
  font-weight: 600;
  margin-bottom: 6px;
  padding: 0;
}

.date-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.quick-dates { display: flex; gap: 6px; }

.chip, .quick-dates button, .segmented span, .view-switch button {
  border: 1.5px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: var(--s0);
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
}
.quick-dates button[aria-pressed="true"],
.view-switch button[aria-pressed="true"] {
  background: var(--coach);
  border-color: var(--coach);
  color: var(--surface);
}

input[type="date"], select {
  border: 1.5px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 7px 10px;
  font-size: var(--s0);
  min-height: 38px;
}

.segmented { display: flex; flex-wrap: wrap; gap: 0; }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segmented span {
  display: block;
  border-radius: 0;
  margin-left: -1.5px;
  font-variation-settings: "wdth" var(--narrow);
  min-width: 44px;
  text-align: center;
}
.segmented label:first-child span { border-radius: 999px 0 0 999px; margin-left: 0; }
.segmented label:last-child span { border-radius: 0 999px 999px 0; }
.segmented input:checked + span {
  background: var(--coach);
  border-color: var(--coach);
  color: var(--surface);
  position: relative;
}
.segmented input:focus-visible + span { outline: 3px solid var(--coach); outline-offset: 2px; position: relative; z-index: 1; }

.go {
  margin-left: auto;
  background: var(--coach);
  color: #fff;
  border: 0;
  border-radius: var(--radius);
  padding: 12px 28px;
  font-weight: 700;
  font-size: var(--s1);
  font-variation-settings: "wdth" 110;
}
.go:hover { background: var(--coach-deep); }
:root[data-theme="dark"] .go { color: #0E1A2B; }
:root[data-theme="dark"] .quick-dates button[aria-pressed="true"], :root[data-theme="dark"] .view-switch button[aria-pressed="true"], :root[data-theme="dark"] .segmented input:checked + span { color: #0E1A2B; }
@media (prefers-color-scheme: dark) {
:root:not([data-theme="light"]) .go { color: #0E1A2B; }
:root:not([data-theme="light"]) .quick-dates button[aria-pressed="true"], :root:not([data-theme="light"]) .view-switch button[aria-pressed="true"], :root:not([data-theme="light"]) .segmented input:checked + span { color: #0E1A2B; }
}

.more-search { margin-top: 18px; }
.more-search summary {
  cursor: pointer;
  font-size: var(--s0);
  font-weight: 600;
  color: var(--coach);
  width: fit-content;
}
.more-grid {
  display: flex; flex-wrap: wrap; gap: 16px 28px;
  align-items: end;
  padding: 14px 0 4px;
}

.check {
  display: flex; gap: 10px; align-items: flex-start;
  font-size: var(--s0);
  cursor: pointer;
  line-height: 1.35;
}
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--coach); flex: none; }

.form-error {
  margin: 14px 0 0;
  color: var(--signal-red);
  font-weight: 600;
}

/* ---------- layout ---------- */

.layout {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 24px var(--gutter) 64px;
  display: grid;
  grid-template-columns: 264px 1fr;
  gap: 40px;
  align-items: start;
}
.layout:focus { outline: none; }

.intro {
  grid-column: 1 / -1;
  max-width: 44rem;
  padding: 40px 0 0;
}
.intro-title {
  margin: 0 0 12px;
  font-size: var(--s5);
  line-height: 1.1;
  font-weight: 800;
  font-variation-settings: "wdth" 112;
  letter-spacing: -0.015em;
  text-wrap: balance;
}
.intro-text { margin: 0; color: var(--muted); font-size: var(--s2); max-width: 38rem; }
.examples { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 24px; }
.examples-label { margin: 0 4px 0 0; font-size: var(--s0); color: var(--muted); }
.examples button {
  border: 1.5px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 7px 14px; font-size: var(--s0); font-weight: 600;
}
.examples button:hover { border-color: var(--coach); color: var(--coach); }

/* What TrainYaar looks for: shown before the first search. */
.ways-title {
  margin: 48px 0 16px;
  font-size: var(--s3);
  font-weight: 800;
  font-variation-settings: "wdth" 108;
}
.ways {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr));
  gap: 16px 32px;
}
.ways li { border-left: 4px solid var(--board); padding: 2px 0 2px 14px; }
.ways h3 { margin: 0 0 4px; font-size: var(--s1); font-weight: 750; }
.ways p { margin: 0; color: var(--muted); font-size: var(--s0); line-height: 1.5; }
.ways-note { margin: 24px 0 0; color: var(--muted); font-size: var(--s0); max-width: 38rem; }

/* Common questions: short answers, one open at a time is fine. */
.faq { margin-top: 56px; }
.faq-title { margin: 0 0 12px; font-size: var(--s3); font-weight: 800; font-variation-settings: "wdth" 108; }
.faq-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 30rem), 1fr)); gap: 0 40px; }
.faq details { border-bottom: 1px solid var(--line); }
.faq summary {
  cursor: pointer; list-style: none; position: relative;
  padding: 14px 32px 14px 0; font-size: var(--s1); font-weight: 650; line-height: 1.35;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: ""; position: absolute; right: 6px; top: 50%; width: 8px; height: 8px; margin-top: -6px;
  border-right: 2px solid var(--coach); border-bottom: 2px solid var(--coach); transform: rotate(45deg);
  transition: transform 0.15s ease;
}
.faq details[open] summary::after { transform: rotate(-135deg); margin-top: -2px; }
.faq summary:hover { color: var(--coach); }
.faq details p { margin: 0 0 16px; color: var(--muted); font-size: var(--s0); line-height: 1.55; max-width: 40rem; }

/* Wide screens: the introduction on the left, what we look for on the right,
   so the page doesn't leave its right half empty. The text keeps its measure. */
@media (min-width: 1100px) {
  .intro {
    max-width: none;
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
    gap: 64px;
    align-items: start;
  }
  .intro-ways { padding-top: 10px; }
  .intro-ways .ways-title { margin-top: 0; }
  .intro-ways .ways { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 28px; }
  .intro .faq { grid-column: 1 / -1; }
}

/* ---------- filters ---------- */

.filters {
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding-right: 4px;
}
.filters-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 8px; }
.filters-head h2 { margin: 0; font-size: var(--s2); font-weight: 750; }
.link {  /* a button that looks like a link */
  border: 0; background: none; padding: 0; cursor: pointer;
  color: var(--coach); font-size: var(--s0); font-weight: 600;
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px;
}
.link:hover { color: var(--coach-deep); text-decoration-thickness: 2px; }
.close-sheet, .filters-foot { display: none; }

.f-group { padding: 16px 0; border-top: 1px solid var(--line); }
.f-group h3 { margin: 0 0 10px; font-size: var(--s0); font-weight: 700; }
.f-group .check + .check { margin-top: 9px; }
.f-count { color: var(--muted); margin-left: auto; font-variant-numeric: tabular-nums; }
.f-group .check { align-items: center; }
.f-group .check span.label { flex: 1; }

.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pills button {
  border: 1.5px solid var(--line); background: var(--surface);
  border-radius: 999px; padding: 6px 12px;
  font-size: var(--s0); font-weight: 600;
}
.pills button[aria-pressed="true"] { border-color: var(--coach); background: var(--coach-soft); color: var(--coach-deep); }
.pills button:disabled { opacity: 0.45; cursor: default; }

.hours { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.hours button {
  border: 1.5px solid var(--line); background: var(--surface);
  border-radius: var(--radius);
  padding: 7px 10px;
  display: flex; justify-content: space-between; align-items: baseline; gap: 6px;
  font-size: var(--s-1); line-height: 1.2;
}
.hours button:disabled { opacity: 0.45; cursor: default; }
.hours button strong { font-size: var(--s0); font-weight: 650; }
.hours button span { color: var(--muted); font-variation-settings: "wdth" var(--narrow); }
.hours button[aria-pressed="true"] { border-color: var(--coach); background: var(--coach-soft); }
.hours button[aria-pressed="true"] strong { color: var(--coach-deep); }

.range-row { display: flex; justify-content: space-between; font-size: var(--s0); margin-bottom: 4px; }
.range-row output { font-weight: 700; font-variant-numeric: tabular-nums; }
input[type="range"] { width: 100%; accent-color: var(--coach); }
.range-ends { display: flex; justify-content: space-between; font-size: var(--s-1); color: var(--muted); }

/* ---------- results ---------- */

.results { min-width: 0; }

.results-head { margin-bottom: 8px; }
.results-title {
  margin: 0;
  font-size: var(--s4);
  font-weight: 780;
  line-height: 1.2;
  font-variation-settings: "wdth" 108;
  text-wrap: balance;
}
.results-sub { margin: 4px 0 0; color: var(--muted); font-size: var(--s0); }
.results-tools {
  display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: center;
  margin-top: 16px;
}
.sort { display: flex; align-items: center; gap: 8px; font-size: var(--s0); font-weight: 600; }

/* Share: the phone's own share sheet where there is one, else this menu. */
.share-wrap { position: relative; }
.share-btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1.5px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 999px; padding: 7px 14px;
  font-size: var(--s0); font-weight: 600;
}
.share-btn svg { width: 16px; height: 16px; }
.share-btn:hover { border-color: var(--coach); color: var(--coach); }
.share-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30;
  min-width: 180px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(14, 26, 43, 0.18);
  display: flex; flex-direction: column;
}
.share-menu[hidden] { display: none; }
.share-menu button, .share-menu a {
  display: block; text-align: left; padding: 9px 12px; border-radius: 4px;
  font: inherit; font-size: var(--s0); font-weight: 600; color: var(--ink);
  background: none; border: 0; text-decoration: none; cursor: pointer;
}
.share-menu button:hover, .share-menu a:hover, .share-menu :focus-visible { background: var(--platform); }
.view-switch { display: flex; margin-left: auto; }
.view-switch button { border-radius: 0; margin-left: -1.5px; }
.view-switch button:first-child { border-radius: 999px 0 0 999px; margin-left: 0; }
.view-switch button:last-child { border-radius: 0 999px 999px 0; }

.filters-toggle {
  display: none;
  align-items: center; gap: 8px;
  border: 1.5px solid var(--line); background: var(--surface);
  border-radius: 999px; padding: 7px 14px;
  font-size: var(--s0); font-weight: 600;
}
.filters-toggle svg { width: 18px; height: 18px; }
.count {
  background: var(--coach); color: #fff;
  border-radius: 999px; padding: 0 7px; font-size: var(--s-1);
}

.active-filters { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.active-filters:empty { display: none; }
.active-filters button {
  border: 0; background: var(--coach-soft); color: var(--coach-deep);
  border-radius: 999px; padding: 4px 10px 4px 12px;
  font-size: var(--s-1); font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px;
}
.active-filters button svg { width: 12px; height: 12px; }

.stale {
  margin: 12px 0 0;
  padding: 10px 14px;
  border-left: 4px solid var(--board);
  background: var(--surface);
  font-size: var(--s0);
}

/* Each option is its own panel; the platform grey between them separates them. */
.options {
  list-style: none; margin: 16px 0 0; padding: 0;
  display: grid; gap: 14px;
}

.option {
  position: relative;
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 8px;
  padding: 18px 20px 16px 24px;
}
.option { cursor: pointer; }
.option .o-details { cursor: auto; }
.option:hover { border-color: color-mix(in srgb, var(--coach) 45%, var(--line)); }
.option.is-open { border-color: var(--coach); }
.option.is-similar { background: color-mix(in srgb, var(--surface) 60%, var(--platform)); border-style: dashed; }

/* The recommended option carries a strip of board yellow. */
.option.is-best { box-shadow: inset 6px 0 0 var(--board); }

.o-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-bottom: 10px; }
.o-num {
  display: inline-grid; place-items: center;
  min-width: 28px; height: 28px; padding: 0 6px;
  border-radius: 6px;
  background: var(--coach); color: #fff;
  font-weight: 800; font-size: var(--s0);
  font-variant-numeric: tabular-nums;
  font-variation-settings: "wdth" 100;
}
:root[data-theme="dark"] .o-num { color: #0E1A2B; }
@media (prefers-color-scheme: dark) {
:root:not([data-theme="light"]) .o-num { color: #0E1A2B; }
}
.o-head .o-tags { margin: 0; }

.o-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 24px;
  align-items: start;
}

.o-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.tag {
  font-size: var(--s-1); font-weight: 650;
  padding: 2px 8px;
  border-radius: 3px;
  border: 1px solid var(--line);
  color: var(--muted);
}
.tag.best {
  background: var(--board); color: #000; border-color: #000;
  font-variation-settings: "wdth" 115;
  font-weight: 800;
}

.o-times {
  display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap;
  font-variation-settings: "wdth" var(--narrow);
  font-variant-numeric: tabular-nums;
}
.o-time { font-size: var(--s5); font-weight: 700; line-height: 1; letter-spacing: -0.01em; }
.o-time sup { font-size: var(--s0); font-weight: 600; color: var(--muted); margin-left: 2px; vertical-align: super; }
.o-dash { color: var(--muted); font-size: var(--s4); }
.o-days { font-size: var(--s0); color: var(--muted); font-variation-settings: "wdth" var(--normal); }

.o-facts {
  text-align: right;
  display: grid; gap: 2px; justify-items: end;
  font-variant-numeric: tabular-nums;
}
.o-duration { font-size: var(--s3); font-weight: 700; font-variation-settings: "wdth" 90; }
.o-changes { font-size: var(--s0); color: var(--muted); }
.o-fare { font-size: var(--s2); font-weight: 700; margin-top: 4px; }
.o-fare small { font-size: var(--s-1); font-weight: 500; color: var(--muted); }

.o-summary { margin: 10px 0 0; font-size: var(--s1); max-width: 46rem; }
.o-warn { margin: 6px 0 0; font-size: var(--s0); color: var(--signal-red); }

/* Route strip: the journey drawn to scale. */
.strip {
  position: relative;
  display: flex;
  align-items: center;
  height: 44px;
  margin: 16px 0 6px;
}
.strip .seg { position: relative; height: 100%; display: flex; align-items: center; min-width: 6px; }
.strip .seg .bar { width: 100%; }
.seg.train .bar { height: 8px; background: var(--coach); border-radius: 4px; }
.seg.wait .bar { height: 2px; background: var(--line); }
.seg.wait.tight .bar { background: var(--signal-red); }
.seg.road .bar { height: 0; border-top: 3px dashed var(--drive); }
.seg.walk .bar { height: 0; border-top: 3px dotted var(--drive); }
.seg .seg-label {
  position: absolute; left: 0; right: 0; top: 0;
  font-size: var(--s-1); font-weight: 650; line-height: 1;
  white-space: nowrap; overflow: hidden; text-overflow: clip;
  font-variation-settings: "wdth" var(--narrow);
  color: var(--coach-deep);
}
.seg.road .seg-label, .seg.walk .seg-label { color: var(--muted); }
.strip .stop {
  position: relative; z-index: 1;
  width: 12px; height: 12px; margin: 0 -6px;
  border-radius: 50%;
  background: var(--surface);
  border: 3px solid var(--coach);
  flex: none;
}
.strip .stop.end { border-color: var(--ink); background: var(--ink); }
.strip .stop-label {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%);
  font-size: var(--s-1); font-weight: 650; color: var(--muted);
  font-variation-settings: "wdth" var(--narrow);
  white-space: nowrap;
}
.strip .stop.end.first .stop-label { left: 0; transform: none; }
.strip .stop.end.last .stop-label { left: auto; right: 0; transform: none; }

@media (prefers-reduced-motion: no-preference) {
  .options.drawing .strip .bar { transform-origin: left center; animation: draw 0.6s cubic-bezier(0.3, 0.7, 0.2, 1) both; }
  .options.drawing .option:nth-child(2) .bar { animation-delay: 60ms; }
  .options.drawing .option:nth-child(3) .bar { animation-delay: 120ms; }
  .options.drawing .option:nth-child(4) .bar { animation-delay: 180ms; }
  .options.drawing .option:nth-child(n+5) .bar { animation-delay: 240ms; }
  @keyframes draw { from { transform: scaleX(0); } to { transform: scaleX(1); } }
}

.o-actions { display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: baseline; margin-top: 12px; }
.details-toggle {
  white-space: nowrap;
  border: 0; background: none; padding: 4px 0;
  color: var(--coach); font-weight: 650; font-size: var(--s0);
  display: inline-flex; gap: 6px; align-items: center;
}
.details-toggle svg { width: 14px; height: 14px; transition: transform 0.2s; }
.details-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }
.o-tradeoff { margin: 0; font-size: var(--s0); color: var(--muted); }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* All stops of a train */
.all-stops { width: 100%; margin-top: 4px; }
.all-stops summary {
  cursor: pointer; width: fit-content;
  font-size: var(--s-1); font-weight: 650; color: var(--coach);
}
.all-stops ol { list-style: none; margin: 8px 0 2px; padding: 0; }
.stop-row {
  display: grid; grid-template-columns: 92px minmax(0, 1fr) auto;
  gap: 2px 12px; align-items: baseline;
  padding: 4px 0; border-top: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  font-size: var(--s-1);
}
.stop-row.ends { font-weight: 700; }
.stop-time { font-variant-numeric: tabular-nums; font-variation-settings: "wdth" var(--narrow); font-weight: 650; }
.stop-time sup { color: var(--muted); font-weight: 600; margin-left: 1px; }
.stop-meta { color: var(--muted); white-space: nowrap; }
@media (max-width: 720px) {
  .stop-row { grid-template-columns: 78px minmax(0, 1fr); }
  .stop-meta { grid-column: 2; }
}
.stop-tip .maplibregl-popup-content {
  font-size: var(--s-1); font-weight: 650; padding: 5px 9px;
  background: var(--surface); color: var(--ink); border-radius: 4px;
  box-shadow: 0 2px 8px rgba(20, 38, 63, 0.25);
}
.stop-tip .maplibregl-popup-tip { display: none; }

/* Route map in the details */
.o-map {
  position: relative;
  height: 300px;
  margin: 14px 0 6px;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--platform);
  border: 1px solid var(--line);
  cursor: grab;
}
.o-map-loading { margin: 0; padding: 14px; font-size: var(--s0); color: var(--muted); }
.map-stop { display: flex; align-items: center; gap: 6px; pointer-events: none; }
.map-dot {
  width: 14px; height: 14px; border-radius: 50%; flex: none; box-sizing: border-box;
  background: var(--surface); border: 3px solid var(--coach);
}
.map-stop.end .map-dot { width: 12px; height: 12px; background: var(--ink); border: 2px solid var(--surface); box-shadow: 0 0 0 2px var(--ink); }
.map-label {
  font-size: var(--s-1); font-weight: 700; line-height: 1.2; white-space: nowrap;
  color: var(--ink); background: color-mix(in srgb, var(--surface) 88%, transparent);
  padding: 2px 6px; border-radius: 3px; box-shadow: 0 1px 3px rgba(20, 38, 63, 0.18);
}
.o-map .maplibregl-ctrl-attrib { font-size: 10px; }
@media (max-width: 720px) { .o-map { height: 240px; } }

/* Problem reports */
.o-report { margin-top: 10px; cursor: auto; }
.report-toggle {
  border: 0; background: none; padding: 2px 0;
  font-size: var(--s-1); color: var(--muted);  /* quieter than the main actions, same underline */
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px;
}
.report-toggle:hover { color: var(--coach); text-decoration-thickness: 2px; }
.o-report.open {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  display: grid; gap: 10px;
}
.o-report legend { font-size: var(--s0); font-weight: 700; margin-bottom: 8px; }
.report-choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 6px 16px; }
.o-report textarea {
  width: 100%; resize: vertical;
  border: 1.5px solid var(--line); border-radius: var(--radius);
  background: var(--surface); padding: 8px 10px; font-size: var(--s0);
}
.report-actions { display: flex; gap: 16px; align-items: center; }
.report-send {
  background: var(--coach); color: #fff; border: 0; border-radius: 999px;
  padding: 7px 16px; font-size: var(--s0); font-weight: 650;
}
:root[data-theme="dark"] .report-send { color: #0E1A2B; }
@media (prefers-color-scheme: dark) {
:root:not([data-theme="light"]) .report-send { color: #0E1A2B; }
}
.report-error { margin: 0; color: var(--signal-red); font-size: var(--s0); }
.o-report.done { font-size: var(--s0); color: var(--signal-green); font-weight: 600; }
.trap { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

/* Hand-off to IRCTC: open its search, copy what to type there. */
.handoff { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; }
.handoff .irctc, .handoff .copy {
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: 999px; padding: 6px 14px;
  font-size: var(--s0); font-weight: 650; line-height: 1.2;
  text-decoration: none; white-space: nowrap;
}
.handoff .irctc { background: var(--coach); color: #fff; border: 1.5px solid var(--coach); }
.handoff .irctc:hover { background: var(--coach-deep); border-color: var(--coach-deep); }
.handoff .copy { background: var(--surface); color: var(--coach); border: 1.5px solid var(--line); }
.handoff .copy:hover { border-color: var(--coach); }
.handoff .copy.done { color: var(--signal-green); border-color: var(--signal-green); }
.handoff svg { width: 14px; height: 14px; flex: none; }
.handoff.compact { margin-left: 0; width: 100%; margin-top: 4px; }
.handoff.compact .irctc, .handoff.compact .copy { padding: 4px 12px; font-size: var(--s-1); }
.it-board { font-weight: 600; }
:root[data-theme="dark"] .handoff .irctc { color: #0E1A2B; }
@media (prefers-color-scheme: dark) {
:root:not([data-theme="light"]) .handoff .irctc { color: #0E1A2B; }
}
@media (max-width: 720px) { .handoff { margin-left: 0; width: 100%; } }

/* Itinerary */
.itinerary { margin: 16px 0 4px; padding: 0; list-style: none; }
.it-row {
  display: grid;
  grid-template-columns: 64px 20px minmax(0, 1fr);
  gap: 0 12px;
}
.it-time {
  font-variation-settings: "wdth" var(--narrow);
  font-variant-numeric: tabular-nums;
  font-weight: 700; font-size: var(--s2);
  text-align: right; line-height: 1.35;
}
.it-time small { display: block; font-weight: 500; font-size: var(--s-1); color: var(--muted); }
.it-rail { position: relative; display: flex; justify-content: center; }
.it-rail::before {
  content: ""; position: absolute; top: 0; bottom: 0; width: 4px;
  background: var(--coach); left: 50%; transform: translateX(-50%);
}
.it-row.station .it-rail::after {
  content: ""; position: relative; top: 7px;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--surface); border: 3px solid var(--coach); box-sizing: border-box;
}
.it-row.station.first .it-rail::before { top: 12px; }
.it-row.station.last .it-rail::before { bottom: auto; height: 12px; }
.it-row.wait .it-rail::before { background: none; border-left: 3px dotted var(--line); width: 0; }
.it-row.road .it-rail::before { background: none; border-left: 3px dashed var(--drive); width: 0; }
.it-row.walk .it-rail::before { background: none; border-left: 3px dotted var(--drive); width: 0; }
.it-body { padding-bottom: 14px; min-width: 0; }
.it-station { font-weight: 650; font-size: var(--s1); line-height: 1.5; }
.it-station span { color: var(--muted); font-weight: 500; }
.it-train {
  margin: 2px 0 0;
  padding: 10px 12px;
  background: var(--coach-soft);
  border-radius: var(--radius);
  font-size: var(--s0);
  display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: baseline;
}
.it-train strong { font-size: var(--s1); color: var(--coach-deep); }
.it-train .muted { color: var(--muted); }
.it-note { font-size: var(--s0); color: var(--muted); padding: 2px 0 14px; }
.it-note.tight { color: var(--signal-red); font-weight: 600; }
.it-note.ok { color: var(--signal-green); font-weight: 600; }

.o-warnings { margin: 4px 0 0; padding: 0 0 0 20px; font-size: var(--s0); }
.o-warnings li { margin: 2px 0; }

/* ---------- timeline view ---------- */

.timeline {
  margin-top: 16px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px 16px 16px;
  overflow-x: auto;
}
.tl-grid { min-width: 640px; }
.tl-axis, .tl-row {
  display: grid;
  grid-template-columns: 196px 1fr;
  gap: 12px;
  align-items: center;
}
.tl-axis { height: 36px; position: sticky; top: 0; background: var(--surface); z-index: 1; }
.tl-scale { position: relative; height: 100%; }
.tl-tick {
  position: absolute; top: 0; bottom: 0;
  border-left: 1px solid var(--line);
  font-size: var(--s-1); color: var(--muted);
  padding: 2px 0 0 4px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.tl-tick.day { border-left: 2px solid var(--muted); color: var(--ink); font-weight: 650; }
.tl-row {
  min-height: 46px;
  border-top: 1px solid var(--line);
  cursor: pointer;
  border-radius: 4px;
}
.tl-row:nth-of-type(even) { background: color-mix(in srgb, var(--platform) 55%, var(--surface)); }
.tl-row:hover, .tl-row:focus-visible { background: var(--coach-soft); }
.tl-num { font-weight: 800; color: var(--coach); margin-right: 6px; font-variant-numeric: tabular-nums; }
.tl-label { font-size: var(--s0); line-height: 1.25; padding: 6px 0 6px 8px; }
.tl-label strong { font-variant-numeric: tabular-nums; font-variation-settings: "wdth" var(--narrow); font-size: var(--s1); }
.tl-label span { display: block; color: var(--muted); font-size: var(--s-1); }
.tl-row.is-best .tl-label { box-shadow: inset 4px 0 0 var(--board); }
.tl-track { position: relative; height: 26px; }
.tl-track .tl-seg { position: absolute; top: 50%; transform: translateY(-50%); }
.tl-seg.train { height: 12px; background: var(--coach); border-radius: 3px; }
.tl-seg.wait { height: 2px; background: var(--line); }
.tl-seg.road { height: 0; border-top: 3px dashed var(--drive); }
.tl-seg.walk { height: 0; border-top: 3px dotted var(--drive); }
.tl-seg.train span {
  position: absolute; left: 4px; top: 50%; transform: translateY(-50%);
  font-size: 10px; font-weight: 700; color: #fff; white-space: nowrap; overflow: hidden;
  max-width: calc(100% - 6px);
  font-variation-settings: "wdth" var(--narrow);
}
:root[data-theme="dark"] .tl-seg.train span { color: #0E1A2B; }
@media (prefers-color-scheme: dark) {
:root:not([data-theme="light"]) .tl-seg.train span { color: #0E1A2B; }
}

/* ---------- states ---------- */

.empty {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 28px 24px;
  margin-top: 16px;
}
.empty strong { display: block; font-size: var(--s2); margin-bottom: 4px; }

.loading {
  grid-column: 1 / -1;
  display: grid; gap: 10px; justify-items: start;
  padding: 40px 0;
  color: var(--muted);
}
.loading p { margin: 0; font-size: var(--s0); }
.loading-track { width: min(360px, 100%); height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; }
.loading-track span { display: block; height: 100%; width: 30%; background: var(--coach); border-radius: 2px; }
@media (prefers-reduced-motion: no-preference) {
  .loading-track span { animation: slide 1.1s ease-in-out infinite; }
  @keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(340%); } }
}

.fine-print {
  margin-top: 24px;
  font-size: var(--s-1);
  color: var(--muted);
  max-width: 46rem;
}
.fine-print p { margin: 0 0 6px; }

.scrim { position: fixed; inset: 0; background: rgba(14, 26, 43, 0.45); z-index: 30; }

/* ---------- small screens ---------- */

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; gap: 16px; }
  .filters-toggle { display: inline-flex; }
  .filters {
    position: fixed; z-index: 40;
    left: 0; right: 0; bottom: 0; top: auto;
    max-height: 85vh;
    background: var(--surface);
    border-radius: 14px 14px 0 0;
    padding: 18px var(--gutter) 0;
    box-shadow: 0 -12px 40px rgba(14, 26, 43, 0.25);
    transform: translateY(105%);
    visibility: hidden;
    transition: transform 0.25s ease, visibility 0s linear 0.25s;
    display: flex; flex-direction: column;
  }
  .filters.open { transition: transform 0.25s ease, visibility 0s; }
  .filters[hidden] { display: flex !important; visibility: hidden; }
  .filters.open { transform: none; visibility: visible; }
  .filters-body { overflow: auto; flex: 1; }
  .close-sheet {
    display: grid; place-items: center; margin-left: auto;
    width: 36px; height: 36px; border: 0; background: none;
  }
  .close-sheet svg { width: 22px; height: 22px; }
  .filters-foot {
    display: block; padding: 12px 0 16px;
    border-top: 1px solid var(--line);
  }
  .filters-foot .go { width: 100%; margin: 0; }
}

.search-summary { display: none; }

@media (max-width: 720px) {
  .masthead { padding-top: 14px; }
  .masthead-note { display: none; }
  .masthead-note.tagline { display: block; font-size: var(--s-1); }
  .masthead .masthead-link { display: none; }  /* the footer links to About */
  .masthead .theme-toggle { margin-left: auto; }
  .search { padding-top: 14px; }
  .boards { grid-template-columns: 1fr; gap: 0; position: relative; }
  .swap {
    position: absolute; z-index: 2; right: 14px; top: calc(50% - 30px);
    margin: 0; width: 40px; height: 40px; transform: rotate(90deg);
    box-shadow: 0 2px 8px rgba(20, 38, 63, 0.18);
  }
  .swap.turned { transform: rotate(270deg); }
  .board-hint { padding-bottom: 6px; }

  /* After a search, fold the form so results start on the first screen. */
  body.has-results:not(.editing) .trip,
  body.has-results:not(.editing) .more-search { display: none; }
  body.has-results .board { padding: 6px 12px 8px; border-width: 3px; }
  body.has-results .board-label { font-size: var(--s-1); }
  body.has-results .board-input { font-size: 1.5rem; }
  body.has-results .board-hint { font-size: var(--s-1); padding-top: 3px; min-height: 0; }
  body.has-results .swap { width: 34px; height: 34px; top: calc(50% - 24px); }
  body.has-results:not(.editing) .search-summary {
    display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 12px;
    margin-top: 6px; padding: 10px 14px;
    border: 1.5px solid var(--line); border-radius: var(--radius);
    background: var(--surface); font-size: var(--s0); font-weight: 600; text-align: left;
  }
  .search-summary-action { color: var(--coach); text-decoration: underline; text-underline-offset: 3px; }
  body.has-results .layout { padding-top: 12px; }

  .board::before, .board::after { display: none; }
  .board { margin-bottom: 4px; }
  .suggestions { top: calc(100% - 10px); }
  .go { margin-left: 0; width: 100%; }
  .trip { gap: 14px 16px; }
  .option { padding: 16px 14px 14px 18px; }
  .o-main { grid-template-columns: 1fr; }
  .o-facts { text-align: left; justify-items: start; grid-auto-flow: column; justify-content: start; gap: 12px; align-items: baseline; }
  .o-fare { margin-top: 0; }
  .o-time { font-size: 1.875rem; }
  .view-switch { margin-left: 0; }
  .intro-title { font-size: 1.875rem; }
  .it-row { grid-template-columns: 52px 18px minmax(0, 1fr); gap: 0 8px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---------- about page ---------- */

.prose {
  max-width: 44rem;
  margin: 0 auto;
  padding: 24px var(--gutter) 72px;
}
.prose h1 {
  font-size: var(--s5); line-height: 1.1; margin: 16px 0 12px;
  font-weight: 800; font-variation-settings: "wdth" 112; letter-spacing: -0.015em;
}
.prose h2 { font-size: var(--s3); margin: 36px 0 8px; font-weight: 750; }
.prose p, .prose li { max-width: 40rem; }
.prose li { margin: 6px 0; }
.prose .lead { font-size: var(--s2); color: var(--muted); }
.notice {
  background: var(--surface);
  border-left: 6px solid var(--board);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 4px 20px;
  margin: 24px 0;
}
.sources { width: 100%; border-collapse: collapse; font-size: var(--s0); background: var(--surface); border-radius: var(--radius); overflow: hidden; }
.sources th, .sources td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.sources th { font-weight: 700; }
@media (max-width: 720px) {
  .masthead-link { margin-left: 0; }
  .sources, .sources tbody, .sources tr, .sources td { display: block; }
  .sources thead { display: none; }
  .sources td:first-child { font-weight: 700; padding-bottom: 0; }
  .sources td { border: 0; padding: 4px 12px; }
  .sources tr { border-bottom: 1px solid var(--line); padding: 8px 0; }
}
