/* ふくいオープンデータ ポータル — 共通スタイル */

:root {
  --bg: #f5f2eb;
  --surface: #fdfcf9;
  --surface-2: #efebe1;
  --border: #d8d1c0;
  --text: #262a2e;
  --muted: #6b665b;
  --accent: #23608f;
  --accent-dark: #1a4a70;
  --accent-soft: #e9eef2;
  --sea: #3d7468;
  --warn: #a2582b;
  --radius: 4px;
  --shadow: none;
  --serif: 'Hiragino Mincho ProN', 'Yu Mincho', 'BIZ UDMincho', 'Noto Serif JP', 'Noto Serif CJK JP', serif;
  --maxw: 1140px;
  --search-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001q.044.06.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1 1 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0'/%3E%3C/svg%3E");
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16191d;
    --surface: #1e2227;
    --surface-2: #262b31;
    --border: #3b4147;
    --text: #e8e5dd;
    --muted: #a6a094;
    --accent: #7fb0d8;
    --accent-dark: #a8cbe6;
    --accent-soft: #24384a;
    --sea: #4d9c8d;
    --warn: #d09a67;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, 'Segoe UI', 'Hiragino Sans', 'Noto Sans JP',
    'Yu Gothic UI', Meiryo, sans-serif;
  font-size: 16px;
  line-height: 1.75;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }

/* ---------- header ---------- */

.site-header {
  background: var(--surface);
  border-top: 3px solid var(--accent-dark);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.site-header .wrap {
  display: flex;
  align-items: center;
  gap: 24px;
  min-height: 62px;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.08rem;
  color: var(--text);
  letter-spacing: 0.01em;
}
.brand:hover { text-decoration: none; }
.brand .mark {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 3px;
  background: var(--accent-dark);
  color: #fff; font-size: 15px;
}
.site-nav { margin-left: auto; display: flex; gap: 20px; flex-wrap: wrap; }
.site-nav a {
  color: var(--muted);
  padding: 6px 1px;
  border-bottom: 2px solid transparent;
  font-size: 0.92rem;
}
.site-nav a:hover { text-decoration: none; color: var(--text); border-bottom-color: var(--border); }
.site-nav a[aria-current='page'] { color: var(--accent-dark); border-bottom-color: var(--accent); font-weight: 600; }

/* ---------- hero ---------- */

.hero {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 44px 0 34px;
}
.hero h1 { margin: 0 0 12px; font-size: clamp(1.5rem, 3.2vw, 2.05rem); line-height: 1.5; font-weight: 600; }
.hero p { margin: 0; max-width: 62ch; color: var(--muted); }
.hero .stats { display: flex; gap: 26px; flex-wrap: wrap; margin-top: 26px; }
.hero .stat { border-left: 2px solid var(--border); padding-left: 14px; }
.hero .stat b {
  display: block; font-size: 1.5rem; line-height: 1.35;
  font-family: var(--serif); color: var(--accent-dark); font-variant-numeric: tabular-nums;
}
.hero .stat span { font-size: 0.82rem; color: var(--muted); }

/* ---------- layout blocks ---------- */

main { padding: 34px 0 64px; }
section { margin-bottom: 44px; }
/* 見出しは明朝。本文はゴシックのまま（表やデータの読みやすさを優先） */
h1, h2, h3, .page-title, .panel-title { font-family: var(--serif); letter-spacing: 0.01em; }
h2 { font-size: 1.26rem; margin: 0 0 16px; padding-bottom: 8px; border-bottom: 1px solid var(--border); font-weight: 600; }
h3 { font-size: 1.05rem; margin: 26px 0 10px; }
.lead { color: var(--muted); margin-top: -6px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-pad { padding: 20px; }

.grid { display: grid; gap: 14px; }
.grid.cat { grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); }
.grid.ds { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }

/* ---------- category tiles ---------- */

.cat-tile {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  transition: border-color 0.12s ease;
}
.cat-tile:hover {
  text-decoration: none;
  border-color: var(--accent);
}
.cat-tile .emoji { font-size: 1.6rem; }
.cat-tile .t { font-weight: 600; line-height: 1.35; }
.cat-tile .c { color: var(--muted); font-size: 0.82rem; }

/* ---------- dataset cards ---------- */

.ds-card {
  display: flex; flex-direction: column; gap: 8px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
}
.ds-card:hover { text-decoration: none; border-color: var(--accent); box-shadow: var(--shadow); }
.ds-card .title { font-weight: 650; line-height: 1.45; }
.ds-card .desc {
  color: var(--muted); font-size: 0.88rem; margin: 0;
  display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
}
.ds-card .meta { margin-top: auto; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

/* ---------- badges ---------- */

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.02em;
  padding: 2px 8px; border-radius: 3px;
  background: var(--surface-2); color: var(--muted);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.badge.fmt-CSV { background: #e6f6ec; color: #17693c; border-color: #bfe6ce; }
.badge.fmt-RDF { background: #efe9fb; color: #543a9b; border-color: #d8ccf3; }
.badge.fmt-Linked-RDF { background: #fdf0e3; color: #8a4d10; border-color: #f2ddc1; }
.badge.fmt-ZIP,
.badge.fmt-TXT,
.badge.fmt-HTML { background: var(--surface-2); }
.badge.geo { background: var(--accent-soft); color: var(--accent-dark); border-color: transparent; }
.badge.cat { background: var(--accent-soft); color: var(--accent-dark); border-color: transparent; }

@media (prefers-color-scheme: dark) {
  .badge.fmt-CSV { background: #123222; color: #7fe0a6; border-color: #1d5236; }
  .badge.fmt-RDF { background: #241b3d; color: #c0a9f5; border-color: #392c5c; }
  .badge.fmt-Linked-RDF { background: #35240f; color: #f0bd82; border-color: #533a1c; }
}

/* ---------- search / filter bar ---------- */

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 18px; }
.search-box { position: relative; flex: 1 1 300px; }
.search-box input {
  width: 100%;
  padding: 12px 14px 12px 40px;
  font-size: 1rem; font-family: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
}
.search-box input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
/* 虫めがねアイコン（Bootstrap Icons "search" / MIT License）を data URI で埋め込む */
.search-box::before {
  content: ''; position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; opacity: 0.5; pointer-events: none;
  background-color: currentColor;
  -webkit-mask: var(--search-icon) no-repeat center / contain;
  mask: var(--search-icon) no-repeat center / contain;
}
select, .btn {
  padding: 11px 14px;
  font-size: 0.94rem; font-family: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
}
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn.primary { background: var(--accent); color: #fff; border-color: transparent; font-weight: 600; }
.btn.primary:hover { background: var(--accent-dark); }
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  padding: 5px 12px; border-radius: 4px; font-size: 0.85rem;
  border: 1px solid var(--border); background: var(--surface); color: var(--muted);
  cursor: pointer; font-family: inherit;
}
.chip[aria-pressed='true'] { background: var(--accent); color: #fff; border-color: transparent; }
.result-count { color: var(--muted); font-size: 0.9rem; margin: 4px 0 14px; }

/* ---------- breadcrumb ---------- */

.breadcrumb { font-size: 0.85rem; color: var(--muted); padding: 14px 0 0; }
.breadcrumb a { color: var(--muted); }
.breadcrumb span + span::before { content: '›'; margin: 0 8px; opacity: 0.6; }

/* ---------- dataset detail ---------- */

.ds-head h1 { font-size: clamp(1.4rem, 3vw, 2rem); margin: 6px 0 12px; line-height: 1.35; }
.ds-head .meta-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.ds-head .desc { color: var(--text); white-space: pre-wrap; max-width: 75ch; }

.dl-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.dl-list li {
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: 4px;
  background: var(--surface-2);
}
.dl-list .name { flex: 1 1 240px; font-size: 0.94rem; word-break: break-word; }
.dl-list .sub { color: var(--muted); font-size: 0.8rem; }

dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 0; }
dl.facts dt { color: var(--muted); font-size: 0.86rem; }
dl.facts dd { margin: 0; font-size: 0.94rem; word-break: break-word; }

/* ---------- data table ---------- */

.table-wrap {
  overflow: auto; max-height: 620px;
  border: 1px solid var(--border); border-radius: 4px; background: var(--surface);
}
table.data { border-collapse: collapse; width: 100%; font-size: 0.86rem; }
table.data th, table.data td {
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  padding: 7px 11px; text-align: left; vertical-align: top;
  white-space: nowrap; max-width: 340px; overflow: hidden; text-overflow: ellipsis;
}
table.data th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface-2); font-weight: 650; white-space: nowrap;
}
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tbody tr:hover td { background: var(--accent-soft); }
/* HTML に直接書き出した表（読み込み後に JavaScript が作り直すまでの表示）。 */
table.data caption {
  caption-side: top; text-align: left; padding: 8px 11px;
  color: var(--muted); font-size: 0.82rem; background: var(--surface-2);
}
.embed-title { margin: 12px 11px 0; font-size: 0.92rem; }
.table-meta { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin: 10px 0; color: var(--muted); font-size: 0.86rem; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.tabs button {
  padding: 7px 14px; border-radius: 4px; font-size: 0.88rem; font-family: inherit;
  border: 1px solid var(--border); background: var(--surface); color: var(--muted); cursor: pointer;
}
.tabs button[aria-selected='true'] { background: var(--accent); color: #fff; border-color: transparent; font-weight: 600; }

/* ---------- map ---------- */

.map-canvas {
  width: 100%; height: 520px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-2);
}
.map-canvas.tall { height: min(74vh, 780px); }

/* 「地図を指で動かす」の切り替え。地図の入れ物に直接重ねるので、
   入れ物を位置の基準にする（Google が中に作る div は position を持つ）。
   押している状態が分かるように色を変える。 */
.map-canvas { position: relative; }
.map-gesture-toggle {
  position: absolute; z-index: 2; left: 10px; bottom: 24px;
  padding: 9px 13px;
  font: inherit; font-size: 0.84rem; font-weight: 650; line-height: 1;
  color: #3c4043; background: #fff; border: 0; border-radius: 3px;
  box-shadow: 0 1px 4px -1px rgba(0, 0, 0, 0.35); cursor: pointer;
}
.map-gesture-toggle[aria-pressed='true'] { color: #fff; background: var(--accent); }
.map-fallback { padding: 22px; }
.map-fallback code {
  background: var(--surface-2); padding: 1px 6px; border-radius: 3px;
  font-size: 0.86em; word-break: break-all;
}
.point-list { list-style: none; margin: 12px 0 0; padding: 0; max-height: 340px; overflow: auto; display: grid; gap: 4px; }
.point-list li { display: flex; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 0.88rem; }
.point-list .pn { flex: 1; }
/* 地図の上に出す吹き出し。
   ページ全体は影を使わない見た目にしているが（--shadow: none）、地図の上だけは
   別。白い箱を淡い地図の上にそのまま置くと、輪郭が地図に溶けて読みにくい。
   ここは地図の一部ではなく「上に載っているもの」なので、枠と影を付ける。 */
.gm-info { font-size: 0.88rem; line-height: 1.6; max-width: 260px; color: #16212e; }
.gm-info b { display: block; margin-bottom: 2px; }
.gm-info a { color: #1667c9; }
.gm-style .gm-style-iw-c {
  border: 1px solid rgba(20, 26, 33, 0.28);
  box-shadow: 0 2px 10px rgba(20, 26, 33, 0.25);
}
/* 吹き出しの下の三角も、枠に合わせて縁を付ける */
.gm-style .gm-style-iw-tc::after { box-shadow: 0 2px 6px rgba(20, 26, 33, 0.25); }

.map-legend { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 12px 0; }

/* ---------- misc ---------- */

.notice {
  border-left: 4px solid var(--warn);
  background: var(--surface);
  border-radius: 4px;
  padding: 12px 16px;
  color: var(--muted);
  font-size: 0.9rem;
}
.empty { text-align: center; padding: 48px 0; color: var(--muted); }

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 28px 0 40px;
  color: var(--muted);
  font-size: 0.87rem;
}
.site-footer a { color: var(--muted); text-decoration: underline; }
.site-footer .cols { display: flex; gap: 40px; flex-wrap: wrap; }

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

@media (max-width: 640px) {
  .hero { padding: 40px 0 34px; }
  dl.facts { grid-template-columns: 1fr; gap: 2px 0; }
  dl.facts dd { margin-bottom: 10px; }
  .map-canvas { height: 400px; }
}

/* ===================================================================
   アイコン（Bootstrap Icons をインライン SVG で埋め込み）
   =================================================================== */

.icon, .icon-xs, .icon-lg {
  display: inline-block;
  vertical-align: -0.14em;
  flex: none;
}
.icon { width: 1.05em; height: 1.05em; }
.icon-xs { width: 0.92em; height: 0.92em; }
.icon-lg { width: 1.5em; height: 1.5em; }

h2 .icon, h2 .icon-lg { margin-right: 6px; opacity: 0.75; }
.badge .icon-xs { margin-right: 3px; }
.btn .icon, .btn .icon-xs { margin-right: 5px; }
.site-nav a .icon { margin-right: 5px; opacity: 0.8; }

.brand .mark .icon { width: 17px; height: 17px; }

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--accent); color: #fff; padding: 10px 16px; border-radius: 0;
}
.skip-link:focus { left: 0; }

/* ===================================================================
   全体索引
   =================================================================== */

.grid.sites { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }

.site-card {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  transition: border-color 0.12s ease;
}
.site-card:hover { text-decoration: none; border-color: var(--accent); }
.site-card .ic { color: var(--accent); display: grid; place-items: center; }
.site-card .body { flex: 1; min-width: 0; }
.site-card .t { font-weight: 650; display: block; line-height: 1.4; }
.site-card .s { color: var(--muted); font-size: 0.82rem; display: block; }
.site-card .c { color: var(--accent-dark); font-size: 0.82rem; display: block; margin-top: 2px; }
.site-card .go { color: var(--muted); opacity: 0.6; }
.site-card.empty-card { opacity: 0.72; }
.site-card.empty-card .c { color: var(--muted); }

.cat-tile .ic { color: var(--accent); display: grid; place-items: center; }

/* ===================================================================
   共通の小物
   =================================================================== */

.page-title { font-size: clamp(1.35rem, 3vw, 1.75rem); margin: 8px 0 6px; line-height: 1.35; }
.wrap.narrow { max-width: 820px; }
.hero.compact { padding: 40px 0 34px; }
.hero .eyebrow { font-size: 0.85rem; color: var(--muted); margin: 0 0 8px; }
.hero .eyebrow a { color: var(--muted); text-decoration: underline; }
.btn.small { padding: 6px 12px; font-size: 0.84rem; }
.lead.small { font-size: 0.85rem; }
.site-footer .ft { margin: 0 0 2px; }

/* ===================================================================
   マニュアルページ
   =================================================================== */

.doc h1 { font-size: clamp(1.5rem, 3.4vw, 2rem); margin: 10px 0 18px; }
.doc h2 {
  font-size: 1.25rem; margin: 44px 0 12px; padding-top: 18px;
  border-top: 1px solid var(--border);
}
.doc h3 { font-size: 1.02rem; margin: 26px 0 8px; }
.doc p, .doc li { line-height: 1.85; }
.doc ul, .doc ol { padding-left: 1.4em; }
.doc li { margin-bottom: 4px; }
.doc hr { border: 0; border-top: 1px solid var(--border); margin: 34px 0; }
.doc code {
  background: var(--surface-2); padding: 1px 6px; border-radius: 3px;
  font-size: 0.88em; word-break: break-word;
}
.doc pre.code {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 4px; padding: 14px 16px; overflow-x: auto;
  font-size: 0.85rem; line-height: 1.65;
}
.doc pre.code code { background: none; padding: 0; }
.doc .notice { margin: 16px 0; }
.doc .table-scroll { overflow-x: auto; margin: 14px 0; }
.doc table.doc-table { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
.doc table.doc-table th, .doc table.doc-table td {
  border: 1px solid var(--border); padding: 8px 12px; text-align: left; vertical-align: top;
}
.doc table.doc-table th { background: var(--surface-2); font-weight: 650; }

.toc {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 20px; margin: 0 0 28px;
}
.toc-title { font-weight: 650; margin: 0 0 6px; font-size: 0.92rem; }
.toc ol { margin: 0; padding-left: 1.3em; }
.toc li { margin-bottom: 2px; font-size: 0.92rem; }

/* ===================================================================
   地図フォールバック（OpenStreetMap / 地点リスト）
   =================================================================== */

.map-note { margin: 10px 0 0; }
.map-note:empty { display: none; }
.notice.inline { display: block; font-size: 0.85rem; padding: 10px 14px; }

.map-fallback { padding: 20px; }
.point-list li {
  display: flex; gap: 12px; align-items: center;
  padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 0.9rem;
}
.point-list .pn { flex: 1; min-width: 0; }
.point-list .sub { opacity: 0.7; font-size: 0.85em; }
.point-list .links { display: flex; gap: 6px; flex: none; }
.point-list .links a {
  font-size: 0.78rem; padding: 3px 9px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--muted);
}
.point-list .links a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

/* 表 / カードの切り替え */
.view-switch { display: inline-flex; border: 1px solid var(--border); border-radius: 4px; overflow: hidden; }
.view-switch button {
  padding: 6px 12px; font-size: 0.84rem; border: 0; cursor: pointer;
  background: var(--surface); color: var(--muted);
}
.view-switch button + button { border-left: 1px solid var(--border); }
.view-switch button.on { background: var(--accent); color: #fff; font-weight: 600; }

/* 施設カードの一覧 */
.card-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.ds-item {
  border: 1px solid var(--border); border-radius: 4px; padding: 14px;
  background: var(--surface); overflow-wrap: anywhere;
}
.ds-item strong { display: block; font-size: 0.98rem; }
.ds-item .sub { margin: 4px 0 0; color: var(--muted); font-size: 0.86rem; }
.ds-item dl.mini { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 10px 0 0; font-size: 0.84rem; }
.ds-item dl.mini dt { color: var(--muted); }
.ds-item dl.mini dd { margin: 0; }
.ds-item .links { margin: 10px 0 0; font-size: 0.84rem; }

/* 押している間だと分かるボタン（現在地の近く） */
.btn.active {
  background: var(--accent); color: #fff; border-color: transparent; font-weight: 600;
}
.btn.active:hover { background: var(--accent-dark); }

/* 1 行だけの表は「項目: 値」で縦に並べる */
.kv { display: grid; grid-template-columns: minmax(8em, 22%) 1fr; gap: 0; margin: 0; }
.kv dt {
  padding: 9px 14px 9px 0; border-bottom: 1px solid var(--border);
  color: var(--muted); font-size: 0.88rem; overflow-wrap: anywhere;
}
.kv dd {
  padding: 9px 0; margin: 0; border-bottom: 1px solid var(--border);
  overflow-wrap: anywhere;
}
@media (max-width: 560px) {
  .kv { grid-template-columns: 1fr; }
  .kv dt { padding-bottom: 0; border-bottom: 0; }
  .kv dd { padding-top: 2px; }
}

/* 現在地から近い順 */
.nearby-host { margin-top: 14px; }
.nearby-host[hidden] { display: none; }
.nearby-head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.nearby-head .sub { color: var(--muted); font-size: 0.85rem; flex: 1; }
.point-list.nearby { max-height: 420px; }
/* 距離は桁をそろえて縦に読めるようにする */
.point-list .dist {
  flex: none; min-width: 66px; text-align: right;
  font-variant-numeric: tabular-nums; font-weight: 600; color: var(--accent);
}
.nearby-privacy { margin: 10px 0 0; color: var(--muted); font-size: 0.8rem; }

/* Leaflet はダークテーマだと白飛びするので、少しだけ馴染ませる */
.leaflet-container { font: inherit; border-radius: var(--radius); }
.leaflet-popup-content { font-size: 0.88rem; line-height: 1.6; }
/* Google 側と同じ理由で、地図の上の吹き出しだけは枠と影を付ける */
.leaflet-popup-content-wrapper, .leaflet-popup-tip {
  border: 1px solid rgba(20, 26, 33, 0.28);
  box-shadow: 0 2px 10px rgba(20, 26, 33, 0.25);
}
@media (prefers-color-scheme: dark) {
  .leaflet-tile { filter: brightness(0.86) contrast(1.05); }
  .leaflet-control-attribution { background: rgba(22, 31, 42, 0.85) !important; color: var(--muted) !important; }
  .leaflet-control-attribution a { color: var(--accent) !important; }
}

/* ===================================================================
   広告枠
   邪魔にならないよう、本文を読み終えた位置にだけ控えめに置く。
   高さを先に確保して、読み込み時のガタつき（CLS）を防ぐ。
   =================================================================== */

.ad-slot {
  display: block;
  margin: 36px 0 8px;
  padding: 10px 0 0;
  border-top: 1px solid var(--border);
}
.ad-label {
  display: block;
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  color: var(--muted);
  opacity: 0.75;
  margin-bottom: 6px;
}
.ad-body {
  min-height: 100px;
  max-height: 280px;
  overflow: hidden;
}
.ad-body:empty { display: none; }
.ad-body ins { display: block; }

@media (max-width: 640px) {
  .ad-slot { margin-top: 28px; }
  .ad-body { min-height: 90px; max-height: 250px; }
}

@media print {
  .ad-slot { display: none; }
}

/* ===================================================================
   バス走行位置マップ
   =================================================================== */

.bus-toolbar { align-items: center; }
.bus-toolbar .clock {
  font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em; min-width: 4.2em;
}
.time-slider { display: block; margin: 0 0 14px; }
.time-slider input[type='range'] { width: 100%; accent-color: var(--accent); height: 26px; }

.bus-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
@media (max-width: 900px) { .bus-layout { grid-template-columns: 1fr; } }

.bus-panel { padding: 14px 4px 8px; max-height: min(74vh, 780px); display: flex; flex-direction: column; }
.bus-panel .panel-title { margin: 0 0 8px; padding: 0 14px; font-weight: 650; font-size: 0.94rem; }

.bus-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.bus-list li {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 9px 14px; border-top: 1px solid var(--border);
  font-size: 0.86rem; cursor: pointer;
}
.bus-list li:hover { background: var(--surface-2); }
.bus-list li.following { background: var(--accent-soft); }
.bus-list li.more { justify-content: center; color: var(--muted); cursor: default; }
.bus-list li.more:hover { background: none; }
.bus-list .dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; flex: none; }
.bus-list .bus-main { flex: 1 1 45%; min-width: 0; }
.bus-list .bus-route { display: block; font-weight: 600; line-height: 1.35; word-break: break-word; }
.bus-list .bus-pos { flex: 1 1 45%; min-width: 0; color: var(--muted); line-height: 1.45; word-break: break-word; }
.bus-list .sub { color: var(--muted); font-size: 0.86em; font-weight: 400; }

/* ===================================================================
   グラフ
   色は検証済みのカテゴリ配色（明・暗それぞれ）。
   補助線・軸・ラベルは文字色トークンを使い、系列色は帯びさせない。
   =================================================================== */

.viz { position: relative; }

.chart {
  margin: 0 0 20px;
  padding: 16px 18px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.chart-title { font-weight: 650; font-size: 0.98rem; margin: 0 0 10px; line-height: 1.4; }
.chart-body { overflow-x: auto; }
.chart-body svg { width: 100%; min-width: 480px; height: auto; display: block; }
.chart-note { margin: 8px 0 0; font-size: 0.8rem; color: var(--muted); }

.chart-grid { stroke: var(--border); stroke-width: 1; }
.chart-axis { fill: var(--muted); font-size: 11px; }
.chart-label { fill: var(--text); font-size: 12px; }
.chart-value { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
/* 点は地色のリングで囲み、線と重なっても見えるようにする */
.chart-dot { stroke: var(--surface); stroke-width: 2; }
.chart-hit { fill: transparent; }
.chart-crosshair { stroke: var(--muted); stroke-width: 1; opacity: 0; }
.chart-col:hover .chart-crosshair,
.chart-col:focus .chart-crosshair { opacity: 0.45; }
.chart-row:hover path,
.chart-row:focus path { filter: brightness(1.08); }
.chart-row, .chart-col { outline: none; }
.chart-row:focus-visible .chart-hit,
.chart-col:focus-visible .chart-hit { fill: var(--accent-soft); }

.chart-legend { display: flex; flex-wrap: wrap; gap: 14px; margin: 0 0 10px; font-size: 0.84rem; color: var(--muted); }
.chart-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend .swatch { width: 11px; height: 11px; border-radius: 3px; }

.chart-tip {
  position: absolute; z-index: 5; transform: translate(-50%, -100%);
  background: var(--text); color: var(--bg);
  padding: 6px 10px; border-radius: 7px;
  font-size: 0.8rem; line-height: 1.45; white-space: nowrap;
  pointer-events: none; box-shadow: var(--shadow);
}

/* ---------- 見出しの数字 ---------- */

.stat-row {
  display: grid; gap: 12px; margin: 0 0 24px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.stat-tile {
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.stat-tile b {
  display: block; font-size: 1.5rem; line-height: 1.2;
  font-variant-numeric: tabular-nums; letter-spacing: -0.01em;
}
.stat-tile .unit { font-size: 0.8rem; font-weight: 500; color: var(--muted); margin-left: 3px; }
.stat-tile span { display: block; font-size: 0.8rem; color: var(--muted); margin-top: 4px; line-height: 1.4; }

@media (max-width: 640px) {
  .stat-tile b { font-size: 1.25rem; }
  .chart { padding: 14px 12px 10px; }
}

/* 地図と表の連動：地点を持つ行はクリックできる */
table.data tr.has-point { cursor: pointer; }
table.data tr.has-point:hover td { background: color-mix(in srgb, var(--accent) 8%, transparent); }
table.data tr.picked td { background: color-mix(in srgb, var(--accent) 16%, transparent); }

/* 実際の車両位置を表示しているときの印。 */
.live-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: #c0392b; margin-right: 6px; vertical-align: baseline;
  box-shadow: 0 0 0 0 rgba(192, 57, 43, 0.6); animation: live-pulse 2s ease-out infinite;
}
@keyframes live-pulse {
  70% { box-shadow: 0 0 0 7px rgba(192, 57, 43, 0); }
  100% { box-shadow: 0 0 0 0 rgba(192, 57, 43, 0); }
}
@media (prefers-reduced-motion: reduce) { .live-dot { animation: none; } }
.live-note { color: var(--text); }

/* 選んだ便の詳細（停留所と時刻）。 */
.bus-detail { margin-top: 14px; }
.bus-detail .panel-title { margin: 0 0 4px; }
.stop-list { list-style: none; margin: 12px 0 0; padding: 0; max-height: 320px; overflow: auto; }
.stop-list li {
  display: flex; align-items: baseline; gap: 10px;
  padding: 4px 0 4px 14px; position: relative; font-size: 0.9rem;
}
/* 停留所をつなぐ縦線と点 */
.stop-list li::before {
  content: ''; position: absolute; left: 3px; top: 0; bottom: 0; width: 2px; background: var(--border);
}
.stop-list li:first-child::before { top: 50%; }
.stop-list li:last-child::before { bottom: 50%; }
.stop-list li::after {
  content: ''; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 8px; height: 8px; border-radius: 50%; background: var(--border);
}
.stop-list li.passed { color: var(--muted); }
.stop-list li.passed::after { background: var(--muted); }
.stop-list li.here { font-weight: 650; }
.stop-list li.here::after { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.stop-list .t { font-variant-numeric: tabular-nums; color: var(--muted); }
.stop-list li.here .t { color: inherit; }
.stop-list .n { flex: 1; }
/* 通過駅。時刻は前後の駅から按分した目安なので、停まる駅と同じ顔にしない。 */
.stop-list li.pass { color: var(--muted); }
.stop-list li.pass::after { background: var(--surface); box-shadow: inset 0 0 0 2px var(--border); }

/* 走行位置マップの凡例と、OpenStreetMap 側のマーカー。
   同じ形が出ていないと凡例の意味が無いので、見た目の指定は 1 か所にまとめ、
   凡例（.map-legend-line .mk）と地図（.map-mk > i）の両方から使う。
   色は路線ごとに変わるので --c で受け取る。 */
.map-legend-line { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.map-legend-line .mk { display: inline-block; width: 13px; height: 13px; margin-right: 5px; vertical-align: -2px; }
.map-mk > i { display: block; width: 100%; height: 100%; box-sizing: border-box; }
/* 白抜きの塗りは、地図の地色（Google も OpenStreetMap も淡い色）に溶けてしまう。
   地図はページの明暗によらず常に淡いので、ここは --surface ではなく白で固定し、
   いちばん外側に細い暗色の輪を足して、どんな地色でも輪郭が出るようにする。
   凡例も同じ指定を使うので、凡例と地図の見た目は一致したままになる。 */
.mk-run, .map-mk.mk-run > i {
  border-radius: 50%; background: var(--c, var(--accent));
  box-shadow: 0 0 0 2px #fff, 0 0 0 3px rgba(20, 26, 33, 0.45);
}
.mk-stop, .map-mk.mk-stop > i {
  background: #fff; border: 3px solid var(--c, var(--accent));
  box-shadow: 0 0 0 1px rgba(20, 26, 33, 0.45);
}
/* 駅・停留所。動いている車両（塗りつぶした丸）と混ざらないよう、白抜きの丸にする。 */
.mk-halt, .map-mk.mk-halt > i {
  border-radius: 50%; background: #fff; border: 3px solid var(--c, var(--accent));
  box-shadow: 0 0 0 1px rgba(20, 26, 33, 0.45);
}
/* 見どころ・施設。交通の点とは形から違えたいので、ひし形にする。 */
/* 塗りがある形は、それだけで淡い地図から浮くので白い縁だけでよい。
   暗い輪を足すと二重線に見えて、かえって読みにくくなる。 */
.mk-place, .map-mk.mk-place > i {
  background: var(--c, var(--accent)); transform: rotate(45deg);
  box-shadow: 0 0 0 1.5px #fff;
}
.mk-here, .map-mk.mk-here > i {
  border-radius: 50%; background: #1a73e8;
  box-shadow: 0 0 0 3px #fff, 0 0 0 4px rgba(26, 115, 232, 0.5);
}
/* 地図に出すまとまりの選択。凡例そのものを操作できるようにしている。 */
.layer-picker {
  border: 1px solid var(--border); border-radius: 6px; padding: 10px 14px 12px;
  margin: 0 0 12px; display: flex; flex-wrap: wrap; gap: 6px 20px;
}
.layer-picker legend { font-size: 0.82rem; color: var(--muted); padding: 0 4px; }
.layer-picker label { display: flex; align-items: center; gap: 4px; cursor: pointer; font-size: 0.92rem; }
.layer-picker input { margin-right: 2px; }
.layer-picker .mk {
  display: inline-block; width: 13px; height: 13px; flex: none; vertical-align: -2px;
}
.layer-picker .mk-halt { --c: #1a4a70; }
.layer-picker .mk-place { --c: #c2691a; }
.layer-picker .mk-run { --c: #1667c9; }

/* Leaflet が divIcon に付ける既定の枠と背景を消す */
.leaflet-marker-icon.map-mk { background: none; border: 0; }
/* 事業者が公開している車両のアイコン（鯖江市つつじバス）。地図に埋もれないよう影を付ける。 */
.map-mk.mk-vehicle img { display: block; filter: drop-shadow(0 1px 2px rgba(0,0,0,.45)); }
.map-legend-line .mk-vehicle { width: 22px; height: 22px; }

/* よく見られているデータセット。 */
.popular { list-style: none; counter-reset: rank; margin: 0; padding: 0; display: grid; gap: 8px; }
.popular li {
  counter-increment: rank;
  display: flex; align-items: center; gap: 14px;
  padding: 12px 16px 12px 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.popular li::before {
  content: counter(rank);
  flex: none; width: 26px; text-align: center;
  font-weight: 700; font-variant-numeric: tabular-nums; color: var(--muted);
}
.popular li:nth-child(-n+3)::before { color: var(--accent); }
.popular a { flex: 1; display: flex; flex-direction: column; gap: 4px; color: var(--text); min-width: 0; }
.popular a:hover { text-decoration: none; }
.popular a:hover .title { color: var(--accent); text-decoration: underline; }
.popular .title { font-weight: 620; line-height: 1.4; }
.popular .meta { display: flex; gap: 6px; flex-wrap: wrap; }
.popular .views { flex: none; color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 650; }
.popular .views .u { font-weight: 400; font-size: 0.8rem; margin-left: 2px; }

/* 時刻表。左に時、右にその時台の分を並べる（紙の時刻表と同じ並べ方）。 */
.times { display: grid; gap: 18px; margin-top: 12px; }
@media (min-width: 720px) { .times { grid-template-columns: 1fr 1fr; } }

.tt-head { font-size: 0.86rem; font-weight: 650; color: var(--muted); margin: 0 0 6px; }
/* 便が分からない車両に出す、路線の時刻表への断り書き */
.tt-note { color: var(--muted); margin: 14px 0 0; }
.tt-stops { margin-top: 14px; font-size: 0.9rem; }
.tt-stops summary { cursor: pointer; color: var(--muted); font-weight: 650; }
.tt-stops summary:hover { color: var(--accent-dark); }
/* 時刻の無い停留所一覧。線と点は残し、時刻の欄だけ空ける */
.stop-list.plain { max-height: 260px; }

/* 路線ごとの時刻表。縦に停留所、横に便。便が 30 を超える路線があるので
   横に流し、停留所の列だけ貼り付けてどの行かを見失わないようにする。 */
.tt-dir { margin-top: 30px; }
/* 便が少ない路線では表が狭い。枠を画面幅いっぱいに広げると、
   中身の右に空箱が残るので、表の幅に合わせる */
.tt-scroll {
  overflow-x: auto; margin-top: 10px; border: 1px solid var(--border);
  border-radius: 8px; width: fit-content; max-width: 100%;
}
.tt-grid { border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 0.86rem; }
.tt-grid th, .tt-grid td { border: 1px solid var(--border); padding: 4px 8px; white-space: nowrap; }
.tt-grid thead th { background: var(--surface); font-weight: 650; color: var(--muted); text-align: center; }
/* 停留所の列は横に流しても貼り付いたままにする。「何時何分」だけ見えていても
   どの停留所の時刻か分からないので、ここが動かないことがいちばん大事。
   便の番号の行（1・2・3…）は縦に貼り付けない。この枠は overflow-x を持つので
   縦のスクロール元は枠自身になり、枠に縦の余地が無いぶん top:0 が効かない。
   番号は並び順しか表していないので、追いかけられなくても読める。 */
.tt-grid tbody th,
.tt-grid thead th:first-child {
  position: sticky; left: 0; z-index: 1; background: var(--surface);
  text-align: left; font-weight: 500; max-width: 14em;
}
.tt-grid thead th:first-child { z-index: 2; text-align: center; font-weight: 650; }
.tt-grid td { text-align: right; }
/* 停留所が 30 を超える路線があるので、1 行おきに色を敷いて横に目で追えるように
   する。地色を変えるだけなので、貼り付けた 1 列目も同じ色にしないと
   横に流したときに継ぎ目が出る */
.tt-grid tbody tr:nth-child(even) th,
.tt-grid tbody tr:nth-child(even) td { background: var(--surface-2); }
.tt-grid .tt-place { white-space: nowrap; }

/* 路線・事業者の一覧 */
.tt-routes { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 8px; }
@media (min-width: 720px) { .tt-routes { grid-template-columns: 1fr 1fr; } }
.tt-routes a {
  display: block; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--surface); color: inherit;
}
.tt-routes a:hover { border-color: var(--accent); text-decoration: none; }
.tt-route-name {
  display: block; font-weight: 620; border-left: 4px solid var(--border);
  padding-left: 8px; line-height: 1.4;
}
.tt-routes a:hover .tt-route-name { color: var(--accent-dark); }
.tt-route-meta { display: block; margin-top: 3px; padding-left: 12px; font-size: 0.84rem; color: var(--muted); }
/* 停留所・駅の名前を押すと、その場所を地図で開ける */
.tt-place { color: var(--text); }
.tt-place .tt-pin {
  margin-left: 6px; padding: 0 5px; border-radius: 3px; font-weight: 500;
  font-size: 0.72rem; color: var(--accent-dark); background: var(--accent-soft);
}
.tt-place:hover { text-decoration: none; }
.tt-place:hover .tt-pin { background: var(--accent); color: #fff; }
.panel-title .tt-place { color: inherit; }
.tt { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.tt th, .tt td { border-top: 1px solid var(--border); padding: 5px 0; vertical-align: baseline; }
.tt th {
  width: 2.6em; text-align: right; padding-right: 12px; font-weight: 650;
  font-family: var(--serif); font-size: 1.05rem; color: var(--accent-dark);
}
/* 分は行内に並べて折り返す。td を flex にすると表の行の高さがずれ、
   時と分で罫線の位置が合わなくなる。 */
.tt .mi { display: inline-block; padding: 1px 5px; margin-right: 2px; border-radius: 3px; }
/* つぎに来るもの。時刻表のどこを見ればよいかが一目で分かるように */
.tt .mi.next { background: var(--accent); color: #fff; font-weight: 650; }

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

/* 避難所の開設状況。災害時に見られるので、いちばん知りたい 1 行を大きく出す。 */
.notice-warn { border-left-color: var(--warn); color: var(--text); }
.shelter-head {
  margin: 18px 0 6px; padding: 18px 20px;
  border: 1px solid var(--border); border-left: 5px solid var(--border);
  border-radius: 6px; background: var(--surface);
}
.shelter-head .s-big { margin: 0 0 6px; font-size: 1.35rem; font-weight: 700; line-height: 1.4; }
.shelter-head .lead { margin: 6px 0 0; }
/* 開設あり＝目立たせる。開設なし＝落ち着いた色。取得できない＝警告 */
.shelter-head.open { border-left-color: var(--warn); }
.shelter-head.open .s-big { color: var(--warn); }
.shelter-head.none { border-left-color: var(--sea); }
/* 避難所は 0 件だが避難情報は出ている。いちばん誤読されやすい状態なので、
   「ありません」を落ち着いた色で出さず、注意を促す色にする */
.shelter-head.warn { border-left-color: var(--warn); }
.shelter-head.warn .lead strong { color: var(--warn); }
.shelter-head.err { border-left-color: var(--warn); background: var(--surface-2); }
.shelter-head.err .s-big { color: var(--warn); }

.shelter-list { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 10px; }
@media (min-width: 720px) { .shelter-list { grid-template-columns: 1fr 1fr; } }
.shelter-list .shelter {
  padding: 12px 14px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface);
}
.shelter-list .shelter.full { border-color: var(--warn); }
.shelter-list .s-name { margin: 0; font-weight: 650; line-height: 1.4; }
.shelter-list .s-full {
  margin-left: 8px; padding: 1px 7px; border-radius: 3px;
  font-size: 0.76rem; font-weight: 650; color: #fff; background: var(--warn);
}
.shelter-list .s-meta { margin: 3px 0 0; font-size: 0.86rem; color: var(--muted); }
.shelter-list .s-meta.sub { font-size: 0.8rem; }

.shelter-cities td.n { text-align: right; font-variant-numeric: tabular-nums; }
.shelter-cities td.sub { color: var(--muted); }
.shelter-cities tr.has-open th, .shelter-cities tr.has-open td { background: var(--accent-soft); }

/* 避難所を市町ごとに畳む。35 箇所が一列に並ぶと自分の市町を探せない。 */
.shelter-tools { margin-top: 12px; }

/* 出ている避難情報。避難所より前に、避難所より強く出す */
.evac {
  margin-top: 22px; border: 2px solid var(--warn); border-radius: 8px;
  background: var(--surface); padding: 16px 16px 12px;
}
.evac > h2 { margin: 0 0 8px; font-size: 1.05rem; }
.evac-big { margin: 0; font-size: 1.15rem; font-weight: 700; color: var(--warn); line-height: 1.5; }
.evac-sum { margin: 4px 0 0; color: var(--muted); font-size: 0.9rem; }
.evac-city { margin-top: 14px; }
.evac-city-name { margin: 0 0 6px; font-weight: 650; }
.evac-city-n { font-weight: 400; color: var(--muted); font-size: 0.86rem; }
.evac-areas { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.evac-area {
  border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px;
  background: var(--surface-2);
}
.evac-level {
  display: inline-block; background: var(--warn); color: #fff; border-radius: 4px;
  padding: 1px 7px; font-size: 0.78rem; font-weight: 650; margin-right: 7px;
}
.evac-name { font-weight: 650; }
.evac-meta { display: block; margin-top: 3px; color: var(--muted); font-size: 0.84rem; }
@media (min-width: 720px) { .evac-areas { grid-template-columns: 1fr 1fr; } }

/* 市町の一覧のあとに続く断り書き。.lead は見出しの直下に置く前提で
   margin-top が負なので、ここで使うと直前のカードに文字が食い込む */
.shelter-note {
  margin: 14px 0 0; color: var(--muted); font-size: 0.85rem;
}
.shelter-cities-section { margin-top: 28px; }

.city {
  margin-top: 10px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); overflow: hidden;
}
.city > summary {
  cursor: pointer; padding: 12px 14px; list-style: none;
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
}
.city > summary::-webkit-details-marker { display: none; }
/* 開いているかを三角で示す（既定の印を消しているので自前で置く） */
.city > summary::before {
  content: '▸'; color: var(--muted); font-size: 0.9em; transition: transform 0.12s ease;
}
.city[open] > summary::before { transform: rotate(90deg); }
.city > summary:hover { background: var(--surface-2); }
.city .c-name { font-weight: 650; }
.city .c-meta { color: var(--muted); font-size: 0.86rem; }
.city .shelter-list { margin: 0; padding: 0 12px 12px; }
