:root {
  --header-h: 48px;
  --panel-w: 340px;
  --bg: #ffffff;
  --text: #1f2933;
  --muted: #5f6b7a;
  --line: #e1e5ea;
  --accent: #1f5fa8;
  --soft: #f4f6f8;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

a { color: var(--accent); }
code { font-family: ui-monospace, Consolas, monospace; font-size: 0.9em; background: var(--soft); padding: 0 3px; border-radius: 3px; }

/* ---------- header ---------- */
.site-header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
}
.site-header h1 {
  margin: 0;
  font-size: 1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.site-header .sub { font-weight: normal; color: var(--muted); font-size: 0.85rem; }

.panel-toggle {
  display: none;
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.85rem;
  cursor: pointer;
}

/* ---------- layout ---------- */
.layout {
  position: relative;
  display: flex;
  height: calc(100% - var(--header-h));
}
.map { flex: 1; min-width: 0; height: 100%; }

.panel {
  width: var(--panel-w);
  height: 100%;
  overflow-y: auto;
  border-left: 1px solid var(--line);
  background: var(--bg);
  font-size: 0.9rem;
  line-height: 1.6;
}

.tabs {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.tab {
  flex: 1;
  border: 0;
  background: none;
  padding: 10px 4px;
  font-size: 0.85rem;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.tab.is-active { color: var(--accent); border-bottom-color: var(--accent); font-weight: bold; }

.tab-body { display: none; padding: 12px 16px 24px; }
.tab-body.is-active { display: block; }
.tab-body h2 { font-size: 0.95rem; margin: 18px 0 6px; }
.tab-body h2:first-child { margin-top: 4px; }

/* ---------- filter ---------- */
.count-box {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  background: var(--soft);
  border-radius: 8px;
  padding: 10px 12px;
}
.count-box strong { font-size: 1.1rem; }

.field { display: block; margin-top: 14px; }
.field > span:first-child { display: block; margin-bottom: 4px; }
.field input[type="search"] {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 0.9rem;
}
.field input[type="range"] { width: 100%; }
.range-scale { display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--muted); }

.legend-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.legend-actions button {
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 4px;
  font-size: 0.75rem;
  padding: 1px 6px;
  cursor: pointer;
}
.legend { list-style: none; margin: 0; padding: 0; }
.legend li label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 0;
  cursor: pointer;
}
.legend .swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.25);
  flex: none;
}
.legend .label { flex: 1; }
.legend .label small { color: var(--muted); }
.legend .num { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 0.8rem; }

.hint { color: var(--muted); font-size: 0.8rem; margin: 8px 0 0; }
.small { font-size: 0.8rem; }
ul.plain { padding-left: 1.2em; margin: 6px 0; }

.glossary dt { font-weight: bold; margin-top: 10px; }
.glossary dd { margin: 2px 0 0; color: #333; }

/* ---------- popup ---------- */
.maplibregl-popup-content { padding: 12px 14px; max-width: 300px; font-size: 0.85rem; line-height: 1.5; }
.poi-popup h3 { margin: 0 18px 2px 0; font-size: 1rem; }
.poi-popup .name-en { color: var(--muted); margin: 0 0 6px; }
.poi-popup table { border-collapse: collapse; width: 100%; }
.poi-popup th { text-align: left; vertical-align: top; color: var(--muted); font-weight: normal; padding: 2px 8px 2px 0; white-space: nowrap; }
.poi-popup td { padding: 2px 0; word-break: break-all; }
.poi-popup .gers { font-family: ui-monospace, Consolas, monospace; font-size: 0.75rem; }
.conf-bar { display: inline-block; vertical-align: middle; width: 70px; height: 6px; background: var(--line); border-radius: 3px; margin-left: 6px; overflow: hidden; }
.conf-bar > span { display: block; height: 100%; background: var(--accent); }
.poi-popup .overlap { margin: 8px 0 0; padding-top: 6px; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.8rem; }
.src-tag { display: inline-block; background: var(--soft); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; margin: 0 4px 2px 0; font-size: 0.75rem; }

/* ---------- loading ---------- */
.loading {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
.loading.is-hidden { display: none; }
.loading.is-error { color: #b42318; }

/* ---------- smartphone ---------- */
@media (max-width: 760px) {
  .site-header h1 { font-size: 0.9rem; }
  .site-header .sub { display: none; }
  .panel-toggle { display: inline-block; }

  .layout { flex-direction: column; }
  .map { flex: 1 1 auto; height: auto; min-height: 0; }
  .panel {
    flex: 0 0 45%;
    width: 100%;
    height: 45%;
    border-left: 0;
    border-top: 1px solid var(--line);
  }
  .panel.is-collapsed { display: none; }
  .maplibregl-popup-content { max-height: 26vh; overflow-y: auto; }
}
