:root {
  --bg: #f6f7f5;
  --surface: #ffffff;
  --surface-2: #eef2f0;
  --text: #1d2725;
  --muted: #5d6b68;
  --line: #dde3e0;
  --accent: #2f6f6a;
  --accent-soft: #d9ebe8;
  --star: #d99a00;
  --pros: #2c7a4b;
  --cons: #b0533c;
  --public: #2f63a8;
  --private: #8a4fa0;
  --c1: #1f7a4d; --c2: #5aa36a; --c3: #d6a536; --c4: #d0703e; --c5: #a8a8a8;
  --d1: #173f7a; --d2: #2f63a8; --d3: #5b8fd0; --d4: #94b8e3; --d5: #c9d9ee;
  --radius: 12px;
  --shadow: 0 1px 2px rgb(0 0 0 / .06), 0 2px 8px rgb(0 0 0 / .04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121716; --surface: #1a2120; --surface-2: #232c2a; --text: #e5ecea; --muted: #9aaaa6;
    --line: #2f3a38; --accent: #6cc0b6; --accent-soft: #1f3a37; --star: #f2c24b;
    --pros: #6fcf95; --cons: #ef9a82; --public: #82aee8; --private: #c99ad9;
    --d1: #c9d9ee; --d2: #94b8e3; --d3: #5b8fd0; --d4: #2f63a8; --d5: #1d3a63;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121716; --surface: #1a2120; --surface-2: #232c2a; --text: #e5ecea; --muted: #9aaaa6;
  --line: #2f3a38; --accent: #6cc0b6; --accent-soft: #1f3a37; --star: #f2c24b;
  --pros: #6fcf95; --cons: #ef9a82; --public: #82aee8; --private: #c99ad9;
  --d1: #c9d9ee; --d2: #94b8e3; --d3: #5b8fd0; --d4: #2f63a8; --d5: #1d3a63;
  --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.65 system-ui, -apple-system, "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }

.top {
  position: sticky; top: 0; z-index: 1000;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 17px; color: var(--text); text-decoration: none; }
.tabs { display: flex; gap: 4px; margin-left: auto; }
.tabs a {
  padding: 6px 14px; border-radius: 999px; text-decoration: none; color: var(--muted); font-weight: 600;
}
.tabs a.on { background: var(--accent-soft); color: var(--accent); }

.filters {
  display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center;
  padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.filters[hidden] { display: none; }
.filters { display: block; }
.fbody { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.fhead { display: none; }
.ftoggle { border: 1px solid var(--line); background: var(--bg); border-radius: 8px; padding: 5px 12px; font-weight: 600; cursor: pointer; }
.filters label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.filters select, .filters input[type="search"] {
  padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg);
}
.filters input[type="search"] { width: 150px; }
.filters .count { margin-left: auto; font-size: 13px; color: var(--muted); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--bg); padding: 5px 10px; font-size: 13px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--accent); color: #fff; }

main { max-width: 1100px; margin: 0 auto; padding: 16px; }
.foot { max-width: 1100px; margin: 0 auto; padding: 8px 16px 32px; font-size: 12px; color: var(--muted); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); gap: 12px; }
.card {
  position: relative; display: block; padding: 14px 44px 14px 14px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
  color: inherit; text-decoration: none;
}
.card:hover { border-color: var(--accent); }
.card h3 { margin: 0 0 4px; font-size: 16px; }
.card .sub { font-size: 12px; color: var(--muted); }
.card .summary { margin: 8px 0 0; font-size: 13px; color: var(--muted);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.stats { display: flex; gap: 14px; margin-top: 8px; font-size: 13px; }
.stats b { font-size: 17px; font-variant-numeric: tabular-nums; }
.badges { display: inline-flex; gap: 4px; flex-wrap: wrap; vertical-align: middle; }
.badge { font-size: 11px; padding: 1px 7px; border-radius: 999px; border: 1px solid currentColor; white-space: nowrap; }
.badge.public { color: var(--public); }
.badge.private { color: var(--private); }
.badge.plain { color: var(--muted); }

.star {
  position: absolute; top: 8px; right: 8px; width: 34px; height: 34px;
  border: 0; background: none; cursor: pointer; font-size: 22px; line-height: 1; color: var(--line);
}
.star.on { color: var(--star); }
.star:focus-visible { outline: 2px solid var(--accent); border-radius: 8px; }

/* 地図 */
.map-wrap { position: relative; }
#map { height: calc(100vh - 190px); min-height: 380px; border-radius: var(--radius); border: 1px solid var(--line); }
.legend {
  position: absolute; z-index: 500; bottom: 12px; left: 12px; padding: 8px 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; font-size: 12px; box-shadow: var(--shadow);
}
.legend .row { display: flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 50%; display: inline-block; border: 1px solid rgb(0 0 0 / .25); }
.leaflet-popup-content { font: 13px/1.6 system-ui, sans-serif; }
.leaflet-popup-content b { font-size: 14px; }
.station-icon {
  background: #c8102e; color: #fff; font-weight: 700; font-size: 12px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center; border: 2px solid #fff; box-shadow: 0 1px 4px rgb(0 0 0 / .4);
}

/* 詳細 */
.back { display: inline-block; margin-bottom: 8px; font-size: 14px; }
.detail-head { position: relative; padding-right: 44px; }
.detail-head h1 { margin: 0; font-size: 22px; }
.detail-head .kana { color: var(--muted); font-size: 13px; }
.keyfacts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin: 14px 0; }
.fact { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.fact .k { font-size: 12px; color: var(--muted); }
.fact .v { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.fact .n { font-size: 12px; color: var(--muted); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin: 12px 0; }
.panel h2 { margin: 0 0 8px; font-size: 16px; }
dl.feat { display: grid; grid-template-columns: 7em 1fr; gap: 6px 12px; margin: 0; }
dl.feat dt { color: var(--muted); font-size: 13px; }
dl.feat dd { margin: 0; }
.pc { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pc ul { margin: 0; padding-left: 1.2em; }
.pc h3 { margin: 0 0 4px; font-size: 14px; }
.pc .pros h3 { color: var(--pros); }
.pc .cons h3 { color: var(--cons); }
.small { font-size: 12px; color: var(--muted); }
.sources { margin: 0; padding-left: 1.2em; font-size: 13px; word-break: break-all; }

.notes form { display: flex; gap: 8px; margin-bottom: 10px; }
.notes textarea { flex: 1; min-height: 44px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); resize: vertical; }
.btn { padding: 8px 14px; border-radius: 8px; border: 1px solid var(--accent); background: var(--accent); color: #fff; cursor: pointer; font-weight: 600; }
.btn.ghost { background: none; color: var(--accent); }
.btn:disabled { opacity: .5; cursor: default; }
.note { border-top: 1px solid var(--line); padding: 8px 0; }
.note .meta { font-size: 12px; color: var(--muted); display: flex; gap: 8px; }
.note .meta button { border: 0; background: none; color: var(--cons); cursor: pointer; font-size: 12px; padding: 0; }
.note p { margin: 2px 0 0; white-space: pre-wrap; }

/* 比較 */
.compare-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table.compare { border-collapse: collapse; min-width: 100%; font-size: 13px; }
.compare th, .compare td { border-bottom: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; min-width: 160px; }
.compare th[scope="row"] { position: sticky; left: 0; background: var(--surface-2); min-width: 90px; color: var(--muted); font-weight: 600; }
.compare thead th { background: var(--surface-2); }
.empty { padding: 40px 16px; text-align: center; color: var(--muted); }

@media (max-width: 640px) {
  .top { padding: 8px 16px; }
  .tabs { margin-left: 0; width: 100%; }
  .tabs a { flex: 1; text-align: center; }
  .filters input[type="search"] { width: 100%; }
  .fhead { display: flex; align-items: center; gap: 10px; }
  .fhead .count { margin-left: auto; }
  .fbody { display: none; margin-top: 10px; }
  .filters.open .fbody { display: flex; }
  .fbody .count { display: none; }
  .tabs a { padding: 6px 8px; }
  .pc { grid-template-columns: 1fr; }
  dl.feat { grid-template-columns: 1fr; gap: 0 0; }
  dl.feat dd { margin-bottom: 8px; }
  #map { height: calc(100vh - 260px); }
}
