/* 道路標識の配色に寄せる: 濃紺の地＋規制の赤＋警戒の黄。地図を画面いっぱいにし、操作はパネル（スマホは下から、PC は左）に寄せる */
:root {
  --ink: #16213a;
  --ink-soft: #4a5672;
  --paper: #f6f7f9;
  --card: #ffffff;
  --line: #d8dde7;
  --signal-red: #d4202f;
  --caution: #e08a00;
  --unknown: #5d6fa3;
  --route: #1d63d8;
  --focus: #1d63d8;
  --font: "BIZ UDPGothic", "Hiragino Sans", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  --r: 12px;
  --shadow: 0 6px 24px rgba(10, 20, 40, 0.18);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #e8ecf5; --ink-soft: #a7b1c8; --paper: #0f1524; --card: #182036; --line: #2b3550;
    --signal-red: #ff5160; --caution: #ffb42e; --unknown: #8fa1d8; --route: #5b9bff; --focus: #8ab8ff;
    --shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ink: #e8ecf5; --ink-soft: #a7b1c8; --paper: #0f1524; --card: #182036; --line: #2b3550;
  --signal-red: #ff5160; --caution: #ffb42e; --unknown: #8fa1d8; --route: #5b9bff; --focus: #8ab8ff;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; overflow: hidden; }
body { background: var(--paper); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.5; }
#app { position: relative; height: 100%; }
#map { position: absolute; inset: 0; background: #e9ecef; }

button { font: inherit; cursor: pointer; color: inherit; }
input:focus-visible, button:focus-visible, summary:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }

/* ---------- 免責（常に表示） ---------- */
.notice {
  position: absolute; z-index: 800; top: calc(8px + env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%);
  max-width: min(560px, calc(100% - 120px)); background: var(--ink); color: var(--card);
  border-radius: 999px; padding: 5px 14px; font-size: 12.5px; box-shadow: var(--shadow);
}
.notice[open] { border-radius: var(--r); }
.notice summary { cursor: pointer; list-style: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notice summary::-webkit-details-marker { display: none; }
.notice .more { opacity: 0.8; }
.notice p { margin: 6px 0 4px; line-height: 1.6; }

.pickbar {
  position: absolute; z-index: 800; top: calc(48px + env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%);
  display: flex; gap: 10px; align-items: center; background: var(--route); color: #fff;
  padding: 8px 8px 8px 14px; border-radius: 999px; box-shadow: var(--shadow); font-size: 14px; white-space: nowrap;
}
.pickbar button { border: 0; background: rgba(255, 255, 255, 0.22); color: #fff; border-radius: 999px; padding: 4px 12px; }

/* ---------- パネル ---------- */
.sheet {
  position: absolute; z-index: 700; background: var(--card); box-shadow: var(--shadow);
  display: flex; flex-direction: column;
}
.handle {
  border: 0; background: transparent; display: grid; justify-items: center; gap: 4px;
  padding: 8px 16px 6px; width: 100%; flex: none;
}
/* 調べている間の動き */
.spin { display: inline-block; width: 0.95em; height: 0.95em; margin-right: 6px; vertical-align: -0.12em; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.busybar { position: absolute; top: 0; left: 0; right: 0; height: 4px; overflow: hidden; border-radius: 16px 16px 0 0; pointer-events: none; }
body.busy .busybar::after { content: ""; position: absolute; top: 0; bottom: 0; width: 35%; background: var(--route); animation: slide 1.1s ease-in-out infinite; }
@keyframes slide { from { left: -35%; } to { left: 100%; } }
.stop-sub.warn { white-space: pre-line; }
@media (prefers-reduced-motion: reduce) { .spin { animation-duration: 2.4s !important; } body.busy .busybar::after { animation: none !important; left: 0; width: 100%; opacity: 0.6; } }
.size-hint { font-size: 11.5px; color: var(--route); }
.summary .warn, .cover-warn { color: var(--signal-red); }
.cover-warn { margin: 0; font-size: 13.5px; font-weight: 700; background: color-mix(in srgb, var(--signal-red) 10%, transparent); border-radius: 8px; padding: 6px 10px; }
.hit .st { font-weight: 700; }
.hit.now .st { color: var(--signal-red); } .hit.later .st { color: var(--caution); } .hit.unknown .st { color: var(--unknown); }
.pin.via span { font-size: 11px; }
.grip { width: 40px; height: 5px; border-radius: 3px; background: var(--line); }
.summary { font-size: 13.5px; color: var(--ink-soft); max-width: 100%; text-align: center; line-height: 1.4; }
.summary b { color: var(--ink); }
.sheet-body { overflow-y: auto; padding: 0 16px calc(16px + env(safe-area-inset-bottom, 0px)); display: grid; gap: 10px; align-content: start; }

/* スマホ: 下から出るパネル。3段の高さを切り替える */
@media (max-width: 899px) {
  .sheet { left: 0; right: 0; bottom: 0; border-radius: 16px 16px 0 0; transition: height 0.2s ease; }
  .sheet[data-size="peek"] { height: calc(56px + env(safe-area-inset-bottom, 0px)); }
  .sheet[data-size="half"] { height: 52%; }
  .sheet[data-size="full"] { height: calc(100% - 52px - env(safe-area-inset-top, 0px)); }
  .sheet[data-size="peek"] .sheet-body { display: none; }
  .sheet[data-size="full"] { z-index: 1100; } /* 全部の時は地図のボタンを一覧に重ねない */
  .handle { touch-action: none; }
  .sheet .brand { display: none; }
  .leaflet-control-attribution { font-size: 10px; }
  .leaflet-bottom { bottom: var(--sheet-h, 52%); }
}
/* PC: 左の固定パネル */
@media (min-width: 900px) {
  .sheet { top: 0; bottom: 0; left: 0; width: 400px; }
  .handle { display: none; }
  .sheet-body { padding-top: 14px; height: 100%; }
  .notice { left: calc(50% + 200px); max-width: min(560px, calc(100% - 520px)); }
  .pickbar { left: calc(50% + 200px); }
  .leaflet-left { left: 400px; }
}

.brand { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.brand h1 { font-size: 17px; margin: 0; letter-spacing: 0.02em; }
.brand .sub { color: var(--ink-soft); font-size: 12.5px; }
.mark { width: 13px; height: 13px; border-radius: 50%; border: 3px solid var(--signal-red); align-self: center; }

/* ---------- 地点の並び ---------- */
.plan { display: grid; gap: 8px; }
.stops { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; position: relative; }
.stop { display: grid; grid-template-columns: 40px 1fr auto; gap: 6px; align-items: start; }
.badge {
  height: 38px; display: grid; place-items: center; border-radius: 8px; font-size: 12px; font-weight: 700;
  background: var(--paper); border: 1px solid var(--line); color: var(--ink-soft);
}
.stop.start .badge { background: var(--route); border-color: var(--route); color: #fff; }
.stop.goal .badge { background: var(--ink); border-color: var(--ink); color: var(--card); }
.stop.road .badge { background: #6b3fb5; border-color: #6b3fb5; color: #fff; }
.stop-main { min-width: 0; display: grid; gap: 2px; position: relative; }
.input-wrap { position: relative; }
.input-wrap input { padding-right: 34px !important; }
.clear { position: absolute; right: 2px; top: 2px; width: 34px; height: 34px; border: 0; background: transparent; color: var(--ink-soft); font-size: 18px; border-radius: 8px; }
.reset { border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 10px; padding: 9px 14px; font-weight: 700; white-space: nowrap; }
.stop input {
  font: inherit; font-size: 16px; /* iPhone で拡大されない大きさ */ color: var(--ink); background: var(--paper);
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; width: 100%; min-width: 0; height: 38px;
}
.stop.ok input { border-color: color-mix(in srgb, var(--route) 55%, var(--line)); }
.stop-sub { font-size: 12px; color: var(--ink-soft); padding-left: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stop-sub.warn { color: var(--signal-red); white-space: normal; }
.tools { display: flex; gap: 4px; }
.tool {
  height: 38px; min-width: 38px; padding: 0 8px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink-soft); font-size: 12.5px; white-space: nowrap;
}
.tool[aria-pressed="true"] { border-color: var(--route); color: var(--route); }
.tool.del { color: var(--signal-red); }
.tool.find { color: var(--route); border-color: color-mix(in srgb, var(--route) 45%, var(--line)); font-weight: 700; }
.stop-sub.example { color: var(--ink-soft); opacity: 0.85; white-space: normal; }

.cands {
  list-style: none; margin: 4px 0 0; padding: 4px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); box-shadow: var(--shadow); display: grid; gap: 2px; max-height: 260px; overflow-y: auto;
}
.cands button { width: 100%; text-align: left; border: 0; background: transparent; border-radius: 8px; padding: 7px 8px; display: grid; }
.cands button:hover, .cands button:focus-visible { background: var(--paper); }
.cands .t { font-weight: 700; font-size: 14px; }
.cands .s { font-size: 12px; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cands .none { padding: 8px; font-size: 13px; color: var(--ink-soft); }

.add-row { display: flex; gap: 8px; padding-left: 46px; }
.add { border: 1px dashed var(--line); background: transparent; border-radius: 8px; padding: 6px 12px; font-size: 13.5px; color: var(--ink-soft); }
.go-row { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.when { font-size: 13px; color: var(--ink-soft); display: flex; gap: 6px; align-items: center; }
.when input { font: inherit; font-size: 16px; color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; font-variant-numeric: tabular-nums; }
.go { border: 0; background: var(--ink); color: var(--card); border-radius: 10px; padding: 10px 18px; font-weight: 700; flex: 1; min-width: 150px; }
.go:disabled { opacity: 0.6; cursor: progress; }
.hint { margin: 0; font-size: 12px; color: var(--ink-soft); }
.status { margin: 0; font-size: 13.5px; color: var(--ink-soft); min-height: 1.5em; }
.status.error { color: var(--signal-red); }

/* ---------- 結果 ---------- */
.results-head { display: grid; gap: 6px; }
.results h2 { font-size: 15px; margin: 0; }
.legend { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font-size: 11.5px; padding: 1px 8px; border-radius: 999px; border: 1.5px solid currentColor; white-space: nowrap; }
.chip.now { color: var(--signal-red); }
.chip.later { color: var(--caution); }
.chip.unknown { color: var(--unknown); }
.chip.dashed { color: var(--ink-soft); border-style: dashed; }
.hit-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.hit {
  display: grid; grid-template-columns: 26px 1fr auto; gap: 8px; align-items: start;
  padding: 8px 10px 8px 8px; border: 1px solid var(--line); border-left-width: 5px; border-radius: var(--r);
  background: var(--card); text-align: left; width: 100%;
}
.hit.now { border-left-color: var(--signal-red); }
.hit.later { border-left-color: var(--caution); }
.hit.unknown { border-left-color: var(--unknown); }
.hit .no { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink-soft); text-align: center; }
.hit .title { font-weight: 700; }
.hit .meta { color: var(--ink-soft); font-size: 13px; }
.hit .km { font-variant-numeric: tabular-nums; color: var(--ink-soft); font-size: 13px; white-space: nowrap; }
.empty { color: var(--ink-soft); font-size: 14px; }

.extras { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: center; border-top: 1px solid var(--line); padding-top: 10px; font-size: 13px; color: var(--ink-soft); }
.toggle { display: inline-flex; gap: 6px; align-items: center; }
.link { border: 0; background: none; color: var(--ink-soft); text-decoration: underline; font-size: 13px; padding: 0; }

/* ---------- 地図の上の印 ---------- */
.pin {
  width: 30px; height: 30px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); display: grid; place-items: center;
  background: var(--route); border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}
.pin span { transform: rotate(45deg); color: #fff; font: 700 12px var(--font); }
.pin.goal { background: #16213a; }
.pin.via { background: #3d4f7a; }
.hitno {
  width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; border: 2px solid #fff;
  color: #fff; font: 700 11.5px var(--font); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}
.hitno.now { background: #d4202f; } .hitno.later { background: #e08a00; } .hitno.unknown { background: #5d6fa3; }
.press-menu { display: grid; gap: 6px; min-width: 150px; }
.press-menu button { border: 1px solid #d8dde7; background: #fff; color: #16213a; border-radius: 8px; padding: 6px 10px; text-align: left; }

/* 地図の吹き出し */
.leaflet-popup-content { font-family: var(--font); font-size: 13.5px; line-height: 1.55; margin: 12px 14px; }
.pop h3 { margin: 0 0 4px; font-size: 15px; }
.pop dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 6px 0; }
.pop dt { color: #4a5672; }
.pop dd { margin: 0; font-variant-numeric: tabular-nums; }
.pop .conf { font-size: 12px; color: #4a5672; }
.pop a { word-break: break-all; }
.leaflet-control-layers-expanded { font-family: var(--font); }
.credit { font-size: 11.5px; color: var(--ink-soft); margin: 0; }
.credit a { color: inherit; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
