:root {
  color-scheme: light;
  --ink: #102f35;
  --muted: #5a7276;
  --deep: #063b4b;
  --deep-2: #07566a;
  --teal: #087f83;
  --sea: #16a5a3;
  --foam: #edf8f5;
  --sand: #f4efe4;
  --coral: #ef805d;
  --line: #d4e4df;
  --white: #fff;
  --shadow: 0 18px 44px rgba(8, 54, 63, 0.12);
  --radius: 24px;
  --max-width: 1240px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 280px;
  background: #f8fbf9;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Hiragino Kaku Gothic ProN", "Yu Gothic", "Noto Sans TC", sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body.dialog-open {
  overflow: hidden;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

img {
  display: block;
  max-width: 100%;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 8px;
  left: 8px;
  transform: translateY(-160%);
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--white);
  color: var(--deep);
  font-weight: 700;
}

.skip-link:focus {
  transform: translateY(0);
}

:focus-visible {
  outline: 3px solid #ffb34d;
  outline-offset: 3px;
}

.site-header {
  position: sticky;
  z-index: 50;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 10px max(20px, calc((100vw - var(--max-width)) / 2));
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(6, 59, 75, 0.93);
  color: var(--white);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  gap: 11px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: var(--coral);
}

.brand-mark svg {
  width: 31px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.5;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.23rem;
  letter-spacing: 0.01em;
  line-height: 1.05;
}

.brand small {
  margin-top: 2px;
  color: #b9dbdc;
  font-size: 0.69rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.about-button {
  display: inline-flex;
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  background: transparent;
  color: #d9efed;
  cursor: pointer;
  font-weight: 700;
}

.about-button > span:first-child {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border: 1px solid currentColor;
  border-radius: 50%;
  font-family: Georgia, serif;
  font-style: italic;
}

.eyebrow {
  margin: 0 0 14px;
  color: #8de1d6;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.19em;
  text-transform: uppercase;
}

.eyebrow.dark {
  color: var(--teal);
}

h2,
h3,
p {
  overflow-wrap: break-word;
}

h2 {
  font-family: Georgia, "Times New Roman", "Yu Mincho", serif;
  font-weight: 500;
  letter-spacing: -0.035em;
}

.explorer {
  width: min(calc(100% - 40px), var(--max-width));
  margin: 0 auto;
  padding: 54px 0 90px;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
}

.section-heading h2 {
  margin: 0;
  font-size: clamp(2.05rem, 4vw, 3.4rem);
  line-height: 1;
}

.language-control {
  display: flex;
  align-items: center;
  gap: 12px;
}

.language-control > span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.segmented-control {
  display: flex;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--white);
}

.segmented-control button {
  min-width: 46px;
  min-height: 44px;
  padding: 6px 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 800;
}

.segmented-control button[aria-pressed="true"] {
  background: var(--deep);
  color: var(--white);
  box-shadow: 0 5px 12px rgba(6, 59, 75, 0.2);
}

.filter-panel {
  display: grid;
  grid-template-columns: minmax(270px, 0.9fr) minmax(0, 1.6fr);
  gap: 20px;
  align-items: center;
  margin-top: 34px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 10px 35px rgba(10, 67, 74, 0.06);
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-box svg {
  position: absolute;
  left: 14px;
  width: 21px;
  fill: none;
  stroke: var(--teal);
  stroke-linecap: round;
  stroke-width: 1.8;
}

.search-box input {
  width: 100%;
  min-height: 48px;
  padding: 10px 46px 10px 45px;
  border: 1px solid #c8ddda;
  border-radius: 13px;
  background: var(--foam);
  color: var(--ink);
  outline: 0;
}

.search-box input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(8, 127, 131, 0.13);
}

.search-box input::placeholder {
  color: #6c8587;
}

.search-box kbd {
  position: absolute;
  right: 12px;
  padding: 2px 7px;
  border: 1px solid #c4d8d5;
  border-radius: 5px;
  background: #fff;
  color: #789092;
  font-family: inherit;
  font-size: 0.72rem;
}

.category-scroll {
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.category-scroll::-webkit-scrollbar {
  display: none;
}

.category-chips {
  display: flex;
  width: max-content;
  gap: 7px;
}

.category-chips button {
  min-height: 42px;
  padding: 8px 15px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.81rem;
  font-weight: 800;
  white-space: nowrap;
}

.category-chips button[aria-pressed="true"] {
  border-color: #9ccbc6;
  background: #dff2ee;
  color: #05666a;
}

.chip-count {
  margin-left: 5px;
  opacity: 0.68;
  font-size: 0.7rem;
}

.results-meta {
  display: flex;
  min-height: 52px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.results-meta p {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.results-meta button {
  border: 0;
  background: transparent;
  color: var(--teal);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
}

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

.species-card {
  position: relative;
  overflow: hidden;
  min-width: 0;
  border: 1px solid #d8e7e3;
  border-radius: var(--radius);
  background: var(--white);
  box-shadow: 0 8px 25px rgba(9, 63, 69, 0.07);
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.species-card:hover {
  transform: translateY(-5px);
  border-color: #a8cec8;
  box-shadow: var(--shadow);
}

.card-button {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-align: left;
}

.card-image {
  position: relative;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  background:
    linear-gradient(110deg, transparent 35%, rgba(255, 255, 255, 0.28) 50%, transparent 65%),
    #cce3df;
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}

.card-image.loaded {
  animation: none;
}

.card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 500ms ease;
}

.species-card:hover .card-image img {
  transform: scale(1.035);
}

.card-category {
  position: absolute;
  right: 13px;
  bottom: 13px;
  padding: 6px 10px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  background: rgba(4, 43, 53, 0.76);
  color: var(--white);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  backdrop-filter: blur(9px);
}

.card-content {
  padding: 21px 21px 19px;
}

.name-row {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
}

.name-row h3 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.42rem;
  font-weight: 500;
  line-height: 1.08;
}

.card-arrow {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: var(--foam);
  color: var(--teal);
}

.card-arrow svg {
  width: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.local-names {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin: 8px 0 0;
  color: #42666a;
  font-size: 0.81rem;
  font-weight: 700;
}

.local-names span + span::before {
  margin-right: 10px;
  color: #b2c8c5;
  content: "·";
}

.card-summary {
  min-height: 3.9em;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 0.89rem;
  line-height: 1.48;
}

.scientific-name {
  margin: 17px 0 0;
  padding-top: 14px;
  border-top: 1px solid #edf2f0;
  color: #799092;
  font-family: Georgia, serif;
  font-size: 0.77rem;
  font-style: italic;
}

.empty-state {
  padding: 55px 20px 70px;
  text-align: center;
}

.empty-state > span {
  display: inline-grid;
  width: 82px;
  height: 82px;
  place-items: center;
  border-radius: 50%;
  background: #e4f3ef;
  color: var(--teal);
}

.empty-state svg {
  width: 52px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.empty-state h3 {
  margin: 19px 0 5px;
  font-family: Georgia, serif;
  font-size: 1.55rem;
}

.empty-state p {
  margin: 0;
  color: var(--muted);
}

.empty-state button,
.primary-button {
  min-height: 46px;
  margin-top: 20px;
  padding: 10px 18px;
  border: 0;
  border-radius: 999px;
  background: var(--deep);
  color: var(--white);
  cursor: pointer;
  font-weight: 800;
}

footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 30px;
  padding: 34px max(20px, calc((100vw - var(--max-width)) / 2));
  background: var(--deep);
  color: #c6dedc;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark.small {
  width: 38px;
  height: 38px;
}

.footer-brand strong,
.footer-brand span {
  display: block;
}

.footer-brand strong {
  color: var(--white);
  font-family: Georgia, serif;
  font-weight: 500;
}

.footer-brand span {
  color: #8ebcba;
  font-size: 0.72rem;
}

footer > p {
  margin: 0;
  font-size: 0.78rem;
}

dialog {
  max-width: none;
  max-height: none;
  padding: 0;
  border: 0;
  background: transparent;
}

dialog::backdrop {
  background: rgba(2, 28, 34, 0.72);
  backdrop-filter: blur(5px);
}

.species-dialog {
  width: min(100% - 32px, 990px);
  overflow: visible;
}

.dialog-shell {
  position: relative;
  overflow: hidden;
  max-height: min(88vh, 820px);
  border-radius: 28px;
  background: var(--white);
  box-shadow: 0 30px 80px rgba(0, 20, 25, 0.35);
}

.dialog-close {
  position: absolute;
  z-index: 5;
  top: 16px;
  right: 16px;
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 50%;
  background: rgba(3, 33, 40, 0.68);
  color: var(--white);
  cursor: pointer;
  backdrop-filter: blur(8px);
}

.dialog-close svg {
  width: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 2;
}

.dialog-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.02fr) minmax(330px, 0.98fr);
  max-height: inherit;
}

.dialog-media {
  position: relative;
  min-height: 600px;
  background: #bddbd5;
}

.dialog-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-credit {
  position: absolute;
  right: 14px;
  bottom: 14px;
  left: 14px;
  width: fit-content;
  min-height: 44px;
  max-width: calc(100% - 28px);
  padding: 7px 10px;
  border-radius: 8px;
  background: rgba(2, 27, 32, 0.72);
  color: #eef8f6;
  font-size: 0.66rem;
  line-height: 1.35;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  backdrop-filter: blur(8px);
}

.photo-credit:hover {
  text-decoration: underline;
}

.dialog-copy {
  overflow-y: auto;
  padding: 45px 38px 40px;
}

.dialog-category {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 12px;
  color: var(--teal);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.dialog-category::before {
  width: 18px;
  height: 1px;
  background: currentColor;
  content: "";
}

.dialog-copy h2 {
  margin: 0;
  font-size: clamp(2.35rem, 5vw, 3.8rem);
  line-height: 0.98;
}

.dialog-local-names {
  margin: 12px 0 0;
  color: #356166;
  font-size: 0.93rem;
  font-weight: 700;
}

.dialog-scientific {
  margin: 5px 0 0;
  color: #7a9192;
  font-family: Georgia, serif;
  font-size: 0.88rem;
  font-style: italic;
}

.dialog-description {
  margin: 24px 0 0;
  color: #34565a;
  font-size: 0.98rem;
  line-height: 1.72;
}

.fact-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  margin: 28px 0 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--line);
}

.fact {
  min-height: 94px;
  padding: 15px;
  background: #f7fbf9;
}

.fact span {
  display: block;
  color: #7a9191;
  font-size: 0.66rem;
  font-weight: 850;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.fact strong {
  display: block;
  margin-top: 6px;
  font-size: 0.9rem;
  line-height: 1.35;
}

.conservation-note {
  margin: 16px 0 0;
  padding: 12px 14px;
  border-left: 3px solid var(--coral);
  background: #fff6ef;
  color: #695b50;
  font-size: 0.78rem;
  line-height: 1.45;
}

.about-dialog {
  width: min(100% - 32px, 620px);
}

.about-shell {
  position: relative;
  padding: 48px;
  border-radius: 26px;
  background: var(--white);
  box-shadow: 0 30px 80px rgba(0, 20, 25, 0.35);
}

.about-shell h2 {
  max-width: 500px;
  margin: 0 0 22px;
  font-size: clamp(2.1rem, 6vw, 3.4rem);
  line-height: 1;
}

.about-shell > p:not(.eyebrow) {
  color: var(--muted);
}

.dark-close {
  border-color: var(--line);
  background: var(--foam);
  color: var(--deep);
}

.noscript-message {
  position: fixed;
  z-index: 2000;
  right: 16px;
  bottom: 16px;
  left: 16px;
  padding: 15px;
  border-radius: 12px;
  background: #792e20;
  color: white;
  text-align: center;
}

@keyframes shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

@media (min-width: 1240px) {
  .species-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .card-content {
    padding-right: 19px;
    padding-left: 19px;
  }
}

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

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

  .dialog-grid {
    grid-template-columns: 1fr 1fr;
  }

  .dialog-copy {
    padding: 40px 28px 34px;
  }
}

@media (max-width: 640px) {
  .site-header {
    min-height: 64px;
    padding-right: 16px;
    padding-left: 16px;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
  }

  .brand strong {
    font-size: 1.08rem;
  }

  .brand small,
  .about-label {
    display: none;
  }

  .explorer {
    width: min(calc(100% - 28px), var(--max-width));
    padding-top: 32px;
  }

  .section-heading {
    display: block;
  }

  .language-control {
    justify-content: space-between;
    margin-top: 24px;
  }

  .filter-panel {
    position: sticky;
    z-index: 20;
    top: 72px;
    gap: 10px;
    margin-right: -7px;
    margin-left: -7px;
    padding: 9px;
    border-radius: 17px;
  }

  .search-box kbd {
    display: none;
  }

  .search-box input {
    padding-right: 14px;
  }

  .category-chips button {
    min-height: 44px;
    padding: 7px 13px;
  }

  .species-grid {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .card-image {
    aspect-ratio: 16 / 10;
  }

  .card-summary {
    min-height: 0;
  }

  footer {
    display: block;
    padding-top: 30px;
    padding-bottom: 30px;
  }

  footer > p {
    margin-top: 22px;
  }

  .species-dialog {
    width: 100%;
    max-height: 94dvh;
    margin: auto 0 0;
  }

  .dialog-shell {
    overflow-y: auto;
    max-height: 94dvh;
    border-radius: 25px 25px 0 0;
  }

  .dialog-shell::before {
    position: absolute;
    z-index: 4;
    top: 8px;
    left: 50%;
    width: 42px;
    height: 4px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.68);
    content: "";
    transform: translateX(-50%);
  }

  .dialog-grid {
    display: block;
    max-height: none;
  }

  .dialog-media {
    min-height: 0;
    aspect-ratio: 4 / 3;
  }

  .dialog-copy {
    overflow: visible;
    padding: 29px 20px 38px;
  }

  .dialog-copy h2 {
    font-size: 2.55rem;
  }

  .photo-credit {
    font-size: 0.6rem;
  }

  .fact {
    min-height: 88px;
    padding: 13px;
  }

  .about-dialog {
    width: 100%;
    margin: auto 0 0;
  }

  .about-shell {
    padding: 44px 23px 34px;
    border-radius: 25px 25px 0 0;
  }
}

@media (max-width: 340px) {
  .segmented-control button {
    min-width: 42px;
    padding-right: 9px;
    padding-left: 9px;
  }

  .language-control > span {
    font-size: 0.68rem;
  }

  .fact-grid {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
