/*
 * Engine Combustion Lab — minimalist dark theme.
 * One neutral palette, one accent (orange) for primary actions and active state, flat surfaces, quiet headings.
 */
:root {
  --bg: #0b0e13; --surface: #10141a; --surface-2: #151a21; --surface-3: #1b212a;
  --line: rgba(255, 255, 255, 0.06); --line2: rgba(255, 255, 255, 0.11);
  --text: #e7eaef; --muted: #8a94a3; --dim: #5f6876;
  --accent: #f28c28; --accent2: #f6a552; --accent-soft: rgba(242, 140, 40, 0.14);
  --info: #6cb4ff; --cyan: var(--info); --ok: #3ecf8e; --warn: #f2b84b; --bad: #f2606f;
  --panel: var(--surface); --glass: var(--surface);
  --mono: "Cascadia Mono", Consolas, "SF Mono", monospace;
  --hdr: 48px; --r: 8px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 13px/1.45 "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif; overflow: hidden; -webkit-font-smoothing: antialiased; }
button, select, input, textarea { font: inherit; color: var(--text); }
button { background: transparent; border: 1px solid var(--line2); border-radius: 6px; padding: 6px 12px; cursor: pointer; transition: background .12s, border-color .12s, color .12s; }
button:hover { background: var(--surface-3); border-color: rgba(255, 255, 255, 0.18); }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #1b1006; font-weight: 600; }
button.primary:hover { background: var(--accent2); border-color: var(--accent2); }
button.ghost { border-color: transparent; }
button.icon { padding: 6px 9px; }
button.round { width: 34px; height: 34px; border-radius: 50%; padding: 0; background: var(--accent); border: none; color: #1b1006; font-size: 12px; font-weight: 700; }
button.round:hover { background: var(--accent2); }
select, input[type=number], input[type=text], #paramSearch { background: var(--surface-2); border: 1px solid var(--line2); border-radius: 6px; padding: 5px 8px; outline: none; }
select option { background: var(--surface-2); }
select:focus, input:focus, textarea:focus { border-color: var(--info); }
:focus-visible { outline: 2px solid var(--info); outline-offset: 1px; }
.hidden { display: none !important; }
h2, h3, h4 { font-weight: 600; }

/* ---------- top bar ---------- */
.topbar { height: var(--hdr); display: flex; align-items: center; gap: 8px; padding: 0 14px; background: var(--surface); border-bottom: 1px solid var(--line); position: relative; z-index: 20; }
.brand { display: flex; align-items: center; gap: 9px; font-size: 14px; font-weight: 600; white-space: nowrap; margin-right: 6px; }
.brand b { color: var(--accent); font-weight: 600; }
.logo { width: 16px; height: 16px; border-radius: 50%; background: var(--accent); }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 7px; padding: 2px; gap: 2px; }
.seg button { border: none; background: transparent; padding: 4px 11px; border-radius: 5px; color: var(--muted); }
.seg button:hover { color: var(--text); background: transparent; }
.seg button.on { background: var(--surface-3); color: var(--text); }
.seg.full { display: flex; margin: 12px; }
.seg.full button { flex: 1; }
.seg.small button { padding: 4px 6px; font-size: 12px; }
.preset { max-width: 240px; }
.spacer { flex: 1; }
.status { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; white-space: nowrap; margin-right: 6px; min-width: 0; }
#statusText { overflow: hidden; text-overflow: ellipsis; max-width: 300px; }
.status .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.status.busy .dot { background: var(--warn); animation: pulse 0.8s infinite alternate; }
.status.err .dot { background: var(--bad); }
@keyframes pulse { to { opacity: .3; } }
.menu { position: relative; }
.pop { position: absolute; right: 0; top: 38px; background: var(--surface-2); border: 1px solid var(--line2); border-radius: var(--r); padding: 4px; display: flex; flex-direction: column; min-width: 190px; box-shadow: 0 12px 28px rgba(0, 0, 0, .45); }
.pop button { border: none; text-align: left; border-radius: 5px; }
.pop hr { border: none; border-top: 1px solid var(--line); margin: 4px 0; }
.pop a { display: block; padding: 6px 12px; border-radius: 5px; color: var(--muted); text-decoration: none; }
.pop a:hover { background: var(--surface-3); color: var(--text); }
.pro-legal { font-size: 11.5px; color: var(--dim); margin: 6px 0 0; }
.pro-legal a { color: var(--muted); }
#btnCompare.on, #btnHeadLab.on { background: var(--accent-soft); border-color: rgba(242, 140, 40, 0.45); color: var(--accent2); }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: 300px minmax(0, 1fr) 330px; height: calc(100% - var(--hdr)); }
.panel { background: var(--surface); display: flex; flex-direction: column; min-height: 0; }
#left { border-right: 1px solid var(--line); }
#right { border-left: 1px solid var(--line); }
.scroll { overflow-y: auto; flex: 1; min-height: 0; }
.scroll::-webkit-scrollbar, .cmp-body::-webkit-scrollbar { width: 8px; }
.scroll::-webkit-scrollbar-thumb, .cmp-body::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 4px; }

/* ---------- parameter rows ---------- */
.search { position: sticky; top: 0; padding: 0 12px 10px; background: var(--surface); z-index: 2; }
#paramSearch { width: 100%; }
details.grp { border-top: 1px solid var(--line); }
details.grp > summary { padding: 11px 14px; cursor: pointer; font-weight: 500; color: var(--text); list-style: none; display: flex; justify-content: space-between; }
details.grp > summary::-webkit-details-marker { display: none; }
details.grp > summary::after { content: '+'; color: var(--dim); }
details.grp[open] > summary::after { content: '−'; }
.prow { padding: 6px 14px 4px; }
.prow .ph { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.prow .pl { color: #c4cad3; font-size: 12.5px; }
.prow .pv { display: flex; align-items: baseline; gap: 4px; }
.prow .pv input { width: 66px; text-align: right; padding: 1px 4px; font: 12px var(--mono); background: transparent; border: 1px solid transparent; }
.prow .pv input:hover, .prow .pv input:focus { border-color: var(--line2); background: var(--surface-2); }
.prow .u { color: var(--dim); font-size: 11px; min-width: 26px; }
.prow input[type=range] { width: 100%; -webkit-appearance: none; appearance: none; height: 3px; border-radius: 2px; background: linear-gradient(90deg, var(--accent) var(--fill, 50%), var(--surface-3) var(--fill, 50%)); outline: none; margin: 7px 0 3px; }
.prow input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px; border-radius: 50%; background: var(--text); border: none; cursor: pointer; }
.prow input[type=range]::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--text); border: none; cursor: pointer; }
.prow.changed .pl { color: var(--accent2); }
.prow.changed .pl::after { content: ' •'; color: var(--accent); }
.prow.hidden { display: none; }
.qsec { margin: 18px 14px 4px; color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.derived { margin: 8px 14px 14px; padding: 9px 11px; border-radius: var(--r); background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); font: 11.5px/1.65 var(--mono); }
.derived b { color: var(--text); font-weight: 600; }
.derived b.bad { color: var(--bad); }
.fuelrow { padding: 6px 14px; }
.fuelrow select { width: 100%; }

/* ---------- stage ---------- */
#stage { display: flex; flex-direction: column; min-width: 0; min-height: 0; height: 100%; overflow: hidden; }
#viewport { position: relative; flex: 1; min-height: 0; overflow: hidden; background: radial-gradient(ellipse at 50% 35%, #151b24 0%, #0d1117 60%, #0a0d11 100%); }
#v3d, #v2d { position: absolute; top: 0; bottom: 0; }
#viewport.mode-3d #v3d { left: 0; right: 0; } #viewport.mode-3d #v2d { display: none; }
#viewport.mode-2d #v2d { left: 0; right: 0; } #viewport.mode-2d #v3d { display: none; }
#viewport.mode-split #v3d { left: 0; right: 50%; } #viewport.mode-split #v2d { left: 50%; right: 0; border-left: 1px solid var(--line2); }
#viewport.mode-2d #viewTools [data-cam], #viewport.mode-2d #btnSpin, #viewport.mode-2d #housing, #viewport.mode-2d #cylShow { display: none; }
#engine { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: crosshair; }
#v3d canvas { cursor: grab; }
#v3d canvas:active { cursor: grabbing; }
.ov { position: absolute; z-index: 5; }
.ov.tl { left: 12px; top: 12px; pointer-events: none; }
.ov.tc { left: 50%; bottom: 76px; transform: translateX(-50%); display: flex; gap: 6px; pointer-events: none; }
.ov.tr { right: 12px; top: 12px; }
.ov.bl { left: 16px; top: 138px; pointer-events: none; font: 10px var(--mono); color: var(--muted); }
#viewport.charts-open #kpis { display: none; }
#legend .bar { width: 160px; height: 6px; border-radius: 3px; margin: 4px 0 2px; }
.glass { background: rgba(16, 20, 26, 0.88); border: 1px solid var(--line2); border-radius: var(--r); }
#viewTools { padding: 8px; display: flex; flex-direction: column; gap: 6px; width: 190px; }
.vt-row { display: flex; gap: 4px; }
.vt-row button { flex: 1; padding: 4px 0; font-size: 13px; }
.vt-row #btnFit, .vt-row #btnFocus { font-size: 12px; }
.vt-row select { width: 100%; font-size: 12px; }
#btnSpin.on, #btnFocus.on { background: var(--surface-3); border-color: var(--info); }
.vt-chk { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }

.kpi { min-width: 88px; padding: 6px 10px 5px; text-align: center; }
.kpi .kv1 { font: 600 17px/1.15 "Segoe UI Variable Display", "Segoe UI", system-ui; color: var(--text); }
.kpi .kv1 small { font-size: 11px; color: var(--muted); font-weight: 400; margin-left: 2px; }
.kpi .kl { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.kpi.bad { border-color: rgba(242, 96, 111, .5); }
.kpi.bad .kv1 { color: var(--bad); }
.kpi.good .kv1 { color: var(--ok); }

.alarm { position: absolute; left: 50%; top: 80px; transform: translateX(-50%); z-index: 8; background: rgba(170, 30, 42, 0.92); color: #fff; font-weight: 600; padding: 8px 16px; border-radius: var(--r); pointer-events: none; text-align: center; }
.tooltip { position: absolute; z-index: 9; pointer-events: none; padding: 8px 10px; border-radius: var(--r); background: rgba(11, 14, 19, 0.94); border: 1px solid var(--line2); font: 11.5px/1.5 var(--mono); white-space: pre; color: var(--text); }
.tooltip b { color: var(--accent2); font-family: "Segoe UI", system-ui; font-size: 12.5px; }

#playbar { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 6; display: flex; gap: 8px; align-items: center; padding: 8px 12px; width: min(820px, calc(100% - 28px)); }
.scrubwrap { flex: 1; position: relative; padding-bottom: 14px; }
#scrub { width: 100%; -webkit-appearance: none; appearance: none; height: 4px; border-radius: 2px; outline: none;
  background: linear-gradient(90deg, rgba(242, 140, 40, .7) 0 25%, rgba(200, 100, 100, .6) 25% 50%, rgba(108, 180, 255, .7) 50% 75%, rgba(160, 130, 240, .65) 75% 100%); }
#scrub::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: var(--text); border: none; cursor: pointer; }
.phases { position: absolute; left: 0; right: 0; bottom: -4px; display: flex; }
.phases button { flex: 1; border: none; background: transparent; padding: 0; font-size: 10px; color: var(--dim); border-radius: 4px; }
.phases button:hover { color: var(--text); background: transparent; }
.phases button.active { color: var(--text); font-weight: 600; }
#angleIn { width: 66px; font-family: var(--mono); }
#btnCharts.on { background: var(--surface-3); border-color: var(--info); }

#chartWrap { height: clamp(190px, 33vh, 310px); display: flex; flex-direction: column; background: var(--surface); border-top: 1px solid var(--line2); }
#chartWrap.collapsed { height: 0; border-top: none; overflow: hidden; }
#tabs { display: flex; gap: 2px; padding: 6px 10px 0; overflow-x: auto; flex-shrink: 0; }
#tabs::-webkit-scrollbar { height: 4px; } #tabs::-webkit-scrollbar-thumb { background: var(--surface-3); }
#tabs button { border: none; border-radius: 6px 6px 0 0; padding: 5px 11px; color: var(--muted); white-space: nowrap; font-size: 12px; }
#tabs button.on { background: var(--surface-2); color: var(--text); box-shadow: inset 0 2px 0 var(--accent); }
#chartBox { flex: 1; position: relative; min-height: 0; }
#chart { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

body.focus-mode .layout { grid-template-columns: 0 1fr 0; }
body.focus-mode #left, body.focus-mode #right { visibility: hidden; overflow: hidden; }

/* ---------- right inspector ---------- */
#right .scroll { padding: 0 12px 14px; }
#right h4 { margin: 18px 2px 8px; font-size: 11px; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; }
.badge { display: inline-block; min-width: 16px; padding: 0 4px; border-radius: 8px; background: var(--bad); color: #fff; font-size: 10px; line-height: 16px; }
.rstate { margin: 2px 2px 10px; font-size: 11.5px; color: var(--muted); }
#overview[data-stale="true"] .rstate { color: var(--warn); }
#overview[data-stale="true"] #kpiGrid { opacity: .55; }
#health { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 10px; }
.hchip { border-radius: var(--r); padding: 7px 6px; text-align: center; font-size: 11px; color: var(--muted); background: var(--surface-2); border: 1px solid var(--line); }
.hchip b { display: block; font-size: 13px; margin-top: 1px; font-weight: 600; }
.hchip.ok b { color: var(--ok); } .hchip.warn b { color: var(--warn); } .hchip.bad b { color: var(--bad); }
.hchip.bad { border-color: rgba(242, 96, 111, .4); }
.kgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.kcard { border-radius: var(--r); padding: 9px 11px; background: var(--surface-2); border: 1px solid var(--line); }
.kcard .l { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.kcard .v { font: 600 17px/1.25 "Segoe UI Variable Display", "Segoe UI", system-ui; color: var(--text); }
.kcard .v small { font-size: 11px; color: var(--muted); font-weight: 400; margin-left: 2px; }
.kcard .s { font-size: 11px; color: var(--dim); }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 3px 10px; font-size: 12px; }
.kv .k { color: var(--muted); }
.kv .v { font-family: var(--mono); text-align: right; color: var(--text); }
.kv .sec { grid-column: 1 / 3; color: var(--muted); font-weight: 600; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; margin-top: 12px; padding-bottom: 3px; border-bottom: 1px solid var(--line); }
.v.good { color: var(--ok); } .v.warn { color: var(--warn); } .v.bad { color: var(--bad); }
details.more { margin-top: 12px; border-top: 1px solid var(--line); }
details.more > summary { cursor: pointer; padding: 9px 2px; color: var(--text); font-weight: 500; }
table.mini { width: 100%; border-collapse: collapse; font-size: 11.5px; margin-top: 8px; }
table.mini th { text-align: left; color: var(--muted); font-weight: 500; padding: 4px 3px; border-bottom: 1px solid var(--line); }
table.mini td { padding: 4px 3px; font-family: var(--mono); border-bottom: 1px solid var(--line); }
table.mini td.l { font-family: inherit; color: #c4cad3; }
.st { font-weight: 600; } .st.ok { color: var(--ok); } .st.warn { color: var(--warn); } .st.bad { color: var(--bad); }
#warnings div { padding: 7px 10px; border-left: 2px solid var(--warn); margin-bottom: 6px; color: #e9dcc0; background: var(--surface-2); border-radius: 0 6px 6px 0; font-size: 12px; }
#warnings div.bad { border-color: var(--bad); color: #f1c9ce; }
#warnings div.ok { border-color: var(--ok); color: #bfe7d4; }
.tag { font-size: 10.5px; padding: 1px 6px; border-radius: 4px; background: var(--surface-3); color: var(--info); font-weight: 400; }
.tag.bad { background: rgba(242, 96, 111, .14); color: var(--bad); }

.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal-box { padding: 20px 22px; min-width: 380px; max-width: 560px; background: var(--surface); border: 1px solid var(--line2); border-radius: 10px; }
.modal-box h3 { margin-top: 0; font-size: 15px; }
.modal-actions { margin-top: 16px; display: flex; gap: 8px; justify-content: flex-end; }
.progress { height: 6px; background: var(--surface-3); border-radius: 3px; overflow: hidden; margin: 10px 0; }
.progress > div { height: 100%; background: var(--accent); width: 0; transition: width 0.2s; }

@media (max-width: 1300px) { .layout { grid-template-columns: 270px minmax(0, 1fr) 300px; } #statusText { display: none; } .preset { max-width: 180px; } .kpi { min-width: 84px; } .kpi .kv1 { font-size: 15px; } }
@media (max-width: 1450px) { .ov.tc .kpi:nth-child(n+6) { display: none; } }
@media (max-width: 1250px) { .ov.tc .kpi:nth-child(n+5) { display: none; } #viewTools { width: 160px; } }

/* ---------- sweeps: job bar, forms ---------- */
.jobbar { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--accent2); white-space: nowrap; }
.jobbar #btnCancelJob { padding: 3px 9px; }
.progress.mini { width: 90px; height: 4px; margin: 0; }
.formerr { color: #f1a7b0; font-size: 12px; min-height: 0; margin: 4px 0; }
.formerr:empty { display: none; }
.hint { color: var(--muted); font-size: 12px; margin: 4px 0; }
.hint.good { color: #9ddcbe; } .hint.bad { color: #f1a7b0; }
.warn { color: var(--warn); }
.modal-box .kv input[type=number] { width: 90px; }
.modal-box fieldset { border: 1px solid var(--line2); border-radius: var(--r); margin: 10px 0 0; padding: 6px 10px 8px; }
.modal-box fieldset label { display: block; margin: 3px 0; }
.modal-box legend { color: var(--muted); font-size: 11.5px; padding: 0 4px; }
.modal-box .scrollbox { max-height: 38vh; overflow: auto; margin-top: 8px; }
.modal-box p { margin: 6px 0; }
#kpis.stale { opacity: .45; }
ul.scope { margin: 0 0 8px; padding-left: 18px; color: var(--muted); font-size: 12px; }
ul.scope li { margin-bottom: 5px; }
ul.scope b { color: var(--text); }

/* ---------- full-screen workspaces (Compare, Head Lab) ---------- */
.cmp { position: fixed; left: 0; right: 0; top: var(--hdr); bottom: 0; z-index: 30; background: var(--bg); display: flex; flex-direction: column; --base-c: #6cb4ff; --mod-c: #f6a552; }
.cmp-head { display: flex; align-items: center; gap: 8px; padding: 10px 18px; border-bottom: 1px solid var(--line); background: var(--surface); flex-wrap: wrap; }
.cmp-head h2 { margin: 0 6px 0 0; font-size: 15px; }
.cmp-sub { color: var(--muted); font-size: 12px; }
.cmp-body { flex: 1; overflow: auto; padding: 16px 18px 28px; }
.cmp-notice { padding: 8px 12px; border-radius: 6px; margin-bottom: 12px; border-left: 2px solid var(--ok); background: var(--surface-2); }
.cmp-notice.warn { border-color: var(--warn); color: #e9dcc0; }
.cmp-notice.bad { border-color: var(--bad); color: #f1c9ce; }
.cmp-session { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.cmp-session label { color: var(--muted); }
.cmp-session #cmpSessionName { width: 200px; } .cmp-session #cmpSessionNotes { flex: 1; min-width: 200px; }
.cmp-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.cmp-card { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; background: var(--surface); min-width: 0; }
.cmp-card.base { box-shadow: inset 0 2px 0 var(--base-c); } .cmp-card.mod { box-shadow: inset 0 2px 0 var(--mod-c); }
.cmp-card header { display: flex; align-items: center; gap: 8px; }
.cmp-card h3 { margin: 0; font-size: 14px; flex: 1; }
.swatch { display: inline-block; width: 14px; height: 3px; border-radius: 2px; vertical-align: middle; margin: 0 4px 0 8px; }
.swatch.base { background: var(--base-c); } .swatch.mod { background: var(--mod-c); } .swatch.knock { width: 7px; height: 7px; border-radius: 50%; background: var(--bad); }
.chip { font-size: 11px; padding: 2px 8px; border-radius: 10px; background: var(--surface-3); color: var(--muted); display: inline-block; }
.chip.ok { color: var(--ok); } .chip.warn { color: var(--warn); } .chip.bad { color: var(--bad); } .chip.busy { color: var(--info); }
.cmp-card .fld { display: block; margin: 10px 0 0; color: var(--muted); }
.cmp-card .fld input, .cmp-card .fld textarea { display: block; width: 100%; margin-top: 3px; background: var(--surface-2); border: 1px solid var(--line2); border-radius: 6px; padding: 5px 8px; color: var(--text); resize: vertical; }
.cmp-cond { border: 1px solid var(--line); border-radius: var(--r); margin: 12px 0 0; padding: 8px 12px 10px; display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; }
.cmp-cond legend { color: var(--muted); font-size: 11.5px; padding: 0 4px; }
.cmp-cond input[type=number] { width: 78px; }
.cmp-cond .fixedgrid, .cmp-cond .hint { flex-basis: 100%; }
.cmp-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.cmp-progress { display: flex; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.cmp-progress .progress { flex: 1; min-width: 120px; margin: 0; }
.cmp-progress span { color: var(--info); font-size: 12px; }
.cmp-name { font-size: 14px; font-weight: 600; margin-top: 6px; }
.cmp-note { color: #c4cad3; font-size: 12px; white-space: pre-wrap; margin: 2px 0 4px; }
.cmp-kv { margin: 8px 0; }
.cmp-kv .v { white-space: normal; }
.cmp-empty { color: var(--muted); text-align: center; padding: 16px; }
.cmp-empty:empty { display: none; }
.cmp-problems { margin: 14px 0; padding: 10px 14px; border-left: 2px solid var(--bad); background: var(--surface-2); border-radius: 0 6px 6px 0; color: #f1c9ce; }
.cmp-problems ul { margin: 0 0 8px; padding-left: 18px; }
.cmp-problems button { margin: 2px 6px 2px 0; }
.cmp-sec { margin-top: 22px; }
.cmp-sec h3 { margin: 0 0 8px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; display: flex; align-items: center; gap: 10px; }
.cmp-sec h3 select { text-transform: none; letter-spacing: 0; font-size: 12px; }
.cmp-band { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.cmp-legend { font-size: 11.5px; color: var(--muted); margin-bottom: 6px; }
.cmp-chart { position: relative; height: clamp(220px, 34vh, 360px); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface); }
.cmp-chart canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.cmp-table { border-collapse: collapse; width: 100%; font-size: 12px; }
.cmp-table th, .cmp-table td { padding: 5px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.cmp-table td { font-family: var(--mono); }
.cmp-table thead th { color: var(--muted); font-weight: 500; }
.cmp-table tbody th { font-weight: 400; color: #c4cad3; }
.cmp-table .b { color: #a8cff8; } .cmp-table .m { color: #f8cf9d; }
.cmp-table thead th.b { box-shadow: inset 0 -2px 0 var(--base-c); } .cmp-table thead th.m { box-shadow: inset 0 -2px 0 var(--mod-c); }
.cmp-table tr.diff th, .cmp-table tr.diff td { background: rgba(242, 184, 75, .06); }
.cmp-table tr.diff th { color: var(--warn); }
.cmp-table small, .cmp-table .sub { color: var(--muted); font-size: 11px; }
.cmp-table.pts td, .cmp-table.pts th { text-align: right; white-space: nowrap; }
.cmp-scroll { overflow-x: auto; }
.cmp-concerns { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.cmp-concern { border-left: 2px solid var(--base-c); padding: 2px 12px; }
.cmp-concern.mod { border-color: var(--mod-c); }
.cmp-concern h4 { margin: 0 0 4px; font-size: 12.5px; }
.cmp-concern ul { margin: 0; padding-left: 18px; font-size: 12px; color: #e9dcc0; }
.cmp-scope { color: var(--dim); font-size: 12px; margin-top: 22px; border-top: 1px solid var(--line); padding-top: 10px; }
details.about { margin-top: 10px; color: var(--muted); font-size: 12px; }
details.about > summary { cursor: pointer; color: var(--muted); list-style: none; display: inline-flex; gap: 6px; align-items: center; }
details.about > summary::-webkit-details-marker { display: none; }
details.about > summary::before { content: 'ⓘ'; color: var(--dim); }
details.about[open] > summary { color: var(--text); }
details.about p { margin: 6px 0 0; line-height: 1.55; }

@media (max-width: 900px) {
  html, body { overflow: auto; }
  .topbar { height: auto; min-height: var(--hdr); flex-wrap: wrap; padding: 6px 10px; gap: 6px; }
  .brand > span:last-child, .status #statusText { display: none; }
  .preset { max-width: 130px; }
  .layout { display: flex; flex-direction: column; height: auto; }
  #stage { height: 70vh; }
  #left, #right { max-height: 60vh; }
  .cmp { top: 0; }
  .cmp-cards, .cmp-concerns { grid-template-columns: 1fr; }
  .modal-box { min-width: 0; width: calc(100% - 24px); }
}

/* ---------- head layout & plug boxes (parameter panel) ---------- */
.headbox { margin: 8px 14px 10px; padding: 10px 12px; border-radius: var(--r); background: var(--surface-2); border: 1px solid var(--line); }
.headbox .hb-title { color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; margin-bottom: 6px; }
.headbox .hb-chk { display: flex; gap: 6px; align-items: center; color: #c4cad3; margin-bottom: 6px; }
.headbox .hb-row { display: block; color: var(--muted); margin-bottom: 6px; }
.headbox .hb-row select { display: block; width: 100%; margin-top: 3px; font-size: 12px; }
.headbox button { padding: 4px 10px; font-size: 12px; }

/* ---------- Head Lab ---------- */
.hl-grid { display: grid; grid-template-columns: minmax(250px, 300px) 1fr minmax(240px, 300px); gap: 18px; align-items: start; }
.hl-col h3 { margin: 0 0 8px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.hl-col h3:not(:first-child) { margin-top: 18px; }
.hl-in { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; align-items: center; padding: 4px 0; border-bottom: 1px solid var(--line); }
.hl-in .hl-l { color: #c4cad3; font-size: 12px; }
.hl-in .hl-v { display: flex; align-items: baseline; gap: 4px; }
.hl-in input { width: 74px; text-align: right; font: 12px var(--mono); }
.hl-in .u { color: var(--dim); font-size: 11px; min-width: 22px; }
.hl-in.changed .hl-l { color: var(--accent2); }
.hl-in .hl-stock { grid-column: 1 / 3; color: var(--info); font-size: 11px; text-align: right; }
.hl-in select { font-size: 12px; }
.hl-canvas { position: relative; height: clamp(300px, 52vh, 560px); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.hl-canvas canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hl-controls { display: flex; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.hl-controls input[type=range] { flex: 1; min-width: 140px; accent-color: var(--accent); }
.hl-loss { display: grid; grid-template-columns: 1fr 90px 38px; gap: 8px; align-items: center; font-size: 12px; color: #c4cad3; margin-top: 4px; }
.hl-loss .bar { height: 4px; background: var(--surface-3); border-radius: 2px; overflow: hidden; }
.hl-loss .bar > div { height: 100%; background: var(--accent); }
.hl-loss b { font: 11.5px var(--mono); text-align: right; font-weight: 500; }
.hl-losses { margin-top: 12px; }
#hlReadout .v.bad, #hlTable td.bad { color: var(--bad); }
#hlTable { margin-top: 12px; }
@media (max-width: 1100px) { .hl-grid { grid-template-columns: 1fr; } }

.hl-workspaces { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; padding: 8px 18px; background: var(--surface); border-bottom: 1px solid var(--line); }
.hl-workspaces button { border-color: transparent; color: var(--muted); }
.hl-workspaces button.on { background: var(--surface-3); color: var(--text); }
.hl-viewbar button.on, .hc-toolbar button.on { background: var(--surface-3); color: var(--text); }
.hl-workspaces > span { margin-left: auto; color: var(--dim); font-size: 11.5px; }
.hl .cmp-body { min-height: 0; }
.hl-viewbar, .hc-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.hl-viewbar > span { color: var(--dim); font-size: 11px; }
.hl-visuals, .hc-visuals { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; min-width: 0; }
.hl-three, .hc-visuals > div, .hl-visuals > .hl-canvas { position: relative; height: clamp(320px, 52vh, 580px); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #0d1117; }
.hl-three canvas, #hcThree canvas, .hc-section canvas { width: 100%; height: 100%; display: block; }
.hc-section canvas { position: absolute; inset: 0; }
.view-3d, .view-2d, .view-cfd { grid-template-columns: minmax(0, 1fr); }
.view-3d > :last-child, .view-2d > :first-child, .view-cfd > :first-child { display: none; }
#hlCfdStatus { font-size: 11.5px; color: var(--muted); margin: 8px 2px 0; }
.hc-key { margin-left: auto; display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 12px; }
.hc-key i { width: 16px; height: 3px; display: inline-block; border-radius: 2px; }
.hc-key .intake { background: #56c9ff; } .hc-key .exhaust { background: #ffad6e; } .hc-key .reverse { background: #ff6da9; }
.hc-playback { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 10px 12px; margin-top: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.hc-playback input[type=range] { flex: 1; min-width: 140px; accent-color: var(--accent); }
.hc-playback output { color: var(--text); min-width: 60px; font: 13px var(--mono); }
.hc-result { color: var(--muted); font-size: 12px; padding: 6px 10px; border-left: 2px solid var(--info); }
.hc-metrics { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; margin: 12px 0 18px; }
.hc-metrics > div { padding: 10px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.hc-metrics span { display: block; color: var(--muted); font-size: 11px; margin-bottom: 5px; }
.hc-metrics b { display: block; font: 12.5px var(--mono); color: var(--text); font-weight: 500; }
.hc-bottom { display: grid; grid-template-columns: minmax(270px, 0.85fr) minmax(0, 1.7fr); gap: 22px; }
.hc h3 { margin: 0 0 8px; color: var(--muted); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.hc details { border: 1px solid var(--line); border-radius: var(--r); padding: 8px 10px; margin: 8px 0; }
.hc summary { cursor: pointer; color: var(--text); }
.hc .hl-in { padding: 5px 0; }
.hc-analysis .cmp-chart { margin-bottom: 10px; }
.hc-analysis h3:not(:first-child) { margin-top: 20px; }
.hc-analysis details p { color: var(--muted); font-size: 12px; }
.hc-alerts { color: #e9dcc0; padding-left: 20px; }
.hv-grid { display: grid; grid-template-columns: minmax(260px, 1fr) minmax(0, 1.7fr); gap: 22px; }
.hv-grid label { display: block; color: var(--muted); margin: 8px 0 4px; }
.hv-grid input[type=text], .hv-grid textarea { width: 100%; background: var(--surface-2); color: var(--text); border: 1px solid var(--line2); border-radius: 6px; padding: 8px; font: 12px var(--mono); }
.hv-grid textarea { resize: vertical; }
#hlValidationState { color: var(--muted); border-left: 2px solid var(--info); padding: 7px 10px; }
#hlValidationSummary { margin-bottom: 8px; color: #c4cad3; }
@media (max-width: 720px) { .hv-grid { grid-template-columns: minmax(0, 1fr); } }
.hc input[aria-invalid=true], .hl input[aria-invalid=true] { border-color: var(--bad); outline-color: var(--bad); }
@media (min-width: 1101px) { .hl-grid { grid-template-columns: 230px minmax(0, 1fr) 240px; } }
@media (max-width: 1100px) { .hl-anim { order: -1; } .hc-metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 720px) {
  .hl-workspaces { padding: 8px; } .hl-workspaces > span { margin-left: 0; }
  .hl-visuals, .hc-visuals { grid-template-columns: minmax(0, 1fr); }
  .hl-three, .hc-visuals > div, .hl-visuals > .hl-canvas { height: 320px; }
  .hc-key { margin-left: 0; flex-basis: 100%; }
  .hc-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hc-bottom { grid-template-columns: minmax(0, 1fr); }
  .hc-playback { gap: 7px; padding: 8px; } .hc-playback input[type=range] { min-width: 100px; }
}

/* medium screens: keep the top bar on one line, give the stage room */
@media (max-width: 1100px) and (min-width: 901px) {
  .layout { grid-template-columns: 250px minmax(0, 1fr) 270px; }
  .brand > span:last-child { display: none; }
  .topbar button { padding: 5px 9px; }
  .ov.tc .kpi:nth-child(n+4) { display: none; }
  #btnStepB, #btnStepF, #angleIn, .phases { display: none; }
  .scrubwrap { padding-bottom: 0; }
  #viewTools { width: 150px; }
}

/* ---------- choices, tables, configuration-dependent rows */
.prow.off, details.grp.off, .qsec.off { display: none; }
.prow.choice .pv select { max-width: 190px; font-size: 12px; padding: 2px 4px; background: var(--surface-2); color: var(--text); border: 1px solid var(--line2); border-radius: 6px; }
.prow.choice { padding-bottom: 8px; }
.tblwrap { padding: 6px 14px 10px; display: flex; flex-direction: column; gap: 8px; }
.tblwrap > button { align-self: flex-start; }
.curveprev { width: 100%; height: 90px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); }
.ptable { border-collapse: collapse; font: 11px var(--mono); width: 100%; }
.ptable th { color: var(--muted); font-weight: 500; text-align: right; padding: 2px 4px; white-space: nowrap; }
.ptable td { padding: 1px 2px; }
.ptable input { width: 100%; min-width: 44px; box-sizing: border-box; text-align: right; padding: 1px 3px; font: 11px var(--mono); background: transparent; color: var(--text); border: 1px solid var(--line); border-radius: 4px; }
.ptable input:focus { border-color: var(--accent); background: var(--surface-2); outline: none; }
.ptable.map input { min-width: 40px; }
.mapscroll { overflow: auto; max-height: 360px; border: 1px solid var(--line); border-radius: var(--r); }
.mapscroll .ptable th:first-child { position: sticky; left: 0; background: var(--surface); }
.mapscroll .ptable tr:first-child th { position: sticky; top: 0; background: var(--surface); }
#warnings div.info { border-color: var(--info); color: #cfe3fb; }

.kv.kv-wide { grid-template-columns: max-content 1fr; column-gap: 16px; }

.prow.crtool .crrow { display: flex; gap: 6px; margin: 6px 0 2px; }
.prow.crtool .crrow input { width: 64px; text-align: right; font: 12px var(--mono); background: var(--surface-2); color: var(--text); border: 1px solid var(--line2); border-radius: 6px; padding: 2px 4px; }
.prow.crtool .crrow select { flex: 1; min-width: 0; font-size: 12px; background: var(--surface-2); color: var(--text); border: 1px solid var(--line2); border-radius: 6px; }
.prow.crtool .crNow { font: 600 13px var(--mono); color: var(--accent2); }

/* ---------- Pro unlock ---------- */
.pro-ico { width: 14px; height: 14px; flex: none; }
.pro-btn { display: inline-flex; align-items: center; gap: 6px; border-color: rgba(242, 140, 40, 0.55); background: var(--accent-soft); color: var(--accent2); font-weight: 600; }
.pro-btn:hover { background: rgba(242, 140, 40, 0.24); border-color: var(--accent); }
.pro-btn.on { background: transparent; border-color: var(--line2); color: var(--text); font-weight: 500; }
.pro-btn.on .pro-ico { color: var(--ok); }
/* small lock tag on locked features */
.pro-lock::after {
  content: 'PRO'; display: inline-block; margin-left: 7px; padding: 1px 5px 1px 15px; border-radius: 999px;
  border: 1px solid rgba(242, 140, 40, 0.45); background: var(--accent-soft) no-repeat 4px 50% / 8px 8px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Crect x='1.5' y='4.5' width='7' height='5' rx='1' fill='%23f6a552'/%3E%3Cpath d='M3 4.5V3a2 2 0 0 1 4 0v1.5' fill='none' stroke='%23f6a552' stroke-width='1.2'/%3E%3C/svg%3E");
  color: var(--accent2); font-size: 9px; font-weight: 700; letter-spacing: .06em; line-height: 13px; vertical-align: 1px;
}
/* dialog */
.modal-box.pro-modal { width: min(760px, calc(100vw - 32px)); max-width: none; max-height: calc(100vh - 32px); overflow-y: auto; padding: 0 0 18px; }
.pro-modal #modalBody { padding: 0 24px; }
.pro-modal .modal-actions { padding: 0 24px; margin-top: 8px; }
.pro-hero { margin: 0 -24px 14px; padding: 22px 24px 16px; border-bottom: 1px solid var(--line); background: radial-gradient(120% 140% at 0% 0%, rgba(242, 140, 40, 0.16), transparent 60%); border-radius: 10px 10px 0 0; }
.pro-eyebrow { font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--accent2); font-weight: 600; }
.pro-hero h3 { margin: 4px 0 2px; font-size: 20px; }
.pro-sub { margin: 0; color: var(--muted); }
.pro-note { margin: 0 0 12px; padding: 8px 12px; border-radius: var(--r); border: 1px solid var(--line2); background: var(--surface-2); font-size: 12.5px; }
.pro-note.ok { border-color: rgba(62, 207, 142, 0.4); color: #bfe7d4; }
.pro-note.err { border-color: rgba(242, 96, 111, 0.4); color: #f1a7b0; }
.pro-note.lock { border-color: rgba(242, 140, 40, 0.4); }
.pro-highlights { list-style: none; margin: 0 0 14px; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.pro-highlights li { display: flex; gap: 8px; align-items: flex-start; }
.pro-highlights .pro-ico { color: var(--accent); margin-top: 2px; }
.pro-highlights b { display: block; font-size: 12.5px; }
.pro-highlights span { display: block; color: var(--muted); font-size: 11.5px; line-height: 1.4; }
.pro-plans { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 0 0 12px; }
.pro-plan { position: relative; display: flex; flex-direction: column; padding: 14px; border: 1px solid var(--line2); border-radius: 10px; background: var(--surface-2); }
.pro-plan.best { border-color: var(--accent); background: linear-gradient(180deg, rgba(242, 140, 40, 0.10), var(--surface-2) 55%); }
.pro-ribbon { position: absolute; top: -9px; right: 12px; padding: 1px 8px; border-radius: 999px; background: var(--accent); color: #1b1006; font-size: 10px; font-weight: 700; letter-spacing: .04em; }
.pro-plan-name { font-weight: 600; }
.pro-plan-price { margin: 6px 0 2px; }
.pro-plan-price span { font-size: 24px; font-weight: 700; letter-spacing: -.01em; }
.pro-plan-price small { color: var(--muted); font-size: 11.5px; }
.pro-plan-blurb { color: var(--muted); font-size: 11.5px; }
.pro-plan ul { list-style: none; margin: 10px 0 14px; padding: 0; flex: 1; }
.pro-plan li { display: flex; align-items: center; gap: 6px; font-size: 12px; margin: 4px 0; }
.pro-plan li .pro-ico { color: var(--ok); width: 12px; height: 12px; }
.pro-plan button { width: 100%; }
.pro-pay { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.pro-pay .hint { margin: 0; }
.pro-chip { font-size: 11px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line2); background: var(--surface-3); }
.pro-secure { margin-left: auto !important; }
.pro-restore { padding-top: 12px; border-top: 1px solid var(--line); }
.pro-restore label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.pro-coderow { display: flex; gap: 8px; align-items: center; }
.pro-coderow input { flex: 1; min-width: 0; font-family: var(--mono); }
.pro-status { margin: 0 0 14px; padding: 12px 14px; border-radius: 10px; border: 1px solid rgba(62, 207, 142, 0.35); background: rgba(62, 207, 142, 0.06); }
.pro-status-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pro-status-head .pro-ico { color: var(--ok); }
.pro-pill { font-size: 11px; padding: 1px 8px; border-radius: 999px; background: var(--surface-3); }
.pro-exp { color: var(--muted); font-size: 12px; margin-left: auto; }
.pro-codebox { margin-top: 10px; }
.pro-codebox .hint { display: block; margin: 0 0 6px; }
.pro-code { flex: 1; min-width: 0; padding: 6px 10px; border-radius: 6px; background: var(--surface-3); font-family: var(--mono); font-size: 12.5px; word-break: break-all; user-select: all; }
@media (max-width: 720px) { .pro-plans, .pro-highlights { grid-template-columns: 1fr; } }
/* ---------- ad slot (js/ads.js), bottom of the right panel, hidden for Pro ---------- */
.ad-wrap { flex: none; border-top: 1px solid var(--line); padding: 6px 12px 10px; background: var(--surface); }
.ad-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.ad-head span { font-size: 9.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--dim); }
.ad-remove { border: none; padding: 0; font-size: 11px; color: var(--accent2); background: none; }
.ad-remove:hover { background: none; text-decoration: underline; }
.ad-slot { height: 100px; overflow: hidden; border-radius: 6px; }
.ad-unit { display: block; width: 100%; height: 100px; }
.ad-house { height: 100%; display: flex; align-items: center; gap: 10px; padding: 0 12px; border: 1px dashed rgba(242, 140, 40, 0.35); border-radius: 6px; background: radial-gradient(120% 140% at 0% 0%, rgba(242, 140, 40, 0.10), transparent 60%); }
.ad-house > div { flex: 1; min-width: 0; }
.ad-house b { display: block; font-size: 12.5px; }
.ad-house span { display: block; color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.ad-house button { white-space: nowrap; }
