:root {
  /* 色：青1色＋地図の灰と白。グラデ禁止、ほかの色を足さない */
  --blue: #0a6cff;
  --capsule-bg: #000;
  --capsule-accent: #7fc3ff;
  --map-bg: #ecebe5;
  --sheet: #fbfbfa;
  --ink: #111;
  --sub: #555;
  --muted: #86847e;
  --faint: #9a988f;
  --gone: #aaa7a0;
  --rule: #e4e2dc;
  --grab: #cfcdc7;
  --chip: #eceae5;
  --badge-bg: #111; --badge-fg: #fff;
  --here: #3a3935;

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", sans-serif;

  --fs-stop: 28px;  --fw-stop: 700; --ls-stop: -0.01em; --lh-stop: 1.2;
  --fs-min: 56px;   --fw-min: 700;  --ls-min: -0.03em;  --lh-min: 1;
  --fs-min-unit: 20px; --fw-min-unit: 600;
  --fs-dest: 16px;  --fw-dest: 600; --lh-dest: 1.4;
  --fs-body: 14px;
  --fs-small: 13px; --lh-small: 1.55;
  --fs-badge: 12px; --fs-meta: 12px;

  --sheet-pad-x: 22px; --sheet-pad-top: 8px;
  --sheet-radius: 16px;
  --grab-gap: 14px;
  --hero-gap-top: 22px;
  --hero-pad-bottom: 20px;
  --row-pad-y: 13px;
  --row-gap: 14px;
  --time-col: 48px;
  --tap: 44px;

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --h-collapsed: calc(148px + var(--safe-b));
  --h-half: min(53svh, 460px);
  --h-full: calc(100svh - (var(--safe-t) + 64px));

  color-scheme: light;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--map-bg);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  word-break: keep-all;
  overflow-wrap: anywhere;
  line-break: strict;
  font-variant-numeric: tabular-nums;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

/* 押したときの反応：pointerdown で scale(.97) */
.press { transition: scale 100ms ease-out; }
.press.is-down { scale: 0.97; }

/* ---------- 地図 ---------- */
.map { position: fixed; inset: 0; background: var(--map-bg); }
.maplibregl-ctrl-bottom-left, .maplibregl-ctrl-bottom-right { will-change: transform; }
.maplibregl-ctrl-attrib { font-size: 10px; }
.maplibregl-ctrl-attrib.maplibregl-compact { background: rgba(255,255,255,.85); }

.mk-stop { position: absolute; width: 26px; height: 26px; border-radius: 50%; background: var(--ink); cursor: default; }
.mk-stop::after { content: ""; position: absolute; left: 8px; top: 8px; width: 10px; height: 10px; border-radius: 50%; background: #fff; }
.mk-stop span { position: absolute; left: 28px; top: 20px; white-space: nowrap; font-size: 12px; font-weight: 700; color: var(--ink);
  text-shadow: 0 0 2px #fff, 0 0 2px #fff, 0 0 3px #fff; pointer-events: none; }

.mk-bus { position: absolute; width: 20px; height: 20px; pointer-events: none; }
.mk-bus .ring { position: absolute; inset: 0; border-radius: 50%; background: var(--blue); animation: ripple 2s ease-out infinite; }
.mk-bus .dot { position: absolute; inset: -2.5px; border-radius: 50%; background: var(--blue); border: 2.5px solid #fff; display: grid; place-items: center; color: #fff; }
.mk-bus .dot svg { width: 13px; height: 13px; stroke-width: 2.2; }
@keyframes ripple { 0% { opacity: .55; transform: scale(1); } 100% { opacity: 0; transform: scale(2.6); } }

/* ---------- 上端カプセル ---------- */
.capsule {
  position: fixed; z-index: 30; top: calc(var(--safe-t) + 8px); left: 50%;
  translate: -50% 0;
  min-width: 180px; max-width: calc(100vw - 32px); height: 37px; border-radius: 20px;
  background: var(--capsule-bg); color: #fff;
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  padding: 0 14px 0 12px; font-size: 13px; white-space: nowrap;
}
.capsule[hidden] { display: none; }
.cap-l { display: flex; align-items: center; gap: 6px; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.cap-l .ic { width: 17px; height: 17px; color: var(--capsule-accent); }
.cap-badge { overflow: hidden; text-overflow: ellipsis; max-width: 11em; }
.cap-r { display: flex; align-items: baseline; gap: 7px; }
.cap-late { font-size: 11px; color: rgba(255,255,255,.7); }
.cap-late:empty { display: none; }
.cap-min { font-size: 15px; font-weight: 700; color: var(--capsule-accent); }

/* ---------- 現在地ボタン ---------- */
.locbtn {
  transition: opacity 120ms linear, scale 100ms ease-out;
  position: fixed; z-index: 20; right: 14px; bottom: 0;
  width: 44px; height: 44px; border-radius: 10px; background: #fff; color: var(--blue);
  box-shadow: 0 1px 3px rgba(0,0,0,.18);
  display: grid; place-items: center;
  transform: var(--loc-y, none);
  will-change: transform;
}
.locbtn .ic { width: 22px; height: 22px; }

/* ---------- ボトムシート ---------- */
.sheet {
  position: fixed; z-index: 10; left: 0; right: 0; bottom: 0;
  height: var(--h-full);
  background: var(--sheet);
  border-radius: var(--sheet-radius) var(--sheet-radius) 0 0;
  box-shadow: 0 -1px 0 rgba(0,0,0,.08);
  display: flex; flex-direction: column;
  will-change: transform;
  transform: translateY(calc(var(--h-full) - var(--h-half)));
}
.sheet-head { flex: none; padding: var(--sheet-pad-top) var(--sheet-pad-x) 0; touch-action: none; }
.grab { display: block; width: 100%; height: calc(5px + var(--grab-gap)); position: relative; touch-action: none; }
.grab::before { content: ""; position: absolute; left: 50%; top: 0; width: 36px; height: 5px; margin-left: -18px; border-radius: 3px; background: var(--grab); }
.sheet-scroll {
  flex: 1; min-height: 0; overflow: hidden; touch-action: none;
  padding: 0 var(--sheet-pad-x) calc(24px + var(--safe-b));
  overscroll-behavior: contain;
}
.sheet.is-full .sheet-scroll { overflow-y: auto; touch-action: pan-y; }
.sheet-body { min-height: 1px; }

/* 見出し */
.sh { display: flex; align-items: flex-start; gap: 12px; touch-action: none; }
.sh .ti { flex: 1; min-width: 0; }
.sh h2 { font-size: var(--fs-stop); font-weight: var(--fw-stop); letter-spacing: var(--ls-stop); line-height: var(--lh-stop); }
.sh .subline { font-size: var(--fs-body); color: var(--muted); margin-top: 3px; }
.sh .mini { display: none; font-size: 15px; margin-top: 4px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sh .mini b { font-weight: 700; color: var(--blue); margin-left: .6em; }
.sh .mini .bd { margin-right: 6px; }
.sheet.is-collapsed .sh .mini { display: block; }
.sheet.is-collapsed .chips { visibility: hidden; }
.sheet.is-collapsed .sh .subline.has-mini { display: none; }
.star { flex: none; width: 36px; height: 36px; border-radius: 50%; background: var(--chip); display: grid; place-items: center; color: var(--ink); position: relative; }
.star::before { content: ""; position: absolute; inset: -4px; }
.star .ic { width: 20px; height: 20px; }
.star[aria-pressed="true"] .ic { fill: currentColor; }

/* のりばチップ */
.chips { display: flex; gap: 8px; overflow-x: auto; margin: 16px calc(var(--sheet-pad-x) * -1) 0; padding: 0 var(--sheet-pad-x) 2px; scrollbar-width: none; touch-action: pan-x; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; height: 32px; padding: 0 12px; border-radius: 16px; background: var(--chip); font-size: 13px; color: var(--sub); white-space: nowrap; }
.chip b { font-weight: 600; color: var(--ink); margin-right: 4px; }
.chip[aria-pressed="true"] { background: var(--ink); color: #fff; }
.chip[aria-pressed="true"] b { color: #fff; }

/* RT が取れないときの1行 */
.rtwarn { font-size: var(--fs-small); color: var(--sub); margin-top: 14px; padding: 8px 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.rtnote { font-size: var(--fs-meta); color: var(--muted); margin-top: 12px; line-height: 1.5; }
.nearby { font-size: var(--fs-meta); color: var(--muted); margin-top: 10px; line-height: 1.5; display: flex; flex-wrap: wrap; gap: 2px 12px; align-items: baseline; }
.nearby .nearlink { font: inherit; color: var(--sub); background: none; border: 0; padding: 4px 0; text-decoration: underline; text-decoration-color: var(--rule); text-underline-offset: 3px; cursor: pointer; }
.subline .rec { display: block; font-size: var(--fs-meta); color: var(--muted); margin-top: 2px; }

/* ヒーロー */
.hero { margin-top: var(--hero-gap-top); padding-bottom: var(--hero-pad-bottom); border-bottom: 1px solid var(--rule); }
.rt { font-size: var(--fs-small); color: var(--sub); display: flex; gap: 8px; align-items: center; min-width: 0; }
.rt span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bd { flex: none; display: inline-block; background: var(--badge-bg); color: var(--badge-fg); font-size: var(--fs-badge); padding: 2px 7px; border-radius: 5px; font-weight: 600; line-height: 1.4; }
.dest { font-size: var(--fs-dest); font-weight: var(--fw-dest); line-height: var(--lh-dest); margin-top: 6px; }
.row2 { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-top: 10px; }
.min { font-size: var(--fs-min); font-weight: var(--fw-min); letter-spacing: var(--ls-min); line-height: var(--lh-min); color: var(--blue); white-space: nowrap; }
.min small { font-size: var(--fs-min-unit); font-weight: var(--fw-min-unit); margin-left: 3px; letter-spacing: 0; }
.min.is-word { font-size: 40px; letter-spacing: -0.02em; }
.info { text-align: right; font-size: var(--fs-small); line-height: var(--lh-small); color: var(--sub); }
.info em { font-style: normal; color: var(--ink); font-weight: 600; }
.fresh { font-size: var(--fs-meta); color: var(--faint); margin-top: 10px; }
.fresh:empty { display: none; }

/* 夜間 */
.night { margin-top: var(--hero-gap-top); padding-bottom: var(--hero-pad-bottom); border-bottom: 1px solid var(--rule); }
.night p:first-child { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
.night .first { margin-top: 10px; font-size: var(--fs-body); color: var(--sub); display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.night .first .tm { font-size: 20px; color: var(--ink); font-weight: 700; }

/* ほかの便 */
.trips { list-style: none; }
.tr-sep { padding: 18px 0 6px; font-size: 12px; font-weight: 600; letter-spacing: .04em; color: var(--muted); border-bottom: 1px solid var(--rule); }
.tr-sep:first-child { padding-top: 6px; }
.tr { display: flex; align-items: baseline; gap: var(--row-gap); padding: var(--row-pad-y) 0; border-bottom: 1px solid var(--rule); font-size: var(--fs-body); width: 100%; text-align: left; }
.tr .tm { flex: none; width: var(--time-col); font-weight: 600; }
.tr .tx { flex: 1; min-width: 0; color: var(--sub); }
.tr .tx .l1 { color: var(--ink); display: flex; align-items: baseline; gap: 6px; }
.tr .tx .l1 .bd { font-size: 11px; padding: 1px 5px; }
.tr .tx .l1 span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tr .tx .l2 { font-size: var(--fs-small); margin-top: 2px; }
.tr .tx .l2 em { font-style: normal; font-weight: 600; color: var(--ink); }
.tr .rr { flex: none; font-weight: 600; white-space: nowrap; }
.tr .rr .soft { font-weight: 400; color: var(--muted); font-size: var(--fs-small); }
.tr.gone, .tr.gone .tx, .tr.gone .tx .l1, .tr.gone .rr, .tr.gone .tx .l2 em { color: var(--gone); }
.tr.gone .bd { background: var(--gone); }
.tr.sel .tm { color: var(--blue); }
button.tr { cursor: pointer; }

.upd { font-size: var(--fs-meta); color: var(--faint); margin-top: 12px; display: inline-flex; align-items: center; gap: 5px; min-height: 32px; }
.upd .ic { width: 15px; height: 15px; }
.more { font-size: var(--fs-small); color: var(--muted); margin-top: 8px; }

/* はじめに／位置なし／圏外 */
.lead { font-size: var(--fs-body); color: var(--sub); margin-top: 8px; line-height: 1.6; }
.primary { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; height: 50px; margin-top: 22px; border-radius: 12px; background: var(--blue); color: #fff; font-size: 16px; font-weight: 600; }
.primary .ic { width: 20px; height: 20px; }
.field { display: flex; align-items: center; gap: 8px; width: 100%; height: 46px; margin-top: 12px; padding: 0 14px; border-radius: 12px; background: var(--chip); color: var(--muted); font-size: 15px; text-align: left; }
.field .ic { width: 18px; height: 18px; color: var(--sub); }
.tries { display: flex; flex-wrap: wrap; gap: 4px 22px; margin-top: 18px; }
.tries button { color: var(--blue); font-size: 15px; font-weight: 600; min-height: var(--tap); }
.fine { font-size: var(--fs-meta); color: var(--faint); margin-top: 14px; line-height: 1.6; }

/* 位置を取得中 */
.progress { height: 2px; background: var(--rule); margin-top: 14px; overflow: hidden; position: relative; }
.progress::after { content: ""; position: absolute; top: 0; bottom: 0; width: 30%; background: var(--blue); animation: prog 1.2s ease-in-out infinite; }
@keyframes prog { 0% { left: -30%; } 100% { left: 100%; } }

/* 検索 */
.search-top { display: flex; align-items: center; gap: 8px; }
.search-top .field { margin-top: 0; flex: 1; color: var(--ink); }
.search-top input { flex: 1; min-width: 0; border: 0; background: none; font: inherit; font-size: 16px; color: var(--ink); outline: none; height: 100%; }
.search-top input::placeholder { color: var(--muted); }
.close { flex: none; width: var(--tap); height: var(--tap); display: grid; place-items: center; color: var(--sub); }
.results { list-style: none; margin-top: 10px; }
.res { display: flex; align-items: baseline; gap: 12px; width: 100%; padding: 12px 0; border-bottom: 1px solid var(--rule); text-align: left; }
.res .nm { flex: 1; min-width: 0; }
.res .nm b { display: block; font-size: 16px; font-weight: 600; }
.res .nm span { display: block; font-size: var(--fs-small); color: var(--muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.res .ds { flex: none; font-size: var(--fs-small); color: var(--muted); }
.res .nm .where { color: var(--sub); }
.empty { font-size: var(--fs-body); color: var(--sub); margin-top: 18px; }

/* 出典 */
.credit { margin-top: 36px; padding-top: 14px; border-top: 1px solid var(--rule); font-size: 11px; line-height: 1.7; color: var(--faint); }
.credit p + p { margin-top: 6px; }
.credit-note { color: var(--sub); }
.credit .linkbtn { font: inherit; color: inherit; background: none; border: 0; padding: 4px 0; text-decoration: underline; cursor: pointer; }

/* トースト */
.toast {
  position: absolute; left: 50%; bottom: calc(16px + var(--safe-b)); translate: -50% 0; z-index: 2;
  display: flex; align-items: center; gap: 14px; max-width: calc(100% - 32px);
  background: var(--ink); color: #fff; font-size: var(--fs-small); padding: 10px 16px; border-radius: 10px; white-space: nowrap;
}
.toast[hidden] { display: none; }
.toast button { color: var(--capsule-accent); font-weight: 600; }

.probe { position: fixed; left: -9999px; top: 0; visibility: hidden; pointer-events: none; }
#probeCollapsed { height: var(--h-collapsed); }
#probeHalf { height: var(--h-half); }
#probeFull { height: var(--h-full); }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- 幅 ---------- */
@media (min-width: 431px) and (max-width: 899px) {
  .sheet { max-width: 560px; margin: 0 auto; }
}
@media (min-width: 900px) {
  .sheet {
    left: 16px; top: 16px; bottom: 16px; right: auto; width: 400px; height: auto;
    border-radius: 16px; box-shadow: 0 2px 12px rgba(0,0,0,.12);
    transform: none !important;
  }
  .sheet-head { touch-action: auto; }
  .grab { display: none; }
  .sheet-head { padding-top: 22px; }
  .sheet-scroll { overflow-y: auto !important; touch-action: auto !important; padding-bottom: 24px; }
  .sh, .sheet-scroll { touch-action: auto; }
  .capsule { left: calc(50% + 216px); }
  .locbtn { transform: none !important; bottom: 44px; right: 16px; }
  .toast { bottom: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .mk-bus .ring { animation: none; opacity: 0; }
  .progress::after { animation: none; left: 0; width: 100%; opacity: .35; }
  .press { transition: none; }
}
.search-top input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
