:root {
  color-scheme: light;
  --ink: #172225;
  --muted: #657175;
  --paper: #f6f8f5;
  --surface: #ffffff;
  --surface-soft: #eef5f2;
  --line: #dbe4df;
  --line-strong: #b9c9c2;
  --sea: #087985;
  --sea-dark: #075b67;
  --green: #2f6b52;
  --amber: #c78f2e;
  --coral: #cf6f62;
  --shadow: 0 18px 42px rgba(15, 40, 45, 0.1);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100svh;
  margin: 0;
  background:
    linear-gradient(180deg, rgba(238, 245, 242, 0.86), rgba(246, 248, 245, 0)),
    var(--paper);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  line-height: 1.55;
}

button,
input,
select {
  font: inherit;
}

a {
  color: inherit;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

.app-header,
.app-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px clamp(18px, 4vw, 46px);
}

.app-header {
  min-height: 66px;
  border-bottom: 1px solid rgba(219, 228, 223, 0.86);
  background: rgba(246, 248, 245, 0.92);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  color: var(--ink);
  text-decoration: none;
}

.brand-logo {
  display: block;
  width: auto;
  height: 46px;
  max-width: min(60vw, 260px);
  object-fit: contain;
  object-position: left center;
}

.data-counts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.data-counts span,
.type-badge,
.chip {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 0.76rem;
  font-weight: 850;
}

.data-counts span {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
}

.app-main {
  width: min(1440px, 100%);
  margin: 0 auto;
}

.search-app {
  display: grid;
  gap: 18px;
  padding: clamp(18px, 3vw, 34px);
}

.search-panel,
.result-list-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.search-panel {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--sea);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.search-heading h1 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 3.2rem);
  line-height: 1.08;
  letter-spacing: 0;
}

.search-controls {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) auto minmax(170px, 220px);
  gap: 12px;
  align-items: end;
}

.search-controls > * {
  min-width: 0;
}

.search-controls label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
}

.search-controls input,
.search-controls select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  padding: 0 12px;
  outline: none;
}

.search-controls input:focus,
.search-controls select:focus {
  border-color: var(--sea);
  box-shadow: 0 0 0 3px rgba(8, 121, 133, 0.13);
}

.mode-control {
  display: grid;
  grid-template-columns: repeat(3, minmax(72px, 1fr));
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #ffffff;
}

.mode-button {
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 900;
}

.mode-button:last-child {
  border-right: 0;
}

.mode-button.is-active {
  background: var(--sea-dark);
  color: #ffffff;
}

.results-shell {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  align-items: start;
  min-height: min(720px, calc(100svh - 210px));
}

.result-list-panel {
  display: grid;
  grid-template-rows: auto auto;
  min-height: 420px;
  overflow: visible;
}

.result-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 850;
}

.text-button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--sea-dark);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 900;
  padding: 0 11px;
}

.result-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-content: start;
  gap: 12px;
  padding: 14px;
}

.result-card {
  width: 100%;
  min-height: 178px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  overflow: hidden;
}

.result-card-button {
  display: grid;
  width: 100%;
  min-height: 178px;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  padding: 0;
  text-align: left;
  text-decoration: none;
}

.result-card-body {
  padding: 14px;
}

.result-card[data-type="spot"],
.empty-state,
.infinite-sentinel {
  grid-column: 1 / -1;
}

.result-card[data-type="spot"].has-media .result-card-button {
  grid-template-columns: minmax(190px, 260px) minmax(0, 1fr);
}

.result-card[data-type="spot"].has-media .result-card-media {
  height: 100%;
  border-right: 1px solid var(--line);
  border-bottom: 0;
}

.result-card-media {
  display: block;
  width: 100%;
  margin: 0;
  overflow: hidden;
  background: #dcebe8;
}

.result-card-media {
  aspect-ratio: 4 / 3;
  border-bottom: 1px solid var(--line);
}

.result-card-media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-credit {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  align-items: center;
  border-top: 1px solid var(--line);
  background: #ffffff;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 780;
  line-height: 1.35;
  padding: 8px 10px;
}

.image-credit a {
  color: var(--sea-dark);
  text-decoration: none;
}

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

.record-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--sea-dark);
  font-size: 0.78rem;
  font-weight: 900;
  padding: 4px 9px;
  text-decoration: none;
}

.breadcrumb ol {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  margin: 0;
  padding: 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  list-style: none;
}

.breadcrumb li {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.breadcrumb li:not(:last-child)::after {
  content: "›";
  color: var(--line-strong);
}

.breadcrumb a {
  color: var(--sea-dark);
  text-underline-offset: 3px;
}

.area-link-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.area-link {
  display: grid;
  gap: 4px;
  min-height: 70px;
  align-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 12px;
  text-decoration: none;
}

.area-link span:first-child {
  font-weight: 900;
}

.area-link span:last-child {
  color: var(--sea-dark);
  font-size: 0.82rem;
  font-weight: 850;
}

.area-directory {
  box-shadow: var(--shadow);
}

.result-card h2 {
  margin: 0;
  font-size: 1.08rem;
  line-height: 1.3;
  letter-spacing: 0;
}

.result-card p,
.fact-grid dd,
.source-list a {
  color: var(--muted);
}

.result-card p {
  margin: 8px 0 0;
  font-size: 0.9rem;
}

.type-badge {
  flex: 0 0 auto;
  background: rgba(8, 121, 133, 0.11);
  color: var(--sea-dark);
}

.type-badge.creature {
  background: rgba(207, 111, 98, 0.13);
  color: #8b3a31;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.spot-card-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin: 12px 0 0;
}

.spot-card-facts div {
  display: grid;
  gap: 2px;
  min-width: 96px;
}

.spot-card-facts dt {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 900;
}

.spot-card-facts dd {
  margin: 0;
  color: var(--sea-dark);
  font-size: 0.9rem;
  font-weight: 900;
}

.chip {
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--muted);
}

.section-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 16px;
}

.section-block h2,
.section-block h3 {
  margin: 0 0 12px;
  font-size: 1rem;
}

.fact-grid {
  display: grid;
  gap: 10px;
  margin: 0;
}

.fact-grid div {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.fact-grid div:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.fact-grid dt {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 900;
}

.fact-grid dd {
  margin: 0;
}

.link-list {
  display: grid;
  gap: 10px;
}

.relation-button,
.relation-link {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--ink);
  cursor: pointer;
  font-weight: 900;
  padding: 10px 12px;
  text-align: left;
  text-decoration: none;
}

.relation-button span:last-child,
.relation-link span:last-child {
  flex: 0 1 auto;
  color: var(--sea-dark);
  font-size: 0.86rem;
  line-height: 1.35;
  text-align: right;
}

.relation-link span:first-child {
  min-width: 0;
}

.source-list {
  display: grid;
  gap: 8px;
}

.source-list a {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.9rem;
  font-weight: 800;
  text-decoration: none;
}

.source-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.source-group summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 800;
  list-style: none;
  padding: 10px 12px;
}

.source-group summary::-webkit-details-marker {
  display: none;
}

.source-group summary::before {
  content: "▸";
  color: var(--sea-dark);
  font-size: 0.82rem;
}

.source-group[open] summary::before {
  content: "▾";
}

.source-group summary span:first-of-type {
  min-width: 0;
  margin-right: auto;
}

.source-group summary span:last-child {
  flex: 0 0 auto;
  color: var(--sea-dark);
  text-align: right;
}

.source-group-links {
  display: grid;
  gap: 6px;
  border-top: 1px solid var(--line);
  background: var(--surface-soft);
  padding: 8px;
}

.source-group-links a {
  border: 0;
  background: #ffffff;
  font-size: 0.82rem;
  padding: 8px 10px;
}

.relation-section-grid {
  border-top: 1px solid var(--line);
  background: var(--surface-soft);
  padding: 10px;
}

.empty-state {
  margin: 0;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  padding: 18px;
  color: var(--muted);
  background: #ffffff;
}

.infinite-sentinel {
  display: grid;
  min-height: 44px;
  place-items: center;
}

.infinite-sentinel span {
  width: 22px;
  height: 22px;
  border: 2px solid var(--line);
  border-top-color: var(--sea);
  border-radius: 999px;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.app-footer {
  display: grid;
  justify-content: stretch;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.86rem;
}

.footer-links,
.footer-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
}

.footer-links a {
  color: var(--ink);
  font-weight: 750;
  text-underline-offset: 3px;
}

.footer-meta {
  justify-content: space-between;
}

.policy-page {
  padding: clamp(18px, 3vw, 34px);
}

.policy-inner {
  display: grid;
  width: min(100%, 920px);
  gap: 18px;
  margin: 0 auto;
}

.policy-header,
.policy-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: clamp(20px, 4vw, 38px);
}

.policy-header {
  background:
    linear-gradient(135deg, rgba(8, 121, 133, 0.13), rgba(47, 107, 82, 0.08) 48%, rgba(207, 111, 98, 0.12)),
    #ffffff;
  box-shadow: var(--shadow);
}

.policy-header h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3rem);
  line-height: 1.15;
}

.policy-header p:not(.eyebrow) {
  max-width: 720px;
  margin: 12px 0 0;
  color: var(--muted);
}

.policy-content {
  display: grid;
  gap: 14px;
}

.policy-section h2 {
  margin: 0 0 12px;
  font-size: 1.3rem;
}

.policy-section p,
.policy-section ul {
  margin: 10px 0 0;
}

.policy-section a {
  color: var(--sea-dark);
  font-weight: 750;
  text-underline-offset: 3px;
}

.policy-facts {
  display: grid;
  gap: 12px;
  margin: 0;
}

.policy-facts div {
  display: grid;
  grid-template-columns: minmax(130px, 0.28fr) minmax(0, 1fr);
  gap: 16px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.policy-facts dt {
  font-weight: 850;
}

.policy-facts dd {
  margin: 0;
}

.policy-action {
  display: inline-flex;
  border-radius: 6px;
  background: var(--sea-dark);
  color: #ffffff !important;
  padding: 11px 15px;
  text-decoration: none;
}

.policy-note {
  margin-top: 18px;
  border-left: 4px solid var(--amber);
  background: #fff9ed;
  padding: 14px 16px;
}

.policy-note p {
  margin-top: 4px;
}

.record-page {
  padding: clamp(18px, 3vw, 34px);
}

.record-inner {
  display: grid;
  gap: 18px;
}

.record-nav {
  display: flex;
}

.record-hero,
.record-content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.36fr);
  gap: 18px;
  align-items: stretch;
}

.record-hero:not(.record-hero-with-media) {
  grid-template-columns: 1fr;
}

.record-hero-copy {
  display: grid;
  align-content: center;
  min-height: 260px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(8, 121, 133, 0.13), rgba(47, 107, 82, 0.08) 48%, rgba(207, 111, 98, 0.12)),
    #ffffff;
  padding: clamp(20px, 4vw, 44px);
  box-shadow: var(--shadow);
}

.record-hero-copy h1,
.missing-record h1 {
  margin: 0;
  font-size: 2.7rem;
  line-height: 1.12;
  letter-spacing: 0;
}

.record-hero-copy p:not(.eyebrow),
.missing-record p:not(.eyebrow) {
  max-width: 760px;
  margin: 12px 0 0;
  color: var(--muted);
}

.record-facts {
  box-shadow: var(--shadow);
}

.record-media-panel {
  display: grid;
  align-content: start;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 14px;
  box-shadow: var(--shadow);
}

.record-media-frame {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #dcebe8;
}

.record-media-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.record-media-panel .image-credit {
  border: 0;
  padding: 0;
}

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

.section-heading-row h2 {
  margin: 0;
}

.section-heading-row span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 900;
}

.section-note {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.7;
}

.creature-tile-grid,
.spot-tile-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.creature-tile,
.spot-tile {
  display: grid;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.creature-tile-main,
.spot-tile-main {
  display: grid;
  color: inherit;
  text-decoration: none;
}

.creature-tile-media,
.spot-tile-media {
  width: 100%;
  aspect-ratio: 4 / 3;
  margin: 0;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
  background: #dcebe8;
}

.creature-tile-media img,
.spot-tile-media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.creature-tile-body,
.spot-tile-body {
  display: grid;
  gap: 6px;
  padding: 12px;
}

.creature-tile-body h3,
.spot-tile-body h3 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.35;
}

.creature-tile-body span,
.spot-tile-body span {
  color: var(--sea-dark);
  font-size: 0.82rem;
  font-weight: 900;
}

.creature-tile .image-credit,
.spot-tile .image-credit {
  min-height: 40px;
}

.relation-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.missing-record {
  max-width: 720px;
  padding: 28px;
}

@media (max-width: 1060px) {
  .search-panel,
  .search-controls,
  .results-shell,
  .record-hero,
  .record-content-grid {
    grid-template-columns: 1fr;
  }

  .results-shell {
    min-height: auto;
  }

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

  .creature-tile-grid,
  .spot-tile-grid,
  .relation-grid,
  .area-link-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .app-header,
  .footer-meta {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .policy-facts div {
    grid-template-columns: 1fr;
    gap: 3px;
  }

  .data-counts {
    justify-content: flex-start;
  }

  .mode-control {
    grid-template-columns: 1fr;
  }

  .mode-button {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .mode-button:last-child {
    border-bottom: 0;
  }

  .fact-grid div {
    grid-template-columns: 1fr;
    gap: 3px;
  }

  .result-list,
  .creature-tile-grid,
  .spot-tile-grid,
  .relation-grid,
  .area-link-grid {
    grid-template-columns: 1fr;
  }

  .result-card[data-type="spot"].has-media .result-card-button {
    grid-template-columns: 1fr;
  }

  .result-card[data-type="spot"].has-media .result-card-media {
    aspect-ratio: 16 / 9;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .section-heading-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .record-hero-copy {
    min-height: 0;
  }

  .record-hero-copy h1,
  .missing-record h1 {
    font-size: 2rem;
  }
}
