:root {
  color-scheme: light;
  --bg: #f5f7f2;
  --panel: #ffffff;
  --text: #1f271f;
  --muted: #667066;
  --line: #d9e0d5;
  --green: #1d8f5f;
  --green-dark: #126d48;
  --yellow: #f0c94a;
  --blue: #366fd7;
  --shadow: 0 16px 40px rgba(31, 39, 31, 0.14);
  font-family: "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

.start-screen {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  background:
    linear-gradient(rgba(245, 247, 242, 0.86), rgba(245, 247, 242, 0.9)),
    url("https://tile.openstreetmap.org/7/109/49.png");
  background-size: 256px 256px;
}

.start-screen.is-hidden {
  display: none;
}

.start-inner {
  display: grid;
  gap: 18px;
  width: min(520px, calc(100vw - 32px));
  max-width: 100%;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.start-inner h1 {
  font-size: 34px;
}

.start-note {
  margin: -6px 0 0;
  color: #b42318;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.55;
}

.start-credit {
  margin: -8px 0 0;
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.45;
}

.start-nickname {
  min-height: 46px;
}

.start-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.start-actions button {
  min-height: 54px;
  font-size: 18px;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 6px;
  background: var(--green);
  color: white;
  cursor: pointer;
  font-weight: 700;
  min-height: 38px;
  padding: 0 14px;
}

button:hover {
  background: var(--green-dark);
}

button.secondary,
.exporter button,
.mode-tabs button,
.secondary-action,
#clearFormButton,
#clearReportButton,
#clearLocalButton {
  background: #e8eee5;
  color: var(--text);
}

button.secondary:hover,
.exporter button:hover,
.mode-tabs button:hover,
.secondary-action:hover,
#clearFormButton:hover,
#clearReportButton:hover,
#clearLocalButton:hover {
  background: #dce7d7;
}

.mode-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  min-width: 0;
}

.mode-tabs button.active {
  background: var(--green);
  color: #fff;
}

.app {
  display: grid;
  grid-template-columns: minmax(340px, 420px) 1fr;
  width: 100vw;
  height: 100vh;
  min-height: 720px;
  overflow: hidden;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  overflow: hidden;
  padding: 18px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  box-shadow: var(--shadow);
  z-index: 500;
}

.form-hint {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.spot-type-guide {
  margin-top: -2px;
  color: #126d48;
  font-weight: 700;
}

.secondary-action {
  width: 100%;
}

.location-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.person-icon {
  position: relative;
  display: inline-block;
  width: 17px;
  height: 18px;
}

.person-icon::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 1px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.person-icon span {
  position: absolute;
  left: 3px;
  bottom: 1px;
  width: 11px;
  height: 9px;
  border-radius: 9px 9px 4px 4px;
  background: currentColor;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

h1,
h2 {
  margin: 0;
  line-height: 1.15;
}

h1 {
  font-size: 28px;
}

h2 {
  font-size: 16px;
}

.stat {
  flex: 0 0 auto;
  min-width: 82px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  text-align: right;
}

.stat strong {
  font-size: 23px;
}

.stat span {
  color: var(--muted);
  font-size: 13px;
}

.controls,
.editor,
.reporter,
.exporter {
  display: grid;
  gap: 8px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfa;
  color: var(--text);
  padding: 9px 10px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(29, 143, 95, 0.14);
}

.split,
.actions,
.exporter {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.exporter {
  grid-template-columns: 1fr;
}

.admin-tools {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  padding: 8px 10px;
}

.admin-tools[hidden] {
  display: none;
}

.admin-tools summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.admin-sheet-link {
  display: grid;
  place-items: center;
  min-height: 36px;
  margin-top: 8px;
  border: 1px solid #cddfca;
  border-radius: 6px;
  background: #f6fbf4;
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.admin-sheet-link:hover {
  background: #eaf7ef;
}

.admin-pending-button {
  width: 100%;
  margin-top: 8px;
  background: #fff4c9;
  color: #654700;
}

.admin-pending-button:hover,
.admin-pending-button.active {
  background: #f0c94a;
  color: #1f271f;
}

.admin-tools .exporter {
  margin-top: 8px;
}

.admin-rename {
  display: grid;
  gap: 8px;
  margin-top: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.admin-rename strong {
  font-size: 13px;
}

.admin-report-list {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.admin-list-header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  margin-top: 4px;
}

.admin-list-header strong {
  font-size: 13px;
}

.admin-list-header span {
  color: var(--muted);
  font-size: 12px;
}

.admin-completed-claims {
  border-top: 1px solid var(--line);
  padding-top: 7px;
}

.admin-completed-claims summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.admin-empty {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.admin-report {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 8px;
  align-items: center;
  border-top: 1px solid var(--line);
  padding-top: 7px;
}

.admin-report strong {
  font-size: 12px;
  overflow-wrap: anywhere;
}

.admin-report p {
  grid-column: 1;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.admin-report button {
  grid-column: 2;
  grid-row: 1 / span 2;
  min-height: 30px;
  padding: 0 10px;
  background: #ffe8e0;
  color: #9b341f;
  font-size: 12px;
}

body[data-mode="register"] .controls,
body[data-mode="register"] .reporter,
body[data-mode="register"] .spot-list {
  display: none;
}

body[data-mode="map"] .editor,
body[data-mode="map"] .reporter {
  display: none;
}

body[data-mode="report"] .editor {
  display: none;
}

.spot-list {
  display: grid;
  gap: 8px;
  min-height: 0;
  margin: 0;
  padding: 0 4px 0 0;
  overflow: auto;
  list-style: none;
}

.spot {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  padding: 10px;
  cursor: pointer;
}

.spot:hover,
.spot.active {
  border-color: var(--green);
  background: #f0f8f2;
}

.spot strong {
  display: block;
  margin-bottom: 4px;
  overflow-wrap: anywhere;
}

.spot p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.spot-note-panel {
  border: 1px solid #cddfca;
  border-radius: 8px;
  background: #f6fbf4;
  padding: 11px;
}

.spot-note-panel > strong {
  display: block;
  margin-bottom: 4px;
  color: var(--text);
}

.spot-id {
  margin-bottom: 4px !important;
  color: var(--green-dark) !important;
  font-weight: 800;
  letter-spacing: 0;
}

.spot-date {
  margin-bottom: 4px !important;
  color: #7a8178 !important;
  font-size: 12px !important;
  font-weight: 700;
}

.map-links {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.map-link {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: #fff;
  font-size: 13px;
  font-weight: 900;
  text-decoration: none;
}

.map-link.naver {
  background: #03c75a;
}

.map-link.kakao {
  background: #fee500;
  color: #1f271f;
}

.map-link.google {
  background: #4285f4;
}

.report-log {
  display: grid;
  gap: 6px;
  margin-top: 8px;
  padding: 8px;
  border: 1px solid #ffd5bf;
  border-radius: 8px;
  background: #fff8f1;
}

.report-log > strong {
  color: #9b341f;
  font-size: 13px;
}

.report-log-item {
  display: grid;
  gap: 2px;
  padding: 7px 8px;
  border-radius: 7px;
  background: #fff;
}

.report-log-item strong {
  color: #7f2b19;
  font-size: 12px;
}

.report-log-item span,
.report-log-item p {
  margin: 0 !important;
  color: var(--muted) !important;
  font-size: 12px;
  line-height: 1.35;
}

.reporter-chip {
  justify-self: start;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #ffe8e0;
  color: #9b341f;
  font-size: 12px;
}

.reporter-chip:hover {
  background: #ffd0c2;
}

.spot-notes {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.spot-note {
  display: grid;
  gap: 2px;
  padding: 8px 9px;
  border: 1px solid #dbe6d6;
  border-radius: 7px;
  background: #f7faf5;
}

.spot-note strong {
  color: var(--green-dark);
  font-size: 12px;
}

.spot-note span,
.spot-note-empty {
  margin: 0 !important;
  color: var(--text) !important;
  font-size: 13px;
  line-height: 1.35;
}

.spot-note-empty {
  color: var(--muted) !important;
}

.spot-note button {
  justify-self: start;
  min-height: 28px;
  padding: 0 9px;
  background: #ffe8e0;
  color: #9b341f;
  font-size: 12px;
}

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

.spot-actions button {
  min-height: 32px;
  padding: 0 10px;
  background: #fff4c9;
  color: #654700;
  font-size: 13px;
}

.spot-actions button:hover {
  background: #f6df8d;
}

.spot-actions .note-open-button.active {
  background: var(--green);
  color: #fff;
}

.spot-actions .note-open-button.active:hover {
  background: var(--green-dark);
}

.danger-actions button {
  background: #ffe8e0;
  color: #9b341f;
}

.danger-actions button:hover {
  background: #ffd0c2;
}

.admin-spot-actions {
  margin-top: 10px;
}

.admin-spot-actions button {
  background: var(--green);
  color: #fff;
}

.admin-spot-actions button:hover {
  background: var(--green-dark);
}

.admin-spot-actions .reject-spot-button {
  background: #ffe8e0;
  color: #9b341f;
}

.admin-spot-actions .reject-spot-button:hover {
  background: #ffd0c2;
}

.admin-state-actions {
  padding-top: 8px;
  border-top: 1px dashed var(--line);
}

.admin-state-actions .pending-state-button {
  background: #fff0db;
  color: #9a4d00;
}

.admin-state-actions .pending-state-button:hover {
  background: #ffd9a6;
}

.inline-report-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: 8px;
}

.inline-location-form {
  display: grid;
  gap: 8px;
  margin-top: 8px;
  padding: 10px;
  border: 1px solid #cddfca;
  border-radius: 8px;
  background: #f6fbf4;
}

.inline-location-form strong {
  color: var(--green-dark);
  font-size: 13px;
}

.inline-location-form input {
  min-height: 34px;
}

.inline-location-form button {
  justify-self: end;
  min-height: 34px;
  padding: 0 12px;
}

.inline-note-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: 8px;
}

.inline-note-form input,
.inline-note-form textarea {
  grid-column: 1 / -1;
}

.inline-note-form textarea {
  min-height: 58px;
  resize: vertical;
}

.inline-note-form button {
  grid-column: 2;
  min-height: 34px;
  padding: 0 12px;
}

.inline-report-form input {
  min-height: 34px;
}

.inline-report-form button {
  min-height: 34px;
  padding: 0 12px;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 7px;
}

.badge {
  border-radius: 999px;
  background: #e8eee5;
  color: #394439;
  font-size: 12px;
  padding: 3px 7px;
}

.badge.local {
  background: #e8f0ff;
  color: var(--blue);
}

.badge.single {
  background: #eaf7ef;
  color: var(--green-dark);
}

.badge.double {
  background: #fff4c9;
  color: #745b00;
}

.badge.report {
  background: #ffe8e0;
  color: #9b341f;
}

.badge.pending {
  background: #fff0db;
  color: #9a4d00;
  border: 1px solid #f2c188;
}

.badge.rejected {
  background: #ececec;
  color: #676767;
}

.badge.note {
  background: #e8f0ff;
  color: var(--blue);
}

.badge.legacy-contributor {
  background: #f1f3f0;
  color: #667066;
  border: 1px dashed #b9c3b5;
}

.badge.new-contributor {
  background: #e8f0ff;
  color: var(--blue);
}

.badge.confirmed-contributor {
  background: #eaf7ef;
  color: var(--green-dark);
  border: 1px solid #b9dbc4;
}

.map-wrap,
#map {
  min-width: 0;
  height: 100%;
  overflow: hidden;
}

.map-wrap {
  position: relative;
}

.list-toggle {
  display: none;
}

.spot-marker-icon {
  display: flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 0;
}

.spot-dot {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.32);
}

.local-marker .spot-dot {
  background: var(--blue);
}

.pending-marker .spot-dot {
  background: #f08a24;
}

.cluster-dot {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: #1f271f;
  color: #fff;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.34);
  font-size: 13px;
  font-weight: 800;
}

.cluster-label {
  max-width: 190px;
}

.cluster-label strong {
  color: var(--green-dark);
}

.spot-label {
  display: inline-grid;
  gap: 1px;
  max-width: 175px;
  min-height: 28px;
  padding: 4px 8px;
  border: 1px solid rgba(18, 109, 72, 0.22);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.95);
  color: var(--text);
  box-shadow: 0 5px 16px rgba(31, 39, 31, 0.18);
  line-height: 1.12;
  opacity: 1;
  transform: translateX(0);
  transition: opacity 120ms ease, transform 120ms ease;
}

.spot-label strong,
.spot-label small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.spot-label strong {
  font-size: 13px;
}

.spot-label small {
  color: var(--muted);
  font-size: 11px;
}

.spot-label small.legacy-contributor-text {
  color: #7a8178;
}

.spot-label small.new-contributor-text {
  color: var(--blue);
}

.spot-label small.confirmed-contributor-text {
  color: var(--green-dark);
  font-weight: 800;
}

body[data-labels="hide"] .spot-label {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-4px);
}

body[data-labels="hide"] .spot-marker-icon:hover .spot-label,
body[data-labels="hide"] .active-marker .spot-label {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}

.active-marker .spot-dot {
  background: var(--yellow);
  border-color: #1f271f;
}

.active-marker .spot-label {
  border-color: rgba(31, 39, 31, 0.4);
  box-shadow: 0 7px 20px rgba(31, 39, 31, 0.24);
}

.user-location-icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: #2f6df6;
  box-shadow: 0 4px 14px rgba(47, 109, 246, 0.4);
}

.user-location-icon::after {
  content: "";
  position: absolute;
  inset: -8px;
  border: 2px solid rgba(47, 109, 246, 0.28);
  border-radius: 50%;
}

.user-location-icon .user-head {
  position: absolute;
  top: 7px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fff;
}

.user-location-icon .user-body {
  position: absolute;
  bottom: 7px;
  width: 14px;
  height: 10px;
  border-radius: 10px 10px 5px 5px;
  background: #fff;
}

.leaflet-popup-content {
  min-width: 220px;
}

.popup-title {
  margin: 0 0 6px;
  font-size: 16px;
}

.popup-meta {
  margin: 3px 0;
  color: #667066;
}

.popup-report {
  margin: 4px 0;
  color: #9b341f;
  font-weight: 700;
}

@media (max-width: 860px) {
  html,
  body {
    overflow: hidden;
  }

  .start-inner {
    width: calc(100vw - 28px);
    padding: 22px;
  }

  .start-inner h1 {
    font-size: 30px;
  }

  .start-note {
    font-size: 15px;
    overflow-wrap: anywhere;
  }

  .start-credit {
    font-size: 12px;
    overflow-wrap: anywhere;
  }

  .start-actions button {
    min-height: 58px;
  }

  .app {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(250px, 42dvh) minmax(0, 1fr);
    height: 100dvh;
    min-height: 100svh;
    max-height: 100dvh;
  }

  body[data-mode="map"].list-collapsed .app,
  body[data-mode="register"].list-collapsed .app {
    grid-template-rows: 100dvh 0;
  }

  .map-wrap {
    grid-row: 1;
  }

  .list-toggle {
    position: absolute;
    left: 12px;
    bottom: 14px;
    z-index: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 0 14px;
    border: 1px solid rgba(18, 109, 72, 0.2);
    background: #fff;
    color: var(--green-dark);
    box-shadow: 0 8px 24px rgba(31, 39, 31, 0.22);
  }

  .list-toggle:hover {
    background: #f0f8f2;
  }

  body:not([data-mode="map"]):not([data-mode="register"]) .list-toggle {
    display: none;
  }

  .sidebar {
    grid-row: 2;
    border-right: 0;
    border-top: 1px solid var(--line);
    gap: 10px;
    padding: 12px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .spot-list {
    overflow: visible;
    padding: 0 0 72px;
  }

  body[data-mode="map"].list-collapsed .sidebar,
  body[data-mode="register"].list-collapsed .sidebar {
    min-height: 0;
    padding: 0;
    border: 0;
    overflow: hidden;
  }

  body[data-mode="map"].list-collapsed .sidebar > *,
  body[data-mode="register"].list-collapsed .sidebar > * {
    display: none;
  }

  h1 {
    font-size: 24px;
  }

  .topbar {
    align-items: center;
    gap: 8px;
  }

  .stat {
    flex: 0 0 auto;
    min-width: 72px;
    padding: 6px 8px;
  }

  .mode-tabs {
    gap: 6px;
  }

  .mode-tabs button {
    min-width: 0;
    padding: 0 4px;
    font-size: 14px;
  }

  .controls .split {
    grid-template-columns: 1fr 0.8fr;
  }

  .stat strong {
    font-size: 20px;
  }

  .mode-tabs button,
  button {
    min-height: 42px;
  }

  .spot {
    padding: 12px;
  }

  .map-link {
    width: 36px;
    height: 36px;
  }

  .leaflet-control-zoom a {
    width: 36px;
    height: 36px;
    line-height: 36px;
  }
}
