/* Mise en page : carte en haut sur téléphone, panneau latéral à gauche sur grand écran.
Vocabulaire visuel des tableaux de départ : noms de gare en condensé, horaires en chasse fixe. */
:root {
  --bg: #eef1ef;
  --surface: #ffffff;
  --surface-2: #f5f7f6;
  --ink: #15202b;
  --muted: #5a6672;
  --line: #d7ddd9;
  --accent: #0b5d8c;
  --accent-ink: #ffffff;
  --night: #8a5f00;
  --night-bg: #fbf1d6;
  --danger: #b3261e;
  --m-hsr: #0b5d8c;
  --m-ld: #6a3fb0;
  --m-reg: #1a7a50;
  --m-bus: #c2561a;
  --m-other: #6b7580;
  --f-display: "Barlow Condensed", "Arial Narrow", system-ui, sans-serif;
  --f-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --r: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e141a;
    --surface: #17202a;
    --surface-2: #1d2833;
    --ink: #e6ecf0;
    --muted: #94a2ae;
    --line: #2a3742;
    --accent: #5ab0e6;
    --accent-ink: #08141d;
    --night: #f0c04a;
    --night-bg: #2c2612;
    --danger: #ff8a80;
    --m-hsr: #5ab0e6;
    --m-ld: #b28cf0;
    --m-reg: #5fcf98;
    --m-bus: #f39a5f;
    --m-other: #9aa5af;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e141a;
  --surface: #17202a;
  --surface-2: #1d2833;
  --ink: #e6ecf0;
  --muted: #94a2ae;
  --line: #2a3742;
  --accent: #5ab0e6;
  --accent-ink: #08141d;
  --night: #f0c04a;
  --night-bg: #2c2612;
  --danger: #ff8a80;
  --m-hsr: #5ab0e6;
  --m-ld: #b28cf0;
  --m-reg: #5fcf98;
  --m-bus: #f39a5f;
  --m-other: #9aa5af;
  color-scheme: dark;
}
* {
  box-sizing: border-box;
}
/* An element with a display style (.frise, .card…) must still hide when told to. */
[hidden] {
  display: none !important;
}
html,
body {
  height: 100%;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 var(--f-body);
  display: grid;
  grid-template-rows: 42vh 1fr;
}
#map {
  min-height: 0;
  background: var(--surface-2);
}
#panel {
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-block: 14px calc(28px + env(safe-area-inset-bottom, 0px));
  padding-inline-start: max(16px, env(safe-area-inset-left, 0px));
  padding-inline-end: max(16px, env(safe-area-inset-right, 0px));
  display: flex;
  flex-direction: column;
  gap: 14px;
  border-top: 1px solid var(--line);
}
@media (min-width: 900px) {
  body {
    grid-template-rows: none;
    grid-template-columns: 440px 1fr;
  }
  #panel {
    order: -1;
    border-top: 0;
    border-inline-end: 1px solid var(--line);
  }
}
header.brand {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.brand h1 {
  margin: 0;
  font: 700 30px/1 var(--f-display);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
/* Brand mark next to the name. */
.brand h1 {
  display: flex;
  align-items: center;
  gap: 8px;
}
.mark {
  width: 26px;
  height: 33px;
  flex: none;
}
.wordmark span {
  color: var(--accent);
}
.language-picker {
  display: flex;
  align-items: center;
  gap: 5px;
  align-self: center;
  order: 1;
  margin-inline-start: auto;
  color: var(--muted);
}
.language {
  flex: none;
  width: auto;
  padding: 3px 6px;
  font-size: 12px;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
}
.brand small {
  flex: 1 1 100%;
  order: 2;
  color: var(--muted);
  font-size: 12px;
  text-align: start;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 12px;
}
.label {
  font: 600 11px/1.2 var(--f-body);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

/* Itinéraire saisi : une colonne de points reliés par un rail */
.route {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.pt {
  position: relative;
  display: grid;
  grid-template-columns: 22px 1fr auto;
  gap: 8px;
  align-items: start;
  padding-block: 6px;
}
.pt::before {
  content: "";
  position: absolute;
  inset-inline-start: 10px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--line);
}
.pt:first-child::before {
  top: 50%;
}
.pt:last-child::before {
  bottom: 50%;
}
.dot {
  position: relative;
  z-index: 1;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  margin-top: 7px;
  display: grid;
  place-items: center;
  font: 700 11px var(--f-mono);
  background: var(--surface);
  border: 2px solid var(--ink);
}
.pt.end .dot {
  background: var(--ink);
  color: var(--surface);
}
.pt.stop .dot {
  border-color: var(--night);
  color: var(--night);
}
.field {
  position: relative;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
input,
select,
button {
  font: inherit;
  color: inherit;
}
input[type="text"],
input[type="date"],
input[type="time"],
input[type="number"],
select {
  width: 100%;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink);
}
input:focus-visible,
select:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.stay {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
  font-size: 13px;
  color: var(--muted);
}
.stay select {
  width: auto;
  padding: 5px 8px;
  font-size: 13px;
}
.stay input[type="time"] {
  width: auto;
  padding: 5px 8px;
  font-size: 13px;
}
.icon-btn {
  border: 0;
  background: none;
  color: var(--muted);
  padding: 8px;
  margin-top: 2px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}
.icon-btn:hover {
  background: var(--surface-2);
  color: var(--ink);
}
.map-pick {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 170px;
}
.map-pick div {
  font-weight: 600;
}
.input-row {
  position: relative;
}
/* The page's direction, not the field's: a field in dir="auto" is left to right while
   empty, even in Arabic, and the icon follows the page. */
html:not([dir="rtl"]) .input-row input {
  padding-right: 40px;
}
html[dir="rtl"] .input-row input {
  padding-left: 40px;
}
html:not([dir="rtl"]) .input-row.with-favorite input {
  padding-right: 80px;
}
html[dir="rtl"] .input-row.with-favorite input {
  padding-left: 80px;
}
.favorite {
  position: absolute;
  inset-block: 0;
  inset-inline-end: 40px;
  width: 40px;
  display: grid;
  place-items: center;
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
}
.favorite[aria-pressed="true"] {
  color: var(--night);
}
.suggest li.saved-favorite svg {
  color: var(--night);
}
.locate {
  position: absolute;
  inset-block: 0;
  inset-inline-end: 0;
  width: 40px;
  display: grid;
  place-items: center;
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
}
.locate:hover {
  color: var(--accent);
}
.suggest {
  position: absolute;
  z-index: 1000;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 2px;
  list-style: none;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.18);
  max-height: 260px;
  overflow-y: auto;
}
.suggest li {
  padding: 8px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}
.suggest li svg {
  flex: none;
  color: var(--muted);
}
.suggest li.kind-city svg {
  color: var(--accent);
}
.suggest li .name {
  flex: 1;
  min-width: 0;
}
.suggest li.kind-city .name {
  font-weight: 600;
}
.suggest li:hover,
.suggest li.on {
  background: var(--surface-2);
}
.suggest li small {
  color: var(--muted);
  white-space: nowrap;
}

.row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.row > * {
  min-width: 0;
}
.grow {
  flex: 1 1 140px;
}
.btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  padding: 9px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
}
.btn:hover {
  border-color: var(--muted);
}
.btn.primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
  font-weight: 600;
}
.btn.small {
  padding: 5px 10px;
  font-size: 13px;
}
.btn.night {
  border-color: var(--night);
  color: var(--night);
  background: transparent;
}
.add-stop {
  align-self: flex-start;
  margin-inline-start: 30px;
}
.route-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
/* Discreet: muted, at the end of the journey card, only when there is something to clear. */
.link-button.clear-journey {
  align-self: center;
  color: var(--muted);
}
.home {
  display: flex;
  align-items: center;
  gap: 8px;
  color: inherit;
  text-decoration: none;
}
.toast button {
  margin-inline-start: 8px;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}
details.opts summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
}
.opts .row {
  margin-top: 10px;
  font-size: 14px;
}
.opts label {
  display: flex;
  gap: 6px;
  align-items: center;
}
.opts input[type="number"] {
  width: 70px;
  padding: 5px 8px;
}

.status {
  font-size: 13px;
  color: var(--muted);
}
.status.err {
  color: var(--danger);
}

/* Résultats par tronçon */
.seg {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.seg-h {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.seg-h h2 {
  margin: 0;
  font: 600 21px/1.1 var(--f-display);
  letter-spacing: 0.01em;
  text-wrap: balance;
}
.seg-h .label {
  white-space: nowrap;
}
.itins {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.it {
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  cursor: pointer;
  text-align: start;
  width: 100%;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.it.sel {
  border-color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}
.it-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  /* A button that looks like the card's first line. */
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: start;
  cursor: pointer;
}
.times {
  font: 700 18px/1 var(--f-mono);
  font-variant-numeric: tabular-nums;
}
.times sup {
  font-size: 11px;
  color: var(--night);
  margin-inline-start: 2px;
}
.meta {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.chip {
  font: 600 11px/1 var(--f-body);
  padding: 4px 6px;
  border-radius: 4px;
  color: #fff;
  background: var(--m-other);
}
.chip.hsr {
  background: var(--m-hsr);
}
.chip.ld {
  background: var(--m-ld);
}
.chip.reg {
  background: var(--m-reg);
}
.chip.bus {
  background: var(--m-bus);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .chip {
    color: #0b1117;
  }
}
:root[data-theme="dark"] .chip {
  color: #0b1117;
}

.wait {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  font-size: 12px;
  color: var(--night);
}
.legs {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.leg {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 0 10px;
  padding: 6px 0;
  border-top: 1px dashed var(--line);
}
.leg:first-child {
  border-top: 0;
}
.leg .t {
  font: 500 13px/1.5 var(--f-mono);
  font-variant-numeric: tabular-nums;
}
.leg .s {
  font-size: 14px;
  min-width: 0;
}
.leg .s b {
  font-weight: 600;
}
.leg .train {
  font-size: 12px;
  color: var(--muted);
  margin-block: 2px;
}
.leg .train i {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
  margin-inline-end: 6px;
  vertical-align: -1px;
}
.stopline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}
.stopline .btn {
  flex: none;
}
.leg details {
  font-size: 12px;
  color: var(--muted);
}
.leg details ul {
  list-style: none;
  margin: 4px 0;
  padding-block: 0;
  padding-inline: 6px 0;
  border-inline-start: 2px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.leg details li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  padding-inline-start: 6px;
}
.walk {
  font-size: 12px;
  color: var(--muted);
  padding-block: 4px;
  padding-inline: 62px 0;
  border-top: 1px dashed var(--line);
}

/* Frise du voyage */
.frise {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  font-size: 14px;
}
.summary b {
  font: 700 16px var(--f-mono);
}
.day h3 {
  margin: 0 0 4px;
  font: 600 17px/1.2 var(--f-display);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.day ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.day li {
  display: grid;
  grid-template-columns: 118px 1fr;
  gap: 8px;
  font-size: 14px;
}
.day li .t {
  white-space: nowrap;
  font: 500 13px/1.5 var(--f-mono);
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}
.day li.sleep {
  background: var(--night-bg);
  color: var(--ink);
  border-radius: 6px;
  padding: 4px 6px;
}
.day li.sleep .t {
  color: var(--night);
}
.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.saved {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.saved-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}
.saved-item button.link {
  border: 0;
  background: none;
  color: var(--accent);
  cursor: pointer;
  padding: 4px 0;
  text-align: start;
  font-weight: 500;
}
footer {
  font-size: 12px;
  color: var(--muted);
}
footer a {
  color: var(--muted);
}
.link-button {
  align-self: flex-start;
  border: 0;
  padding: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: 13px;
  text-decoration: underline;
  cursor: pointer;
}
.about {
  max-width: min(520px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--ink);
  padding: 20px;
  line-height: 1.5;
}
.about::backdrop {
  background: rgb(0 0 0 / 45%);
}
.about h2 {
  margin: 0 0 12px;
  font: 600 24px/1.1 var(--f-display);
}
.about a {
  color: var(--accent);
}
.about-thanks {
  padding: 12px;
  border-inline-start: 4px solid var(--accent);
  border-radius: 6px;
  background: var(--surface-2);
  font-weight: 500;
}
.about-note {
  color: var(--muted);
  font-size: 13px;
}
.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}
.coverage-map {
  height: 240px;
  border-radius: 8px;
  /* The sea: the map has no tiles, only country outlines. */
  background: var(--surface-2);
}
.coverage-list {
  font-size: 13px;
}
.empty {
  color: var(--muted);
  font-size: 14px;
}
.spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: -2px;
  margin-inline-end: 6px;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation: none;
  }
}
.leaflet-container {
  font-family: var(--f-body);
}
/* Leaflet's own attribution colours lack contrast in dark mode. */
.leaflet-container .leaflet-control-attribution {
  background: var(--surface);
  color: var(--muted);
}
.leaflet-control-attribution a {
  color: var(--accent);
}
.dark-tiles .base-tiles {
  filter: invert(1) hue-rotate(180deg) brightness(0.92) contrast(0.88)
    saturate(0.6);
}
.railway-toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 9px;
  border: 2px solid rgb(0 0 0 / 20%);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font: 600 12px var(--f-body);
  cursor: pointer;
}
.railway-toggle[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-ink);
}
.map-pin {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font: 700 12px var(--f-mono);
  background: var(--surface);
  color: var(--ink);
  border: 2px solid var(--ink);
  box-shadow: 0 2px 6px rgb(0 0 0 / 0.3);
}
.map-pin.end {
  background: var(--ink);
  color: var(--surface);
}
.map-pin.stop {
  border-color: var(--night);
  color: var(--night);
}
.map-xfer {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--ink);
}
.leaflet-popup-content {
  font: 14px/1.4 var(--f-body);
}
.leaflet-popup-content .btn {
  margin-top: 6px;
}
.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 2000;
  background: var(--ink);
  color: var(--surface);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 14px;
}

/* Right-to-left languages: physical shadows do not follow the writing direction. */
[dir="rtl"] .it.sel {
  box-shadow: inset -3px 0 0 var(--accent);
}

/* Travel modules (options): checkboxes with their notice, summary under the search button. */
.modules {
  margin: 10px 0 0;
  padding: 10px 0 0;
  border: 0;
  border-top: 1px solid var(--line);
}
.modules legend {
  padding: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.module + .module {
  margin-top: 6px;
}
.module .hint {
  margin: 4px 0 0;
  padding-inline-start: 24px;
  color: var(--muted);
  font-size: 12px;
}
.active-modules {
  align-self: flex-start;
  padding: 4px 10px;
  color: var(--ink);
  font-size: 13px;
  background: var(--night-bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
}
.module-status {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}
.module-status.ok {
  color: var(--m-reg);
}
.it .stations {
  margin: 2px 0 6px;
  color: var(--muted);
  font-size: 13px;
}
.city-stations {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}
/* The operator's name links to its ticket office: discreet, like the rest of the line. */
a.tickets {
  color: inherit;
  text-decoration: underline dotted;
}
/* Emissions: one muted line under the timeline summary. */
.carbon {
  font-size: 13px;
  color: var(--muted);
}
/* Avoided operators: a label, removable chips, a field with the operators seen. */
.avoid {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}
.avoid-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.avoid-list:empty {
  display: none;
}
.avoid-chip {
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 3px 10px;
  background: var(--surface);
  color: var(--accent);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
/* A stopover with several possible cities: the others under the field, removable. */
.choices {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  font-size: 13px;
  color: var(--muted);
}
.choice-chip {
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 3px 10px;
  background: var(--surface);
  color: var(--accent);
  font: inherit;
  cursor: pointer;
}
/* Under the segment reaching it: which city was kept and how the others compare. */
.choice-note {
  margin: 0 0 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--surface-2);
  font-size: 13px;
}
.choice-note p {
  margin: 4px 0;
}
/* The version, after the footer links: small and muted, for bug reports. */
.version {
  margin-inline-start: auto;
  font-size: 12px;
  color: var(--muted);
}
