/* デザインシステムは設計方針書(site_design_doc.html)のトークンをそのまま踏襲 */
:root {
  --bg: #F2F4F5; --surface: #FFFFFF; --ink: #1A2530; --ink-dim: #5C6B76;
  --line: #D7DEE2; --line-faint: #E8EDEF; --accent: #2C7A66; --accent-ink: #FFFFFF;
  --warn: #A8631E; --warn-bg: #FBF0E2; --warn-line: #E8C79A;
  --sans: "Zen Kaku Gothic New", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo", sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12191D; --surface: #182229; --ink: #E7EDEC; --ink-dim: #90A3A0;
    --line: #2E3E42; --line-faint: #202B30; --accent: #4FBFA0; --accent-ink: #0B1512;
    --warn: #E0A458; --warn-bg: #2E2415; --warn-line: #5C481F;
  }
}
:root[data-theme="dark"] {
  --bg: #12191D; --surface: #182229; --ink: #E7EDEC; --ink-dim: #90A3A0;
  --line: #2E3E42; --line-faint: #202B30; --accent: #4FBFA0; --accent-ink: #0B1512;
  --warn: #E0A458; --warn-bg: #2E2415; --warn-line: #5C481F;
}
:root[data-theme="light"] {
  --bg: #F2F4F5; --surface: #FFFFFF; --ink: #1A2530; --ink-dim: #5C6B76;
  --line: #D7DEE2; --line-faint: #E8EDEF; --accent: #2C7A66; --accent-ink: #FFFFFF;
  --warn: #A8631E; --warn-bg: #FBF0E2; --warn-line: #E8C79A;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: var(--sans); }
a { color: var(--accent); }

#app { display: grid; grid-template-columns: 360px 1fr; height: 100vh; min-height: 560px; }
@media (max-width: 780px) { #app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; height: auto; min-height: 100vh; } }

#panel { background: var(--surface); border-right: 1px solid var(--line-faint); display: flex; flex-direction: column; padding: 18px 16px; gap: 14px; overflow-y: auto; }
.eyebrow { font-family: var(--mono); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); font-weight: 700; }
.brand { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.brand h1 { font-size: 17px; margin: 2px 0 0; font-weight: 800; line-height: 1.3; }
.brand a.disclaimer-link { font-size: 11px; color: var(--ink-dim); white-space: nowrap; }
.sub { font-size: 12px; color: var(--ink-dim); line-height: 1.6; margin: 0; }

.search-box { display: flex; align-items: center; gap: 8px; border: 1.5px solid var(--line); border-radius: 8px; padding: 12px; background: var(--bg); min-height: 44px; }
.search-box input { border: none; background: transparent; outline: none; color: var(--ink); font-family: var(--sans); font-size: 15px; width: 100%; }
.search-box input::placeholder { color: var(--ink-dim); }
.search-box svg { flex: none; opacity: .6; }

.muni-row { display: flex; gap: 6px; }
.muni-select { font-family: var(--sans); font-size: 12.5px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); width: 100%; }
.muni-select:disabled { opacity: .5; }

#results { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; max-height: 260px; min-height: 40px; }
.result-item { display: flex; justify-content: space-between; align-items: baseline; padding: 7px 9px; border-radius: 6px; cursor: pointer; border: 1px solid transparent; gap: 8px; }
.result-item:hover { background: var(--line-faint); }
.result-item.active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.result-item .rl { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.result-item .chiban { font-family: var(--mono); font-weight: 700; font-size: 13.5px; }
.result-item .place { font-size: 11px; color: var(--ink-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tier-badge { font-family: var(--mono); font-size: 9.5px; font-weight: 800; padding: 1px 6px; border-radius: 10px; flex: none; }
.tier-badge.r { background: #E7F2EE; color: var(--accent); }
.tier-badge.e { background: var(--warn-bg); color: var(--warn); }
.tier-badge.place { background: var(--line-faint); color: var(--ink-dim); }
:root[data-theme="dark"] .tier-badge.r, @media (prefers-color-scheme: dark) { }
.empty-note { font-size: 12px; color: var(--ink-dim); padding: 6px 2px; line-height: 1.7; }

#detail { border-top: 1px solid var(--line-faint); padding-top: 12px; display: none; flex-direction: column; gap: 6px; }
#detail.show { display: flex; }
#detail .d-chiban { font-family: var(--mono); font-size: 20px; font-weight: 700; }
#detail .d-row { display: flex; justify-content: space-between; font-size: 12px; padding: 3px 0; border-bottom: 1px dashed var(--line-faint); gap: 10px; }
#detail .d-row span:first-child { color: var(--ink-dim); flex: none; }
#detail .d-row span:last-child { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; overflow: hidden; text-overflow: ellipsis; }
#detail .actions { display: flex; gap: 8px; margin-top: 4px; flex-wrap: wrap; }
#detail .actions a { font-size: 11.5px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px; text-decoration: none; color: var(--ink-dim); }
#detail .actions a:hover { border-color: var(--warn); color: var(--warn); }
#detail .actions a#d-share:hover { border-color: var(--accent); color: var(--accent); }
#detail .actions a.copied { border-color: var(--accent); color: var(--accent); }

.est-toggle { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); font-size: 12px; }
.est-toggle .lbl { display: flex; flex-direction: column; gap: 1px; }
.est-toggle .lbl b { font-size: 12.5px; }
.est-toggle .lbl span { font-size: 10.5px; color: var(--ink-dim); }
.switch { position: relative; width: 38px; height: 21px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track { position: absolute; inset: 0; background: var(--line); border-radius: 20px; transition: background .15s; cursor: pointer; }
.switch input:checked + .track { background: var(--warn); }
.switch .thumb { position: absolute; top: 2px; left: 2px; width: 17px; height: 17px; background: #fff; border-radius: 50%; transition: transform .15s; pointer-events: none; }
.switch input:checked ~ .thumb { transform: translateX(17px); }

.footer-links { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line-faint); font-size: 11px; color: var(--ink-dim); display: flex; flex-direction: column; gap: 4px; }

#mapwrap { position: relative; overflow: hidden; background: var(--bg); }
#map { position: absolute; inset: 0; }
#map .maplibregl-canvas { cursor: grab; }
#map .maplibregl-canvas-container.maplibregl-interactive { cursor: grab; }
#map .maplibregl-canvas-container.maplibregl-interactive:active { cursor: grabbing; }

/* MapLibre純正コントロールをタッチしやすい大きさに */
.maplibregl-ctrl-group button { width: 36px !important; height: 36px !important; }
.maplibregl-ctrl-attrib { font-size: 10.5px !important; }

#est-banner { position: absolute; top: 0; left: 0; right: 0; background: var(--warn); color: #241206; font-size: 12px; font-weight: 700; text-align: center; padding: 7px 12px; display: none; z-index: 5; }
#est-banner.show { display: block; }

#hint { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); font-family: var(--mono); font-size: 11px; color: var(--ink-dim); background: var(--surface); border: 1px solid var(--line-faint); border-radius: 20px; padding: 5px 12px; opacity: .92; z-index: 4; pointer-events: none; white-space: nowrap; }
#hint.warn { color: var(--warn); border-color: var(--warn-line); background: var(--warn-bg); }

#locate-btn { position: absolute; bottom: 100px; right: 12px; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--accent); font-size: 18px; cursor: pointer; z-index: 4; box-shadow: 0 1px 4px rgba(0,0,0,.15); }
#locate-btn:hover { border-color: var(--accent); }
#locate-btn.busy { opacity: .5; pointer-events: none; }

#loading { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; background: color-mix(in srgb, var(--bg) 75%, transparent); font-size: 13px; color: var(--ink-dim); z-index: 6; pointer-events: none; }
#loading.show { display: flex; }

/* 初期表示のカバレッジ一覧(検索前に「どこがどれだけ見られるか」を見せる) */
#coverage { border-top: 1px solid var(--line-faint); padding-top: 10px; margin-top: -4px; }
#coverage summary { font-size: 12px; font-weight: 700; cursor: pointer; color: var(--ink-dim); list-style: none; display: flex; align-items: center; justify-content: space-between; }
#coverage summary::-webkit-details-marker { display: none; }
#coverage summary .car { transition: transform .15s; }
#coverage[open] summary .car { transform: rotate(90deg); }
#coverage .cov-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; max-height: 220px; overflow-y: auto; }
#coverage .cov-row { display: flex; flex-direction: column; gap: 3px; font-size: 11px; cursor: pointer; padding: 3px; border-radius: 4px; }
#coverage .cov-row:hover { background: var(--line-faint); }
#coverage .cov-head { display: flex; justify-content: space-between; gap: 8px; }
#coverage .cov-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#coverage .cov-pct { font-family: var(--mono); color: var(--ink-dim); flex: none; }
#coverage .cov-bar { height: 5px; border-radius: 3px; background: var(--line-faint); position: relative; overflow: hidden; }
#coverage .cov-bar i { position: absolute; inset: 0 auto 0 0; border-radius: 3px; background: var(--accent); display: block; }
