/* ═══════════════════════════════════════════════════════════════════════════
   Hyacin v2.0 — Cyber-Botanist Theme
   F11: Neon UX/UI Aesthetic
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Design Tokens ────────────────────────────────────────────────────────── */
:root {
    /* Background layers */
    --hy-bg-deep:     #0a0a14;
    --hy-bg:          #0d0d1a;
    --hy-bg-surface:  #12122a;
    --hy-bg-raised:   #1a1a3a;
    --hy-bg-glass:    rgba(18, 18, 42, 0.7);

    /* Neon accent palette */
    --hy-green:       #00ff88;    /* Growth / Success / Plants */
    --hy-green-dim:   #00cc6a;
    --hy-green-glow:  rgba(0, 255, 136, 0.15);
    --hy-purple:      #a855f7;    /* Butterflies */
    --hy-purple-glow: rgba(168, 85, 247, 0.15);
    --hy-pink:        #ff2d7b;    /* Alerts / Danger */
    --hy-pink-glow:   rgba(255, 45, 123, 0.15);
    --hy-cyan:        #00d4ff;    /* Water / Tech / Info */
    --hy-cyan-glow:   rgba(0, 212, 255, 0.15);
    --hy-amber:       #ffb800;    /* Warnings / Conflicts */
    --hy-amber-glow:  rgba(255, 184, 0, 0.15);

    /* Text */
    --hy-text:        #e2e8f0;
    --hy-text-dim:    #a8b3c4;
    --hy-text-muted:  #94a3b8;

    /* Borders */
    --hy-border:      rgba(255, 255, 255, 0.08);
    --hy-border-glow: rgba(0, 255, 136, 0.2);

    /* Sizing */
    --hy-topbar-height: 48px;
    --hy-sidebar-width: 200px;
    --hy-sidebar-collapsed: 56px;
    --hy-nav-height:  48px;  /* legacy compat */
    --hy-radius:      8px;
    --hy-radius-lg:   12px;
    --hy-radius-full: 9999px;

    /* Transitions */
    --hy-transition:  0.15s ease;

    /* Glassmorphism */
    --hy-glass-blur:  12px;
    --hy-glass-bg:    rgba(18, 18, 42, 0.6);
    --hy-glass-border: rgba(255, 255, 255, 0.06);
}

/* ── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    height: 100%;
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    height: 100%;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--hy-text);
    background: var(--hy-bg-deep);
    overflow: hidden;
    display: grid;
    grid-template-rows: var(--hy-topbar-height) 1fr;
    grid-template-columns: var(--hy-sidebar-width) 1fr;
    grid-template-areas:
        "topbar topbar"
        "sidebar main";
}

a { color: var(--hy-cyan); text-decoration: none; transition: color var(--hy-transition); }
a:hover { color: var(--hy-green); }

/* ── Top Bar ──────────────────────────────────────────────────────────────── */
.hy-topbar {
    grid-area: topbar;
    height: var(--hy-topbar-height);
    background: var(--hy-glass-bg);
    backdrop-filter: blur(var(--hy-glass-blur));
    -webkit-backdrop-filter: blur(var(--hy-glass-blur));
    border-bottom: 1px solid var(--hy-glass-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    z-index: 1001;
}

.hy-topbar-left { display: flex; align-items: center; gap: 0.75rem; }
.hy-topbar-right { display: flex; align-items: center; gap: 0.75rem; }
.hy-topbar-user { font-size: 0.75rem; color: var(--hy-text-dim); }

.hy-sidebar-toggle {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
}
.hy-sidebar-toggle span {
    width: 20px;
    height: 2px;
    background: var(--hy-text);
    border-radius: 2px;
    transition: var(--hy-transition);
}

.hy-nav-logo {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 700;
    color: var(--hy-text);
    text-decoration: none;
}
.hy-logo-icon { font-size: 1.3rem; }
.hy-logo-text { font-size: 1rem; letter-spacing: -0.02em; }
.hy-logo-version {
    font-size: 0.5rem;
    color: var(--hy-green);
    background: var(--hy-green-glow);
    padding: 1px 5px;
    border-radius: var(--hy-radius-full);
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.hy-sidebar {
    grid-area: sidebar;
    width: var(--hy-sidebar-width);
    background: var(--hy-bg-surface);
    border-right: 1px solid var(--hy-glass-border);
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: var(--hy-border) transparent;
    transition: width 0.2s ease;
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.hy-sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0.5rem;
    flex: 1;
}

.hy-sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.65rem;
    border-radius: var(--hy-radius);
    font-size: 0.82rem;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
    transition: all var(--hy-transition);
    overflow: hidden;
    color: rgba(255, 255, 255, 0.66);
}
/* Inactive links: legible off-white (WCAG-friendly on the midnight bg). Accent
   color is reserved for hover + the active route, so the rail reads cleanly. */
.hy-sidebar-link:hover { color: #ffffff; background: rgba(255,255,255,0.06); }
.hy-sidebar-link.active { color: var(--hy-green); background: var(--hy-green-glow); }

/* Per-section accents apply only on hover — inactive stays the legible gray. */
.hy-sidebar-care:hover { color: var(--hy-cyan); }
.hy-sidebar-butterfly:hover { color: var(--hy-purple); }
.hy-sidebar-quicklog:hover { color: var(--hy-green); }
.hy-sidebar-v1 { color: var(--hy-text-muted); font-size: 0.72rem; }

.hy-sidebar-icon { font-size: 1.1rem; flex-shrink: 0; width: 1.3rem; text-align: center; }
.hy-sidebar-label { transition: opacity 0.15s ease; }

.hy-sidebar-divider {
    height: 1px;
    background: var(--hy-border);
    margin: 0.4rem 0.5rem;
}
.hy-sidebar-spacer { flex: 1; }
.hy-sidebar-section {
    font-size: 0.6rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.09em;
    color: var(--hy-text-muted); padding: 0.7rem 0.75rem 0.25rem; white-space: nowrap; overflow: hidden;
}
.hy-sidebar.collapsed .hy-sidebar-section { display: none; }

.hy-sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
}

/* Collapsed sidebar */
.hy-sidebar.collapsed {
    width: var(--hy-sidebar-collapsed);
}
.hy-sidebar.collapsed .hy-sidebar-label {
    opacity: 0;
    width: 0;
    overflow: hidden;
}
.hy-sidebar.collapsed .hy-sidebar-link {
    justify-content: center;
    padding: 0.55rem 0;
}
.hy-sidebar.collapsed .hy-sidebar-divider {
    margin: 0.4rem 0.25rem;
}

/* Body grid adjusts with collapsed sidebar */
body.sidebar-collapsed {
    --hy-sidebar-width: 56px;
}

/* No sidebar (logged out) */
body.no-sidebar {
    grid-template-columns: 1fr;
    grid-template-areas:
        "topbar"
        "main";
}

/* ── Main Content ─────────────────────────────────────────────────────────── */
#app-main {
    grid-area: main;
    overflow-y: auto;
    min-height: 0;
    padding: 1rem;
    /* Ambient atmosphere — a faint neon wash anchored to the top corners, so
       every page carries the enhanced "glow-up" feel, not just Home. Subtle
       (low alpha) and behind all content. */
    background:
        radial-gradient(65% 55% at 88% -5%, rgba(255, 184, 0, 0.05), transparent 60%),
        radial-gradient(55% 50% at 3% 0%, rgba(168, 85, 247, 0.05), transparent 55%);
}

/* ── Cards (Glassmorphism) ────────────────────────────────────────────────── */
.hy-card {
    /* Glass base + a subtle top-light / bottom-shade for depth, applied
       uniformly so cards read as one elevated system across the app. */
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(0, 0, 0, 0.06)),
        var(--hy-glass-bg);
    backdrop-filter: blur(var(--hy-glass-blur));
    -webkit-backdrop-filter: blur(var(--hy-glass-blur));
    border: 1px solid var(--hy-glass-border);
    border-radius: var(--hy-radius-lg);
    padding: 1rem;
    transition: border-color var(--hy-transition), box-shadow var(--hy-transition);
}
.hy-card:hover {
    border-color: var(--hy-border-glow);
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.30);
}

.hy-card-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--hy-green);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.hy-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 1rem;
    border: 1px solid transparent;
    border-radius: var(--hy-radius);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--hy-transition);
    white-space: nowrap;
    text-decoration: none;
}

.hy-btn-primary {
    background: var(--hy-green);
    color: #000;
    border-color: var(--hy-green);
}
.hy-btn-primary:hover { background: var(--hy-green-dim); box-shadow: 0 0 12px var(--hy-green-glow); }

.hy-btn-danger {
    background: var(--hy-pink);
    color: #fff;
    border-color: var(--hy-pink);
}
.hy-btn-danger:hover { box-shadow: 0 0 12px var(--hy-pink-glow); }

.hy-btn-ghost {
    background: transparent;
    color: var(--hy-text-dim);
    border-color: var(--hy-border);
}
.hy-btn-ghost:hover { color: var(--hy-text); background: rgba(255,255,255,0.05); }

.hy-btn-sm { padding: 0.3rem 0.7rem; font-size: 0.72rem; }
.hy-btn-xs { padding: 0.2rem 0.55rem; font-size: 0.68rem; }

/* Icon-only action buttons — square, chrome-free until hover */
.hy-btn-icon {
    padding: 0.3rem;
    min-width: 1.95rem;
    justify-content: center;
    font-size: 0.95rem;
    line-height: 1;
    background: transparent;
    border-color: transparent;
    color: var(--hy-text-dim);
}
.hy-btn-icon:hover { background: rgba(255,255,255,0.07); color: var(--hy-text); }
/* Destructive icons stay calm until you actually hover them */
.hy-btn-icon.hy-icon-danger:hover { background: rgba(236,72,153,0.14); color: var(--hy-pink); }
.hy-btn-icon.hy-icon-success:hover { background: rgba(74,222,128,0.14); }

/* Ghost/outline badge — calm, uniform chrome for non-semantic label pills */
.hy-badge-ghost { background: transparent; border: 1px solid var(--hy-border); color: var(--hy-text-dim); }

/* Shared fauna (Butterflies/Wildlife) detail layout — single source of truth; each page sets --hy-fauna-accent */
.hy-fauna-detail-page { max-width: 1000px; margin: 0 auto; display: flex; flex-direction: column; gap: 1rem; }
.hy-fauna-hero { display: flex; gap: 1.5rem; padding: 0; overflow: hidden; }
.hy-fauna-hero-img { width: 200px; height: 200px; flex-shrink: 0; background: var(--hy-bg-raised); display: flex; align-items: center; justify-content: center; }
.hy-fauna-hero-photo { width: 100%; height: 100%; object-fit: cover; }
.hy-fauna-hero-placeholder { font-size: 4rem; opacity: 0.5; }
.hy-fauna-hero-info { padding: 1.25rem; display: flex; flex-direction: column; gap: 0.5rem; justify-content: center; }
.hy-fauna-hero-name { font-size: 1.3rem; font-weight: 700; color: var(--hy-fauna-accent, var(--hy-green)); margin: 0; }
.hy-fauna-hero-sci { font-size: 0.85rem; color: var(--hy-text-muted); }
.hy-fauna-hero-badges { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.hy-fauna-key-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem; margin-top: 0.5rem; }
.hy-fauna-tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--hy-border); }
.hy-fauna-tab { padding: 0.5rem 1rem; background: none; border: none; border-bottom: 2px solid transparent; color: var(--hy-text-dim); font-size: 0.82rem; font-weight: 500; cursor: pointer; transition: all var(--hy-transition); }
.hy-fauna-tab:hover { color: var(--hy-text); }
.hy-fauna-tab.active { color: var(--hy-fauna-accent, var(--hy-green)); border-bottom-color: var(--hy-fauna-accent, var(--hy-green)); }
@media (max-width: 768px) {
    .hy-fauna-hero { flex-direction: column; }
    .hy-fauna-hero-img { width: 100%; height: 180px; }
    .hy-fauna-key-facts { grid-template-columns: 1fr; }
    .hy-fauna-tabs { overflow-x: auto; }
}

/* Dense metadata chips (seed cards, etc.) — icon + value instead of "Label: value" */
.hy-seed-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    font-size: 0.72rem;
    color: var(--hy-text-dim);
    background: rgba(255,255,255,0.04);
    border-radius: 6px;
    padding: 0.12rem 0.4rem;
    margin: 0.15rem 0.2rem 0 0;
    white-space: nowrap;
}

/* Inline species linker — reads as plain text until you touch that row */
.hy-inline-ref {
    -webkit-appearance: none;
    appearance: none;
    max-width: 100%;
    padding: 0.15rem 0.35rem;
    background: transparent;
    border-color: transparent;
    color: var(--hy-text);
    cursor: pointer;
    transition: background var(--hy-transition), border-color var(--hy-transition);
}
.hy-inline-ref.hy-inline-ref-empty { color: var(--hy-text-muted); font-style: italic; }
.hy-td-species:hover .hy-inline-ref,
.hy-inline-ref:focus {
    -webkit-appearance: auto;
    appearance: auto;
    background: rgba(255,255,255,0.04);
    border-color: var(--hy-border);
}

/* ── Stat Tiles ───────────────────────────────────────────────────────────── */
.hy-stat {
    text-align: center;
    padding: 0.75rem;
}
.hy-stat-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
    background: linear-gradient(135deg, var(--hy-green), var(--hy-cyan));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.hy-stat-label {
    font-size: 0.68rem;
    color: var(--hy-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 0.25rem;
}

/* ── Badges ───────────────────────────────────────────────────────────────── */
.hy-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 2px 8px;
    border-radius: var(--hy-radius-full);
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.hy-badge-green  { background: var(--hy-green-glow); color: var(--hy-green); border: 1px solid rgba(0,255,136,0.3); }
.hy-badge-purple { background: var(--hy-purple-glow); color: var(--hy-purple); border: 1px solid rgba(168,85,247,0.3); }
.hy-badge-pink   { background: var(--hy-pink-glow); color: var(--hy-pink); border: 1px solid rgba(255,45,123,0.3); }
.hy-badge-cyan   { background: var(--hy-cyan-glow); color: var(--hy-cyan); border: 1px solid rgba(0,212,255,0.3); }
.hy-badge-amber  { background: var(--hy-amber-glow); color: var(--hy-amber); border: 1px solid rgba(255,184,0,0.3); }

/* Conservation-status chip — layout only; color comes from an inline style set
   by services/conservation-codes.js consChip(). Single-sourced here (was
   duplicated inline across the fauna/library index + detail views). */
.hy-cons-chip { display: inline-flex; align-items: center; padding: 0.1rem 0.4rem; border-radius: 4px; font-size: 0.66rem; font-weight: 700; letter-spacing: 0.02em; border: 1px solid rgba(0,0,0,0.25); }

/* Reference-library switcher — "one Library, three branches" segmented pills.
   Rendered by config/reference-types.js referenceSwitcher(). Each pill carries
   its branch accent via a --pill custom property set inline. */
.hy-ref-switcher { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; margin-bottom: 1.1rem; }
.hy-ref-switcher-title { font-size: 0.95rem; font-weight: 700; color: var(--hy-text); letter-spacing: 0.01em; }
.hy-ref-pills { display: inline-flex; gap: 0.25rem; padding: 0.25rem; background: var(--hy-bg-surface); border: 1px solid var(--hy-border); border-radius: var(--hy-radius-full); flex-wrap: wrap; }
.hy-ref-pill { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.4rem 0.85rem; border-radius: var(--hy-radius-full); color: var(--hy-text-dim); font-size: 0.83rem; font-weight: 600; white-space: nowrap; transition: color var(--hy-transition), background var(--hy-transition), box-shadow var(--hy-transition); }
.hy-ref-pill:hover { color: var(--hy-text); background: var(--hy-bg-raised); }
.hy-ref-pill.active { color: #0a0a14; background: var(--pill); box-shadow: 0 0 14px color-mix(in srgb, var(--pill) 40%, transparent); }
.hy-ref-pill.active:hover { color: #0a0a14; background: var(--pill); }
.hy-ref-pill-ic { font-size: 0.95rem; line-height: 1; }
@media (max-width: 560px) { .hy-ref-pill-lb { display: none; } .hy-ref-pill { padding: 0.4rem 0.6rem; } }

/* Shared reference card grid — one card system for all Library branches.
   Rendered by config/reference-types.js referenceCard()/referenceGrid(). Each
   card's --accent (branch colour) drives the name + hover glow; per-branch field
   differences ride in the badges row. Replaces the divergent .hy-fauna-* cards. */
.hy-ref-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 1rem; }
.hy-ref-card {
    display: flex; flex-direction: column; overflow: hidden;
    border-radius: var(--hy-radius-lg); border: 1px solid var(--hy-glass-border);
    background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(0,0,0,0.06)), var(--hy-glass-bg);
    text-decoration: none; color: inherit;
    transition: transform var(--hy-transition), border-color var(--hy-transition), box-shadow var(--hy-transition);
}
.hy-ref-card:hover {
    transform: translateY(-2px);
    border-color: color-mix(in srgb, var(--accent) 45%, transparent);
    box-shadow: 0 6px 22px rgba(0,0,0,0.40);
}
.hy-ref-card-thumb { aspect-ratio: 4 / 3; background: var(--hy-bg-raised); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.hy-ref-card-thumb img { width: 100%; height: 100%; object-fit: cover; }
.hy-ref-card-ph { font-size: 3rem; opacity: 0.45; }
.hy-ref-card-body { padding: 0.8rem; display: flex; flex-direction: column; gap: 0.3rem; }
.hy-ref-card-name { font-weight: 600; font-size: 0.92rem; color: var(--accent); line-height: 1.2; }
.hy-ref-card-sci { font-size: 0.76rem; font-style: italic; color: var(--hy-text-muted); }
.hy-ref-card-meta { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.15rem; align-items: center; }

/* ── Grid ─────────────────────────────────────────────────────────────────── */
.hy-grid {
    display: grid;
    gap: 1rem;
}
.hy-grid-2 { grid-template-columns: repeat(2, 1fr); }
.hy-grid-3 { grid-template-columns: repeat(3, 1fr); }
.hy-grid-4 { grid-template-columns: repeat(4, 1fr); }

/* ── Quick Actions (Homepage FAB) ─────────────────────────────────────────── */
.hy-fab {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 900;
}
.hy-fab-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--hy-green);
    color: #000;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0, 255, 136, 0.3);
    transition: all var(--hy-transition);
    display: flex;
    align-items: center;
    justify-content: center;
}
.hy-fab-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 30px rgba(0, 255, 136, 0.5);
}

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    body {
        grid-template-columns: 1fr;
        grid-template-areas:
            "topbar"
            "main";
    }
    .hy-sidebar {
        position: fixed;
        top: var(--hy-topbar-height);
        left: 0;
        bottom: 0;
        width: 220px;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        z-index: 1000;
    }
    .hy-sidebar.mobile-open {
        transform: translateX(0);
    }
    .hy-sidebar-overlay.visible {
        display: block;
    }
    .hy-grid-2, .hy-grid-3, .hy-grid-4 { grid-template-columns: 1fr; }
    .hy-fab { bottom: 1rem; right: 1rem; }

    /* Touch-friendly tap targets */
    .hy-btn { min-height: 40px; padding: 0.6rem 1rem; }
    .hy-btn-sm { min-height: 36px; }
    .hy-btn-xs { min-height: 32px; }

    /* Prevent iOS zoom on focus */
    .hy-input, .hy-select, textarea.hy-input { font-size: 16px; }

    /* Stack detail headers */
    .hy-detail-header,
    .hy-map-header,
    .hy-page-header { flex-direction: column; align-items: flex-start; }
    .hy-detail-actions { width: 100%; }

    /* Tables: horizontal scroll if overflowing */
    .hy-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    table { min-width: 100%; }

    /* Cards: less padding on small screens */
    .hy-card { padding: 0.75rem; }
}

@media (max-width: 480px) {
    .hy-logo-text { display: none; }
    #app-main { padding: 0.5rem; }
    .hy-card-title { font-size: 0.9rem; }
    /* Bulk-action bar wraps */
    .hy-bulk-bar { flex-wrap: wrap; gap: 0.5rem; }
    .hy-bulk-actions { flex-wrap: wrap; }
}

/* ── Forms (shared primitives) ────────────────────────────────────────────
   Single source of truth for form layout across Library / Butterflies /
   Wildlife (and any page that uses .hy-form-*). Accent — focus ring + fieldset
   legend — is driven by --hy-form-accent, so each form sets its branch color
   once on the .hy-form-page wrapper (green / purple / cyan). The header rule is
   scoped to .hy-form-page so it never touches index/detail page headers, which
   keep their own space-between layouts. */
:root { --hy-form-accent: var(--hy-green); }

.hy-form-page { max-width: 800px; margin: 0 auto; display: flex; flex-direction: column; gap: 1rem; }
.hy-form-page .hy-page-header { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.hy-page-title { font-size: 1.25rem; font-weight: 700; color: var(--hy-text); }

.hy-fieldset { border: 1px solid var(--hy-border); border-radius: var(--hy-radius-lg); padding: 1rem; margin-bottom: 0.5rem; }
.hy-legend { font-size: 0.85rem; font-weight: 600; color: var(--hy-form-accent); padding: 0 0.5rem; }

.hy-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.hy-form-full { grid-column: 1 / -1; }
.hy-form-group { display: flex; flex-direction: column; gap: 0.25rem; }
.hy-form-row { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.hy-form-row .hy-form-group { flex: 1; min-width: 140px; }

.hy-label { font-size: 0.75rem; font-weight: 600; color: var(--hy-text-dim); text-transform: uppercase; letter-spacing: 0.03em; }
.hy-label-check { flex-direction: row; align-items: center; gap: 0.5rem; cursor: pointer; text-transform: none; letter-spacing: normal; }

.hy-input, .hy-select { background: var(--hy-bg-surface); border: 1px solid var(--hy-border); border-radius: var(--hy-radius); color: var(--hy-text); padding: 0.45rem 0.75rem; font-size: 0.82rem; outline: none; transition: border-color var(--hy-transition); }
.hy-input:focus, .hy-select:focus { border-color: var(--hy-form-accent); }
.hy-input-full { width: 100%; }
.hy-textarea { resize: vertical; font-family: inherit; }
.hy-form-actions { display: flex; gap: 0.5rem; margin-top: 0.5rem; flex-wrap: wrap; }

@media (max-width: 768px) {
    .hy-form-grid { grid-template-columns: 1fr; }
    .hy-form-row { flex-direction: column; }
}

/* ── Library toolbar (shared across Plants / Butterflies / Wildlife) ───────
   The Plants index owns the reference look; these are hoisted from it verbatim
   so the two fauna indexes wear the same header band, inline search, action
   buttons and meta/count row. Plants keeps an identical local copy (cascade
   order) so it is visually unchanged. */
.hy-library { max-width: 1200px; margin: 0 auto; }
.hy-library-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.hy-library-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; }
.hy-library-search { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.hy-library-search .hy-input { min-width: 220px; }
.hy-library-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.hy-library-meta { margin-bottom: 1rem; display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.hy-view-controls { margin-left: auto; display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.hy-view-ctrl { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.75rem; color: var(--hy-text-dim); }
.hy-view-select { padding: 0.25rem 0.4rem; font-size: 0.75rem; min-width: 92px; }
.hy-checkbox-label { display: flex; align-items: center; gap: 0.3rem; cursor: pointer; font-size: 0.8rem; }
.hy-sort-select { min-width: 130px; padding: 0.4rem 0.5rem; }
.hy-section-title { font-size: 1rem; font-weight: 600; color: var(--hy-text); }
.hy-link-banner { padding: 0.75rem 1rem; margin-bottom: 1rem; border: 1px solid var(--hy-green); display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.hy-text-dim { color: var(--hy-text-dim); font-size: 0.82rem; }
.hy-text-muted { color: var(--hy-text-muted); font-size: 0.82rem; font-style: italic; }

/* Empty states — centered placeholder used by the index pages. Covers both
   the .hy-empty and .hy-empty-state naming already in use. */
.hy-empty, .hy-empty-state { text-align: center; padding: 3rem 1rem; color: var(--hy-text-dim); }
.hy-empty-icon { font-size: 3rem; margin-bottom: 0.75rem; opacity: 0.5; }
.hy-empty p, .hy-empty-state p { margin-bottom: 1rem; }
.hy-empty-state h3 { margin-bottom: 0.4rem; color: var(--hy-text); }

@media (max-width: 768px) {
    .hy-library-header { flex-direction: column; align-items: stretch; }
}

/* ── Sun Mode (High Contrast Outdoor) ─────────────────────────────────────── */
[data-theme="sun"] {
    --hy-bg-deep:    #f5f5f0;
    --hy-bg:         #ffffff;
    --hy-bg-surface: #f0f0ea;
    --hy-bg-raised:  #e8e8e0;
    --hy-text:       #1a1a1a;
    --hy-text-dim:   #4a4a4a;
    --hy-text-muted: #888;
    --hy-border:     rgba(0,0,0,0.12);
    --hy-glass-bg:   rgba(255,255,255,0.85);
    --hy-glass-border: rgba(0,0,0,0.08);
    --hy-green:      #059669;
    --hy-green-dim:  #047857;
    --hy-cyan:       #0284c7;
    --hy-pink:       #dc2626;
    --hy-purple:     #7c3aed;
    --hy-amber:      #d97706;
}

/* ── Accessibility: focus rings ───────────────────────────────────────────── */
:focus { outline: none; }
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid var(--hy-cyan);
    outline-offset: 2px;
    border-radius: 4px;
}

/* ── Themed Confirm Modal ─────────────────────────────────────────────────── */
.hy-confirm-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.15s ease;
    padding: 1rem;
}
.hy-confirm-backdrop.show { opacity: 1; }
.hy-confirm-dialog {
    background: var(--hy-bg-raised);
    border: 1px solid var(--hy-border);
    border-radius: var(--hy-radius-lg);
    max-width: 420px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 0 1px var(--hy-border-glow);
    transform: translateY(8px) scale(0.98);
    transition: transform 0.15s ease;
}
.hy-confirm-backdrop.show .hy-confirm-dialog { transform: translateY(0) scale(1); }
.hy-confirm-body {
    padding: 1.25rem 1.25rem 0.75rem;
    color: var(--hy-text);
    font-size: 0.95rem;
    line-height: 1.5;
}
.hy-confirm-actions {
    padding: 0.75rem 1.25rem 1.25rem;
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}


/* ══════════════════════════════════════════════════════════════════════════
   Reference-page vocabulary — shared by Library, Butterflies and Wildlife
   detail pages (rc15/rc16). Icons come from partials/icons.ejs (a vendored
   Lucide-style sprite in the layout). Icons stay muted; colour only where it
   carries meaning; Hyacin green marks headings and active states.
   ══════════════════════════════════════════════════════════════════════════ */
.hy-ic { width: 1em; height: 1em; vertical-align: -0.15em; color: var(--hy-text-muted); flex-shrink: 0; }
.hy-card-title .hy-ic { margin-right: 0.4rem; color: var(--hy-green); opacity: 0.85; }
.hy-ic-sun { color: #e8b13a; }
.hy-ic-water { color: #5b9def; }
.hy-ic-soil { color: #b0743a; }
.hy-ic-ph { color: #b39ddb; }
.hy-ic-cold { color: #7fc8e8; }
.hy-ic-bloom { color: #f4a6c1; }
.hy-ic-fruit { color: #d94a4a; }
.hy-ic-drought { color: #e0955a; }
.hy-ic-salt { color: #8fb8c9; }

/* Chips: categorical values that split cleanly out of the stored text. */
.hy-chips { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.hy-chip { display: inline-flex; align-items: center; font-size: 0.74rem; font-weight: 500; padding: 0.2rem 0.55rem; border-radius: var(--hy-radius-full, 999px); background: var(--hy-bg-raised); border: 1px solid var(--hy-border); color: var(--hy-text); white-space: nowrap; }
.hy-chip-soil { border-color: color-mix(in srgb, #b0743a 45%, transparent); }
.hy-chip-wild { border-color: color-mix(in srgb, var(--hy-cyan) 45%, transparent); }
.hy-chip-bug { border-color: color-mix(in srgb, var(--hy-purple) 45%, transparent); }
.hy-chip-habitat { border-color: color-mix(in srgb, var(--hy-green) 45%, transparent); }
.hy-chip-star { border-color: color-mix(in srgb, var(--hy-amber, #d19a2f) 45%, transparent); }
.hy-chip-use { border-color: color-mix(in srgb, var(--hy-cyan) 45%, transparent); }
.hy-chip-plant { border-color: color-mix(in srgb, var(--hy-green) 45%, transparent); }
.hy-chip-nectar { border-color: color-mix(in srgb, #f4a6c1 55%, transparent); }
