:root {
  --bg: #f7f5f2;
  --panel-bg: #ffffff;
  --border: #e2ddd5;
  --text: #2b2823;
  --text-muted: #6b665e;
  --accent: #0f7a8c;
  --accent-contrast: #ffffff;
  --header-h: 56px;
  --footer-h: 40px;
  font-family: "Hiragino Sans", "Yu Gothic", "Noto Sans JP", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
}

body {
  display: flex;
  flex-direction: column;
}

/* Header */
.app-header {
  flex: 0 0 var(--header-h);
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--panel-bg);
  border-bottom: 1px solid var(--border);
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-icon { font-size: 24px; color: var(--accent); }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-ja { font-weight: 700; font-size: 16px; }
.brand-en { font-size: 11px; color: var(--text-muted); }

.icon-btn {
  border: none;
  background: transparent;
  font-size: 18px;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text);
}
.icon-btn:hover { background: var(--bg); }

.filter-toggle { display: none; }

/* Body layout */
.app-body {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
  position: relative;
}

.filter-panel {
  flex: 0 0 300px;
  width: 300px;
  overflow-y: auto;
  background: var(--panel-bg);
  border-right: 1px solid var(--border);
  padding: 16px;
  z-index: 10;
}

.filter-group { margin-bottom: 18px; }
.filter-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

select, input[type="search"] {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

.range-row { display: flex; flex-direction: column; gap: 4px; }
.range-row input[type="range"] { width: 100%; }

.text-btn {
  border: 1px solid var(--border);
  background: var(--panel-bg);
  color: var(--accent);
  padding: 7px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  width: 100%;
}
.text-btn:hover { background: var(--bg); }

.legend { border-top: 1px solid var(--border); padding-top: 14px; margin-bottom: 14px; }
.legend-title { font-size: 12px; font-weight: 600; color: var(--text-muted); margin: 0 0 8px; }
.legend ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.legend li { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.swatch {
  width: 12px; height: 12px; border-radius: 50%;
  display: inline-block; flex: 0 0 auto;
  border: 1px solid rgba(0,0,0,0.15);
}

.result-count { font-size: 12px; color: var(--text-muted); margin: 0; }

/* Map */
#map {
  flex: 1 1 auto;
  min-width: 0;
}

.leaflet-popup-content, .leaflet-container {
  font-family: inherit;
}

/* Detail panel */
.detail-panel {
  position: absolute;
  top: 12px;
  right: 12px;
  bottom: 12px;
  width: 320px;
  max-width: calc(100% - 24px);
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  padding: 16px;
  overflow-y: auto;
  z-index: 15;
}
.detail-panel[hidden] { display: none; }
.detail-panel .icon-btn { position: absolute; top: 8px; right: 8px; }

.detail-category { font-weight: 700; font-size: 15px; margin: 0 32px 12px 0; }

#detailContent dl { margin: 0; }
#detailContent dt {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 10px;
}
#detailContent dt:first-child { margin-top: 0; }
#detailContent dd {
  margin: 2px 0 0;
  font-size: 14px;
  word-break: break-word;
}

/* Footer */
.app-footer {
  flex: 0 0 auto;
  min-height: var(--footer-h);
  display: flex;
  align-items: center;
  padding: 6px 16px;
  font-size: 11px;
  color: var(--text-muted);
  background: var(--panel-bg);
  border-top: 1px solid var(--border);
}
.app-footer a { color: var(--accent); }

/* Mobile */
@media (max-width: 760px) {
  .filter-toggle { display: inline-flex; align-items: center; justify-content: center; }

  .filter-panel {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 85%;
    max-width: 320px;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 8px 0 24px rgba(0,0,0,0.15);
  }
  .filter-panel.open { transform: translateX(0); }

  .detail-panel {
    left: 12px;
    right: 12px;
    width: auto;
    top: auto;
    height: 60%;
  }
}
