/* NativeAtlas — Clean scientific aesthetic */
:root {
    --primary: #166534;
    --primary-light: #22c55e;
    --primary-dark: #14532d;
    --bg: #f8fafc;
    --surface: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --radius: 6px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

/* Icon circle — scalable text-based icon in a round border */
.icon-circle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1em;
    height: 1em;
    border: 1.5px solid currentColor;
    border-radius: 50%;
    font-weight: 700;
    font-style: normal;
    font-size: inherit;
    line-height: 1;
    text-align: center;
    flex-shrink: 0;
}

/* App Layout */
.app-layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.app-header {
    display: flex;
    flex-direction: column;
    background: var(--primary-dark);
    color: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    z-index: 1000;
}

.header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0 1.5rem;
    height: 56px;
}

.header-org-row {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.75rem;
    overflow-x: auto;
    scrollbar-width: none;
    background: rgba(0,0,0,0.15);
    border-top: 1px solid rgba(255,255,255,0.08);
}

.header-org-row::-webkit-scrollbar { display: none; }

.mobile-only { display: none; }
.desktop-only { display: flex; }

.header-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.header-brand h1 {
    font-size: 1.25rem;
    font-weight: 700;
    flex-shrink: 0;
}

.header-brand h1 a {
    color: white;
    text-decoration: none;
}

.brand-short { display: none; }
.brand-full { display: inline; }

.header-org-selector {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-left: 0.5rem;
    overflow-x: auto;
    scrollbar-width: none;
}

.header-org-selector::-webkit-scrollbar {
    display: none;
}

.org-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: rgba(255,255,255,0.8);
    font-size: 0.7rem;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
    font-family: inherit;
}

.org-tab:hover {
    background: rgba(255,255,255,0.2);
    color: white;
}

.org-tab.active {
    background: rgba(255,255,255,0.25);
    border-color: rgba(255,255,255,0.5);
    color: white;
    font-weight: 600;
}

.org-tab.inactive {
    opacity: 0.5;
}

.org-toggle-icon {
    width: 20px;
    height: 12px;
    flex-shrink: 0;
    vertical-align: middle;
}

.header-subtitle {
    font-size: 0.75rem;
    opacity: 0.8;
    margin-left: 0.75rem;
}

/* Nav carousel wrapper */
.header-nav-carousel {
    display: flex;
    align-items: center;
    min-width: 0;
    flex: 1;
}

.nav-scroll-btn {
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 36px;
    flex-shrink: 0;
    background: none;
    border: none;
    color: rgba(255,255,255,0.5);
    cursor: pointer;
    padding: 0;
    transition: color 0.15s, opacity 0.15s;
    display: none;
}

.nav-scroll-btn.visible {
    display: flex;
}

.nav-scroll-btn:hover {
    color: white;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
}

.header-nav::-webkit-scrollbar {
    display: none;
}

.header-nav a {
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    font-size: 0.8rem;
    padding: 0.35rem 0.6rem;
    border-radius: var(--radius);
    transition: background 0.15s;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
}

.header-nav a:hover {
    background: rgba(255,255,255,0.15);
    color: white;
}

.nav-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.nav-icon-link {
    padding: 0.4rem !important;
}

.nav-draft-active {
    color: #f59e0b !important;
}
.nav-draft-active .nav-icon {
    stroke: #f59e0b;
}
.nav-draft-active .nav-label {
    color: #f59e0b;
}

.nav-divider {
    width: 1px;
    height: 20px;
    background: rgba(255,255,255,0.2);
    margin: 0 0.25rem;
}

.user-avatar {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0 !important;
    border-radius: 50% !important;
    background: rgba(255,255,255,0.2);
    color: white !important;
    font-size: 0.7rem !important;
    font-weight: 700;
    letter-spacing: 0.02em;
    transition: background 0.15s;
    overflow: hidden;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.user-avatar svg {
    width: 18px;
    height: 18px;
    opacity: 0.8;
}

.user-avatar:hover {
    background: rgba(255,255,255,0.35) !important;
}

/* Connection Indicator */
.connection-indicator {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    margin-left: 0.5rem;
    vertical-align: middle;
    transition: all 0.3s;
}

.connection-indicator svg {
    width: 20px;
    height: 20px;
}

.connection-indicator.online svg {
    stroke: #86efac;
}

.connection-indicator.offline svg {
    stroke: #f59e0b;
    animation: flash-offline 1s ease-in-out infinite;
}

@keyframes flash-offline {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.2; }
}

/* Reconnect Modal — hidden; connection state shown via wifi icon only */
#components-reconnect-modal {
    display: none !important;
}

/* Offline mode — dim interactive controls */
.offline-mode .app-main button,
.offline-mode .app-main input,
.offline-mode .app-main select,
.offline-mode .app-main textarea,
.offline-mode .app-main form {
    opacity: 0.5;
    pointer-events: none;
}

/* Offline no-cache fallback page */
.offline-no-cache {
    max-width: 500px;
    margin: 3rem auto;
    text-align: center;
    padding: 2rem 1.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.offline-no-cache h2 {
    font-size: 1.25rem;
    margin-bottom: 0.75rem;
    color: var(--text);
}

.offline-no-cache p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
}

.offline-no-cache ul {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0 0;
}

.offline-no-cache ul li {
    margin-bottom: 0.35rem;
}

.offline-no-cache a,
a.offline-cached-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
}

.offline-no-cache a:hover,
a.offline-cached-link:hover {
    text-decoration: underline;
}

.app-main {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

/* Map Page Layout */
.map-page {
    display: flex;
    height: calc(100vh - 56px);
    overflow: hidden;
}

.map-panel {
    flex: 1;
    position: relative;
    min-width: 0;
}

/* Draggable split handle between map and side panel */
.split-handle {
    flex-shrink: 0;
    width: 6px;
    background: var(--border);
    cursor: col-resize;
    position: relative;
    z-index: 10;
    transition: background 0.15s;
}
.split-handle:hover,
.split-handle.dragging {
    background: var(--primary-light, #22c55e);
}
/* Wider invisible hit area */
.split-handle::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: -4px;
    right: -4px;
}

.side-panel {
    width: 360px;
    flex-shrink: 0;
    min-height: 0;
    background: var(--surface);
    border-left: 1px solid var(--border);
    overflow-y: scroll;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
    scrollbar-gutter: stable;
}

.side-panel::-webkit-scrollbar { width: 6px; }
.side-panel::-webkit-scrollbar-track { background: transparent; }
.side-panel::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
.side-panel::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

.map-container {
    position: relative;
    width: 100%;
    height: 100%;
}

#leaflet-map, #maplibre-map {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

#maplibre-map {
    display: none;
}

/* Map Filter Bar */
.map-filters {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface);
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    z-index: 500;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    min-width: 600px;
}

/* Time Slider */
.time-slider {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
}

.time-slider label {
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
}

.time-slider input[type="range"] {
    flex: 1;
    accent-color: var(--primary);
}

.time-slider .month-label {
    font-size: 0.8rem;
    font-weight: 600;
    min-width: 3rem;
    text-align: center;
    color: var(--primary);
}

/* Date Range Slider */
.date-range-slider {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
}

.date-range-slider label {
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
}

.range-track {
    flex: 1;
    position: relative;
    height: 20px;
}

.range-track input[type="range"] {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    pointer-events: none;
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    height: 20px;
    margin: 0;
}

.range-track input[type="range"]::-webkit-slider-thumb {
    pointer-events: all;
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary);
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
    cursor: pointer;
    position: relative;
    z-index: 2;
}

.range-track input[type="range"]::-moz-range-thumb {
    pointer-events: all;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary);
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
    cursor: pointer;
}

.range-track input[type="range"]::-webkit-slider-runnable-track {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
}

.range-track input[type="range"]::-moz-range-track {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
}

.range-track .range-min {
    z-index: 1;
}

.range-track .range-max {
    z-index: 2;
}

.range-label {
    font-size: 0.8rem;
    font-weight: 600;
    min-width: 5.5rem;
    text-align: center;
    color: var(--primary);
    white-space: nowrap;
}

.filter-divider {
    width: 1px;
    height: 24px;
    background: var(--border);
    flex-shrink: 0;
}

/* Species Search */
.species-search {
    position: relative;
}

.species-search input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    outline: none;
}

.species-search input:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 2px rgba(34,197,94,0.2);
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    max-height: 300px;
    overflow-y: auto;
    z-index: 10;
}

.search-results .result-item {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
}

.search-results .result-item:hover {
    background: #f1f5f9;
}

.search-results .result-item .common-name {
    font-weight: 600;
}

.search-results .result-item .scientific-name {
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.8rem;
}

.search-results-divider {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.75rem;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}

.search-results-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border);
}

.search-results .result-item-geo .scientific-name {
    font-style: normal;
    font-size: 0.75rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Bird Card */
.bird-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    flex-shrink: 0;
}

.bird-card-header {
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem;
    align-items: flex-start;
}

.bird-card-thumb {
    flex-shrink: 0;
    width: 80px;
    height: 80px;
    border-radius: var(--radius);
    overflow: hidden;
    background: #f1f5f9;
    position: relative;
}

.bird-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.bird-card-thumb-loading {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
}

.bird-card-thumb-loading .loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.bird-card-thumb-empty {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    color: var(--text-muted);
}

.bird-card-thumb-empty svg {
    width: 32px;
    height: 32px;
    opacity: 0.4;
}

/* Upload overlay button on existing thumbnail */
.bird-card-thumb-upload-overlay {
    position: absolute;
    bottom: 4px;
    right: 4px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: none;
    background: rgba(0,0,0,0.55);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s;
    padding: 0;
    z-index: 1;
}

.bird-card-thumb:hover .bird-card-thumb-upload-overlay {
    opacity: 1;
}

.bird-card-thumb-upload-overlay:hover {
    background: rgba(0,0,0,0.75);
}

.bird-card-thumb-upload-overlay.has-error {
    background: rgba(220,38,38,0.8);
    opacity: 1;
}

.bird-card-thumb-upload-overlay.has-error:hover {
    background: rgba(220,38,38,0.95);
}

/* Always visible on touch devices */
@media (hover: none) {
    .bird-card-thumb-upload-overlay {
        opacity: 1;
    }
}

.bird-card-header-info {
    flex: 1;
    min-width: 0;
}

.bird-card-body {
    padding: 1rem;
}

.bird-card h3 {
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
}

.bird-card .scientific-name {
    font-style: italic;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 0.25rem;
}

.bird-card .family-name {
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-bottom: 0.75rem;
}

.bird-card .stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    font-size: 0.8rem;
    margin: 0.75rem 0;
}

.bird-card .stats dt {
    color: var(--text-muted);
}

.bird-card .stats dd {
    font-weight: 600;
}

.bird-card-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.bird-card-title h3 {
    flex: 1;
    min-width: 0;
}

.sound-icon {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 5px;
    border: none;
    border-radius: 50%;
    background: rgba(34,197,94,0.15);
    color: var(--primary);
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}

button.sound-icon {
    font-size: 0;
}

.sound-icon:hover {
    background: rgba(34,197,94,0.25);
    color: var(--primary-dark);
}

.sound-icon.playing {
    background: rgba(22,163,74,0.15);
    color: var(--success);
}

.sound-icon.playing:hover {
    background: rgba(22,163,74,0.25);
}

.sound-icon.disabled {
    color: #cbd5e1;
    background: #f1f5f9;
    cursor: default;
    pointer-events: none;
}

.sound-icon svg {
    width: 100%;
    height: 100%;
}

.bird-audio {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

.bird-audio label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 0.5rem;
}

.bird-audio .audio-credit {
    display: block;
    text-align: right;
    margin-top: 0.25rem;
    color: var(--text-muted);
    font-size: 0.7rem;
}

.bird-audio .audio-credit a {
    color: var(--primary-light);
    text-decoration: none;
}

.bird-audio .audio-credit a:hover {
    text-decoration: underline;
}

.conservation-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
}

.conservation-badge.least-concern { background: #dcfce7; color: #166534; }
.conservation-badge.near-threatened { background: #fef9c3; color: #854d0e; }
.conservation-badge.vulnerable { background: #fed7aa; color: #9a3412; }
.conservation-badge.endangered { background: #fecaca; color: #991b1b; }
.conservation-badge.critically-endangered { background: #fca5a5; color: #7f1d1d; }
.conservation-badge.extinct { background: #1e293b; color: #f8fafc; }

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--text);
}

.form-control {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.875rem;
}

.form-control:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 2px rgba(34,197,94,0.2);
    outline: none;
}

.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #15803d; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #b91c1c; }
.btn-secondary { background: var(--border); color: var(--text); }

/* Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.data-table th, .data-table td {
    padding: 0.5rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    background: #f1f5f9;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
}

.data-table tr:hover {
    background: #f8fafc;
}

/* Status badges */
.status-pending { color: var(--warning); font-weight: 600; }
.status-approved { color: var(--success); font-weight: 600; }
.status-rejected { color: var(--danger); font-weight: 600; }

/* Loading spinner */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.spinner-sm {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid #e2e8f0;
    border-top-color: #94a3b8;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    vertical-align: middle;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius);
    color: white;
    font-size: 0.875rem;
    z-index: 9999;
    animation: slideIn 0.3s ease;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

@keyframes slideIn {
    from { transform: translateY(1rem); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Page containers */
.page-container {
    max-width: 960px;
    margin: 2rem auto;
    padding: 0 1.5rem;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
}

.page-title-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.page-title-row .page-title {
    margin-bottom: 0;
    flex: 1;
}

/* Sighting entry form */
.entry-form {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-row.coords-row {
    grid-template-columns: 1fr 1fr auto;
    align-items: end;
}

.form-group-btn {
    padding-bottom: 0.1rem;
}

.btn-location {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.btn-location:hover:not(:disabled) {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.btn-location:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.species-grid {
    margin-top: 1rem;
}

/* File upload */
.file-upload {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s;
}

.file-upload:hover {
    border-color: var(--primary-light);
}

/* Help Panel */
.help-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--surface);
    color: var(--primary);
    cursor: pointer;
    transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}

.help-icon-btn .icon-circle {
    font-size: 16px;
}

.help-icon-btn:hover {
    background: rgba(34,197,94,0.1);
    box-shadow: 0 0 0 2px rgba(34,197,94,0.2);
}

.help-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    z-index: 1999;
}

.help-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 420px;
    max-width: 90vw;
    height: 100vh;
    background: var(--surface);
    box-shadow: -4px 0 16px rgba(0,0,0,0.15);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    animation: slideInRight 0.25s ease;
}

@keyframes slideInRight {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

.help-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.help-panel-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
}

.help-close-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: var(--radius);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
}

.help-close-btn:hover {
    background: #f1f5f9;
    color: var(--text);
}

.help-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    font-size: 0.875rem;
    line-height: 1.65;
}

.help-panel-body h4 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
    color: var(--primary-dark);
}

.help-panel-body h5 {
    font-size: 0.9rem;
    margin-top: 1.25rem;
    margin-bottom: 0.5rem;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid var(--border);
}

.help-panel-body p {
    margin-bottom: 0.75rem;
    color: var(--text);
}

.help-panel-body ol, .help-panel-body ul {
    margin-left: 1.25rem;
    margin-bottom: 0.75rem;
}

.help-panel-body li {
    margin-bottom: 0.35rem;
}

.help-dl {
    margin-bottom: 0.75rem;
}

.help-dl dt {
    font-weight: 600;
    margin-top: 0.5rem;
    color: var(--text);
}

.help-dl dd {
    margin-left: 0;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.help-code {
    background: #f1f5f9;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem;
    margin: 0.75rem 0;
    overflow-x: auto;
}

.help-code pre {
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.75rem;
    line-height: 1.5;
    white-space: pre;
    margin: 0;
}

/* Profile Page */
.profile-layout {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.profile-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.profile-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    flex-shrink: 0;
}

.profile-header h3 {
    font-size: 1.25rem;
    margin-bottom: 0.15rem;
}

.role-badge {
    display: inline-block;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
}

.role-badge.admin { background: #dbeafe; color: var(--primary-dark); }
.role-badge.user { background: #dcfce7; color: #166534; }

.profile-stats {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 0.75rem;
}

.stat-card {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem;
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
}

.stat-value.stat-approved { color: var(--success); }
.stat-value.stat-pending { color: var(--warning); }
.stat-value.stat-rejected { color: var(--danger); }

.stat-label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
    margin-top: 0.15rem;
}

/* Stats Page */
.stats-page {
    max-width: 1100px;
}

.stats-overview {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.chart-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

.chart-selector .btn {
    font-size: 0.8rem;
    padding: 0.4rem 0.85rem;
}

.chart-container {
    width: 100%;
    min-height: 400px;
    height: 450px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

/* Chart Builder Page */
.charts-page {
    max-width: 1100px;
}

.chart-builder-controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.chart-builder-controls > div > label,
.chart-builder-series-list > label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 0.35rem;
}

.chart-builder-filters {
    max-width: 700px;
}

.filter-row {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
}

.filter-field {
    flex: 1;
    min-width: 0;
}

.filter-label {
    display: block;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 0.2rem;
}

.filter-selection {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.6rem;
    background: #eff6ff;
    border: 1px solid var(--primary-light);
    border-radius: var(--radius);
    font-size: 0.875rem;
    color: var(--primary);
    min-height: 38px;
}

.filter-selection span {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.filter-clear {
    background: none;
    border: none;
    color: var(--primary-light);
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    padding: 0 0.15rem;
    flex-shrink: 0;
}

.filter-clear:hover {
    color: var(--danger);
}

.add-series-btn {
    flex-shrink: 0;
    align-self: flex-end;
    height: 38px;
    margin-top: auto;
}

.filter-preview {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.35rem;
}

.location-search-wrapper {
    position: relative;
}

.location-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 100;
    max-height: 250px;
    overflow-y: auto;
}

.location-option {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: none;
    background: none;
    text-align: left;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text);
}

.location-option:hover {
    background: #f1f5f9;
}

.location-count {
    font-size: 0.75rem;
    color: var(--text-muted);
    flex-shrink: 0;
    margin-left: 0.5rem;
}

.chart-builder-series-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.chart-builder-series-list > label {
    width: 100%;
}

.series-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: #f1f5f9;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.3rem 0.5rem 0.3rem 0.65rem;
    font-size: 0.825rem;
}

.series-color {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.series-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 0 0.15rem;
    margin-left: 0.15rem;
    border-radius: 50%;
}

.series-remove:hover {
    color: var(--danger);
    background: rgba(220, 38, 38, 0.1);
}

.chart-builder-options {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
}

.chart-empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* Responsive — tablet: drop nav labels early so items don't clip */
@media (max-width: 1100px) {
    .nav-label { display: none; }
    .header-nav { gap: 0.25rem; }
    .header-nav a { padding: 0.35rem 0.5rem; }
}

@media (max-width: 900px) {
    .brand-full { display: none; }
    .brand-short { display: inline; }
    .header-org-selector { display: none; }
}

/* Responsive — mobile */
@media (max-width: 768px) {
    .map-page {
        flex-direction: column;
    }
    .split-handle {
        width: 100%;
        height: 6px;
        cursor: row-resize;
    }
    .split-handle::after {
        left: 0;
        right: 0;
        top: -4px;
        bottom: -4px;
    }
    .side-panel {
        width: 100% !important;
        height: 40vh;
        border-left: none;
        border-top: 1px solid var(--border);
    }
    .map-filters {
        min-width: unset;
        flex-direction: column;
        gap: 0.5rem;
        padding: 0.5rem 1rem;
        left: 1rem;
        right: 1rem;
        transform: none;
        width: auto;
    }
    .filter-divider {
        width: 100%;
        height: 1px;
    }
    .form-row {
        grid-template-columns: 1fr;
    }
    .form-row.coords-row {
        grid-template-columns: 1fr 1fr auto;
    }
    .header-row {
        padding: 0 0.5rem;
        gap: 0.25rem;
    }

    .brand-full { display: none; }
    .brand-short { display: inline; }

    .header-brand {
        flex-shrink: 0;
        gap: 0.25rem;
    }

    .connection-indicator {
        margin-left: 0.15rem;
    }

    .desktop-only {
        display: none !important;
    }

    .mobile-only {
        display: flex !important;
    }

    .header-subtitle {
        display: none;
    }

    .nav-label {
        display: none;
    }

    .header-nav {
        gap: 0.15rem;
        -webkit-overflow-scrolling: touch;
    }

    .header-nav a {
        padding: 0.35rem 0.45rem;
    }

    .nav-divider {
        margin: 0 0.1rem;
    }
    .profile-stats {
        grid-template-columns: repeat(2, 1fr);
    }
    .stats-overview {
        grid-template-columns: repeat(2, 1fr);
    }
    .chart-container {
        min-height: 300px;
        height: 350px;
    }
    .chart-builder-filters {
        max-width: 100%;
    }
    .filter-row {
        flex-direction: column;
    }
    .add-series-btn {
        width: 100%;
    }
    .chart-builder-options {
        flex-direction: column;
        gap: 1rem;
    }
}

/* Bird Card — Sections (observers, localities) */
.bird-card-section {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

.bird-card-section h4 {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 0.35rem;
}

.bird-card-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.bird-card-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.15rem 0;
    font-size: 0.8rem;
}

.bird-card-list .list-name {
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.bird-card-list .list-count {
    color: var(--text-muted);
    font-size: 0.7rem;
    flex-shrink: 0;
    margin-left: 0.5rem;
}

/* Bird Card — Mini Chart */
.bird-card-chart {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

.bird-card-chart h4 {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 0.35rem;
}

.bird-card-chart-canvas {
    width: 100%;
    height: 160px;
}

/* Bird Card — Clickable stat */
.stat-link {
    color: var(--primary);
    cursor: pointer;
    text-decoration: none;
    font-weight: inherit;
}

.stat-link:hover {
    text-decoration: underline;
    color: var(--primary-light);
}

/* Multi-species bird card list */
.bird-card-list-header {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
    padding: 0.4rem 0;
}

.bird-card-list-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
}

.bird-card-list-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Collapsed bird card */
.bird-card-collapsed {
    cursor: pointer;
    transition: box-shadow 0.15s, border-color 0.15s;
    height: 98px;
    min-height: 98px;
    flex-shrink: 0;
    overflow: hidden;
}

.bird-card-collapsed:hover {
    border-color: var(--primary-light);
    box-shadow: 0 1px 4px rgba(22,101,52,0.12);
}

.bird-card-collapsed .bird-card-header {
    padding: 0.5rem 0.75rem;
    align-items: center;
    height: 100%;
    gap: 0.6rem;
}

.bird-card-collapsed .bird-card-thumb {
    width: 64px;
    height: 64px;
}

.bird-card-collapsed .bird-card-header-info {
    overflow: hidden;
}

.bird-card-collapsed .bird-card-header-info h3 {
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0;
}

.bird-card-collapsed .bird-card-title {
    margin-bottom: 0;
}

.bird-card-collapsed .scientific-name {
    font-size: 0.7rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0.15rem;
}

.bird-card-collapsed .bird-card-collapsed-meta {
    display: flex;
    margin: 0;
}

.bird-card-collapsed .conservation-badge {
    display: none;
}

.bird-card-expand-hint {
    display: flex;
    align-items: center;
    color: var(--text-muted);
    flex-shrink: 0;
    transition: transform 0.2s;
}

.bird-card-expand-hint {
    cursor: pointer;
}

.bird-card-expand-hint.expanded {
    transform: rotate(180deg);
}

.bird-card-expand-hint:hover {
    color: var(--primary);
}

.bird-card-collapsed:hover .bird-card-expand-hint {
    color: var(--primary);
    transform: translateY(2px);
}

/* Collapsed card metadata row */
.bird-card-collapsed-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.6rem;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin: 0.2rem 0 0.3rem;
}

/* Sighting context bar in expanded card */
.bird-card-sighting-context {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.75rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    padding-bottom: 0.5rem;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.meta-item {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    white-space: nowrap;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.meta-item svg {
    flex-shrink: 0;
    opacity: 0.6;
}

/* Info icon (? button) */
.info-icon {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 5px;
    border-radius: 50%;
    background: rgba(34,197,94,0.15);
    cursor: pointer;
    color: var(--primary);
    transition: background 0.15s, color 0.15s;
}

.info-icon .icon-circle {
    font-size: 14px;
}

.info-icon:hover {
    background: rgba(34,197,94,0.25);
    color: var(--primary-dark);
}

/* Wiki info panel */
.bird-card-info-panel {
    padding: 0.6rem 0.75rem;
    border-top: 1px solid var(--border);
    background: #f8fafc;
    font-size: 0.8rem;
    line-height: 1.6;
    color: var(--text);
    max-height: 200px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.bird-card-info-panel::-webkit-scrollbar { width: 3px; }
.bird-card-info-panel::-webkit-scrollbar-track { background: transparent; }
.bird-card-info-panel::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.bird-card-info-panel p {
    margin: 0;
}

.bird-card-info-panel .text-muted {
    color: var(--text-muted);
    font-style: italic;
}

/* Image Lightbox */
.image-lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100000;
    cursor: pointer;
}

.image-lightbox img {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    cursor: default;
}

.lightbox-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(255,255,255,0.15);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.lightbox-close:hover {
    background: rgba(255,255,255,0.3);
}

.lightbox-revert {
    position: absolute;
    top: 1rem;
    left: 1rem;
    background: rgba(220,38,38,0.7);
    border: none;
    color: white;
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8rem;
    font-family: inherit;
    transition: background 0.15s;
    z-index: 10;
}

.lightbox-revert:hover {
    background: rgba(220,38,38,0.9);
}

.lightbox-revert:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.lightbox-upload {
    position: absolute;
    top: 1rem;
    left: 1rem;
    background: rgba(21,128,61,0.7);
    border: none;
    color: white;
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8rem;
    font-family: inherit;
    transition: background 0.15s;
    z-index: 10;
}

.lightbox-upload:hover {
    background: rgba(21,128,61,0.9);
}

/* When both revert and upload are shown, stack them */
.lightbox-revert + .lightbox-upload {
    left: auto;
    right: 4.5rem;
    top: 1rem;
}

/* Clickable thumb in expanded card */
.bird-card:not(.bird-card-collapsed) .bird-card-thumb {
    cursor: pointer;
}

.bird-card:not(.bird-card-collapsed) .bird-card-thumb:hover img {
    opacity: 0.85;
    transition: opacity 0.15s;
}

/* Map Search (unified mode selector) */
.map-search {
    position: relative;
}

.search-bar {
    display: flex;
    align-items: stretch;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.search-mode-icons {
    display: flex;
    background: var(--bg);
    border-right: 1px solid var(--border);
}

.mode-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 100%;
    padding: 0.4rem;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    transition: background 0.15s, color 0.15s;
}

.mode-btn svg {
    width: 16px;
    height: 16px;
}

.mode-btn:hover {
    background: var(--border);
    color: var(--text);
}

.mode-btn.active {
    background: var(--primary);
    color: white;
}

.search-bar input {
    flex: 1;
    min-width: 0;
    padding: 0.5rem 0.75rem;
    border: none;
    font-size: 0.875rem;
    outline: none;
}

.search-bar input:focus {
    box-shadow: inset 0 0 0 2px rgba(34,197,94,0.15);
}

.map-search .search-input-wrapper {
    position: relative;
}

.active-filter-chip {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-top: 0.5rem;
    padding: 0.35rem 0.6rem;
    background: #eff6ff;
    border: 1px solid var(--primary-light);
    border-radius: var(--radius);
    font-size: 0.825rem;
    color: var(--primary);
}

.active-filter-chip span {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.active-filter-chip button {
    background: none;
    border: none;
    color: var(--primary-light);
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    padding: 0 0.15rem;
}

.active-filter-chip button:hover {
    color: var(--danger);
}

/* Species Browse Page */
.species-browse-page {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

.species-browse-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.species-search-box input {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    width: 280px;
    outline: none;
}

.species-search-box input:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 2px rgba(34,197,94,0.15);
}

.species-sort-select {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    background: var(--surface);
    color: var(--text);
    outline: none;
    cursor: pointer;
}

.species-sort-select:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 2px rgba(34,197,94,0.15);
}

.species-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 1.5rem;
}

.species-card-grid .bird-card {
    margin: 0;
}

@media (max-width: 768px) {
    .species-browse-header {
        flex-direction: column;
        align-items: stretch;
    }
    .species-search-box input {
        width: 100%;
    }
    .species-card-grid {
        grid-template-columns: 1fr;
    }
}

/* Submit Page — Tabs */
.submit-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.submit-tab {
    padding: 0.5rem 1.25rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.submit-tab:hover {
    border-color: var(--primary-light);
    color: var(--text);
}

.submit-tab.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Drop Zone */
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
    transition: border-color 0.15s, background 0.15s;
}

.drop-zone:hover {
    border-color: var(--primary-light);
}

.drop-zone.drag-over {
    border-color: var(--primary);
    background: rgba(34,197,94,0.05);
}

.drop-zone-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.drop-zone-text svg {
    color: var(--primary-light);
}

/* Photo Preview Grid */
.photo-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
    margin-top: 0.75rem;
}

.photo-preview-item {
    position: relative;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: #f1f5f9;
}

.photo-preview-item img {
    width: 100%;
    height: 100px;
    object-fit: cover;
    display: block;
}

.photo-preview-info {
    padding: 0.35rem 0.5rem;
    font-size: 0.7rem;
    line-height: 1.4;
}

.photo-preview-name {
    display: block;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
}

.photo-preview-meta {
    display: block;
    color: var(--text-muted);
}

/* Species Search Input (entry form autocomplete) */
.species-search-input {
    position: relative;
}

.species-search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    max-height: 250px;
    overflow-y: auto;
    z-index: 20;
}

.species-search-dropdown .result-item {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.species-search-dropdown .result-item:hover {
    background: #f1f5f9;
}

.species-search-dropdown .result-item .common-name {
    font-weight: 600;
}

.species-search-dropdown .result-item .scientific-name {
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.8rem;
}

.species-search-dropdown .result-item .species-code {
    margin-left: auto;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.75rem;
    background: #f1f5f9;
    padding: 0.1rem 0.4rem;
    border-radius: var(--radius);
    color: var(--primary);
    font-weight: 600;
}

/* Report Sighting Button */
.report-sighting-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
}

.report-sighting-btn svg {
    flex-shrink: 0;
}

.btn-sm {
    padding: 0.3rem 0.75rem;
    font-size: 0.8rem;
}

/* Species Code Badge (on bird cards) */
.species-code {
    display: inline-block;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.7rem;
    font-style: normal;
    font-weight: 600;
    background: #f1f5f9;
    color: var(--primary);
    padding: 0.05rem 0.35rem;
    border-radius: var(--radius);
    vertical-align: middle;
    margin-left: 0.25rem;
}

@media (max-width: 768px) {
    .submit-tabs {
        flex-wrap: wrap;
    }
    .photo-preview-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }
}

/* ===== About Page ===== */
.about-page {
    max-width: 800px;
    margin: 0 auto;
    padding: 1rem 0;
}

.about-hero {
    text-align: center;
    padding: 2rem 0 1.5rem;
    border-bottom: 2px solid var(--primary);
    margin-bottom: 2rem;
}

.about-flags {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.about-flags svg {
    border-radius: 3px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.about-hero h1 {
    font-size: 2.5rem;
    color: var(--primary);
    margin: 0;
}

.about-tagline {
    font-size: 1.1rem;
    color: var(--text-muted);
    margin-top: 0.75rem;
    line-height: 1.6;
}

.about-section {
    margin-bottom: 2rem;
}

.about-section h2 {
    color: var(--primary);
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
}

.about-section h3 {
    margin-top: 1.25rem;
    margin-bottom: 0.5rem;
}

.about-section p {
    line-height: 1.7;
    margin-bottom: 0.75rem;
}

.about-section ul, .about-section ol {
    line-height: 1.7;
    padding-left: 1.5rem;
    margin-bottom: 0.75rem;
}

.about-section li {
    margin-bottom: 0.35rem;
}

.about-dl {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.5rem 1rem;
    margin: 1rem 0;
}

.about-dl dt {
    font-weight: 600;
    color: var(--text);
}

.about-dl dd {
    margin: 0;
    color: var(--text-muted);
    line-height: 1.6;
}

.about-footer-section {
    text-align: center;
    padding: 1.5rem;
    background: #f0f9ff;
    border-radius: var(--radius);
    border: 1px solid #bae6fd;
}

.about-footer-section p {
    font-style: italic;
    color: var(--primary);
    font-size: 1rem;
    margin: 0;
}

/* ===== Guide Page ===== */
.guide-page {
    max-width: 800px;
    margin: 0 auto;
    padding: 1rem 0 2rem;
}

.guide-intro {
    font-size: 1rem;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 1.5rem;
}

.guide-toc {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.5rem;
    margin-bottom: 2rem;
}

.guide-toc h3 {
    margin: 0 0 0.75rem;
    font-size: 1rem;
}

.guide-toc ol {
    margin: 0;
    padding-left: 1.25rem;
    columns: 2;
    column-gap: 2rem;
}

.guide-toc li {
    margin-bottom: 0.35rem;
    font-size: 0.85rem;
}

.guide-toc a {
    color: var(--primary);
    text-decoration: none;
}

.guide-toc a:hover {
    text-decoration: underline;
}

.guide-section {
    margin-bottom: 2.5rem;
    padding-top: 0.5rem;
}

.guide-section h2 {
    color: var(--primary);
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
}

.guide-section h3 {
    margin-top: 1.25rem;
    margin-bottom: 0.5rem;
}

.guide-section p {
    line-height: 1.7;
    margin-bottom: 0.75rem;
}

.guide-section ul, .guide-section ol {
    line-height: 1.7;
    padding-left: 1.5rem;
    margin-bottom: 0.75rem;
}

.guide-section li {
    margin-bottom: 0.35rem;
}

.guide-section code {
    background: #f1f5f9;
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
    font-size: 0.85em;
    font-family: 'Consolas', 'Monaco', monospace;
}

.guide-dl {
    display: grid;
    grid-template-columns: minmax(120px, auto) 1fr;
    gap: 0.5rem 1rem;
    margin: 1rem 0;
}

.guide-dl dt {
    font-weight: 600;
    color: var(--text);
}

.guide-dl dd {
    margin: 0;
    color: var(--text-muted);
    line-height: 1.6;
}

/* ===== Organisations Page ===== */
.org-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.org-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    overflow: hidden;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.org-card:hover {
    border-color: var(--primary-light);
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.org-card.expanded {
    border-color: var(--primary);
}

.org-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
}

.org-name {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.org-meta {
    display: flex;
    gap: 1rem;
    margin-top: 0.25rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.org-chevron {
    flex-shrink: 0;
    color: var(--text-muted);
    transition: transform 0.2s;
}

.org-card.expanded .org-chevron {
    transform: rotate(180deg);
}

.org-card-body {
    padding: 0 1.25rem 1.25rem;
    border-top: 1px solid var(--border);
    padding-top: 1rem;
    cursor: default;
}

.org-card-body p {
    line-height: 1.6;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.org-stats {
    display: flex;
    gap: 2rem;
    margin-top: 0.75rem;
}

.org-stat {
    display: flex;
    flex-direction: column;
}

.org-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.org-stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ===== Leaflet Control Overrides ===== */
.leaflet-bar a,
.leaflet-control-layers-toggle {
    background-color: #e5e7eb !important;
    color: #1f2937 !important;
}

.leaflet-bar a:hover,
.leaflet-control-layers-toggle:hover {
    background-color: #d1d5db !important;
}

.leaflet-control-layers {
    background: #e5e7eb !important;
    border-color: #9ca3af !important;
}

/* ===== Atlas Grid Overlay (Leaflet) ===== */
.atlas-grid-control {
    background: #e5e7eb;
    border-radius: 4px;
}

.atlas-grid-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    color: #1f2937;
    text-decoration: none;
    line-height: 1;
}

.atlas-grid-btn svg {
    display: block;
}

.atlas-grid-btn:hover {
    background: #d1d5db;
}

.atlas-grid-btn.active {
    background: var(--primary);
    color: white;
}

.atlas-grid-btn.active:hover {
    background: var(--primary);
}

/* 3D Terrain toggle */
.atlas-3d-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    cursor: pointer;
}

.atlas-3d-btn svg {
    display: block;
}

.atlas-3d-btn:hover {
    background: #d1d5db;
}

/* Locate me control */
.atlas-locate-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    color: #1f2937;
    text-decoration: none;
    line-height: 1;
    cursor: pointer;
}

.atlas-locate-btn svg { display: block; }

.atlas-locate-btn:hover { background: #d1d5db; }

.atlas-locate-btn.locating {
    animation: locate-spin 1s linear infinite;
}

.atlas-locate-btn.tracking {
    background: var(--primary);
    color: white;
}

.atlas-locate-btn.tracking:hover {
    background: var(--primary-dark);
}

@keyframes locate-spin {
    to { transform: rotate(360deg); }
}

/* Blue location dot pulse */
.location-dot-pulse {
    animation: loc-pulse 2s ease-out infinite;
}

@keyframes loc-pulse {
    0% { opacity: 1; }
    50% { opacity: 0.7; }
    100% { opacity: 1; }
}

/* MapLibre control buttons */
.maplibre-ctrl-btn {
    font-weight: 700;
    font-size: 11px;
    padding: 0;
    width: 29px;
    height: 29px;
    cursor: pointer;
    background: #fff;
    border: 0;
    border-radius: 4px;
    color: #333;
    line-height: 29px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.maplibre-ctrl-btn:hover {
    background: #e5e7eb;
}

.maplibre-ctrl-btn.active {
    background: var(--primary);
    color: white;
}

.maplibre-ctrl-btn.active:hover {
    background: var(--primary);
}

/* Exaggeration slider control */
.maplibre-exag-ctrl {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255,255,255,0.9);
    backdrop-filter: blur(4px);
    border-radius: 6px;
    padding: 4px 10px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
    pointer-events: auto;
}

.maplibre-exag-icon {
    display: flex;
    align-items: center;
    color: #555;
    flex-shrink: 0;
}

.maplibre-exag-slider {
    width: 90px;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: #cbd5e1;
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

.maplibre-exag-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--primary, #166534);
    border: 2px solid #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
    cursor: pointer;
}

.maplibre-exag-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--primary, #166534);
    border: 2px solid #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
    cursor: pointer;
}

.maplibre-exag-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: #333;
    min-width: 2.5em;
    text-align: right;
}

/* MapLibre popup styling to match Leaflet tooltips */
.maplibregl-popup-content {
    font-size: 0.8rem;
    padding: 6px 10px;
    border-radius: 4px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.grid-label {
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 10px;
    color: #6b7280;
    background: rgba(255,255,255,0.75);
    padding: 0 2px;
    white-space: nowrap;
    pointer-events: none;
}

.grid-label-lat {
    text-align: left;
}

.grid-label-lon {
    text-align: center;
}

.atlas-grid-btn-3d.active {
    background: var(--primary) !important;
    color: white;
}

.atlas-grid-btn-3d.active:hover {
    background: var(--primary-dark) !important;
}

/* ===== Avatar Crop ===== */
.avatar-crop-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100000;
}

.avatar-crop-dialog {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    max-width: 90vw;
    max-height: 90vh;
    overflow: auto;
}

.crop-region {
    position: absolute;
    border: 2px solid white;
    box-shadow: 0 0 0 9999px rgba(0,0,0,0.45);
    cursor: move;
    border-radius: 50%;
}
.crop-region.detect-crop {
    border-radius: 0;
}

.crop-region .crop-handle {
    position: absolute;
    width: 14px;
    height: 14px;
    background: white;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
    pointer-events: auto;
}
.crop-handle.tl { top: -5px;    left: -5px;   cursor: nwse-resize; }
.crop-handle.tr { top: -5px;    right: -5px;  cursor: nesw-resize; }
.crop-handle.bl { bottom: -5px; left: -5px;   cursor: nesw-resize; }
.crop-handle.br { bottom: -5px; right: -5px;  cursor: nwse-resize; }
.crop-handle.t  { top: -5px;    left: calc(50% - 7px); cursor: ns-resize; }
.crop-handle.b  { bottom: -5px; left: calc(50% - 7px); cursor: ns-resize; }
.crop-handle.l  { left: -5px;   top: calc(50% - 7px);  cursor: ew-resize; }
.crop-handle.r  { right: -5px;  top: calc(50% - 7px);  cursor: ew-resize; }

.profile-avatar.clickable {
    cursor: pointer;
    transition: opacity 0.15s, box-shadow 0.15s;
}

.profile-avatar.clickable:hover {
    opacity: 0.85;
    box-shadow: 0 0 0 3px rgba(34,197,94,0.3);
}

.profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

/* ===== Alert Styles ===== */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

.alert-success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.alert-danger {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* ===== Toggle Label ===== */
.toggle-label {
    cursor: pointer;
    user-select: none;
}

.toggle-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

/* ===== Members Table ===== */
.members-table {
    font-size: 0.8rem;
}

.members-table th {
    font-size: 0.7rem;
}

.members-table td {
    padding: 0.4rem 0.75rem;
}

/* ===== User Thumbnail ===== */
.user-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
    vertical-align: middle;
    margin-right: 0.35rem;
}

/* ===== Organisation Application Form ===== */
.application-form {
    border-top: 2px solid var(--border);
    padding-top: 1.5rem;
}

.application-form h3 {
    color: var(--primary-dark);
}

.application-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    overflow: hidden;
}

.application-card .org-card-body p {
    line-height: 1.6;
    color: var(--text-muted);
    font-size: 0.9rem;
}

@media (max-width: 768px) {
    .about-hero h1 {
        font-size: 1.8rem;
    }
    .about-dl, .guide-dl {
        grid-template-columns: 1fr;
    }
    .guide-toc ol {
        columns: 1;
    }
    .org-meta {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
}

/* ── Detect Page ── */

.detect-disabled-notice {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}
.detect-disabled-notice svg {
    opacity: 0.4;
    margin-bottom: 1rem;
}

.detect-upload-zone {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 3rem 2rem;
    text-align: center;
    transition: border-color 0.2s, background 0.2s;
    cursor: pointer;
    max-width: 600px;
    margin: 1rem auto;
}
.detect-upload-zone:hover,
.detect-upload-zone.dragging {
    border-color: var(--primary);
    background: rgba(22, 101, 52, 0.04);
}
.detect-upload-icon {
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}
.detect-upload-text {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0.5rem 0 0.25rem;
}
.detect-upload-hint {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 1rem;
}
.detect-browse-btn {
    display: inline-block;
    cursor: pointer;
}
.detect-error {
    color: #dc2626;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

/* Detection Card */
.detect-card {
    max-width: 600px;
    margin: 1rem auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.detect-card-header {
    display: flex;
    gap: 1rem;
    padding: 1rem;
}
.detect-card-thumb {
    width: 80px;
    height: 80px;
    border-radius: var(--radius);
    overflow: hidden;
    flex-shrink: 0;
    cursor: pointer;
    position: relative;
    background: #f1f5f9;
}
.detect-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.detect-card-thumb-video {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    background: #e2e8f0;
}
.detect-card-thumb-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
}
.detect-card-thumb-overlay .spinner-sm {
    width: 24px;
    height: 24px;
    border-width: 2px;
}
.detect-card-info {
    flex: 1;
    min-width: 0;
}
.detect-card-filename {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}
.detect-card-filename strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.detect-media-badge {
    background: var(--primary);
    color: white;
    font-size: 0.7rem;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    text-transform: uppercase;
    font-weight: 600;
    flex-shrink: 0;
}
.detect-card-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.4;
}
.detect-card-status {
    margin-top: 0.5rem;
}
.detect-status-text {
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.detect-status-text.pending,
.detect-status-text.processing {
    color: var(--warning);
}
.detect-status-text.failed {
    color: var(--danger);
    font-weight: 600;
}
.detect-status-detail {
    font-size: 0.78rem;
    color: var(--text-muted);
    display: block;
    margin-top: 0.2rem;
}
.detect-card-detection {
    padding: 0.5rem 0;
    border-top: 1px solid var(--border);
}
.detect-card-detection:first-child {
    border-top: none;
}
.detect-card-detection-top {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.detect-card-species {
    font-weight: 600;
    font-size: 0.95rem;
}
.detect-source-badge {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.detect-source-badge.video {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
}
.detect-source-badge.audio {
    background: rgba(245, 158, 11, 0.15);
    color: #d97706;
}
.detect-card-conf {
    font-size: 0.8rem;
    color: var(--text-muted);
}
.detect-card-add-btn {
    margin-left: auto;
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
    border-radius: 4px;
    width: 24px;
    height: 24px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
.detect-card-add-btn:hover {
    background: #166534;
    color: white;
    border-color: #166534;
}
.detect-card-sci {
    font-style: italic;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}
.detect-card-footer {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border);
    background: #f8fafc;
}
.detect-confidence {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
}
.detect-confidence-bar {
    height: 6px;
    background: var(--primary);
    border-radius: 3px;
    flex: 1;
    min-width: 0;
}
.detect-header-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.35rem;
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s, border-color 0.15s;
    text-decoration: none;
}
.detect-header-btn:hover {
    color: var(--primary);
    border-color: var(--primary);
}

/* Model Setup Panel */
.detect-model-panel {
    max-width: 600px;
    margin: 0.75rem auto 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
}
.detect-model-panel h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin: 0 0 0.75rem;
}
.detect-model-info {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 0.75rem;
}
.detect-model-row {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    font-size: 0.85rem;
}
.detect-model-label {
    color: var(--text-muted);
    flex-shrink: 0;
    min-width: 80px;
}
.detect-model-value {
    color: var(--text);
}
.detect-model-value.mono {
    font-family: monospace;
    font-size: 0.8rem;
}
.detect-model-value.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 350px;
}
.detect-model-badge {
    font-size: 0.7rem;
    padding: 0.1rem 0.5rem;
    border-radius: 4px;
    font-weight: 600;
}
.detect-model-badge.loaded {
    background: #dcfce7;
    color: #166534;
}
.detect-model-badge.not-loaded {
    background: #fef2f2;
    color: #dc2626;
}
.detect-model-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}
.detect-model-hint code {
    background: #f1f5f9;
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    font-size: 0.75rem;
}
.detect-model-progress {
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 0.5rem;
}
.detect-model-progress-bar {
    height: 100%;
    background: var(--primary);
    border-radius: 3px;
    transition: width 0.3s;
}

.detect-action-row {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
}
.detect-camera-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}
.detect-live-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: #0891b2;
    color: #fff;
    border-color: #0891b2;
}
.detect-live-btn:hover {
    background: #0e7490;
    border-color: #0e7490;
}

.detect-camera-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.85);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.detect-camera-container {
    max-width: 640px;
    width: 100%;
    padding: 1rem;
}
.detect-camera-container video {
    width: 100%;
    border-radius: 8px;
    background: #000;
}
.detect-camera-controls {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    margin-top: 1rem;
}

.btn-danger {
    background: #dc2626;
    color: white;
    border: none;
    padding: 0.4rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
}
.btn-danger:hover {
    background: #b91c1c;
}

.detect-feedback {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.5rem;
    font-size: 0.8rem;
}
.detect-feedback-label {
    color: var(--text-muted);
}
.detect-feedback-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.15rem 0.5rem;
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.15s;
}
.detect-feedback-btn.yes:hover {
    background: #dcfce7;
    border-color: #166534;
    color: #166534;
}
.detect-feedback-btn.no:hover {
    background: #fef2f2;
    border-color: #dc2626;
    color: #dc2626;
}
.detect-feedback-btn.unknown {
    color: #92400e;
    font-weight: 700;
}
.detect-feedback-btn.unknown:hover {
    background: #fef3c7;
    border-color: #92400e;
    color: #92400e;
}
.detect-correction {
    display: flex;
    gap: 0.4rem;
    margin-top: 0.35rem;
}
.detect-correction-input {
    flex: 1;
    font-size: 0.8rem;
    padding: 0.2rem 0.4rem;
    border: 1px solid var(--border);
    border-radius: 4px;
}
.detect-feedback-thanks {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: #166534;
    font-style: italic;
}

/* ── Training Data Page ── */

.train-species-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 1rem;
}
.train-species-thumb {
    width: 80px;
    height: 80px;
    border-radius: 10px;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--surface);
}
.train-species-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.train-species-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}
.train-species-info h3 {
    margin: 0 0 0.25rem;
    font-size: 1.2rem;
}
.train-species-scientific {
    font-style: italic;
    color: var(--text-muted);
    font-size: 0.9rem;
}
.train-species-code {
    display: inline-block;
    font-size: 0.75rem;
    background: rgba(22, 101, 52, 0.1);
    color: var(--primary);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    margin-left: 0.5rem;
    font-weight: 600;
}

.train-upload-zone {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 2rem 1.5rem;
    text-align: center;
    transition: border-color 0.2s, background 0.2s;
    cursor: pointer;
    max-width: 600px;
    margin: 0 auto 1.5rem;
}
.train-upload-zone:hover,
.train-upload-zone.dragging {
    border-color: var(--primary);
    background: rgba(22, 101, 52, 0.04);
}

.train-success-toast {
    text-align: center;
    padding: 0.5rem 1rem;
    background: rgba(22, 163, 74, 0.12);
    color: #166534;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 1rem;
    animation: fadeIn 0.3s;
}

.train-media-section h3 {
    font-size: 1rem;
    margin: 0 0 0.75rem;
}
.train-media-count {
    color: var(--text-muted);
    font-weight: 400;
    font-size: 0.85rem;
}
.train-empty {
    color: var(--text-muted);
    text-align: center;
    padding: 2rem;
    font-size: 0.9rem;
}

.train-media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.75rem;
}
.train-media-card {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    transition: box-shadow 0.15s;
}
.train-media-card:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.train-media-thumb {
    width: 100%;
    aspect-ratio: 1;
    overflow: hidden;
    position: relative;
    background: #f1f5f9;
}
.train-media-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.train-media-icon {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}
.train-media-badge {
    position: absolute;
    bottom: 4px;
    right: 4px;
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
    letter-spacing: 0.5px;
}
.train-media-badge.photo {
    background: rgba(59, 130, 246, 0.2);
    color: #2563eb;
}
.train-media-badge.video {
    background: rgba(168, 85, 247, 0.2);
    color: #7c3aed;
}
.train-media-badge.audio {
    background: rgba(245, 158, 11, 0.2);
    color: #d97706;
}

.train-media-details {
    padding: 0.5rem 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}
.train-media-name {
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.train-media-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}
.train-media-notes {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
}

.train-media-confirm-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    background: rgba(0,0,0,0.7);
    z-index: 2;
}
.train-media-confirm-overlay span {
    color: white;
    font-size: 0.85rem;
    font-weight: 500;
}
.train-media-delete {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(0,0,0,0.5);
    border: none;
    color: white;
    cursor: pointer;
    padding: 0.3rem;
    border-radius: 4px;
    transition: background 0.15s;
    opacity: 0;
    z-index: 1;
}
.train-media-card:hover .train-media-delete {
    opacity: 1;
}
.train-media-delete:hover {
    background: rgba(220, 38, 38, 0.8);
}

@media (hover: none) {
    .train-media-delete {
        opacity: 1;
    }
}
.btn-danger {
    background: var(--danger);
    color: white;
    border: none;
}
.btn-danger:hover {
    background: #dc2626;
}

/* Bulk Training Upload */
.bulk-action-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 1rem;
    margin-top: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.bulk-file-summary {
    font-size: 0.85rem;
    color: var(--text-muted);
}
.bulk-action-buttons {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.bulk-progress {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--primary);
}

.bulk-train-table-wrap {
    margin-top: 0.75rem;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}
.bulk-train-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}
.bulk-train-table thead {
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
}
.bulk-train-table th {
    padding: 0.5rem 0.75rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    white-space: nowrap;
}
.bulk-train-table td {
    padding: 0.5rem 0.75rem;
    vertical-align: middle;
    border-top: 1px solid var(--border);
}
.bulk-col-thumb { width: 80px; }
.bulk-col-file { min-width: 120px; }
.bulk-col-species { min-width: 220px; }
.bulk-col-status { width: 100px; }
.bulk-col-actions { width: 120px; white-space: nowrap; }

.bulk-thumb {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: 6px;
    display: block;
}
.bulk-thumb-clickable {
    cursor: pointer;
    transition: box-shadow 0.15s, transform 0.15s;
}
.bulk-thumb-clickable:hover {
    box-shadow: 0 0 0 2px var(--primary);
    transform: scale(1.05);
}
.bulk-thumb-empty {
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f1f5f9;
    border-radius: 6px;
    color: var(--text-muted);
}
.bulk-filename {
    display: block;
    font-weight: 500;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.bulk-filesize {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Species search input + dropdown */
.bulk-species-search {
    position: relative;
}
.bulk-species-input {
    padding: 0.35rem 0.6rem !important;
    font-size: 0.85rem !important;
}
.bulk-species-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 100;
    max-height: 220px;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0 0 var(--radius) var(--radius);
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}
.bulk-species-option {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.35rem;
    width: 100%;
    padding: 0.5rem 0.6rem;
    border: none;
    background: none;
    text-align: left;
    cursor: pointer;
    font-size: 0.85rem;
}
.bulk-species-option:hover {
    background: rgba(22,101,52,0.06);
}
.bulk-species-option-name {
    font-weight: 500;
    color: var(--text);
}
.bulk-species-option-code {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary);
}
.bulk-species-option-sci {
    font-style: italic;
    font-size: 0.75rem;
    color: var(--text-muted);
    width: 100%;
}

/* Species chip (assigned) */
.bulk-species-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.6rem;
    background: rgba(22,163,74,0.1);
    color: var(--primary-dark);
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 500;
}
.bulk-species-chip-clear {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    padding: 0;
    cursor: pointer;
    color: var(--text-muted);
    border-radius: 50%;
}
.bulk-species-chip-clear:hover {
    color: var(--danger);
}

/* Status badges */
.bulk-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}
.bulk-status-badge.pending { background: #f1f5f9; color: var(--text-muted); }
.bulk-status-badge.uploading { background: #eff6ff; color: #2563eb; }
.bulk-status-badge.done { background: #dcfce7; color: #166534; }
.bulk-status-badge.error { background: #fef2f2; color: #dc2626; cursor: help; }
.spinner-sm {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid rgba(37,99,235,0.2);
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* Row states */
.bulk-row-done { opacity: 0.55; }
.bulk-row-error td { background: #fef2f2; }

.bulk-remove-btn {
    padding: 0.25rem;
    color: var(--text-muted);
}
.bulk-remove-btn:hover { color: var(--danger); }

.bulk-col-actions {
    display: flex;
    gap: 0.35rem;
    align-items: center;
}

@media (max-width: 640px) {
    .bulk-action-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    .bulk-train-table-wrap {
        margin-left: -1rem;
        margin-right: -1rem;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }
}

/* ──────────────────────────────────────
   Live Detection Page
   ────────────────────────────────────── */

.live-detect-page {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 56px);
    overflow: hidden;
}

/* Header */
.live-detect-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    flex-shrink: 0;
}
.live-back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    color: var(--primary);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
}
.live-back-link:hover { text-decoration: underline; }
.live-detect-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    flex: 1;
}
.live-status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-muted);
    flex-shrink: 0;
}
.live-status-dot.pulsing {
    background: var(--success);
    animation: live-pulse 1.5s ease-in-out infinite;
}
@keyframes live-pulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.5); }
    50% { opacity: 0.7; box-shadow: 0 0 0 6px rgba(22, 163, 74, 0); }
}

/* Camera viewport */
.live-viewport {
    position: relative;
    flex: 1;
    min-height: 0;
    background: #111;
    overflow: hidden;
    transition: flex 0.3s, min-height 0.3s;
}
.live-viewport video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.live-viewport canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* Mic indicator (hidden by default, shown when video minimized) */
.live-viewport-mic-indicator {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    color: rgba(255,255,255,0.5);
    font-size: 0.8rem;
}

/* Video minimized / audio-only mode */
.video-minimized .live-viewport {
    flex: 0 0 auto;
    min-height: 48px;
    max-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.video-minimized .live-viewport video,
.video-minimized .live-viewport canvas,
.video-minimized .live-viewport .live-toast-container,
.video-minimized .live-viewport .live-viewport-prompt {
    display: none;
}
.video-minimized .live-viewport-mic-indicator {
    display: flex;
}
.video-minimized .live-species-panel {
    flex: 1;
    max-height: none;
}
.live-viewport-prompt {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: #cbd5e1;
    background: none;
    border: 2px dashed rgba(203, 213, 225, 0.35);
    border-radius: 1rem;
    padding: 2.5rem 3rem;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s;
}
.live-viewport-prompt:hover:not(:disabled) {
    border-color: rgba(203, 213, 225, 0.7);
    color: #e2e8f0;
}
.live-viewport-prompt:disabled { opacity: 0.4; cursor: not-allowed; }
.live-viewport-prompt svg { margin-bottom: 0.75rem; opacity: 0.5; }
.live-viewport-prompt p { font-size: 0.9rem; margin: 0; }

/* Toast container */
.live-toast-container {
    position: absolute;
    top: 0.75rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    pointer-events: none;
    z-index: 10;
}
.live-toast {
    padding: 0.35rem 0.85rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #fff;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.3s, transform 0.3s;
    white-space: nowrap;
}
.live-toast-visible {
    opacity: 1;
    transform: translateY(0);
}
.live-toast-exit {
    opacity: 0;
    transform: translateY(-10px);
}
.live-toast-video { background: rgba(22, 163, 74, 0.85); }
.live-toast-audio { background: rgba(217, 119, 6, 0.85); }

/* Error message */
.live-error {
    padding: 0.6rem 1rem;
    background: #fef2f2;
    color: var(--danger);
    border-bottom: 1px solid #fecaca;
    font-size: 0.85rem;
    flex-shrink: 0;
}

/* Controls bar */
.live-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    flex-shrink: 0;
}
.live-controls .btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}
.live-controls .btn-danger {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}
.live-controls .btn-danger:hover { opacity: 0.9; }
.live-control-select {
    padding: 0.3rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.8rem;
    background: var(--surface);
    color: var(--text);
}
.live-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.3rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    opacity: 0.5;
    transition: all 0.15s ease;
    text-decoration: line-through;
}
.live-toggle-btn.active {
    opacity: 1;
    color: var(--text);
    border-color: var(--primary);
    background: rgba(22, 101, 52, 0.06);
    text-decoration: none;
}
.live-toggle-btn:hover { opacity: 0.85; }
.live-toggle-btn svg { flex-shrink: 0; }
.live-species-count {
    margin-left: auto;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Admin settings panel */
.live-settings-panel {
    max-width: 600px;
    margin: 0.75rem auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    flex-shrink: 0;
}
.live-settings-panel h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin: 0 0 0.75rem;
}
.live-settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem 1rem;
    align-items: center;
    margin-bottom: 0.75rem;
}
.live-settings-grid label {
    font-size: 0.85rem;
    color: var(--text-muted);
}
.live-settings-grid select {
    padding: 0.3rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.85rem;
    background: var(--surface);
    color: var(--text);
}
.live-settings-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.live-settings-saved {
    font-size: 0.8rem;
    color: var(--success);
    font-weight: 500;
}

/* Activity bar */
.live-activity {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem 0.75rem;
    padding: 0.25rem 1rem;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
    font-size: 0.75rem;
    font-family: 'Consolas', 'Monaco', monospace;
    color: var(--text-muted);
    flex-shrink: 0;
    min-height: 1.5rem;
}
.live-activity-stat { white-space: nowrap; cursor: pointer; user-select: none; }
.live-activity-stat:hover { text-decoration: underline; }
.live-activity-off { opacity: 0.4; text-decoration: line-through; }
.live-activity-pending {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary-light);
    animation: live-pulse 1s ease-in-out infinite;
}
.live-activity-err { color: var(--danger); font-weight: 600; }
.live-activity-msg {
    color: var(--danger);
    word-break: break-word;
    white-space: normal;
}

/* Performance panel */
.live-perf-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}
@media (max-width: 600px) {
    .live-perf-grid { grid-template-columns: 1fr; }
}
.live-perf-section h4 {
    margin: 0 0 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.live-perf-table {
    width: 100%;
    font-size: 0.8rem;
    border-collapse: collapse;
}
.live-perf-table td {
    padding: 0.2rem 0.5rem;
    border-bottom: 1px solid var(--border);
}
.live-perf-table td:first-child {
    color: var(--text-muted);
    white-space: nowrap;
}
.live-perf-table td:last-child {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    text-align: right;
}
.live-perf-suggestions {
    margin: 1rem 0;
    padding: 0.75rem 1rem;
    background: color-mix(in srgb, var(--primary) 8%, transparent);
    border-left: 3px solid var(--primary);
    border-radius: 0 var(--radius) var(--radius) 0;
}
.live-perf-suggestions h4 {
    margin: 0 0 0.5rem;
    font-size: 0.85rem;
}
.live-perf-suggestions ul {
    margin: 0;
    padding-left: 1.2rem;
    font-size: 0.82rem;
    line-height: 1.6;
}
.live-perf-suggestions li {
    margin-bottom: 0.3rem;
}
.live-perf-apply {
    margin: 1rem 0;
    padding: 0.75rem 1rem;
    background: color-mix(in srgb, var(--success) 8%, transparent);
    border-left: 3px solid var(--success);
    border-radius: 0 var(--radius) var(--radius) 0;
}
.live-perf-apply h4 {
    margin: 0 0 0.5rem;
    font-size: 0.85rem;
}
.live-perf-suggested-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 0.75rem;
}
.live-perf-suggested-item {
    font-size: 0.78rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.2rem 0.5rem;
}
.live-perf-suggested-item strong {
    color: var(--primary);
}
.live-perf-uptime {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin: 0.5rem 0 0;
}
.live-perf-loading, .live-perf-error {
    font-size: 0.85rem;
    padding: 0.5rem;
}
.live-perf-error {
    color: var(--danger);
}

/* Species list panel */
.live-species-panel {
    max-height: 35vh;
    overflow-y: auto;
    background: var(--surface);
    flex-shrink: 0;
}
.live-species-empty {
    padding: 1.5rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}
.live-species-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--border);
}
.live-species-item:last-child { border-bottom: none; }
.live-species-thumb {
    width: 48px;
    height: 36px;
    border-radius: 4px;
    object-fit: cover;
    flex-shrink: 0;
    cursor: pointer;
    transition: opacity 0.15s;
}
.live-species-thumb:hover { opacity: 0.8; }
.live-species-thumb-audio {
    width: 48px;
    height: 36px;
    border-radius: 4px;
    background: #fef3c7;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--warning);
}
.live-species-thumb-audio.live-audio-play {
    border: none;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    padding: 0;
}
.live-species-thumb-audio.live-audio-play:hover {
    background: #fde68a;
    transform: scale(1.08);
}
.live-species-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}
.live-species-name {
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.live-species-sci {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.live-species-actions {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    flex-shrink: 0;
}
.live-species-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(22, 163, 74, 0.15);
    color: var(--success);
    text-decoration: none;
    transition: background 0.15s;
}
.live-species-action:hover {
    background: rgba(22, 163, 74, 0.3);
}
.live-species-action-search {
    background: rgba(22, 101, 52, 0.15);
    color: var(--primary);
}
.live-species-action-search:hover {
    background: rgba(22, 101, 52, 0.3);
}
.live-species-badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.1rem 0.4rem;
    border-radius: 999px;
    flex-shrink: 0;
}
.live-species-badge.video {
    background: #dcfce7;
    color: #166534;
}
.live-species-badge.audio {
    background: #fef3c7;
    color: #92400e;
}
.live-species-conf {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--primary);
    flex-shrink: 0;
    min-width: 3rem;
    text-align: right;
}
.live-species-time {
    font-size: 0.7rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

/* Live detection feedback / correction */
.live-feedback-row {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-top: 0.2rem;
}
.live-feedback-label {
    font-size: 0.7rem;
    color: var(--text-muted);
}
.live-feedback-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    padding: 0;
    transition: background 0.15s, transform 0.1s;
}
.live-feedback-btn:hover { transform: scale(1.12); }
.live-feedback-yes {
    background: rgba(22, 163, 74, 0.15);
    color: var(--success);
}
.live-feedback-yes:hover { background: rgba(22, 163, 74, 0.3); }
.live-feedback-no {
    background: rgba(220, 38, 38, 0.12);
    color: #dc2626;
}
.live-feedback-no:hover { background: rgba(220, 38, 38, 0.25); }
.live-feedback-unknown {
    background: rgba(146, 64, 14, 0.12);
    color: #92400e;
    font-weight: 700;
    font-size: 0.8rem;
}
.live-feedback-unknown:hover { background: rgba(146, 64, 14, 0.25); }
.live-feedback-saved {
    font-size: 0.7rem;
    color: var(--success);
    display: flex;
    align-items: center;
    gap: 0.25rem;
}
.live-feedback-saving {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-style: italic;
}
.live-correction-row {
    flex-direction: column;
    align-items: stretch;
    position: relative;
}
.live-correction-input {
    font-size: 0.8rem;
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    color: var(--text);
    width: 100%;
    outline: none;
}
.live-correction-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(22, 101, 52, 0.15);
}
.live-correction-results {
    max-height: 160px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    display: flex;
    flex-direction: column;
}
.live-correction-results:empty {
    display: none;
}
.live-correction-option {
    display: flex;
    flex-direction: column;
    padding: 0.3rem 0.5rem;
    border: none;
    background: none;
    cursor: pointer;
    text-align: left;
    color: var(--text);
    transition: background 0.1s;
}
.live-correction-option:hover {
    background: rgba(22, 101, 52, 0.1);
}
.live-correction-option-name {
    font-size: 0.8rem;
    font-weight: 600;
}
.live-correction-option-sci {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-style: italic;
}
.live-correction-empty {
    font-size: 0.75rem;
    color: var(--text-muted);
    padding: 0.3rem 0.5rem;
    font-style: italic;
}

/* Training review page */
.training-group {
    margin-bottom: 1.5rem;
}
.training-group-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.training-group-count {
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--text-muted);
    background: var(--surface);
    padding: 0.1rem 0.4rem;
    border-radius: 999px;
}
.training-group-items {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.training-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.training-item-unknown {
    border-left: 3px solid #f59e0b;
}
.training-item-preview {
    width: 64px;
    flex-shrink: 0;
}
.training-item-preview img {
    width: 64px;
    height: 48px;
    object-fit: cover;
    border-radius: 4px;
}
.training-item-audio-icon {
    width: 64px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fef3c7;
    border-radius: 4px;
    color: var(--warning);
}
.training-item-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}
.training-item-filename {
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.training-item-meta {
    font-size: 0.7rem;
    color: var(--text-muted);
}
.training-item-notes {
    font-size: 0.75rem;
    color: var(--text);
    font-style: italic;
}
.training-item-actions {
    flex-shrink: 0;
}
.spinner-inline {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* Mobile */
@media (max-width: 768px) {
    .live-detect-header { padding: 0.4rem 0.75rem; }
    .live-controls { padding: 0.4rem 0.75rem; gap: 0.35rem; }
    .live-species-panel { max-height: 30vh; }
    .live-species-item { padding: 0.4rem 0.75rem; gap: 0.4rem; }
    .live-settings-panel { margin: 0.5rem; }
    .live-settings-grid { grid-template-columns: 1fr; }
}

/* Live detection lightbox */
.live-lightbox {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.live-lightbox img {
    max-width: 90vw;
    max-height: 80vh;
    border-radius: var(--radius);
    object-fit: contain;
    cursor: default;
}
.live-lightbox-label {
    margin-top: 0.75rem;
    color: #e2e8f0;
    font-size: 0.9rem;
    font-weight: 600;
}

/* Audio player lightbox */
.live-audio-player {
    background: #1e293b;
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    min-width: 300px;
    max-width: 90vw;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.live-audio-player-label {
    color: #f1f5f9;
    font-size: 0.95rem;
    font-weight: 600;
    text-align: center;
}
.live-audio-waveform {
    width: 100%;
    height: 64px;
    border-radius: 4px;
    background: rgba(0,0,0,0.3);
}
.live-audio-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.live-audio-play-btn {
    background: #f59e0b;
    color: #1e293b;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s, transform 0.1s;
}
.live-audio-play-btn:hover {
    background: #fbbf24;
    transform: scale(1.08);
}
.live-audio-time {
    color: #94a3b8;
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
}

/* ── Footer + cookie banner (added 2026-04-28) ───────────────────────────── */
.app-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.8rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: space-between;
    align-items: center;
}
.app-footer .footer-links a { color: var(--text-muted); margin: 0 0.15rem; text-decoration: none; }
.app-footer .footer-links a:hover { color: var(--text); text-decoration: underline; }
.app-footer .footer-sep { color: var(--border); }
.app-footer .footer-copyright { color: var(--text-muted); }

.cookie-banner {
    position: fixed;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    width: min(720px, calc(100% - 2rem));
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    padding: 0.75rem 1rem;
    display: flex;
    gap: 0.75rem;
    align-items: center;
    z-index: 9000;
    font-size: 0.85rem;
    color: var(--text);
}
.cookie-banner-text { flex: 1; line-height: 1.4; }
.cookie-banner-text a { color: var(--primary); }
.cookie-banner button { white-space: nowrap; }
