/* ============================================================
   HTML File Viewer - scoped under .htv-root / .htv-* (rebuilt 2026-10-11)
   Shared header, footer, FAQ and related pills come from custom_styles.css.
   Accent: blue #3399cc (viewers). Single colours, no gradients,
   no thick side borders. Light default, dark via [data-theme="dark"].
   ============================================================ */
.htv-root {
    --htv-accent: #3399cc;
    --htv-accent-strong: #237a9f;
    --htv-accent-soft: rgba(51, 153, 204, 0.09);
    --htv-accent-line: rgba(51, 153, 204, 0.45);
    --htv-go: #237a9f;
    --htv-go-hover: #1b6183;
    --htv-card: var(--bg-elevated, #fff);
    --htv-sunk: var(--card-tertiary, #f1f5f9);
    --htv-open: var(--card-secondary, #f8f9fa);
    --htv-line: var(--border-color, #e2e8f0);
    --htv-text-1: var(--text-primary, #1e293b);
    --htv-text-2: var(--text-secondary, #555);
    --htv-muted: var(--text-muted, #64748b);
    --htv-warn: #b45309;
    --htv-red: #c23b3b;
    --htv-red-soft: rgba(230, 78, 78, 0.08);
    --htv-red-line: rgba(230, 78, 78, 0.35);
    --htv-mono: ui-monospace, "Cascadia Mono", SFMono-Regular, Menlo, Consolas, "DejaVu Sans Mono", "Liberation Mono", monospace;
    /* text surface */
    --htv-bg: #ffffff;
    --htv-fg: #1f2937;
    --htv-gut: #f6f8fa;
    --htv-gut-t: #94a3b8;
    --htv-gut-line: #e5e7eb;
    --htv-ws: #c0c7d2;
    --htv-ts: #0f7a8a;
    --htv-e: #c62828;
    --htv-w: #b45309;
    --htv-i: #1d6fa5;
    --htv-d: #8a94a6;
    --htv-row-err: rgba(230, 78, 78, 0.07);
    --htv-row-warn: rgba(217, 119, 6, 0.07);
    --htv-hit: rgba(250, 204, 21, 0.45);
    --htv-hit-cur: #facc15;
}
[data-theme="dark"] .htv-root {
    --htv-accent: #60a5fa;
    --htv-accent-strong: #93c5fd;
    --htv-accent-soft: rgba(96, 165, 250, 0.12);
    --htv-accent-line: rgba(96, 165, 250, 0.45);
    --htv-go: #2563eb;
    --htv-go-hover: #1d4ed8;
    --htv-sunk: #172033;
    --htv-open: #1a2438;
    --htv-warn: #fbbf24;
    --htv-red: #f87171;
    --htv-red-soft: rgba(248, 113, 113, 0.1);
    --htv-red-line: rgba(248, 113, 113, 0.4);
    --htv-bg: #0f172a;
    --htv-fg: #e2e8f0;
    --htv-gut: #131c30;
    --htv-gut-t: #64748b;
    --htv-gut-line: #24314a;
    --htv-ws: #475569;
    --htv-ts: #5eead4;
    --htv-e: #f87171;
    --htv-w: #fbbf24;
    --htv-i: #7dd3fc;
    --htv-d: #7c8aa3;
    --htv-row-err: rgba(248, 113, 113, 0.1);
    --htv-row-warn: rgba(251, 191, 36, 0.08);
    --htv-hit: rgba(250, 204, 21, 0.3);
}

.htv-root.tool-container { max-width: 1100px; margin: 0 auto; padding: 2rem; }
.htv-root [hidden] { display: none !important; }
.htv-root .htv-main { background: none; border: none; box-shadow: none; border-radius: 0; overflow: visible; padding: 0; }
.htv-root button { font: inherit; }
.htv-root code { font-family: var(--htv-mono); font-size: 0.86em; padding: 0.05rem 0.35rem; border-radius: 5px; background: var(--htv-sunk); }
.htv-root kbd {
    display: inline-block; padding: 0.05rem 0.4rem; border-radius: 5px; border: 1px solid var(--htv-line); border-bottom-width: 2px;
    background: var(--htv-card); font: 600 0.78em var(--htv-mono); color: var(--htv-text-1);
}
.htv-root .htv-muted { color: var(--htv-muted); font-weight: 500; }
.htv-root :focus-visible { outline: 3px solid var(--htv-accent-line); outline-offset: 2px; }

/* ---------- title ---------- */
.htv-root .tool-header { text-align: center; margin-bottom: 1.75rem; }
.htv-root .htv-title-row { display: flex; align-items: center; justify-content: center; gap: 0.9rem; margin-bottom: 0.9rem; }
.htv-root .htv-title-icon { width: 56px; height: 56px; border-radius: 16px; background: var(--htv-accent); color: #fff; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
[data-theme="dark"] .htv-root .htv-title-icon { color: #0b1e33; }
.htv-root .htv-title-icon svg { width: 30px; height: 30px; display: block; }
.htv-root .tool-title { margin: 0; font-size: 2rem; font-weight: 700; color: var(--htv-accent); line-height: 1.2; }
.htv-root .tool-description { max-width: 800px; margin: 0 auto; font-size: 1.05rem; line-height: 1.65; color: var(--htv-text-2); }
.htv-root .tool-description a { color: var(--htv-accent-strong); font-weight: 500; }
[data-theme="dark"] .htv-root .tool-description a { color: var(--htv-accent); }

/* ---------- error ---------- */
.htv-root .htv-error { display: flex; align-items: flex-start; gap: 0.7rem; margin: 0 0 1rem; padding: 0.9rem 1rem; border-radius: 12px; border: 1px solid var(--htv-red-line); background: var(--htv-red-soft); color: var(--htv-text-1); }
.htv-root .htv-error > svg { width: 20px; height: 20px; color: #e64e4e; flex-shrink: 0; margin-top: 2px; }
.htv-root .htv-error > div { flex: 1; min-width: 0; }
.htv-root .htv-error p { margin: 0; font-size: 0.92rem; line-height: 1.55; overflow-wrap: anywhere; }
.htv-root .htv-error p + p { margin-top: 0.3rem; color: var(--htv-muted); font-size: 0.86rem; }
.htv-root .htv-error a { color: var(--htv-red); font-weight: 600; }
.htv-root .htv-error-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.55rem; }
.htv-root .htv-x { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; flex-shrink: 0; border: none; border-radius: 8px; background: none; color: var(--htv-muted); cursor: pointer; padding: 0; margin: 0; }
.htv-root .htv-x:hover { background: rgba(100, 116, 139, 0.12); color: var(--htv-text-1); }
.htv-root .htv-x svg { width: 17px; height: 17px; }

/* ---------- cards ---------- */
.htv-root .htv-card { background: var(--htv-card); border: 1px solid var(--htv-line); border-radius: 20px; padding: 1.25rem; box-shadow: var(--shadow-sm); margin-bottom: 1.25rem; min-width: 0; }
.htv-root .htv-caption { display: inline-flex; align-items: center; gap: 0.35rem; margin: 0 0 0.45rem; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--htv-muted); }
.htv-root .htv-caption svg { width: 14px; height: 14px; }

/* ---------- buttons ---------- */
.htv-root .htv-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem; width: auto; min-height: 44px; padding: 0.6rem 1.1rem; margin: 0;
    border-radius: 12px; border: 1px solid transparent; font-size: 0.95rem; font-weight: 700; cursor: pointer; white-space: nowrap; text-decoration: none;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.htv-root .htv-btn svg { width: 18px; height: 18px; flex-shrink: 0; }
.htv-root .htv-go { background: var(--htv-go); color: #fff; }
.htv-root .htv-go:hover:not(:disabled) { background: var(--htv-go-hover); color: #fff; }
.htv-root .htv-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.htv-root .htv-btn-lg { min-height: 50px; padding: 0.65rem 1.5rem; font-size: 1rem; }
.htv-root .htv-btn-sm { min-height: 36px; padding: 0.4rem 0.8rem; font-size: 0.85rem; border-radius: 10px; }
.htv-root .htv-btn-sm svg { width: 16px; height: 16px; }
.htv-root .htv-btn-ghost { background: var(--htv-sunk); color: var(--htv-text-2); border-color: var(--htv-line); }
.htv-root .htv-btn-ghost:hover:not(:disabled) { color: var(--htv-text-1); border-color: var(--htv-accent-line); }
.htv-root .htv-text-btn { display: inline-flex; align-items: center; gap: 0.35rem; width: auto; padding: 0.35rem 0.6rem; margin: 0; border: none; border-radius: 8px; background: none; color: var(--htv-accent-strong); font-size: 0.85rem; font-weight: 600; cursor: pointer; white-space: nowrap; text-decoration: none; }
[data-theme="dark"] .htv-root .htv-text-btn { color: var(--htv-accent); }
.htv-root .htv-text-btn:hover:not(:disabled) { background: var(--htv-accent-soft); }
.htv-root .htv-text-btn svg { width: 15px; height: 15px; }
.htv-root .htv-icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; padding: 0; margin: 0; border: none; border-radius: 7px; background: none; color: var(--htv-text-2); cursor: pointer; flex-shrink: 0; }
.htv-root .htv-icon-btn:hover:not(:disabled) { background: var(--htv-accent-soft); color: var(--htv-text-1); }
.htv-root .htv-icon-btn:disabled { opacity: 0.35; cursor: default; }
.htv-root .htv-icon-btn svg { width: 16px; height: 16px; }
.htv-root .htv-seg-btn { display: inline-flex; align-items: center; gap: 0.4rem; width: auto; min-height: 36px; padding: 0.35rem 0.85rem; margin: 0; border-radius: 999px; border: 1px solid var(--htv-line); background: var(--htv-card); color: var(--htv-text-2); font-size: 0.85rem; font-weight: 600; cursor: pointer; }
.htv-root .htv-seg-btn svg { width: 15px; height: 15px; color: var(--htv-accent); }
.htv-root .htv-seg-btn:hover { border-color: var(--htv-accent-line); color: var(--htv-text-1); }
.htv-root .htv-chip { display: inline-flex; align-items: center; justify-content: center; gap: 0.35rem; width: auto; min-height: 34px; padding: 0.3rem 0.55rem; margin: 0; border-radius: 9px; border: 1px solid var(--htv-line); background: var(--htv-card); color: var(--htv-text-2); font-size: 0.8rem; font-weight: 700; cursor: pointer; min-width: 0; }
.htv-root .htv-chip:hover { border-color: var(--htv-accent-line); }
.htv-root .htv-chip.is-active { border-color: var(--htv-accent); background: var(--htv-accent-soft); color: var(--htv-accent-strong); }
[data-theme="dark"] .htv-root .htv-chip.is-active { color: var(--htv-accent); }
.htv-root .htv-chip svg { width: 15px; height: 15px; }
.htv-root .htv-quick { display: grid; gap: 0.35rem; }
.htv-root .htv-quick > * { min-width: 0; }
.htv-root .htv-quick-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.htv-root .htv-quick-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.htv-root .htv-quick-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.htv-root .htv-sub { margin: 0.75rem 0 0.35rem; font-size: 0.78rem; font-weight: 700; color: var(--htv-text-2); }
.htv-root .htv-sub:first-child { margin-top: 0.2rem; }

/* ---------- upload ---------- */
.htv-root .htv-drop {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.35rem; text-align: center; min-height: 180px; padding: 1.5rem 1.25rem;
    border-radius: 16px; border: 2px dashed var(--htv-accent-line); background: var(--htv-accent-soft); cursor: pointer; color: var(--htv-muted); font-size: 0.86rem; line-height: 1.5;
    transition: border-color 0.15s, background 0.15s; box-sizing: border-box; margin: 0;
}
.htv-root .htv-drop:hover, .htv-root .htv-drop.is-drag { border-color: var(--htv-accent); background: rgba(51, 153, 204, 0.14); }
.htv-root .htv-drop:focus-within { outline: 3px solid var(--htv-accent-soft); }
.htv-root .htv-drop strong { font-size: 1.08rem; color: var(--htv-text-1); }
.htv-root .htv-drop-link { color: var(--htv-accent-strong); text-decoration: underline; text-underline-offset: 3px; }
[data-theme="dark"] .htv-root .htv-drop-link { color: var(--htv-accent); }
.htv-root .htv-drop-icon { width: 58px; height: 58px; border-radius: 16px; display: flex; align-items: center; justify-content: center; margin-bottom: 0.35rem; background: var(--htv-card); color: var(--htv-accent); border: 1px solid var(--htv-line); }
.htv-root .htv-drop-icon svg { width: 28px; height: 28px; }
.htv-root .htv-types { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.3rem; margin-top: 0.35rem; max-width: 560px; }
.htv-root .htv-types span { padding: 0.05rem 0.45rem; border-radius: 6px; background: var(--htv-card); border: 1px solid var(--htv-line); font: 600 0.72rem var(--htv-mono); color: var(--htv-text-2); }
.htv-root .htv-or { display: flex; align-items: center; gap: 0.75rem; margin: 1rem 0 0.6rem; color: var(--htv-muted); font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }
.htv-root .htv-or::before, .htv-root .htv-or::after { content: ""; flex: 1; height: 1px; background: var(--htv-line); }
.htv-root .htv-textarea { display: block; width: 100%; min-height: 130px; max-height: 60vh; resize: vertical; box-sizing: border-box; margin: 0; padding: 0.75rem 0.85rem; border-radius: 12px; border: 1px solid var(--htv-line); background: var(--input-bg, #fff); color: var(--htv-text-1); font: 0.86rem/1.55 var(--htv-mono); tab-size: 4; }
.htv-root .htv-textarea:focus { outline: none; border-color: var(--htv-accent); box-shadow: 0 0 0 3px var(--htv-accent-soft); }
.htv-root .htv-input-bar { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.7rem; }
.htv-root .htv-kbd-hint { margin-left: auto; font-size: 0.76rem; color: var(--htv-muted); }
.htv-root .htv-samples { margin-top: 1rem; }
.htv-root .htv-sample-row { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.htv-root .htv-under { display: flex; flex-wrap: wrap; align-items: center; gap: 0.45rem 0.6rem; margin-top: 1rem; }
.htv-root .htv-pill { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.22rem 0.65rem; border-radius: 999px; background: var(--htv-sunk); border: 1px solid var(--htv-line); font-size: 0.78rem; font-weight: 600; color: var(--htv-text-2); }
.htv-root .htv-pill svg { width: 14px; height: 14px; color: var(--htv-accent); }
.htv-root .htv-recent { margin-top: 1rem; padding-top: 0.85rem; border-top: 1px solid var(--htv-line); }
.htv-root .htv-recent-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.htv-root .htv-recent-head .htv-caption { margin: 0; }
.htv-root .htv-recent-list { list-style: none; margin: 0.4rem 0 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.4rem; }
.htv-root .htv-recent-list button { display: flex; flex-direction: column; align-items: flex-start; gap: 0.1rem; width: 100%; padding: 0.5rem 0.7rem; margin: 0; border-radius: 10px; border: 1px solid var(--htv-line); background: var(--htv-sunk); cursor: pointer; text-align: left; min-width: 0; }
.htv-root .htv-recent-list button:hover { border-color: var(--htv-accent-line); }
.htv-root .htv-recent-name { font-size: 0.85rem; font-weight: 700; color: var(--htv-text-1); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.htv-root .htv-recent-meta { font-size: 0.74rem; color: var(--htv-muted); }

/* page-wide drop overlay */
.htv-root .htv-overlay { position: fixed; inset: 0; z-index: 10004; display: flex; align-items: center; justify-content: center; background: rgba(15, 23, 42, 0.45); pointer-events: none; }
.htv-root .htv-overlay-box { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; padding: 2rem 2.5rem; border-radius: 20px; border: 2px dashed var(--htv-accent); background: var(--htv-card); color: var(--htv-text-1); font-weight: 700; font-size: 1.1rem; }
.htv-root .htv-overlay-box svg { width: 36px; height: 36px; color: var(--htv-accent); }

/* ---------- progress ---------- */
.htv-root .htv-prog { padding: 1rem 1.1rem; }
.htv-root .htv-prog-top { display: flex; align-items: center; gap: 0.9rem; flex-wrap: wrap; }
.htv-root .htv-prog-top .htv-btn { margin-left: auto; }
.htv-root .htv-loader { display: block; width: 40px; height: 40px; flex-shrink: 0; overflow: visible; --cico-outer: #f2534e; --cico-outer-soft: #f8d3d1; --cico-mid: #31ae77; --cico-mid-soft: #d0e7dd; --cico-inner: #2b9edb; }
[data-theme="dark"] .htv-root .htv-loader { --cico-outer-soft: rgba(242, 83, 78, 0.22); --cico-mid-soft: rgba(49, 174, 119, 0.22); }
.htv-root .htv-loader circle { fill: none; stroke-width: 72; transform-box: fill-box; transform-origin: center; }
.htv-root .htv-loader .bp { stroke: var(--cico-outer-soft); }
.htv-root .htv-loader .gp { stroke: var(--cico-mid-soft); }
.htv-root .htv-loader .b { stroke: var(--cico-outer); stroke-linecap: round; stroke-dasharray: 35.3 100; animation: htvSpinL 1.3s linear infinite; }
.htv-root .htv-loader .g { stroke: var(--cico-mid); stroke-linecap: round; stroke-dasharray: 75.8 100; animation: htvSpinR 2.1s linear infinite; }
.htv-root .htv-loader .r { stroke: var(--cico-inner); animation: htvBreathe 1.3s ease-in-out infinite; }
@keyframes htvSpinL { from { transform: rotate(117deg); } to { transform: rotate(-243deg); } }
@keyframes htvSpinR { from { transform: rotate(36deg); } to { transform: rotate(396deg); } }
@keyframes htvBreathe { 50% { transform: scale(0.9); } }
@media (prefers-reduced-motion: reduce) {
    .htv-root .htv-loader .b { animation-duration: 4s; }
    .htv-root .htv-loader .g { animation-duration: 6s; }
    .htv-root .htv-loader .r { animation: none; }
}
.htv-root .htv-stages { display: flex; align-items: center; flex-wrap: wrap; row-gap: 0.4rem; }
.htv-root .htv-stage { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.8rem; font-weight: 700; color: var(--htv-muted); }
.htv-root .htv-dot { display: inline-flex; align-items: center; justify-content: center; padding: 6px; border-radius: 50%; background: var(--htv-card); border: 1px solid var(--htv-line); color: var(--htv-muted); }
.htv-root .htv-dot svg { width: 18px; height: 18px; display: block; }
.htv-root .htv-stage.active { color: var(--htv-text-1); }
.htv-root .htv-stage.active .htv-dot { background: var(--htv-go); border-color: var(--htv-go); color: #fff; }
.htv-root .htv-stage.done .htv-dot { background: #339966; border-color: #339966; color: #fff; }
.htv-root .htv-stage-line { width: 28px; height: 2px; margin: 0 0.5rem; border-radius: 2px; background: var(--htv-line); flex-shrink: 0; }
.htv-root .htv-stage-line.done { background: #339966; }
.htv-root .htv-prog-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.75rem; margin-top: 0.85rem; }
.htv-root .htv-prog-text { font-size: 0.86rem; color: var(--htv-text-2); min-width: 0; overflow-wrap: anywhere; }
.htv-root .htv-prog-pct { font-size: 0.95rem; font-weight: 800; color: var(--htv-text-1); font-variant-numeric: tabular-nums; }
.htv-root .htv-bar { position: relative; height: 8px; margin-top: 0.5rem; border-radius: 999px; background: var(--htv-line); overflow: hidden; }
.htv-root .htv-bar > .htv-bar-fill { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--htv-go); border-radius: 999px; transition: width 0.2s; }

/* ---------- viewer head ---------- */
.htv-root .htv-filehead { display: flex; align-items: center; gap: 0.8rem; flex-wrap: wrap; }
.htv-root .htv-fileicon { width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; background: var(--htv-accent-soft); color: var(--htv-accent); }
.htv-root .htv-fileicon svg { width: 22px; height: 22px; }
.htv-root .htv-filetext { flex: 1 1 220px; min-width: 0; }
.htv-root .htv-filetext strong { display: block; font-size: 1.02rem; color: var(--htv-text-1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.htv-root .htv-filetext span { display: block; font-size: 0.82rem; color: var(--htv-muted); }
.htv-root .htv-badges { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.htv-root .htv-badge { display: inline-flex; align-items: center; gap: 0.35rem; width: auto; margin: 0; padding: 0.25rem 0.7rem; border-radius: 999px; font-size: 0.8rem; font-weight: 700; white-space: nowrap; background: var(--htv-accent-soft); border: 1px solid var(--htv-accent-line); color: var(--htv-accent-strong); cursor: pointer; }
[data-theme="dark"] .htv-root .htv-badge { color: var(--htv-accent); }
.htv-root .htv-badge svg { width: 14px; height: 14px; }
.htv-root .htv-badge.is-plain { cursor: default; background: var(--htv-sunk); border-color: var(--htv-line); color: var(--htv-text-2); }
.htv-root .htv-badge.is-edit { cursor: default; background: rgba(217, 119, 6, 0.1); border-color: rgba(217, 119, 6, 0.4); color: var(--htv-warn); }

/* notes */
.htv-root .htv-notes { display: grid; gap: 0.5rem; margin-top: 0.75rem; }
.htv-root .htv-note { display: flex; gap: 0.6rem; align-items: flex-start; padding: 0.65rem 0.9rem; border-radius: 12px; font-size: 0.86rem; line-height: 1.5; color: var(--htv-text-1); background: rgba(51, 153, 204, 0.08); border: 1px solid rgba(51, 153, 204, 0.3); }
.htv-root .htv-note.is-warn { background: rgba(217, 119, 6, 0.08); border-color: rgba(217, 119, 6, 0.35); }
.htv-root .htv-note > svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; color: var(--htv-accent); }
.htv-root .htv-note.is-warn > svg { color: var(--htv-warn); }
.htv-root .htv-note > div { flex: 1; min-width: 0; }
.htv-root .htv-note p { margin: 0; overflow-wrap: anywhere; }
.htv-root .htv-note a { color: var(--htv-accent-strong); font-weight: 600; }
[data-theme="dark"] .htv-root .htv-note a { color: var(--htv-accent); }
.htv-root .htv-alts { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.45rem; align-items: center; }

/* stats */
.htv-root .htv-stats { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.75rem; }
.htv-root .htv-stat { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.22rem 0.6rem; border-radius: 999px; background: var(--htv-sunk); border: 1px solid var(--htv-line); font-size: 0.78rem; color: var(--htv-text-2); max-width: 100%; }
.htv-root .htv-stat svg { width: 14px; height: 14px; color: var(--htv-accent); flex-shrink: 0; }
.htv-root .htv-stat strong { color: var(--htv-text-1); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.htv-root .htv-stat.is-busy svg { animation: htvSpinR 1.4s linear infinite; }
.htv-root .htv-stat-more { display: none; width: auto; margin: 0; cursor: pointer; font-weight: 700; color: var(--htv-accent-strong); border-style: dashed; }
[data-theme="dark"] .htv-root .htv-stat-more { color: var(--htv-accent); }
.htv-root .htv-search input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; display: none; }

/* ---------- toolbar ---------- */
.htv-root .htv-toolbar { position: relative; display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin-top: 1rem; }
.htv-root .htv-search { flex: 1; min-width: 260px; display: flex; align-items: center; gap: 0.2rem; height: 42px; padding: 0 0.3rem 0 0.7rem; border-radius: 10px; border: 1px solid var(--htv-line); background: var(--input-bg, #fff); box-sizing: border-box; }
.htv-root .htv-search:focus-within { border-color: var(--htv-accent); box-shadow: 0 0 0 3px var(--htv-accent-soft); }
.htv-root .htv-search > svg { width: 16px; height: 16px; color: var(--htv-muted); flex-shrink: 0; }
.htv-root .htv-search input { flex: 1; min-width: 0; width: auto; height: 100%; border: none; background: none; outline: none; box-shadow: none; color: var(--htv-text-1); font-size: 0.9rem; padding: 0 0 0 0.4rem; margin: 0; }
.htv-root .htv-flag { display: inline-flex; align-items: center; justify-content: center; width: auto; min-width: 28px; height: 28px; padding: 0 0.3rem; margin: 0; border: 1px solid transparent; border-radius: 6px; background: none; color: var(--htv-muted); font: 700 0.75rem var(--htv-mono); cursor: pointer; flex-shrink: 0; }
.htv-root .htv-flag svg { width: 15px; height: 15px; }
.htv-root .htv-flag:hover { color: var(--htv-text-1); }
.htv-root .htv-flag[aria-pressed="true"] { border-color: var(--htv-accent); background: var(--htv-accent-soft); color: var(--htv-accent-strong); }
[data-theme="dark"] .htv-root .htv-flag[aria-pressed="true"] { color: var(--htv-accent); }
.htv-root .htv-search-count { font-size: 0.76rem; color: var(--htv-muted); white-space: nowrap; font-variant-numeric: tabular-nums; max-width: 210px; overflow: hidden; text-overflow: ellipsis; }
.htv-root .htv-search-count.is-none { color: var(--htv-red); }
.htv-root .htv-sep { width: 1px; height: 20px; background: var(--htv-line); flex-shrink: 0; }
.htv-root .htv-goto { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; display: flex; align-items: center; gap: 0.4rem; padding: 0.6rem; border-radius: 12px; border: 1px solid var(--htv-line); background: var(--htv-card); box-shadow: 0 10px 30px rgba(15, 23, 42, 0.18); }
.htv-root .htv-goto label { font-size: 0.82rem; font-weight: 700; color: var(--htv-text-2); white-space: nowrap; }
.htv-root .htv-input { width: 150px; height: 36px; padding: 0 0.7rem; margin: 0; border: 1px solid var(--htv-line); border-radius: 9px; background: var(--input-bg, #fff); color: var(--htv-text-1); font: 0.88rem var(--htv-mono); box-sizing: border-box; }
.htv-root .htv-input:focus { outline: none; border-color: var(--htv-accent); box-shadow: 0 0 0 3px var(--htv-accent-soft); }
.htv-root .htv-select { width: 100%; height: 40px; max-width: 100%; min-width: 0; padding: 0 0.6rem; margin: 0; border-radius: 9px; border: 1px solid var(--htv-line); background: var(--input-bg, #fff); color: var(--htv-text-1); font-size: 0.88rem; box-sizing: border-box; }

/* ---------- options (collapsed rows) ---------- */
.htv-root .htv-adv { border: 1px solid var(--htv-line); border-radius: 12px; overflow: hidden; background: var(--htv-card); margin-top: 0.75rem; }
.htv-root .htv-adv-row + .htv-adv-row { border-top: 1px solid var(--htv-line); }
.htv-root .htv-adv-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; width: 100%; min-height: 52px; box-sizing: border-box; padding: 0.55rem 1rem; margin: 0; border: none; background: none; cursor: pointer; text-align: left; color: var(--htv-text-1); font-weight: 400; }
.htv-root .htv-adv-left { display: flex; align-items: center; gap: 0.65rem; min-width: 0; }
.htv-root .htv-adv-left > svg { width: 18px; height: 18px; color: var(--htv-accent); flex-shrink: 0; }
.htv-root .htv-adv-text { display: flex; flex-direction: column; min-width: 0; }
.htv-root .htv-adv-title { font-size: 0.9rem; font-weight: 700; }
.htv-root .htv-adv-hint { font-size: 0.76rem; color: var(--htv-muted); line-height: 1.35; }
.htv-root .htv-adv-right { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }
.htv-root .htv-adv-value { max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0.2rem 0.55rem; border-radius: 999px; background: var(--htv-accent-soft); color: var(--htv-accent-strong); font-size: 0.76rem; font-weight: 700; }
[data-theme="dark"] .htv-root .htv-adv-value { color: var(--htv-accent); }
.htv-root .htv-chevron { width: 17px; height: 17px; color: var(--htv-muted); transition: transform 0.2s; }
.htv-root .htv-adv-row.open .htv-chevron { transform: rotate(180deg); }
.htv-root .htv-adv-row.open .htv-adv-head, .htv-root .htv-adv-row.open .htv-adv-body { background: var(--htv-open); }
.htv-root .htv-adv-body { padding: 0.2rem 1rem 1rem; }
.htv-root .htv-adv-note { margin: 0.5rem 0 0; font-size: 0.78rem; color: var(--htv-muted); line-height: 1.45; }
.htv-root .htv-size { display: inline-flex; align-items: center; gap: 0.35rem; margin-top: 0.5rem; }
.htv-root .htv-size-val { min-width: 48px; text-align: center; font-weight: 800; font-size: 0.86rem; color: var(--htv-text-1); font-variant-numeric: tabular-nums; }
.htv-root .htv-switch-text { font-size: 0.74rem; font-weight: 800; color: var(--htv-muted); min-width: 26px; text-align: right; }
/* switch - beats the global .tool-container checkbox rules */
.tool-container.htv-root input[type="checkbox"].htv-switch {
    -webkit-appearance: none !important; appearance: none !important; position: relative; flex-shrink: 0;
    width: 40px !important; height: 22px !important; margin: 0 !important; padding: 0 !important;
    border: none !important; border-radius: 999px !important; background: #cbd5e1 !important; box-shadow: none !important; cursor: pointer; transition: background 0.2s;
}
[data-theme="dark"] .tool-container.htv-root input[type="checkbox"].htv-switch { background: #475569 !important; }
.tool-container.htv-root input[type="checkbox"].htv-switch::after, .tool-container.htv-root input[type="checkbox"].htv-switch:checked::after {
    content: '' !important; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%;
    background: #fff; transform: none !important; transition: left 0.2s; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2); font-size: 0; line-height: 0; border: none;
}
.tool-container.htv-root input[type="checkbox"].htv-switch:checked { background: var(--htv-go) !important; }
.tool-container.htv-root input[type="checkbox"].htv-switch:checked::after { left: 21px; }
.tool-container.htv-root input[type="checkbox"].htv-switch:focus-visible { outline: 3px solid var(--htv-accent-line); outline-offset: 2px; }

/* ---------- panels (code, preview...) ---------- */
.htv-root .htv-panel { position: relative; margin-top: 0.85rem; border: 1px solid var(--htv-line); border-radius: 14px; overflow: hidden; background: var(--htv-bg); min-width: 0; }
.htv-root .htv-panel.is-full { position: fixed; inset: 10px; z-index: 10000; margin: 0; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35); }
.htv-root .htv-panel.is-full .htv-view, .htv-root .htv-panel.is-full .htv-fill { flex: 1; height: auto; min-height: 0; }
body.htv-noscroll { overflow: hidden; }
.htv-root .htv-full-btn { position: absolute; top: 6px; right: 18px; z-index: 4; display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; padding: 0; margin: 0; border-radius: 8px; border: 1px solid var(--htv-line); background: var(--htv-card); color: var(--htv-text-2); cursor: pointer; opacity: 0.85; }
.htv-root .htv-full-btn:hover { color: var(--htv-text-1); border-color: var(--htv-accent-line); opacity: 1; }
.htv-root .htv-full-btn svg { width: 16px; height: 16px; }

/* ---------- the virtualised code view ---------- */
.htv-root .htv-view {
    --htv-fs: 13px; --htv-rh: 21px; --htv-gd: 3ch;
    position: relative; height: 620px; overflow: auto; outline: none; overscroll-behavior: contain;
    background: var(--htv-bg); color: var(--htv-fg); font-family: var(--htv-mono); font-size: var(--htv-fs); tab-size: 4; -moz-tab-size: 4;
}
.htv-root .htv-view:focus-visible { box-shadow: inset 0 0 0 2px var(--htv-accent-line); }
.htv-root .htv-space { position: relative; min-width: 100%; }
.htv-root .htv-win { position: absolute; top: 0; left: 0; width: max-content; min-width: 100%; will-change: transform; }
.htv-root .htv-l { display: flex; height: var(--htv-rh); line-height: var(--htv-rh); white-space: pre; }
.htv-root .htv-g {
    position: sticky; left: 0; z-index: 1; flex-shrink: 0; display: flex; align-items: center; min-width: calc(var(--htv-gd) + 2.5rem); padding: 0 0.6rem 0 0.15rem; box-sizing: border-box;
    background: var(--htv-gut); color: var(--htv-gut-t); border-right: 1px solid var(--htv-gut-line); user-select: none; -webkit-user-select: none;
    font-family: var(--htv-mono); font-size: 0.85em; font-variant-numeric: tabular-nums;
}
.htv-root .htv-ln { flex: 1; text-align: right; cursor: pointer; }
.htv-root .htv-ln:hover { color: var(--htv-text-1); }
.htv-root .htv-fold, .htv-root .htv-fold-sp { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; margin-right: 0.2rem; flex-shrink: 0; border-radius: 4px; }
.htv-root .htv-fold { cursor: pointer; color: var(--htv-gut-t); opacity: 0.55; }
.htv-root .htv-l:hover .htv-fold, .htv-root .htv-fold.is-closed { opacity: 1; }
.htv-root .htv-fold:hover { background: var(--htv-accent-soft); color: var(--htv-accent); }
.htv-root .htv-fold.is-closed { color: var(--htv-accent); }
.htv-root .htv-fold svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.htv-root .htv-fold-ph { display: inline-block; margin-left: 0.6rem; padding: 0 0.45rem; height: calc(var(--htv-rh) - 6px); line-height: calc(var(--htv-rh) - 6px); border-radius: 5px; background: var(--htv-accent-soft); border: 1px solid var(--htv-accent-line); color: var(--htv-accent-strong); font: 600 0.8em system-ui, sans-serif; cursor: pointer; vertical-align: 1px; }
[data-theme="dark"] .htv-root .htv-fold-ph { color: var(--htv-accent); }
.htv-root .htv-c { padding: 0 1.6rem 0 0.75rem; }
.htv-root .htv-l.is-sel { background: var(--htv-accent-soft); }
.htv-root .htv-l.is-sel .htv-g { background: var(--htv-accent); color: #fff; }
.htv-root .htv-l.is-sel .htv-fold { color: #fff; }
.htv-root .htv-trunc { color: var(--htv-muted); font-style: italic; font-family: system-ui, sans-serif; font-size: 0.82em; }
.htv-root .htv-cc { display: inline-block; padding: 0 2px; border-radius: 3px; background: var(--htv-red-soft); color: var(--htv-red); font-size: 0.8em; line-height: 1.2; }
.htv-root .htv-sw { display: inline-block; width: 0.8em; height: 0.8em; margin-right: 0.3em; border-radius: 3px; border: 1px solid rgba(100, 116, 139, 0.55); vertical-align: -0.05em; box-sizing: border-box; }

/* syntax colours - light */
.htv-root .htv-t-cm { color: #6b7686; font-style: italic; }
.htv-root .htv-t-pu { color: #64748b; }
.htv-root .htv-t-sl, .htv-root .htv-t-tg { color: #1f6f43; font-weight: 600; }
.htv-root .htv-t-cl { color: #a3366f; }
.htv-root .htv-t-id { color: #c23b3b; font-weight: 600; }
.htv-root .htv-t-ps { color: #7c3aed; }
.htv-root .htv-t-at, .htv-root .htv-t-an { color: #a55a10; }
.htv-root .htv-t-ar, .htv-root .htv-t-kw { color: #c23b3b; font-weight: 600; }
.htv-root .htv-t-ak { color: #8a5a00; }
.htv-root .htv-t-pr { color: #1d5fa0; }
.htv-root .htv-t-cv { color: #0e7a7a; }
.htv-root .htv-t-vl { color: #7a3fb0; }
.htv-root .htv-t-nu, .htv-root .htv-t-co { color: #b4500f; }
.htv-root .htv-t-st, .htv-root .htv-t-av, .htv-root .htv-t-ur { color: #18794e; }
.htv-root .htv-t-fn { color: #1d5fa0; font-weight: 600; }
.htv-root .htv-t-im { color: #e64e4e; font-weight: 700; }
.htv-root .htv-t-en { color: #b4500f; }
.htv-root .htv-t-dt { color: #6b7686; font-weight: 600; }
/* syntax colours - dark */
[data-theme="dark"] .htv-root .htv-t-cm { color: #7f8ea3; }
[data-theme="dark"] .htv-root .htv-t-pu { color: #8b9ab0; }
[data-theme="dark"] .htv-root .htv-t-sl, [data-theme="dark"] .htv-root .htv-t-tg { color: #7ee2a8; }
[data-theme="dark"] .htv-root .htv-t-cl { color: #f39ac8; }
[data-theme="dark"] .htv-root .htv-t-id { color: #fca5a5; }
[data-theme="dark"] .htv-root .htv-t-ps { color: #c4b5fd; }
[data-theme="dark"] .htv-root .htv-t-at, [data-theme="dark"] .htv-root .htv-t-an { color: #fbbf77; }
[data-theme="dark"] .htv-root .htv-t-ar, [data-theme="dark"] .htv-root .htv-t-kw { color: #f87171; }
[data-theme="dark"] .htv-root .htv-t-ak { color: #fcd34d; }
[data-theme="dark"] .htv-root .htv-t-pr, [data-theme="dark"] .htv-root .htv-t-fn { color: #7cc4f2; }
[data-theme="dark"] .htv-root .htv-t-cv { color: #5eead4; }
[data-theme="dark"] .htv-root .htv-t-vl { color: #d6a6f5; }
[data-theme="dark"] .htv-root .htv-t-nu, [data-theme="dark"] .htv-root .htv-t-co, [data-theme="dark"] .htv-root .htv-t-en { color: #fdba74; }
[data-theme="dark"] .htv-root .htv-t-st, [data-theme="dark"] .htv-root .htv-t-av, [data-theme="dark"] .htv-root .htv-t-ur { color: #86d8a6; }
[data-theme="dark"] .htv-root .htv-t-im { color: #ff8a8a; }
[data-theme="dark"] .htv-root .htv-t-dt { color: #94a3b8; }

/* search hits */
.htv-root mark.htv-hit { background: var(--htv-hit); color: inherit; border-radius: 2px; padding: 0; }
.htv-root mark.htv-hit.is-cur { background: var(--htv-hit-cur); color: #111; box-shadow: 0 0 0 1px rgba(202, 138, 4, 0.8); }
.htv-root mark.htv-hit.is-cur span { color: #111; }

/* status line under the code */
.htv-root .htv-status { display: flex; justify-content: space-between; gap: 0.5rem 1rem; flex-wrap: wrap; padding: 0.35rem 0.85rem; border-top: 1px solid var(--htv-line); background: var(--htv-sunk); font-size: 0.76rem; color: var(--htv-muted); font-variant-numeric: tabular-nums; }
.htv-root .htv-status span { min-width: 0; overflow-wrap: anywhere; }

/* ---------- view tabs ---------- */
.htv-root .htv-tabs { display: flex; gap: 0.25rem; margin-top: 1rem; padding: 0.25rem; border-radius: 12px; background: var(--htv-sunk); border: 1px solid var(--htv-line); overflow-x: auto; scrollbar-width: thin; }
.htv-root .htv-tab { display: inline-flex; align-items: center; gap: 0.4rem; flex-shrink: 0; width: auto; min-height: 38px; padding: 0.35rem 0.85rem; margin: 0; border: none; border-radius: 9px; background: none; color: var(--htv-text-2); font-size: 0.88rem; font-weight: 700; cursor: pointer; white-space: nowrap; }
.htv-root .htv-tab svg { width: 16px; height: 16px; color: var(--htv-accent); }
.htv-root .htv-tab:hover { color: var(--htv-text-1); }
.htv-root .htv-tab.is-active { background: var(--htv-card); color: var(--htv-accent-strong); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08); }
[data-theme="dark"] .htv-root .htv-tab.is-active { background: #26334a; color: var(--htv-accent); }
.htv-root .htv-tab-n { padding: 0 0.4rem; border-radius: 999px; background: var(--htv-accent-soft); color: var(--htv-accent-strong); font-size: 0.72rem; font-variant-numeric: tabular-nums; }
[data-theme="dark"] .htv-root .htv-tab-n { color: var(--htv-accent); }
.htv-root .htv-tab-n.is-warn { background: rgba(217, 119, 6, 0.12); color: var(--htv-warn); }
.htv-root .htv-tab-n.is-bad { background: var(--htv-red-soft); color: var(--htv-red); }
.htv-root .htv-vpanel { min-width: 0; }

/* segmented control */
.htv-root .htv-segs { display: inline-flex; flex-wrap: wrap; padding: 0.15rem; gap: 0.15rem; border-radius: 9px; background: var(--htv-sunk); border: 1px solid var(--htv-line); max-width: 100%; }
.htv-root .htv-segs button { display: inline-flex; align-items: center; gap: 0.3rem; width: auto; min-height: 32px; padding: 0.15rem 0.65rem; margin: 0; border: none; border-radius: 7px; background: none; color: var(--htv-muted); font-size: 0.82rem; font-weight: 700; cursor: pointer; white-space: nowrap; }
.htv-root .htv-segs button svg { width: 15px; height: 15px; }
.htv-root .htv-segs button:hover:not(:disabled) { color: var(--htv-text-1); }
.htv-root .htv-segs button:disabled { opacity: 0.45; cursor: default; }
.htv-root .htv-segs button.is-active { background: var(--htv-card); color: var(--htv-accent-strong); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08); }
[data-theme="dark"] .htv-root .htv-segs button.is-active { color: var(--htv-accent); background: #26334a; }
.htv-root .htv-seg-sub { font-weight: 600; font-size: 0.74rem; opacity: 0.8; }

/* code toolbar row 2 */
.htv-root .htv-toolbar2 { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.6rem; }
.htv-root .htv-toolbar2 .htv-grow { flex: 1; }
.htv-root .htv-savings { font-size: 0.8rem; color: var(--htv-muted); }
.htv-root .htv-savings strong { color: #237a4f; }
[data-theme="dark"] .htv-root .htv-savings strong { color: #6ee7a8; }

/* ---------- data panels (outline, lists, reports) ---------- */
.htv-root .htv-report { margin-top: 0.85rem; display: grid; gap: 0.85rem; min-width: 0; }
.htv-root .htv-box { border: 1px solid var(--htv-line); border-radius: 14px; background: var(--htv-card); min-width: 0; overflow: hidden; }
.htv-root .htv-box-head { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; padding: 0.7rem 0.95rem; border-bottom: 1px solid var(--htv-line); background: var(--htv-open); }
.htv-root .htv-box-head h3 { display: flex; align-items: center; gap: 0.45rem; margin: 0; font-size: 0.95rem; color: var(--htv-text-1); flex: 1; min-width: 0; }
.htv-root .htv-box-head h3 svg { width: 17px; height: 17px; color: var(--htv-accent); flex-shrink: 0; }
.htv-root .htv-box-head .htv-count { font-weight: 600; color: var(--htv-muted); font-size: 0.82rem; }
.htv-root .htv-box-body { padding: 0.75rem 0.95rem; min-width: 0; }
.htv-root .htv-box-body.is-flush { padding: 0; }
.htv-root .htv-empty { padding: 0.9rem 0.95rem; color: var(--htv-muted); font-size: 0.88rem; }
.htv-root .htv-kv { display: grid; grid-template-columns: minmax(110px, 190px) minmax(0, 1fr); gap: 0; margin: 0; }
.htv-root .htv-kv > dt, .htv-root .htv-kv > dd { margin: 0; padding: 0.5rem 0.95rem; border-bottom: 1px solid var(--htv-line); font-size: 0.86rem; min-width: 0; overflow-wrap: anywhere; }
.htv-root .htv-kv > dt { color: var(--htv-muted); font-weight: 700; }
.htv-root .htv-kv > dd { color: var(--htv-text-1); }
.htv-root .htv-kv > dt:nth-last-child(2), .htv-root .htv-kv > dd:last-child { border-bottom: none; }
.htv-root .htv-tbl-wrap { overflow: auto; max-height: 520px; min-width: 0; }
.htv-root .htv-tbl { width: 100%; border-collapse: collapse; font-size: 0.84rem; margin: 0; }
.htv-root .htv-tbl th, .htv-root .htv-tbl td { padding: 0.45rem 0.75rem; text-align: left; border-bottom: 1px solid var(--htv-line); color: var(--htv-text-2); vertical-align: top; }
.htv-root .htv-tbl th { position: sticky; top: 0; z-index: 1; background: var(--htv-sunk); color: var(--htv-text-1); font-weight: 700; font-size: 0.78rem; white-space: nowrap; }
.htv-root .htv-tbl tr:last-child td { border-bottom: none; }
.htv-root .htv-tbl td.htv-mono, .htv-root .htv-mono { font-family: var(--htv-mono); font-size: 0.82rem; overflow-wrap: anywhere; word-break: break-word; }
.htv-root .htv-tbl td.htv-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.htv-root .htv-tbl tbody tr:hover td { background: var(--htv-accent-soft); }
.htv-root .htv-jump { display: inline; width: auto; padding: 0; margin: 0; border: none; background: none; color: var(--htv-accent-strong); font: inherit; font-weight: 700; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; white-space: nowrap; }
[data-theme="dark"] .htv-root .htv-jump { color: var(--htv-accent); }
.htv-root .htv-tag { display: inline-flex; align-items: center; gap: 0.25rem; padding: 0.05rem 0.45rem; border-radius: 999px; font-size: 0.72rem; font-weight: 700; white-space: nowrap; background: var(--htv-sunk); border: 1px solid var(--htv-line); color: var(--htv-text-2); }
.htv-root .htv-tag.is-ok { background: rgba(51, 153, 102, 0.1); border-color: rgba(51, 153, 102, 0.4); color: #237a4f; }
.htv-root .htv-tag.is-warn { background: rgba(217, 119, 6, 0.1); border-color: rgba(217, 119, 6, 0.4); color: var(--htv-warn); }
.htv-root .htv-tag.is-bad { background: var(--htv-red-soft); border-color: var(--htv-red-line); color: var(--htv-red); }
.htv-root .htv-tag.is-info { background: var(--htv-accent-soft); border-color: var(--htv-accent-line); color: var(--htv-accent-strong); }
[data-theme="dark"] .htv-root .htv-tag.is-ok { color: #6ee7a8; }
[data-theme="dark"] .htv-root .htv-tag.is-info { color: var(--htv-accent); }
.htv-root .htv-filter { display: flex; align-items: center; gap: 0.4rem; flex: 1 1 220px; min-width: 0; max-width: 340px; height: 36px; padding: 0 0.6rem; border-radius: 9px; border: 1px solid var(--htv-line); background: var(--input-bg, #fff); box-sizing: border-box; }
.htv-root .htv-filter svg { width: 15px; height: 15px; color: var(--htv-muted); flex-shrink: 0; }
.htv-root .htv-filter input { flex: 1; min-width: 0; width: auto; height: 100%; border: none; background: none; outline: none; box-shadow: none; padding: 0; margin: 0; color: var(--htv-text-1); font-size: 0.86rem; }
.htv-root .htv-filter:focus-within { border-color: var(--htv-accent); box-shadow: 0 0 0 3px var(--htv-accent-soft); }
.htv-root .htv-more { display: flex; justify-content: center; padding: 0.6rem; border-top: 1px solid var(--htv-line); }
.htv-root .htv-mini-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.5rem; }
.htv-root .htv-ms { padding: 0.65rem 0.8rem; border-radius: 12px; border: 1px solid var(--htv-line); background: var(--htv-open); min-width: 0; }
.htv-root .htv-ms b { display: block; font-size: 1.25rem; color: var(--htv-text-1); font-variant-numeric: tabular-nums; line-height: 1.2; overflow-wrap: anywhere; }
.htv-root .htv-ms span { font-size: 0.78rem; color: var(--htv-muted); font-weight: 600; }
.htv-root .htv-bars { display: grid; gap: 0.35rem; }
.htv-root .htv-bar-row { display: grid; grid-template-columns: minmax(0, 180px) minmax(0, 1fr) 54px; gap: 0.6rem; align-items: center; font-size: 0.82rem; }
.htv-root .htv-bar-row > span:first-child { font-family: var(--htv-mono); color: var(--htv-text-1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.htv-root .htv-bar-row > span:last-child { text-align: right; color: var(--htv-muted); font-variant-numeric: tabular-nums; }
.htv-root .htv-bar-track { height: 8px; border-radius: 999px; background: var(--htv-sunk); overflow: hidden; }
.htv-root .htv-bar-fill { height: 100%; border-radius: 999px; background: var(--htv-accent); }
.htv-root .htv-issue { display: flex; align-items: flex-start; gap: 0.55rem; padding: 0.55rem 0.95rem; border-bottom: 1px solid var(--htv-line); font-size: 0.86rem; color: var(--htv-text-1); min-width: 0; }
.htv-root .htv-issue:last-child { border-bottom: none; }
.htv-root .htv-issue > svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 2px; }
.htv-root .htv-issue.is-e > svg { color: var(--htv-red); }
.htv-root .htv-issue.is-w > svg { color: var(--htv-warn); }
.htv-root .htv-issue.is-i > svg { color: var(--htv-accent); }
.htv-root .htv-issue.is-ok > svg { color: #339966; }
.htv-root .htv-issue > div { flex: 1; min-width: 0; overflow-wrap: anywhere; line-height: 1.5; }
.htv-root .htv-issue small { display: block; color: var(--htv-muted); font-size: 0.8rem; }
.htv-root .htv-issue code { font-size: 0.8em; }

/* action bar */
.htv-root .htv-actionbar { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin-top: 1.1rem; padding-top: 1rem; border-top: 1px solid var(--htv-line); }
.htv-root .htv-actionbar .htv-btn-ghost { min-height: 40px; padding: 0.4rem 0.7rem; font-size: 0.86rem; gap: 0.35rem; }
.htv-root .htv-actionbar .htv-btn-ghost svg { width: 16px; height: 16px; }
.htv-root .htv-actionbar .htv-go { margin-left: auto; }
.htv-root .htv-dl-hint { font-weight: 600; font-size: 0.8rem; opacity: 0.85; }

/* toast */
.htv-root .htv-toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 10003; max-width: calc(100vw - 32px); box-sizing: border-box; padding: 0.55rem 1rem; border-radius: 10px; background: #1e293b; color: #fff; font-size: 0.86rem; font-weight: 600; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25); transition: opacity 0.25s; text-align: center; }
[data-theme="dark"] .htv-root .htv-toast { background: #e2e8f0; color: #0f172a; }
.htv-root .htv-toast.is-out { opacity: 0; }

/* ---------- content ---------- */
.htv-root .htv-info { margin-top: 2rem; display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.25rem; }
.htv-root .htv-info > * { min-width: 0; }
.htv-root .htv-info-card { background: var(--bg-elevated, #fff); border: 1px solid var(--htv-line); border-radius: var(--radius-md, 12px); padding: 1.4rem 1.5rem; }
.htv-root .htv-info-card h2 { display: flex; align-items: center; gap: 0.55rem; margin: 0 0 0.9rem; font-size: 1.25rem; color: var(--htv-text-1); }
.htv-root .htv-info-card h2 svg { width: 22px; height: 22px; color: var(--htv-accent); flex-shrink: 0; }
.htv-root .htv-info-card h3 { margin: 1.2rem 0 0.5rem; font-size: 1.05rem; color: var(--htv-text-1); }
.htv-root .htv-info-card p, .htv-root .htv-info-card li { color: var(--htv-text-2); line-height: 1.65; font-size: 0.97rem; }
.htv-root .htv-info-card p { margin: 0.8rem 0 0; }
.htv-root .htv-info-card h2 + p { margin-top: 0; }
.htv-root .htv-info a { color: var(--htv-accent-strong); font-weight: 500; }
[data-theme="dark"] .htv-root .htv-info a { color: var(--htv-accent); }
.htv-root .htv-steps, .htv-root .htv-list { margin: 0; padding-left: 1.3rem; display: grid; gap: 0.45rem; }
.htv-root .htv-features { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; }
.htv-root .htv-feature { padding: 0.9rem 1rem; border-radius: 12px; border: 1px solid var(--htv-line); background: var(--htv-open); min-width: 0; }
.htv-root .htv-feature > svg { width: 20px; height: 20px; color: var(--htv-accent); }
.htv-root .htv-info-card .htv-feature h3 { margin: 0.35rem 0 0.2rem; font-size: 0.95rem; }
.htv-root .htv-info-card .htv-feature p { margin: 0; font-size: 0.88rem; line-height: 1.55; }
.htv-root .htv-table-wrap { overflow-x: auto; border: 1px solid var(--htv-line); border-radius: 10px; margin-top: 0.9rem; }
.htv-root .htv-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; min-width: 520px; margin: 0; }
.htv-root .htv-table th, .htv-root .htv-table td { padding: 0.6rem 0.8rem; text-align: left; border-bottom: 1px solid var(--htv-line); color: var(--htv-text-2); vertical-align: top; }
.htv-root .htv-table th { background: var(--htv-sunk); color: var(--htv-text-1); font-weight: 700; font-size: 0.82rem; }
.htv-root .htv-table tr:last-child td { border-bottom: none; }
.htv-root .htv-table td:first-child { font-weight: 700; color: var(--htv-text-1); white-space: nowrap; }
.htv-root .htv-keys { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.4rem 1rem; margin-top: 0.9rem; padding: 0; list-style: none; }
.htv-root .htv-keys li { display: flex; justify-content: space-between; gap: 0.6rem; padding: 0.35rem 0.6rem; border-radius: 8px; background: var(--htv-open); font-size: 0.88rem; min-width: 0; }
.htv-root .htv-keys li span:last-child { text-align: right; white-space: nowrap; }
.htv-root .htv-faq .faq-question svg { width: 18px; height: 18px; flex-shrink: 0; }

/* ---------- responsive ---------- */
@media (max-width: 760px) {
    .htv-root .htv-search { flex-basis: 100%; min-width: 0; }
}
@media (max-width: 600px) {
    .htv-root.tool-container { padding: 1.1rem 16px; }
    .htv-root .tool-title { font-size: 1.55rem; }
    .htv-root .htv-title-icon { width: 46px; height: 46px; border-radius: 13px; }
    .htv-root .htv-title-icon svg { width: 25px; height: 25px; }
    .htv-root .tool-description { font-size: 0.98rem; }
    .htv-root .htv-card { padding: 1rem; border-radius: 16px; }
    .htv-root .htv-drop { min-height: 150px; }
    .htv-root .htv-kbd-hint { display: none; }
    .htv-root .htv-input-bar .htv-go { flex: 1 1 100%; }
    .htv-root .htv-input-bar .htv-btn-ghost { flex: 1; }
    .htv-root .htv-search-count { max-width: 92px; }
    .htv-root .htv-search { gap: 0.05rem; padding-left: 0.55rem; }
    .htv-root .htv-search .htv-sep { display: none; }
    .htv-root .htv-flag { min-width: 26px; padding: 0 0.15rem; }
    .htv-root .htv-stats:not(.is-open) .htv-stat:nth-child(n+5):not(.htv-stat-more) { display: none; }
    .htv-root .htv-stat-more { display: inline-flex; }
    .htv-root .htv-toolbar > .htv-btn { flex: 1; }
    .htv-root .htv-goto { left: 0; right: auto; flex-wrap: wrap; }
    .htv-root .htv-adv-head { padding: 0.55rem 0.75rem; }
    .htv-root .htv-adv-hint { display: none; }
    .htv-root .htv-adv-value { max-width: 110px; }
    .htv-root .htv-quick-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .htv-root .htv-view, .htv-root .htv-editor { height: 470px; }
    .htv-root .htv-c { padding-right: 0.9rem; }
    .htv-root .htv-actionbar .htv-go { flex: 1 1 100%; margin-left: 0; order: -1; }
    .htv-root .htv-actionbar .htv-btn-ghost { flex: 1 1 calc(33% - 0.5rem); padding: 0.45rem 0.4rem; }
    .htv-root .htv-recent-list { grid-template-columns: minmax(0, 1fr); }
    .htv-root .htv-features, .htv-root .htv-keys { grid-template-columns: minmax(0, 1fr); }
    .htv-root .htv-info-card { padding: 1.1rem; }
    .htv-root .htv-stage .htv-lbl { display: none; }
    .htv-root .htv-stage-line { width: 20px; margin: 0 0.3rem; }
    .htv-root .htv-panel.is-full { inset: 0; border-radius: 0; }
}

/* print: only the text (#htvPrintBox is added to <body> while printing) */
#htvPrintBox { display: none; }
@media print {
    body.htv-printing > *:not(#htvPrintBox) { display: none !important; }
    body.htv-printing #htvPrintBox { display: block !important; color: #000; background: #fff; }
    #htvPrintBox h1 { margin: 0 0 10px; font: 600 13px system-ui, sans-serif; }
    #htvPrintBox pre { margin: 0; white-space: pre-wrap; word-break: break-word; font: 11px/1.45 ui-monospace, Consolas, monospace; tab-size: 4; }
}

/* ---------- HTML viewer: tool-specific parts ---------- */
.htv-root .htv-two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.85rem; min-width: 0; }
.htv-root .htv-two > * { min-width: 0; }
.htv-root .htv-font-list { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.htv-root .htv-inline-switch { display: inline-flex; align-items: center; gap: 0.45rem; font-size: 0.84rem; color: var(--htv-text-2); cursor: pointer; margin: 0; white-space: nowrap; }
.htv-root .htv-inline-switch strong { color: var(--htv-text-1); }

/* preview */
.htv-root .htv-pv-bar { display: flex; align-items: center; gap: 0.5rem 0.9rem; flex-wrap: wrap; margin-top: 0.85rem; }
.htv-root .htv-pv-bar .htv-grow { flex: 1; }
.htv-root .htv-pv-stage { display: block; overflow: auto; height: 680px; background: var(--htv-sunk); }
.htv-root .htv-pv-stage iframe { display: block; height: 100%; width: 100%; border: 0; background: #fff; margin: 0 auto; }
.htv-root .htv-pv-stage.is-narrow { padding: 0.6rem; box-sizing: border-box; }
.htv-root .htv-pv-stage.is-narrow iframe { border-radius: 10px; box-shadow: 0 2px 12px rgba(15, 23, 42, 0.15); }
.htv-root .htv-pv-note { margin: 0; padding: 0.45rem 0.85rem; border-top: 1px solid var(--htv-line); background: var(--htv-sunk); font-size: 0.78rem; color: var(--htv-muted); line-height: 1.5; min-height: 2.6em; box-sizing: border-box; }
.htv-root .htv-pv-note .htv-jump { font-weight: 700; }
.htv-root .htv-panel.is-full .htv-pv-stage { flex: 1; height: auto; min-height: 0; }
.htv-root .htv-pv-big { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.75rem; height: 100%; padding: 1.5rem; text-align: center; color: var(--htv-text-2); font-size: 0.92rem; }
.htv-root .htv-pv-big p { margin: 0; max-width: 460px; }
.htv-root .htv-base { display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; margin-top: 0.5rem; }
.htv-root .htv-base .htv-input { flex: 1 1 260px; width: auto; min-width: 0; }
.htv-root .htv-base-suggest { margin: 0.5rem 0 0; font-size: 0.8rem; color: var(--htv-muted); overflow-wrap: anywhere; }

/* split view: code and preview side by side */
.htv-root .htv-views.is-split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 0.85rem; align-items: start; }
.htv-root .htv-views.is-split > .htv-vpanel[data-panel="code"] { order: 1; }
.htv-root .htv-views.is-split > .htv-vpanel[data-panel="preview"] { order: 2; }
.htv-root .htv-views.is-split .htv-search { min-width: 0; flex-basis: 100%; }
.htv-root .htv-views.is-split .htv-view, .htv-root .htv-views.is-split .htv-pv-stage { height: 640px; }
.htv-root .htv-views.is-split .htv-pv-bar .htv-segs button span { display: none; }

/* SEO */
.htv-root .htv-serp { display: flex; flex-direction: column; gap: 0.15rem; padding: 0.95rem 1.1rem; border: 1px solid var(--htv-line); border-radius: 14px; background: var(--htv-card); min-width: 0; }
.htv-root .htv-serp-url { font-size: 0.8rem; color: #4d5156; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.htv-root .htv-serp-title { font-size: 1.15rem; color: #1a0dab; line-height: 1.3; overflow-wrap: anywhere; }
.htv-root .htv-serp-desc { font-size: 0.86rem; color: #4d5156; line-height: 1.5; overflow-wrap: anywhere; }
.htv-root .htv-serp-note { margin-top: 0.35rem; font-size: 0.72rem; color: var(--htv-muted); }
[data-theme="dark"] .htv-root .htv-serp-url, [data-theme="dark"] .htv-root .htv-serp-desc { color: #bdc1c6; }
[data-theme="dark"] .htv-root .htv-serp-title { color: #8ab4f8; }
.htv-root .htv-heads { list-style: none; margin: 0; padding: 0.35rem 0; max-height: 520px; overflow: auto; }
.htv-root .htv-heads li { display: flex; align-items: baseline; gap: 0.45rem; padding: 0.3rem 0.95rem; font-size: 0.86rem; color: var(--htv-text-1); min-width: 0; }
.htv-root .htv-head-t { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.htv-root .htv-res-type { display: inline-flex; align-items: center; gap: 0.35rem; font-weight: 700; color: var(--htv-text-1); text-transform: capitalize; white-space: nowrap; }
.htv-root .htv-res-type svg { width: 15px; height: 15px; color: var(--htv-accent); }

/* DOM tree */
.htv-root .htv-tree { list-style: none; margin: 0; padding: 0.4rem 0; max-height: 620px; overflow: auto; font-family: var(--htv-mono); font-size: 0.82rem; }
.htv-root .htv-tree li { padding: 0 0.95rem 0 calc(0.6rem + var(--d, 0) * 1.05rem); min-width: 0; }
.htv-root .htv-tree li:hover { background: var(--htv-accent-soft); }
.htv-root .htv-ol-row { display: flex; align-items: center; gap: 0.3rem; min-height: 26px; min-width: 0; }
.htv-root .htv-ol-lbl { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.htv-root .htv-ol-tog, .htv-root .htv-ol-sp { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; flex-shrink: 0; padding: 0; margin: 0; border: none; border-radius: 5px; background: none; color: var(--htv-muted); cursor: pointer; }
.htv-root .htv-ol-tog:hover { background: var(--htv-accent-soft); color: var(--htv-accent); }
.htv-root .htv-ol-tog svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; transition: transform 0.15s; }
.htv-root .htv-ol-tog.is-open svg { transform: rotate(90deg); }
.htv-root .htv-ol-text { color: var(--htv-muted); font-family: system-ui, sans-serif; }
.htv-root .htv-ol-n { font-size: 0.74rem; font-family: system-ui, sans-serif; }
.htv-root .htv-ol-more { color: var(--htv-muted); font-style: italic; padding-top: 0.3rem; padding-bottom: 0.3rem; }
.htv-root .htv-tree .htv-jump, .htv-root .htv-find-list .htv-jump { font-family: system-ui, sans-serif; font-size: 0.76rem; margin-left: auto; padding-left: 0.4rem; }
.htv-root .htv-find { border-bottom: 1px solid var(--htv-line); background: var(--htv-open); }
.htv-root .htv-find-head { padding: 0.45rem 0.95rem; font-size: 0.8rem; font-weight: 700; color: var(--htv-text-2); }
.htv-root .htv-find-list { list-style: none; margin: 0; padding: 0 0 0.4rem; max-height: 260px; overflow: auto; font-family: var(--htv-mono); font-size: 0.82rem; }
.htv-root .htv-find-list li { display: flex; align-items: center; gap: 0.4rem; padding: 0.2rem 0.95rem; min-width: 0; }

@media (max-width: 900px) {
    .htv-root .htv-views.is-split { grid-template-columns: minmax(0, 1fr); }
    .htv-root .htv-views.is-split .htv-view, .htv-root .htv-views.is-split .htv-pv-stage { height: 460px; }
}
@media (max-width: 760px) {
    .htv-root .htv-two { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 600px) {
    .htv-root .htv-pv-stage { height: 560px; }
    .htv-root .htv-pv-bar .htv-segs button span { display: none; }
    .htv-root .htv-box-head .htv-filter { max-width: none; flex: 1 1 100%; }
    .htv-root .htv-kv { grid-template-columns: minmax(0, 1fr); }
    .htv-root .htv-kv > dt { padding-bottom: 0; border-bottom: none; }
}
