/* File-viewer & developer tools (tools/_dev_layout.html). Builds on tools.css. */

.dv {
    --dv-surface: #fff;
    --dv-subtle: #f8fafc;
    --dv-line: var(--border, #e2e8f0);
    --dv-code: #f6f8fa;
    --dv-hover: rgba(var(--t-500-rgb, 99, 102, 241), 0.07);
    --dv-sel: rgba(var(--t-500-rgb, 99, 102, 241), 0.15);
    --dv-accent: var(--primary-dark, #4f46e5);
    --dv-k: #7c3aed;
    --dv-str: #047857;
    --dv-num: #1d4ed8;
    --dv-bool: #c2410c;
    --dv-null: #64748b;
    --dv-tag: #be185d;
    --dv-attr: #b45309;
    --dv-mark: #fde68a;
    --dv-add-bg: #e6ffec;
    --dv-add-hl: #abf2bc;
    --dv-del-bg: #ffebe9;
    --dv-del-hl: #ffc1c0;
    --dv-mono: ui-monospace, SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace;
}
[data-bs-theme="dark"] .dv, html.dark-theme .dv {
    --dv-surface: var(--dark-2, #161b22);
    --dv-subtle: var(--dark-3, #21262d);
    --dv-line: var(--dark-border, #30363d);
    --dv-code: #0d1117;
    --dv-accent: var(--t-300, #a5b4fc);
    --dv-k: #c4b5fd;
    --dv-str: #6ee7b7;
    --dv-num: #93c5fd;
    --dv-bool: #fdba74;
    --dv-null: #94a3b8;
    --dv-tag: #f9a8d4;
    --dv-attr: #fcd34d;
    --dv-mark: rgba(250, 204, 21, 0.35);
    --dv-add-bg: rgba(46, 160, 67, 0.15);
    --dv-add-hl: rgba(46, 160, 67, 0.4);
    --dv-del-bg: rgba(248, 81, 73, 0.15);
    --dv-del-hl: rgba(248, 81, 73, 0.4);
}

/* ---- Toolbar & layout ---- */
.dv-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 12px 14px; margin-bottom: 16px; }
.dv-bar .ms-auto { display: flex; flex-wrap: wrap; gap: 8px; }
.dv-seg { padding: 3px; }
.dv-seg span { padding: 6px 12px; white-space: nowrap; }
.dv-sep { width: 1px; align-self: stretch; background: var(--dv-line); margin: 0 4px; }
.dv-opt { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text-main); margin: 0; cursor: pointer; white-space: nowrap; }
.dv-opt input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); }
.dv-select { height: 32px; padding: 2px 28px 2px 10px; font-size: 13px; border-radius: 9px; width: auto; }

.dv-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.dv-grid-wide { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); }
.dv-pane { padding: 0; overflow: hidden; display: flex; flex-direction: column; min-width: 0; }
.dv-head {
    display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between;
    padding: 10px 14px; border-bottom: 1px solid var(--dv-line); font-size: 13px; font-weight: 700; color: var(--text-main);
    min-height: 48px;
}
.dv-head-title { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.dv-head-title > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dv-head-tools { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.dv-body { padding: 14px; min-width: 0; }
.dv-scroll { height: calc(100vh - 290px); min-height: 420px; overflow: auto; }

.dv-icon-btn {
    display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; flex-shrink: 0;
    border: 1px solid var(--dv-line); border-radius: 8px; background: var(--dv-subtle); color: var(--text-main); font-size: 14px;
}
.dv-icon-btn:hover { color: var(--dv-accent); border-color: var(--primary); }
.dv-icon-btn:disabled { opacity: .45; pointer-events: none; }

/* View tabs inside a pane */
.dv-tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.dv-tab {
    border: 0; background: transparent; color: var(--text-muted); font-size: 13px; font-weight: 600;
    padding: 6px 12px; border-radius: 8px; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px;
}
.dv-tab:hover { color: var(--dv-accent); background: var(--dv-hover); }
.dv-tab.active { color: var(--dv-accent); background: var(--dv-sel); }
.dv-tab .badge { font-size: 10.5px; }
.dv-view[hidden] { display: none !important; }

/* Stats chips */
.dv-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.dv-chip {
    display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; color: var(--text-muted);
    background: var(--dv-subtle); border: 1px solid var(--dv-line); border-radius: 999px; padding: 3px 10px; white-space: nowrap;
}
.dv-chip strong { color: var(--text-main); }
.dv-chip.is-ok { color: #047857; background: #ecfdf5; border-color: #a7f3d0; }
.dv-chip.is-bad { color: #b91c1c; background: #fef2f2; border-color: #fecaca; }
.dv-chip.is-warn { color: #b45309; background: #fffbeb; border-color: #fde68a; }
[data-bs-theme="dark"] .dv-chip.is-ok, html.dark-theme .dv-chip.is-ok { color: #6ee7b7; background: rgba(16, 185, 129, .12); border-color: rgba(16, 185, 129, .3); }
[data-bs-theme="dark"] .dv-chip.is-bad, html.dark-theme .dv-chip.is-bad { color: #fca5a5; background: rgba(239, 68, 68, .12); border-color: rgba(239, 68, 68, .3); }
[data-bs-theme="dark"] .dv-chip.is-warn, html.dark-theme .dv-chip.is-warn { color: #fcd34d; background: rgba(245, 158, 11, .12); border-color: rgba(245, 158, 11, .3); }

/* ---- Code editor ---- */
.dv-editor { display: flex; flex: 1; min-height: 0; background: var(--dv-surface); }
.dv-gutter {
    flex: 0 0 auto; min-width: 44px; padding: 14px 8px 14px 6px; text-align: right; overflow: hidden; user-select: none;
    font: 13px/1.6 var(--dv-mono); color: #94a3b8; background: var(--dv-subtle); border-right: 1px solid var(--dv-line); white-space: pre;
}
.dv-gutter .is-err { color: #fff; background: #dc2626; border-radius: 4px; padding: 0 3px; }
.dv-src {
    flex: 1; min-width: 0; display: block; width: 100%; border: 0; resize: none; outline: none; padding: 14px;
    font: 13px/1.6 var(--dv-mono); color: var(--text-main); background: transparent; tab-size: 4; white-space: pre; overflow: auto;
}
.dv-src::placeholder { color: #94a3b8; }
.dv-editor:focus-within { box-shadow: inset 0 0 0 2px rgba(var(--t-500-rgb, 99, 102, 241), .25); }
.dv-editor.is-over, .dv-pane.is-over { box-shadow: inset 0 0 0 2px var(--primary); background: var(--dv-hover); }

/* Read-only code output */
.dv-code { margin: 0; background: var(--dv-code); font: 13px/1.6 var(--dv-mono); color: var(--text-main); white-space: pre; tab-size: 4; }
.dv-code code { display: block; padding: 14px 16px; background: transparent !important; color: inherit; font: inherit; }
.dv-code.is-wrap { white-space: pre-wrap; word-break: break-word; }

/* ---- Errors, toast, empty states ---- */
.dv-error { margin: 12px 14px 0; padding: 12px 14px; border-radius: 12px; background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; font-size: 13px; }
.dv-error[hidden] { display: none; }
.dv-error-title { font-weight: 700; display: flex; align-items: center; gap: 6px; }
.dv-error-detail { margin-top: 4px; }
.dv-error-code { margin: 8px 0 0; padding: 10px 12px; border-radius: 8px; background: rgba(255, 255, 255, .7); color: #7f1d1d; font: 12.5px/1.5 var(--dv-mono); overflow-x: auto; white-space: pre; }
[data-bs-theme="dark"] .dv-error, html.dark-theme .dv-error { background: rgba(239, 68, 68, .1); border-color: rgba(239, 68, 68, .35); color: #fca5a5; }
[data-bs-theme="dark"] .dv-error-code, html.dark-theme .dv-error-code { background: rgba(0, 0, 0, .3); color: #fecaca; }

.dv-warn-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.dv-warn-list li { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; padding: 8px 10px; border-radius: 10px; background: var(--dv-subtle); color: var(--text-main); }
.dv-warn-list li i { margin-top: 2px; }
.dv-warn-list .lvl-bad i { color: #dc2626; }
.dv-warn-list .lvl-warn i { color: #d97706; }
.dv-warn-list .lvl-ok i { color: #059669; }
.dv-warn-list .lvl-info i { color: var(--primary); }

.dv-empty { text-align: center; color: var(--text-muted); padding: 64px 16px; font-size: 14px; }
.dv-empty i { font-size: 42px; display: block; margin-bottom: 8px; color: rgba(var(--t-500-rgb, 99, 102, 241), .55); }
.dv-empty[hidden] { display: none; }

.dv-toast {
    position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 2100; max-width: calc(100% - 32px);
    background: #111827; color: #fff; font-size: 14px; font-weight: 600; padding: 10px 18px; border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
}
.dv-toast[hidden] { display: none; }
.dv-toast.is-ok { background: #065f46; }
.dv-toast.is-warn { background: #92400e; }

/* ---- Find box ---- */
.dv-find {
    display: flex; align-items: center; gap: 4px; height: 34px; padding: 0 4px 0 10px; min-width: 220px; flex: 1; max-width: 360px;
    border: 1px solid var(--dv-line); border-radius: 10px; background: var(--dv-surface);
}
.dv-find:focus-within { border-color: var(--primary); }
.dv-find > i { color: #94a3b8; font-size: 13px; }
.dv-find input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; font-size: 13px; color: var(--text-main); }
.dv-find .dv-icon-btn { width: 26px; height: 26px; border: 0; background: transparent; }
.dv-find-count { font-size: 12px; color: var(--text-muted); white-space: nowrap; }

/* ---- Tree ---- */
.dv-tree { font: 13px/1.5 var(--dv-mono); color: var(--text-main); padding: 10px 6px; outline: none; }
.dv-tree:focus-visible { box-shadow: inset 0 0 0 2px rgba(var(--t-500-rgb, 99, 102, 241), .3); }
.dv-row { display: flex; align-items: flex-start; gap: 2px; padding: 1px 8px 1px 4px; border-radius: 6px; cursor: pointer; min-width: max-content; }
.dv-row:hover { background: var(--dv-hover); }
.dv-row.is-selected { background: var(--dv-sel); }
.dv-row.is-match .dv-label { background: rgba(250, 204, 21, .18); border-radius: 4px; }
.dv-row.is-current .dv-label { background: var(--dv-mark); box-shadow: 0 0 0 2px #f59e0b; }
.dv-caret { flex: 0 0 18px; height: 19px; display: inline-flex; align-items: center; justify-content: center; color: #94a3b8; font-size: 10px; }
.dv-caret i { transition: transform .12s; }
.dv-node.is-open > .dv-row .dv-caret i { transform: rotate(90deg); }
.dv-label { display: inline-flex; flex-wrap: nowrap; gap: 6px; white-space: pre; padding: 0 2px; }
.dv-kids { margin-left: 13px; padding-left: 6px; border-left: 1px dashed var(--dv-line); }
.dv-more {
    margin: 4px 0 4px 24px; border: 1px dashed var(--dv-line); background: transparent; color: var(--dv-accent);
    font: 600 12px/1 system-ui, sans-serif; padding: 6px 10px; border-radius: 8px;
}
.dv-more:hover { background: var(--dv-hover); }
.dv-k { color: var(--dv-k); font-weight: 600; }
.dv-k-root { color: var(--text-muted); }
.dv-k-index { color: var(--dv-null); }
.dv-k-meta { color: var(--dv-null); font-size: 12px; }
.dv-colon { color: var(--dv-null); margin-left: -6px; }
.dv-v-string { color: var(--dv-str); }
.dv-v-number { color: var(--dv-num); }
.dv-v-bool { color: var(--dv-bool); font-weight: 600; }
.dv-v-null, .dv-v-date { color: var(--dv-null); font-style: italic; }
.dv-v-date { color: var(--dv-num); }
.dv-x-tag { color: var(--dv-tag); font-weight: 600; }
.dv-x-attr { color: var(--dv-attr); }
.dv-x-text { color: var(--text-main); }
.dv-x-comment { color: var(--dv-null); font-style: italic; }

/* Selected-node path bar */
.dv-path {
    display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-top: 1px solid var(--dv-line); background: var(--dv-subtle);
    font: 12.5px/1.4 var(--dv-mono); color: var(--text-main); min-height: 44px;
}
.dv-path code { flex: 1; min-width: 0; overflow-x: auto; white-space: nowrap; background: none; color: var(--dv-accent); padding: 0; font: inherit; scrollbar-width: thin; }
.dv-path .dv-type { font: 600 11px/1 system-ui, sans-serif; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }

/* Key / value tables (properties, claims, stats) */
.dv-kv { width: 100%; border-collapse: collapse; font-size: 13px; }
.dv-kv th, .dv-kv td { padding: 8px 10px; border-bottom: 1px solid var(--dv-line); vertical-align: top; text-align: left; }
.dv-kv th { width: 34%; color: var(--text-muted); font-weight: 600; }
.dv-kv td { color: var(--text-main); word-break: break-word; }
.dv-kv tr:last-child th, .dv-kv tr:last-child td { border-bottom: 0; }
.dv-kv code { font-family: var(--dv-mono); font-size: 12.5px; color: var(--dv-accent); background: none; padding: 0; }
.dv-kv .dv-sub { display: block; font-size: 12px; color: var(--text-muted); font-weight: 400; margin-top: 2px; }

.dv-section-title { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin: 18px 0 8px; }
.dv-section-title:first-child { margin-top: 0; }
.dv-help { font-size: 12.5px; color: var(--text-muted); }
.dv-help code { font-size: 12px; }

@media (max-width: 991.98px) {
    .dv-grid, .dv-grid-wide { grid-template-columns: 1fr; }
    .dv-scroll { height: 60vh; min-height: 300px; }
    .dv-find { max-width: none; }
}
@media (max-width: 575.98px) {
    .dv-bar .btn span { display: none; }
    .dv-bar .btn i { margin: 0; }
}

/* ---- Generic data table (JSON table view, CSV, HTML assets) ---- */
.dv-table-wrap { overflow: auto; border-top: 1px solid var(--dv-line); }
.dv-table { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; font-size: 13px; color: var(--text-main); }
.dv-table th, .dv-table td { padding: 7px 12px; border-bottom: 1px solid var(--dv-line); border-right: 1px solid var(--dv-line); text-align: left; vertical-align: top;
    max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dv-table thead th { position: sticky; top: 0; z-index: 1; background: var(--dv-subtle); font-weight: 700; }
.dv-table tbody tr:hover td { background: var(--dv-hover); }
.dv-table .is-num { text-align: right; font-variant-numeric: tabular-nums; }
.dv-table .dv-rownum { color: var(--dv-null); text-align: right; background: var(--dv-subtle); position: sticky; left: 0; font-variant-numeric: tabular-nums; min-width: 44px; }
.dv-table thead .dv-rownum { z-index: 2; }
.dv-table td.is-selected { outline: 2px solid var(--primary); outline-offset: -2px; background: var(--dv-sel); }

/* CSV */
.dv-table-csv thead tr:first-child th { padding: 0; }
.dv-th { display: flex; align-items: center; gap: 6px; width: 100%; border: 0; background: none; padding: 8px 12px; font: inherit; font-weight: 700; color: inherit; text-align: left; }
.dv-th:hover { color: var(--dv-accent); }
.is-num .dv-th { justify-content: flex-end; }
.dv-th-name { overflow: hidden; text-overflow: ellipsis; }
.dv-th-type { font: 600 10px/1 var(--dv-mono); color: var(--dv-null); background: var(--dv-surface); border: 1px solid var(--dv-line); border-radius: 4px; padding: 2px 4px; }
.dv-th-sort, .dv-th-prio { color: var(--dv-accent); }
.dv-th-prio { font-size: 10px; }
.dv-filter-row th { top: 37px; padding: 4px 6px; background: var(--dv-surface); }
.dv-filter-row input { min-width: 90px; font-size: 12px; }
.dv-pager { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 14px; border-top: 1px solid var(--dv-line); }
.dv-col-menu { max-height: 360px; overflow: auto; }
.dv-col-menu .dropdown-item { font-weight: 500; }
.dv-col-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.dv-col-card { border: 1px solid var(--dv-line); border-radius: 12px; padding: 12px; background: var(--dv-surface); }
.dv-col-head { display: flex; justify-content: space-between; gap: 8px; align-items: center; margin-bottom: 6px; color: var(--text-main); }
.dv-col-head strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- XML / XPath ---- */
.dv-xpath { display: flex; align-items: center; gap: 6px; flex: 1 1 280px; height: 34px; padding: 0 3px 0 10px; border: 1px solid var(--dv-line); border-radius: 10px; background: var(--dv-surface); }
.dv-xpath:focus-within { border-color: var(--primary); }
.dv-xpath-label { font: 700 11px/1 system-ui, sans-serif; color: var(--text-muted); text-transform: uppercase; }
.dv-xpath input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; font: 13px var(--dv-mono); color: var(--text-main); }
.dv-xpath .btn { padding: 3px 12px; }
.dv-xpath-results { max-height: 220px; overflow: auto; padding: 8px 14px; border-bottom: 1px solid var(--dv-line); background: var(--dv-subtle); font-size: 13px; }
.dv-xpath-results[hidden] { display: none; }
.dv-xpath-head { font-weight: 700; color: var(--text-main); margin-bottom: 6px; }
.dv-xpath-err { color: #dc2626; font-weight: 600; }
.dv-xpath-list { display: flex; flex-direction: column; gap: 3px; }
.dv-xpath-item { display: flex; gap: 10px; align-items: baseline; text-align: left; border: 0; background: var(--dv-surface); border-radius: 8px; padding: 5px 10px; color: var(--text-main); min-width: 0; }
.dv-xpath-item:hover { background: var(--dv-sel); }
.dv-xpath-item code { color: var(--dv-accent); background: none; padding: 0; font-size: 12px; white-space: nowrap; }
.dv-xpath-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-muted); }

/* ---- PDF reader ---- */
.dv-pdf-pass { margin-bottom: 16px; }
.dv-pdf-pass[hidden], .dv-pdf[hidden] { display: none; }
.dv-pdf-page { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-muted); }
.dv-pdf-page input { width: 56px; text-align: center; }
.dv-pdf-main { display: flex; padding: 0; overflow: hidden; height: calc(100vh - 230px); min-height: 480px; }
.dv-pdf-side { flex: 0 0 230px; display: flex; flex-direction: column; border-right: 1px solid var(--dv-line); background: var(--dv-subtle); min-width: 0; }
.dv-pdf-side[hidden] { display: none; }
.dv-pdf-tabs { padding: 6px; border-bottom: 1px solid var(--dv-line); justify-content: space-around; }
.dv-pdf-thumbs, .dv-pdf-list { flex: 1; overflow: auto; }
.dv-pdf-thumbs { padding: 12px 22px; display: flex; flex-direction: column; gap: 14px; }
.dv-pdf-thumb { position: relative; width: 100%; padding: 0; border: 2px solid transparent; border-radius: 6px; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .15); overflow: hidden; flex-shrink: 0; }
.dv-pdf-thumb canvas { display: block; width: 100%; height: 100%; }
.dv-pdf-thumb span { position: absolute; bottom: 4px; right: 4px; font-size: 11px; font-weight: 700; background: rgba(15, 23, 42, .7); color: #fff; border-radius: 4px; padding: 1px 6px; }
.dv-pdf-thumb.is-active { border-color: var(--primary); }
.dv-pdf-list { padding: 8px; font-size: 13px; }
.dv-pdf-outline { list-style: none; margin: 0; padding: 0; }
.dv-pdf-link { display: block; width: 100%; text-align: left; border: 0; background: none; color: var(--text-main); border-radius: 6px; padding: 5px 8px; font-size: 13px; }
.dv-pdf-link:hover:not(:disabled) { background: var(--dv-sel); color: var(--dv-accent); }
.dv-pdf-link:disabled { color: var(--text-muted); }
.dv-pdf-hit { display: block; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--dv-line); background: none; padding: 8px; color: var(--text-main); }
.dv-pdf-hit:hover { background: var(--dv-sel); }
.dv-pdf-hit strong { display: block; font-size: 12px; color: var(--dv-accent); }
.dv-pdf-hit span { font-size: 12.5px; color: var(--text-muted); }
.dv-pdf-list .dv-kv th { width: 40%; }
.dv-pdf-view { flex: 1; overflow: auto; background: #e2e8f0; outline: none; min-width: 0; }
[data-bs-theme="dark"] .dv-pdf-view, html.dark-theme .dv-pdf-view { background: #0d1117; }
.dv-pdf-pages { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 16px; width: max-content; min-width: 100%; }
.dv-pdf-pg { position: relative; background: #fff; box-shadow: 0 2px 10px rgba(0, 0, 0, .18); flex-shrink: 0; }
.dv-pdf-box { position: absolute; inset: 0; overflow: hidden; }
.dv-pdf-box canvas { display: block; }
.dv-pdf-num { position: absolute; bottom: -2px; left: 50%; transform: translate(-50%, 100%); font-size: 11px; color: var(--text-muted); }
.dv-pdf-err { padding: 40px 16px; text-align: center; color: #b91c1c; font-size: 13px; }
.dv-pdf-main.is-night .dv-pdf-box canvas, .dv-pdf-main.is-night .dv-pdf-thumb canvas { filter: invert(.92) hue-rotate(180deg); }
.dv-pdf-main.is-night .dv-pdf-pg { background: #111; }
.dv-pdf-main:fullscreen { height: 100vh; border-radius: 0; }
#nightBtn[aria-pressed="true"] { background: var(--dv-sel); color: var(--dv-accent); }

/* pdf.js text layer (selection + search highlights) */
.textLayer { position: absolute; text-align: initial; inset: 0; overflow: hidden; line-height: 1; text-size-adjust: none; forced-color-adjust: none; transform-origin: 0 0; z-index: 2; }
.textLayer :is(span, br) { color: transparent; position: absolute; white-space: pre; cursor: text; transform-origin: 0% 0%; }
.textLayer span.markedContent { top: 0; height: 0; }
.textLayer .highlight { margin: -1px; padding: 1px; background-color: rgba(250, 204, 21, .45); border-radius: 3px; }
.textLayer .highlight.selected { background-color: rgba(249, 115, 22, .6); }
.textLayer ::selection { background: rgba(37, 99, 235, .3); }
.textLayer br::selection { background: transparent; }

/* ---- Diff ---- */
.dv-diff-input { height: 34vh; min-height: 220px; }
.dv-diff-scroll { overflow: auto; max-height: calc(100vh - 200px); }
.dv-diff { width: 100%; border-collapse: collapse; table-layout: fixed; font: 12.5px/1.55 var(--dv-mono); color: var(--text-main); }
.dv-diff col.c-ln { width: 52px; }
.dv-diff col.c-sg { width: 22px; }
.dv-diff thead th { position: sticky; top: 0; z-index: 1; background: var(--dv-subtle); font: 700 12.5px/1.3 system-ui, sans-serif; padding: 8px 12px; border-bottom: 1px solid var(--dv-line); text-align: left; }
.dv-diff td { padding: 0 10px; vertical-align: top; }
.dv-diff td.ln { text-align: right; color: var(--dv-null); user-select: none; background: var(--dv-subtle); border-right: 1px solid var(--dv-line); padding: 0 8px; }
.dv-diff td.cd { white-space: pre; overflow-x: hidden; }
.dv-diff.is-wrap td.cd { white-space: pre-wrap; word-break: break-word; }
.dv-diff.is-split td.cd:nth-child(2) { border-right: 1px solid var(--dv-line); }
.dv-diff td.sg { text-align: center; user-select: none; }
.dv-diff .is-del { background: var(--dv-del-bg); }
.dv-diff .is-add { background: var(--dv-add-bg); }
.dv-diff td.ln.is-del, .dv-diff td.sg.is-del { color: #b91c1c; }
.dv-diff td.ln.is-add, .dv-diff td.sg.is-add { color: #15803d; }
.dv-diff .is-none { background: repeating-linear-gradient(-45deg, transparent 0 6px, rgba(148, 163, 184, .12) 6px 12px); }
.dv-diff del { background: var(--dv-del-hl); text-decoration: none; border-radius: 2px; }
.dv-diff ins { background: var(--dv-add-hl); text-decoration: none; border-radius: 2px; }
.dv-diff tr.is-focus td { box-shadow: inset 0 2px 0 var(--primary); }
.dv-fold td { padding: 0 !important; background: var(--dv-subtle); }
.dv-fold button { width: 100%; border: 0; background: rgba(var(--t-500-rgb, 99, 102, 241), .06); color: var(--dv-accent); font: 600 12px/1 system-ui, sans-serif; padding: 7px; }
.dv-fold button:hover { background: var(--dv-sel); }

.dv-kv .dv-kv-group { width: auto; padding-top: 14px; font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); }

/* ---- HTML viewer ---- */
.dv-html-stage { display: flex; justify-content: center; background: repeating-conic-gradient(var(--dv-subtle) 0% 25%, var(--dv-surface) 0% 50%) 50% / 20px 20px; padding: 0; }
.dv-html-frame { display: block; height: 100%; border: 0; background: #fff; transition: width .2s; max-width: 100%; }
.dv-html-node { border-top: 1px solid var(--dv-line); padding: 12px 14px; max-height: 260px; overflow: auto; background: var(--dv-subtle); }
.dv-html-sel { font: 12.5px var(--dv-mono); color: var(--dv-accent); background: none; padding: 0; word-break: break-all; }
.dv-outline { list-style: none; margin: 0; padding: 0; }
.dv-outline li { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: 14px; color: var(--text-main); border-bottom: 1px dashed var(--dv-line); }
.dv-outline .lvl-1 { font-weight: 800; }
.dv-outline .lvl-2 { font-weight: 700; }
.dv-outline-tag { font: 700 11px/1 var(--dv-mono); color: var(--dv-tag); background: var(--dv-subtle); border-radius: 4px; padding: 3px 5px; }

/* ---- Image viewer ---- */
#viewer[hidden] { display: none; }
.dv-zoom-val { min-width: 52px; text-align: center; font-variant-numeric: tabular-nums; }
.dv-color { width: 34px; height: 30px; padding: 2px; border: 1px solid var(--dv-line); border-radius: 8px; background: var(--dv-surface); cursor: pointer; }
.dv-img-main { display: grid; grid-template-columns: auto minmax(0, 1fr) 340px; gap: 16px; align-items: stretch; }
.dv-img-strip { width: 116px; padding: 8px; display: flex; flex-direction: column; gap: 8px; overflow: auto; height: calc(100vh - 250px); min-height: 440px; }
.dv-img-strip[hidden] { display: none; }
.dv-img-thumb { position: relative; flex-shrink: 0; }
.dv-img-thumb-btn { width: 100%; border: 2px solid transparent; border-radius: 10px; background: var(--dv-subtle); padding: 4px; display: flex; flex-direction: column; gap: 3px; }
.dv-img-thumb-btn img { width: 100%; height: 72px; object-fit: contain; }
.dv-img-thumb-btn span { font-size: 11px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dv-img-thumb.is-active .dv-img-thumb-btn { border-color: var(--primary); }
.dv-img-thumb-x { position: absolute; top: 2px; right: 2px; width: 22px; height: 22px; border: 0; border-radius: 50%; background: rgba(15, 23, 42, .65); color: #fff; font-size: 13px; display: flex; align-items: center; justify-content: center; padding: 0; }
.dv-img-stage { position: relative; overflow: hidden; padding: 0; height: calc(100vh - 250px); min-height: 440px; cursor: grab; touch-action: none; outline: none; }
.dv-img-stage:active { cursor: grabbing; }
.dv-img-stage[data-bg="checker"] { background: repeating-conic-gradient(#e2e8f0 0% 25%, #fff 0% 50%) 50% / 20px 20px; }
[data-bs-theme="dark"] .dv-img-stage[data-bg="checker"], html.dark-theme .dv-img-stage[data-bg="checker"] { background: repeating-conic-gradient(#21262d 0% 25%, #161b22 0% 50%) 50% / 20px 20px; }
.dv-img-stage[data-bg="white"] { background: #fff; }
.dv-img-stage[data-bg="black"] { background: #000; }
.dv-img-stage[data-bg="custom"] { background: var(--bg, #6366f1); }
.dv-img-stage img { position: absolute; left: 0; top: 0; max-width: none; transform-origin: center; user-select: none; pointer-events: none; }
.dv-img-stage img.is-pixel { image-rendering: pixelated; }
.dv-img-probe { position: absolute; left: 12px; bottom: 12px; display: flex; align-items: center; gap: 8px; background: rgba(15, 23, 42, .82); color: #fff; font: 12px var(--dv-mono); padding: 6px 10px; border-radius: 8px; pointer-events: none; }
.dv-img-probe[hidden] { display: none; }
.dv-swatch { width: 16px; height: 16px; border-radius: 4px; border: 1px solid rgba(255, 255, 255, .6); }
.dv-img-side { height: calc(100vh - 250px); min-height: 440px; }
.dv-img-panel { overflow: auto; flex: 1; }
.dv-palette { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.dv-palette-swatch { height: 52px; border: 1px solid var(--dv-line); border-radius: 10px; display: flex; align-items: flex-end; padding: 0; overflow: hidden; }
.dv-palette-swatch span { width: 100%; background: rgba(255, 255, 255, .85); color: #111; font: 10.5px/1.6 var(--dv-mono); }
.dv-svg-edit { font: 12.5px/1.5 var(--dv-mono); }
.dv-svg-code { max-height: 320px; overflow: auto; border-radius: 10px; }
.dv-tab-muted { opacity: .55; }
.text-transform-none { text-transform: none; letter-spacing: 0; font-weight: 400; }

@media (max-width: 1199.98px) {
    .dv-img-main { grid-template-columns: minmax(0, 1fr); }
    .dv-img-strip { flex-direction: row; width: auto; height: auto; min-height: 0; }
    .dv-img-thumb { width: 96px; }
    .dv-img-stage { height: 60vh; min-height: 320px; }
    .dv-img-side { height: auto; min-height: 0; }
}

/* ---- Base64 ---- */
.dv-bar-flat { margin: 0; padding: 10px 14px; border-bottom: 1px solid var(--dv-line); border-radius: 0; }
.dv-b64-grid { gap: 0; }
.dv-b64-col { display: flex; flex-direction: column; min-width: 0; }
.dv-b64-col + .dv-b64-col { border-left: 1px solid var(--dv-line); }
.dv-b64-area { height: 46vh; min-height: 260px; white-space: pre-wrap; word-break: break-all; }
.dv-b64-preview { width: 72px; height: 72px; object-fit: contain; border: 1px solid var(--dv-line); border-radius: 10px; background: #fff; }
.dv-b64-out { font: 12.5px/1.5 var(--dv-mono); word-break: break-all; }
.dv-b64-decoded { display: grid; gap: 16px; }
.dv-hexdump { border-radius: 10px; max-height: 340px; overflow: auto; font-size: 12px; }
.min-w-0 { min-width: 0; }
@media (max-width: 991.98px) { .dv-b64-col + .dv-b64-col { border-left: 0; border-top: 1px solid var(--dv-line); } }

/* ---- JWT ---- */
.dv-mono { font-family: var(--dv-mono) !important; font-size: 13px; }
.dv-jwt-input { word-break: break-all; white-space: pre-wrap; resize: vertical; min-height: 140px; }
.dv-jwt-color { padding: 12px 14px; border-top: 1px solid var(--dv-line); font: 13px/1.6 var(--dv-mono); word-break: break-all; background: var(--dv-subtle); }
.dv-jwt-color[hidden] { display: none; }
.dv-jwt-h { color: #e11d48; }
.dv-jwt-p { color: #7c3aed; }
.dv-jwt-s { color: #0284c7; }
.dv-jwt-k { color: #ea580c; }
.dv-jwt-iv { color: #059669; }
.dv-jwt-dot { color: var(--text-main); font-weight: 800; }
[data-bs-theme="dark"] .dv-jwt-h, html.dark-theme .dv-jwt-h { color: #fb7185; }
[data-bs-theme="dark"] .dv-jwt-p, html.dark-theme .dv-jwt-p { color: #c4b5fd; }
[data-bs-theme="dark"] .dv-jwt-s, html.dark-theme .dv-jwt-s { color: #7dd3fc; }

/* ---- Hash ---- */
.dv-hash-text { height: 30vh; min-height: 200px; white-space: pre-wrap; }
.dv-hash-algos { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.dv-hash-entry + .dv-hash-entry { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--dv-line); }
.dv-hash-entry-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; color: var(--text-main); }
.dv-hash-entry-head strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60%; }
.dv-hash-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.dv-hash-table th, .dv-hash-table td { padding: 8px 6px; border-bottom: 1px solid var(--dv-line); vertical-align: middle; }
.dv-hash-table th { width: 128px; color: var(--text-muted); font-weight: 700; white-space: nowrap; }
.dv-hash-table code { font: 12.5px/1.5 var(--dv-mono); color: var(--text-main); background: none; padding: 0; word-break: break-all; }
.dv-hash-table tr.is-match td, .dv-hash-table tr.is-match th { background: #ecfdf5; }
[data-bs-theme="dark"] .dv-hash-table tr.is-match td, [data-bs-theme="dark"] .dv-hash-table tr.is-match th,
html.dark-theme .dv-hash-table tr.is-match td, html.dark-theme .dv-hash-table tr.is-match th { background: rgba(16, 185, 129, .12); }
.dv-hash-copy { width: 40px; }
.dv-hash-tag { display: inline-block; margin-left: 6px; font: 600 10px/1 system-ui, sans-serif; color: var(--text-muted); border: 1px solid var(--dv-line); border-radius: 4px; padding: 2px 4px; text-transform: uppercase; }
.dv-hash-tag.is-weak { color: #b45309; border-color: #fcd34d; }

/* ---------- XLSX viewer ---------- */
.xv-sheets { display: flex; gap: 4px; overflow-x: auto; padding: 8px 12px 0; border-bottom: 1px solid var(--dv-line); background: var(--dv-subtle); scrollbar-width: thin; }
.xv-sheet { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--dv-line); border-bottom: 0; border-radius: 8px 8px 0 0; background: transparent; color: var(--text-muted); font-size: 13px; font-weight: 600; padding: 6px 14px; white-space: nowrap; }
.xv-sheet:hover { color: var(--dv-accent); background: var(--dv-hover); }
.xv-sheet.is-active { color: var(--dv-accent); background: #fff; box-shadow: inset 0 2px 0 var(--dv-accent); }
.xv-sheet.is-hidden { font-style: italic; opacity: .75; }
.xv-goto input { width: 170px; font-family: var(--dv-mono); }
.xv-table td.xv-merged { background: var(--dv-subtle); text-align: center; vertical-align: middle; font-weight: 600; }
.xv-table td.xv-f, .xv-list td.xv-f { font-family: var(--dv-mono); font-size: 12.5px; color: var(--dv-accent); }
.xv-table td.xv-err { color: #b91c1c; }
.xv-table td.xv-note { background-image: linear-gradient(225deg, #ef4444 6px, transparent 6px); }
.xv-table td { max-width: 420px; overflow: hidden; text-overflow: ellipsis; }
.xv-cell-kv { border-top: 1px solid var(--dv-line); }
.xv-cell-kv th { width: 160px; }
.xv-list tbody tr { cursor: pointer; }
.xv-list tbody tr:focus-visible td { outline: 2px solid var(--primary); outline-offset: -2px; }
[data-bs-theme="dark"] .xv-sheet.is-active, html.dark-theme .xv-sheet.is-active { background: #151c2e; }
[data-bs-theme="dark"] .xv-table td.xv-err, html.dark-theme .xv-table td.xv-err { color: #fca5a5; }
