:root {
    color-scheme: light;
    --sidebar-width: 320px;
    --accent: #d94f6f;
    --accent-light: #e87a90;
    --accent-bg: rgba(217, 79, 111, 0.12);
    --accent-hover: rgba(217, 79, 111, 0.22);
    --green: var(--accent);
    --green-light: var(--accent-light);
    --green-bg: var(--accent-bg);
    --green-hover: var(--accent-hover);
    --grey-50: #171717;
    --grey-100: #262626;
    --grey-200: #404040;
    --grey-300: #525252;
    --grey-400: #737373;
    --grey-500: #a3a3a3;
    --grey-600: #d4d4d4;
    --grey-700: #e5e5e5;
    --grey-800: #f5f5f5;
    --grey-900: #fafafa;
    --highlight-color: rgba(255, 208, 20, 0.3);
    --highlight-current: rgba(255, 208, 20, 0.5);
    --viewer-bg: var(--grey-600);
    --toolbar-bg: var(--grey-700);
    --page-bg: var(--grey-600);
    --toolbar-text: #333;
    --pulse-color: #333;
    --overlay: rgba(0,0,0,0.06);
    --overlay-hover: rgba(0,0,0,0.1);
    --overlay-active: rgba(0,0,0,0.12);
    --overlay-border: rgba(0,0,0,0.15);
    --text-overlay: #333;
    --text-overlay-hover: #222;
    --text-muted: #666;
}

[data-theme="dark"] {
    color-scheme: dark;
    --accent: #f28a9e;
    --accent-light: #f6a7b5;
    --accent-bg: rgba(242, 138, 158, 0.12);
    --accent-hover: rgba(242, 138, 158, 0.22);
    --green: var(--accent);
    --green-light: var(--accent-light);
    --green-bg: var(--accent-bg);
    --green-hover: var(--accent-hover);
    --grey-50: #fafafa;
    --grey-100: #f5f5f5;
    --grey-200: #e5e5e5;
    --grey-300: #d4d4d4;
    --grey-400: #a3a3a3;
    --grey-500: #737373;
    --grey-600: #525252;
    --grey-700: #404040;
    --grey-800: #262626;
    --grey-900: #171717;
    --highlight-color: rgba(255, 208, 20, 0.4);
    --highlight-current: rgba(255, 208, 20, 0.6);
    --viewer-bg: var(--grey-800);
    --toolbar-bg: var(--grey-900);
    --page-bg: var(--grey-800);
    --toolbar-text: white;
    --pulse-color: #fff;
    --pulse-opacity: 1;
    --overlay: rgba(255,255,255,0.08);
    --overlay-hover: rgba(255,255,255,0.15);
    --overlay-active: rgba(255,255,255,0.12);
    --overlay-border: rgba(255,255,255,0.15);
    --text-overlay: var(--grey-300);
    --text-overlay-hover: white;
    --text-muted: var(--grey-400);
}

@font-face {
    font-family: 'InterVariable';
    src: url('fonts/InterVariable.woff2') format('woff2');
    font-weight: 100 1000;
    font-style: normal;
    font-display: swap;
}

/* ── Theme transition ── */

html.transitioning,
html.transitioning *,
html.transitioning *::before,
html.transitioning *::after {
    transition: background-color 0.8s ease, color 0.8s ease, border-color 0.8s ease, box-shadow 0.8s ease !important;
}

/* ── Reset & Base ── */

* { box-sizing: border-box; touch-action: manipulation; }

body {
    font-family: 'InterVariable', 'Segoe UI', system-ui, sans-serif;
    margin: 0;
    display: flex;
    height: 100vh;
    background: var(--grey-600);
    overflow: hidden;
    color: var(--grey-800);
}

input, select, button, textarea {
    font-family: inherit;
}

/* ── Layout ── */

#sidebar {
    width: var(--sidebar-width);
    min-width: 200px;
    max-width: 800px;
    background: var(--grey-800);
    border-right: 1px solid var(--grey-700);
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 10px rgba(0,0,0,0.2);
    flex-shrink: 0;
    position: relative;
    color: var(--grey-300);
    transition: background 0.15s;
}
#sidebar.drag-over {
    background: var(--grey-700);
}

#resizer {
    width: 6px; cursor: col-resize; background: var(--grey-700); transition: background 0.2s;
    z-index: 10; flex-shrink: 0; position: relative;
}
#resizer::after {
    content: ''; position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 2px; height: 24px;
    background: var(--grey-500);
    border-radius: 1px; opacity: 0.2;
    transition: opacity 0.2s;
    box-shadow: -5px 0 0 var(--grey-500), 5px 0 0 var(--grey-500);
    pointer-events: none;
}
#resizer:hover::after { opacity: 0.5; }
#resizer:hover, body.dragging #resizer { background: var(--grey-600); }

.viewer-container {
    flex: 1; background: var(--grey-800); position: relative; overflow: hidden; display: flex; flex-direction: column;
}

.viewer-scroll { flex: 1; overflow: auto; position: relative; }

/* ── Sidebar Header ── */

.header {
    padding: 6px 8px;
    background: var(--grey-900);
    border-bottom: 1px solid var(--grey-700);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.header-main-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-open {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex:1;
    padding: 5px 10px;
    background: var(--grey-700);
    color: var(--grey-300);
    border: 1px solid var(--grey-600);
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.18s;
}
.btn-open:hover { background: var(--grey-600); color: var(--grey-200); }
.btn-open input { display: none; }
.btn-open-icon { width: 16px; height: 16px; flex-shrink: 0; }

.list-select {
    flex: 1;
    min-width: 0;
    background: var(--overlay);
    border: 1px solid var(--overlay-border);
    color: var(--text-overlay);
    border-radius: 4px;
    padding: 5px 8px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    appearance: auto;
}
.list-select:hover { background: var(--overlay-active); border-color: var(--overlay-hover); }
.list-select:focus { outline: none; border-color: var(--accent); }
.list-select option { background: var(--grey-800); color: var(--grey-300); }

.stats-bar {
    padding: 5px 5px; background: var(--grey-900); border-bottom: 1px solid var(--grey-700);
    font-size: 0.75rem; display: flex; justify-content: space-between; color: var(--grey-400);
}

.status-bar { font-size: 0.65rem; font-weight: 350; color: var(--grey-400); margin-top: 1px; padding: 0 1px; min-height: 18px; font-family: 'InterVariable', sans-serif; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; display: flex; justify-content: space-between; }
#progressBar { width: 100%; height: 2px; background: var(--grey-700); overflow: hidden; flex-shrink: 0; }
#progressBarFill { height: 100%; background: var(--accent); width: 0%; transition: width 0.15s; }
.drop-zone-viewer {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 48px 40px; text-align: center; pointer-events: none;
    border: 2px dashed var(--grey-600); border-radius: 16px;
    min-width: 280px; min-height: 200px;
    transition: border-color 0.4s ease;
}
.drop-zone-viewer-icon {
    width: 56px; height: 56px; color: var(--grey-500); margin-bottom: 16px; opacity: 0.5;
}
.drop-zone-viewer-icon svg { width: 100%; height: 100%; }
.drop-zone-viewer-title {
    font-size: 1.1rem; font-weight: 600; color: var(--grey-400); margin: 0 0 6px 0;
}
.drop-zone-viewer-text {
    font-size: 0.85rem; color: var(--grey-500); margin: 0;
}

/* ── Sidebar Search ── */

.sidebar-search {
    width: 100%;
    flex-shrink: 0;
}
.sidebar-search-row {
    display: flex;
    align-items: center;
    gap: 0;
    width: 100%;
    background: var(--grey-700);
    border: 1px solid var(--grey-600);
    border-radius: 4px;
    transition: border-color 0.2s, background 0.2s;
}
.sidebar-search-row:focus-within {
    border-color: var(--accent);
    background: var(--grey-600);
}
.global-search-icon {
    color: var(--grey-500);
    font-size: 0.85rem;
    padding: 0 0 0 8px;
    user-select: none;
    pointer-events: none;
}
.global-search-input {
    flex: 1;
    background: none;
    border: none;
    color: var(--grey-200);
    padding: 5px 8px;
    font-size: 0.85rem;
    outline: none;
    box-sizing: border-box;
    min-width: 0;
}
.global-search-input::placeholder {
    color: var(--grey-400);
    opacity: 0.8;
}
.global-search-input:placeholder-shown {
    text-align: left;
    padding-left: 4px;
}
.global-search-input:not(:placeholder-shown) {
    text-align: left;
}
.gs-nav-btn {
    background: none;
    border: none;
    color: var(--grey-300);
    padding: 5px 7px;
    font-size: 0.85rem;
    line-height: 1;
    flex-shrink: 0;
    cursor: pointer;
    border-radius: 2px;
    transition: color 0.2s, background 0.2s;
}
.gs-nav-btn:first-of-type {
    border-left: 1px solid var(--grey-600);
}
.gs-nav-btn:hover {
    color: var(--text-overlay-hover);
    background: var(--overlay);
}

.gs-clear-btn {
    display: none;
    border: none;
    color: var(--grey-400);
    padding: 5px 7px;
    font-size: 0.8rem;
    line-height: 1;
    flex-shrink: 0;
    cursor: pointer;
    border-radius: 2px;
    background: none;
    transition: color 0.2s, background 0.2s;
}
.global-search-input:not(:placeholder-shown) ~ .gs-clear-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.gs-clear-btn:hover {
    color: var(--accent);
    background: var(--accent-bg);
}

/* ── File Tree ── */

.results-area { flex: 1; overflow-y: auto; padding: 4px 8px; }

.sidebar ul {
    list-style-type: none;
    padding-left: 10px;
    margin: 0;
}

#file-tree { padding-left: 0; }

.file-tree li { margin: 0; padding: 0; user-select: none; }

.tree-nested { display: none; }
.tree-nested.expanded { display: block; }

.folder {
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 2px 4px;
    cursor: pointer;
    border-radius: 3px;
    font-size: 0.87rem;
    font-weight: 450;
    color: var(--grey-300);
    transition: background 0.15s, font-weight 0.15s;
    white-space: nowrap;
}
.folder:hover { font-weight: 500; }
.folder::before {
    content: "+";
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 4px;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--grey-500);
    flex-shrink: 0;
    width: 16px;
    height: 16px;
}
.folder.open::before { content: "\2212"; }
.folder:hover { background: var(--grey-700); }

.file {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 2px 4px;
    cursor: pointer;
    border-radius: 3px;
    font-size: 0.87rem;
    font-weight: 450;
    color: var(--grey-300);
    transition: background 0.15s, font-weight 0.15s;
    white-space: nowrap;
    user-select: none;
    -webkit-user-select: none;
}
.file:hover { background: var(--accent-bg); font-weight: 500; }
.file.active {
    background: var(--accent-bg);
    border-left: 2px solid var(--accent);
    padding-left: 4px;
    font-weight: 500;
}
.file-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}
.file img, .file svg { width: 16px; height: 16px; flex-shrink: 0; }

.tree-count {
    font-size: 0.87rem;
    font-weight: 600;
    color: var(--grey-300);
    background: var(--grey-700);
    padding: 1px 5px;
    border-radius: 8px;
    min-width: 16px;
    text-align: center;
    flex-shrink: 0;
    user-select: none;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background .15s, border-color .15s;
}
.tree-count:hover {
    background: var(--grey-600);
    border-color: var(--grey-400);
}

.tree-search-count {
    font-size: 0.87rem;
    font-weight: 700;
    color: var(--accent);
    background: var(--accent-bg);
    padding: 1px 5px;
    border-radius: 8px;
    min-width: 16px;
    text-align: center;
    flex-shrink: 0;
    margin-left: 3px;
    border: 1px solid var(--accent-hover);
    cursor: pointer;
    user-select: none;
    transition: background .15s, border-color .15s;
}
.tree-search-count:hover {
    background: var(--accent-hover);
    border-color: var(--accent);
}

.sidebar ul.tree-nested {
    border-left: 1px solid var(--grey-600);
    padding-left: 14px;
}

/* ── Keyword Grid ── */

.keyword-grid-panel {
    border-top: 1px solid var(--grey-700);
    background: var(--grey-900);
    max-height: 40%;
    display: flex;
    flex-direction: column;
    min-height: 100px;
    flex-shrink: 0;
}

.kw-grid-header {
    padding: 6px 10px;
    font-size: 0.75rem;
    font-weight: 450;
    color: var(--grey-400);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    gap: 12px;
    background: var(--grey-800);
    border-bottom: 1px solid var(--grey-700);
}

.kw-grid-filename {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.7rem;
    color: var(--accent);
    font-weight: 500;
    flex: 1;
    min-width: 0;
}

.kw-ocr-btn {
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 3px;
    border: 1px solid var(--grey-600);
    background: transparent;
    color: var(--grey-400);
    cursor: pointer;
    flex-shrink: 0;
    line-height: 1.4;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}
.kw-ocr-btn:hover, .kw-ocr-btn.active {
    background: var(--accent-bg);
    color: var(--accent-light);
    border-color: var(--accent);
}

.kw-grid-content {
    flex: 1;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 6px;
    padding: 8px;
    align-content: start;
}

.kw-grid-empty {
    color: var(--grey-500);
    font-size: 0.75rem;
    text-align: center;
    padding: 20px;
    grid-column: 1 / -1;
    font-style: italic;
}

.kw-grid-cell {
    padding: 6px 8px;
    background: var(--grey-800);
    border: 1px solid var(--grey-700);
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 6px;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
    min-height: 32px;
}
.kw-grid-cell:hover {
    background: var(--grey-700);
    border-color: var(--accent-light);
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.35);
}
.kw-grid-cell.active {
    background: var(--accent-bg);
    border-color: var(--accent);
    box-shadow: inset 0 0 0 1px var(--accent);
}

.kw-cell-name {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--grey-300);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    text-align: left;
}

.kw-cell-count {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--accent);
    background: var(--accent-bg);
    padding: 2px 6px;
    border-radius: 4px;
    min-width: 20px;
    text-align: center;
    font-family: monospace;
    flex-shrink: 0;
}

[data-theme="light"] .kw-grid-cell.active .kw-cell-name { color: var(--grey-100); }
.kw-grid-cell.active .kw-cell-name { color: white; }
.kw-grid-cell.active .kw-cell-count { color: white; background: var(--accent); }

.ocr-toggle {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 3px;
    border: 1px solid var(--grey-600);
    background: transparent;
    color: var(--grey-400);
    cursor: pointer;
    margin-left: 6px;
    vertical-align: middle;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}
.ocr-toggle:hover, .ocr-toggle.active {
    background: var(--accent-bg);
    color: var(--accent-light);
    border-color: var(--accent);
}

.ocr-toggle-tree {
    font-size: 0.75rem;
    padding: 1px 4px;
    border-radius: 3px;
    border: 1px solid var(--grey-600);
    background: transparent;
    color: var(--grey-500);
    cursor: pointer;
    flex-shrink: 0;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}
.ocr-toggle-tree:hover, .ocr-toggle-tree.active {
    background: var(--accent-bg);
    color: var(--accent-light);
    border-color: var(--accent);
}

/* ── Viewer Toolbar ── */

.viewer-toolbar {
    display: flex;
    align-items: stretch;
    justify-content: center;
    gap: 12px;
    padding: 0 14px;
    height: 68px;
    background: var(--grey-900);
    color: var(--text-overlay);
    z-index: 10;
    flex-shrink: 0;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--grey-400) transparent;
    border-bottom: 1px solid var(--grey-700);
}

.viewer-toolbar::-webkit-scrollbar {
    height: 4px;
}
.viewer-toolbar::-webkit-scrollbar-track {
    background: transparent;
}
.viewer-toolbar::-webkit-scrollbar-thumb {
    background: var(--grey-400);
    border-radius: 4px;
}

.toolbar-section {
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 2px 6px;
    border: 1px solid var(--grey-700);
    border-radius: 4px;
}

.sidebar .toolbar-section {
    border-color: var(--overlay-border);
}

.viewer-toolbar .toolbar-section {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 3px 10px;
    border-radius: 8px;
    height: 100%;
    overflow: hidden;
}

.viewer-toolbar .toolbar-row {
    display: flex;
    align-items: center;
    gap: 5px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.viewer-toolbar .toolbar-row > * {
    min-width: 0;
    flex-shrink: 1;
}


.viewer-toolbar .separator {
    color: var(--grey-500);
    margin: 0 2px;
    font-size: 0.8rem;
    opacity: 0.4;
    user-select: none;
}

.viewer-toolbar button {
    background: var(--overlay);
    border: none;
    color: var(--text-overlay);
    padding: 5px 9px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 475;
    line-height: 1.35;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s, transform 0.1s;
    flex-shrink: 0;
}
.viewer-toolbar button:hover {
    background: var(--overlay-hover);
    color: var(--text-overlay-hover);
}
.viewer-toolbar button:active {
    background: var(--overlay-active);
    transform: scale(0.96);
}
.viewer-toolbar button:disabled {
    opacity: 0.3;
    cursor: default;
    pointer-events: none;
    transform: none;
}

#prevPageBtn, #nextPageBtn {
    padding-left: 16px;
    padding-right: 16px;
}

#zoomFitBtn, #zoomActualBtn {
    padding-left: 12px;
    padding-right: 12px;
}

#measureDistBtn, #measurePerimBtn, #measureAreaBtn {
    min-width: 34px;
    padding: 5px 12px;
}

#clearMeasureBtn {
    padding: 5px 6px;
}

.viewer-toolbar .zoom-level {
    font-size: 0.88rem;
    min-width: 44px;
    text-align: center;
    color: var(--grey-400);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.viewer-toolbar .dim {
    font-size: 0.8rem;
    color: var(--text-overlay);
    font-weight: 400;
}

.viewer-toolbar .toolbar-page:has(.page-input:disabled) .dim,
.viewer-toolbar .toolbar-keyword:has(.match-input:disabled) .dim {
    opacity: 0.35;
}

.viewer-toolbar .match-counter {
    font-size: 0.78rem;
    color: var(--accent);
    font-weight: 600;
    font-family: monospace;
    min-width: 56px;
    text-align: center;
}

.toolbar-measure .scale-input {
    width: 64px;
    background: var(--overlay);
    border: 1px solid var(--overlay-border);
    color: var(--text-overlay);
    text-align: center;
    padding: 3px 4px;
    border-radius: 5px;
    font-size: 0.82rem;
    font-family: monospace;
    transition: border-color 0.15s, background 0.15s;
}
.toolbar-measure .scale-input:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--overlay-active);
}
.toolbar-measure .scale-input:disabled { opacity: 0.35; cursor: default; }

.toolbar-measure button.active-tool {
    background: var(--accent);
    color: white;
    box-shadow: 0 0 0 1px var(--accent);
}
.toolbar-measure button.active-tool:hover {
    background: var(--accent-light);
    box-shadow: 0 0 0 1px var(--accent-light);
}

.page-input, .match-input {
    background: var(--overlay);
    border: 1px solid var(--overlay-border);
    color: var(--text-overlay);
    text-align: center;
    padding: 4px 6px;
    border-radius: 5px;
    font-size: 0.9rem;
    font-family: monospace;
    transition: border-color 0.15s, background 0.15s;
}
.page-input { width: 52px; }
.match-input { width: 70px; }
.page-input:focus, .match-input:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--overlay-active);
}
.page-input:disabled, .match-input:disabled {
    opacity: 0.35;
    cursor: default;
}

.keyword-select {
    background: var(--overlay);
    border: 1px solid var(--overlay-border);
    color: var(--text-overlay);
    padding: 5px 8px;
    border-radius: 5px;
    font-size: 0.85rem;
    cursor: pointer;
    max-width: 120px;
    transition: border-color 0.15s, background 0.15s;
}
.keyword-select option {
    background: var(--grey-800);
    color: var(--grey-200);
}
.keyword-select:focus {
    outline: none;
    border-color: var(--accent);
}

.kw-manage-btn {
    background: none;
    border: none;
    color: var(--grey-400);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 5px 6px;
    border-radius: 4px;
    line-height: 1;
    transition: color 0.2s, background 0.2s;
    flex-shrink: 0;
}
.kw-manage-btn:hover {
    color: var(--accent-light);
    background: var(--accent-bg);
}

.search-input-wrapper {
    display: flex;
    align-items: center;
    position: relative;
    gap: 2px;
    background: var(--overlay);
    border: 1px solid var(--overlay-border);
    border-radius: 5px;
    padding: 1px 3px 1px 8px;
    max-height: 26px;
    box-sizing: border-box;
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.search-input-wrapper:focus-within {
    border-color: var(--accent);
    background: var(--overlay-active);
    box-shadow: 0 0 0 1px var(--accent);
}

.search-icon {
    color: var(--grey-500);
    font-size: 0.85rem;
    user-select: none;
    pointer-events: none;
}

.inline-search-input {
    background: transparent;
    border: none;
    color: var(--text-overlay);
    padding: 3px 4px;
    font-size: 0.85rem;
    outline: none;
    min-width: 60px;
    width: 90px;
}

.inline-search-input::placeholder {
    color: var(--grey-500);
    opacity: 0.8;
}

.inline-search-input:disabled {
    opacity: 0.35;
    cursor: default;
}

.inline-search-clear {
    background: none;
    border: none;
    color: var(--grey-500);
    padding: 2px 6px;
    margin: 1px;
    font-size: 0.75rem;
    cursor: pointer;
    border-radius: 3px;
    transition: color 0.15s, background 0.15s, opacity 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
}

.inline-search-clear.visible {
    opacity: 1;
    pointer-events: auto;
}

.inline-search-clear:hover {
    color: var(--accent);
    background: var(--accent-bg);
}

.inline-search-clear:disabled {
    opacity: 0.35;
    cursor: default;
    pointer-events: none;
}

.viewer-toolbar .toolbar-keyword {
    overflow: visible;
}
.viewer-toolbar .toolbar-keyword > .toolbar-row {
    overflow: visible;
}

/* ── PDF Viewer ── */

#pdfViewer { margin: 0 auto; position: relative; }

.pdf-page {
    position: relative; margin: 16px auto; box-shadow: 0 4px 12px rgba(0,0,0,0.3); background: white;
    width: calc(var(--base-w, 600) * var(--pdf-scale, 1.0) * 1px);
    height: calc(var(--base-h, 800) * var(--pdf-scale, 1.0) * 1px);
    transition: box-shadow 0.2s;
}
.pdf-page canvas { display: block; transition: opacity 0.15s ease-in; }

.docx-wrapper {
    margin: 0 auto; max-width: 100%;
    width: calc(var(--docx-scale, 1.0) * 800px);
}
.docx-page {
    margin: 16px auto; padding: 20px; box-sizing: border-box;
    background: white; color: black; box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    font-family: Times New Roman, serif; font-size: 12pt; line-height: 1.6;
}

.textLayer {
    position: absolute; top: 0; left: 0;
    width: 100%; height: 100%;
    overflow: hidden; opacity: 1; line-height: 1.0; z-index: 2;
    pointer-events: none;
}
.textLayer > span {
    color: transparent; position: absolute; white-space: pre; cursor: text;
    transform-origin: 0% 0%; pointer-events: auto; user-select: text;
    -webkit-user-select: text;
    font-family: 'InterVariable', sans-serif;
}
.textLayer ::selection { background: rgba(0, 0, 255, 0.3); }

.highlight-mark {
    position: absolute; background: var(--highlight-color); border-radius: 2px;
    pointer-events: none; z-index: 1;
}
.highlight-mark.current {
    background: var(--highlight-current); outline: 2px solid rgba(255, 208, 20, 0.8); z-index: 2;
}

.doc-highlight {
    background: var(--highlight-color); border-radius: 2px; padding: 0 2px;
}
.doc-highlight.current {
    background: var(--highlight-current); outline: 2px solid rgba(255, 208, 20, 0.8);
}

.page-placeholder {
    position: relative; margin: 16px auto; background: var(--page-bg);
    display: flex; align-items: center; justify-content: center;
    width: calc(var(--base-w, 600) * var(--pdf-scale, 1.0) * 1px);
    height: calc(var(--base-h, 800) * var(--pdf-scale, 1.0) * 1px);
    overflow: hidden;
}
.page-placeholder::after {
    content: '';
    position: absolute; inset: 0;
    background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.04) 50%, transparent 100%);
    animation: placeholder-shimmer 1.8s ease-in-out infinite;
    pointer-events: none;
}

/* ── Search Overlay ── */

.search-overlay {
    display: none;
    position: absolute;
    top: 44px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    background: var(--grey-800);
    border: 1px solid var(--grey-600);
    border-radius: 8px;
    padding: 8px 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    gap: 8px;
    align-items: center;
}
.search-overlay.visible { display: flex; }

.search-overlay input {
    background: var(--grey-900);
    border: 1px solid var(--grey-600);
    color: var(--grey-200);
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 0.85rem;
    width: 200px;
    outline: none;
}
.search-overlay input:focus { border-color: var(--accent); }

.search-overlay-results {
    color: var(--grey-400);
    font-size: 0.8rem;
    min-width: 50px;
    text-align: center;
}

.search-overlay-btn {
    background: var(--overlay);
    border: none;
    color: var(--text-overlay);
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
}
.search-overlay-btn:hover { background: var(--overlay-hover); color: var(--text-overlay-hover); }

.search-overlay-close {
    background: transparent;
    color: var(--text-muted);
    padding: 6px 8px;
}
.search-overlay-close:hover {
    color: #e74c3c;
    background: rgba(231, 76, 60, 0.2);
}

.custom-highlight {
    position: absolute;
    background: var(--highlight-color);
    pointer-events: none;
    z-index: 5;
}
.custom-highlight.current {
    background: var(--highlight-current);
    box-shadow: 0 0 3px rgba(255, 208, 20, 0.8);
}

/* ── Measurement Tools ── */

.is-measuring .pdf-page { cursor: crosshair; }
.is-measuring .textLayer > span { cursor: crosshair; pointer-events: none; }

.measure-layer { position: absolute; top: 0; left: 0; width: 100%; height: 100%; overflow: hidden; pointer-events: none; z-index: 4; }
.measure-line { position: absolute; pointer-events: none; z-index: 5; }
.m-line { transform-origin: 0 50%; }
.measure-tick { position: absolute; pointer-events: none; z-index: 6; transform-origin: 50% 50%; }
.measure-tick-pending { position: absolute; pointer-events: none; z-index: 6; transform-origin: 50% 50%; background: var(--accent); }
.measure-label { position: absolute; font-size: 15px; background: rgba(255,255,255,0.3); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); padding: 1px 5px; border-radius: 3px; z-index: 7; white-space: nowrap; font-family: 'InterVariable', sans-serif; border: 1px solid; pointer-events: auto; }
.measure-fill { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 3; }
.measure-line-ghost { position: absolute; pointer-events: none; z-index: 5; border-top: 2px dashed rgba(0, 200, 255, 0.85); height: 0; background: none; transform-origin: 0 50%; }
.measure-label-ghost { position: absolute; font-size: 15px; background: rgba(255,255,255,0.3); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); padding: 1px 5px; border-radius: 3px; z-index: 7; white-space: nowrap; font-family: 'InterVariable', sans-serif; border: 1px solid rgba(0, 200, 255, 0.5); pointer-events: auto; color: #000; }
.measure-fill-ghost { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 3; background: rgba(0, 200, 255, 0.12); }
.measure-highlight {
    transition: all 0.15s ease;
    filter: saturate(1.5) brightness(1.1) drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2));
    outline: 2px dashed rgba(180, 20, 20, 0.9);
    outline-offset: 4px;
}

/* ── Loader ── */

#viewerLoader {
    position: absolute; inset: 0; background: var(--grey-800); display: none;
    justify-content: center; align-items: center; z-index: 10;
    color: white; font-size: 1rem; flex-direction: column; gap: 12px;
}

.spinner {
    width: 30px; height: 30px; border: 3px solid rgba(255,255,255,0.2);
    border-radius: 50%; border-top-color: var(--accent); animation: spin 1s ease-in-out infinite;
}

.page-loading {
    display: flex; align-items: center; justify-content: center;
    height: 200px; color: #888; font-size: 14px; gap: 8px;
}
.page-loading .spinner {
    width: 20px; height: 20px; border: 2px solid #ccc;
    border-radius: 50%; border-top-color: #666;
    animation: spin 0.8s linear infinite;
}

.loader-details { text-align: center; }
.loader-filename { font-size: 0.85rem; color: var(--grey-300); margin-bottom: 4px; max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.loader-status { font-size: 0.75rem; color: var(--grey-500); }
.loader-progress-bar { width: 200px; height: 2px; background: var(--grey-700); border-radius: 2px; overflow: hidden; margin-top: 8px; }
.loader-progress-fill { height: 100%; background: var(--accent); width: 0%; transition: width 0.15s; }

/* ── Dialogs ── */

#newListDialog {
    display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.7); z-index: 10003; align-items: center; justify-content: center;
}
#newListDialog.show { display: flex; }
#newListDialog .modal { background: var(--grey-800); padding: 24px; border-radius: 12px; width: 350px; box-shadow: 0 10px 25px rgba(0,0,0,0.5); }
#newListDialog input {
    width: 100%; padding: 10px; margin: 12px 0; border-radius: 6px;
    border: 1px solid var(--grey-600); background: var(--grey-900); color: var(--grey-300); box-sizing: border-box;
}

/* ── Settings Menu & Toggles ── */

.toggle-container {
    color: var(--grey-400);
    font-size: 0.85rem;
    display: flex;
    justify-content: space-between;
    margin-left: 8px;
    padding-left: 8px;
    border-left: 1px solid var(--overlay-border);
}

.settings-menu {
    display: none;
    position: fixed;
    background: var(--grey-800);
    border: 1px solid var(--grey-600);
    border-radius: 6px;
    padding: 8px;
    z-index: 100;
    flex-direction: column;
    gap: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.settings-menu.visible {
    display: flex;
}

.settings-menu-btn {
    padding: 6px 8px;
    font-size: 0.75rem;
    font-weight: 475;
    border: 1px solid var(--grey-600);
    border-radius: 4px;
    cursor: pointer;
    background: transparent;
    color: var(--grey-300);
}

.settings-menu-btn:hover { background: var(--accent-hover); }

.toggle-btn {
    display: flex; justify-content: space-between; align-items: center;
    min-width: 140px;
}
.toggle-btn.on .toggle-state { color: var(--accent-light); }

.toggle-state { font-size: 0.7rem; font-weight: bold; color: var(--grey-500); }
.toggle-label { font-size: 0.75rem; color: var(--grey-400); }

.settings-menu-section {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 4px;
    padding-top: 8px;
    border-top: 1px solid var(--grey-600);
}

.settings-menu-row {
    display: flex;
    gap: 4px;
}

.settings-menu-quality-btn {
    flex: 1;
    padding: 6px 8px;
    font-size: 0.75rem;
    border: 1px solid var(--grey-600);
    border-radius: 4px;
    cursor: pointer;
    background: transparent;
    color: var(--grey-300);
}
.settings-menu-quality-btn.active {
    background: var(--accent);
    color: white;
}

.settings-menu-link {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--grey-300);
    text-decoration: none;
    font-size: 0.8rem;
}
.settings-menu-link:hover { color: var(--accent-light); }

.settings-menu-link-icon {
    width: 16px;
    height: 16px;
    filter: brightness(0) invert(0.7);
}
.settings-menu-link:hover .settings-menu-link-icon {
    filter: brightness(0) invert(0.85) saturate(1.5) hue-rotate(80deg);
}

/* ── Keyword Menu ── */

.keyword-menu {
    display: none;
    position: fixed;
    background: var(--grey-800);
    border: 1px solid var(--grey-600);
    border-radius: 6px;
    padding: 10px;
    z-index: 100;
    flex-direction: column;
    gap: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    width: 340px;
    max-height: 480px;
}
.keyword-menu.visible {
    display: flex;
}

.keyword-menu-section {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 4px;
    padding-top: 8px;
    border-top: 1px solid var(--grey-600);
}

.keyword-menu-row {
    display: flex;
    gap: 4px;
}
.keyword-menu-row select {
    flex: 1;
    background: var(--overlay);
    border: 1px solid var(--overlay-border);
    color: var(--text-overlay);
    border-radius: 4px;
    padding: 5px 6px;
    font-size: 0.75rem;
    cursor: pointer;
    min-width: 0;
}
.keyword-menu-row select:focus {
    outline: none;
    border-color: var(--accent);
}
.keyword-menu-row select option {
    background: var(--grey-800);
    color: var(--grey-300);
}
.keyword-menu-row button {
    padding: 5px 8px;
    font-size: 0.7rem;
    font-weight: 500;
    border: 1px solid var(--grey-600);
    border-radius: 4px;
    cursor: pointer;
    background: transparent;
    color: var(--grey-300);
    white-space: nowrap;
    flex-shrink: 0;
}
.keyword-menu-row button:hover {
    background: var(--accent-hover);
}
.keyword-menu-row button#kwDeleteListBtn:hover {
    background: var(--accent-bg);
    color: var(--accent);
}

.keyword-menu-info {
    font-size: 0.7rem;
    color: var(--grey-400);
    padding: 0 2px;
}

.keyword-menu textarea {
    width: 100%;
    height: 200px;
    resize: vertical;
    background: var(--grey-900);
    border: 1px solid var(--grey-600);
    color: var(--grey-200);
    border-radius: 4px;
    padding: 6px 8px;
    font-size: 0.78rem;
    font-family: monospace;
    line-height: 1.4;
    box-sizing: border-box;
}
.keyword-menu textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.keyword-menu-footer {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    padding-top: 4px;
}
.keyword-menu-footer button {
    padding: 6px 12px;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 4px;
    cursor: pointer;
    border: 1px solid var(--grey-600);
    background: transparent;
    color: var(--grey-300);
}
.keyword-menu-footer button:hover {
    background: var(--overlay-hover);
    color: var(--text-overlay-hover);
}
.keyword-menu-footer button#kwSaveBtn {
    background: var(--accent);
    color: white;
    border: none;
}
.keyword-menu-footer button#kwSaveBtn:hover {
    filter: brightness(1.1);
}

/* ── Toggle Switch ── */

.toggle-switch {
    position: relative;
    width: 32px;
    height: 16px;
    cursor: pointer;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute; inset: 0;
    background: var(--grey-600); border-radius: 8px; transition: 0.2s;
}
.toggle-slider::before {
    content: '';
    position: absolute;
    width: 12px; height: 12px;
    left: 2px; top: 2px;
    background: white; border-radius: 50%;
    transition: 0.2s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--accent); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(16px); }

/* ── Utility ── */

.nav-clear {
    background: none; border: none; color: var(--grey-400); cursor: pointer;
    font-size: 0.85rem; padding: 5px 10px;
}
.nav-clear:hover { color: var(--accent); }

.btn-icon {
    background: var(--overlay);
    border: none;
    color: var(--text-overlay);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 475;
    padding: 5px 10px;
    border-radius: 4px;
    transition: background 0.2s;
    line-height: 1;
    flex-shrink: 0;
}
.btn-icon:hover { background: var(--overlay-hover); color: var(--text-overlay-hover); }
.btn-icon:disabled { opacity: 0.35; cursor: default; pointer-events: none; }
.btn-icon-danger:hover { background: var(--accent-bg); color: var(--accent); }

.drop-zone-empty {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    height: 100%; min-height: 200px; padding: 32px 24px; text-align: center;
    border: 2px dashed var(--grey-600); border-radius: 14px;
    box-sizing: border-box;
    transition: border-color 0.4s ease, background 0.3s ease;
}
.drop-zone-empty-icon {
    width: 52px; height: 52px; color: var(--grey-500); margin-bottom: 14px; opacity: 0.5;
}
.drop-zone-empty-icon svg { width: 100%; height: 100%; }
.drop-zone-empty-title {
    font-size: 1rem; font-weight: 600; color: var(--grey-400); margin: 0 0 4px 0;
}
.drop-zone-empty-text {
    font-size: 0.8rem; color: var(--grey-500); margin: 0;
}

.dim { font-size: 0.7rem; font-weight: 350; color: var(--grey-500); }
.small { width: 70px; padding: 4px; font-size: 0.8rem; }
.keyword-select.small { width: auto; min-width: 80px; }

/* ── Animations ── */

@keyframes placeholder-shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

@keyframes ocr-pulse {
    0%, 100% { opacity: 0.3; color: var(--grey-500); background: transparent; border-color: var(--grey-600); }
    50% { opacity: 1; color: var(--accent-light); background: var(--accent-bg); border-color: var(--accent); }
}

.ocr-pulsing {
    color: var(--pulse-color) !important;
    opacity: var(--pulse-opacity) !important;
}

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

/* ── Dark Theme Overrides ── */

[data-theme="dark"] .btn-open {
    background: var(--grey-500);
    color: var(--grey-700);
    border-color: var(--grey-400);
}
[data-theme="dark"] .btn-open:hover {
    background: var(--grey-400);
    color: var(--grey-800);
}

[data-theme="dark"] .keyword-select option {
    background: #f5f5f5;
    color: #333;
}

[data-theme="dark"] .gs-nav-btn:first-of-type {
    border-left-color: rgba(0,0,0,0.15);
}

[data-theme="dark"] .kw-grid-cell.active {
    background: var(--grey-700);
    border-color: var(--accent);
}
[data-theme="dark"] .kw-grid-cell.active .kw-cell-name {
    color: var(--grey-200);
}
[data-theme="dark"] .kw-grid-cell.active .kw-cell-count {
    color: white;
    background: var(--accent);
}

[data-theme="dark"] #resizer {
    background: var(--grey-400);
}
[data-theme="dark"] #resizer:hover,
[data-theme="dark"] body.dragging #resizer {
    background: var(--grey-500);
}

/* ── Noise Texture Overlay ── */

body::before {
    content: ''; position: fixed; inset: 0; z-index: 9999;
    pointer-events: none; opacity: 0.035;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
    background-repeat: repeat; background-size: 256px 256px;
}

/* ── Custom Scrollbars ── */

.results-area::-webkit-scrollbar,
.viewer-scroll::-webkit-scrollbar { width: 6px; height: 6px; }

.results-area::-webkit-scrollbar-track,
.viewer-scroll::-webkit-scrollbar-track { background: transparent; }

.results-area::-webkit-scrollbar-thumb,
.viewer-scroll::-webkit-scrollbar-thumb {
    background: var(--grey-600); border-radius: 3px;
    transition: background 0.2s;
}
.results-area::-webkit-scrollbar-thumb:hover,
.viewer-scroll::-webkit-scrollbar-thumb:hover { background: var(--grey-500); }

.kw-grid-content::-webkit-scrollbar { width: 4px; }
.kw-grid-content::-webkit-scrollbar-track { background: transparent; }
.kw-grid-content::-webkit-scrollbar-thumb { background: var(--grey-600); border-radius: 2px; }

/* ── Mobile ── */

@media (max-width: 600px) {

    .mobile-toggle-sidebar {
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 4px 8px;
        margin-left: auto;
        background: transparent;
        border: 1px solid var(--grey-600);
        border-radius: 4px;
        color: var(--grey-300);
        cursor: pointer;
        font-size: 1rem;
        order: 3;
    }

    #sidebar {
        position: fixed;
        left: 0;
        width: 100%;
        z-index: 10000;
        transform: translateX(0);
        transition: height 0.25s;
    }

    #sidebar.open {
        top: auto !important;
        bottom: 0 !important;
        height: 70% !important;
        max-height: 70% !important;
    }

    #sidebar.collapsed {
        position: fixed !important;
        top: auto !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        height: 44px !important;
        max-height: 44px !important;
        overflow: visible;
        z-index: 10000 !important;
        box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    }

    #sidebar.collapsed .results-area,
    #sidebar.collapsed .keyword-grid-panel {
        display: none;
    }

    #resizer { display: none; }

    .viewer-container { height: 55%; min-height: 200px; }
    .viewer-container.sidebar-collapsed { height: calc(100% - 44px); }

    .header-main-row { flex-wrap: wrap; }
    .results-area { padding: 8px; }
    .header { padding: 8px; }
    .btn-open { padding: 8px 12px; font-size: 0.8rem; }

    .sidebar ul.tree-nested { padding-left: 12px; }

    .folder, .file { font-size: 0.78rem; padding: 2px 4px; }
    .tree-count { font-size: 0.6rem; padding: 1px 4px; }
    .tree-child { font-size: 0.72rem; padding: 2px 6px 2px 8px; }
}

/* ── Custom Dropdown ── */

.custom-dropdown {
    position: relative;
    display: inline-block;
    vertical-align: middle;
}

.custom-dropdown-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    width: 100%;
    background: var(--overlay);
    border: 1px solid var(--overlay-border);
    color: var(--text-overlay);
    border-radius: 4px;
    padding: 5px 8px;
    font-size: 0.85rem;
    font-family: inherit;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}
.custom-dropdown-trigger:hover {
    background: var(--overlay-active);
    border-color: var(--overlay-hover);
}
.custom-dropdown.open .custom-dropdown-trigger {
    border-color: var(--accent);
    background: var(--overlay-active);
}
.custom-dropdown-trigger:focus-visible {
    outline: none;
    border-color: var(--accent);
}

.custom-dropdown-arrow {
    flex-shrink: 0;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid var(--grey-400);
    margin-top: 1px;
    transition: transform 0.2s;
}
.custom-dropdown.open .custom-dropdown-arrow {
    transform: rotate(180deg);
}

.custom-dropdown-menu {
    display: none;
    position: absolute;
    z-index: 200;
    min-width: 100%;
    width: auto;
    max-height: 240px;
    overflow-y: auto;
    background: var(--grey-800);
    border: 1px solid var(--grey-600);
    border-radius: 5px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
    margin-top: 2px;
    padding: 4px 0;
}
.custom-dropdown-menu.open {
    display: block;
}
.custom-dropdown-menu.flip-up {
    margin-top: 0;
    margin-bottom: 2px;
}

.custom-dropdown-item {
    padding: 6px 10px;
    font-size: 0.83rem;
    color: var(--grey-200);
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background 0.12s;
    user-select: none;
}
.custom-dropdown-item:hover,
.custom-dropdown-item:focus-visible {
    background: var(--accent-bg);
    outline: none;
}
.custom-dropdown-item.selected {
    background: var(--accent);
    color: white;
    font-weight: 500;
}
.custom-dropdown-item.selected:hover,
.custom-dropdown-item.selected:focus-visible {
    background: var(--accent-light);
}
.custom-dropdown-item.disabled {
    opacity: 0.4;
    cursor: default;
    pointer-events: none;
}

.custom-dropdown.disabled .custom-dropdown-trigger {
    opacity: 0.35;
    cursor: default;
    pointer-events: none;
}

[data-theme="dark"] .custom-dropdown-menu {
    background: #262626;
    border-color: #404040;
}
[data-theme="dark"] .custom-dropdown-item {
    color: #d4d4d4;
}
[data-theme="dark"] .custom-dropdown-item.selected {
    background: var(--accent);
    color: white;
}

/* ── Sidebar keyword row ── */

.keyword-row .custom-dropdown {
    flex: 1;
    min-width: 0;
}

/* ── Keyword menu row ── */

.keyword-menu-row .custom-dropdown {
    flex: 1;
    min-width: 0;
}
.keyword-menu-row .custom-dropdown-trigger {
    font-size: 0.75rem;
    padding: 5px 6px;
}

/* ── Toolbar keyword select ── */

.custom-dropdown[data-for="keywordSelect"] .custom-dropdown-trigger {
    max-width: 132px;
    min-width: 88px;
}

/* ── Mobile ── */

@media (max-width: 600px) {
    .custom-dropdown-item {
        padding: 8px 12px;
        font-size: 0.85rem;
    }
    .custom-dropdown-menu {
        max-height: 200px;
    }
}
