:root {
  --bg: #f7f7f5;
  --panel: #ffffff;
  --ink: #1d2125;
  --muted: #5d656d;
  --line: #dfe2e5;
  --accent: #1f5f99;
  --chip: #eef1f4;
  --grade-a: #1e7b45;
  --grade-b: #5f8f2b;
  --grade-c: #b7791f;
  --grade-d: #c4561c;
  --grade-f: #b42318;
  --grade-none: #8a9198;
  --warn-bg: #fff6e5;
  --warn-ink: #7a4b00;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 2px 8px rgba(0, 0, 0, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121416;
    --panel: #1b1e21;
    --ink: #e7e9eb;
    --muted: #9aa3ab;
    --line: #2d3236;
    --accent: #6aa8e0;
    --chip: #262b2f;
    --grade-a: #3fb36b;
    --grade-b: #8dbb4c;
    --grade-c: #d9a23b;
    --grade-d: #e07a3f;
    --grade-f: #e5534b;
    --grade-none: #6f777e;
    --warn-bg: #33270f;
    --warn-ink: #f0c674;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.25; margin: 0; }

/* ---------------------------------------------------------------- header */
.top {
  display: flex; align-items: center; gap: 16px;
  height: 52px; padding: 0 16px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.top h1 { font-size: 17px; font-weight: 650; letter-spacing: -.01em; }
.top h1 a { color: inherit; text-decoration: none; }
.top .tagline { font-size: 12px; color: var(--muted); white-space: nowrap; }
.top nav { margin-left: auto; display: flex; gap: 14px; font-size: 14px; }
.top nav a { text-decoration: none; color: var(--muted); }
.top nav a[aria-current="page"] { color: var(--ink); font-weight: 600; }

/* ---------------------------------------------------------------- layout */
.app { display: grid; grid-template-columns: 420px 1fr; height: calc(100% - 52px); }
.side { display: flex; flex-direction: column; min-height: 0; background: var(--panel); border-right: 1px solid var(--line); }
#map { height: 100%; background: var(--bg); }
@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 42vh auto; height: auto; }
  #map { grid-row: 1; height: 42vh; }
  .side { grid-row: 2; border-right: 0; }
  .top { gap: 10px; }
  .top h1 { font-size: 15px; white-space: nowrap; }
  .top .tagline { display: none; }
  .top nav { gap: 10px; font-size: 13px; }
}

/* ---------------------------------------------------------------- filters + list */
.filters { padding: 12px 16px; border-bottom: 1px solid var(--line); display: grid; gap: 10px; }
.filters input[type=search], .filters select {
  width: 100%; padding: 9px 11px; font: inherit; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.search-row { display: flex; gap: 8px; }
.search-row input { flex: 1; min-width: 0; }
.near-btn { white-space: nowrap; flex: none; }
.active-chip { background: var(--accent); border-color: var(--accent); color: #fff; }
.map-area-btn {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 1000;
  background: var(--panel); box-shadow: 0 1px 4px rgba(0, 0, 0, .25); font-weight: 600;
}
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--chip); color: var(--ink); font: inherit; font-size: 13px; cursor: pointer;
}
.chip[aria-pressed="true"] { border-color: var(--ink); font-weight: 600; }
.count { font-size: 13px; color: var(--muted); }
.list { overflow-y: auto; flex: 1; min-height: 0; }
.row {
  display: grid; grid-template-columns: 40px 1fr; gap: 12px; align-items: center;
  width: 100%; padding: 10px 16px; text-align: left; font: inherit; color: inherit;
  background: none; border: 0; border-bottom: 1px solid var(--line); cursor: pointer;
}
.row:hover, .row:focus-visible { background: var(--chip); outline: none; }
.row .name { font-weight: 600; }
.row .sub { font-size: 13px; color: var(--muted); }
.more { margin: 12px 16px; }

/* ---------------------------------------------------------------- grade badge */
.grade {
  display: inline-grid; place-items: center; flex: none;
  width: 36px; height: 36px; border-radius: 8px;
  color: #fff; font-weight: 750; font-size: 18px;
  background: var(--grade-none);
}
.grade.big { width: 64px; height: 64px; font-size: 34px; border-radius: 12px; }
.grade.sm { width: 22px; height: 22px; font-size: 12px; border-radius: 5px; }
.g-A { background: var(--grade-a); }
.g-B { background: var(--grade-b); }
.g-C { background: var(--grade-c); }
.g-D { background: var(--grade-d); }
.g-F { background: var(--grade-f); }

/* ---------------------------------------------------------------- detail */
.detail { overflow-y: auto; flex: 1; min-height: 0; padding: 14px 16px 40px; }
.back { margin-bottom: 12px; }
.btn {
  padding: 6px 12px; font: inherit; font-size: 14px; color: var(--ink);
  background: var(--chip); border: 1px solid var(--line); border-radius: 8px; cursor: pointer;
}
.headline { display: flex; gap: 14px; align-items: center; margin: 4px 0 6px; }
.headline h2 { font-size: 21px; }
.addr { color: var(--muted); font-size: 14px; }
.meaning { margin: 10px 0 2px; }
.facts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 14px 0; }
.fact { background: var(--bg); border-radius: 8px; padding: 8px 10px; }
.fact b { display: block; font-size: 18px; }
.fact span { font-size: 12px; color: var(--muted); }
.section-title { font-size: 15px; font-weight: 650; margin: 22px 0 8px; }
.note { font-size: 13px; color: var(--muted); }
.warn { background: var(--warn-bg); color: var(--warn-ink); padding: 8px 10px; border-radius: 8px; font-size: 13px; }
.card { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 10px; }
.card-head { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; }
.card-head .date { font-weight: 650; }
.card-head .score { margin-left: auto; font-weight: 650; }
.item { border-top: 1px solid var(--line); padding: 8px 0 2px; margin-top: 8px; }
.item-name { font-weight: 550; }
.tags { display: inline-flex; flex-wrap: wrap; gap: 4px; margin-left: 4px; vertical-align: middle; }
.tag { font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--chip); border: 1px solid var(--line); white-space: nowrap; }
.tag.priority { border-color: var(--grade-f); color: var(--grade-f); }
.tag.repeat { background: var(--grade-f); border-color: var(--grade-f); color: #fff; }
details { margin-top: 4px; font-size: 14px; }
summary { cursor: pointer; color: var(--accent); }
details p { margin: 6px 0; }
.empty { padding: 24px 16px; color: var(--muted); }

/* ---------------------------------------------------------------- method page */
.page { max-width: 820px; margin: 0 auto; padding: 24px 16px 64px; }
.page h2 { font-size: 22px; margin: 30px 0 10px; }
.page h3 { font-size: 16px; margin: 20px 0 6px; }
.page p, .page li { max-width: 72ch; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 600; color: var(--muted); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

.page-title { font-size: 26px; margin-top: 8px !important; }
.side-foot { padding: 8px 16px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); }
.foot {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px;
  max-width: 820px; margin: 0 auto; padding: 20px 16px 32px;
  border-top: 1px solid var(--line); font-size: 13px; color: var(--muted);
}
.foot b { color: var(--ink); }
.leaflet-container { font: inherit; }
@media (prefers-color-scheme: dark) {
  .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.85) contrast(.9); }
}
