:root {
  --bg: #fff; --fg: #1f2933; --muted: #6b7885; --line: #d5dbe0;
  --pass: #2b8fd6; --alight: #c2255c; --accent: #1c6e8c;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #1b2126; --fg: #e6ebef; --muted: #98a4ae; --line: #38424b; }
}
* { box-sizing: border-box; }
/* html/body 自体はスクロールさせない（中身はすべて position:fixed の各要素が自前でスクロールを持つ構成）。
   こうしないと、スマホでフォーム入力中にブラウザが「入力欄を画面内に収めよう」として
   ページ全体を上にスクロールしてしまい、入力欄より上にあるはずの一覧やヘッダーが隠れてしまう */
html, body { margin: 0; top: 0; left: 0; width: 100%; height: 100%; overflow: hidden; position: fixed; overscroll-behavior: none;
  background: var(--bg); color: var(--fg); font: 15px/1.45 -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif; }
#map { position: fixed; inset: 0; }
#top { position: fixed; top: 0; left: 0; right: 0; display: flex; flex-direction: column; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 10px) 12px 4px; z-index: 5; pointer-events: none; }
#top > * { pointer-events: auto; }
.searchcard { display: flex; align-items: center; width: 100%; max-width: 520px; height: 48px; padding: 0 4px 0 18px;
  background: var(--bg); border-radius: 24px; box-shadow: 0 2px 10px rgba(0,0,0,.25); }
.searchcard #q { flex: 1 1 auto; min-width: 0; max-width: none; padding: 0; border: 0; outline: 0; background: transparent; }
.gear { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 50%; background: transparent; color: var(--muted); }
.chips { display: flex; gap: 8px; flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; white-space: nowrap; }
.chip { height: 36px; padding: 0 16px; border: 0; border-radius: 18px; background: var(--bg); color: var(--fg); font: inherit; font-size: 14px; box-shadow: 0 1px 6px rgba(0,0,0,.25); }
.chip.on { background: var(--accent); color: #fff; }
.chip.round { margin-left: auto; width: 36px; padding: 0; border-radius: 50%; color: var(--muted); font-weight: 700; }
#legend { position: fixed; left: 8px; bottom: calc(env(safe-area-inset-bottom) + 30px); z-index: 5; font-size: 12px;
  background: color-mix(in srgb, var(--bg) 92%, transparent); border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; }
/* 画面中心の＋マーク。背景の地図タイルはアプリがダーク配色でも常に薄い色なので、--fgではなく固定の濃い色を使う
   （さらに白いハロー(drop-shadow)を添えて、森林・水域など地図が暗めの場所でも見えるようにする）。
   地図操作の邪魔にならないようクリックは透過させる */
#crosshair { position: fixed; top: 50%; left: 50%; width: 22px; height: 22px; transform: translate(-50%, -50%);
  z-index: 4; opacity: .9; pointer-events: none; filter: drop-shadow(0 0 1.5px #fff) drop-shadow(0 0 1.5px #fff); }
#crosshair::before, #crosshair::after { content: ''; position: absolute; background: #20272d; }
#crosshair::before { left: 50%; top: 0; bottom: 0; width: 2px; transform: translateX(-50%); }
#crosshair::after { top: 50%; left: 0; right: 0; height: 2px; transform: translateY(-50%); }
/* 左上、「路線」チップのすぐ下に、地図中心の都道府県・市区町村を表示（--top-hはヘッダーの実測高さ） */
#centerinfo { position: fixed; left: 12px; top: calc(var(--top-h, 96px) + 8px); z-index: 5; font-size: 12px;
  background: color-mix(in srgb, var(--bg) 92%, transparent); border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; }
.d { display: inline-block; border-radius: 50%; vertical-align: middle; margin: 0 2px 0 6px; }
.d.s0 { width: 8px; height: 8px; border: 1.5px solid #8a99a3; background: #fff; }
.d.s1 { width: 11px; height: 11px; background: var(--pass); border: 1.5px solid #fff; box-shadow: 0 0 0 1px #7d8b96; }
.d.s2 { width: 14px; height: 14px; background: var(--alight); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--alight); }
/* #sheet 自体は固定配置のみ担当し、スクロールは中の #sheetScroll に任せる
   （position:fixed の要素に直接 overflow:auto を付けると position:sticky の子が誤って前面に出ることがあるため） */
#sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; max-height: 75vh; display: flex; flex-direction: column;
  background: var(--bg); border-top: 1px solid var(--line); border-radius: 14px 14px 0 0;
  box-shadow: 0 -4px 20px rgba(0,0,0,.15); }
/* #sheet の display:flex は id セレクタなので、[hidden] のUA既定(display:none)より詳細度が高く上書きしてしまう。
   hidden 属性の時だけ確実に隠すよう明示しておく（閉じるボタン/スワイプで閉じても見た目に反映されなかった原因） */
#sheet[hidden] { display: none; }
/* flex + min-height:0 が無いと高さ100%指定が効かず、子が中身の高さぶん伸びてスクロールが発生しなくなる */
#sheetScroll { flex: 1 1 auto; min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 14px 16px calc(env(safe-area-inset-bottom) + 14px); }
/* #sheetFoot はスクロール領域の外（下）に固定で置く入力欄など用。空の時は使わないので隠す
   （「路線」パネルの検索欄をここに置き、候補一覧は #sheetScroll 側＝検索欄の上に出るようにして、
   ソフトキーボード表示中も検索欄・候補がキーボードの上に残るようにしている） */
#sheetFoot { flex: none; padding: 10px 16px calc(env(safe-area-inset-bottom) + 10px); border-top: 1px solid var(--line); background: var(--bg); }
#sheetFoot[hidden] { display: none; }
#sheet h2 { margin: 0 0 2px; font-size: 18px; }
#sheet .sub { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); }
.row.grouprow { background: var(--line); border-top: 0; border-radius: 8px; padding: 8px 10px; margin-top: 8px; }
.row.grouprow .ln { font-weight: 600; }
.row.subline { padding-left: 18px; border-top-style: dashed; }
.row.subline .ln { font-size: 13px; color: var(--muted); }
.ln { flex: 1; min-width: 0; font-size: 14px; }
button.ln { border: 0; background: transparent; color: inherit; font: inherit; padding: 0; text-align: left; cursor: pointer; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; flex: none; }
.seg button { border: 0; background: transparent; color: var(--fg); padding: 9px 12px; min-height: 44px; font: inherit; }
.seg.mini button { padding: 8px 9px; min-height: 40px; font-size: 13px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on[data-s="0"] { background: var(--line); }
.seg button.on[data-s="1"] { background: var(--pass); color: #10222c; }
.seg button.on[data-s="2"] { background: var(--alight); color: #fff; }
.seg.locked { opacity: .4; }
.seg.locked button { cursor: not-allowed; }
.authPrompt { background: #fff3bf; color: #4a3b00; border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; font-size: 14px; }
.authPrompt .actions { margin-top: 8px; margin-bottom: 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.btn { border: 1px solid var(--line); background: transparent; color: var(--fg); border-radius: 8px; padding: 10px 14px; min-height: 44px; font: inherit; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom) + 90px); z-index: 20;
  background: #222; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; max-width: 90vw; }
.lnk { border: 0; background: transparent; color: var(--accent); font: inherit; padding: 4px 6px; min-height: 32px; white-space: nowrap; }
.form label { display: block; font-size: 13px; color: var(--muted); margin-top: 10px; }
.form input { display: block; width: 100%; margin-top: 4px; padding: 11px 12px; font: inherit; font-size: 16px; color: var(--fg);
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; }
#lineSearch { display: block; width: 100%; margin: 8px 0; padding: 11px 12px; font: inherit; font-size: 16px; color: var(--fg);
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; }
.btn.on { background: var(--accent); border-color: var(--accent); color: #fff; }
#q { flex: 1 1 120px; min-width: 0; max-width: 220px; padding: 6px 10px; font-size: 16px; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; }
#results { position: fixed; z-index: 6; top: calc(env(safe-area-inset-top) + 64px); left: 12px; right: 12px; max-width: 520px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.18); overflow: hidden; }
#results button { display: flex; justify-content: space-between; width: 100%; border: 0; border-bottom: 1px solid var(--line); background: transparent;
  color: var(--fg); font: inherit; padding: 12px 14px; min-height: 44px; text-align: left; }
#results button span { color: var(--muted); font-size: 13px; }
#results .none { padding: 12px 14px; color: var(--muted); }
#sheet.tall { max-height: calc(100vh - var(--top-h, 96px) - 10px); }
/* 「路線」パネルは検索欄を大きく使いたいので、ヘッダー（駅名を検索欄など）ごと覆う高さまで許可する。
   max-heightだけだと中身の高さ次第で上端の位置がブレて、ステータスバー（時計など）に重なることがあったため、
   topを直接指定して常にセーフエリアの直下で止まるようにしている。
   高さは100vhではなく--vvh（JSでvisualViewport.heightを反映。ソフトキーボード表示中はその分だけ縮む）を基準にする。
   さらにiOS Safariはhtml/bodyがスクロール不可でも、フォーカス中の入力欄を画面内に収めようとして
   visualViewport自体を下にパンさせることがあり、position:fixedの要素はこのパンに追従しないため、
   パンした量（--vvtop＝visualViewport.offsetTop）だけ上端の位置を一緒にずらして追従させている */
#sheet.full { top: calc(env(safe-area-inset-top) + var(--vvtop, 0px)); bottom: auto; height: calc(var(--vvh, 100vh) - env(safe-area-inset-top)); max-height: none; }
.big { font-size: 15px; margin: 4px 0 10px; } .big b { font-size: 26px; color: var(--alight); }
.bar { position: relative; height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.bar i { position: absolute; left: 0; top: 0; bottom: 0; } .bar .p { background: var(--pass); } .bar .a { background: var(--alight); }
.tabs { display: flex; gap: 8px; margin: 14px 0 6px; } .tabs button { flex: 1; min-height: 40px; border: 1px solid var(--line); background: transparent; color: var(--fg); border-radius: 8px; font: inherit; }
.tabs button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.drow { display: block; width: 100%; text-align: left; border: 0; border-top: 1px solid var(--line); background: transparent; color: var(--fg); font: inherit; padding: 10px 0; }
.dh { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 5px; } .dh span { color: var(--muted); font-size: 12px; text-align: right; }
#sheet h3 { margin: 14px 0 2px; font-size: 13px; color: var(--muted); }
#banner { position: fixed; top: calc(var(--top-h, 96px) + 2px); left: 0; right: 0; z-index: 5; background: #fff3bf; color: #4a3b00; font-size: 13px; padding: 6px 16px; }
#banner .lnk { color: #7a5b00; text-decoration: underline; }
#foot { position: fixed; left: 8px; bottom: calc(env(safe-area-inset-bottom) + 4px); z-index: 4; font-size: 11px; background: color-mix(in srgb, var(--bg) 85%, transparent); border-radius: 6px; padding: 2px 6px; }
#foot a { color: var(--muted); margin-right: 8px; text-decoration: none; } 
.btn.danger { color: #c92a2a; border-color: #c92a2a; }
.ts { margin-top: 12px; min-height: 65px; }
.form .sub a { color: var(--accent); }
/* #sheetScroll 自身の上下左右パディング分だけ、stickyヘッダーの背景と本体の間に隙間ができ、
   そこからスクロール中の中身が透けて見えていた。負のマージンで #sheetScroll の外周まで背景を伸ばして塞ぐ */
.diag-head { position: sticky; top: -14px; z-index: 2; background: var(--bg);
  margin: -14px -16px 2px; padding: 14px 16px 6px; border-bottom: 1px solid var(--line);
  transform: translateZ(0); will-change: transform; }
.diag-head h2, .diag-head .sub { margin-bottom: 0; }
.head-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.head-row h2 { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.head-actions { display: flex; gap: 6px; flex: none; }
.btn.sm { padding: 6px 10px; min-height: 32px; font-size: 13px; }
.diagram { padding: 4px 0; }
.drow2 { position: relative; display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px;
  padding: 8px 0 8px 32px; border: 0; background: transparent; color: var(--fg); font: inherit; text-align: left; }
.drow2::before, .drow2::after { content: ''; position: absolute; left: 15px; width: 3px; background: #8a99a3; transform: translateX(-50%); }
.drow2::before { top: 0; height: 50%; }
.drow2::after { top: 50%; height: 50%; }
.drow2:first-child::before, .drow2:last-child::after { display: none; }
.drow2 .d { position: absolute; left: 15px; top: 50%; transform: translate(-50%, -50%); margin: 0; z-index: 1; }

.selbox { pointer-events: none; box-sizing: border-box; display: flex; align-items: center; border: 3px solid #2f9e44; }
.selbox span { background: #fff; color: #26323b; font-weight: 600; line-height: 1; padding: 3px 5px 3px 2px; white-space: nowrap; border-radius: 4px; }
.chev { color: var(--muted); margin-left: 2px; }
.lname { display: block; }
.lhint { display: block; margin-top: 3px; font-size: 12px; color: var(--accent); }
.setname { padding: 4px 0; }
.helpcard { touch-action: pan-y; }
.helpcard b { font-size: 15px; }
.helpillus { display: flex; flex-direction: column; justify-content: center; gap: 4px; min-height: 90px;
  background: color-mix(in srgb, var(--line) 35%, transparent); border-radius: 10px; padding: 12px; margin-bottom: 12px; pointer-events: none; }
.helpillus .row { border-top: 0; padding: 4px 0; }
.helpillus .drow2 { border-top: 0; }
.helpnav { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 16px; }
.dots { display: flex; gap: 6px; }
.dot { width: 6px; height: 6px; padding: 0; border-radius: 50%; background: var(--line); }
.dot.on { width: 16px; border-radius: 4px; background: var(--accent); }
.btn:disabled { opacity: .45; }
