:root {
  color-scheme: light;
  --ink: #14201c;
  --muted: #60706a;
  --panel: #fffffff2;
  --line: #d6ded9;
  --surface: #f7faf8;
  --accent: #0f766e;
  --accent-dark: #124b45;
  --amber: #a96107;
  --blue: #245f9f;
  --shadow: 0 16px 38px rgba(20, 32, 28, 0.18);
}

* {
  box-sizing: border-box;
}

html,
body,
.map-shell,
#map {
  width: 100%;
  height: 100%;
  min-height: 100vh;
  margin: 0;
}

body {
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  letter-spacing: 0;
  overflow: hidden;
}

.map-shell {
  position: relative;
  background: #dfe8df;
}

#map {
  z-index: 1;
}

.panel {
  position: absolute;
  z-index: 500;
  top: 10px;
  left: 10px;
  width: min(310px, calc(100vw - 20px));
  max-height: calc(100vh - 20px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid rgba(214, 222, 217, 0.9);
  border-radius: 8px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

h1 {
  margin: 0;
  font-size: 1.08rem;
  line-height: 1.1;
  letter-spacing: 0;
}

.icon-button {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  display: grid;
  place-items: center;
  color: var(--accent-dark);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}

.icon-button:hover,
.icon-button:focus-visible {
  border-color: var(--accent);
  outline: none;
}

.icon-button svg {
  width: 17px;
  height: 17px;
  stroke-width: 2.2;
}

.back-button {
  position: absolute;
  z-index: 600;
  top: 10px;
  left: 10px;
  min-height: 36px;
  display: none;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  color: var(--accent-dark);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 850;
  background: var(--panel);
  border: 1px solid rgba(214, 222, 217, 0.95);
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(20, 32, 28, 0.16);
  backdrop-filter: blur(12px);
  cursor: pointer;
}

.back-button:hover,
.back-button:focus-visible {
  border-color: var(--accent);
  outline: none;
}

.back-button svg {
  width: 17px;
  height: 17px;
  stroke-width: 2.4;
}

.filter-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
}

.filter-button {
  min-width: 0;
  min-height: 30px;
  padding: 5px 6px;
  color: var(--ink);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 800;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}

.filter-button.is-active {
  color: #fff;
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.summary {
  display: block;
}

.summary > div {
  min-width: 0;
  padding: 7px 9px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.summary-label {
  display: block;
  margin-bottom: 1px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
}

.summary strong {
  display: block;
  min-width: 0;
  font-size: 0.88rem;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.site-list {
  display: grid;
  gap: 6px;
  padding-right: 2px;
  overflow: auto;
  scrollbar-color: #b7c5bf transparent;
}

.site-button {
  width: 100%;
  min-height: 48px;
  padding: 8px 9px;
  text-align: left;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  cursor: pointer;
}

.site-button:hover,
.site-button:focus-visible {
  border-color: #93aaa2;
  outline: none;
}

.site-button.is-selected {
  background: #f2fbf7;
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.site-button[data-kind="ROSPA"] {
  border-left-color: var(--blue);
}

.site-button[data-kind="RONPA"] {
  border-left-color: var(--amber);
}

.site-title {
  display: block;
  font-size: 0.82rem;
  font-weight: 850;
  line-height: 1.18;
  overflow-wrap: anywhere;
}

.site-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 750;
}

.pill {
  max-width: 100%;
  padding: 2px 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow-wrap: anywhere;
}

.leaflet-control-layers,
.leaflet-bar {
  border: 1px solid rgba(119, 137, 128, 0.35) !important;
  border-radius: 8px !important;
  box-shadow: 0 8px 24px rgba(20, 32, 28, 0.15) !important;
}

.leaflet-bar a:first-child {
  border-top-left-radius: 8px !important;
  border-top-right-radius: 8px !important;
}

.leaflet-bar a:last-child {
  border-bottom-right-radius: 8px !important;
  border-bottom-left-radius: 8px !important;
}

.leaflet-popup-content-wrapper {
  border-radius: 8px;
}

.leaflet-popup-content {
  min-width: 250px;
  max-width: 320px;
  margin: 14px 16px;
}

.popup-title {
  margin: 0 0 9px;
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.22;
  overflow-wrap: anywhere;
}

.popup-table {
  display: grid;
  grid-template-columns: minmax(82px, 0.58fr) minmax(0, 1fr);
  gap: 6px 10px;
  margin: 0;
  color: var(--ink);
  font-size: 0.82rem;
}

.popup-table dt {
  color: var(--muted);
  font-weight: 800;
}

.popup-table dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.empty-state {
  padding: 14px;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed #aebeb6;
  border-radius: 8px;
  font-size: 0.86rem;
  line-height: 1.4;
}

@media (max-width: 720px) {
  body {
    overflow: hidden;
  }

  .back-button {
    display: inline-flex;
  }

  .panel {
    top: auto;
    right: 10px;
    bottom: 10px;
    left: 10px;
    width: auto;
    max-height: 42vh;
    padding: 10px;
    gap: 8px;
  }

  h1 {
    font-size: 1rem;
  }

  .summary {
    display: none;
  }

  .site-button {
    min-height: 46px;
  }

  .leaflet-control-zoom {
    margin-top: 10px !important;
  }
}
