*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    /* Light surfaces */
    --bg:             #f8f9fb;
    --surface:        #ffffff;
    --surface-alt:    #f0f2f5;
    --surface-dark:   #1a1d27;
    --surface-darker: #0f1117;

    /* Text */
    --text:           #1a1d27;
    --text-muted:     #6b7280;
    --text-bright:    #0f1117;
    --text-on-dark:   #c8ccd4;

    /* Yellow highlighter accent */
    --yellow:         #f5e14d;
    --yellow-dim:     rgba(245, 225, 77, 0.20);
    --yellow-border:  #d4c132;
    --yellow-hover:   #ffe84d;

    /* Viridis heatmap (10-level) */
    --viz-0: #f0f2f5;  --viz-1: #fde725;  --viz-2: #6ece58;
    --viz-3: #35b779;  --viz-4: #1f9e89;  --viz-5: #26828e;
    --viz-6: #31688e;  --viz-7: #3e4989;  --viz-8: #482878;
    --viz-9: #440154;

    /* Functional */
    --border:         #dfe3ea;
    --border-dark:    #2a2e3a;
    --primary:        #2563eb;
    --link:           #2563eb;
    --danger:         #ef4444;
    --mark-bg:        rgba(245, 225, 77, 0.35);
}

body {
    font-family: "IBM Plex Sans", system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* ---- Top bar ---- */

#top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 44px;
    padding: 0 24px;
    background: var(--surface-dark);
    flex-shrink: 0;
}

#top-bar-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

#top-bar-left .breadcrumb-sep {
    color: #fff;
    font-size: 0.8rem;
}

#top-bar-title {
    font-family: "IBM Plex Mono", "SF Mono", "Cascadia Code", monospace;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-on-dark);
    text-decoration: none;
    letter-spacing: -0.02em;
    flex-shrink: 0;
}

#top-bar-title:hover {
    color: var(--yellow);
}

#top-bar-context {
    font-family: "IBM Plex Mono", "SF Mono", "Cascadia Code", monospace;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--yellow);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#top-nav {
    display: flex;
    gap: 16px;
    flex-shrink: 0;
}

#top-nav a {
    font-family: "IBM Plex Sans", system-ui, sans-serif;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-on-dark);
    text-decoration: none;
    padding: 4px 8px;
    border-radius: 4px;
}

#top-nav a:hover {
    color: var(--yellow);
}

#top-nav a.active {
    background: rgba(245, 225, 77, 0.15);
    color: var(--yellow);
}

/* ---- Homepage ---- */

#datasets-page {
    flex: 1;
    padding: 24px 48px 64px;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    overflow-y: auto;
}

#home-header {
    margin-bottom: 24px;
}

.home-stats {
    font-family: "IBM Plex Mono", "SF Mono", "Cascadia Code", monospace;
    font-size: 0.85em;
    color: var(--text-muted);
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
}

.home-stats .stat-value {
    color: var(--text);
    font-weight: 500;
}

#datasets-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

/* Dataset cards */
.dataset-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 20px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.dataset-card:hover {
    border-color: var(--yellow-border);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

.dataset-card-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 12px;
}

.dataset-card-name {
    font-family: "IBM Plex Mono", "SF Mono", "Cascadia Code", monospace;
    font-size: 1.1em;
    font-weight: 500;
    color: var(--text-bright);
}

.dataset-card-badge {
    font-family: "IBM Plex Mono", "SF Mono", "Cascadia Code", monospace;
    font-size: 0.7em;
    padding: 2px 8px;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 3px;
    color: var(--text-muted);
}

.dataset-card-stats {
    font-family: "IBM Plex Mono", "SF Mono", "Cascadia Code", monospace;
    font-size: 0.8em;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 12px;
}

.dataset-card-stats div {
    display: flex;
    justify-content: space-between;
}

.dataset-card-stats .stat-value {
    font-weight: 500;
    color: var(--text);
}

.dataset-card-heatmap {
    margin-top: auto;
    padding-top: 12px;
    line-height: 0;
}

.dataset-card-heatmap svg {
    width: 100%;
    height: auto;
    border-radius: 2px;
}

/* ---- Detail view ---- */

#detail-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* ---- Breadcrumb separator ---- */

.breadcrumb-sep {
    color: var(--border);
}

/* ---- Tabs ---- */

.tabs {
    display: flex;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    flex-shrink: 0;
}

.tab {
    padding: 10px 20px;
    cursor: pointer;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    font-family: "IBM Plex Sans", system-ui, sans-serif;
    font-size: 0.85rem;
    font-weight: 500;
    user-select: none;
}

.tab:hover {
    color: var(--text);
}

.tab.active {
    color: var(--text-bright);
    border-bottom-color: var(--yellow);
}

/* ---- Search bar ---- */

#search-bar {
    display: flex;
    align-items: center;
    padding: 8px 24px 16px;
    flex-shrink: 0;
}

.search-bar-form {
    display: flex;
    flex: 1;
    max-width: 600px;
    gap: 0.5rem;
}

.search-bar-form input[type="text"] {
    flex: 1;
    padding: 0.45rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-family: "IBM Plex Mono", "SF Mono", "Cascadia Code", monospace;
    font-size: 0.85rem;
    background: var(--surface);
    color: var(--text);
}

.search-bar-form input[type="text"]::placeholder {
    color: #b0b8c1;
}

.search-bar-form input[type="text"]:focus {
    outline: none;
    border-color: var(--yellow-border);
    box-shadow: 0 0 0 2px var(--yellow-dim);
}

.search-bar-form button {
    padding: 0.45rem 1.25rem;
    background: var(--text-bright);
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-family: "IBM Plex Sans", system-ui, sans-serif;
    font-size: 0.85rem;
    font-weight: 500;
}

.search-bar-form button:hover {
    background: #2d3142;
}

.search-bar-form button[type="button"] {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
}

.search-bar-form button[type="button"]:hover {
    background: var(--surface-alt);
    border-color: var(--text-muted);
}

.search-bar-form input[type="date"] {
    padding: 0.45rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-family: "IBM Plex Mono", "SF Mono", "Cascadia Code", monospace;
    font-size: 0.85rem;
    background: var(--surface);
    color: var(--text);
}

.search-bar-form input[type="date"]:focus {
    outline: none;
    border-color: var(--yellow-border);
    box-shadow: 0 0 0 2px var(--yellow-dim);
}

.search-bar-form select {
    padding: 0.45rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-family: "IBM Plex Mono", "SF Mono", "Cascadia Code", monospace;
    font-size: 0.85rem;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
}

.search-bar-form select:focus {
    outline: none;
    border-color: var(--yellow-border);
    box-shadow: 0 0 0 2px var(--yellow-dim);
}

/* ---- Main layout ---- */

main {
    flex: 1;
    display: grid;
    min-height: 0;
    border-top: 1px solid var(--border);
    grid-template-rows: 1fr auto;
    overflow: hidden;
}

main.no-viewer {
    grid-template-columns: 1fr;
}

main.has-viewer {
    grid-template-columns: 1fr 5px 1fr;
}

main.has-diff-viewer {
    grid-template-columns: 350px 5px 1fr;
}

.main-splitter {
    display: none;
    width: 5px;
    cursor: col-resize;
    background: var(--border);
    flex-shrink: 0;
    transition: background 0.15s;
    grid-column: 2;
    grid-row: 1;
}

.main-splitter:hover,
.main-splitter.dragging {
    background: var(--primary);
}

main.has-viewer .main-splitter,
main.has-diff-viewer .main-splitter {
    display: block;
}

main.no-viewer #viewer-panel {
    display: none;
}

main.has-viewer #viewer-panel,
main.has-diff-viewer #viewer-panel {
    display: flex;
}

/* ---- Results panel ---- */

#results-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
    grid-column: 1;
    grid-row: 1;
}

#results-header {
    padding: 0.5rem 1rem;
    font-family: "IBM Plex Mono", "SF Mono", "Cascadia Code", monospace;
    font-size: 0.8rem;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

#results-list {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.result-item {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    border-left: 3px solid transparent;
}

.result-item:hover {
    background: var(--surface-alt);
}

.result-item.active {
    background: var(--yellow-dim);
    border-left-color: var(--yellow);
}

/* Grouped results */
.result-group {
    border-bottom: 1px solid var(--text-muted);
    position: relative;
}


.result-group-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 0.6rem 0.65rem 1rem;
    cursor: pointer;
    user-select: none;
}

.summary-toggle {
    display: flex;
    align-items: center;
    gap: 4px;
    font-family: "IBM Plex Mono", "SF Mono", "Cascadia Code", monospace;
    font-size: 0.75rem;
    color: var(--text-muted);
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
}

.summary-toggle input[type="checkbox"] {
    accent-color: var(--primary);
}

.result-group-summary {
    position: relative;
    font-family: "IBM Plex Sans", system-ui, sans-serif;
    font-size: 0.7rem;
    color: var(--text-muted);
    padding: 0.3rem 1rem 0.4rem calc(0.9rem + 0.7rem + 0.5rem);
    line-height: 1.4;
}

.result-group-summary::before {
    content: "";
    position: absolute;
    left: calc(0.9rem + 1px);
    top: 0;
    bottom: 0;
    width: 1px;
    background: #a5abb4;
}

.result-group-header:hover {
    background: var(--surface-alt);
}

.result-group-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
    overflow: hidden;
    flex: 1 1 0;
}

.result-group-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
    margin-left: auto;
}

.result-group-toggle {
    font-size: 0.7rem;
    color: var(--text-muted);
    width: 1rem;
    text-align: center;
    flex-shrink: 0;
}

.result-group-name {
    font-family: "IBM Plex Mono", "SF Mono", "Cascadia Code", monospace;
    font-weight: 500;
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

/* Hide redundant dataset chip inside a dataset view */
#detail-view .result-group-dataset {
    display: none;
}

.result-group-pages-label {
    font-family: "IBM Plex Mono", "SF Mono", "Cascadia Code", monospace;
    font-size: 0.75rem;
    color: var(--text-muted);
    width: 4.5rem;
    text-align: right;
    flex-shrink: 0;
}

.result-group-dataset {
    font-family: "IBM Plex Mono", "SF Mono", "Cascadia Code", monospace;
    font-size: 0.65rem;
    padding: 0.1rem 0.3rem;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: var(--surface);
    color: var(--text-muted);
    font-weight: 500;
    white-space: nowrap;
    text-align: center;
    flex-shrink: 0;
}

.result-group-category {
    font-family: "IBM Plex Mono", "SF Mono", "Cascadia Code", monospace;
    font-size: 0.65rem;
    padding: 0.1rem 0.3rem;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: var(--surface);
    color: var(--text-muted);
    font-weight: 500;
    white-space: nowrap;
    text-align: center;
    flex-shrink: 0;
}
.result-group-category.editable {
    cursor: pointer;
}
.result-group-category.editable:hover {
    border-color: var(--primary);
    color: var(--primary);
}

#category-edit-filename {
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}
#category-edit-select {
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.85rem;
    width: 100%;
    padding: 0.4rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    color: var(--text);
}

.result-group-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 1.5rem;
    background: var(--text-bright);
    color: white;
    border-radius: 3px;
    font-family: "IBM Plex Mono", "SF Mono", "Cascadia Code", monospace;
    font-size: 0.65rem;
    font-weight: 500;
    flex-shrink: 0;
}

.result-group-pages {
    display: none;
}

.result-group.expanded .result-group-header {
    background: var(--surface-alt);
    border-bottom: 1px solid var(--border);
}

.result-group.expanded .result-group-pages {
    display: block;
    position: relative;
    margin-left: 0.9rem;
    padding: 0.35rem 0.8rem 0.5rem 0;
}

/* Trunk connecting header to first leaf */
.result-group.expanded .result-group-pages::before {
    content: "";
    position: absolute;
    left: 1px;
    top: -1px;
    height: calc(0.35rem + 1px);
    width: 1px;
    background: #a5abb4;
}


.result-group.expanded .result-group-toggle {
    transform: rotate(90deg);
}

/* Tree connector: vertical pipe on the left */
.result-group-pages .result-item {
    position: relative;
    margin-left: 0.7rem;
    padding: 0.5rem 0.8rem 0.5rem 1rem;
    background: var(--surface);
    border: 1px solid #a5abb4;
    border-radius: 4px;
    margin-bottom: 0.35rem;
}

.result-group-pages .result-item:last-child {
    margin-bottom: 0;
}

/* Vertical pipe per item */
.result-group-pages .result-item::before {
    content: "";
    position: absolute;
    left: -0.7rem;
    top: -0.35rem;
    bottom: -0.35rem;
    width: 1px;
    background: #a5abb4;
}

/* First item: pipe starts from very top of pages container */
.result-group-pages .result-item:first-child::before {
    top: -0.35rem;
}

/* Last item: pipe stops at the horizontal branch (midpoint) */
.result-group-pages .result-item:last-child::before {
    bottom: calc(50% - 1px);
}

/* Horizontal branch connector */
.result-group-pages .result-item::after {
    content: "";
    position: absolute;
    left: -0.7rem;
    top: 50%;
    width: 0.7rem;
    height: 1px;
    background: #a5abb4;
}

/* Hover highlight on leaf cards */
.result-group-pages .result-item:hover {
    border-color: var(--text-muted);
}

.result-group-pages .result-item.active {
    border-color: #e5a136;
    background: rgba(229, 161, 54, 0.08);
}

.result-source {
    font-family: "IBM Plex Mono", "SF Mono", "Cascadia Code", monospace;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

.result-meta {
    font-family: "IBM Plex Mono", "SF Mono", "Cascadia Code", monospace;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.result-bates {
    font-weight: 500;
    color: var(--text);
}

.result-snippet {
    font-size: 0.85rem;
    line-height: 1.5;
    margin-top: 0.25rem;
}

.diff-snippet-clickable {
    cursor: pointer;
    display: inline-block;
    padding: 0.15rem 0.5rem;
    margin-top: 0.2rem;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: var(--surface);
    font-size: 0.8rem;
}

.diff-snippet-clickable:hover {
    border-color: var(--text-muted);
    background: var(--surface-alt);
}

.diff-snippet-clickable.selected {
    background: rgba(236, 72, 153, 0.25);
    border-color: rgba(236, 72, 153, 0.6);
}

.diff-snippet-empty {
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.7rem;
}

.result-snippet mark {
    background: var(--mark-bg);
    padding: 0 2px;
    border-radius: 1px;
}

.result-entities {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-top: 0.4rem;
}

.entity-chip {
    font-family: "IBM Plex Mono", "SF Mono", "Cascadia Code", monospace;
    font-size: 0.65rem;
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    font-weight: 500;
}

.entity-chip.person   { background: #dbeafe; color: #1e40af; }
.entity-chip.org      { background: #d1fae5; color: #065f46; }
.entity-chip.location { background: #ffedd5; color: #9a3412; }
.entity-chip.date     { background: #ede9fe; color: #5b21b6; }
.entity-chip.phone    { background: #ccfbf1; color: #134e4a; }
.entity-chip.email    { background: #fee2e2; color: #991b1b; }
.entity-chip.account_number { background: #fef3c7; color: #92400e; }
.entity-chip.credential     { background: #fce7f3; color: #9d174d; }
.entity-chip.misc     { background: #e5e7eb; color: #374151; }

/* ---- Pagination ---- */

#pagination {
    grid-column: 1 / -1;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-top: 1px solid var(--border);
    background: var(--surface);
}

#pagination button {
    padding: 0.3rem 0.7rem;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 4px;
    cursor: pointer;
    font-family: "IBM Plex Mono", "SF Mono", "Cascadia Code", monospace;
    font-size: 0.8rem;
}

#pagination button:hover:not(:disabled) {
    background: var(--surface-alt);
}

#pagination button:disabled {
    opacity: 0.4;
    cursor: default;
}

#pagination .page-info {
    font-family: "IBM Plex Mono", "SF Mono", "Cascadia Code", monospace;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ---- Viewer panel ---- */

#viewer-panel {
    flex-direction: column;
    border-left: none;
    min-height: 0;
    grid-column: 3;
    grid-row: 1;
    overflow: hidden;
}

#viewer-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    background: var(--surface-dark);
    border-bottom: 1px solid var(--border-dark);
    flex-shrink: 0;
}

#viewer-title {
    font-family: "IBM Plex Mono", "SF Mono", "Cascadia Code", monospace;
    font-size: 0.8rem;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-on-dark);
}

#viewer-title .doj-link {
    font-size: 0.7rem;
    color: var(--text-on-dark);
    font-weight: 500;
    padding: 0.2rem 0.5rem;
    background: rgba(255,255,255,0.08);
    border: 1px solid var(--border-dark);
    border-radius: 3px;
    text-decoration: underline;
    display: inline-block;
    vertical-align: middle;
}

#viewer-title .doj-link:hover {
    background: rgba(255,255,255,0.15);
    color: var(--yellow);
}

#viewer-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-shrink: 0;
}

.pdf-zoom-label {
    font-family: "IBM Plex Mono", "SF Mono", "Cascadia Code", monospace;
    font-size: 0.7rem;
    color: var(--text-on-dark);
    display: flex;
    align-items: center;
    gap: 0.3rem;
    white-space: nowrap;
}

.pdf-zoom-select {
    font-family: "IBM Plex Mono", "SF Mono", "Cascadia Code", monospace;
    font-size: 0.7rem;
    background: var(--surface-dark);
    color: var(--text-on-dark);
    border: 1px solid var(--border-dark);
    border-radius: 4px;
    padding: 0.15rem 0.3rem;
    cursor: pointer;
}

.pdf-zoom-select:hover {
    border-color: var(--text-muted);
}

#btn-new-tab {
    font-family: "IBM Plex Mono", "SF Mono", "Cascadia Code", monospace;
    font-size: 0.75rem;
    color: var(--text-on-dark);
    text-decoration: none;
}

#btn-new-tab:hover {
    color: var(--yellow);
    text-decoration: underline;
}

#btn-close-viewer {
    background: none;
    border: 1px solid var(--border-dark);
    border-radius: 4px;
    padding: 0.2rem 0.5rem;
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--text-on-dark);
}

#btn-close-viewer:hover {
    background: rgba(255,255,255,0.08);
    color: var(--yellow);
}

#pdf-viewer {
    flex: 1;
    border: none;
    width: 100%;
    background: var(--surface-darker);
}

/* ---- Diff viewer ---- */

#diff-viewer {
    display: none;
    flex: 1;
    flex-direction: row;
    overflow: hidden;
}

#diff-viewer.active {
    display: flex;
}

.diff-side {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.diff-side:first-child {
    border-right: 1px solid var(--border-dark);
}

.diff-label {
    padding: 0.3rem 0.75rem;
    font-family: "IBM Plex Mono", "SF Mono", "Cascadia Code", monospace;
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-on-dark);
    background: var(--surface-dark);
    border-bottom: 1px solid var(--border-dark);
    text-align: center;
    flex-shrink: 0;
}

.diff-label a {
    color: var(--yellow);
    text-decoration: underline;
    font-weight: 500;
}

.diff-label a:hover {
    color: var(--yellow-hover);
}

.diff-alt-select {
    background: var(--surface-dark);
    color: var(--text-on-dark);
    border: 1px solid var(--border-dark);
    border-radius: 3px;
    font-family: "IBM Plex Mono", "SF Mono", "Cascadia Code", monospace;
    font-size: 0.65rem;
    padding: 0.15rem 0.3rem;
    cursor: pointer;
    max-width: 100%;
}

.diff-alt-select:focus {
    outline: none;
    border-color: var(--yellow-border);
}

.diff-alt-select:hover {
    border-color: var(--yellow-border);
}

.doj-link {
    font-size: 0.65rem;
    color: var(--text-on-dark) !important;
    font-weight: 500 !important;
    margin-left: 0.5rem;
    padding: 0.15rem 0.4rem;
    background: rgba(255,255,255,0.08);
    border: 1px solid var(--border-dark);
    border-radius: 3px;
    white-space: nowrap;
}

.doj-link:hover {
    background: rgba(255,255,255,0.15);
    color: var(--yellow) !important;
}

.diff-canvas-wrap {
    flex: 1;
    overflow: auto;
    position: relative;
    background: var(--surface-darker);
}

.diff-canvas-wrap canvas {
    display: block;
}

/* Yellow highlighter bbox overlays */
.diff-bbox {
    position: absolute;
    background: rgba(245, 225, 77, 0.35);
    pointer-events: none;
    border-radius: 1px;
}

.diff-bbox-highlight {
    background: rgba(236, 72, 153, 0.40);
    z-index: 10;
}

/* Hide iframe when diff viewer is active */
main.has-diff-viewer #pdf-viewer {
    display: none;
}

/* ---- Footer ---- */

footer {
    padding: 0.4rem 1rem;
    font-family: "IBM Plex Mono", "SF Mono", "Cascadia Code", monospace;
    font-size: 0.7rem;
    color: var(--text-muted);
    background: var(--surface);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    text-align: center;
}

/* ---- Heatmap section ---- */

.heatmap-section {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 8px 24px 4px;
    display: flex;
    flex-direction: column;
    height: 290px;
    flex-shrink: 0;
}

.heatmap-section.collapsed {
    height: auto;
    padding: 4px 24px;
}

.heatmap-section.collapsed .heatmap-wrap {
    display: none;
}

.heatmap-wrap {
    flex: 1;
    overflow: hidden;
}

.heatmap-grid {
    display: grid;
    gap: 2px;
    width: 100%;
    height: 100%;
}

.heatmap-cell {
    border-radius: 2px;
    cursor: pointer;
    outline: 2px solid transparent;
    outline-offset: -1px;
    min-width: 0;
    min-height: 0;
}

.heatmap-label {
    font-family: "IBM Plex Mono", "SF Mono", "Cascadia Code", monospace;
    font-size: 0.7em;
    color: var(--text-muted);
    margin-bottom: 4px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.heatmap-collapse {
    font-size: 0.85em;
    padding: 1px 6px;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: var(--surface-alt);
    color: var(--text-muted);
    cursor: pointer;
    font-family: inherit;
}

.heatmap-collapse:hover {
    background: var(--surface);
    color: var(--text);
    border-color: var(--yellow-border);
}

.heatmap-legend {
    display: inline-flex;
    align-items: center;
    gap: 1px;
    margin-left: auto;
    flex-shrink: 0;
}

.heatmap-legend-cell {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 1px;
}

.heatmap-legend-label {
    font-size: 0.85em;
    color: var(--text-muted);
    padding: 0 4px;
}

.heatmap-footer {
    background: var(--surface);
    padding: 6px 24px 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    border-bottom: 1px solid var(--border);
}

.heatmap-cell:hover {
    outline-color: var(--danger);
    z-index: 1;
}

.heatmap-cell.selected {
    outline-color: var(--danger);
    outline-width: 3px;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.4);
    z-index: 2;
}

.heatmap-cell[data-level="0"] { background: var(--viz-0); }
.heatmap-cell[data-level="1"] { background: var(--viz-1); }
.heatmap-cell[data-level="2"] { background: var(--viz-2); }
.heatmap-cell[data-level="3"] { background: var(--viz-3); }
.heatmap-cell[data-level="4"] { background: var(--viz-4); }
.heatmap-cell[data-level="5"] { background: var(--viz-5); }
.heatmap-cell[data-level="6"] { background: var(--viz-6); }
.heatmap-cell[data-level="7"] { background: var(--viz-7); }
.heatmap-cell[data-level="8"] { background: var(--viz-8); }
.heatmap-cell[data-level="9"] { background: var(--viz-9); }

.heatmap-tooltip {
    position: fixed;
    background: var(--surface);
    color: var(--text);
    font-family: "IBM Plex Mono", "SF Mono", "Cascadia Code", monospace;
    font-size: 0.75rem;
    padding: 6px 10px;
    border-radius: 4px;
    border: 1px solid var(--border);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    pointer-events: none;
    z-index: 1000;
    white-space: nowrap;
}

.heatmap-summary {
    font-family: "IBM Plex Mono", "SF Mono", "Cascadia Code", monospace;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.heatmap-summary .stat-value {
    color: var(--text-bright);
    font-weight: 500;
}

.heatmap-timeline {
    display: flex;
    align-items: center;
    gap: 12px;
}

.heatmap-timeline input[type="range"] {
    flex: 1;
    max-width: 300px;
    accent-color: var(--primary);
    height: 4px;
    cursor: pointer;
}

/* ---- Removals detail (file table + preview split) ---- */

.removals-detail {
    display: flex;
    flex: 1 1 0;
    border-top: 1px solid var(--border);
    overflow: hidden;
}

.removals-table-wrap {
    width: 25%;
    flex-shrink: 0;
    overflow-y: auto;
    min-width: 150px;
    height: 100%;
}

.removals-splitter {
    width: 5px;
    cursor: col-resize;
    background: var(--border);
    flex-shrink: 0;
    transition: background 0.15s;
}

.removals-splitter:hover,
.removals-splitter.dragging {
    background: var(--primary);
}

.removals-table {
    width: 100%;
    border-collapse: collapse;
    font-family: "IBM Plex Mono", "SF Mono", "Cascadia Code", monospace;
    font-size: 0.8rem;
}

.removals-table thead {
    position: sticky;
    top: 0;
    z-index: 5;
}

.removals-table th {
    background: var(--surface-alt);
    padding: 8px 12px;
    text-align: left;
    font-weight: 500;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.removals-table td {
    padding: 6px 12px;
    border-bottom: 1px solid var(--surface-alt);
    color: var(--text);
    white-space: nowrap;
}

.removals-table tbody tr {
    cursor: pointer;
    border-left: 3px solid transparent;
}

.removals-table tbody tr:hover {
    background: var(--surface-alt);
}

.removals-table tbody tr.selected {
    background: var(--yellow-dim);
    border-left-color: var(--yellow);
}

.removals-table .file-link {
    color: var(--link);
    text-decoration: none;
    cursor: pointer;
}

.removals-table .file-link:hover {
    text-decoration: underline;
}

.removals-table .removed-file {
    color: var(--danger);
    font-weight: 500;
}

.removals-table .link-cell {
    white-space: nowrap;
}

.external-link {
    color: var(--link);
    text-decoration: underline;
    white-space: nowrap;
}

.external-link::after {
    content: " \2197";
    font-size: 0.85em;
}

.external-link:hover {
    color: var(--text-bright);
}

/* ---- Removals preview pane ---- */

.removals-preview {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

.removals-viewer-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    background: var(--surface-dark);
    border-bottom: 1px solid var(--border-dark);
    flex-shrink: 0;
}

.removals-viewer-toolbar span {
    font-family: "IBM Plex Mono", "SF Mono", "Cascadia Code", monospace;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-on-dark);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#removals-viewer-title {
    font-family: "IBM Plex Mono", "SF Mono", "Cascadia Code", monospace;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--yellow);
    text-decoration: underline;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#removals-viewer-title:hover {
    color: var(--yellow-hover);
}

.removals-viewer-toolbar button {
    background: none;
    border: 1px solid var(--border-dark);
    border-radius: 4px;
    padding: 0.2rem 0.5rem;
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--text-on-dark);
    flex-shrink: 0;
}

.removals-viewer-toolbar button:hover {
    background: rgba(255,255,255,0.08);
    color: var(--yellow);
}

#removals-pdf-viewer {
    flex: 1;
    border: none;
    width: 100%;
    min-height: 0;
    background: var(--surface-darker);
}

#removals-panel {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

/* ---- Single-page viewer mode (entities tab) ---- */

#diff-viewer.single-page .diff-side:last-child {
    display: none;
}
#diff-viewer.single-page .diff-side:first-child {
    flex: 1;
    border-right: none;
}

/* Entity sub-group (document within entity) */
.entity-doc-group {
    padding-left: 1rem;
    border-left: 2px solid var(--border);
    margin: 0.25rem 0 0.25rem 0.5rem;
}
.entity-doc-header {
    font-family: "IBM Plex Mono", "SF Mono", "Cascadia Code", monospace;
    font-size: 0.75rem;
    color: var(--text-muted);
    padding: 0.3rem 0.5rem;
    cursor: pointer;
}
.entity-doc-header:hover {
    color: var(--text);
}

/* Entity group top-level header */
.entity-group-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1rem;
    cursor: pointer;
    user-select: none;
}
.entity-group-header:hover {
    background: var(--surface-alt);
}
.entity-group-counts {
    font-family: "IBM Plex Mono", "SF Mono", "Cascadia Code", monospace;
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-left: auto;
}

/* Entity page items */
.entity-page-item {
    padding: 0.3rem 0.5rem;
    cursor: pointer;
    border-left: 3px solid transparent;
    font-family: "IBM Plex Mono", "SF Mono", "Cascadia Code", monospace;
    font-size: 0.75rem;
    color: var(--text-muted);
}
.entity-page-item:hover {
    background: var(--surface-alt);
    color: var(--text);
}
.entity-page-item.active {
    background: var(--yellow-dim);
    border-left-color: var(--yellow);
    color: var(--text);
}
.entity-variant-chips {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 0.2rem;
    margin-left: 0.5rem;
}
.entity-variant-chip {
    font-size: 0.6rem;
    padding: 0.05rem 0.3rem;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 2px;
    color: var(--text-muted);
}

/* ---- Merge panel ---- */

#merge-panel {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.merge-columns {
    display: flex;
    flex: 1;
    min-height: 0;
    border-top: 1px solid var(--border);
}

.merge-col {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.merge-col-source {
    width: 280px;
    flex-shrink: 0;
    border-right: 1px solid var(--border);
}

.merge-col-detail {
    flex: 1;
    border-right: 1px solid var(--border);
}

.merge-col-target {
    width: 300px;
    flex-shrink: 0;
}

.merge-col-header {
    font-family: "IBM Plex Mono", "SF Mono", "Cascadia Code", monospace;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 8px 12px;
    background: var(--surface-alt);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.merge-source-controls {
    display: flex;
    gap: 4px;
    padding: 8px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.merge-source-controls select,
.merge-source-controls input {
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-family: "IBM Plex Mono", "SF Mono", "Cascadia Code", monospace;
    font-size: 0.75rem;
    background: var(--surface);
    color: var(--text);
}

.merge-source-controls select {
    flex-shrink: 0;
}

.merge-source-controls input {
    flex: 1;
    min-width: 0;
}

.merge-source-controls input:focus,
.merge-source-controls select:focus {
    outline: none;
    border-color: var(--yellow-border);
    box-shadow: 0 0 0 2px var(--yellow-dim);
}

.merge-source-list {
    flex: 1;
    overflow-y: auto;
}

.merge-source-item {
    padding: 6px 12px;
    cursor: pointer;
    border-left: 3px solid transparent;
    font-family: "IBM Plex Mono", "SF Mono", "Cascadia Code", monospace;
    font-size: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 4px;
}

.merge-source-item:hover {
    background: var(--surface-alt);
}

.merge-source-item.active {
    background: var(--yellow-dim);
    border-left-color: var(--yellow);
}

.merge-source-item-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}

.merge-source-item-count {
    font-size: 0.65rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.merge-source-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.4rem;
    padding: 4px 8px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    font-family: "IBM Plex Mono", "SF Mono", "Cascadia Code", monospace;
    font-size: 0.7rem;
}

.merge-source-pagination button {
    padding: 2px 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.7rem;
}

.merge-source-pagination button:disabled {
    opacity: 0.4;
    cursor: default;
}

/* Detail (center) column */
.merge-detail-list {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.merge-detail-row {
    padding: 6px 12px;
    border-bottom: 1px solid var(--surface-alt);
    display: flex;
    gap: 8px;
    align-items: flex-start;
    font-size: 0.8rem;
}

.merge-detail-row:hover {
    background: var(--surface-alt);
}

.merge-detail-row input[type="checkbox"] {
    margin-top: 3px;
    flex-shrink: 0;
    accent-color: var(--primary);
}

.merge-detail-row-content {
    flex: 1;
    min-width: 0;
}

.merge-detail-meta {
    font-family: "IBM Plex Mono", "SF Mono", "Cascadia Code", monospace;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.merge-detail-snippet {
    font-size: 0.8rem;
    line-height: 1.4;
    color: var(--text);
    word-break: break-word;
}

.merge-detail-snippet mark {
    background: var(--mark-bg);
    padding: 0 2px;
    border-radius: 1px;
}

.merge-detail-link {
    color: var(--link);
    text-decoration: none;
}

.merge-detail-link:hover {
    text-decoration: underline;
}

.merge-detail-variant {
    display: inline-block;
    font-size: 0.6rem;
    padding: 0.05rem 0.3rem;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 2px;
    color: var(--text-muted);
    margin-left: 4px;
}

.merge-detail-footer {
    border-top: 1px solid var(--border);
    padding: 8px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    background: var(--surface);
}

.merge-detail-pagination {
    font-family: "IBM Plex Mono", "SF Mono", "Cascadia Code", monospace;
    font-size: 0.7rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.merge-detail-pagination button {
    padding: 2px 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.7rem;
}

.merge-detail-pagination button:disabled {
    opacity: 0.4;
    cursor: default;
}

.merge-detail-actions {
    display: flex;
    gap: 8px;
}

.merge-btn {
    padding: 0.35rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    font-family: "IBM Plex Sans", system-ui, sans-serif;
    font-size: 0.8rem;
    font-weight: 500;
    background: var(--surface);
    color: var(--text);
}

.merge-btn:hover:not(:disabled) {
    background: var(--surface-alt);
    border-color: var(--text-muted);
}

.merge-btn:disabled {
    opacity: 0.4;
    cursor: default;
}

.merge-btn-primary {
    background: var(--text-bright);
    color: #fff;
    border-color: var(--text-bright);
}

.merge-btn-primary:hover:not(:disabled) {
    background: #2d3142;
    border-color: #2d3142;
}
.merge-btn-danger {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}
.merge-btn-danger:hover:not(:disabled) {
    background: #dc2626;
    border-color: #dc2626;
}

.merge-source-delete {
    font-size: 0.7rem;
    line-height: 1;
    padding: 0.1rem 0.3rem;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.15s;
}
.merge-source-item:hover .merge-source-delete {
    opacity: 1;
}
.merge-source-delete:hover {
    border-color: var(--danger);
    color: var(--danger);
}

/* Target (right) column */
.merge-target-controls {
    padding: 8px;
    border-bottom: 1px solid var(--border);
    position: relative;
    flex-shrink: 0;
}

.merge-target-controls input {
    width: 100%;
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-family: "IBM Plex Mono", "SF Mono", "Cascadia Code", monospace;
    font-size: 0.75rem;
    background: var(--surface);
    color: var(--text);
}

.merge-target-controls input:focus {
    outline: none;
    border-color: var(--yellow-border);
    box-shadow: 0 0 0 2px var(--yellow-dim);
}

.merge-target-suggestions {
    position: absolute;
    top: 100%;
    left: 8px;
    right: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.merge-target-suggestion {
    padding: 6px 10px;
    cursor: pointer;
    font-family: "IBM Plex Mono", "SF Mono", "Cascadia Code", monospace;
    font-size: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.merge-target-suggestion:hover {
    background: var(--surface-alt);
}

.merge-target-suggestion-count {
    font-size: 0.65rem;
    color: var(--text-muted);
}

.merge-target-selected {
    padding: 8px 12px;
    background: var(--yellow-dim);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.merge-target-label {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.merge-target-name {
    font-family: "IBM Plex Mono", "SF Mono", "Cascadia Code", monospace;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-bright);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.merge-target-clear {
    background: none;
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 0 6px;
    cursor: pointer;
    font-size: 0.75rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.merge-target-clear:hover {
    color: var(--danger);
    border-color: var(--danger);
}

.merge-log-header {
    margin-top: auto;
}

.merge-log-list {
    flex: 1;
    overflow-y: auto;
    min-height: 100px;
}

.merge-log-item {
    padding: 4px 12px;
    font-family: "IBM Plex Mono", "SF Mono", "Cascadia Code", monospace;
    font-size: 0.65rem;
    color: var(--text-muted);
    border-bottom: 1px solid var(--surface-alt);
    line-height: 1.5;
}

.merge-log-arrow {
    color: var(--primary);
    font-weight: 500;
}

.merge-log-count {
    opacity: 0.6;
}

/* Merge confirm modal */
.merge-modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.merge-modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 24px;
    max-width: 480px;
    width: 90%;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}

.merge-modal-title {
    font-family: "IBM Plex Sans", system-ui, sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 12px;
}

.merge-modal-body {
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text);
    margin-bottom: 20px;
}

.merge-modal-body strong {
    font-family: "IBM Plex Mono", "SF Mono", "Cascadia Code", monospace;
    font-size: 0.85rem;
}

.merge-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ---- Entities panel (3-column) ---- */

#entities-panel {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.entities-columns {
    display: flex;
    flex: 1;
    min-height: 0;
    border-top: 1px solid var(--border);
}

.entities-col {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.entities-col-list {
    width: 320px;
    flex-shrink: 0;
    border-right: 1px solid var(--border);
}

.entities-col-detail {
    flex: 1;
    border-right: none;
}

.ent-splitter {
    width: 5px;
    cursor: col-resize;
    background: var(--border);
    flex-shrink: 0;
    transition: background 0.15s;
}

.ent-splitter:hover,
.ent-splitter.dragging {
    background: var(--primary);
}

.entities-col-preview {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

#ent-pdf-viewer {
    flex: 1;
    border: none;
    width: 100%;
    background: var(--surface-darker);
}

/* Clickable detail rows in entities tab */
.result-item.ent-clickable {
    cursor: pointer;
}

.result-item.ent-clickable:hover {
    border-color: var(--text-muted);
}

.result-item.ent-clickable.active {
    border-color: #e5a136;
    background: rgba(229, 161, 54, 0.08);
}

#ent-new-tab:hover {
    color: var(--yellow);
    text-decoration: underline;
}

/* ---- Global search view ---- */

#search-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

#global-filter-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 24px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

#global-filter-bar select {
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-family: "IBM Plex Mono", "SF Mono", "Cascadia Code", monospace;
    font-size: 0.75rem;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
}

#global-filter-bar select:focus {
    outline: none;
    border-color: var(--yellow-border);
    box-shadow: 0 0 0 2px var(--yellow-dim);
}

.global-search-bar {
    padding: 8px 24px 16px;
    flex-shrink: 0;
}

#global-main {
    flex: 1;
    display: grid;
    min-height: 0;
    border-top: 1px solid var(--border);
    grid-template-rows: 1fr auto;
    overflow: hidden;
}

#global-main.no-viewer {
    grid-template-columns: 1fr;
}

#global-main.has-viewer {
    grid-template-columns: 1fr 1fr;
}

#global-main.no-viewer #global-viewer-panel {
    display: none;
}

#global-main.has-viewer #global-viewer-panel {
    display: flex;
}

#global-results-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

#global-results-header {
    padding: 0.5rem 1rem;
    font-family: "IBM Plex Mono", "SF Mono", "Cascadia Code", monospace;
    font-size: 0.8rem;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

#global-results-list {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

#global-viewer-panel {
    flex-direction: column;
    border-left: 1px solid var(--border);
    min-height: 0;
    overflow: hidden;
}

#global-pdf-viewer {
    flex: 1;
    border: none;
    width: 100%;
    background: var(--surface-darker);
}

#global-pagination {
    grid-column: 1 / -1;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-top: 1px solid var(--border);
    background: var(--surface);
}

#global-pagination button {
    padding: 0.3rem 0.7rem;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 4px;
    cursor: pointer;
    font-family: "IBM Plex Mono", "SF Mono", "Cascadia Code", monospace;
    font-size: 0.8rem;
}

#global-pagination button:hover:not(:disabled) {
    background: var(--surface-alt);
}

#global-pagination button:disabled {
    opacity: 0.4;
    cursor: default;
}

#global-pagination .page-info {
    font-family: "IBM Plex Mono", "SF Mono", "Cascadia Code", monospace;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ---- Empty state ---- */

.empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ---- Landing page ---- */

#landing-page {
    flex: 1;
    overflow-y: auto;
}

.landing-hero {
    text-align: center;
    padding: 80px 48px 64px;
    max-width: 800px;
    margin: 0 auto;
}

.landing-hero h1 {
    font-family: "IBM Plex Sans", system-ui, sans-serif;
    font-size: 2.8rem;
    font-weight: 600;
    line-height: 1.15;
    color: var(--text-bright);
    margin-bottom: 24px;
    letter-spacing: -0.02em;
}

.landing-hero .highlight {
    background: linear-gradient(to top, var(--yellow) 35%, transparent 35%);
    padding: 0 4px;
}

.landing-subhead {
    font-size: 1.15rem;
    line-height: 1.6;
    color: var(--text-muted);
    max-width: 600px;
    margin: 0 auto 32px;
}

.landing-cta-row {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.landing-btn {
    display: inline-block;
    padding: 12px 28px;
    border-radius: 6px;
    font-family: "IBM Plex Sans", system-ui, sans-serif;
    font-size: 0.95rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.landing-btn-primary {
    background: var(--text-bright);
    color: #fff;
    border: 1px solid var(--text-bright);
}

.landing-btn-primary:hover {
    background: #2d3142;
    border-color: #2d3142;
}

.landing-btn-secondary {
    background: transparent;
    color: var(--text-bright);
    border: 1px solid var(--border);
}

.landing-btn-secondary:hover {
    border-color: var(--text-bright);
    background: var(--surface-alt);
}

.landing-stats {
    display: flex;
    justify-content: center;
    gap: 32px;
    flex-wrap: wrap;
    margin-top: 40px;
    font-family: "IBM Plex Mono", "SF Mono", "Cascadia Code", monospace;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.landing-stat-value {
    display: block;
    font-size: 1.8rem;
    font-weight: 500;
    color: var(--text-bright);
    letter-spacing: -0.02em;
}

/* ---- Feature sections ---- */

.landing-feature {
    padding: 80px 48px;
}

.landing-feature-dark {
    background: var(--surface-dark);
    color: var(--text-on-dark);
}

.landing-feature-light {
    background: var(--bg);
    color: var(--text);
}

.landing-feature-inner {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 48px;
    align-items: center;
    max-width: 1100px;
    margin: 0 auto;
}

.landing-feature-reversed .landing-feature-inner {
    direction: rtl;
}

.landing-feature-reversed .landing-feature-inner > * {
    direction: ltr;
}

.landing-feature-text h2 {
    font-family: "IBM Plex Sans", system-ui, sans-serif;
    font-size: 1.8rem;
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: 16px;
    letter-spacing: -0.01em;
}

.landing-feature-dark .landing-feature-text h2 {
    color: #fff;
}

.landing-feature-text p {
    font-size: 1rem;
    line-height: 1.65;
    margin-bottom: 16px;
    opacity: 0.85;
}

.landing-chip {
    display: inline-block;
    font-family: "IBM Plex Mono", "SF Mono", "Cascadia Code", monospace;
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 4px 10px;
    border-radius: 3px;
    margin-bottom: 16px;
    background: var(--yellow-dim);
    color: var(--yellow-border);
}

.landing-feature-dark .landing-chip {
    background: rgba(245, 225, 77, 0.12);
    color: var(--yellow);
}

.landing-arrow-link {
    font-family: "IBM Plex Mono", "SF Mono", "Cascadia Code", monospace;
    font-size: 0.85rem;
    font-weight: 500;
    text-decoration: none;
}

.landing-feature-dark .landing-arrow-link {
    color: var(--yellow);
}

.landing-feature-dark .landing-arrow-link:hover {
    color: var(--yellow-hover);
}

.landing-feature-light .landing-arrow-link {
    color: var(--text-bright);
}

.landing-feature-light .landing-arrow-link:hover {
    text-decoration: underline;
}

.landing-feature-img img {
    width: 100%;
    border-radius: 8px;
    border: 1px solid var(--border-dark);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
}

.landing-feature-dark .landing-feature-img img {
    box-shadow: 0 4px 32px rgba(0, 0, 0, 0.4);
}

/* Centered feature (no screenshot) */
.landing-feature-centered {
    text-align: center;
}

.landing-feature-inner-centered {
    max-width: 650px;
    margin: 0 auto;
}

.landing-feature-inner-centered h2 {
    font-family: "IBM Plex Sans", system-ui, sans-serif;
    font-size: 1.8rem;
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: 16px;
    letter-spacing: -0.01em;
}

.landing-feature-inner-centered p {
    font-size: 1rem;
    line-height: 1.65;
    opacity: 0.85;
}

/* Bottom CTA */
.landing-bottom-cta {
    text-align: center;
    padding: 80px 48px;
    background: var(--surface-dark);
}

.landing-bottom-cta h2 {
    font-family: "IBM Plex Sans", system-ui, sans-serif;
    font-size: 2rem;
    font-weight: 600;
    color: #fff;
    margin-bottom: 28px;
    letter-spacing: -0.01em;
}

.landing-bottom-cta .landing-btn-secondary {
    color: var(--text-on-dark);
    border-color: var(--border-dark);
}

.landing-bottom-cta .landing-btn-secondary:hover {
    border-color: var(--text-on-dark);
    background: rgba(255, 255, 255, 0.05);
}

/* ---- About page ---- */

#about-page {
    flex: 1;
    overflow-y: auto;
}

.about-content {
    max-width: 700px;
    margin: 0 auto;
    padding: 48px 48px 80px;
}

.about-content h1 {
    font-family: "IBM Plex Sans", system-ui, sans-serif;
    font-size: 2rem;
    font-weight: 600;
    color: var(--text-bright);
    margin-bottom: 24px;
    letter-spacing: -0.01em;
}

.about-content h2 {
    font-family: "IBM Plex Sans", system-ui, sans-serif;
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-bright);
    margin-top: 36px;
    margin-bottom: 12px;
}

.about-content p {
    font-size: 1rem;
    line-height: 1.7;
    color: var(--text);
    margin-bottom: 16px;
}

.about-content ul {
    margin: 0 0 16px 20px;
    list-style: disc;
}

.about-content li {
    font-size: 1rem;
    line-height: 1.7;
    color: var(--text);
    margin-bottom: 8px;
}

.about-content li strong {
    color: var(--text-bright);
}

/* ---- Landing responsive ---- */

@media (max-width: 768px) {
    .landing-hero {
        padding: 48px 24px 40px;
    }

    .landing-hero h1 {
        font-size: 1.8rem;
    }

    .landing-subhead {
        font-size: 1rem;
    }

    .landing-feature {
        padding: 48px 24px;
    }

    .landing-feature-inner {
        grid-template-columns: 1fr;
        gap: 32px;
    }

    .landing-feature-reversed .landing-feature-inner {
        direction: ltr;
    }

    .landing-feature-text h2,
    .landing-feature-inner-centered h2 {
        font-size: 1.4rem;
    }

    .landing-bottom-cta {
        padding: 48px 24px;
    }

    .landing-bottom-cta h2 {
        font-size: 1.5rem;
    }

    .landing-stats {
        gap: 16px;
    }

    .landing-stat-value {
        font-size: 1.4rem;
    }

    .about-content {
        padding: 32px 24px 64px;
    }
}

/* ---- Exclude dropdown & chips ---- */
.exclude-trigger {
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.75rem;
    background: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 2px 8px;
    cursor: pointer;
    color: var(--text-muted);
    white-space: nowrap;
}

.exclude-trigger:hover {
    border-color: var(--text);
    color: var(--text);
}

.exclude-trigger.has-excludes {
    border-color: var(--danger);
    color: var(--danger);
}

.exclude-panel {
    position: absolute;
    z-index: 100;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    max-width: 500px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.ct-chip {
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.65rem;
    padding: 2px 6px;
    border: 1px solid var(--border);
    border-radius: 3px;
    cursor: pointer;
    background: var(--surface);
    color: var(--text);
    user-select: none;
    transition: all 0.15s;
    white-space: nowrap;
}

.ct-chip:hover {
    border-color: var(--text-muted);
}

.ct-chip.excluded {
    background: var(--surface-alt);
    color: var(--text-muted);
    text-decoration: line-through;
    border-color: var(--danger);
    opacity: 0.7;
}

/* ---- Entity detail toolbar ---- */
.ent-detail-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
