:root {
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;

  color: #1f2933;
  background: #f5f7f6;

  --border: #d8dedb;
  --muted: #66736c;
  --panel: #ffffff;
  --soft: #f5f7f6;
  --soft-2: #eef2f0;
  --accent: #6a1b9a;
  --accent-dark: #4a148c;
  --danger: #9f2f2f;
}


* {
  box-sizing: border-box;
}


html,
body {
  margin: 0;
  min-height: 100%;
}


body {
  display: flex;
  flex-direction: column;
  background: #f5f7f6;
}


button,
input,
select {
  font: inherit;
}


button,
input,
select,
summary {
  outline-offset: 2px;
}


button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(106, 27, 154, 0.28);
}


a {
  color: #54227a;
}


.header {
  padding: 1rem 1.5rem;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}


.header-main {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
}


.header h1 {
  margin: 0 0 0.3rem;
  font-size: 1.7rem;
}


.header p {
  margin: 0;
  color: #53615a;
}


.database-meta {
  max-width: 440px;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
  text-align: right;
}


main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}


.controls {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem 1.5rem;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}


.species-search-control {
  flex: 1 1 520px;
  min-width: 0;
}


.control-label {
  display: block;
  margin-bottom: 0.3rem;
  font-weight: 650;
}


.species-search-row {
  display: flex;
  gap: 0.5rem;
}


.species-search {
  width: min(560px, 100%);
  min-width: 220px;
  padding: 0.55rem 0.7rem;
  border: 1px solid #aeb8b3;
  border-radius: 6px;
  background: white;
}


.control-help {
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.8rem;
}


.summary-actions {
  flex: 0 1 auto;
  min-width: 260px;
  text-align: right;
}


.record-summary {
  min-height: 1.3rem;
  color: #53615a;
  font-size: 0.92rem;
}


.action-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.4rem;
  margin-top: 0.35rem;
}


.action-feedback {
  min-height: 1rem;
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.78rem;
}


.button {
  min-height: 38px;
  padding: 0.48rem 0.72rem;
  border: 1px solid var(--accent-dark);
  border-radius: 6px;
  background: var(--accent-dark);
  color: white;
  cursor: pointer;
}


.button.secondary {
  border-color: #aeb8b3;
  background: white;
  color: #35413b;
}


.button:hover:not(:disabled) {
  filter: brightness(0.96);
}


.button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}


.filters-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.65rem;
  padding: 0.65rem 1.5rem;
  background: #fafbfa;
  border-bottom: 1px solid var(--border);
}


.filters-panel[hidden] {
  display: none;
}


.filter-field {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 120px;
}


.filter-reference {
  min-width: 200px;
  max-width: 310px;
}


.filter-field label {
  color: #53615a;
  font-size: 0.78rem;
  font-weight: 650;
}


.filter-field input,
.filter-field select,
.unmapped-tools input,
.unmapped-tools select {
  min-height: 36px;
  padding: 0.42rem 0.55rem;
  border: 1px solid #b9c2bd;
  border-radius: 5px;
  background: white;
}


.filter-field select {
  max-width: 220px;
}


.filter-reference select {
  max-width: 310px;
}


.filter-checkbox {
  padding-bottom: 0.45rem;
  color: #45534c;
  font-size: 0.88rem;
}


.filter-checkbox label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}


.content-layout {
  flex: 1;
  display: grid;
  grid-template-columns:
    minmax(0, 1fr)
    minmax(330px, 390px);
  min-height: 0;
}


.map-container {
  position: relative;
  min-width: 0;
  min-height: 540px;
}


#map {
  width: 100%;
  height: calc(100vh - 245px);
  min-height: 540px;
  background: #e7ece9;
}


.map-empty-message {
  position: absolute;
  z-index: 500;
  left: 50%;
  top: 1rem;
  transform: translateX(-50%);
  max-width: calc(100% - 2rem);
  padding: 0.55rem 0.8rem;
  border: 1px solid #c8cecb;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.94);
  color: #53615a;
  font-size: 0.86rem;
  text-align: center;
}


.details-panel {
  overflow-y: auto;
  max-height: calc(100vh - 245px);
  padding: 1rem;
  background: var(--panel);
  border-left: 1px solid var(--border);
}


.details-panel section + section {
  margin-top: 1.35rem;
  padding-top: 1.15rem;
  border-top: 1px solid #e2e7e4;
}


.details-panel h2 {
  margin: 0 0 0.75rem;
  font-size: 1.04rem;
}


.section-heading-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}


.section-heading-row h2 {
  min-width: 0;
}


.text-button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent-dark);
  font-size: 0.8rem;
  cursor: pointer;
  text-decoration: underline;
}


.placeholder {
  margin: 0;
  color: #6b756f;
  font-size: 0.93rem;
}


.temporal-legend {
  display: grid;
  grid-template-columns:
    repeat(2, minmax(0, 1fr));
  gap: 0.42rem 0.75rem;
}


.legend-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
  font-size: 0.86rem;
}


.legend-dot {
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  border: 1.5px solid #333333;
  border-radius: 50%;
}


.legend-note {
  margin: 0.7rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.4;
}


.year-chart-summary {
  margin-bottom: 0.5rem;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}


.year-chart {
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 0.2rem;
}


.year-chart svg {
  display: block;
  height: 190px;
  max-width: none;
}


.chart-axis {
  stroke: #8f9a94;
  stroke-width: 1;
}


.chart-grid {
  stroke: #e2e6e4;
  stroke-width: 1;
}


.chart-label,
.chart-count {
  fill: #65716b;
  font-size: 10px;
}


.chart-bar {
  cursor: pointer;
}


.chart-bar:hover,
.chart-bar:focus {
  opacity: 0.82;
}


.chart-bar.selected {
  stroke: #111111;
  stroke-width: 2;
}


.popup-title {
  margin-bottom: 0.7rem;
  font-size: 1.06rem;
}


.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.65rem 0 0.9rem;
}


.small-button {
  padding: 0.35rem 0.5rem;
  border: 1px solid #b8c0bc;
  border-radius: 5px;
  background: #fafbfa;
  color: #35413b;
  font-size: 0.79rem;
  cursor: pointer;
}


.detail-section {
  margin-top: 1rem;
}


.detail-section h3 {
  margin: 0 0 0.45rem;
  color: #39463f;
  font-size: 0.88rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}


.detail-row {
  display: grid;
  grid-template-columns:
    minmax(105px, 0.9fr)
    minmax(0, 1.4fr);
  gap: 0.45rem;
  padding: 0.27rem 0;
  border-bottom: 1px solid #f0f2f1;
  font-size: 0.86rem;
  line-height: 1.35;
}


.detail-label {
  color: #5c6862;
  font-weight: 650;
}


.detail-value {
  min-width: 0;
  overflow-wrap: anywhere;
}


.reference-card {
  padding: 0.55rem 0;
  border-bottom: 1px solid #edf0ee;
  font-size: 0.84rem;
  line-height: 1.4;
}


.reference-card:last-child {
  border-bottom: 0;
}


.reference-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 0.3rem;
}


.coordinate-group-intro {
  margin: 0 0 0.7rem;
  color: var(--muted);
  font-size: 0.86rem;
}


.coordinate-group-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}


.coordinate-group-item {
  width: 100%;
  padding: 0.55rem 0.65rem;
  text-align: left;
  border: 1px solid #d6dcda;
  border-radius: 6px;
  background: #f8faf9;
  cursor: pointer;
}


.coordinate-group-item:hover {
  background: #f0f4f2;
}


.group-item-top {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}


.mini-color-dot {
  flex: 0 0 auto;
  width: 11px;
  height: 11px;
  border: 1px solid #333333;
  border-radius: 50%;
}


.group-item-id {
  font-weight: 650;
}


.group-item-meta {
  display: block;
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.8rem;
}


.occurrence-group-wrapper {
  background: transparent;
  border: 0;
}


.occurrence-group-marker {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 2px solid #2d2d2d;
  border-radius: 50%;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.24);
  color: #ffffff;
  font-size: 11px;
  font-weight: 750;
  text-shadow:
    0 1px 2px rgba(0, 0, 0, 0.8);
}


.unmapped-tools {
  display: grid;
  gap: 0.45rem;
  margin-bottom: 0.65rem;
}


.unmapped-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}


.unmapped-item {
  width: 100%;
  padding: 0.6rem 0.7rem;
  text-align: left;
  border: 1px solid #d9dfdc;
  border-radius: 6px;
  background: #f7f9f8;
  cursor: pointer;
}


.unmapped-item:hover {
  background: #eef2f0;
}


.unmapped-item-title {
  display: block;
  font-weight: 650;
}


.unmapped-item-meta,
.unmapped-item-reason {
  display: block;
  margin-top: 0.16rem;
  color: #64716a;
  font-size: 0.8rem;
}


.unmapped-item-reason {
  color: #7a4b37;
}


.count-badge {
  display: inline-block;
  min-width: 1.5rem;
  padding: 0.05rem 0.35rem;
  border-radius: 999px;
  background: #ece8ef;
  color: #4e2d61;
  font-size: 0.75rem;
  text-align: center;
}


.about-section details {
  font-size: 0.84rem;
}


.about-section summary {
  cursor: pointer;
  color: #39463f;
  font-weight: 650;
}


.about-content {
  margin-top: 0.65rem;
  color: #59655f;
  line-height: 1.5;
}


.about-content p {
  margin: 0.55rem 0;
}


footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.55rem 1.5rem;
  background: var(--panel);
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.78rem;
}


footer p {
  margin: 0;
}


@media (max-width: 980px) {

  .header-main {
    flex-direction: column;
    gap: 0.6rem;
  }

  .database-meta {
    max-width: none;
    text-align: left;
  }

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

  .summary-actions {
    min-width: 0;
    text-align: left;
  }

  .action-buttons {
    justify-content: flex-start;
  }

  .content-layout {
    grid-template-columns:
      minmax(0, 1fr)
      330px;
  }

}


@media (max-width: 760px) {

  .header {
    padding: 0.9rem 1rem;
  }

  .header h1 {
    font-size: 1.4rem;
  }

  .controls,
  .filters-panel {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .species-search-row {
    flex-wrap: wrap;
  }

  .species-search {
    width: 100%;
    min-width: 0;
  }

  .species-search-row .button {
    width: 100%;
  }

  .filters-panel {
    align-items: stretch;
  }

  .filter-field,
  .filter-reference {
    flex: 1 1 145px;
    min-width: 0;
    max-width: none;
  }

  .filter-field select,
  .filter-reference select {
    width: 100%;
    max-width: none;
  }

  .filter-checkbox {
    flex-basis: 100%;
    padding-bottom: 0;
  }

  .content-layout {
    display: block;
  }

  #map {
    height: 62vh;
    min-height: 420px;
  }

  .details-panel {
    overflow: visible;
    max-height: none;
    border-left: 0;
    border-top: 1px solid var(--border);
  }

  .temporal-legend {
    grid-template-columns:
      repeat(2, minmax(0, 1fr));
  }

  footer {
    flex-direction: column;
    padding: 0.55rem 1rem;
  }

}


@media (max-width: 430px) {

  .temporal-legend {
    grid-template-columns: 1fr;
  }

  .detail-row {
    grid-template-columns: 1fr;
    gap: 0.05rem;
  }

}
