:root {
  --sg-bg: #071426;
  --sg-bg-2: #0a1628;
  --sg-ink: #e5edf7;
  --sg-muted: #94a3b8;
  --sg-soft: #cbd5e1;
  --sg-blue: #3b82f6;
  --sg-blue-2: #60a5fa;
  --sg-green: #3f8f64;
  --sg-amber: #f59e0b;
  --sg-line: rgba(147, 197, 253, 0.18);
  --sg-line-strong: rgba(147, 197, 253, 0.32);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  background: var(--sg-bg);
}

body.species-guide-page {
  min-height: 100vh;
  margin: 0;
  padding-top: env(safe-area-inset-top);
  background: var(--sg-bg);
  color: var(--sg-ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.species-guide-hero {
  position: relative;
  display: grid;
  min-height: min(620px, calc(100dvh - var(--ara-top-nav-height, 64px)));
  overflow: hidden;
  padding: calc(var(--ara-top-nav-height, 64px) + clamp(4rem, 8vw, 7rem)) clamp(1rem, 5vw, 5rem) clamp(4rem, 8vw, 7rem);
  isolation: isolate;
}

.species-guide-hero__image,
.species-guide-hero__wash {
  position: absolute;
  inset: 0;
}

.species-guide-hero__image {
  z-index: -3;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.species-guide-hero__wash {
  z-index: -2;
  background: rgba(4, 12, 24, 0.62);
}

.species-guide-hero__content {
  align-self: end;
  width: min(1520px, 100%);
  margin: 0 auto;
}

.sg-eyebrow {
  margin: 0 0 0.75rem;
  color: #dbeafe;
  font-size: 0.75rem;
  font-weight: 850;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.sg-title {
  max-width: 820px;
  margin: 0;
  color: #fff;
  font-size: clamp(3.25rem, 9vw, 7.4rem);
  font-weight: 950;
  line-height: 0.9;
  letter-spacing: 0;
}

.species-guide-hero__lead {
  max-width: 640px;
  margin: 1.25rem 0 0;
  color: rgba(239, 246, 255, 0.9);
  font-size: clamp(1.08rem, 1.6vw, 1.32rem);
  line-height: 1.55;
}

.species-guide-main {
  width: min(1520px, calc(100% - clamp(32px, 5vw, 88px)));
  margin: 0 auto;
  padding: clamp(2rem, 5vw, 4rem) 0 clamp(5rem, 8vw, 7rem);
}

.species-guide-intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 420px);
  gap: clamp(1.5rem, 4vw, 3rem);
  align-items: start;
  margin-bottom: clamp(2.5rem, 5vw, 4rem);
  border-bottom: 1px solid var(--sg-line);
  padding-bottom: clamp(2rem, 4vw, 3rem);
}

.species-guide-intro h2 {
  max-width: 740px;
  margin: 0;
  color: #fff;
  font-size: clamp(1.9rem, 3vw, 3rem);
  font-weight: 925;
  line-height: 1.05;
  letter-spacing: 0;
}

.species-guide-intro p:not(.sg-eyebrow) {
  max-width: 760px;
  margin: 1rem 0 0;
  color: var(--sg-soft);
  font-size: 1rem;
  line-height: 1.75;
}

.species-guide-toc {
  display: grid;
  gap: 0.75rem;
}

.species-guide-toc a {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  min-height: 58px;
  border: 1px solid rgba(96, 165, 250, 0.42);
  border-radius: 10px;
  background: rgba(37, 99, 235, 0.2);
  color: #f8fafc;
  padding: 0.8rem 1rem;
  font-size: 0.94rem;
  font-weight: 850;
  text-decoration: none;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.species-guide-toc a:nth-child(2) {
  border-color: rgba(52, 211, 153, 0.42);
  background: rgba(16, 185, 129, 0.2);
}

.species-guide-toc a:nth-child(3) {
  border-color: rgba(245, 158, 11, 0.48);
  background: rgba(245, 158, 11, 0.2);
}

.species-guide-toc strong {
  flex: 1;
}

.species-guide-toc a:hover,
.species-guide-toc a:focus-visible {
  border-color: rgba(96, 165, 250, 0.72);
  background: rgba(37, 99, 235, 0.3);
  outline: none;
  transform: translateY(-2px);
}

.species-guide-toc a:nth-child(2):hover,
.species-guide-toc a:nth-child(2):focus-visible {
  border-color: rgba(63, 143, 100, 0.75);
  background: rgba(16, 185, 129, 0.3);
}

.species-guide-toc a:nth-child(3):hover,
.species-guide-toc a:nth-child(3):focus-visible {
  border-color: rgba(245, 158, 11, 0.75);
  background: rgba(245, 158, 11, 0.3);
}

.species-guide-toc .material-symbols-rounded {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 999px;
  background: rgba(96, 165, 250, 0.16);
  color: #bfdbfe;
  font-size: 1.25rem;
}

.species-guide-toc a:nth-child(2) .material-symbols-rounded {
  background: rgba(63, 143, 100, 0.18);
  color: #bbf7d0;
}

.species-guide-toc a:nth-child(3) .material-symbols-rounded {
  background: rgba(245, 158, 11, 0.16);
  color: #fde68a;
}

.species-guide-toc .species-guide-toc__arrow {
  width: 34px;
  height: 34px;
  margin-left: auto;
  background: rgba(219, 234, 254, 0.14);
  color: #eff6ff;
  font-size: 1.05rem;
  transition: transform 0.18s ease, background 0.18s ease;
}

.species-guide-toc a:hover .species-guide-toc__arrow,
.species-guide-toc a:focus-visible .species-guide-toc__arrow {
  background: rgba(255, 255, 255, 0.22);
  transform: translateX(3px);
}

.species-search-shell {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  min-height: 58px;
  border: 1px solid var(--sg-line-strong);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.045);
  padding: 0 1rem;
}

.species-search-shell .material-symbols-rounded {
  color: #93c5fd;
  font-size: 1.3rem;
}

.search-input {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--sg-ink);
  font: inherit;
  font-size: 1rem;
}

.search-input:focus {
  outline: none;
}

.search-input::placeholder {
  color: #64748b;
}

.species-group-section {
  scroll-margin-top: calc(var(--ara-top-nav-height, 64px) + 1rem);
  margin-bottom: clamp(2.5rem, 5vw, 4rem);
}

.species-group-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--sg-line);
  padding-bottom: 0.75rem;
}

.species-group-title {
  margin: 0;
  color: #fff;
  font-size: clamp(1.4rem, 2vw, 2rem);
  font-weight: 900;
  letter-spacing: 0;
}

.species-group-subtitle {
  margin: 0;
  color: var(--sg-muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.species-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
  gap: 1rem;
}

.species-explorer-card {
  display: block;
  min-width: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.035);
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.species-explorer-card:hover,
.species-explorer-card:focus-visible {
  border-color: rgba(96, 165, 250, 0.44);
  background: rgba(255, 255, 255, 0.055);
  outline: none;
  transform: translateY(-2px);
}

.species-explorer-card:active {
  transform: translateY(0);
}

.species-explorer-card-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.species-explorer-content {
  flex: 1;
  padding: 1rem 1rem 0;
}

.species-explorer-card__media {
  height: 132px;
  overflow: hidden;
  background: #071426;
}

.species-explorer-card__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.45s ease;
}

.species-explorer-card:hover .species-explorer-card__media img,
.species-explorer-card:focus-visible .species-explorer-card__media img {
  transform: scale(1.045);
}

.species-explorer-card__fallback {
  display: grid;
  width: 100%;
  height: 100%;
  gap: 0.4rem;
  place-items: center;
  align-content: center;
  border: 1px dashed rgba(147, 197, 253, 0.24);
  background: #071426;
  color: rgba(147, 197, 253, 0.35);
}

.species-explorer-card__fallback .material-symbols-rounded {
  font-size: 2.4rem;
}

.species-explorer-card__fallback small {
  color: rgba(219, 234, 254, 0.64);
  font-size: 0.68rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.species-explorer-name {
  margin: 0;
  color: #f8fafc;
  font-size: 1.04rem;
  font-weight: 850;
  line-height: 1.22;
}

.species-explorer-sci {
  margin: 0.35rem 0 0;
  color: var(--sg-muted);
  font-size: 0.84rem;
  font-style: italic;
}

.species-explorer-meta-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.species-explorer-tree-count {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  border: 1px solid rgba(96, 165, 250, 0.24);
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.12);
  color: #bfdbfe;
  padding: 0.35rem 0.55rem;
  font-size: 0.74rem;
  font-weight: 750;
}

.species-explorer-tree-count .material-symbols-rounded {
  font-size: 0.95rem;
}

.species-explorer-arrow {
  margin-left: auto;
  color: #64748b;
  font-size: 1.3rem;
  transition: color 0.2s ease, transform 0.2s ease;
}

.species-explorer-summary {
  display: -webkit-box;
  margin: 0.75rem 0 0;
  overflow: hidden;
  color: #7f8fa3;
  font-size: 0.86rem;
  line-height: 1.58;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.species-explorer-card:hover .species-explorer-arrow,
.species-explorer-card:focus-visible .species-explorer-arrow {
  color: var(--sg-blue-2);
  transform: translateX(3px);
}

@media (max-width: 1120px) {
  .species-card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.status-message {
  padding: 3rem 1rem;
  color: #64748b;
  font-size: 0.9rem;
  text-align: center;
}

@media (max-width: 760px) {
  .species-guide-hero {
    min-height: 520px;
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .species-guide-hero__wash {
    background: rgba(4, 12, 24, 0.68);
  }

  .species-guide-intro {
    display: block;
  }

  .species-guide-toc {
    margin-top: 1.3rem;
  }

  .species-search-shell {
    margin-top: 1.3rem;
  }

  .species-group-header {
    display: block;
  }

  .species-group-subtitle {
    margin-top: 0.35rem;
  }

  .species-card-grid {
    grid-template-columns: 1fr;
  }

  .species-explorer-card__media {
    height: 116px;
  }
}
