.vkh.vkh-thermal {
    --th-night: #111827;
    --th-night-line: #374359;
    --th-night-ink: #f5f6fc;
    --th-night-muted: #b9c8dd;
    --th-ember: #ffbd71;
    --th-scene-height: clamp(14.25rem, 28vw, 24rem);
}

.vkh-thermal .vkh-th-hero {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 1.5rem;
    padding-block: clamp(1.35rem, 3vw, 2.5rem);
}
.vkh-thermal .vkh-th-hero h1 { max-width: none; font-size: clamp(2rem, 4.3vw, 3.6rem); }
.vkh-thermal .vkh-th-hero .vkh-lead { max-width: 58ch; }
.vkh-th-hero-aside {
    display: grid;
    gap: .55rem;
    padding: .9rem 1rem;
    border-inline-start: 2px solid var(--vkh-accent);
    color: var(--vkh-accent);
    font-size: .69rem;
    font-weight: 750;
    letter-spacing: .06em;
}

.vkh-th-mode-bar { display: flex; flex-wrap: wrap; gap: .5rem; margin-block: 1.2rem .75rem; }
.vkh-thermal .vkh-th-mode-bar [aria-pressed="true"] {
    border-color: var(--vkh-accent);
    background: var(--vkh-accent);
    color: var(--vkh-on-accent);
}
.vkh-th-workbench {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(15rem, .45fr);
    gap: .85rem;
    align-items: start;
}
.vkh-th-stage, .vkh-th-panel {
    min-width: 0;
    border: 1px solid var(--vkh-line);
    border-radius: 12px;
    background: var(--vkh-surface);
}
.vkh-th-stage {
    overflow: hidden;
    border-color: var(--th-night-line);
    background: radial-gradient(ellipse at 50% 76%, #242b3d 0%, transparent 70%), var(--th-night);
    color: var(--th-night-ink);
}
.vkh-th-stage-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .45rem .8rem;
    padding: clamp(.85rem, 2vw, 1.25rem) clamp(.8rem, 2.4vw, 1.5rem) 0;
}
.vkh-thermal .vkh-th-stage-head h2 { color: var(--th-night-ink); font-size: clamp(1.12rem, 2.3vw, 1.6rem); }
.vkh-thermal .vkh-th-stage-label {
    margin-block-end: .2rem;
    color: var(--th-ember);
    font-size: .67rem;
    font-weight: 750;
    letter-spacing: .08em;
}
.vkh-thermal .vkh-th-stage-head .vkh-button {
    padding-inline: .7rem;
    border-color: var(--th-night-line);
    background: #1e293a;
    color: var(--th-night-ink);
    font-size: .8rem;
}
.vkh-thermal .vkh-th-stage-head .vkh-button:is(:hover, :focus-visible, [aria-pressed="true"]) { border-color: var(--th-ember); }
.vkh-thermal .vkh-th-stage-head .vkh-button:focus-visible { outline-color: var(--th-ember); }
.vkh-th-display, .vkh-th-render-options, .vkh-th-presets > div {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
}
.vkh-th-display {
    align-items: center;
    justify-content: space-between;
    margin: .7rem clamp(.8rem, 2.4vw, 1.5rem) 0;
    padding: .32rem;
    border: 1px solid var(--th-night-line);
    border-radius: 9px;
    background: #0e1624;
}
.vkh-thermal .vkh-th-display .vkh-button {
    padding-inline: .68rem;
    border-color: transparent;
    background: #192536;
    color: var(--th-night-ink);
    font-size: .8rem;
}
.vkh-thermal .vkh-th-display .vkh-button:is(:hover, :focus-visible) { border-color: var(--th-ember); }
.vkh-thermal .vkh-th-display [data-th-render="materials"][aria-pressed="true"] { border-color: #84a8ed; background: #273a59; }
.vkh-thermal .vkh-th-display [data-th-render="flir"][aria-pressed="true"] { border-color: #c78dd6; background: #45274c; }
.vkh-thermal .vkh-th-display [data-th-particles][aria-pressed="true"]:enabled { border-color: #886039; color: var(--th-ember); }
.vkh-thermal .vkh-th-display [data-th-particles]:disabled { opacity: .52; cursor: default; }
.vkh-th-scene, .vkh-th-chart { display: block; width: 100%; max-width: 100%; }
.vkh-th-scene { height: var(--th-scene-height); }
.vkh-th-stage-footer {
    min-height: 3.1rem;
    padding: .65rem clamp(.8rem, 2.4vw, 1.5rem);
    border-top: 1px solid var(--th-night-line);
    background: #141c2b;
}
.vkh-thermal .vkh-th-stage-note, .vkh-th-thermal-key { color: var(--th-night-muted); font-size: .82rem; }
.vkh-thermal [data-th-canvas-fallback] { min-block-size: var(--th-scene-height); align-content: center; padding: 1rem; }
.vkh-th-rod-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem .75rem; }
.vkh-th-thermal-key { display: flex; flex-wrap: wrap; align-items: center; gap: .32rem .6rem; }
.vkh-th-spectrum {
    width: clamp(3rem, 15vw, 8rem);
    height: .47rem;
    border-radius: 1rem;
    background: linear-gradient(90deg, #191e4a, #522c8c 24%, #b23387 49%, #ec5d4c 72%, #ffab4d 89%, #fff3c1);
}

.vkh-th-panel { padding: clamp(.85rem, 2vw, 1.25rem); }
.vkh-thermal .vkh-th-panel h2 { font-size: clamp(1.22rem, 2.4vw, 1.7rem); }
.vkh-th-fields { display: grid; gap: .7rem; margin-block-start: .75rem; }
.vkh-th-presets { display: grid; gap: .3rem; }
.vkh-thermal .vkh-th-presets .vkh-button { font-size: .77rem; padding-inline: .52rem; }
.vkh-thermal .vkh-th-presets [aria-pressed="true"] {
    border-color: var(--vkh-accent);
    background: var(--vkh-tint);
    color: var(--vkh-ink);
}
.vkh-th-playback { display: flex; flex-wrap: wrap; gap: .45rem; }
.vkh-thermal [data-th-play] { min-width: 6.4rem; }
.vkh-thermal .vkh-th-field {
    display: grid;
    min-width: 0;
    gap: .26rem;
    margin: 0;
    color: var(--vkh-ink);
    font-size: .85rem;
    line-height: 1.45;
}
.vkh-th-field > span { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .12rem .45rem; }
.vkh-th-field b { font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--vkh-accent); }
.vkh-thermal .vkh-th-field :is(select, input[type="range"]) { width: 100%; margin: 0; }
.vkh-thermal .vkh-th-field select {
    min-height: 44px;
    padding-inline: .55rem 1.5rem;
    border: 1px solid var(--vkh-line);
    border-radius: 7px;
    background-color: var(--vkh-field);
    color: var(--vkh-ink);
    font: inherit;
}
.vkh-thermal .vkh-th-field input[type="range"] {
    min-height: 33px;
    padding: 0;
    border: 0;
    background: transparent;
    accent-color: var(--vkh-accent);
    cursor: pointer;
}
.vkh-thermal .vkh-th-note { font-size: .85rem; line-height: 1.5; }
.vkh-thermal [data-th-fallback] { margin-block: 1rem; }
.vkh-thermal [data-th-fallback] a { color: var(--vkh-accent); text-decoration: underline; }

/* Keep the real responsive layout in flow while the footer script starts.
   Without scripting the original compact fallback and sources stay available. */
@media (scripting: enabled) {
    .vkh-thermal .vkh-th-startup { position: relative; }
    .vkh-thermal [data-th-fallback] {
        position: absolute;
        inset-inline-start: 0;
        inset-block-start: .4rem;
        z-index: 1;
    }
    .vkh-thermal [data-th-fallback] span { display: none; }
    .vkh-thermal [data-th-interactive][hidden] { display: block !important; visibility: hidden; }
    .vkh-thermal [data-th-interactive][hidden] [data-th-visual-controls][hidden] { display: flex !important; }
    .vkh-thermal [data-th-value]:empty { min-block-size: 1lh; }
    /* Measure a typical reading in the actual card width, including wrapping. */
    .vkh-thermal [data-th-properties]:empty::before { content: "k 000 W/(m·K) · α 000 mm²/s\A Flujo en la sonda · 0 kW/m²"; visibility: hidden; }
    :lang(en) .vkh-thermal [data-th-properties]:empty::before { content: "k 000 W/(m·K) · α 000 mm²/s\A Heat flux at probe · 0 kW/m²"; }

    /* Browsers with inert CSS can show the initial labels and panel before
       activation, while keeping the inactive controls out of the tab order. */
    @supports (interactivity: inert) {
        .vkh-thermal [data-th-interactive][hidden] { interactivity: inert; visibility: visible; }
        .vkh-thermal [data-th-interactive][hidden] .vkh-th-mode-bar { visibility: hidden; }
    }
}
@media (scripting: enabled) and (prefers-reduced-motion: reduce) {
    .vkh-thermal [data-th-interactive][hidden] [data-th-speed-control] { display: none; }
    .vkh-thermal [data-th-interactive][hidden] [data-th-motion][hidden] { display: block !important; }
    .vkh-thermal [data-th-interactive][hidden] .vkh-th-playback { visibility: hidden; }
}

.vkh-th-results { margin-block-start: .85rem; }
.vkh-th-chart-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .35rem 1rem; margin-block: .85rem .55rem; }
.vkh-thermal .vkh-th-chart-head h3 { margin: 0; font-size: clamp(1.05rem, 2vw, 1.35rem); }
.vkh-th-chart { height: 15rem; border-radius: 8px; background: var(--th-night); }
.vkh-th-readings { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 9rem), 1fr)); gap: .6rem; margin-block-start: .75rem; }
.vkh-th-reading {
    min-width: 0;
    padding: .65rem .55rem;
    border: 1px solid var(--vkh-line);
    border-radius: 8px;
    background: var(--vkh-field);
}
.vkh-thermal .vkh-th-slot-label { justify-content: start; align-items: center; font-weight: 700; }
.vkh-th-slot-label > span { padding: .14rem .31rem; border-radius: 3px; background: var(--th-slot, #91b4ff); color: #111827; font-size: .68rem; line-height: 1.2; font-variant-numeric: tabular-nums; }
.vkh-thermal .vkh-th-reading select { background-color: var(--vkh-surface); }
.vkh-thermal .vkh-th-value { margin-block-start: .42rem; color: var(--vkh-ink); font-weight: 750; font-size: 1.08rem; font-variant-numeric: tabular-nums; }
.vkh-thermal .vkh-th-metadata { font-size: .78rem; line-height: 1.45; white-space: pre-line; }

.vkh-th-method { margin-block-start: .85rem; }
.vkh-th-method summary { cursor: pointer; color: var(--vkh-accent); font-weight: 720; }
.vkh-th-method-body { display: grid; gap: .7rem; margin-block-start: .75rem; }
.vkh-th-sources { margin: 0; padding-inline-start: 1.3rem; font-size: .88rem; }
.vkh-th-sources a { color: var(--vkh-accent); text-decoration: underline; text-underline-offset: .16em; }

@media (max-width: 55rem) {
    .vkh-th-workbench { grid-template-columns: minmax(0, 1fr); }
    .vkh-th-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 1rem; }
    .vkh-th-fields > .vkh-th-note, .vkh-th-presets { grid-column: 1 / -1; }
}

@media (max-width: 40rem) {
    .vkh-thermal .vkh-th-hero { grid-template-columns: minmax(0, 1fr); }
    .vkh-th-hero-aside { display: none; }
    .vkh-th-fields { grid-template-columns: minmax(0, 1fr); }
    .vkh-th-readings { grid-template-columns: repeat(auto-fit, minmax(min(100%, 7.75rem), 1fr)); }
}
