:root {
  --bg-1: #f9fbf7;
  --bg-2: #dff3ec;
  --card: rgba(255, 255, 255, 0.92);
  --line: #c9ddcf;
  --text: #103024;
  --pride: #2f9d44;
  --safety: #d6463a;
  --help: #1e79c2;
  --shadow: 0 10px 24px rgba(12, 48, 28, 0.14);
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: "Noto Sans KR", "Apple SD Gothic Neo", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 10% 10%, var(--bg-2), var(--bg-1));
}

body {
  display: grid;
  grid-template-rows: auto 1fr;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  display: grid;
  gap: 10px;
  padding: 12px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.title-wrap h1 {
  margin: 0;
  font-size: 1.2rem;
}

.title-wrap p {
  margin: 4px 0 0;
  font-size: 0.92rem;
}

.standards {
  margin-top: 6px;
  display: grid;
  gap: 4px;
}

.standards p {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.35;
  color: #2c4d3f;
}

.filter-wrap {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.top-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 999px;
  min-height: 48px;
  padding: 0 16px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}

.btn:active {
  transform: translateY(1px);
}

.btn.primary {
  background: #116a3d;
  border-color: #116a3d;
  color: #fff;
}

.btn.active {
  border-color: #2a6b4f;
  background: #e9f5ee;
}

main {
  position: relative;
  min-height: 0;
}

#map {
  width: 100%;
  height: 100%;
}

.legend {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 700;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px 12px;
  min-width: 170px;
}

.dashboard {
  position: absolute;
  left: 12px;
  top: 12px;
  z-index: 700;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
  width: min(90vw, 290px);
}

.dashboard.hidden {
  display: none;
}

.dashboard h2 {
  margin: 0 0 6px;
  font-size: 0.95rem;
}

.dashboard p {
  margin: 0 0 8px;
  font-size: 0.9rem;
  font-weight: 700;
}

.stats-list {
  display: grid;
  gap: 6px;
}

.stat-row {
  display: grid;
  gap: 4px;
  font-size: 0.88rem;
}

.bar-track {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: #eaf1eb;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
}

.legend h2 {
  font-size: 0.92rem;
  margin: 0 0 8px;
}

.legend ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
  font-size: 0.9rem;
}

.dot {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

.dot.pride {
  background: var(--pride);
}

.dot.safety {
  background: var(--safety);
}

.dot.help {
  background: var(--help);
}

.form-panel {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  width: min(94vw, 420px);
  z-index: 800;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}

.form-panel.hidden {
  display: none;
}

.form-panel h2 {
  margin: 0 0 8px;
  font-size: 1rem;
}

#entryForm {
  display: grid;
  gap: 8px;
}

#entryForm label {
  font-weight: 700;
  font-size: 0.9rem;
}

#entryForm input,
#entryForm select,
#entryForm textarea {
  width: 100%;
  border: 1px solid #b8d0c0;
  border-radius: 10px;
  min-height: 44px;
  font-size: 1rem;
  padding: 8px 10px;
  background: #fff;
}

#entryForm textarea {
  resize: vertical;
}

.actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.custom-pin {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.15);
}

.popup-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.popup-btn {
  border: 1px solid #c3d6c8;
  border-radius: 8px;
  background: #fff;
  min-height: 34px;
  padding: 0 10px;
  font-weight: 700;
  cursor: pointer;
}

.popup-btn.delete {
  border-color: #e1b3af;
  color: #b63d34;
}

@media (max-width: 768px) {
  .app-header {
    padding: 10px;
  }

  .legend {
    left: 10px;
    right: auto;
    bottom: 10px;
  }

  .dashboard {
    left: 10px;
    top: 10px;
  }

  .form-panel {
    bottom: 90px;
  }
}
