:root {
  color-scheme: light;
  --ink: #141f1c;
  --muted: #556761;
  --line: #d3ded8;
  --paper: #f4f7f4;
  --surface: #ffffff;
  --accent: #0f6854;
  --accent-light: #e4f2ec;
  --accent-gold: #c59345;
  --shadow: 0 14px 36px rgba(20, 31, 28, 0.09);
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100vh; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  overflow-y: auto;
}
button, input, select { font: inherit; }

/* Header */
.site-header {
  background: #162a25;
  color: #f7fbf8;
  border-bottom: 4px solid var(--accent-gold);
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
}
.header-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 34px 32px 30px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
}
.header-main-title {
  max-width: 850px;
}
.header-top-right {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(247, 200, 115, 0.4);
  padding: 6px 16px 6px 8px;
  border-radius: 999px;
  backdrop-filter: blur(6px);
  box-shadow: 0 2px 10px rgba(0,0,0,0.15);
}
.brand-logo-img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  background: #ffffff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
  display: block;
}
.brand-name {
  font-family: 'Cinzel', Georgia, serif;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  color: #fff;
  text-transform: uppercase;
}

.eyebrow { margin: 0 0 8px; color: #a6cdc0; font-size: 0.76rem; font-weight: 600; letter-spacing: 0.16em; }
h1, h2, p { margin-top: 0; }
h1 {
  margin-bottom: 10px;
  font-family: 'Cinzel', Georgia, serif;
  font-size: clamp(2.2rem, 5vw, 3.8rem);
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: 0.02em;
  color: #ffffff;
}
.lede { margin: 0; color: #cae0d7; font-size: 1.05rem; line-height: 1.5; }

/* Main Shell */
.atlas-shell {
  max-width: 1440px;
  margin: 0 auto;
  padding: 28px 32px 60px;
  flex: 1;
  width: 100%;
  box-sizing: border-box;
}
.overview {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  margin-bottom: 24px;
  border-radius: 8px;
  overflow: hidden;
}
.stat { background: var(--surface); padding: 20px 22px; display: flex; flex-direction: column; gap: 6px; }
.stat strong { font-size: 1.9rem; line-height: 1; font-weight: 700; color: var(--ink); }
.stat span { color: var(--muted); font-size: 0.8rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; }
.stat-note strong { font-size: 1.15rem; color: var(--accent); padding-top: 4px; }

.controls {
  display: grid;
  grid-template-columns: minmax(260px, 1.4fr) minmax(170px, 1fr) minmax(130px, 200px);
  gap: 12px;
  align-items: center;
  margin-bottom: 32px;
}
.search-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
input, select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  padding: 0 14px;
  font-size: 0.92rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, select:focus, button:focus-visible, a:focus-visible {
  outline: 0;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 104, 84, 0.2);
}
.controls > label:not(.search-label) { color: var(--muted); font-size: 0.85rem; font-weight: 600; text-align: right; }

.results-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 20px;
}
.results-head h2 { margin-bottom: 12px; font-family: 'Cinzel', Georgia, serif; font-size: 1.35rem; color: var(--ink); }
.results-head p { margin-bottom: 12px; color: var(--muted); font-size: 0.9rem; font-weight: 500; }

.family-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px; }
.family-card {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 10px;
  overflow: hidden;
  text-align: left;
  padding: 0;
  cursor: pointer;
  color: inherit;
  box-shadow: 0 2px 8px rgba(0,0,0,0.03);
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
  display: flex;
  flex-direction: column;
  user-select: none;
}
.family-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); border-color: #8bb3a2; }
.family-card img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: #e8ece8; pointer-events: none; }
.card-copy { padding: 14px 16px 16px; display: flex; flex-direction: column; flex: 1; pointer-events: none; }
.card-order { color: var(--accent); font-size: 0.74rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 6px; }
.card-name { font-family: Georgia, "Times New Roman", serif; font-size: 1.22rem; font-weight: 600; margin-bottom: 4px; color: #111d1a; font-style: italic; }
.card-common { color: #2c473e; font-size: 0.88rem; font-weight: 500; min-height: 1.3em; margin-bottom: 8px; }
.card-species { color: var(--muted); font-size: 0.78rem; font-style: italic; margin-top: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-top: 6px; border-top: 1px dashed var(--line); }

.load-more {
  display: block;
  margin: 34px auto 0;
  min-height: 46px;
  padding: 0 28px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
  box-shadow: 0 4px 12px rgba(15, 104, 84, 0.25);
}
.load-more:hover { background: #0b4e3f; transform: translateY(-1px); }
.empty { padding: 60px 0; text-align: center; color: var(--muted); font-size: 1.1rem; }

/* Detail Dialog Modal */
.detail-dialog {
  width: min(840px, calc(100% - 32px));
  max-height: 90vh;
  margin: auto;
  border: 0;
  border-radius: 14px;
  padding: 0;
  box-shadow: 0 32px 90px rgba(0, 0, 0, 0.45);
  color: var(--ink);
  background: var(--surface);
  position: fixed;
  inset: 0;
  overflow: hidden;
  z-index: 9999;
}
.detail-dialog::backdrop {
  background: rgba(10, 18, 15, 0.75);
  backdrop-filter: blur(4px);
}
.dialog-scroll-wrap {
  max-height: 90vh;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
}
.detail-dialog img {
  display: block;
  width: 100%;
  max-height: 48vh;
  object-fit: cover;
  background: #e8ece8;
  border-bottom: 1px solid var(--line);
}
.detail-copy {
  padding: 28px 32px 34px;
}
.detail-copy h2 {
  margin-bottom: 4px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2.1rem;
  font-style: italic;
  color: #111d1a;
}
.detail-copy .common-title {
  color: var(--accent);
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 16px;
}
.detail-copy p.desc {
  line-height: 1.75;
  font-size: 1rem;
  color: #24332f;
  margin-bottom: 24px;
}
.detail-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
  font-size: 0.9rem;
}
.detail-meta div {
  background: #f8faf8;
  border: 1px solid var(--line);
  padding: 12px 14px;
  border-radius: 8px;
}
.detail-meta span {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}
.detail-meta strong {
  color: #111d1a;
}
.detail-meta a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}
.detail-meta a:hover {
  text-decoration: underline;
}

.icon-button {
  position: absolute;
  right: 16px;
  top: 16px;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: rgba(255,255,255,0.94);
  color: #1a2924;
  font-size: 1.8rem;
  line-height: 1;
  cursor: pointer;
  z-index: 20;
  box-shadow: 0 4px 14px rgba(0,0,0,0.28);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}
.icon-button:hover {
  background: #ffffff;
  transform: scale(1.08);
}

/* Site Footer */
.site-footer {
  background: #13221e;
  color: #c4d7cf;
  border-top: 1px solid rgba(255,255,255,0.08);
  padding: 36px 32px;
  margin-top: auto;
}
.footer-inner {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
}
.footer-brand {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.footer-badge {
  align-self: flex-start;
}
.footer-copy { margin: 0; font-size: 0.86rem; color: #8faea2; }
.footer-credits { font-size: 0.92rem; color: #d7eae2; }
.footer-credits p { margin: 0; }
.heart-icon { color: #e25555; display: inline-block; animation: pulse 1.6s infinite ease-in-out; }
.creator-link {
  color: #f7c873;
  text-decoration: none;
  font-weight: 600;
  border-bottom: 1px dotted rgba(247, 200, 115, 0.6);
  padding-bottom: 1px;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.creator-link:hover { color: #ffffff; border-color: #ffffff; }

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.18); }
}

@media (max-width: 768px) {
  .header-inner, .atlas-shell, .footer-inner { padding-left: 18px; padding-right: 18px; }
  .header-inner { flex-direction: column-reverse; gap: 16px; }
  .header-top-right { align-self: flex-start; }
  .overview { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .controls { grid-template-columns: 1fr; }
  .controls > label:not(.search-label) { display: none; }
  .family-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .card-copy { padding: 10px 12px 12px; }
  .card-name { font-size: 1.05rem; }
  .detail-copy { padding: 20px 18px 24px; }
  .detail-meta { grid-template-columns: 1fr; }
  .footer-inner { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 480px) {
  .family-grid { grid-template-columns: 1fr; }
}
