:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e3e8ef;
  --text: #16202e;
  --muted: #64748b;
  --accent: #0f6fd6;
  --accent-soft: #e7f1fd;
  --gold: #b4801f;
  --green: #14855c;
  --red: #c0392f;
  --shadow: 0 1px 2px rgba(16, 32, 54, .05), 0 8px 24px rgba(16, 32, 54, .06);
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e141b;
    --surface: #161e27;
    --surface-2: #1c2530;
    --border: #2a3542;
    --text: #e8edf3;
    --muted: #93a1b3;
    --accent: #58a6ff;
    --accent-soft: #17324f;
    --gold: #e0ac4e;
    --green: #3ec89a;
    --red: #ef7b6f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", Meiryo, sans-serif;
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px; }

h1, h2, h3 { line-height: 1.35; margin: 0; }

/* ---------- header ---------- */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 500;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 14px;
  padding-bottom: 14px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { font-size: 30px; line-height: 1; }
.brand h1 { font-size: 19px; letter-spacing: .01em; }
.brand-sub { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }
.data-badge {
  flex: none;
  font-size: 12px;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 12px;
  white-space: nowrap;
}

/* ---------- panels ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  margin: 18px 0;
}
.panel h2 { font-size: 16px; }
.section-note { margin: 6px 0 14px; font-size: 12.5px; color: var(--muted); }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.located { margin: 0; font-size: 13px; color: var(--muted); }

/* ---------- search ---------- */
.search-panel { margin-top: 24px; }
.field-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.search-row { display: flex; gap: 10px; }
.search-row input {
  flex: 1;
  min-width: 0;
  font-size: 16px;
  padding: 13px 15px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
}
.search-row input:focus { outline: 2px solid var(--accent); outline-offset: -1px; background: var(--surface); }

.btn {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 10px;
  padding: 13px 20px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn[disabled] { opacity: .55; cursor: progress; }

.hint { margin: 9px 2px 0; font-size: 12.5px; color: var(--muted); }
.examples { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; margin-top: 12px; font-size: 12.5px; color: var(--muted); }
.chip {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 12.5px;
  cursor: pointer;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }

.status { margin-top: 12px; font-size: 13.5px; padding: 10px 14px; border-radius: 10px; }
.status.loading { background: var(--surface-2); color: var(--muted); }
.status.error { background: color-mix(in srgb, var(--red) 12%, transparent); color: var(--red); }

.candidates { margin-top: 12px; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.candidates button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 11px 15px;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
}
.candidates button:last-child { border-bottom: 0; }
.candidates button:hover { background: var(--accent-soft); }

/* ---------- conditions ---------- */
.cond-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; margin-top: 16px; align-items: start; }
.cond-block { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 16px; }
.cond-block h3 { font-size: 13px; letter-spacing: .06em; color: var(--muted); text-transform: none; }
.block-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.inline-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.inline-fields.hidden { display: none; }

.field { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; }
.field > span:first-child { color: var(--muted); font-weight: 600; }
.field small { color: var(--muted); font-size: 11.5px; }
.field input[type="number"], .field select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
}
.input-unit { position: relative; display: block; }
.input-unit i { position: absolute; right: 11px; top: 50%; transform: translateY(-50%); font-style: normal; font-size: 12px; color: var(--muted); pointer-events: none; }
.input-unit input { padding-right: 44px !important; }

.switch { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted); cursor: pointer; }
.switch input { width: 16px; height: 16px; accent-color: var(--accent); }
.switch.disabled { opacity: .45; cursor: not-allowed; }

.adjust { margin-top: 14px; border-top: 1px dashed var(--border); padding-top: 12px; }
.adjust summary { font-size: 12.5px; color: var(--muted); cursor: pointer; }
.adjust .tag { color: var(--accent); font-weight: 700; }
.adjust-body { margin-top: 12px; }
.checks { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; }
.checks label { display: flex; align-items: center; gap: 7px; font-size: 12.5px; cursor: pointer; }
.checks input { accent-color: var(--accent); }
.checks em { font-style: normal; color: var(--muted); font-size: 11.5px; }
.slider-field { margin-top: 12px; }
.slider-field input[type="range"] { width: 100%; accent-color: var(--accent); }

/* ---------- hero ---------- */
.hero {
  background: linear-gradient(135deg, #12324f, #0d1b2a);
  color: #fff;
  border-radius: var(--radius);
  padding: 26px 24px;
  margin: 18px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  box-shadow: var(--shadow);
}
.hero-label { margin: 0; font-size: 12.5px; opacity: .8; letter-spacing: .05em; }
.hero-value { margin: 4px 0 0; font-size: 42px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.hero-range { margin: 6px 0 0; font-size: 12.5px; opacity: .75; }
.hero-split { display: flex; gap: 26px; flex-wrap: wrap; }
.split-item { display: flex; flex-direction: column; gap: 2px; }
.split-item span { font-size: 11.5px; opacity: .75; }
.split-item b { font-size: 19px; font-weight: 600; }

/* ---------- tables ---------- */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.two-col > .panel { margin: 0; }

.value-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.value-table th, .value-table td { padding: 10px 4px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: baseline; }
.value-table th { font-weight: 600; width: 46%; }
.value-table th small { display: block; font-weight: 400; font-size: 11.5px; color: var(--muted); }
.value-table td { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.value-table tr.total th, .value-table tr.total td { border-top: 2px solid var(--border); border-bottom: 0; font-size: 15px; padding-top: 12px; }
.value-table tr.total td { color: var(--accent); }
.value-table td .sub { display: block; font-size: 11.5px; font-weight: 400; color: var(--muted); }
.value-table tr.muted td, .value-table tr.muted th { color: var(--muted); font-weight: 500; }

.confidence { margin-top: 14px; font-size: 12.5px; border-radius: 10px; padding: 11px 13px; background: var(--surface-2); border: 1px solid var(--border); }
.confidence b { display: inline-flex; align-items: center; gap: 6px; }
.badge { display: inline-block; border-radius: 999px; padding: 1px 9px; font-size: 11.5px; font-weight: 700; }
.badge.high { background: color-mix(in srgb, var(--green) 18%, transparent); color: var(--green); }
.badge.mid { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.badge.low, .badge.vlow { background: color-mix(in srgb, var(--gold) 20%, transparent); color: var(--gold); }
.confidence p { margin: 5px 0 0; color: var(--muted); }

.tax-options { margin-top: 14px; display: flex; flex-direction: column; gap: 7px; }
.inherit-box { margin-top: 12px; font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 11px 13px; }
.inherit-box .row { display: flex; justify-content: space-between; gap: 12px; }
.inherit-box .row + .row { margin-top: 4px; }
.inherit-box b { font-variant-numeric: tabular-nums; }
.inherit-box .note { color: var(--muted); margin-top: 6px; }

/* ---------- map ---------- */
#map { height: 380px; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); z-index: 1; }
.map-legend { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 10px; font-size: 12px; color: var(--muted); }
.map-legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
.dot.target { background: var(--red); }
.dot.koji { background: #2f80ed; }
.dot.chosa { background: #16a085; }
.pin-target { background: var(--red); width: 16px; height: 16px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.25); }
.leaflet-popup-content { font-size: 12.5px; line-height: 1.6; margin: 12px 14px; }
.leaflet-popup-content b { font-size: 14px; }
.leaflet-container { font-family: inherit; }

/* ---------- points table ---------- */
.table-scroll { overflow-x: auto; }
.points-table { width: 100%; border-collapse: collapse; font-size: 12.5px; min-width: 700px; }
.points-table th, .points-table td { padding: 9px 10px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
.points-table thead th { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.points-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.points-table tbody tr { cursor: pointer; }
.points-table tbody tr:hover { background: var(--accent-soft); }
.points-table tbody tr.active { background: var(--accent-soft); }
.points-table .addr { white-space: normal; min-width: 210px; }
.points-table .up { color: var(--green); }
.points-table .down { color: var(--red); }
.kind-tag { display: inline-block; font-size: 10.5px; padding: 1px 7px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); }

/* ---------- chart ---------- */
#chart svg { width: 100%; height: auto; display: block; }
.chart-stats { display: flex; gap: 22px; flex-wrap: wrap; margin-top: 12px; font-size: 12.5px; color: var(--muted); }
.chart-stats b { color: var(--text); font-size: 15px; display: block; font-variant-numeric: tabular-nums; }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--border); margin-top: 34px; padding: 22px 0 40px; background: var(--surface); }
.disclaimer { font-size: 12px; color: var(--muted); margin: 0 0 10px; line-height: 1.8; }
.disclaimer b { color: var(--text); display: inline-block; margin-right: 6px; }
.sources { font-size: 11.5px; color: var(--muted); margin: 0; }
.sources a { color: var(--muted); }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .cond-grid, .two-col { grid-template-columns: 1fr; }
  .hero-value { font-size: 34px; }
  .hero { padding: 22px 18px; }
}
@media (max-width: 620px) {
  .wrap { padding: 0 14px; }
  .header-inner { flex-direction: column; align-items: flex-start; gap: 8px; }
  .brand h1 { font-size: 17px; }
  .search-row { flex-direction: column; }
  .inline-fields, .checks { grid-template-columns: 1fr; }
  .panel { padding: 17px; }
  .hero-split { gap: 18px; }
  .hero-value { font-size: 30px; }
  #map { height: 300px; }
}
