:root {
  color-scheme: light;
  --bg: #f8f6e8;
  --paper: #fffdf6;
  --ink: #152f30;
  --muted: #445b55;
  --dark: #113838;
  --lime: #e3efa8;
  --line: #ccd9cd;
  --heading: Georgia, "Times New Roman", serif;
  --sans: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --wrap: 1240px;
  --pad: clamp(20px, 4vw, 56px);
  --nav-offset: 88px;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: var(--nav-offset); }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.58 var(--sans); }
[hidden] { display: none !important; }
img { display: block; max-width: 100%; }
button, input { font: inherit; }
button:enabled { cursor: pointer; }
button:disabled { opacity: .58; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-underline-offset: .25em; }
:is(a, button, input, summary):focus-visible { outline: 3px solid #347a54; outline-offset: 4px; }
:is(h1, h2, h3, h4, p, figure) { margin: 0; }
h1, h2, .paper-card h3 { font-family: var(--heading); font-weight: 400; }
h2 { font-size: clamp(2.4rem, 5vw, 4rem); line-height: 1.03; letter-spacing: -.055em; }
h3 { line-height: 1.25; }
.wrap { width: min(var(--wrap), 100% - var(--pad) * 2); margin-inline: auto; }
.sr-only, .skip:not(:focus) {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.skip:focus { position: fixed; top: 10px; left: 10px; z-index: 20; background: var(--paper); padding: 10px 18px; border-radius: 8px; }
.anchor-alias { position: absolute; top: 0; left: 0; }
#main, .section, .hero, .site-footer { position: relative; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.header-inner { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.brand { display: inline-flex; gap: 10px; align-items: center; font-size: 1.3rem; font-weight: 750; letter-spacing: -.045em; text-decoration: none; }
.brand-mark { display: grid; place-items: center; flex: 0 0 35px; width: 35px; height: 35px; border-radius: 50%; background: var(--lime); }
.brand-mark img { object-fit: contain; }
.site-nav, .footer-inner nav { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.site-nav a, .header-support, .back-top, .footer-inner nav a {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  border-radius: 8px;
  padding: 6px 12px;
  text-decoration: none;
  font-size: .89rem;
  font-weight: 650;
}
.site-nav a { color: var(--muted); }
.site-nav a:hover, .site-nav a[aria-current], .footer-inner nav a:hover { background: #e2ecdf; color: var(--ink); }
.header-support { border: 1px solid #aebfb2; white-space: nowrap; }
.header-support:hover, .header-support[aria-current], .back-top:hover { background: #e2ecdf; }

.hero { padding-top: clamp(16px, 3vw, 36px); }
.hero-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  align-items: center;
  gap: clamp(22px, 3.5vw, 54px);
  padding: clamp(25px, 3.5vw, 54px);
  overflow: hidden;
  border-radius: 24px;
  background:
    repeating-radial-gradient(ellipse at 2% 110%, transparent 0 24px, #dcefb011 25px 26px, transparent 27px 43px),
    linear-gradient(125deg, #102e32, #174843);
  color: #fffdf2;
}
.hero-figure { align-self: stretch; display: grid; grid-template-rows: 1fr auto; min-width: 0; min-height: 0; overflow: hidden; border: 1px solid #fcf8df66; border-radius: 12px; background: #132d29; }
.hero-figure img { width: 100%; height: 100%; min-height: 270px; max-height: 440px; object-fit: cover; object-position: center; }
.hero-figure figcaption { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 1px 14px; padding: 10px 14px; background: #f3edcf; color: var(--ink); font-size: .88rem; }
.hero-figure figcaption i { color: var(--muted); }
.eyebrow { color: #315746; font-size: .76rem; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; }
.hero .eyebrow, .support-panel .eyebrow { color: var(--lime); }
.hero h1 { margin-top: 15px; max-width: 11ch; font-size: clamp(3rem, 5.4vw, 5.45rem); line-height: 1; letter-spacing: -.065em; }
.hero h1 em { font-weight: inherit; color: var(--lime); }
.hero-intro { max-width: 40ch; margin-top: 18px; color: #e4eee3; font-size: clamp(1rem, 1.4vw, 1.12rem); }
.actions { display: flex; gap: 12px 24px; flex-wrap: wrap; align-items: center; margin-top: 28px; }
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  min-height: 46px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: 9px;
  font-weight: 700;
  line-height: 1.3;
  text-decoration: none;
  transition: background-color .18s ease, color .18s ease;
}
.button-lime { background: var(--lime); color: var(--dark); }
.button-lime:hover { background: #edf7b3; }
.button-dark { background: var(--dark); color: #fff; }
.button-dark:enabled:hover { background: #27523c; }
.button-outline { border-color: #9eb4a0; }
.button-outline:hover { background: #e7efdf; }
.hero-link { display: inline-flex; gap: 8px; align-items: center; min-height: 44px; font-weight: 650; color: #eef5e5; }
.hero-link:hover { color: var(--lime); }
.hero a:focus-visible, .support-panel :is(a, button):focus-visible { outline-color: var(--lime); }

.section { padding-block: clamp(46px, 6vw, 86px); }
.section-heading { display: grid; gap: 12px; align-content: start; }
.section-heading > p:not(.eyebrow), .gallery-heading > div > p:not(.eyebrow) { max-width: 58ch; color: var(--muted); font-size: 1.04rem; }
.panel, .species-card, .paper-card { border: 1px solid var(--line); border-radius: 16px; background: var(--paper); }
.identify-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); align-items: start; gap: 18px; margin-top: 28px; }
.upload-panel, .results-panel { padding: clamp(15px, 2.4vw, 26px); }
.drop-area {
  display: grid;
  place-items: center;
  gap: 9px;
  padding: clamp(22px, 5vw, 44px) 15px;
  border: 1.5px dashed #7e9c92;
  border-radius: 12px;
  text-align: center;
  background: #eaf3ea;
  transition: background-color .18s;
}
.drop-area.is-dragging { background: #e5f4c9; border-color: #426d4e; }
.upload-mark { display: grid; place-items: center; width: 50px; height: 50px; margin-bottom: 3px; border-radius: 50%; background: #d1e5d7; }
.upload-mark img { object-fit: contain; }
.drop-area p, .photo-preview figcaption, .upload-footer a, .score-note, .results-empty { color: var(--muted); }
.drop-area p, .upload-footer, .feedback { font-size: .91rem; }
.drop-area button { margin-top: 5px; }
.drop-hint { display: none; }
@media (pointer: fine) {
  .drop-hint { display: block; }
}
.text-button { border: 0; border-radius: 4px; padding: 0; background: none; color: inherit; font-weight: 650; line-height: 1.4; text-align: left; text-decoration: underline; text-underline-offset: .24em; }
.text-button:enabled:hover { color: #27623e; }
.upload-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px 16px; flex-wrap: wrap; margin-top: 12px; }
.upload-footer a, .upload-footer button { display: inline-flex; align-items: center; gap: 5px; min-height: 28px; }
.results-panel h3 { font-size: 1.25rem; }
.results-empty > p { margin-top: 7px; }
.photo-tips { margin-top: 22px; padding: 16px; border-radius: 11px; background: #f3f6ed; font-size: .92rem; }
.photo-tips h4 { color: var(--ink); font-size: inherit; }
.photo-tips ul { margin: 7px 0 0; padding-left: 18px; }
.photo-tips li + li { margin-top: 4px; }
.notice, .feedback:not(:empty) { margin-top: 12px; }
.feedback.error { color: #942f27; }
.photo-preview { display: grid; justify-items: center; gap: 7px; padding: 10px; border-radius: 11px; background: #eef2e8; }
.photo-preview :is(img, canvas) { display: block; width: auto; height: auto; max-width: 100%; max-height: 340px; border-radius: 6px; object-fit: contain; }
.photo-preview canvas { width: min(100%, 340px); aspect-ratio: 1; touch-action: none; cursor: grab; }
.photo-preview canvas:active { cursor: grabbing; }
.photo-preview figcaption { max-width: 100%; overflow-wrap: anywhere; font-size: .83rem; }
#crop-controls { display: grid; gap: 5px; margin: 15px 0 0; padding: 7px 12px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: .88rem; }
#crop-controls legend { padding-inline: 5px; font-weight: 700; }
#crop-controls label { display: grid; grid-template-columns: 90px minmax(0, 1fr); gap: 10px; align-items: center; min-height: 32px; }
#crop-controls p { color: var(--muted); margin-bottom: 3px; }
#crop-controls input { width: 100%; margin: 0; accent-color: #2e6949; }
.editor-tools { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-block: 10px 14px; }
.editor-tools button { min-height: 34px; font-size: .88rem; }
.analyze-button { width: 100%; }
.match-list { display: grid; gap: 8px; margin: 14px 0 0; padding-left: 22px; }
.match-list li { padding: 8px 12px; border-radius: 8px; background: #f3f6ed; }
.match-list li:first-child { background: #e8f3c9; }
.match-list li > div { display: flex; gap: 6px 12px; align-items: baseline; justify-content: space-between; flex-wrap: wrap; }
.match-list li:first-child i { font-weight: 700; }
.match-list li span { font-size: .83rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.score-note { margin-top: 12px; font-size: .83rem; }

.gallery-section { background: #e5eee4; border-block: 1px solid var(--line); }
.gallery-heading { grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 20px; }
.gallery-heading > div { display: grid; gap: 12px; }
.filters { min-inline-size: 0; display: flex; gap: 4px; flex-wrap: wrap; border: 1px solid #c5d3c4; border-radius: 28px; padding: 4px; margin: 0; background: #f9fbf5; }
.filters label { position: relative; cursor: pointer; }
.filters input { position: absolute; top: 4px; left: 8px; width: 1px; height: 1px; opacity: 0; }
.filters span { display: flex; min-height: 40px; align-items: center; border-radius: 24px; padding: 0 13px; font-weight: 650; font-size: .83rem; }
.filters input:checked + span { background: var(--dark); color: #fff; }
.filters input:focus-visible + span { outline: 3px solid #347a54; outline-offset: 2px; }
.filters label:hover input:not(:checked) + span { background: #e9eee2; }
.species-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 17px; margin-top: 26px; }
.species-card { display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.species-card > img { width: 100%; height: auto; aspect-ratio: 16/10; object-fit: cover; background: #253628; }
.species-content { flex: 1; display: flex; flex-direction: column; gap: 7px; padding: 16px; }
.species-content > p:not(.species-group) { color: var(--muted); font-size: .92rem; }
.species-content .scientific { margin-top: -6px; }
.species-group {
  align-self: start;
  padding: 2px 8px;
  border-radius: 5px;
  background: #f2e8c9;
  color: #554622;
  font-size: .72rem;
  letter-spacing: .07em;
  font-weight: 750;
  text-transform: uppercase;
}
.species-card[data-group="damselfly"] .species-group { background: #ddecdf; color: #244b3e; }
.card-links { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; margin-top: auto; padding-top: 8px; font-size: .84rem; }
.card-links a, .card-links button { display: inline-flex; align-items: center; min-height: 35px; gap: 4px; font-weight: 650; }
.card-links a:hover { color: #27623e; }
.field-grid, .research-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.field-grid { margin-top: 24px; }
.guide-card { display: flex; flex-direction: column; overflow: hidden; }
.guide-card > img { width: 100%; height: auto; aspect-ratio: 2.45; object-fit: cover; object-position: 50% 43%; }
.guide-content, .paper-card { padding: clamp(17px, 3vw, 28px); }
.guide-content { display: grid; grid-template-rows: auto 1fr auto; flex: 1; }
.guide-content a { justify-self: start; margin-top: 12px; font-weight: 650; }
.guide-card p, .paper-card > p:not(.eyebrow) { margin-top: 7px; color: var(--muted); }
.faq { margin-top: 34px; }
.faq h3 { margin-bottom: 10px; }
details { border-bottom: 1px solid var(--line); }
summary { display: flex; align-items: center; justify-content: space-between; gap: 15px; min-height: 50px; padding-block: 10px; font-weight: 700; cursor: pointer; list-style: none; }
summary::-webkit-details-marker { display: none; }
summary::after { content: "+"; color: #315746; font: 1.3rem/1 var(--sans); }
details[open] > summary::after { content: "−"; }
details > p { max-width: 70ch; padding-bottom: 12px; color: var(--muted); }
.research-section { background: #eef2e9; border-block: 1px solid var(--line); }
.research-grid { align-items: start; gap: 16px 36px; }
.paper-card h3 { margin-top: 8px; font-size: clamp(1.6rem, 3vw, 2.2rem); line-height: 1.1; letter-spacing: -.03em; }
.paper-card .button { margin-top: 18px; }
.credits { grid-column: 1 / -1; }
.credits strong { margin-right: 4px; }
.support-panel { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(22px, 4vw, 48px); padding: clamp(23px, 5vw, 56px); border-radius: 21px; background: var(--dark); color: #f8fcf3; }
.support-panel .section-heading > p:not(.eyebrow), .support-options p { color: #dbe8d9; }
.support-panel .button { justify-self: start; margin-top: 5px; }
.support-options { border-left: 1px solid #557163; padding-left: clamp(18px, 4vw, 35px); }
.support-options article + article { border-top: 1px solid #557163; margin-top: 16px; padding-top: 16px; }
.support-options p, .support-options a, .upi { margin-top: 6px; }
.support-options a { display: inline-block; overflow-wrap: anywhere; color: var(--lime); }
.upi { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.upi code { padding: 5px 8px; border: 1px solid #607c6d; border-radius: 6px; color: #f8fcf3; font-size: .95rem; }
.upi .text-button { color: var(--lime); min-height: 32px; }
.upi .text-button:hover { color: #f2fbc0; }
.site-footer { border-top: 1px solid var(--line); }
.footer-inner { display: flex; gap: 12px 18px; flex-wrap: wrap; align-items: center; justify-content: space-between; padding-block: 22px; }
.back-top { gap: 6px; }
.copyright { flex-basis: 100%; border-top: 1px solid var(--line); padding-top: 12px; color: var(--muted); font-size: .88rem; }
.legal { max-width: 740px; min-height: 72vh; }
.legal h1, .legal > h2:first-child { margin: 8px 0 20px; font-size: clamp(2.6rem, 8vw, 5rem); line-height: 1; letter-spacing: -.05em; }
.legal h2:not(:first-child), .legal h3 { margin: 24px 0 8px; font: 700 1.24rem/1.3 var(--sans); letter-spacing: 0; }
.legal[id^="preview-"] { min-height: 0; }
.legal p { color: var(--muted); }
.legal p + p { margin-top: 10px; }

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

@media (max-width: 720px) {
  :root { --nav-offset: 110px; }
  .header-inner { display: grid; min-height: 0; grid-template-columns: minmax(0, 1fr) auto; gap: 5px 8px; padding-block: 7px 4px; }
  .site-nav { grid-row: 2; grid-column: 1 / -1; justify-content: space-between; gap: 0; border-top: 1px solid var(--line); }
  .site-nav a { min-height: 40px; padding-inline: 8px; font-size: .8rem; }
  .header-support { min-height: 38px; padding-inline: 8px; font-size: .79rem; }
  .hero-card { grid-template-columns: minmax(0, 1fr); align-items: stretch; padding: clamp(17px, 4vw, 28px); border-radius: 19px; }
  .hero h1 { font-size: clamp(2.55rem, 9vw, 4.3rem); max-width: 15ch; margin-top: 12px; }
  .hero-intro { margin-top: 14px; }
  .actions { margin-top: 20px; gap: 6px 14px; }
  .hero-figure img { height: auto; min-height: 0; max-height: 320px; aspect-ratio: 1.65; }
  .identify-grid, .gallery-heading, .research-grid, .support-panel { grid-template-columns: minmax(0, 1fr); }
  .filters { justify-self: start; }
  .support-options { border-left: 0; border-top: 1px solid #557163; padding: 18px 0 0; }
}

@media (max-width: 485px) {
  .species-grid, .field-grid { grid-template-columns: minmax(0, 1fr); }
  .footer-inner nav { order: 1; width: 100%; justify-content: space-between; }
  .footer-inner nav a { padding-inline: 3px; }
  .copyright { order: 2; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: 0s !important; }
}
