/* Header styles loaded via <link> in HTML — see header.css */

/* ========================================================
   Gallery Page
   ======================================================== */

:root {
    --g-accent: #8C1515;
    --g-accent-soft: #f4eaea;
    --g-accent-hover: #6f1010;
    --g-text: #0D0F0F;
    --g-text-2: #5c5348;
    --g-text-3: #8a8279;
    --g-bg: #F3EFEC;
    --g-surface: #ffffff;
    --g-border: #e0d8d2;
    --g-border-soft: #f5f0eb;
    --g-positive: #1d6b4a;
    --g-positive-bg: #EAF1ED;
    --g-negative: #b42318;
    --g-negative-bg: #fce8e6;
    --g-annotation-bg: #fef9c3;
    --g-sidebar-w: 280px;
    --g-right-w: 320px;
    --g-header-h: 56px;

    /* Shared header variables (used by header.css) */
    --h-fg: #0D0F0F;
    --h-fg2: #5c5348;
    --h-fg3: #8a8279;
    --h-bg: #fff;
    --h-bg2: #F3EFEC;
    --h-border: #e0d8d2;
    --h-brand: #8C1515;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Source Sans 3', system-ui, -apple-system, 'Segoe UI', sans-serif;
    background: var(--g-bg);
    color: var(--g-text);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ── Three Panels ─────────────────────────────── */
.panels {
    display: flex;
    flex: 1;
    min-height: 0;          /* allow flex children to shrink below content size */
}

/* ── LEFT: Sidebar ────────────────────────────── */
.panel-left {
    width: var(--g-sidebar-w);
    min-width: 180px;
    background: var(--g-surface);
    border-right: 1px solid var(--g-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width 0.25s ease, min-width 0.25s ease, padding 0.25s ease;
}
.panel-left.collapsed {
    width: 0 !important;
    min-width: 0 !important;
    padding: 0 !important;
    border-right: none;
    overflow: hidden;
}

.panel-left-header {
    padding: 14px 16px 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.panel-left-header h2 {
    font-size: 11px;
    font-weight: 600;
    color: var(--g-text-3);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.product-count {
    font-size: 11px;
    font-weight: 600;
    color: var(--g-text-3);
}

/* ── Panel collapse & resize ─────────────────── */
.panel-collapse-btn {
    background: none;
    border: 1px solid var(--g-border);
    border-radius: 4px;
    padding: 2px 4px;
    cursor: pointer;
    color: var(--g-text-3);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    margin-left: auto;
    flex-shrink: 0;
}
.panel-collapse-btn:hover {
    color: var(--g-text);
    background: var(--g-bg);
    border-color: var(--g-text-3);
}
.collapsed .panel-collapse-btn { display: none; }

.panel-resize-handle {
    width: 4px;
    cursor: col-resize;
    background: transparent;
    flex-shrink: 0;
    transition: background 0.15s;
    position: relative;
    z-index: 5;
}
.panel-resize-handle::after {
    content: '';
    position: absolute;
    top: 0; bottom: 0;
    left: -3px; right: -3px;
}
.panel-resize-handle:hover,
.panel-resize-handle.dragging {
    background: var(--g-accent, #8C1515);
}

/* Expand tabs shown when panel is collapsed */
.panel-expand-tab {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 48px;
    background: var(--g-surface, #fff);
    border: 1px solid var(--g-border);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--g-text-3);
    z-index: 6;
    transition: all 0.15s;
}
.panel-expand-tab:hover {
    color: var(--g-text);
    background: var(--g-bg);
}
.panel-expand-tab-left {
    left: 0;
    border-radius: 0 6px 6px 0;
    border-left: none;
}
.panel-expand-tab-right {
    right: 0;
    border-radius: 6px 0 0 6px;
    border-right: none;
}

.directory-filters {
    display: flex;
    gap: 1px;
    padding: 0 12px 8px;
    background: transparent;
}

.data-source-note {
    font-size: 11px;
    font-weight: 600;
    color: #8C1515;
    margin-bottom: 10px;
    padding: 6px 10px;
    background: rgba(140,21,21,.06);
    border-left: 3px solid #8C1515;
    border-radius: 0 6px 6px 0;
    line-height: 1.4;
}

.gallery-footnote {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--g-surface);
    border-top: 1px solid var(--g-border);
    padding: 6px 16px;
    font-size: 10px;
    color: var(--g-text-3);
    z-index: 50;
    line-height: 1.5;
}
.gallery-footnote a {
    color: var(--g-accent, #8C1515);
    text-decoration: none;
}
.gallery-footnote a:hover {
    text-decoration: underline;
}

.dir-filter {
    background: none;
    border: none;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 500;
    color: var(--g-text-3);
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.15s;
    font-family: inherit;
}

.dir-filter:hover { color: var(--g-text-2); background: var(--g-border-soft); }

.dir-filter.active {
    color: var(--g-text);
    background: var(--g-border-soft);
    font-weight: 600;
}

.directory-search {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0 12px 6px;
    padding: 5px 8px;
    background: var(--g-bg);
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--g-text-3);
    transition: border-color 0.15s;
}

.directory-search:focus-within { border-color: var(--g-border); }

.directory-search input {
    border: none;
    background: none;
    outline: none;
    font-size: 12px;
    font-family: inherit;
    color: var(--g-text);
    width: 100%;
}

.directory-search input::placeholder { color: var(--g-text-3); }

.directory-list {
    flex: 1;
    overflow-y: auto;
    padding: 2px 6px 12px;
}

/* Product item */
.dir-product {
    margin-bottom: 1px;
}

.dir-product-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    background: none;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    transition: background 0.1s;
}

.dir-product-btn:hover { background: var(--g-bg); }

.dir-product-btn.active {
    background: var(--g-bg);
}

.dir-product-logo {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    object-fit: contain;
    flex-shrink: 0;
}

.dir-product-logo-fallback {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

.dir-product-info {
    flex: 1;
    min-width: 0;
}

.dir-product-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--g-text);
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dir-product-meta {
    font-size: 11px;
    color: var(--g-text-3);
    line-height: 1.2;
}

.dir-product-badge {
    font-size: 11px;
    font-weight: 500;
    flex-shrink: 0;
    min-width: 16px;
    text-align: right;
}

.dir-product-badge.has-violations {
    color: var(--g-negative);
}

.dir-product-badge.no-violations {
    color: var(--g-text-3);
}

.dir-expand-icon {
    width: 14px;
    height: 14px;
    transition: transform 0.15s;
    flex-shrink: 0;
    color: var(--g-text-3);
}

.dir-product.expanded .dir-expand-icon {
    transform: rotate(90deg);
}

/* Prompt sub-items */
.dir-prompts {
    display: none;
    padding: 0 0 2px 36px;
}

.dir-product.expanded .dir-prompts { display: block; }

.dir-prompt-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    background: none;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    font-size: 12px;
    color: var(--g-text-2);
    transition: all 0.1s;
}

.dir-prompt-btn:hover { background: var(--g-bg); color: var(--g-text); }

.dir-prompt-btn.active {
    background: #F3EFEC;
    color: var(--g-text);
}

.dir-prompt-icon {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    opacity: 0.4;
}

.dir-prompt-btn.active .dir-prompt-icon { opacity: 0.8; }

.dir-prompt-label {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dir-prompt-violations {
    font-size: 10px;
    font-weight: 500;
    color: var(--g-negative);
    flex-shrink: 0;
}

.dir-prompt-btn.active .dir-prompt-violations { color: var(--g-negative); }

/* ── CENTER: Prompt Viewer ────────────────────── */
.panel-center {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--g-bg);
}

.center-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--g-text-3);
    text-align: center;
    padding: 40px;
}

.center-empty svg { opacity: 0.3; }

.center-empty h3 {
    font-size: 15px;
    font-weight: 500;
    color: var(--g-text-2);
}

.center-empty p {
    font-size: 13px;
    max-width: 280px;
    line-height: 1.5;
}

.center-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Prompt header */
.prompt-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    background: var(--g-surface);
    border-bottom: 1px solid var(--g-border);
    flex-shrink: 0;
}

.prompt-header-logo {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    object-fit: contain;
}

.prompt-header-logo-fallback {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 13px;
    font-weight: 700;
}

.prompt-header-info {
    flex: 1;
    min-width: 0;
}

.prompt-header-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--g-text);
}

.prompt-header-file {
    font-size: 11px;
    color: var(--g-text-3);
    font-family: 'SF Mono', 'Fira Code', ui-monospace, monospace;
}

.prompt-header-type {
    font-size: 11px;
    color: var(--g-text-2);
    background: var(--g-bg);
    padding: 3px 8px;
    border-radius: 4px;
    font-weight: 500;
    flex-shrink: 0;
}

/* Prompt badges (protection rank + problematic status) */
.prompt-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

.prompt-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 9px;
    border-radius: 20px;
    line-height: 1.3;
    letter-spacing: 0.01em;
    white-space: nowrap;
}

.prompt-badge svg {
    flex-shrink: 0;
}

/* Protective tiers */
.prompt-badge--pos-t10 {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    color: #92400e;
    border: 1px solid #f59e0b44;
}
.prompt-badge--pos-t10 svg { stroke: #d97706; }

.prompt-badge--pos-t30 {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #10b98133;
}
.prompt-badge--pos-t30 svg { stroke: #059669; }

.prompt-badge--pos-t50 {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #86efac22;
}
.prompt-badge--pos-t50 svg { stroke: #16a34a; }

.prompt-badge--pos-rest {
    background: #f8fafc;
    color: #64748b;
    border: 1px solid #e2e8f022;
}
.prompt-badge--pos-rest svg { stroke: #94a3b8; }

/* Problematic tiers */
.prompt-badge--neg-t10 {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fca5a544;
}
.prompt-badge--neg-t10 svg { stroke: #dc2626; }

.prompt-badge--neg-t30 {
    background: #fff7ed;
    color: #9a3412;
    border: 1px solid #fdba7433;
}
.prompt-badge--neg-t30 svg { stroke: #ea580c; }

.prompt-badge--neg-rest {
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fcd34d22;
}
.prompt-badge--neg-rest svg { stroke: #d97706; }

/* Clean — no problematic */
.prompt-badge--clean {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #86efac33;
}
.prompt-badge--clean svg { stroke: #16a34a; }

/* Dimension scores (pill row) */
.dimension-scores-bar {
    display: flex;
    gap: 6px;
    padding: 10px 20px;
    background: var(--g-surface);
    border-bottom: 1px solid var(--g-border);
    flex-shrink: 0;
    flex-wrap: wrap;
}
.dimension-scores-bar:empty { display: none; }

.score-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: default;
    transition: all 0.15s ease;
}

.score-pill-label { font-weight: 600; }
.score-pill-val { font-weight: 500; opacity: 0.75; font-size: 0.9em; }

.score-positive {
    background: var(--g-positive-bg);
    color: var(--g-positive);
}

.score-negative {
    background: var(--g-negative-bg);
    color: var(--g-negative);
}

/* Dimension bar chart — diverging annotation counts */
.dimension-bar-chart { padding: 10px 20px 6px; }
.dim-chart { display: flex; flex-direction: column; gap: 1px; }
.dim-chart-header {
    display: grid;
    grid-template-columns: 24px 90px 1fr 2px 1fr 28px;
    align-items: center;
    gap: 8px;
    padding: 0 0 4px;
    border-bottom: 1px solid rgba(0,0,0,.06);
    margin-bottom: 2px;
}
.dim-chart-hdr-neg, .dim-chart-hdr-pos {
    font: 600 9px/1 var(--g-sans, sans-serif);
    color: var(--g-text-tertiary, #a09890);
    letter-spacing: .04em;
    text-transform: uppercase;
}
.dim-chart-hdr-neg { text-align: right; }
.dim-chart-hdr-pos { text-align: left; }
.dim-chart-row {
    display: grid;
    grid-template-columns: 24px 90px 1fr 2px 1fr 28px;
    align-items: center;
    gap: 8px;
    padding: 5px 0;
}
.dim-chart-row:hover { background: rgba(0,0,0,.015); border-radius: 4px; }
.dim-chart-id {
    font: 700 10px/1 var(--g-mono, monospace);
    color: var(--g-text-secondary, #6b6560);
}
.dim-chart-name {
    font: 500 11px/1.2 var(--g-sans, sans-serif);
    color: var(--g-text-primary, #1a1a2e);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.dim-chart-neg-track, .dim-chart-pos-track {
    display: flex;
    align-items: center;
    gap: 4px;
    height: 16px;
}
.dim-chart-neg-track { justify-content: flex-end; }
.dim-chart-center {
    width: 2px;
    height: 16px;
    background: rgba(0,0,0,.12);
    border-radius: 1px;
    flex-shrink: 0;
}
.dim-chart-fill {
    height: 8px;
    border-radius: 4px;
    transition: width .5s cubic-bezier(.22,1,.36,1);
    min-width: 4px;
}
.dim-chart-fill--pos { background: var(--g-positive, #1d6b4a); opacity: .55; }
.dim-chart-fill--neg { background: var(--g-negative, #b42318); opacity: .5; }
.dim-chart-count {
    font: 700 9px/1 var(--g-mono, monospace);
    flex-shrink: 0;
}
.dim-chart-count--pos { color: var(--g-positive, #1d6b4a); }
.dim-chart-count--neg { color: var(--g-negative, #b42318); }
.dim-chart-total {
    font: 600 9px/1 var(--g-mono, monospace);
    color: var(--g-text-tertiary, #a09890);
    text-align: right;
}

/* Prompt text toolbar */
.prompt-text-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 20px;
    border-bottom: 1px solid var(--g-border, #eee);
}

/* View switcher — segmented control */
.view-switcher {
    display: flex;
    background: rgba(0,0,0,.04);
    border-radius: 8px;
    padding: 2px;
    gap: 2px;
    flex-shrink: 0;
}
.view-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 14px;
    border: none;
    border-radius: 6px;
    background: transparent;
    font: 600 11px/1 var(--g-sans, sans-serif);
    color: var(--g-text-secondary, #6b6560);
    cursor: pointer;
    transition: all .15s ease;
    white-space: nowrap;
}
.view-btn svg { opacity: .5; transition: opacity .15s; }
.view-btn:hover {
    color: var(--g-text-primary, #1a1a2e);
    background: rgba(0,0,0,.03);
}
.view-btn:hover svg { opacity: .7; }
.view-btn.active {
    background: #fff;
    color: var(--g-text-primary, #1a1a2e);
    box-shadow: 0 1px 3px rgba(0,0,0,.08), 0 0 0 1px rgba(0,0,0,.04);
}
.view-btn.active svg { opacity: .85; }

/* Evidence legend — pill style */
.evidence-legend {
    display: flex;
    gap: 8px;
    flex: 1;
    flex-wrap: wrap;
    align-items: center;
}

.evidence-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 20px;
    font: 600 11px/1 var(--g-sans, sans-serif);
    letter-spacing: .02em;
}

.evidence-legend-item:has(.hl-evidence-negative) {
    background: rgba(185, 28, 28, 0.06);
    color: rgba(185, 28, 28, 0.85);
}
.evidence-legend-item:has(.hl-evidence-risky-swatch) {
    background: rgba(234, 179, 8, 0.08);
    color: rgba(180, 130, 0, 0.9);
}
.evidence-legend-item:has(.hl-evidence-positive) {
    background: rgba(21, 128, 61, 0.06);
    color: rgba(21, 128, 61, 0.85);
}
.evidence-legend-item:has(.hl-annotation-swatch) {
    background: rgba(59, 130, 246, 0.06);
    color: rgba(59, 130, 246, 0.85);
}

.evidence-legend-swatch {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.evidence-legend-swatch.hl-evidence-positive {
    background: rgba(21, 128, 61, 0.7);
    border-bottom: none;
}

.evidence-legend-swatch.hl-evidence-negative {
    background: rgba(185, 28, 28, 0.7);
    border-bottom: none;
}

.evidence-legend-swatch.hl-evidence-risky-swatch {
    background: rgba(200, 150, 0, 0.7);
    border-bottom: none;
}

.evidence-legend-swatch.hl-annotation-swatch {
    background: rgba(59, 130, 246, 0.7);
    border-bottom: none;
}

/* Prompt text */
.prompt-text-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    position: relative;
    background: var(--g-surface);
}

.prompt-pre {
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', ui-monospace, monospace;
    font-size: 12.5px;
    line-height: 1.75;
    color: var(--g-text);
    margin: 0;
    tab-size: 4;
}

/* ── Excerpt context + ellipsis ──────────────── */
.ctx-text {
    color: var(--g-text-3);
}

.ctx-ellipsis {
    color: var(--g-text-3);
    opacity: 0.5;
    user-select: none;
    font-size: 16px;
    letter-spacing: 2px;
}

/* ── Risky highlight ─────────────────────────── */
.hl-evidence-risky {
    background: rgba(234, 179, 8, 0.12);
    border-bottom: 2px solid rgba(234, 179, 8, 0.5);
    font-weight: 600;
    border-radius: 1px;
}

/* Highlights */
.highlight { cursor: pointer; }

.hl-evidence-positive {
    background: rgba(21, 128, 61, 0.1);
    border-bottom: 2px solid rgba(21, 128, 61, 0.45);
    font-weight: 600;
    border-radius: 1px;
}

.hl-evidence-negative {
    background: rgba(185, 28, 28, 0.1);
    border-bottom: 2px solid rgba(185, 28, 28, 0.45);
    font-weight: 600;
    border-radius: 1px;
}

.hl-annotation {
    cursor: pointer;
    background: rgba(59, 130, 246, 0.13);
    border-bottom: 2px solid rgba(59, 130, 246, 0.5);
    border-radius: 1px;
}

/* Fade-in for highlights when annotations load asynchronously */
@keyframes highlightFadeIn {
    from {
        background-color: transparent;
        border-bottom-color: transparent;
    }
}

.prompt-text-container.annotations-loaded .highlight {
    animation: highlightFadeIn 0.5s ease-out;
}

.highlight-flash {
    animation: hlFlash 1.2s ease;
}

@keyframes hlFlash {
    0%, 100% { opacity: 1; }
    30% { opacity: 0.2; }
    60% { opacity: 1; }
}

.pill-flash {
    animation: pillFlash 1.2s ease;
}

@keyframes pillFlash {
    0%, 100% { transform: scale(1); }
    30% { transform: scale(1.15); }
    60% { transform: scale(1); }
}

/* ── RIGHT: Annotations ──────────────────────── */
.panel-right {
    width: var(--g-right-w);
    min-width: 180px;
    background: var(--g-surface);
    border-left: 1px solid var(--g-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width 0.25s ease, min-width 0.25s ease, padding 0.25s ease;
}
.panel-right.collapsed {
    width: 0 !important;
    min-width: 0 !important;
    padding: 0 !important;
    border-left: none;
    overflow: hidden;
}

.panel-right-header {
    padding: 14px 16px 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.panel-right-header h2 {
    font-size: 11px;
    font-weight: 600;
    color: var(--g-text-3);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.ann-count {
    font-size: 11px;
    font-weight: 600;
    color: var(--g-text-3);
}


/* Annotations list */
.annotations-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 12px;
}

.annotations-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--g-text-3);
    font-size: 13px;
    line-height: 1.6;
}

.annotations-empty p {
    margin: 0;
}

.annotations-empty::before {
    content: '💬';
    display: block;
    font-size: 28px;
    margin-bottom: 8px;
    opacity: 0.5;
}

/* Annotation card */
.annotation-card {
    padding: 14px 16px;
    margin-bottom: 8px;
    border-radius: 12px;
    cursor: pointer;
    border: 1px solid var(--g-border-soft);
    background: var(--g-surface);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    animation: annotationCardIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* Staggered entrance for annotation cards */
.annotation-card:nth-child(1) { animation-delay: 0s; }
.annotation-card:nth-child(2) { animation-delay: 0.05s; }
.annotation-card:nth-child(3) { animation-delay: 0.1s; }
.annotation-card:nth-child(4) { animation-delay: 0.15s; }
.annotation-card:nth-child(5) { animation-delay: 0.2s; }
.annotation-card:nth-child(n+6) { animation-delay: 0.25s; }

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

.annotation-card:hover {
    border-color: var(--g-border);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.03);
    transform: translateY(-1px);
}

.annotation-card:active {
    transform: translateY(0);
    box-shadow: none;
}

.annotation-flash {
    animation: annFlash 1.2s ease;
}

@keyframes annFlash {
    0%, 100% { background: var(--g-surface); box-shadow: none; }
    30% { background: var(--g-accent-soft); box-shadow: 0 0 0 2px var(--g-accent)20; }
    60% { background: var(--g-surface); box-shadow: none; }
}

.ann-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.ann-user {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ann-avatar {
    width: 24px;
    height: 24px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 9px;
    font-weight: 700;
    flex-shrink: 0;
    letter-spacing: 0.5px;
}

.ann-user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--g-text);
    letter-spacing: -0.01em;
}

.ann-time {
    font-size: 11px;
    color: var(--g-text-3);
    margin-left: 2px;
}

.ann-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}
.ann-dim-tag {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 6px;
    letter-spacing: -0.01em;
}
.ann-delete-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border: none;
    background: none;
    color: var(--g-text-3);
    border-radius: 4px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s, color 0.15s;
}
.annotation-card:hover .ann-delete-btn { opacity: 1; }
.ann-delete-btn:hover {
    background: #fee2e2;
    color: #dc2626;
}

.ann-selected-text {
    font-size: 13px;
    color: var(--g-text-2);
    font-style: italic;
    line-height: 1.5;
    padding: 6px 10px;
    background: var(--g-bg);
    border-left: 3px solid var(--g-text-3);
    border-radius: 0 8px 8px 0;
    margin-bottom: 8px;
    margin-top: 2px;
}

.ann-comment {
    font-size: 13px;
    color: var(--g-text);
    line-height: 1.55;
    margin-bottom: 8px;
    letter-spacing: -0.005em;
}

/* ── Reaction Bar ────────────────────────────── */
.reaction-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    margin: 6px 0 4px;
}

.reaction-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px 3px 6px;
    border: 1px solid var(--g-border);
    border-radius: 20px;
    background: var(--g-bg);
    cursor: pointer;
    font-family: inherit;
    font-size: 12px;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    user-select: none;
    line-height: 1;
}

.reaction-pill:hover {
    border-color: var(--g-accent);
    background: var(--g-accent-soft);
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(225, 29, 72, 0.1);
}

.reaction-pill.reaction-active {
    border-color: var(--g-accent);
    background: var(--g-accent-soft);
    box-shadow: 0 0 0 1px var(--g-accent);
}

.reaction-pill.reaction-active:hover {
    background: var(--g-accent-soft);
}

.reaction-emoji {
    font-size: 15px;
    line-height: 1;
    display: flex;
    align-items: center;
}

.reaction-count {
    font-size: 11px;
    font-weight: 600;
    color: var(--g-text-2);
    min-width: 8px;
    text-align: center;
}

.reaction-pill.reaction-active .reaction-count {
    color: var(--g-accent);
}

/* Add reaction button */
.reaction-add-wrap {
    position: relative;
}

.reaction-add-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 24px;
    border: 1px dashed var(--g-border);
    border-radius: 20px;
    background: none;
    cursor: pointer;
    color: var(--g-text-3);
    transition: all 0.2s;
    padding: 0;
}

.reaction-add-btn:hover {
    border-color: var(--g-accent);
    color: var(--g-accent);
    background: var(--g-accent-soft);
    border-style: solid;
}

/* Reaction Picker Popup */
.reaction-picker {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%) scale(0.9);
    display: flex;
    gap: 2px;
    padding: 6px 8px;
    background: var(--g-surface);
    border: 1px solid var(--g-border);
    border-radius: 24px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06);
    opacity: 0;
    pointer-events: none;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 100;
    white-space: nowrap;
}

.reaction-picker.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-50%) scale(1);
}

.picker-emoji {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    transition: all 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
    padding: 0;
    position: relative;
}

.picker-emoji:hover {
    background: var(--g-bg);
    transform: scale(1.35);
}

.picker-emoji:active {
    transform: scale(1.0);
}

.picker-emoji.picker-active {
    background: var(--g-accent-soft);
}

.picker-emoji.picker-active::after {
    content: '';
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--g-accent);
}

/* Pop animation */
.reaction-pop {
    animation: reactionPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes reactionPop {
    0% { transform: scale(1); }
    40% { transform: scale(1.3); }
    70% { transform: scale(0.95); }
    100% { transform: scale(1); }
}

/* Picker arrow */
.reaction-picker::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: var(--g-surface);
    filter: drop-shadow(0 1px 1px rgba(0,0,0,0.05));
}

/* Replies */
.ann-replies {
    padding-left: 12px;
    border-left: 2px solid var(--g-border-soft);
    margin: 6px 0 2px;
}

.reply-item {
    padding: 6px 0;
    animation: replyFadeIn 0.3s ease-out both;
}

.reply-item + .reply-item {
    border-top: 1px solid var(--g-border-soft);
}

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

.reply-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 2px;
}

.reply-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

.reply-header strong {
    font-size: 12px;
    color: var(--g-text);
    font-weight: 600;
}

.reply-time {
    font-size: 10px;
    color: var(--g-text-3);
}

.reply-item p {
    font-size: 12px;
    color: var(--g-text-2);
    line-height: 1.5;
    margin: 0;
    padding-left: 13px;
}

.ann-reply-form {
    display: flex;
    gap: 6px;
    margin-top: 10px;
    align-items: center;
}

.reply-input {
    flex: 1;
    border: 1px solid var(--g-border);
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 12px;
    font-family: inherit;
    outline: none;
    transition: all 0.2s;
    background: var(--g-bg);
}

.reply-input:focus {
    border-color: var(--g-accent);
    background: var(--g-surface);
    box-shadow: 0 0 0 2px rgba(225, 29, 72, 0.08);
}

.reply-input::placeholder {
    color: var(--g-text-3);
}

.reply-send-btn {
    background: var(--g-accent);
    color: white;
    border: none;
    border-radius: 8px;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.reply-send-btn:hover {
    background: var(--g-accent-hover);
    transform: scale(1.05);
}

.reply-send-btn:active {
    transform: scale(0.95);
}

.reply-send-btn:hover { opacity: 0.7; }

/* ── Medium-Style Selection Toolbar ──────────── */
.sel-toolbar {
    position: fixed;
    z-index: 200;
    display: flex;
    align-items: center;
    gap: 0;
    padding: 4px 6px;
    background: #1c1917;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.24), 0 1px 4px rgba(0,0,0,0.12);
    opacity: 0;
    pointer-events: none;
    transform: translateY(4px) scale(0.95);
    transition: all 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.sel-toolbar.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

/* Triangle arrow pointing down */
.sel-toolbar::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #1c1917;
}

.sel-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    background: none;
    color: rgba(255,255,255,0.75);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
    padding: 0;
}

.sel-btn:hover {
    color: white;
    background: rgba(255,255,255,0.12);
}

.sel-btn:active {
    transform: scale(0.92);
}

.sel-highlight:hover { color: #fbbf24; }
.sel-comment:hover { color: var(--g-accent); }

.sel-divider {
    width: 1px;
    height: 18px;
    background: rgba(255,255,255,0.15);
    margin: 0 2px;
}

/* ── Inline Comment Box (floating popover) ─────── */
.inline-comment-box {
    padding: 10px 12px;
    width: 340px;
    max-width: 90vw;
    background: var(--g-border-soft);
    border: 1px solid var(--g-border);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,.12), 0 2px 8px rgba(0,0,0,.06);
    animation: icbSlideIn 0.2s ease-out;
}

@keyframes icbSlideIn {
    from { opacity: 0; transform: translateY(-8px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.icb-selected {
    font-size: 11px;
    color: var(--g-text-2);
    font-style: italic;
    background: #fff;
    padding: 6px 10px;
    border-radius: 6px;
    margin-bottom: 8px;
    border-left: 3px solid var(--g-border);
    max-height: 40px;
    overflow: hidden;
    line-height: 1.4;
}
.icb-reactions {
    display: flex;
    gap: 4px;
    margin-bottom: 8px;
}
.icb-emoji {
    width: 32px;
    height: 32px;
    border: 1px solid var(--g-border);
    background: #fff;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.12s;
}
.icb-emoji:hover {
    background: var(--g-border-soft);
    border-color: var(--g-text-3);
    transform: scale(1.15);
}
.icb-emoji.icb-emoji-active {
    background: var(--g-accent-soft);
    border-color: var(--g-accent);
}
.icb-comment-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.icb-input {
    flex: 1;
    border: 1px solid var(--g-border);
    border-radius: 8px;
    padding: 7px 10px;
    font-size: 12px;
    font-family: inherit;
    outline: none;
    resize: none;
    transition: border-color 0.15s;
    background: #fff;
}

.icb-input:focus { border-color: var(--g-text-3); box-shadow: 0 0 0 3px rgba(140,21,21,.08); }

.icb-submit {
    padding: 7px 16px;
    border-radius: 8px;
    cursor: pointer;
    background: #000;
    border: none;
    color: #F6F2EE;
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    align-self: flex-end;
}
.icb-submit:hover { background: #E54A2B; }

/* ── Scrollbar ────────────────────────────────── */
.directory-list::-webkit-scrollbar,
.prompt-text-container::-webkit-scrollbar,
.annotations-list::-webkit-scrollbar {
    width: 5px;
}

.directory-list::-webkit-scrollbar-track,
.prompt-text-container::-webkit-scrollbar-track,
.annotations-list::-webkit-scrollbar-track {
    background: transparent;
}

.directory-list::-webkit-scrollbar-thumb,
.prompt-text-container::-webkit-scrollbar-thumb,
.annotations-list::-webkit-scrollbar-thumb {
    background: var(--g-border);
    border-radius: 3px;
}

.directory-list::-webkit-scrollbar-thumb:hover,
.prompt-text-container::-webkit-scrollbar-thumb:hover,
.annotations-list::-webkit-scrollbar-thumb:hover {
    background: var(--g-text-3);
}

/* ── Responsive ───────────────────────────────── */
@media (max-width: 1100px) {
    :root {
        --g-sidebar-w: 220px;
        --g-right-w: 260px;
    }
}

/* ── Mobile bottom tab bar ─────────────────────── */
.mobile-tab-bar {
    display: none;
}

@media (max-width: 860px) {
    body { overflow: hidden; }
    .panel-collapse-btn,
    .panel-resize-handle,
    .panel-expand-tab { display: none !important; }

    .panels {
        flex-direction: row;
        flex: 1;
        min-height: 0;
        position: relative;
        overflow: hidden;
    }

    .panel-left, .panel-right {
        position: absolute;
        top: 0; bottom: 0;
        width: 100%;
        min-width: 100%;
        max-height: none;
        border-right: none;
        border-left: none;
        border-bottom: none;
        z-index: 10;
        transform: translateX(-100%);
        transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1),
                    visibility 0s 0.28s;
        visibility: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        background: var(--g-surface, #fff);
    }

    .panel-right {
        transform: translateX(100%);
    }

    .panel-left.mobile-visible,
    .panel-right.mobile-visible {
        transform: translateX(0);
        visibility: visible;
        transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1),
                    visibility 0s 0s;
    }

    .panel-center {
        width: 100%;
        min-width: 100%;
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        min-height: 0;
    }

    .inline-comment-box {
        position: fixed !important;
        bottom: 56px;
        left: 0 !important;
        top: auto !important;
        width: 100%;
        max-width: 100vw;
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -4px 24px rgba(0,0,0,.12);
        z-index: 200 !important;
    }
    .icb-emoji { width: 36px; height: 36px; font-size: 18px; }
    .icb-input { font-size: 16px; }

    .mobile-tab-bar {
        display: flex;
        background: var(--g-surface);
        border-top: 1px solid var(--g-border);
        padding: 0;
        flex-shrink: 0;
        z-index: 20;
    }

    .mobile-tab {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        padding: 8px 4px 6px;
        background: none;
        border: none;
        font-family: inherit;
        font-size: 10px;
        font-weight: 500;
        color: var(--g-text-3);
        cursor: pointer;
        transition: color 0.15s, background 0.15s;
        position: relative;
    }

    .mobile-tab svg {
        width: 20px;
        height: 20px;
        flex-shrink: 0;
    }

    .mobile-tab:hover {
        color: var(--g-text-2);
        background: var(--g-bg);
    }

    .mobile-tab.active {
        color: var(--g-accent);
        font-weight: 600;
    }

    .mobile-tab.active::after {
        content: '';
        position: absolute;
        top: 0;
        left: 20%;
        right: 20%;
        height: 2px;
        background: var(--g-accent);
        border-radius: 0 0 2px 2px;
    }

    .mobile-tab .mobile-tab-badge {
        position: absolute;
        top: 4px;
        right: calc(50% - 18px);
        min-width: 14px;
        height: 14px;
        padding: 0 4px;
        background: var(--g-negative);
        color: white;
        font-size: 9px;
        font-weight: 700;
        border-radius: 7px;
        display: flex;
        align-items: center;
        justify-content: center;
        line-height: 1;
    }

    .center-empty p { font-size: 12px; }
    .center-empty h3 { font-size: 14px; }

    .prompt-header { padding: 10px 14px; gap: 8px; }
    .prompt-header-name { font-size: 13px; }
    .dimension-scores-bar { padding: 8px 14px; gap: 4px; }
    .score-pill { font-size: 11px; padding: 4px 8px; }
    .evidence-legend { gap: 4px; }
    .evidence-legend-item { padding: 4px 8px; font-size: 10px; }
    .prompt-text-container { padding: 14px; -webkit-overflow-scrolling: touch; }
    .prompt-pre { font-size: 11.5px; line-height: 1.7; }

    .sel-toolbar { display: none !important; }

    .topbar-subtitle { display: none; }
}

/* ========================================================
   Skeleton Loading Placeholders
   ======================================================== */
.skel {
    background: linear-gradient(90deg, var(--g-border) 25%, var(--g-border-soft) 50%, var(--g-border) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 6px;
}
@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
.skel-line { height: 14px; margin-bottom: 12px; }
.skel-block { height: 80px; margin-bottom: 12px; }
.skel-placeholder { padding: 4px 0; }

/* ========================================================
   Content Transition Animations
   ======================================================== */
@keyframes fadeSlideIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Applied to prompt text container after content loads */
.prompt-text-container.loaded {
    animation: fadeSlideIn 0.3s ease-out both;
}

/* Applied to header + scores when switching prompts */
.prompt-header.loaded {
    animation: fadeSlideIn 0.25s ease-out both;
}
.dimension-scores-bar.loaded {
    animation: fadeSlideIn 0.25s ease-out 0.05s both;
}

/* Stagger for skeleton lines */
.skel-loading .skel-line:nth-child(1) { animation-delay: 0s; }
.skel-loading .skel-line:nth-child(2) { animation-delay: 0.05s; }
.skel-loading .skel-line:nth-child(3) { animation-delay: 0.1s; }
.skel-loading .skel-line:nth-child(4) { animation-delay: 0.15s; }
.skel-loading .skel-line:nth-child(5) { animation-delay: 0.2s; }
.skel-loading .skel-line:nth-child(6) { animation-delay: 0.25s; }
.skel-loading .skel-line:nth-child(7) { animation-delay: 0.3s; }
.skel-loading .skel-line:nth-child(8) { animation-delay: 0.35s; }

@keyframes skeletonFadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}
.skel-loading .skel-line {
    opacity: 0;
    animation: skeletonFadeIn 0.3s ease-out both, shimmer 1.5s infinite 0.4s;
}
