:root {
  --bg-panel: rgba(255, 250, 245, 0.92);
  --bg-panel-strong: rgba(255, 248, 238, 0.98);
  --border-soft: rgba(128, 88, 55, 0.18);
  --shadow-soft: 0 16px 40px rgba(70, 51, 33, 0.18);
  --text-main: #34261c;
  --text-soft: #705745;
  --brand: #d36f42;
  --brand-deep: #aa4f28;
  --brand-light: #fbe8db;
  --surface: #fffdf9;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  color: var(--text-main);
  background: #f2ede8;
}

body {
  position: relative;
  overflow: hidden;
}

#map {
  width: 100%;
  height: 100%;
  background:
    radial-gradient(circle at top left, rgba(242, 205, 180, 0.4), transparent 26%),
    radial-gradient(circle at bottom right, rgba(214, 236, 208, 0.38), transparent 20%),
    #efe6dd;
}

.map-toolbar {
  position: absolute;
  top: 18px;
  left: 18px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(340px, calc(100vw - 36px));
}

.admin-toolbar {
  display: grid;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 18px;
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(16px);
}

.admin-toolbar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.admin-status {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
}

.admin-mode-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.56);
  border: 1px solid rgba(128, 88, 55, 0.12);
}

.admin-mode-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.admin-mode-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-soft);
}

.edit-mode-badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: #f7ebdc;
  color: var(--brand-deep);
  font-size: 12px;
  font-weight: 700;
}

.admin-mode-hint {
  margin: 0;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-soft);
}

.admin-mode-controls {
  display: grid;
  gap: 10px;
}

.admin-mode-select-wrap {
  display: grid;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-soft);
}

.primary-button,
.secondary-button,
.panel-toggle,
.species-button,
.icon-button,
.popup-action-button,
.remove-image-button {
  border: none;
  border-radius: 14px;
  font: inherit;
  cursor: pointer;
  transition: transform 0.2s ease, opacity 0.2s ease, background 0.2s ease;
}

.primary-button,
.secondary-button {
  padding: 12px 16px;
}

.primary-button {
  background: linear-gradient(135deg, var(--brand), var(--brand-deep));
  color: #fff;
  box-shadow: var(--shadow-soft);
}

.secondary-button {
  background: #f2ece5;
  color: var(--text-main);
}

.align-left {
  justify-self: start;
}

.hidden {
  display: none !important;
}

.primary-button:hover,
.secondary-button:hover,
.panel-toggle:hover,
.species-button:hover,
.icon-button:hover,
.popup-action-button:hover,
.remove-image-button:hover {
  transform: translateY(-1px);
}

.primary-button:disabled {
  opacity: 0.7;
  cursor: wait;
}

.info-panel {
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  border-radius: 20px;
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.panel-toggle {
  width: 100%;
  padding: 14px 18px;
  text-align: left;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.65), rgba(251, 240, 230, 0.8));
  color: var(--text-main);
  font-weight: 700;
}

.panel-body {
  padding: 0 18px 18px;
  max-height: 70vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.panel-body.collapsed {
  display: none;
}

.panel-tip {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-soft);
  margin: 12px 0;
}

.filter-group {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.filter-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-soft);
}

.filter-input {
  width: 100%;
  border: 1px solid rgba(123, 89, 62, 0.18);
  border-radius: 14px;
  background: #fffdfb;
  padding: 11px 14px;
  font: inherit;
  color: var(--text-main);
}

.filter-input:focus {
  outline: 2px solid rgba(211, 111, 66, 0.25);
  border-color: rgba(211, 111, 66, 0.6);
}

.filter-reset-button {
  width: 100%;
  margin-bottom: 12px;
}

.stats-summary {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 14px;
  background: var(--brand-light);
  color: var(--brand-deep);
  font-weight: 700;
}

.stats-summary span:first-child {
  font-size: 24px;
}

.species-list {
  list-style: none;
  padding: 0;
  margin: 16px 0 0;
  display: grid;
  gap: 10px;
  flex: 1;
  overflow-y: auto;
  padding-right: 6px;
  min-height: 0;
}

.species-list::-webkit-scrollbar {
  width: 6px;
}

.species-list::-webkit-scrollbar-track {
  background: #f1e9df;
  border-radius: 3px;
}

.species-list::-webkit-scrollbar-thumb {
  background: #d36f42;
  border-radius: 3px;
}

.species-list::-webkit-scrollbar-thumb:hover {
  background: #aa4f28;
}

.species-button {
  width: 100%;
  padding: 11px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface);
  border: 1px solid rgba(139, 95, 62, 0.12);
  color: var(--text-main);
}

.species-button.active {
  background: linear-gradient(135deg, #ffe0d0, #fff8f1);
  border-color: rgba(211, 111, 66, 0.45);
  color: var(--brand-deep);
}

.species-count {
  min-width: 32px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #f5ede6;
  font-size: 12px;
  text-align: center;
}

.status-message {
  position: absolute;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%) translateY(16px);
  z-index: 1000;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(44, 35, 27, 0.86);
  color: #fff;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.status-message.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.modal-overlay {
  position: absolute;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(38, 28, 18, 0.42);
  backdrop-filter: blur(6px);
}

.modal-card {
  width: min(680px, 100%);
  max-height: min(90vh, 860px);
  overflow: auto;
  background: var(--bg-panel-strong);
  border: 1px solid rgba(133, 90, 56, 0.15);
  border-radius: 28px;
  box-shadow: 0 28px 60px rgba(41, 28, 18, 0.24);
  padding: 24px;
}

.admin-modal-card {
  width: min(460px, 100%);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.modal-header h2 {
  margin: 4px 0 0;
  font-size: 28px;
}

.modal-kicker {
  margin: 0;
  color: var(--brand-deep);
  font-size: 13px;
  letter-spacing: 0.08em;
}

.icon-button {
  width: 40px;
  height: 40px;
  background: #f4ebe4;
  color: var(--text-main);
  font-size: 26px;
  line-height: 1;
}

.record-form {
  display: grid;
  gap: 16px;
}

.record-form label {
  display: grid;
  gap: 8px;
  font-weight: 600;
}

.record-form input,
.record-form textarea {
  width: 100%;
  border: 1px solid rgba(123, 89, 62, 0.18);
  border-radius: 14px;
  background: #fffdfb;
  padding: 12px 14px;
  font: inherit;
  color: var(--text-main);
}

.record-form input:focus,
.record-form textarea:focus {
  outline: 2px solid rgba(211, 111, 66, 0.25);
  border-color: rgba(211, 111, 66, 0.6);
}

.form-help,
.coordinate-note,
.section-tip {
  color: var(--text-soft);
  font-size: 14px;
}

.coordinate-note {
  padding: 12px 14px;
  border-radius: 14px;
  background: #f7eee6;
}

.existing-images {
  padding: 14px;
  border-radius: 18px;
  background: #fff7f0;
  border: 1px solid rgba(123, 89, 62, 0.12);
}

.section-title-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 12px;
}

.section-title-row h3 {
  margin: 0;
  font-size: 16px;
}

.existing-images-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
}

.existing-image-item {
  display: grid;
  gap: 8px;
}

.existing-image-item img {
  width: 100%;
  height: 98px;
  object-fit: cover;
  border-radius: 14px;
  display: block;
}

.remove-image-button {
  padding: 8px 10px;
  background: #f9ddd9;
  color: #9d3641;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.flower-marker {
  display: block;
  position: relative;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.92);
  transform: none;
  box-shadow: 0 8px 16px rgba(71, 43, 28, 0.26);
  transition: transform 0.2s ease, opacity 0.2s ease, filter 0.2s ease;
}

.flower-marker::after {
  content: "";
  position: absolute;
  width: 8px;
  height: 8px;
  background: rgba(255, 255, 255, 0.82);
  border-radius: 50%;
  top: 7px;
  left: 7px;
}

.flower-marker.default {
  background: radial-gradient(circle at 30% 30%, #f9e7b3, #d8a947 68%, #c8922d 100%);
}

.flower-marker.temporary {
  background: radial-gradient(circle at 30% 30%, #fff0bf, #e5ba61 68%, #cf9331 100%);
  animation: pulse-marker 1.1s infinite alternate;
}

.flower-marker.highlighted {
  background: linear-gradient(135deg, #ff6b6b, #d93f50);
  transform: scale(1.12);
}

.flower-marker.dimmed {
  opacity: 0.33;
  filter: grayscale(0.2);
}

@keyframes pulse-marker {
  from {
    transform: scale(1);
  }
  to {
    transform: scale(1.08);
  }
}

.leaflet-popup-content-wrapper {
  border-radius: 22px;
  padding: 4px;
}

.leaflet-popup-content {
  margin: 0;
}

.popup-card {
  width: min(360px, 72vw);
  color: var(--text-main);
}

.popup-topline {
  display: flex;
  justify-content: flex-start;
  margin-bottom: 10px;
}

.popup-count-badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: #f7ebdc;
  color: var(--brand-deep);
  font-size: 12px;
  font-weight: 700;
}

.popup-card h3 {
  margin: 0 0 10px;
  font-size: 22px;
}

.popup-meta {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 14px;
  color: var(--text-soft);
}

.popup-description {
  margin: 0 0 14px;
  line-height: 1.7;
}

.popup-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  gap: 10px;
}

.popup-gallery img {
  width: 100%;
  height: 92px;
  object-fit: cover;
  border-radius: 14px;
  display: block;
}

.popup-empty {
  padding: 12px;
  border-radius: 14px;
  background: #f7efe8;
  color: var(--text-soft);
  font-size: 14px;
}

.popup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.popup-action-button {
  padding: 10px 14px;
  color: #fff;
}

.popup-view-detail-button {
  background: linear-gradient(135deg, #d0a13f, #a7731f);
}

.popup-edit-button {
  background: linear-gradient(135deg, #5a9a73, #36704e);
}

.popup-delete-button {
  background: linear-gradient(135deg, #e06b72, #bf4350);
}

.detail-overlay {
  position: absolute;
  inset: 0;
  z-index: 1300;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(31, 22, 14, 0.48);
  backdrop-filter: blur(8px);
}

.detail-shell {
  width: min(980px, 100%);
  max-height: min(88vh, 920px);
  display: flex;
  flex-direction: column;
  background: rgba(255, 250, 244, 0.98);
  border-radius: 30px;
  border: 1px solid rgba(133, 90, 56, 0.12);
  box-shadow: 0 28px 60px rgba(41, 28, 18, 0.26);
  overflow: hidden;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 24px 24px 18px;
  border-bottom: 1px solid rgba(125, 93, 65, 0.12);
  background: linear-gradient(180deg, rgba(255, 248, 239, 0.96), rgba(255, 252, 247, 0.98));
}

.detail-kicker {
  margin: 0 0 6px;
  color: var(--brand-deep);
  font-size: 13px;
  letter-spacing: 0.08em;
}

.detail-header h2 {
  margin: 0;
  font-size: 28px;
}

.detail-summary {
  margin: 10px 0 0;
  color: var(--text-soft);
  line-height: 1.6;
}

.detail-body {
  flex: 1;
  overflow: auto;
  padding: 22px 24px 24px;
  display: grid;
  gap: 16px;
}

.detail-toolbar {
  display: flex;
  justify-content: flex-start;
}

.detail-add-button {
  padding-left: 18px;
  padding-right: 18px;
}

.detail-record-card,
.detail-empty {
  background: #fffdf9;
  border: 1px solid rgba(126, 90, 60, 0.12);
  border-radius: 24px;
  box-shadow: 0 12px 24px rgba(87, 57, 34, 0.08);
}

.detail-record-card {
  padding: 20px;
}

.detail-empty {
  padding: 22px;
  color: var(--text-soft);
}

.detail-record-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
}

.detail-record-head h3 {
  margin: 0 0 8px;
  font-size: 24px;
}

.detail-record-meta {
  margin: 0;
  display: grid;
  gap: 6px;
  color: var(--text-soft);
  font-size: 14px;
}

.detail-record-actions {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

.detail-record-description {
  margin: 16px 0;
  line-height: 1.8;
}

.detail-gallery-scroll {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 220px;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 6px;
}

.detail-gallery-scroll img {
  width: 220px;
  height: 160px;
  object-fit: cover;
  border-radius: 18px;
  display: block;
  box-shadow: 0 10px 20px rgba(64, 42, 23, 0.12);
}

@media (max-width: 820px) {
  .map-toolbar {
    width: min(100vw - 24px, 100%);
    left: 12px;
    top: 12px;
  }

  .modal-card {
    padding: 18px;
    border-radius: 22px;
  }

  .modal-header h2 {
    font-size: 24px;
  }

  .section-title-row,
  .admin-toolbar-top,
  .admin-mode-row,
  .detail-header,
  .detail-record-head,
  .detail-record-actions,
  .form-actions,
  .popup-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .form-actions .primary-button,
  .form-actions .secondary-button,
  .detail-record-actions .secondary-button,
  .popup-action-button,
  .align-left {
    width: 100%;
  }

  .detail-overlay {
    padding: 14px;
  }

  .detail-shell {
    max-height: 92vh;
    border-radius: 24px;
  }

  .detail-header,
  .detail-body {
    padding-left: 18px;
    padding-right: 18px;
  }

  .detail-header h2 {
    font-size: 24px;
  }

  .detail-gallery-scroll {
    grid-auto-columns: 180px;
  }

  .detail-gallery-scroll img {
    width: 180px;
    height: 132px;
  }
}

.thumbnail-image {
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.thumbnail-image:hover {
  transform: scale(1.02);
  box-shadow: 0 12px 24px rgba(64, 42, 23, 0.2);
}

.image-viewer-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(12px);
}

.image-viewer-container {
  position: relative;
  width: min(90vw, 1200px);
  height: min(90vh, 800px);
  display: flex;
  flex-direction: column;
  background: #1a1a1a;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 32px 64px rgba(0, 0, 0, 0.5);
}

.image-viewer-close {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 10;
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease;
}

.image-viewer-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.image-viewer-content {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 60px 24px 24px;
  overflow: hidden;
}

.image-viewer-content img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
}

.image-viewer-actions {
  display: flex;
  justify-content: center;
  gap: 16px;
  padding: 20px 24px;
  background: rgba(0, 0, 0, 0.5);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.image-viewer-actions .primary-button {
  padding: 12px 24px;
  background: linear-gradient(135deg, #d0a13f, #a7731f);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.image-viewer-actions .primary-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(160, 115, 31, 0.4);
}

@media (max-width: 820px) {
  .image-viewer-overlay {
    padding: 0;
  }

  .image-viewer-container {
    width: 100vw;
    height: 100vh;
    border-radius: 0;
  }

  .image-viewer-content {
    padding: 80px 16px 16px;
  }

  .image-viewer-actions {
    padding: 16px;
  }
}
