:root {
  --green: #2f5d43;
  --leaf: #6f8f55;
  --paper: #f8f4e9;
  --ink: #1f261f;
  --muted: #667266;
  --line: #d8d0bc;
  --red: #d72d2d;
  --cream: #fffdf7;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

.cover-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 0;
  background: #2f8e94;
  cursor: pointer;
}

.language-screen {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 22px;
  background:
    radial-gradient(circle at 20% 15%, rgba(255, 253, 247, 0.18), transparent 34%),
    linear-gradient(145deg, #204c3d, #477257);
}

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

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

.language-panel {
  width: min(100%, 420px);
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.96);
  box-shadow: 0 20px 70px rgba(10, 22, 18, 0.35);
}

.language-panel h1 {
  margin-bottom: 8px;
}

.language-panel p {
  color: var(--muted);
  line-height: 1.65;
}

.language-options {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.language-options button {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--green);
  color: #fff;
  font: inherit;
  font-size: 17px;
  font-weight: 800;
}

.language-options button:disabled {
  background: #f3f0e7;
  color: #8c9288;
}

.language-notice {
  min-height: 24px;
  margin: 12px 0 0;
  font-size: 14px;
}

.cover-screen img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100dvh;
  object-fit: contain;
  user-select: none;
}

.top-actions button {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 999px;
  background: #fff;
  color: var(--green);
  font-weight: 800;
}

.cover-screen:focus-visible {
  outline: 4px solid rgba(255, 215, 88, 0.9);
  outline-offset: -4px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px clamp(16px, 4vw, 36px);
  background: rgba(248, 244, 233, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--leaf);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 24px;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 4px;
  font-size: 18px;
}

.status {
  flex: 0 0 auto;
  padding: 7px 10px;
  border: 1px solid #b7c6ab;
  border-radius: 999px;
  color: var(--green);
  background: #edf5e7;
  font-size: 12px;
  font-weight: 700;
}

.layout {
  padding: 18px clamp(12px, 3vw, 30px);
}

.map-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
  gap: 18px;
}

.map-panel,
.detail-panel,
.map-scroll,
.map-open-button {
  min-width: 0;
}

.map-toolbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}

.map-toolbar p,
.detail-panel p {
  color: var(--muted);
  line-height: 1.65;
}

.legend {
  margin-bottom: 0;
  font-size: 13px;
  line-height: 1.55;
}

.legend span {
  display: inline-block;
  margin-right: 2px;
  color: var(--green);
  font-weight: 800;
}

.search {
  display: grid;
  gap: 5px;
  min-width: 170px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.search input {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--cream);
  color: var(--ink);
  font: inherit;
  font-size: 16px;
}

.search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

#clearSearch {
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--cream);
  color: var(--green);
  font-weight: 800;
}

#clearSearch[hidden] {
  display: none;
}

.map-open-button {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid #b7c6ab;
  border-radius: 8px;
  background: #edf5e7;
  color: var(--green);
  font: inherit;
  font-weight: 900;
  text-align: left;
}

.map-open-button strong {
  flex: 0 0 auto;
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--green);
  color: #fff;
  font-size: 13px;
}

.map-scroll {
  grid-column: 1;
  grid-row: 2;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #efe7d2;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.55);
}

.map-spread {
  position: relative;
  width: min(1380px, 210vw);
  min-width: 820px;
}

.map-spread img {
  width: 100%;
  height: auto;
  display: block;
  user-select: none;
}

.markers {
  position: absolute;
  inset: 0;
}

.marker {
  position: absolute;
  width: 32px;
  height: 32px;
  transform: translate(-50%, -50%);
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  line-height: 1;
  box-shadow: 0 2px 7px rgba(60, 20, 12, 0.32);
  cursor: pointer;
}

.marker:hover,
.marker:focus-visible {
  outline: 3px solid rgba(255, 231, 118, 0.78);
  background: #b91f1f;
}

.marker.active {
  outline: 4px solid rgba(255, 215, 88, 0.9);
  background: #b91f1f;
}

.printed-map .marker {
  width: 24px;
  height: 24px;
  border-color: transparent;
  background: transparent;
  color: transparent;
  box-shadow: none;
  font-size: 0;
  pointer-events: none;
  touch-action: manipulation;
}

.printed-map .marker:hover,
.printed-map .marker:focus-visible,
.printed-map .marker.active {
  outline: 0;
  background: transparent;
  box-shadow: 0 0 0 3px rgba(255, 215, 88, 0.9);
}

.nearby-picker {
  position: fixed;
  z-index: 50;
  left: 50%;
  bottom: max(14px, env(safe-area-inset-bottom));
  width: min(420px, calc(100vw - 24px));
  padding: 12px;
  transform: translateX(-50%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--cream);
  box-shadow: 0 8px 28px rgba(46, 36, 24, 0.24);
}

.nearby-picker[hidden] {
  display: none;
}

.nearby-picker-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.nearby-picker-close {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  font-size: 24px;
  line-height: 1;
}

.nearby-options {
  display: flex;
  gap: 9px;
  overflow-x: auto;
  padding: 3px 2px 5px;
}

.nearby-option {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  box-shadow: 0 2px 7px rgba(60, 20, 12, 0.28);
}

.detail-panel {
  grid-column: 2;
  grid-row: 2;
  position: sticky;
  top: 84px;
  align-self: start;
  max-height: calc(100vh - 110px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--cream);
}

.detail {
  padding: 20px;
}

.image-gallery {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.image-gallery figure {
  margin: 0;
}

.image-gallery img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 6px;
}

.image-gallery figcaption {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.image-placeholder {
  display: grid;
  place-items: center;
  min-height: 170px;
  margin-bottom: 18px;
  padding: 18px;
  border: 1px dashed #a6b891;
  border-radius: 8px;
  background: #edf5e7;
  text-align: center;
}

.image-placeholder span {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  margin-bottom: 10px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  font-size: 22px;
  font-weight: 900;
}

.image-placeholder p {
  max-width: 280px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.detail-number {
  display: inline-grid;
  place-items: center;
  min-width: 44px;
  width: 44px;
  height: 44px;
  margin-bottom: 14px;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  font-size: 20px;
  font-weight: 900;
}

.detail-number.animal-number {
  width: auto;
  min-width: 92px;
  height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  font-size: 18px;
  white-space: nowrap;
}

.latin {
  margin-bottom: 6px;
  color: var(--green);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 20px;
}

.provisional-name .common-name {
  font-style: italic;
}

.meta {
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 14px;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.tag {
  padding: 5px 8px;
  border-radius: 999px;
  background: #eef3e7;
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
}

.tag.review {
  background: #fff3d7;
  color: #8c5c00;
}

.quick-list {
  display: flex;
  gap: 8px;
  padding: 0 clamp(12px, 3vw, 30px) 12px;
  overflow: auto;
}

.quick-list button {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--cream);
  color: var(--green);
  font-weight: 700;
}

.quick-list button.active {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px;
  padding: 0 clamp(12px, 3vw, 30px) 28px;
}

.card {
  min-height: 112px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--cream);
  text-align: left;
  cursor: pointer;
}

.card strong {
  display: block;
  margin-bottom: 5px;
  font-size: 16px;
}

.card span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.empty {
  padding: 22px;
  color: var(--muted);
}

.inline-link {
  min-height: 28px;
  margin-right: 6px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--green);
  font-weight: 800;
}

.map-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: var(--paper);
}

.map-modal[hidden] {
  display: none;
}

.map-modal-open {
  overflow: hidden;
}

.map-modal-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: max(12px, env(safe-area-inset-top)) 12px 10px;
  border-bottom: 1px solid var(--line);
  background: rgba(248, 244, 233, 0.96);
}

.map-modal-bar strong {
  min-width: 0;
  color: var(--green);
  font-size: 15px;
}

.map-modal-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.map-modal-actions button {
  min-width: 38px;
  min-height: 38px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--green);
  font: inherit;
  font-weight: 900;
}

.map-modal-scroll {
  overflow: auto;
  background: #efe7d2;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x pan-y pinch-zoom;
}

.modal-map-spread {
  width: 1380px;
  max-width: none;
  min-width: 820px;
  transform-origin: 0 0;
}

@media (max-width: 860px) {
  .map-panel {
    grid-template-columns: 1fr;
  }

  .detail-panel {
    grid-column: 1;
    grid-row: 3;
    position: static;
    max-height: none;
  }

  .map-open-button {
    grid-row: 2;
  }

  .map-scroll {
    grid-column: 1;
    grid-row: 4;
    max-height: 45vh;
  }

  .map-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .search {
    min-width: 0;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .printed-map .marker {
    width: 20px;
    height: 20px;
  }

  .printed-map .marker:hover,
  .printed-map .marker:focus-visible,
  .printed-map .marker.active {
    box-shadow: 0 0 0 3px rgba(255, 215, 88, 0.9);
  }
}

@media (min-width: 861px) {
  .map-open-button {
    display: none;
  }
}
