:root {
  --bg: #1a2a22;
  --panel: rgba(244, 241, 233, 0.96);
  --ink: #1c2b22;
  --muted: #5a6b60;
  --accent: #2f6b4f;
  --accent-deep: #1e4a37;
  --insect: #c45c26;
  --plant: #3f8f5a;
  --line: rgba(28, 43, 34, 0.12);
  --shadow: 0 18px 50px rgba(10, 20, 14, 0.28);
  --font-display: "Fraunces", "Apple SD Gothic Neo", serif;
  --font-body: "IBM Plex Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-body);
  color: var(--ink);
  background: #142018;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 100vh;
  min-height: 100dvh;
}

.map-wrap {
  position: absolute;
  inset: 0;
  z-index: 0;
}

#map {
  width: 100%;
  height: 100%;
}

.panel-toggle {
  position: absolute;
  top: 1rem;
  left: 1rem;
  z-index: 3;
  border: 0;
  border-radius: 999px;
  padding: 0.7rem 1.1rem;
  cursor: pointer;
  background: rgba(244, 241, 233, 0.95);
  color: var(--accent-deep);
  font: inherit;
  font-weight: 700;
  box-shadow: var(--shadow);
  transition: transform 180ms ease, opacity 180ms ease;
}

.panel-toggle:hover {
  transform: translateY(-1px);
}

body.panel-open .panel-toggle {
  opacity: 0;
  pointer-events: none;
}

.panel {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: min(380px, calc(100vw - 1.5rem));
  height: 100%;
  padding: 1.25rem 1.15rem 1rem;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: auto;
  backdrop-filter: blur(10px);
  transform: translateX(0);
  animation: panelIn 220ms ease;
}

.panel[hidden] {
  display: none !important;
}

@keyframes panelIn {
  from {
    opacity: 0;
    transform: translateX(-18px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.brand-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}

.brand-mark {
  margin: 0;
  font-size: 0.75rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
}

.panel-close {
  border: 0;
  border-radius: 999px;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
  background: rgba(47, 107, 79, 0.12);
  color: var(--accent-deep);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
}

.brand h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.55rem, 2.2vw, 2rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.lede {
  margin: 0.65rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.45);
  font-size: 0.86rem;
}

.stats-wide {
  grid-column: 1 / -1;
}

.stats .muted,
.stats-wide.muted {
  color: var(--muted);
  font-size: 0.78rem;
}

.stats strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1.15rem;
  color: var(--accent-deep);
}

.more-tag {
  margin-left: 0.35rem;
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 500;
}

.iw.stack {
  min-width: 240px;
  max-width: 300px;
  max-height: 320px;
  display: flex;
  flex-direction: column;
}

.iw-place {
  margin: 0.2rem 0 0.45rem !important;
  font-size: 0.78rem !important;
}

.iw-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow: auto;
  max-height: 220px;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.iw-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.45rem;
  align-items: start;
  padding: 0.35rem 0.2rem;
  border-top: 1px solid rgba(28, 43, 34, 0.08);
}

.iw-row strong {
  font-size: 0.86rem;
  margin: 0;
}

.iw-row p {
  margin: 0.1rem 0 0 !important;
  font-size: 0.72rem !important;
}

.iw-note {
  color: #3d5246 !important;
  white-space: pre-wrap;
}

.iw-more {
  margin: 0.4rem 0 0 !important;
  font-size: 0.75rem !important;
  color: var(--muted);
}

.add-modal {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(16, 28, 22, 0.38);
  backdrop-filter: blur(2px);
}

.add-modal[hidden] {
  display: none !important;
}

.add-card {
  width: min(420px, 100%);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding: 1.25rem 1.15rem;
  border-radius: 16px;
  background: rgba(244, 241, 233, 0.98);
  box-shadow: var(--shadow);
}

.add-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.add-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.25rem;
}

.add-coords {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.add-card textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  background: #fff;
  color: var(--ink);
  resize: vertical;
  min-height: 96px;
  font: inherit;
}

.add-error {
  margin: 0;
  color: #a33b2b;
  font-size: 0.85rem;
}

.filters {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  background: #fff;
  color: var(--ink);
}

.search-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.4rem;
}

button {
  border: 0;
  border-radius: 10px;
  padding: 0.65rem 0.9rem;
  cursor: pointer;
  background: rgba(47, 107, 79, 0.12);
  color: var(--accent-deep);
  font-weight: 600;
}

button.primary {
  background: linear-gradient(180deg, #3a7d5c, var(--accent-deep));
  color: #f7f4ec;
  box-shadow: 0 8px 18px rgba(30, 74, 55, 0.28);
}

button:hover {
  filter: brightness(1.05);
}

.hint {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.result-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  max-height: 32vh;
  overflow: auto;
}

.result-list li {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  background: rgba(255, 255, 255, 0.55);
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease;
}

.result-list li:hover {
  transform: translateY(-1px);
  background: #fff;
}

.result-list .name {
  font-weight: 600;
  font-size: 0.92rem;
}

.result-list .meta {
  margin-top: 0.2rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.badge {
  display: inline-block;
  margin-right: 0.35rem;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  color: #fff;
}

.badge.insect { background: var(--insect); }
.badge.plant { background: var(--plant); }

.credit {
  margin-top: auto;
  padding-top: 0.75rem;
  font-size: 0.72rem;
  color: var(--muted);
}

.map-legend {
  position: absolute;
  right: 1rem;
  bottom: 1rem;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0.8rem;
  border-radius: 999px;
  background: rgba(244, 241, 233, 0.92);
  box-shadow: var(--shadow);
  font-size: 0.82rem;
  font-weight: 600;
}

.search-bar {
  position: absolute;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  width: min(560px, calc(100vw - 7rem));
}

.search-form {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.4rem;
  padding: 0.45rem;
  border-radius: 14px;
  background: rgba(244, 241, 233, 0.96);
  box-shadow: var(--shadow);
}

.search-form select,
.search-form input {
  margin: 0;
}

.search-form select {
  width: auto;
  min-width: 4.5rem;
}

.search-results {
  list-style: none;
  margin: 0.4rem 0 0;
  padding: 0.35rem;
  max-height: min(50vh, 360px);
  overflow: auto;
  border-radius: 14px;
  background: rgba(244, 241, 233, 0.98);
  box-shadow: var(--shadow);
}

.search-results[hidden] {
  display: none !important;
}

.search-results li {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  cursor: pointer;
}

.search-results li:hover {
  background: rgba(47, 107, 79, 0.1);
}

.search-results .title {
  font-weight: 600;
  font-size: 0.92rem;
}

.search-results .meta {
  font-size: 0.78rem;
  color: var(--muted);
}

.search-empty {
  padding: 0.75rem;
  color: var(--muted);
  font-size: 0.85rem;
}

@media (max-width: 860px) {
  .search-bar {
    left: 1rem;
    right: 1rem;
    width: auto;
    transform: none;
    top: 4.2rem;
  }

  .search-form {
    grid-template-columns: 1fr auto;
  }

  .search-form select {
    grid-column: 1 / -1;
  }
}

.dot {
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 50%;
  display: inline-block;
  margin-right: 0.3rem;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.7);
}

.dot.insect { background: radial-gradient(circle at 35% 30%, #e8a06a, var(--insect)); }
.dot.plant { background: radial-gradient(circle at 35% 30%, #6bbf84, var(--plant)); }

.map-error {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background:
    radial-gradient(900px 500px at 20% 15%, #2d4a38 0%, transparent 55%),
    linear-gradient(160deg, #142018, #1f3328 50%, #243a2e);
  color: #f4f1e9;
}

.map-error[hidden] {
  display: none !important;
}

.map-error-card {
  width: min(520px, 100%);
  padding: 1.5rem 1.4rem;
  border-radius: 16px;
  background: rgba(244, 241, 233, 0.96);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.map-error-card h2 {
  margin: 0 0 0.75rem;
  font-family: var(--font-display);
  font-size: 1.35rem;
}

.map-error-card p,
.map-error-card li {
  margin: 0.45rem 0;
  color: var(--muted);
  line-height: 1.5;
  font-size: 0.92rem;
}

.map-error-card ol {
  margin: 0.75rem 0 0;
  padding-left: 1.2rem;
}

.map-error-card a {
  color: var(--accent-deep);
  font-weight: 600;
}

.map-error-card code {
  font-size: 0.85em;
  background: rgba(47, 107, 79, 0.12);
  padding: 0.1rem 0.35rem;
  border-radius: 6px;
}

.iw {
  padding: 0.45rem 0.2rem 0.25rem;
  min-width: 190px;
  max-width: 240px;
  font-family: var(--font-body);
}

.iw-kicker {
  display: inline-block;
  margin-bottom: 0.3rem;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  color: #fff;
  background: var(--insect);
}

.iw.plant .iw-kicker {
  background: var(--plant);
}

.iw strong {
  display: block;
  font-size: 0.98rem;
  margin-bottom: 0.15rem;
  letter-spacing: -0.02em;
}

.iw-sci {
  font-style: italic;
  opacity: 0.85;
}

.iw p {
  margin: 0.12rem 0;
  font-size: 0.78rem;
  color: #445248;
}

.agg-bubble {
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  border-radius: 50%;
  background: rgba(30, 74, 55, 0.94);
  color: #fff;
  font-weight: 700;
  font-family: var(--font-body);
  text-align: center;
  border: 2px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 6px 18px rgba(20, 32, 24, 0.35), 0 0 0 6px rgba(255, 255, 255, 0.22);
  cursor: pointer;
  user-select: none;
  transition: transform 160ms ease;
}

.agg-bubble:hover {
  transform: scale(1.06);
}

@media (max-width: 860px) {
  .panel {
    width: 100%;
    max-width: none;
  }

  .result-list {
    max-height: 28vh;
  }
}
