  /* ───────── palette + type: antique botanical plate ───────── */
  :root {
    --parchment: #efe5cf;      /* panel paper */
    --parchment-hi: #f7f0de;   /* card paper, a shade lighter */
    --parchment-lo: #e4d6b6;   /* aged edges */
    --ink: #2e2419;            /* brown-black printing ink */
    --ink-soft: #5e5040;
    --ink-faint: #8f7f66;      /* hairline rules */

    --native-ink: #4f6233;     /* botanical green */
    --introduced-ink: #8a5a1c; /* ochre */
    --unknown-ink: #7a6d5a;
    --risk-ink: #8e2f22;       /* oxblood */

    /* printed double rule: hairline border + inset inner hairline */
    --frame: inset 0 0 0 3px var(--parchment-hi), inset 0 0 0 4px var(--parchment-lo);

    --display: "IM Fell English SC", "IM Fell English", Georgia, serif;
    --text: "EB Garamond", Garamond, Georgia, serif;
  }

  body {
    margin: 0;
    background: var(--parchment);
    color: var(--ink);
    font-family: var(--text);
  }

  /* ───────── map ───────── */
  #nyc_map {
    position: fixed;
    inset: 0;
    background: var(--parchment-lo);
  }

  /* warm the basemap so it sits on the same paper as the panel */
  #nyc_map .leaflet-tile-pane {
    filter: sepia(0.2) saturate(0.85) brightness(0.98);
  }

  /* zoom buttons + credits in the same ink-and-paper style */
  .leaflet-bar,
  .leaflet-bar a {
    border-radius: 0 !important;
  }

  .leaflet-bar {
    border: 1px solid var(--ink-faint) !important;
    box-shadow: none !important;
  }

  .leaflet-bar a {
    background: var(--parchment-hi);
    color: var(--ink);
    font-family: var(--text);
    border-bottom-color: var(--ink-faint);
  }

  .leaflet-bar a:hover {
    background: var(--parchment);
  }

  .leaflet-control-attribution {
    background: rgba(247, 240, 222, 0.85) !important;
    font-family: var(--text);
    color: var(--ink-soft);
  }

  /* radius slider, floating top-left next to the zoom buttons */
  .radius_control {
    position: fixed;
    top: 10px;
    left: 56px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px 14px 10px;
    background: var(--parchment-hi);
    border: 1px solid var(--ink-faint);
    box-shadow: var(--frame);
    font-family: var(--text);
    font-size: 0.9rem;
    color: var(--ink-soft);
  }

  .radius_control label {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-family: var(--display);
    letter-spacing: 0.08em;
  }

  #radius_value {
    color: var(--ink);
    font-family: var(--text);
    font-style: italic;
    letter-spacing: 0;
  }

  #radius_slider {
    width: 180px;
    accent-color: var(--native-ink);
  }

  /* ───────── first-visit hint: centered cursor + ring + label ───────── */
  /* clicks pass straight through to the map; it never blocks the action it points to */
  .map_hint {
    --hint-delay: 1.5s;  /* pause on load before it fades in */
    --hint-cycle: 1.8s;  /* one press + ring */
    --hint-fade: 0.35s;  /* fade out on first click */
    position: fixed;
    top: 50%;
    left: 50%;
    z-index: 900; /* above the map, below controls (1000) and panels (1100+) */
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    pointer-events: none;
    animation: hint_in 0.7s ease var(--hint-delay) both;
    transition: opacity var(--hint-fade) ease;
  }

  .map_hint.is_hidden {
    opacity: 0;
    animation: none;
  }

  .hint_target {
    position: relative;
    width: 44px;
    height: 44px;
  }

  /* expanding click ring, same green ink + fill as the search circle */
  .hint_target::before {
    content: "";
    position: absolute;
    inset: 0;
    border: 1.5px solid var(--native-ink);
    border-radius: 50%;
    background: color-mix(in srgb, var(--native-ink) 12%, transparent);
    opacity: 0;
    animation: hint_ring var(--hint-cycle) ease-out calc(var(--hint-delay) + 1.4s) 3;
  }

  /* cursor slides in, then presses; tip (2px into the svg) sits on the ring's center */
  .hint_cursor {
    position: absolute;
    top: calc(50% - 2px);
    left: calc(50% - 2px);
    transform-origin: 2px 2px;
    filter: drop-shadow(1px 2px 1.5px color-mix(in srgb, var(--ink) 25%, transparent));
    animation:
      hint_approach 0.6s ease-out calc(var(--hint-delay) + 0.7s) both,
      hint_press var(--hint-cycle) ease calc(var(--hint-delay) + 1.4s) 3;
  }

  .hint_label {
    margin: 0;
    padding: 6px 14px 7px;
    background: var(--parchment-hi);
    border: 1px solid var(--ink-faint);
    box-shadow: var(--frame);
    font-family: var(--display);
    font-size: 0.95rem;
    letter-spacing: 0.08em;
    text-transform: lowercase; /* lowercase + small-caps face = even small caps */
    color: var(--ink-soft);
    white-space: nowrap;
  }

  @keyframes hint_in {
    from { opacity: 0; }
  }

  /* approach uses `translate` and press uses `scale`, so both run on one element */
  @keyframes hint_approach {
    from { translate: 18px 20px; opacity: 0; }
  }

  @keyframes hint_press {
    22%, 40% { scale: 1; }
    30%      { scale: 0.82; }
  }

  @keyframes hint_ring {
    0%, 28% { transform: scale(0.15); opacity: 0; }
    32%     { transform: scale(0.15); opacity: 1; }
    100%    { transform: scale(1.25); opacity: 0; }
  }

  /* reduced motion: no pause or movement, just the static cursor + label */
  @media (prefers-reduced-motion: reduce) {
    .map_hint {
      animation: hint_in 0.01s linear 0.6s both;
    }

    .hint_target::before,
    .hint_cursor {
      animation: none;
    }
  }

  /* ───────── species + about panels: off-screen right until .open ───────── */
  .panel {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 1100;
    box-sizing: border-box;
    width: 60vw;
    height: 100vh;
    height: 100dvh;
    padding: clamp(22px, 4vh, 40px) clamp(24px, 2.6vw, 44px);
    display: flex;
    flex-direction: column;
    overflow: hidden; /* frame + close stay put; .panel_lists / .about_text scroll instead */
    /* paper with slightly darker, aged edges */
    background:
      radial-gradient(ellipse at center, var(--parchment) 55%, var(--parchment-lo) 130%);
    border-left: 1px solid var(--ink-faint);
    box-shadow: -6px 0 18px rgba(46, 36, 25, 0.12);
    transform: translateX(100%);
    visibility: hidden;
    transition: transform 0.35s ease, visibility 0s linear 0.35s;
  }

  /* printed double-rule frame around the whole plate */
  .panel::before {
    content: "";
    position: absolute;
    inset: 10px;
    border: 3px double var(--ink-faint);
    pointer-events: none;
  }

  .panel.open {
    transform: none;
    visibility: visible;
    transition: transform 0.35s ease;
  }

  /* about panel: same panel, 60% of the species panel's width, on top of it */
  .panel_about {
    width: 36vw;
    z-index: 1200;
  }

  .panel_about h1 {
    font-size: clamp(1.1rem, 1.5vw, 1.5rem); /* smaller so the title fits the narrower panel */
    margin-bottom: clamp(6px, 1.5vh, 14px); /* byline sits close under it */
  }

  /* panel buttons: close (×) + info (i) */
  .panel_close,
  .info_button {
    padding: 0;
    border: none;
    background: transparent;
    color: var(--ink-soft);
    font-family: var(--text);
    line-height: 1;
    cursor: pointer;
  }

  .panel_close:hover,
  .info_button:hover {
    color: var(--ink);
  }

  .panel_close {
    position: absolute;
    top: 16px;
    right: 18px;
    z-index: 1;
    width: 32px;
    height: 32px;
    font-size: 1.6rem;
  }

  /* scroll body of each panel (fallback only for the cards: they size themselves to fit) */
  .panel_lists,
  .about_text {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
  }

  /* the two sections stack; if the panel is short they shrink to share it */
  .panel_lists {
    display: flex;
    flex-direction: column;
    gap: clamp(14px, 5vh, 56px);
  }

  .panel_lists[hidden] {
    display: none;
  }

  .panel_section {
    flex: 0 1 auto; /* natural height, distinctive sits right below; both shrink on short screens */
    min-height: 0;
    display: flex;
    flex-direction: column;
  }

  /* section title: centred small caps between hairline rules, like a plate heading */
  .panel h1 {
    flex: none;
    display: flex;
    align-items: center;
    gap: 0.8em;
    margin: 0 0 clamp(10px, 3.2vh, 30px);
    font-family: var(--display);
    font-size: clamp(1.35rem, 2.3vw, 2.1rem);
    font-weight: normal;
    line-height: 1.1;
    letter-spacing: 0.14em;
    color: var(--ink);
    white-space: nowrap;
  }

  .panel h1::before,
  .panel h1::after {
    content: "";
    flex: 1;
    border-top: 1px solid var(--ink-faint);
  }

  /* one row of 5 cards */
  .species_list {
    flex: 0 1 auto;
    min-height: 0;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    grid-template-rows: minmax(0, 1fr);
    align-items: stretch;
    gap: clamp(6px, 0.8vw, 12px);
  }

  .species_list > .loading {
    grid-column: 1 / -1;
  }

  /* ───────── card: a miniature plate ───────── */
  .species_card {
    container-type: inline-size; /* text below scales with card width */
    --name-size: clamp(0.85rem, 11.5cqi, 1.25rem);
    --name-lh: 1.12;
    --text-size: clamp(0.72rem, 9cqi, 1rem);
    --sci-lh: 1.25;
    box-sizing: border-box;
    min-width: 0;
    min-height: 0;
    max-height: 100%; /* never taller than the row, so the image shrinks instead */
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: hidden;
    padding: clamp(8px, 7cqi, 14px) clamp(6px, 6cqi, 12px) clamp(8px, 7cqi, 14px);
    text-align: center;
    background: var(--parchment-hi);
    /* double frame: outer hairline + inner hairline */
    border: 1px solid var(--ink-faint);
    box-shadow: var(--frame);
  }

  .species_card > * {
    flex: none;
  }

  /* specimen in an oval frame */
  .species_card img {
    display: block;
    flex: 0 1 auto; /* full size when there's room, shorter when the panel is short */
    box-sizing: border-box;
    min-height: 0;
    width: 100%;
    aspect-ratio: 6 / 5; /* landscape oval: most iNat photos are landscape, so less is cut off at the sides */
    object-fit: cover;
    border-radius: 50%;
    border: 1px solid var(--ink-faint);
    padding: 3px;
    background: var(--parchment-hi);
    filter: sepia(0.12) saturate(0.92);
  }

  /*
    fixed-height layout:
    name + scientific name stay together right under the image (a 1-line name
    doesn't leave a gap between them); the leftover space goes above the footer,
    so tags + counts line up along the bottom of every card in the row.
    long names shrink to fit 2 lines (fitNames in script.js) instead of truncating.
  */
  /* fixed slot: always room for a 2-line name + 1-line scientific name, so every
     card is the same height; content sits at the top of the slot */
  .card_name {
    width: 100%;
    margin-top: clamp(6px, 6cqi, 12px);
    min-height: calc(2 * var(--name-lh) * var(--name-size) + var(--sci-lh) * var(--text-size) + 2px);
  }

  .species_card h3 {
    margin: 0;
    max-width: 100%;
    font-family: var(--display); /* same face as the section titles */
    font-size: var(--name-size);
    font-weight: normal;
    text-transform: capitalize; /* iNat names vary in case; caps + small caps like a plate title */
    letter-spacing: 0.04em;
    line-height: var(--name-lh);
    color: var(--ink);
  }

  .species_card p {
    margin: 0;
    font-size: var(--text-size);
    color: var(--ink-soft);
  }

  .sci_name {
    margin-top: 2px !important;
    font-style: italic;
    line-height: var(--sci-lh);
  }

  .card_foot {
    width: 100%;
    margin-top: auto; /* pushes the footer to the bottom; any spare space sits above it */
    padding-top: clamp(6px, 6cqi, 10px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(3px, 3cqi, 6px);
  }

  /* fleuron divider above the footer */
  .card_foot::before {
    content: "❦";
    color: var(--ink-faint);
    font-size: clamp(0.6rem, 7cqi, 0.85rem);
    line-height: 1;
  }

  /* one-line text: full card width so fitNames can detect overflow, then shrinks to fit */
  .sci_name,
  .obs_count {
    width: 100%;
    white-space: nowrap;
  }

  .obs_count {
    font-style: italic;
  }

  /* labels: printed small-caps words in coloured ink, not pills */
  .tags {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 2px 8px;
  }

  .tag {
    font-family: var(--display);
    font-size: clamp(0.68rem, 8.5cqi, 0.95rem);
    letter-spacing: 0.1em;
    line-height: 1.2;
    text-transform: lowercase; /* lowercase + small-caps face = even small caps */
  }

  .tag.native {
    color: var(--native-ink);
  }

  .tag.introduced {
    color: var(--introduced-ink);
  }

  .tag.unknown,
  .tag.pending {
    color: var(--unknown-ink);
  }

  .tag.at_risk {
    color: var(--risk-ink);
  }

  .tag.at_risk::before {
    content: "✛ ";
    color: var(--ink-faint);

  }

  /* ───────── panel footer: data credit + info button, bottom right ───────── */
  .panel_foot {
    flex: none;
    margin-top: auto; /* stays at the bottom, also when the status message replaces the lists */
    padding-top: clamp(10px, 2vh, 20px);
    display: flex;
    align-items: center;
    justify-content: space-between; /* creds left, info button right */
    gap: 10px;
  }

  .panel_foot p {
    margin: 0;
    font-size: 0.8rem;
    font-style: italic;
    color: var(--ink-soft);
  }

  .panel a {
    color: inherit;
    text-decoration-color: var(--ink-faint);
    text-underline-offset: 2px;
  }

  .panel a:hover {
    color: var(--ink);
  }

  .info_button {
    flex: none;
    width: 24px;
    height: 24px;
    border: 1px solid var(--ink-faint);
    border-radius: 50%;
    font-size: 0.95rem;
    font-style: italic;
  }

  .info_button:hover {
    border-color: var(--ink-soft);
  }

  /* ───────── about panel text ───────── */
  .about_text h2 {
    margin: 1.1em 0 0.25em;
    font-family: var(--display);
    font-size: 1.05rem;
    font-weight: normal;
    letter-spacing: 0.08em;
    color: var(--ink);
  }

  .about_text p {
    margin: 0 0 0.6em;
    font-size: 1rem;
    line-height: 1.5;
    color: var(--ink-soft);
  }

  /* byline centred under the title, intro set a little larger in full ink */
  .about_text .byline {
    margin: 0 0 0.8em;
    text-align: center;
    font-style: italic;
  }

  .about_text .lede {
    font-size: 1.1rem;
    color: var(--ink);
  }

  /* stacked fractions in tall brackets */
  .formula {
    display: flex;
    flex-wrap: wrap; /* second bracket drops to its own line in a narrow panel */
    justify-content: center;
    align-items: center;
    gap: 0 10px;
    margin: 0.6em 0 0.9em;
    font-style: italic;
    color: var(--ink);
  }

  .frac_group {
    display: inline-flex;
    align-items: center;
    gap: 3px;
  }

  .formula .bracket {
    font-size: 2.6em;
    line-height: 1;
    font-style: normal;
    color: var(--ink-faint);
  }

  .formula .op {
    font-style: normal;
  }

  .frac {
    display: inline-flex;
    flex-direction: column;
    text-align: center;
    gap: 2px;
    line-height: 1.3;
  }

  .frac span:first-child {
    border-bottom: 1px solid var(--ink-soft); /* fraction bar */
    padding-bottom: 2px; /* space above the bar; .frac gap spaces below it */
  }

  /* hanging indent, like a printed reference list */
  .about_text .cite {
    padding-left: 1.5em;
    text-indent: -1.5em;
    overflow-wrap: anywhere; /* long urls wrap instead of overflowing */
  }

  /* status (guardrail/error) message: replaces the lists, centred at the top of the panel */
  .status {
    box-sizing: border-box;
    max-width: 34em;
    margin: clamp(28px, 6vh, 56px) auto 0;
    padding: 14px 22px;
    text-align: center;
    background: var(--parchment-hi);
    border: 1px solid var(--ink-faint);
    box-shadow: var(--frame);
    color: var(--ink-soft);
    font-family: var(--text);
    font-size: 1.05rem;
    font-style: italic;
  }

  .loading {
    margin: 0;
    font-family: var(--text);
    font-size: 1rem;
    font-style: italic;
    text-align: center;
    color: var(--ink-soft);
  }

  /* ───────── phones: panel becomes a bottom sheet ───────── */
  @media (max-width: 700px) {
    .panel {
      top: auto;
      bottom: 0;
      width: 100vw;
      height: 65vh;
      height: 65dvh;
      padding: 18px 14px 14px;
      border-left: none;
      border-top: 1px solid var(--ink-faint);
      box-shadow: 0 -6px 18px rgba(46, 36, 25, 0.12);
      transform: translateY(100%);
    }

    .panel::before {
      inset: 5px;
    }

    /* about sheet: 60% of the species sheet's height */
    .panel_about {
      height: 39vh;
      height: 39dvh;
    }

    .panel_close {
      top: 8px;
      right: 10px;
    }

    .panel h1 {
      font-size: 1.05rem;
      letter-spacing: 0.1em;
      margin-bottom: 8px;
    }

    .panel_lists {
      gap: 12px;
    }

    .panel_section:first-child h1,
    .panel_about h1 {
      padding-right: 30px; /* clear the close button */
    }

    .species_list {
      gap: 4px;
    }

    .species_card {
      padding: 6px 3px;
      box-shadow: none;
    }

    .species_card img {
      width: 96%;
      padding: 1px;
    }

    .card_foot::before {
      display: none;
    }
  }
