/* 臨時ダイヤ乗換案内 — スマホ（375px）起点。色はすべて :root のトークンから使う */
:root {
  --bg: #f3f5f7;
  --surface: #ffffff;
  --surface-2: #f7f9fb;
  --text: #16202a;
  --muted: #5b6875;
  --border: #d9dfe5;
  --primary: #0f5c8c;
  --primary-ink: #ffffff;
  --primary-soft: #e3eff7;
  --focus: #1b7fc4;
  --warn: #9a4a00;
  --warn-bg: #fff3e0;
  --warn-border: #f0b36b;
  --danger: #b3261e;
  --danger-bg: #fdecea;
  --danger-border: #eea39c;
  --ok: #1e6b3a;
  --ok-bg: #e7f5ec;
  --exact: #0d6b4f;
  --exact-bg: #e2f4ee;
  --approx: #6a5a00;
  --approx-bg: #fbf5d9;
  --shadow: 0 1px 2px rgba(16, 24, 32, .06), 0 2px 8px rgba(16, 24, 32, .05);
  --radius: 12px;
  --gutter: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e141a;
    --surface: #17202a;
    --surface-2: #1c2632;
    --text: #e8edf2;
    --muted: #a3b0bd;
    --border: #2d3a47;
    --primary: #5fb0e8;
    --primary-ink: #06121c;
    --primary-soft: #16324a;
    --focus: #8cc8f2;
    --warn: #ffc27a;
    --warn-bg: #3a2a14;
    --warn-border: #7a5424;
    --danger: #ff9b92;
    --danger-bg: #3d1a18;
    --danger-border: #7c3530;
    --ok: #8fd9a8;
    --ok-bg: #16301f;
    --exact: #7fe0bf;
    --exact-bg: #123328;
    --approx: #f0dc7a;
    --approx-bg: #332d10;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e141a; --surface: #17202a; --surface-2: #1c2632; --text: #e8edf2; --muted: #a3b0bd; --border: #2d3a47;
  --primary: #5fb0e8; --primary-ink: #06121c; --primary-soft: #16324a; --focus: #8cc8f2;
  --warn: #ffc27a; --warn-bg: #3a2a14; --warn-border: #7a5424; --danger: #ff9b92; --danger-bg: #3d1a18; --danger-border: #7c3530;
  --ok: #8fd9a8; --ok-bg: #16301f; --exact: #7fe0bf; --exact-bg: #123328; --approx: #f0dc7a; --approx-bg: #332d10; --shadow: none;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", Meiryo, sans-serif;
  font-size: 16px;
  line-height: 1.7;
  overflow-wrap: anywhere;
}
a { color: var(--primary); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.wrap { width: 100%; max-width: 760px; margin: 0 auto; padding: 0 var(--gutter); }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 8px; top: 8px; z-index: 10; background: var(--surface); padding: 8px 12px; }
.loading { padding: 32px 0; color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- header ---------- */
.site-header { background: var(--primary); color: var(--primary-ink); }
.header-inner { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding-top: 8px; padding-bottom: 4px; }
.brand { display: flex; align-items: center; gap: 8px; color: inherit; text-decoration: none; min-height: 44px; margin-right: auto; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: rgba(255, 255, 255, .16); }
.brand-text { font-weight: 700; font-size: 1.05rem; line-height: 1.2; }
.brand-text small { display: inline-block; margin-left: 6px; padding: 1px 6px; border: 1px solid currentColor; border-radius: 4px; font-size: .7rem; font-weight: 600; vertical-align: 2px; opacity: .9; }
.nav { display: flex; gap: 2px; width: 100%; }
.nav a { flex: 1 1 0; min-width: 0; display: grid; place-items: center; min-height: 44px; color: inherit; text-decoration: none; font-weight: 600; font-size: .95rem; border-bottom: 3px solid transparent; }
.nav a[aria-current="page"] { border-bottom-color: currentColor; }
@media (min-width: 640px) {
  .nav { width: auto; }
  .nav a { flex: 0 0 auto; padding: 0 12px; }
}

/* ---------- common blocks ---------- */
main { padding-top: 16px; padding-bottom: 32px; }
main:focus { outline: none; }
h1, h2, h3 { line-height: 1.35; margin: 0 0 8px; }
h1 { font-size: 1.3rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.alert { border-radius: var(--radius); padding: 12px 14px; margin-bottom: 16px; border: 1px solid; }
.alert p { margin: 4px 0 0; }
.alert-danger { background: var(--danger-bg); border-color: var(--danger-border); }
.alert-danger strong:first-child { color: var(--danger); }
.alert-warn { background: var(--warn-bg); border-color: var(--warn-border); }
.alert-warn strong:first-child { color: var(--warn); }
.alert a { font-weight: 600; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 48px; padding: 8px 18px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); font-weight: 600; cursor: pointer; text-decoration: none; color: var(--text); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); width: 100%; font-size: 1.05rem; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row .btn { flex: 1 1 0; min-width: 0; }
.site-footer { border-top: 1px solid var(--border); padding: 16px 0 calc(24px + env(safe-area-inset-bottom)); font-size: .875rem; color: var(--muted); }
.site-footer p { margin: 0 0 8px; }

/* ---------- search form ---------- */
.search-form { display: grid; gap: 12px; }
.od { display: grid; grid-template-columns: minmax(0, 1fr) 48px; gap: 8px; align-items: center; }
.od-fields { display: grid; gap: 8px; min-width: 0; }
.field { position: relative; min-width: 0; }
.field label { display: block; font-size: .8rem; font-weight: 700; color: var(--muted); margin-bottom: 2px; }
.field input[type="text"], .field input[type="search"], .field input[type="date"], .field input[type="time"] {
  width: 100%; min-height: 48px; padding: 10px 12px; font-size: 16px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface-2);
}
.swap { width: 48px; height: 48px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); cursor: pointer; display: grid; place-items: center; }
.swap svg { width: 22px; height: 22px; }
.via-toggle { background: none; border: 0; color: var(--primary); font-weight: 600; padding: 0; min-height: 44px; cursor: pointer; justify-self: start; }
.when { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 8px; }
.seg { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label { display: grid; place-items: center; min-height: 44px; font-weight: 600; font-size: .95rem; cursor: pointer; background: var(--surface-2); border-left: 1px solid var(--border); }
.seg label:first-of-type { border-left: 0; }
.seg input:checked + label { background: var(--primary); color: var(--primary-ink); }
.seg input:focus-visible + label { outline: 3px solid var(--focus); outline-offset: -3px; }
.now-btn { justify-self: start; background: none; border: 0; color: var(--primary); font-weight: 600; min-height: 44px; padding: 0; cursor: pointer; }

.suggest { position: absolute; left: 0; right: 0; top: 100%; z-index: 5; margin: 4px 0 0; padding: 4px 0; list-style: none; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, .18); max-height: 50vh; overflow-y: auto; }
.suggest li { padding: 10px 12px; min-height: 44px; cursor: pointer; display: flex; flex-direction: column; justify-content: center; }
.suggest li[aria-selected="true"], .suggest li:hover { background: var(--primary-soft); }
.suggest .s-name { font-weight: 700; }
.suggest .s-sub { font-size: .8rem; color: var(--muted); line-height: 1.4; }
.form-error { color: var(--danger); font-weight: 600; margin: 0; }

.recent { list-style: none; padding: 0; margin: 0; }
.recent li + li { border-top: 1px solid var(--border); }
.recent button { width: 100%; text-align: left; background: none; border: 0; min-height: 48px; padding: 8px 0; cursor: pointer; }

/* ---------- results ---------- */
.result-head { margin-bottom: 12px; }
.result-head h1 { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
.result-head .arrow { color: var(--muted); }
.cond { color: var(--muted); font-size: .9rem; margin: 0; }
.tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px; -webkit-overflow-scrolling: touch; }
.tab { flex: 0 0 auto; min-width: 128px; text-align: left; border: 1px solid var(--border); background: var(--surface); border-radius: 10px; padding: 8px 10px; cursor: pointer; }
.tab[aria-selected="true"] { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); background: var(--primary-soft); }
.tab .t-time { font-weight: 700; font-variant-numeric: tabular-nums; }
.tab .t-sub { font-size: .8rem; color: var(--muted); }
.badges { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 2px; min-height: 20px; }
.badge { display: inline-block; font-size: .72rem; font-weight: 700; line-height: 1; padding: 4px 6px; border-radius: 5px; border: 1px solid; white-space: nowrap; }
.b-fast { color: #fff; background: #c2410c; border-color: #c2410c; }
.b-easy { color: #fff; background: #1d6fb8; border-color: #1d6fb8; }
.b-short { color: #fff; background: #5b4bb7; border-color: #5b4bb7; }
.b-exact { color: var(--exact); background: var(--exact-bg); border-color: currentColor; }
.b-approx { color: var(--approx); background: var(--approx-bg); border-color: currentColor; }
.b-warn { color: var(--warn); background: var(--warn-bg); border-color: currentColor; }

.journey-summary { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin-bottom: 4px; }
.journey-summary .big { font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.journey-summary .meta { color: var(--muted); }

.timeline { list-style: none; margin: 12px 0 0; padding: 0; }
.tl-station { display: grid; grid-template-columns: 3.4em 20px minmax(0, 1fr); align-items: start; column-gap: 6px; }
.tl-time { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; line-height: 1.3; padding-top: 2px; }
.tl-time .t2 { display: block; font-weight: 500; color: var(--muted); font-size: .85rem; }
.tl-dot { width: 16px; height: 16px; border-radius: 50%; border: 3px solid var(--text); background: var(--surface); margin: 4px auto 0; }
.tl-name { font-weight: 700; font-size: 1.05rem; line-height: 1.35; padding-top: 1px; }
.tl-leg { display: grid; grid-template-columns: 3.4em 20px minmax(0, 1fr); column-gap: 6px; }
.tl-bar { width: 6px; margin: 0 auto; border-radius: 3px; background: var(--c, var(--muted)); }
.tl-walk .tl-bar { background: repeating-linear-gradient(to bottom, var(--muted) 0 4px, transparent 4px 8px); width: 3px; }
.tl-body { padding: 8px 0 12px; min-width: 0; }
.leg-line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-weight: 700; }
.leg-line .swatch { width: 12px; height: 12px; border-radius: 3px; background: var(--c); flex: 0 0 auto; }
.leg-meta { color: var(--muted); font-size: .88rem; margin-top: 2px; }
.leg-note { margin-top: 6px; font-size: .85rem; padding: 6px 8px; border-radius: 8px; background: var(--warn-bg); border: 1px solid var(--warn-border); }
.leg-note.exact { background: var(--exact-bg); border-color: transparent; }
.stops-toggle { background: none; border: 0; color: var(--primary); font-weight: 600; padding: 0; min-height: 44px; cursor: pointer; font-size: .88rem; }
.stops-list { list-style: none; margin: 0; padding: 0 0 4px; font-size: .88rem; }
.stops-list li { display: flex; gap: 8px; }
.stops-list .st-t { font-variant-numeric: tabular-nums; color: var(--muted); min-width: 3.2em; }
.transfer-row { display: grid; grid-template-columns: 3.4em 20px minmax(0, 1fr); column-gap: 6px; font-size: .85rem; color: var(--muted); }
.transfer-row span:last-child { padding: 2px 0 6px; }

.more-row { display: flex; gap: 8px; margin: 8px 0 16px; }
.more-row .btn { flex: 1 1 0; min-width: 0; }
.compare { font-size: .9rem; }

/* ---------- status ---------- */
.status-list { list-style: none; margin: 0; padding: 0; }
.status-item { border-top: 1px solid var(--border); padding: 12px 0; }
.status-item:first-child { border-top: 0; padding-top: 0; }
.status-line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.status-line h3 { margin: 0; }
.pill { font-size: .78rem; font-weight: 700; padding: 3px 8px; border-radius: 999px; border: 1px solid; white-space: nowrap; }
.pill-suspended { color: var(--danger); background: var(--danger-bg); border-color: var(--danger-border); }
.pill-reduced, .pill-partial { color: var(--warn); background: var(--warn-bg); border-color: var(--warn-border); }
.pill-timetable { color: var(--exact); background: var(--exact-bg); border-color: currentColor; }
.status-item p { margin: 4px 0 0; }
.sources { font-size: .85rem; }
.sources li { margin-bottom: 4px; }

/* ---------- timetable ---------- */
.tt-controls { display: grid; gap: 8px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 520px) { .tt-controls { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.tt-controls select { width: 100%; min-height: 48px; padding: 8px; font-size: 16px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); }
.tt-table { width: 100%; border-collapse: collapse; margin-top: 12px; font-variant-numeric: tabular-nums; }
.tt-table th { width: 3.2em; text-align: right; padding: 8px 10px 8px 0; vertical-align: top; border-top: 1px solid var(--border); font-size: 1.05rem; }
.tt-table td { padding: 6px 0; border-top: 1px solid var(--border); }
.tt-mins { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.tt-min { min-width: 2.2em; display: inline-block; padding: 2px 4px; border-radius: 6px; }
.tt-min.next { background: var(--primary); color: var(--primary-ink); font-weight: 700; }
.tt-min.past { color: var(--muted); }
.tt-min small { font-size: .7rem; color: inherit; opacity: .8; margin-left: 2px; }

/* ---------- about ---------- */
.prose p, .prose li { max-width: 40em; }
.prose h2 { margin-top: 20px; }
.prose ul { padding-left: 1.2em; }

@media (min-width: 640px) {
  .when { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.6fr); align-items: end; }
  .when .seg { grid-column: auto; }
}
@media (prefers-reduced-motion: no-preference) {
  .tab, .btn, .seg label { transition: background-color .15s, border-color .15s; }
}
.approx-mark { font-size: .72em; font-weight: 700; color: var(--approx); margin-right: 1px; }
.alert-link { display: inline-flex; align-items: center; min-height: 44px; margin-top: 4px; font-weight: 700; }
