:root {
  --green: #465b2d;
  --green-soft: #6c7b4e;
  --paper: #ffffff;
  --ink: #1c1c1c;
  --muted: #5c6156;
  --line: #e2e5de;
  --change: #785ef0;
  --keep: #ffb000;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
  color-scheme: light;
}

* { box-sizing: border-box; }

[hidden] {
  display: none !important;
}

html, body {
  margin: 0;
  height: 100%;
  font-family: "Segoe UI", Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: #f4f5f3;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  min-height: 100dvh;
}

.topbar {
  background: var(--green);
  color: white;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
}

.topbar h1 {
  margin: 0;
  font-size: 1.15rem;
}

.topbar p {
  margin: 2px 0 0;
  font-size: 0.8rem;
  opacity: 0.9;
}

.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
}

#map {
  flex: 1;
  width: 100%;
  height: 100%;
  z-index: 0;
}

.floating {
  position: absolute;
  z-index: 500;
  background: var(--paper);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.tools {
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  gap: 8px;
  padding: 8px;
}

.tools select,
.tools button,
.actions button,
.sheet button,
.sheet input,
.sheet textarea {
  font: inherit;
  font-size: 16px;
}

.tools select { flex: 1; min-width: 0; }

.tools button,
.actions button,
.wizard-nav button,
.vote,
.primary,
.secondary {
  border: 0;
  border-radius: 10px;
  min-height: 44px;
  padding: 8px 12px;
}

.layers {
  left: 12px;
  bottom: calc(132px + env(safe-area-inset-bottom));
  margin: 0;
  padding: 8px 12px;
  border: 0;
  max-width: min(280px, calc(100% - 24px));
}

.layers legend {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0 4px;
}

.layers label {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 0.92rem;
  margin: 4px 0;
}

.actions {
  position: absolute;
  z-index: 500;
  left: 12px;
  right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  display: flex;
  gap: 8px;
}

.actions button { flex: 1; }

.primary { background: var(--green); color: white; }
.secondary { background: white; color: var(--green); border: 2px solid var(--green) !important; }

.sheet {
  position: fixed;
  inset: 0;
  z-index: 800;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: flex-end;
}

.sheet-card {
  position: relative;
  background: var(--paper);
  width: 100%;
  max-height: min(88dvh, 760px);
  overflow: auto;
  border-radius: 18px 18px 0 0;
  padding: 16px 16px calc(20px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow);
}

.sheet h2 { margin: 0 36px 8px 0; font-size: 1.25rem; }

.close {
  position: absolute;
  right: 8px;
  top: 8px;
  width: 44px;
  height: 44px;
  border: 0;
  background: transparent;
  font-size: 28px;
  color: var(--green);
}

.sheet label,
.detail p { display: block; margin: 12px 0; }

.sheet textarea,
.sheet input[type="text"],
.tools select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: white;
}

.sheet textarea { min-height: 88px; resize: vertical; }

.hint, .optional, #step-help { color: var(--muted); font-size: 0.92rem; }
.status { min-height: 1.2em; color: #8c3a3a; }
.status.ok { color: var(--green); }

.vote-row, .wizard-nav { display: flex; gap: 8px; }
.vote-row button, .wizard-nav button { flex: 1; }
.vote { background: white; border: 2px solid var(--line) !important; }
.vote.selected[data-vote="like"] { background: var(--green); color: white; border-color: var(--green) !important; }
.vote.selected[data-vote="dislike"] { background: #8c3a3a; color: white; border-color: #8c3a3a !important; }

.current-files { display: grid; gap: 8px; margin-top: 8px; }
.current-files p { margin: 0; }
.current-files button { justify-self: start; }

.emoji-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.emoji {
  border: 2px solid var(--line);
  background: white;
  border-radius: 999px;
  min-height: 44px;
  padding: 6px 10px;
}
.emoji.selected { border-color: var(--green); background: #eef2e6; }

.detail img {
  width: 100%;
  max-height: 240px;
  object-fit: cover;
  border-radius: 12px;
  background: var(--line);
}

.detail audio { width: 100%; }

.badge {
  display: inline-block;
  color: white;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.8rem;
}

.pin span {
  display: block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid white;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

.toast {
  position: fixed;
  z-index: 900;
  left: 16px;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  background: var(--ink);
  color: white;
  padding: 12px 14px;
  border-radius: 12px;
  text-align: center;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.leaflet-control-attribution { font-size: 10px; }
