:root {
  --bg: #f4f6f9; --card: #ffffff; --fg: #1b1d22; --muted: #5f6672; --line: #e2e5ea;
  --accent: #0b6bcb; --chip: #eef2f7; --hour: #f1f4f8;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121418; --card: #1c1f24; --fg: #e8eaee; --muted: #a3aab5; --line: #333841;
    --accent: #5aa7ff; --chip: #2a2f37; --hour: #242830; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121418; --card: #1c1f24; --fg: #e8eaee; --muted: #a3aab5; --line: #333841;
  --accent: #5aa7ff; --chip: #2a2f37; --hour: #242830; color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg);
       font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.wrap { max-width: 900px; margin: 0 auto; padding: 12px 16px 32px; }
.top { display: flex; justify-content: space-between; align-items: center; }
.top h1 { font-size: 19px; display: flex; gap: 8px; align-items: center; margin: 4px 0 12px; }
.link { color: var(--accent); }
.controls { background: var(--card); border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; }
.tabs { display: inline-grid; grid-template-columns: 1fr 1fr; background: var(--chip); border-radius: 10px;
        padding: 3px; gap: 2px; margin-bottom: 10px; }
.tabs button { border: 0; background: transparent; color: var(--muted); padding: 6px 18px; border-radius: 8px;
               font: inherit; cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--card); color: var(--fg); font-weight: 600; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row input { flex: 1; min-width: 0; }
input, select { font: inherit; color: var(--fg); background: var(--card); border: 1px solid var(--line);
                border-radius: 8px; padding: 7px 9px; }
.btn { font: inherit; font-weight: 600; color: #fff; background: var(--accent); border: 0; border-radius: 8px;
       padding: 7px 12px; cursor: pointer; }
.btn.secondary { background: var(--chip); color: var(--fg); }
.via-line { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 10px; }
.seg.dirs { margin-top: 8px; flex-wrap: wrap; }
.vl-stops { margin: 8px 0 0; padding-left: 2.2em; columns: 2 260px; column-gap: 24px; }
.vl-stops li { break-inside: avoid; padding: 1px 0; }
.vl-stops li::marker { color: var(--muted); font-size: 12px; }
.vl-stops button { border: 0; background: none; color: var(--accent); font: inherit; cursor: pointer; padding: 2px 0;
                   text-align: left; }
.vl-stops button:hover { text-decoration: underline; }
.vl-stops small { color: var(--muted); }
.vl-stops li.tp button { font-weight: 600; }
.linkbtn { border: 0; background: none; color: var(--accent); font: inherit; font-size: 13px; cursor: pointer; padding: 0; }
.hint { color: var(--muted); font-size: 13.5px; }
.results { list-style: none; padding: 0; margin: 6px 0 0; display: grid; gap: 4px; }
.results button { width: 100%; text-align: left; font: inherit; color: var(--fg); background: var(--chip); border: 0;
                  border-radius: 8px; padding: 8px 10px; cursor: pointer; }
.results small { color: var(--muted); }
.opts { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 10px; }
.seg { display: inline-flex; background: var(--chip); border-radius: 8px; padding: 2px; }
.seg button { border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 13.5px;
              padding: 5px 10px; border-radius: 6px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--card); color: var(--fg); font-weight: 600; }
.pick { border: 1px solid var(--line); border-radius: 8px; margin: 10px 0 0; padding: 6px 10px 8px; }
.pick legend { font-size: 13.5px; color: var(--muted); padding: 0 4px; }
.pick-list { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.pick-list label { display: flex; gap: 5px; align-items: center; font-size: 14px; }
.pick-list small { color: var(--muted); }

/* ---------------------------------------------------------------- aikataulu */
.sheet { background: var(--card); border-radius: 12px; padding: 14px 16px; }
.sheet:empty { display: none; }
.sheet h2 { margin: 0; font-size: 22px; }
.sheet .sub { color: var(--muted); margin: 2px 0 10px; }
.legend { list-style: none; padding: 0; margin: 0 0 10px; display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 14px; }
.legend b { display: inline-block; min-width: 2.2em; }
.cols { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.col h3 { font-size: 15px; margin: 0 0 4px; }
.col h3 small { color: var(--muted); font-weight: 400; }
table.tt { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
table.tt th { width: 2.6em; text-align: right; padding: 3px 8px 3px 4px; background: var(--hour); font-weight: 700;
              vertical-align: top; }
table.tt td { padding: 3px 6px; border-bottom: 1px solid var(--line); line-height: 1.6; }
table.tt .m { display: inline-block; margin-right: 9px; white-space: nowrap; }
table.tt .m sup { font-size: 9.5px; color: var(--muted); margin-left: 1px; }
table.tt .m.v { text-decoration: underline dotted; }
table.tt button.m { border: 0; background: none; color: inherit; font: inherit; padding: 0; cursor: pointer; }
table.tt button.m:hover { color: var(--accent); }
.night th { font-style: italic; }
.foot { color: var(--muted); font-size: 12px; margin-top: 10px; }
.sheet h3.sec { margin: 18px 0 6px; font-size: 17px; }
.trip { margin-top: 12px; }
.trip ol { padding-left: 0; list-style: none; margin: 6px 0; columns: 2 260px; }
.trip li { display: flex; gap: 10px; break-inside: avoid; padding: 2px 0; }
.trip li .t { width: 3.2em; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.trip li.tp .t::after { content: "•"; color: var(--accent); margin-left: 2px; }

/* ---------------------------------------------------------------- tulostus */
@media print {
  @page { size: A4; margin: 12mm; }
  :root { --bg: #fff; --card: #fff; --fg: #000; --muted: #444; --line: #bbb; --hour: #eee; color-scheme: light; }
  body { background: #fff; font-size: 11pt; }
  .no-print, #msg, .trip button { display: none !important; }
  .wrap { max-width: none; padding: 0; }
  .sheet { padding: 0; border-radius: 0; }
  table.tt tr { break-inside: avoid; }
  table.tt th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .col { break-inside: avoid-page; }
  table.tt button.m { color: #000; }
}

img.logo { border-radius: 7px; flex: none; }
