/* hotcoco dataset browser — Cyanotype */

/* ── Tokens ── */
:root {
    --bg-base: #141415;
    --bg-surface: #1C1C1E;
    --bg-elevated: #242427;
    --bg-hover: #2C2C30;
    --bg-active: #343438;

    --border-subtle: #2A2A2D;
    --border-default: #333337;
    --border-strong: #3E3E43;

    /* The 24px ground grid: --border-strong at reduced strength, so it reads
       as texture and never as content. Depth in Cyanotype comes from rule
       weight, which is what the --border-* tier is for. */
    --grid-line: rgba(62, 62, 67, 0.45);

    --text-primary: #EAEAEA;
    --text-secondary: #B0B0B3;
    --text-tertiary: #8C8C90;
    --text-inverse: #141415;

    --accent: #8FB3E2;
    --accent-hover: #A8C4EC;
    --accent-muted: rgba(143, 179, 226, 0.15);
    --accent-subtle: rgba(143, 179, 226, 0.08);

    --gt-badge-bg: rgba(176, 176, 179, 0.12);
    --gt-badge-text: #B4B4B8;
    --dt-badge-bg: rgba(143, 179, 226, 0.12);
    --dt-badge-text: #8FB3E2;

    /* Plum, chart palette #5 (dark) — the caveat marker on
       non-leaderboard-comparable numbers. Same palette slot as
       plot/report.py's `caveat`, taken on the dark ground this surface renders
       against. Deliberately not red: Cyanotype spends red exclusively on false
       positives. */
    --caveat: #B189B3;
    --caveat-bg: rgba(177, 137, 179, 0.10);
    --caveat-border: rgba(177, 137, 179, 0.35);

    /* Eval semantics. Outside the chart palette on purpose — a chart series
       that happens to be green does not mean "true positive". */
    --tp: #7FBC98;
    --fp: #F0A050;
    --fn: #9296EE;
    /* Tints derived from the tokens, so a semantic change is a one-line edit. */
    --tp-bg: rgba(127, 188, 152, 0.15);
    --fp-bg: rgba(240, 160, 80, 0.15);
    --fn-bg: rgba(146, 150, 238, 0.15);

    --radius-sm: 2px;
    --radius-md: 3px;
    --radius-lg: 4px;

    --font-display: 'Instrument Serif', 'Times New Roman', Times, serif;
    --font-body: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, monospace;

    /* Floating surfaces only — dropdown panels, modals. A card in normal flow
       gets a border, never a shadow, which is why there is no --shadow-sm. */
    --shadow-md: 0 2px 10px rgba(0,0,0,0.45);
    --shadow-lg: 0 8px 28px rgba(0,0,0,0.55);
    --shadow-glow: 0 0 0 1px rgba(143,179,226,0.22);
}

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

body {
    font-family: var(--font-body);
    background: var(--bg-base);
    color: var(--text-primary);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ── Layout ── */
.layout {
    display: grid;
    grid-template-columns: 220px 1fr;
    height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
    background: var(--bg-surface);
    border-right: 1px solid var(--border-subtle);
    padding: 20px 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.sidebar-brand {
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-subtle);
}

.sidebar-brand h1 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 400;
    color: var(--accent);
    letter-spacing: -0.01em;
    margin-bottom: 4px;
}

.sidebar-brand .subtitle {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 400;
    color: var(--text-tertiary);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.filter-label {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-tertiary);
    margin-bottom: 8px;
}

/* ── Filter Sections ── */
#filters {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ── Category Dropdown ── */
.cat-dropdown {
    position: relative;
}

.cat-dropdown-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    padding: 9px 12px;
    font-family: var(--font-body);
    font-size: 0.82rem;
    color: var(--text-primary);
    cursor: pointer;
    user-select: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.cat-dropdown-toggle:hover {
    border-color: var(--border-strong);
}

.cat-dropdown-toggle:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-muted);
}

.cat-dropdown-arrow {
    font-size: 0.65rem;
    color: var(--text-tertiary);
    transition: transform 0.2s;
}

.cat-dropdown.open .cat-dropdown-arrow {
    transform: rotate(180deg);
}

.cat-dropdown-panel {
    display: none;
    flex-direction: column;
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 4px);
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    z-index: 100;
    box-shadow: var(--shadow-lg);
    max-height: 340px;
    overflow: hidden;
}

.cat-dropdown-panel.open {
    display: flex;
    animation: dropdownReveal 0.15s ease-out;
}

@keyframes dropdownReveal {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.cat-search {
    border: none;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-surface);
    color: var(--text-primary);
    font-family: var(--font-body);
    padding: 10px 12px;
    font-size: 0.82rem;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    outline: none;
}

.cat-search::placeholder {
    color: var(--text-tertiary);
}

.cat-list {
    overflow-y: auto;
    max-height: 240px;
    padding: 4px;
}

.cat-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    font-size: 0.82rem;
    cursor: pointer;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    transition: background 0.1s, color 0.1s;
}

.cat-option:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* Shared checkbox base — reset + theme for all custom checkboxes */
.cat-option input[type="checkbox"],
.overlay-toggles input[type="checkbox"],
.tree-group-check {
    appearance: none;
    -webkit-appearance: none;
    border: 1.5px solid var(--border-strong);
    background: transparent;
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
    transition: border-color 0.1s, background 0.1s;
}

.cat-option input[type="checkbox"]:checked,
.overlay-toggles input[type="checkbox"]:checked,
.tree-group-check:checked {
    background: var(--accent);
    border-color: var(--accent);
}

.cat-option input[type="checkbox"]:checked::after,
.overlay-toggles input[type="checkbox"]:checked::after,
.tree-group-check:checked::after {
    content: '';
    position: absolute;
    border: solid var(--text-inverse);
    transform: rotate(45deg);
}

/* Category filter checkbox — 16px variant */
.cat-option input[type="checkbox"] {
    width: 16px;
    height: 16px;
    border-radius: 4px;
}

.cat-option input[type="checkbox"]:checked::after {
    left: 4.5px;
    top: 1.5px;
    width: 5px;
    height: 9px;
    border-width: 0 2px 2px 0;
}

.cat-actions {
    border-top: 1px solid var(--border-subtle);
    padding: 8px;
}

.btn-clear {
    background: transparent;
    border: 1px solid var(--border-default);
    color: var(--text-tertiary);
    font-family: var(--font-body);
    padding: 4px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.72rem;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}

.btn-clear:hover {
    border-color: var(--border-strong);
    color: var(--text-secondary);
}

/* ── Range Slider (shared by score + IoU sliders) ── */
.range-slider {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-top: 4px;
}

.range-slider-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: var(--font-mono);
    font-size: 0.62rem;
    color: var(--text-tertiary);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding-bottom: 2px;
}

.range-slider-value {
    font-weight: 500;
    color: var(--text-secondary);
}

.range-slider input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    background: linear-gradient(to right, var(--accent) 0%, var(--border-default) 0%);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

.range-slider input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--bg-surface);
    cursor: pointer;
    transition: box-shadow 0.15s;
}

.range-slider input[type="range"]::-webkit-slider-thumb:hover {
    box-shadow: 0 0 0 4px var(--accent-muted);
}

.range-slider input[type="range"]:focus-visible::-webkit-slider-thumb {
    box-shadow: 0 0 0 3px var(--accent-muted), 0 0 0 5px var(--accent);
}

.range-slider input[type="range"]:focus-visible::-moz-range-thumb {
    box-shadow: 0 0 0 3px var(--accent-muted), 0 0 0 5px var(--accent);
}

.range-slider input[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--bg-surface);
    cursor: pointer;
}

.range-slider input[type="range"]::-moz-range-track {
    height: 4px;
    background: transparent;
    border: none;
}

.range-slider input[type="range"]::-moz-range-progress {
    height: 4px;
    background: var(--accent);
    border-radius: 2px;
}

/* ── Buttons ── */
.btn-shuffle {
    width: 100%;
    background: var(--bg-elevated);
    color: var(--text-secondary);
    border: 1px solid var(--border-default);
    font-family: var(--font-body);
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-shuffle:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-strong);
}

.btn-shuffle:active {
    background: var(--bg-active);
}

/* ── Image Count ── */
.image-count {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 400;
    color: var(--text-tertiary);
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid var(--border-subtle);
}

/* ── Gallery Grid ── */
/* The drafting grid — Cyanotype's surface texture, replacing the old
   shadow-and-noise treatment. A background layer on the gallery ground, never
   an overlay: an image browser must not paint on top of the images, so this
   shows only in the gutters between cards. */
main {
    overflow-y: auto;
    padding: 16px;
    background-color: var(--bg-base);
    background-image:
        linear-gradient(var(--grid-line) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
    background-size: 24px 24px;
    background-position: -1px -1px;
}

#gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 12px;
}

.thumb-card {
    border-radius: var(--radius-md);
    overflow: hidden;
    cursor: pointer;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    position: relative;
    animation: cardFadeIn 0.3s ease-out both;
}

.thumb-card::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: var(--radius-md);
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
    background: linear-gradient(to top, rgba(20,20,21,0.65) 0%, transparent 50%);
}

.thumb-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-glow);
    border-color: var(--border-strong);
}

.thumb-card:hover::after {
    opacity: 1;
}

.thumb-card:active {
    transform: translateY(-1px);
}

/* Aspect ratio container for consistent grid before images load */
.thumb-ratio {
    position: relative;
    width: 100%;
    padding-bottom: 75%; /* 4:3 default aspect ratio */
    overflow: hidden;
    background: var(--bg-elevated);
}

.thumb-ratio::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent 25%, rgba(255,255,255,0.03) 50%, transparent 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    from { background-position: 200% 0; }
    to { background-position: -200% 0; }
}

.thumb-ratio img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: opacity 0.3s ease;
    z-index: 1;
}

.thumb-ratio.loaded::before {
    display: none;
}

.thumb-id {
    position: absolute;
    bottom: 6px;
    right: 6px;
    z-index: 2;
    font-family: var(--font-mono);
    font-size: 0.6rem;
    font-weight: 500;
    color: rgba(255,255,255,0.9);
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    padding: 2px 6px;
    border-radius: 4px;
    opacity: 0;
    transition: opacity 0.15s;
    pointer-events: none;
}

.thumb-card:hover .thumb-id {
    opacity: 1;
}

@keyframes cardFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.scroll-sentinel {
    height: 1px;
}

/* ── Gallery Empty State ── */
.gallery-empty {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    gap: 12px;
}

.gallery-empty-icon {
    color: var(--text-tertiary);
    opacity: 0.4;
    margin-bottom: 4px;
}

.gallery-empty-title {
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.gallery-empty-sub {
    font-family: var(--font-body);
    font-size: 0.82rem;
    color: var(--text-tertiary);
}

/* ── HTMX Loading & Errors ── */
.htmx-request .thumb-ratio img {
    opacity: 0.4;
}

.htmx-indicator { display: none; }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { display: block; }

.loading-spinner {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: var(--text-tertiary);
    font-size: 0.85rem;
    gap: 10px;
}

.loading-spinner::before {
    content: '';
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-default);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.error-toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-elevated);
    color: var(--text-primary);
    border: 1px solid rgba(240, 160, 80, 0.4);
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-size: 0.82rem;
    box-shadow: var(--shadow-md);
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}

.error-toast.visible {
    opacity: 1;
    pointer-events: auto;
}

/* ── Lightbox ── */
.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 11, 0.94);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 12px;
}

.lightbox.open {
    display: flex;
    animation: lightboxFadeIn 0.2s ease-out;
}

@keyframes lightboxFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.lightbox-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    width: 96vw;
    max-width: 1500px;
    height: 96vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    animation: lightboxSlideUp 0.25s ease-out;
    contain: size layout;
}

@keyframes lightboxSlideUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.lightbox-header {
    display: flex;
    align-items: center;
    padding: 6px 12px;
    border-bottom: 1px solid var(--border-subtle);
    gap: 8px;
    flex-shrink: 0;
    background: var(--bg-surface);
}

.lightbox-nav {
    display: flex;
    gap: 4px;
}

.nav-btn {
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    width: 30px;
    height: 30px;
    font-size: 0.95rem;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.1s, color 0.1s, border-color 0.1s;
}

.nav-btn:hover:not(:disabled) {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-strong);
}

.nav-btn:disabled {
    opacity: 0.25;
    cursor: default;
}

.nav-btn:focus-visible,
.close-btn:focus-visible,
.btn-shuffle:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.lightbox-title {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--text-tertiary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Keyboard Shortcut Hints ── */
.lightbox-shortcuts {
    display: flex;
    align-items: center;
    gap: 3px;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--text-tertiary);
    user-select: none;
    flex-shrink: 0;
}

.lightbox-shortcuts kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.6rem;
    font-weight: 500;
    color: var(--text-tertiary);
    line-height: 1;
}

.close-btn {
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    width: 30px;
    height: 30px;
    font-size: 1.1rem;
    color: var(--text-tertiary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.1s, color 0.1s;
    line-height: 1;
}

.close-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* ── Lightbox Body ── */
.lightbox-body {
    display: grid;
    grid-template-columns: 1fr 280px;
    overflow: hidden;
    flex: 1;
    min-height: 0;
}

.image-panel {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 6px;
    background: var(--bg-base);
}

.image-container {
    position: relative;
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: var(--radius-sm);
    background: #0a0908;
}

.image-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
}

#overlay-canvas {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: auto;
    touch-action: none;
}

.overlay-toggles {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
    padding: 0;
    font-size: 0.75rem;
    align-items: center;
    flex-shrink: 0;
    color: var(--text-secondary);
    margin-left: auto;
}

.overlay-toggles label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: color 0.1s;
}

.overlay-toggles label:hover {
    color: var(--text-primary);
}

/* Overlay toggles checkbox — 14px variant */
.overlay-toggles input[type="checkbox"] {
    width: 14px;
    height: 14px;
    border-radius: 3px;
}

.overlay-toggles input[type="checkbox"]:checked::after {
    left: 3.5px;
    top: 0.5px;
    width: 5px;
    height: 8px;
    border-width: 0 1.5px 1.5px 0;
}

.toggle-sep {
    color: var(--border-default);
    font-size: 0.9em;
}

/* ── Info Panel (Annotations Sidebar) ── */
.info-panel {
    border-left: 1px solid var(--border-subtle);
    padding: 14px;
    overflow-y: auto;
    background: var(--bg-surface);
    display: flex;
    flex-direction: column;
}

.info-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    min-height: 24px;
    flex-shrink: 0;
}

.info-panel-header h3 {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-tertiary);
}

.ann-count {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    font-weight: 600;
    color: var(--text-tertiary);
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    padding: 1px 7px;
    border-radius: 10px;
    min-width: 28px;
    text-align: center;
}

.ann-item {
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    margin-bottom: 2px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid transparent;
}

.ann-item:hover {
    background: var(--bg-hover);
}

.ann-item.highlighted {
    background: var(--bg-hover);
    border-color: var(--border-default);
}

.ann-color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    transition: box-shadow 0.15s;
}

.ann-item.highlighted .ann-color-dot,
.ann-item:hover .ann-color-dot {
    box-shadow: 0 0 6px 1px currentColor;
}

.ann-label {
    flex: 1;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.78rem;
}

.ann-score {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 400;
    color: var(--text-tertiary);
}

.ann-source {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
}

.ann-source.gt {
    background: var(--gt-badge-bg);
    color: var(--gt-badge-text);
}

.ann-source.dt {
    background: var(--dt-badge-bg);
    color: var(--dt-badge-text);
}

/* ── Eval Badges ── */
.eval-badge {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    flex-shrink: 0;
}

.eval-tp {
    background: var(--tp-bg);
    color: var(--tp);
}

.eval-fp {
    background: var(--fp-bg);
    color: var(--fp);
}

.eval-fn {
    background: var(--fn-bg);
    color: var(--fn);
}

/* Match highlight in sidebar */
.ann-item.match-highlighted {
    background: var(--bg-hover);
    border-color: var(--border-strong);
    outline: 1px dashed rgba(255, 255, 255, 0.25);
    outline-offset: -1px;
}

/* ── Color Mode Toggle ── */
.color-mode-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: 4px;
    color: var(--text-tertiary);
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 500;
    padding: 3px 8px;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.color-mode-toggle:hover {
    border-color: var(--border-strong);
    color: var(--text-primary);
}

.color-mode-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-tertiary);
    transition: background 0.15s, box-shadow 0.15s;
}

.color-mode-toggle.active {
    border-color: rgba(127, 188, 152, 0.3);
    color: var(--text-secondary);
}

.color-mode-toggle.active .color-mode-dot {
    background: var(--tp);
    box-shadow: 0 0 6px rgba(127, 188, 152, 0.4);
}

.color-mode-toggle.active:hover {
    border-color: rgba(127, 188, 152, 0.5);
    color: var(--text-primary);
}

/* ── Gallery Eval Badges ── */
.thumb-badges {
    position: absolute;
    bottom: 6px;
    left: 6px;
    z-index: 2;
    display: flex;
    gap: 3px;
    pointer-events: none;
}

.thumb-badge {
    font-family: var(--font-mono);
    font-size: 0.55rem;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 3px;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    line-height: 1.3;
}

.badge-tp {
    background: rgba(127, 188, 152, 0.9);
    color: var(--bg-base);
}

.badge-fp {
    background: rgba(240, 160, 80, 0.9);
    color: var(--bg-base);
}

.badge-fn {
    background: rgba(146, 150, 238, 0.9);
    color: var(--bg-base);
}

/* ── Eval Controls ── */
.eval-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.eval-select {
    width: 100%;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    padding: 7px 10px;
    font-family: var(--font-body);
    font-size: 0.78rem;
    color: var(--text-primary);
    cursor: pointer;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%236b6259' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 28px;
    transition: border-color 0.15s;
}

.eval-select:hover {
    border-color: var(--border-strong);
}

.eval-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-muted);
}

/* ── Category View Toggle ── */
.filter-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.cat-view-toggle {
    display: flex;
    gap: 2px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: 4px;
    padding: 1px;
}

.view-btn {
    background: transparent;
    border: none;
    color: var(--text-tertiary);
    font-size: 0.7rem;
    width: 22px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 3px;
    transition: background 0.1s, color 0.1s;
    line-height: 1;
}

.view-btn:hover {
    color: var(--text-secondary);
}

.view-btn.active {
    background: var(--accent-muted);
    color: var(--accent);
}

/* ── Category Tree View ── */
.cat-tree {
    overflow-y: auto;
    max-height: 240px;
    padding: 4px;
}

.tree-group {
    margin-bottom: 1px;
}

.tree-group-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background 0.1s, color 0.1s;
    user-select: none;
    outline: none;
}

.tree-group-header:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.tree-group-header:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

.tree-expand-icon {
    font-size: 0.6rem;
    color: var(--text-tertiary);
    width: 10px;
    text-align: center;
    flex-shrink: 0;
    transition: transform 0.15s;
}

/* Tree group checkbox — 14px variant (same size as overlay) */
.tree-group-check {
    width: 14px;
    height: 14px;
    border-radius: 3px;
}

.tree-group-check:checked::after {
    left: 3.5px;
    top: 0.5px;
    width: 5px;
    height: 8px;
    border-width: 0 1.5px 1.5px 0;
}

.tree-group-check:indeterminate {
    background: var(--accent-muted);
    border-color: var(--accent);
}

.tree-group-check:indeterminate::after {
    content: '';
    position: absolute;
    left: 2px;
    top: 5px;
    width: 8px;
    height: 0;
    border-bottom: 2px solid var(--accent);
}

.tree-group-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tree-group-count {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    font-weight: 500;
    color: var(--text-tertiary);
    flex-shrink: 0;
}

.tree-children {
    padding-left: 20px;
}

.tree-child {
    padding-left: 16px;
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-default);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-strong);
}

/* ── Responsive: Narrower lightbox info panel ── */
@media (max-width: 1000px) {
    .lightbox-body {
        grid-template-columns: 1fr 220px;
    }

    .info-panel {
        padding: 12px;
    }

    .ann-item {
        padding: 6px 8px;
        font-size: 0.75rem;
        gap: 8px;
    }
}

/* ── Responsive: Short viewports (IFrame ≤ 700px) ── */
@media (max-height: 700px) {
    .lightbox {
        padding: 4px;
    }

    .lightbox-card {
        height: 100vh;
        border-radius: var(--radius-sm);
    }

    .lightbox-header {
        padding: 4px 10px;
    }

    .image-panel {
        padding: 4px;
    }

    .overlay-toggles {
        gap: 4px 8px;
        font-size: 0.68rem;
    }

    .gallery-empty {
        padding: 40px 16px;
    }

    .cat-dropdown-panel {
        max-height: 240px;
    }
}

/* ── Responsive: Toolbar Mode ── */
@media (max-width: 768px) {
    .layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }

    .sidebar {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
        padding: 10px 12px;
        align-items: center;
        border-right: none;
        border-bottom: 1px solid var(--border-subtle);
        overflow: visible;
    }

    .sidebar-brand {
        padding-bottom: 0;
        border-bottom: none;
    }

    .sidebar-brand h1 {
        font-size: 1.1rem;
        margin-bottom: 0;
    }

    .sidebar-brand .subtitle {
        display: none;
    }

    .sidebar-nav {
        margin-top: 0;
        gap: 4px;
    }

    .nav-pill {
        font-size: 0.65rem;
        padding: 3px 10px;
    }

    #filters {
        flex: 1;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
        align-items: center;
        min-width: 0;
    }

    .filter-section {
        flex: 1;
        min-width: 120px;
    }

    .filter-label {
        display: none;
    }

    .cat-dropdown-toggle {
        padding: 6px 10px;
        font-size: 0.75rem;
        height: 32px;
    }

    .cat-dropdown-panel {
        min-width: 220px;
    }

    .eval-controls {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 6px;
    }

    .eval-select {
        flex: 1;
        min-width: 100px;
        padding: 5px 8px;
        font-size: 0.72rem;
        height: 32px;
    }

    .range-slider {
        flex: 1;
        min-width: 100px;
    }

    .btn-shuffle {
        width: auto;
        padding: 6px 10px;
        font-size: 0.75rem;
        gap: 5px;
        height: 32px;
    }

    .image-count {
        margin-top: 0;
        padding-top: 0;
        border-top: none;
        font-size: 0.65rem;
        margin-left: auto;
    }

    /* Gallery: smaller cards for narrow viewports */
    #gallery {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 8px;
    }

    main {
        padding: 12px;
    }

    /* Lightbox: stack image above info panel */
    .lightbox-card {
        width: 98vw;
        height: 95vh;
        border-radius: var(--radius-md);
    }

    .lightbox-body {
        grid-template-columns: 1fr;
        grid-template-rows: minmax(0, 1fr) minmax(120px, 40%);
    }

    .info-panel {
        border-left: none;
        border-top: 1px solid var(--border-subtle);
        overflow-y: auto;
    }

    .lightbox-header {
        padding: 6px 10px;
        gap: 6px;
        flex-wrap: wrap;
    }

    .lightbox-shortcuts {
        display: none;
    }

    .lightbox-title {
        font-size: 0.68rem;
    }

    .overlay-toggles {
        gap: 4px 8px;
        font-size: 0.68rem;
        order: 10;
        flex-basis: 100%;
        margin-left: 0;
        padding-top: 2px;
        border-top: 1px solid var(--border-subtle);
    }
}

/* ── Very narrow: side-by-side notebooks, small phones ── */
@media (max-width: 480px) {
    .sidebar {
        gap: 6px 8px;
        padding: 8px 10px;
    }

    /* Hide brand text on gallery (filters present), keep nav pills on dashboard */
    .sidebar-brand h1 {
        display: none;
    }

    .sidebar-nav {
        margin-top: 0;
    }

    .filter-section {
        min-width: 80px;
        flex: 1 1 80px;
    }

    .btn-shuffle span {
        display: none;
    }

    .btn-shuffle {
        padding: 6px 8px;
        flex: 0 0 auto;
    }

    .image-count {
        flex-basis: 100%;
        text-align: center;
        margin-left: 0;
        font-size: 0.6rem;
        padding-top: 2px;
    }

    #gallery {
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
        gap: 6px;
    }

    .lightbox {
        padding: 0;
    }

    .lightbox-card {
        width: 100vw;
        height: 100vh;
        border-radius: 0;
        border: none;
    }

    .nav-btn {
        width: 28px;
        height: 28px;
    }

    .close-btn {
        width: 28px;
        height: 28px;
    }

    .lightbox-header {
        padding: 6px 10px;
        gap: 6px;
    }

    .lightbox-title {
        font-size: 0.65rem;
    }

    .info-panel {
        padding: 10px;
    }
}


/* ══════════════════════════════════════════════════════════════════════
   Dashboard
   ══════════════════════════════════════════════════════════════════════ */

/* ── Navigation pills ── */
.sidebar-nav {
    display: flex;
    gap: 6px;
    margin-top: 12px;
}

.nav-pill {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 500;
    padding: 4px 12px;
    border-radius: 12px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.15s, background 0.15s;
}

.nav-pill:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.nav-pill.active {
    color: var(--accent);
    background: var(--accent-muted);
}

/* ── Dashboard sidebar metadata ── */
.dashboard-meta {
    padding: 16px;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.meta-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.meta-label {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.meta-value {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-primary);
}

.meta-value-caveat {
    color: var(--caveat);
}

/* ── Provenance banner ── */
.provenance-banner {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    padding: 14px 16px;
    margin-bottom: 20px;
    background: var(--caveat-bg);
    border: 1px solid var(--caveat-border);
    border-radius: var(--radius-md);
}

.provenance-tag {
    flex-shrink: 0;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--caveat);
    border: 1px solid var(--caveat-border);
    border-radius: var(--radius-sm);
    padding: 3px 8px;
}

.provenance-body {
    min-width: 0;
}

.provenance-headline {
    margin: 0;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
}

.provenance-reasons {
    margin: 6px 0 0;
    padding-left: 18px;
    font-size: 0.78rem;
    line-height: 1.5;
    color: var(--text-secondary);
}

/* ── Dashboard main area ── */
.dashboard-main {
    padding: 24px;
    overflow-y: auto;
    max-width: 1400px;
}

.dashboard-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    text-align: center;
    color: var(--text-secondary);
}

.dashboard-empty h2 {
    font-family: var(--font-display);
    font-size: 1.4rem;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.dashboard-empty pre {
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 10px 16px;
    margin: 8px 0;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--accent);
}

/* ── KPI tiles ── */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.kpi-tile {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 20px 16px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: border-color 0.15s;
}

.kpi-tile:hover {
    border-color: var(--border-default);
}

.kpi-value {
    font-family: var(--font-display);
    font-size: 1.8rem;
    color: var(--accent);
    line-height: 1;
}

.kpi-label {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* ── Chart grid ── */
.chart-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 24px;
    align-items: start;
}

.chart-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 16px;
    overflow: hidden;
    transition: border-color 0.15s;
}

.chart-card:hover {
    border-color: var(--border-default);
}

.chart-card .js-plotly-plot {
    width: 100% !important;
}

/* Plotly chart containers should not overflow their card */
.chart-card .plotly-graph-div {
    width: 100% !important;
}

.chart-wide {
    grid-column: span 2;
}

/* ── Per-category AP leaderboard ── */
.cat-mean {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    margin-bottom: 8px;
    border-radius: var(--radius-sm);
    background: var(--accent-subtle);
    border: 1px solid var(--accent-subtle);
}

.cat-mean-label {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.cat-mean-value {
    font-family: var(--font-display);
    font-size: 1.1rem;
    color: var(--accent);
}

.cat-ap-list {
    display: flex;
    flex-direction: column;
}

.cat-row {
    display: grid;
    grid-template-columns: 28px 1fr 3fr 52px;
    align-items: center;
    gap: 8px;
    padding: 5px 8px;
    text-decoration: none;
    border-radius: 4px;
    transition: background 0.1s;
    cursor: pointer;
}

.cat-row:hover {
    background: var(--bg-hover);
}

.cat-row.hidden {
    display: none;
}

.cat-rank {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    color: var(--text-tertiary);
    text-align: right;
}

.cat-name {
    font-family: var(--font-body);
    font-size: 0.78rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cat-bar-wrap {
    height: 14px;
    background: var(--bg-elevated);
    border-radius: 3px;
    overflow: hidden;
}

.cat-bar {
    display: block;
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease;
}

.cat-bar.above {
    background: var(--accent);
}

.cat-bar.below {
    background: var(--accent);
    opacity: 0.5;
}

.cat-ap {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-align: right;
}

.cat-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 10px;
    margin-top: 4px;
    border: none;
    border-top: 1px solid var(--border-subtle);
    background: transparent;
    color: var(--accent);
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 500;
    cursor: pointer;
    letter-spacing: 0.03em;
    transition: color 0.15s;
}

.cat-toggle:hover {
    color: var(--accent-hover);
}

.cat-toggle-icon {
    font-size: 0.8rem;
}

/* ── TIDE error breakdown ── */
.tide-header {
    padding: 4px 0 10px 0;
}

.tide-header-label {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.tide-row {
    display: grid;
    grid-template-columns: 90px 1fr 56px 52px;
    align-items: center;
    gap: 8px;
    padding: 8px 4px;
    border-bottom: 1px solid var(--border-subtle);
}

.tide-row:last-of-type {
    border-bottom: none;
}

.tide-label {
    font-family: var(--font-body);
    font-size: 0.8rem;
    color: var(--text-primary);
}

.tide-bar-wrap {
    height: 18px;
    background: var(--bg-elevated);
    border-radius: 3px;
    overflow: hidden;
}

.tide-bar {
    display: block;
    height: 100%;
    border-radius: 3px;
    background: var(--accent);
    transition: width 0.3s ease;
}

.tide-delta {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--accent);
    text-align: right;
}

.tide-count {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--text-tertiary);
    text-align: right;
}

.tide-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 4px 4px 4px;
    margin-top: 6px;
    border-top: 1px solid var(--border-subtle);
}

.tide-footer-label {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.tide-footer-value {
    font-family: var(--font-display);
    font-size: 1rem;
    color: var(--accent);
}

.chart-title {
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 8px 0;
}

.chart-hint {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    font-weight: 400;
    color: var(--text-tertiary);
    margin-left: 8px;
}

/* ── Label errors ── */
.label-errors-section {
    margin-bottom: 24px;
}

.label-errors-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.label-errors-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.label-errors-table th {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-align: left;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-default);
}

.label-errors-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
}

.label-errors-table tbody tr {
    cursor: pointer;
    transition: background 0.1s;
}

.label-errors-table tbody tr:hover {
    background: var(--bg-hover);
}

.label-errors-table .mono {
    font-family: var(--font-mono);
    font-size: 0.75rem;
}

.error-badge {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.error-badge-wrong {
    background: var(--fp-bg);
    color: var(--fp);
}

.error-badge-missing {
    background: var(--fn-bg);
    color: var(--fn);
}

/* ── Plotly modebar fix: icons invisible on dark bg ── */
.modebar-btn path {
    fill: rgba(255, 255, 255, 0.5) !important;
}

.modebar-btn.active path,
.modebar-btn:hover path {
    fill: var(--accent) !important;
}

/* ── Dashboard Responsive ── */

/* Medium screens: single-column chart grid */
@media (max-width: 1000px) {
    .chart-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .chart-wide {
        grid-column: span 1;
    }

    .cat-row {
        grid-template-columns: 24px 1fr 2.5fr 48px;
        gap: 6px;
        padding: 4px 6px;
    }
}

/* Toolbar mode: sidebar collapses to horizontal bar */
@media (max-width: 768px) {
    .dashboard-main {
        padding: 16px 12px;
    }

    .dashboard-meta {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 4px 16px;
        padding: 8px 0;
        border-top: none;
        border-bottom: 1px solid var(--border-subtle);
    }

    .meta-item {
        gap: 6px;
    }

    .meta-label {
        font-size: 0.6rem;
    }

    .meta-value {
        font-size: 0.72rem;
    }

    .kpi-row {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        margin-bottom: 16px;
    }

    .kpi-tile {
        padding: 14px 12px;
    }

    .kpi-value {
        font-size: 1.4rem;
    }

    .kpi-label {
        font-size: 0.6rem;
    }

    .chart-grid {
        gap: 12px;
        margin-bottom: 16px;
    }

    .chart-card {
        padding: 12px;
    }

    .chart-title {
        font-size: 0.8rem;
        margin-bottom: 6px;
    }

    .tide-row {
        grid-template-columns: 80px 1fr 50px 44px;
        gap: 6px;
        padding: 6px 2px;
    }

    .tide-label {
        font-size: 0.75rem;
    }

    .tide-delta {
        font-size: 0.65rem;
    }

    .tide-count {
        font-size: 0.6rem;
    }

    .label-errors-table {
        font-size: 0.72rem;
    }

    .label-errors-table th {
        font-size: 0.6rem;
        padding: 6px 8px;
    }

    .label-errors-table td {
        padding: 6px 8px;
    }

    .label-errors-table .mono {
        font-size: 0.68rem;
    }

    .error-badge {
        font-size: 0.55rem;
        padding: 2px 6px;
    }
}

/* Very narrow: stacked KPI, minimal padding */
@media (max-width: 480px) {
    .dashboard-main {
        padding: 10px 8px;
    }

    .dashboard-meta {
        display: none;
    }

    .kpi-row {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        margin-bottom: 12px;
    }

    .kpi-tile {
        padding: 10px 8px;
    }

    .kpi-value {
        font-size: 1.15rem;
    }

    .chart-grid {
        gap: 10px;
        margin-bottom: 12px;
    }

    .chart-card {
        padding: 10px 8px;
    }

    .chart-title {
        font-size: 0.75rem;
    }

    .chart-hint {
        display: none;
    }

    .cat-row {
        grid-template-columns: 20px 1fr 2fr 40px;
        gap: 4px;
        padding: 3px 4px;
    }

    .cat-name {
        font-size: 0.72rem;
    }

    .cat-ap {
        font-size: 0.65rem;
    }

    .cat-bar-wrap {
        height: 10px;
    }

    .tide-row {
        grid-template-columns: 70px 1fr 44px;
        gap: 4px;
        padding: 5px 2px;
    }

    .tide-count {
        display: none;
    }

    .tide-label {
        font-size: 0.72rem;
    }

    .tide-bar-wrap {
        height: 14px;
    }

    .label-errors-table th:nth-child(4),
    .label-errors-table td:nth-child(4),
    .label-errors-table th:nth-child(6),
    .label-errors-table td:nth-child(6) {
        display: none;
    }
}

/* ── Accessibility: Reduced Motion ── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}


/* ── Empty state ── */
/* One owner for the "no data" paragraph the dashboard, its partials, and the
   per-category panel all render. */
.empty-state {
    color: var(--text-secondary);
    text-align: center;
    padding: 40px;
}
