/* LeonSim Workbench on the Pro shell (pro.css): the title bar with the case picker and the job, the command ribbon,
   the simulation tree (each stage with its state, as in an Ansys project schematic) over the properties on the left,
   the 3D view with its heads-up toolbar, view cube, triad and scale, the output dock under it (log, estimate, runs,
   files, warnings, as STAR-CCM+ docks its output and plots), reports and the scene on the right, and the status bar.
   style.css still draws the result widgets (KPI groups, pills, tables, legend); this file sets their tokens and
   restyles them for the graphite shell.  On phones the view comes first and the panels become tabs under it. */
:root:root:root {                      /* wins over style.css's light/dark tokens */
  color-scheme: dark;
  --chrome: #16181b; --panel: #1d2024; --panel-2: #23272c; --well: #121417; --line: #2c3036; --line-2: #3a3f46;
  --ink: #e6e9ed; --ink-2: #b4bac2; --muted: #7d858f;
  --accent: #4ea1ff; --accent-ink: #fff; --accent-soft: rgba(78, 161, 255, 0.14);
  --ok: #5fd08a; --ok-soft: rgba(95, 208, 138, 0.13); --warn: #f0b04f; --warn-soft: rgba(240, 176, 79, 0.13);
  --crit: #ff6b62; --crit-soft: rgba(255, 107, 98, 0.13);
  --bg: var(--well); --viewport: var(--vp-bot); --radius: 4px; --gutter: 10px;
  --font-body: var(--font); --font-display: var(--font); --font-mono: var(--mono);
  --step--1: 11px; --step-0: 12.5px; --step-1: 13px; --step-2: 15px;
  /* read by viewer.js: the part, the coolant and plain streamlines on the dark view */
  --solid: #9aa4af; --fluid: #4d9de6; --stream: #dfe7ee;
}
body { background: var(--chrome); font: 400 12.5px/1.4 var(--font); }

.wb {
  height: 100%; display: grid;
  grid-template-columns: minmax(250px, 19rem) minmax(0, 1fr) minmax(280px, 22rem);
  grid-template-rows: auto auto minmax(0, 1fr) minmax(150px, 27%) auto;
  grid-template-areas: "tb tb tb" "rb rb rb" "left view right" "left bottom right" "sb sb sb";
}
.wb > .tb { grid-area: tb; }
.wb > .rb { grid-area: rb; }
.wb > .sbar { grid-area: sb; }
.dock.left { grid-area: left; border-right: 1px solid var(--line); }
.dock.right { grid-area: right; border-left: 1px solid var(--line); overflow: auto; }
.dock.bottom { grid-area: bottom; border-top: 1px solid var(--line); }
.tabs { display: none; }

/* ---------------------------------------------------------------- title bar */
.case-pick { display: flex; align-items: center; gap: 6px; min-width: 0; color: var(--muted); }
.case-pick select { height: 24px; min-width: 12rem; max-width: 18rem; font-weight: 600; color: var(--ink); }
.mode-chip { text-transform: none; letter-spacing: 0; padding: 2px 8px; border-radius: 4px; background: var(--accent-soft); color: var(--accent); font: 500 11px/1.4 var(--font); flex: none; }
.job[data-state="busy"] .dot { background: var(--panel-2); color: var(--ink-2); }
.job[data-state="busy"] .dot::before { content: "Loading"; }
.job[data-state="running"] .dot::before { content: "Solving"; }

/* ---------------------------------------------------------------- ribbon */
.rb a.cmd { text-decoration: none; }
.rb label.cmd { user-select: none; }
.rb .pseg button { padding: 3px 8px; font-size: 11.5px; }
#layers .s[aria-disabled="true"] { opacity: 0.4; cursor: default; }

/* ---------------------------------------------------------------- simulation tree and properties */
.sim-body { flex: 0 0 auto; max-height: 45%; }
.props-body { flex: 1 1 0; min-height: 0; padding-bottom: 10px; }
.ptree .node .st {
  width: 15px; height: 15px; border-radius: 3px; display: grid; place-items: center; flex: none;
  font: 600 9.5px/1 var(--mono); background: var(--panel-2); color: var(--muted);
}
.ptree .node .st.ok { background: var(--ok-soft); color: var(--ok); }
.ptree .node .st.run { background: var(--accent-soft); color: var(--accent); }
.ptree .node .st.warn { background: var(--warn-soft); color: var(--warn); }
.ptree .node .st.crit { background: var(--crit-soft); color: var(--crit); }
.ptree .node .st.run::before { content: ""; width: 7px; height: 7px; border-radius: 50%; border: 1.5px solid currentColor; border-right-color: transparent; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .ptree .node .st.run::before { animation: none; } }
.ptree .node .kd { margin-left: auto; max-width: 52%; overflow: hidden; text-overflow: ellipsis; }
.ptree .node.root { color: var(--ink); font-weight: 600; }

.props-body .pg-cap small { font-weight: 400; text-transform: none; letter-spacing: 0; margin-left: 4px; }
.params { display: grid; grid-template-columns: minmax(0, 1fr) 7rem; gap: 0; align-items: center; }
.params label { font: 400 11.5px/1 var(--mono); color: var(--ink-2); padding: 3px 8px 3px 10px; min-height: 26px; display: flex; align-items: center;
  border-bottom: 1px solid rgba(44, 48, 54, 0.6); overflow-wrap: anywhere; }
.params input { height: 22px; margin: 2px 10px 2px 0; width: calc(100% - 10px); padding: 0 6px; }
.params input.changed { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); }
.spec-adv { margin: 10px 10px 0; display: grid; gap: 8px; }
.spec-adv > summary {
  cursor: pointer; list-style: none; display: flex; align-items: center; gap: 7px; padding: 5px 8px; border-radius: 4px;
  border: 1px solid var(--line-2); background: var(--panel-2); color: var(--ink-2); font-weight: 500;
}
.spec-adv > summary::-webkit-details-marker { display: none; }
.spec-adv > summary::before { content: "▸"; color: var(--muted); font-size: 9px; width: 9px; }
.spec-adv[open] > summary::before { content: "▾"; }
.spec-adv > summary:hover { color: var(--ink); border-color: #565d66; }
#spec { height: 34vh; min-height: 12rem; font: 400 11.5px/1.55 var(--mono); background: var(--well); border-color: var(--line); border-radius: 4px; color: #d3dae2; padding: 8px 10px; }
.msg { border-radius: 4px; font-size: 11.5px; }
#tmpl-row { gap: 4px; }
#tmpl, #tmpl-mat { height: 26px; }
#run-hint:empty { display: none; }

/* ---------------------------------------------------------------- the view */
.view { grid-area: view; position: relative; min-width: 0; min-height: 0; overflow: hidden; background: linear-gradient(180deg, var(--vp-top), var(--vp-bot)); }
.view .vp-title { max-width: 38%; }
.view .vp-title span { font-family: var(--mono); font-size: 11px; }
.vp-hud .pseg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }
.vcube polygon { stroke: #8794a3; }
.overlay { z-index: 3; }
.ov-chip { background: rgba(29, 32, 36, 0.88); border: 1px solid var(--line-2); border-radius: 6px; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35); padding: 6px 10px; }
.legend { left: 76px; bottom: 12px; width: min(19rem, calc(100% - 200px)); }
.legend .lt b { font: 600 11.5px/1.3 var(--font); letter-spacing: 0; text-transform: none; }
.legend .ticks { font: 400 10.5px/1.2 var(--mono); color: var(--ink-2); }
.probe { right: 12px; bottom: 34px; }
.probe .ov-chip { font: 400 11px/1.5 var(--mono); }
.probe .pick-acts .btn { font: 500 11px/1 var(--font); min-height: 22px; padding: 0 8px; border-radius: 4px; background: var(--panel-2); border-color: var(--line-2); color: var(--ink); }
.credit { bottom: 36px; font: 400 10.5px/1.35 var(--mono); color: var(--ink-2); text-shadow: 0 1px 3px #000; }
.veil { inset: 0; z-index: 2; background: rgba(18, 20, 23, 0.55); }
.veil .ov-chip { padding: 14px 18px; font-size: 12.5px; color: var(--ink-2); max-width: 26rem; }
html[data-softgl] .vp-hud, html[data-softgl] .ov-chip { backdrop-filter: none; -webkit-backdrop-filter: none; }

/* ---------------------------------------------------------------- output dock */
.btabs { display: flex; align-items: stretch; height: 28px; background: var(--chrome); border-bottom: 1px solid var(--line); flex: none; padding-left: 4px; }
.btabs button { border: 0; background: transparent; color: var(--muted); padding: 0 12px; cursor: pointer; font-weight: 500; font-size: 11.5px; border-bottom: 2px solid transparent; display: flex; align-items: center; gap: 6px; }
.btabs button:hover { color: var(--ink); }
.btabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); background: var(--panel); }
.btabs .count { font: 500 10.5px var(--mono); color: var(--warn); }
.bbody { flex: 1 1 0; min-height: 0; overflow: auto; }
.bbody > * { margin: 0; padding: 8px 12px; }
.dock.bottom[data-on] .bbody > :not(.on) { display: none !important; }
#log, #log:empty { display: block; max-height: none; min-height: 100%; border: 0; border-radius: 0; background: var(--well); font: 400 11px/1.55 var(--mono); color: #b9c2cc; white-space: pre-wrap; }
#log:empty::before { content: "The solver's output appears here when a case runs."; color: var(--muted); }
.estimate { margin: 0; gap: 8px; }
#sec-runs, #sec-files, #sec-warnings { display: grid; gap: 8px; align-content: start; }
#sec-runs .row { gap: 6px; }
#sec-runs .hint { flex: 1 1 16rem; }
.files { gap: 4px; }
.files .btn { font: 500 11.5px/1 var(--font); letter-spacing: 0; text-transform: none; min-height: 26px; padding: 0 10px; border-radius: 4px;
  border: 1px solid var(--line-2); background: var(--panel-2); color: var(--ink); text-decoration: none; }
.files .btn:hover { border-color: #565d66; background: #2a2f35; }

/* ---------------------------------------------------------------- reports and scene */
#sec-kpis, #sec-display { display: block; }
.kpis { padding: 8px 12px 12px; gap: 12px; }
.kgroup h3 { font: 600 10.5px/1 var(--font); letter-spacing: 0.06em; color: var(--muted); margin: 2px 0 4px; }
.kgroup h3::after { border-top-color: var(--line); }
.kv { padding: 3px 0; border-bottom: 1px solid rgba(44, 48, 54, 0.6); }
.kv dt { color: var(--ink-2); }
.kv dd { font: 400 12px/1.3 var(--mono); color: var(--ink); }
.kv.hero { padding: 6px 0 8px; }
.kv.hero dt { color: var(--ink); font-weight: 500; }
.kv.hero dd { font: 500 20px/1.1 var(--mono); letter-spacing: -0.02em; }
.kv dd .pm { color: var(--accent); }
.pill { font: 500 10.5px/1 var(--font); letter-spacing: 0.02em; text-transform: none; border-radius: 4px; padding: 3px 6px; }
table.modes { font: 400 11px/1.3 var(--mono); }
table.modes th { font: 600 10.5px/1.2 var(--font); letter-spacing: 0.02em; text-transform: none; color: var(--muted); padding: 4px 6px; }
table.modes td { padding: 3px 6px; border-bottom-color: rgba(44, 48, 54, 0.8); }
table.modes tbody tr:hover { background: rgba(255, 255, 255, 0.03); }
table.modes tbody tr.on { background: var(--accent-soft); color: var(--ink); box-shadow: 2px 0 0 var(--accent) inset; }
.warnings li { border-radius: 4px; }
.timebar i { background: var(--accent); }
svg.frf { color: var(--accent); }
#sec-display .pg-row > .k { white-space: nowrap; }
#sec-display .pg-row > .v > select { flex: 1 1 auto; min-width: 0; }
#sec-display input[type="range"] { flex: 1 1 5rem; min-width: 0; accent-color: var(--accent); }
.small-num { font: 400 10.5px/1 var(--mono); color: var(--muted); min-width: 3.4rem; text-align: right; }
.check { display: flex; align-items: center; gap: 6px; cursor: pointer; color: var(--ink-2); font-size: 11.5px; }
#sec-display .pg-note { padding-top: 10px; }

/* ---------------------------------------------------------------- set-up groups (Car attitude, Flow, Boundaries, Mesh, Solver) */
#params { display: block; }
.pg-group { border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.pg-group.flash { animation: flash 1.2s ease-out; }
@keyframes flash { from { background: var(--accent-soft); } to { background: transparent; } }
.pg-group .pg-row { grid-template-columns: 8.4rem minmax(0, 1fr); }
.pg-row.par > .k, .pg-row.ro > .k { font: 400 12px/1.2 var(--font); color: var(--ink-2); cursor: text; }
.pg-row.par input { height: 22px; padding: 0 6px; text-align: right; font: 400 12px var(--mono); }
.pg-row.par input.changed { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); }
.pg-row.par .u { min-width: 2.2rem; }
.pg-row.ro .rv { font: 400 11.5px/1.3 var(--mono); color: var(--ink-2); }
.pg-row.ro { min-height: 24px; }
table.bcs { width: 100%; }
table.bcs td { white-space: nowrap; padding: 3px 6px; font-size: 10.5px; }
table.bcs td:first-child { font: 500 11.5px var(--font); color: var(--ink); padding-left: 10px; }
table.bcs td:last-child { white-space: normal; color: var(--muted); }
.bc-kind { display: inline-block; padding: 1px 5px; border-radius: 3px; background: var(--panel-2); color: var(--ink-2); font: 500 10px/1.4 var(--font); }
.bc-velocity-inlet { background: rgba(78, 161, 255, 0.16); color: #8cc2ff; }
.bc-pressure-outlet { background: rgba(240, 176, 79, 0.15); color: var(--warn); }
.bc-moving-wall, .bc-rotating-wall { background: rgba(95, 208, 138, 0.14); color: var(--ok); }
.bc-symmetry { background: rgba(180, 140, 255, 0.16); color: #c5a8ff; }
.pseg.lvl button:disabled, #accuracy button:disabled { opacity: 0.38; cursor: not-allowed; }
.mon-link { margin: 4px 0 2px; }

/* ---------------------------------------------------------------- the job pill's progress, the mesh note and the zone labels */
.job { position: relative; }
.job .prog { position: absolute; left: 6px; right: 6px; bottom: 1px; height: 2px; border-radius: 1px; background: rgba(78, 161, 255, 0.18); overflow: hidden; }
.job .prog b { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.5s ease; }
.mesh-note { right: 12px; top: 96px; max-width: 22rem; font-size: 11.5px; }
.mesh-note .ov-chip { display: grid; gap: 3px; }
.mesh-note .row { display: flex; gap: 6px; margin-top: 4px; }
.mesh-note .hint { color: var(--muted); }
.bc-labels { position: absolute; inset: 0; pointer-events: none; z-index: 2; overflow: hidden; }
.bcl { position: absolute; left: 0; top: 0; white-space: nowrap; padding: 2px 7px; border-radius: 10px; font: 500 10.5px/1.3 var(--font);
  background: rgba(22, 24, 27, 0.82); border: 1px solid var(--line-2); color: var(--ink-2); }
.bcl.bc-xmin, .bcl.flow { color: #8cc2ff; border-color: rgba(78, 161, 255, 0.5); }
.bcl.bc-xmax { color: var(--warn); border-color: rgba(240, 176, 79, 0.45); }
.bcl.bc-zmin { color: var(--ok); border-color: rgba(95, 208, 138, 0.45); }
.bcl.bc-ymin { color: #c5a8ff; border-color: rgba(180, 140, 255, 0.45); }
#legend2 { margin-top: 6px; padding-top: 5px; border-top: 1px solid var(--line); }
#legend2 canvas { width: 100%; height: 6px; display: block; border-radius: 2px; }
.legend.only2 .ov-chip > :not(#legend2) { display: none; }
.legend.only2 #legend2 { margin: 0; padding: 0; border: 0; }

/* ---------------------------------------------------------------- monitors (residual and forces) */
.monitors { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 8px; background: var(--well); min-height: 100%; }
svg.mon { width: 100%; height: auto; max-height: 100%; display: block; background: var(--panel); border: 1px solid var(--line); border-radius: 4px; }
svg.mon .mt { font: 600 10.5px var(--font); fill: var(--ink-2); }
svg.mon .ma, svg.mon .mh { font: 400 9.5px var(--mono); fill: var(--muted); }
svg.mon .mg { stroke: var(--line); stroke-width: 1; }
svg.mon .ml { fill: none; stroke-width: 1.4; vector-effect: non-scaling-stroke; }
svg.mon .s0 { stroke: #c5a8ff; fill: #c5a8ff; } svg.mon .s1 { stroke: #4ea1ff; fill: #4ea1ff; } svg.mon .s2 { stroke: #f0b04f; fill: #f0b04f; }
svg.mon .ml.s0, svg.mon .ml.s1, svg.mon .ml.s2 { fill: none; }
svg.mon .mlab { font: 500 10px var(--mono); stroke: none; }
svg.mon .mavg { fill: rgba(95, 208, 138, 0.07); }
svg.mon .mset { stroke: var(--ok); stroke-dasharray: 3 3; }

/* ---------------------------------------------------------------- tablet: the right dock under the view */
@media (max-width: 1180px) and (min-width: 761px) {
  .wb { grid-template-columns: minmax(240px, 18rem) minmax(0, 1fr) minmax(250px, 18rem); }
}

/* ---------------------------------------------------------------- phone: the view first, the panels as tabs */
@media (max-width: 760px) {
  html, body { height: auto; }
  .wb { height: auto; min-height: 100%; display: flex; flex-direction: column; }
  .tb { flex-wrap: wrap; height: auto; padding: 6px 10px; row-gap: 6px; }
  .tb .apps { order: 5; width: 100%; overflow-x: auto; scrollbar-width: none; }
  .tb > .sep { display: none; }
  .case-pick { flex: 1 1 auto; } .case-pick select { min-width: 0; max-width: none; width: 100%; }
  .job { order: 6; width: 100%; max-width: none; }
  .view { height: 58vh; min-height: 300px; flex: none; }
  .vp-title { display: none; }
  .vp-hud { top: auto; bottom: 8px; max-width: calc(100% - 16px); overflow-x: auto; scrollbar-width: none; }
  .vcube { width: 64px; height: 64px; }
  .vtriad, .vruler { display: none; }
  .legend { left: 10px; bottom: 50px; width: min(14rem, calc(100% - 20px)); }
  .probe { bottom: 50px; }
  .tabs { display: flex; position: sticky; top: env(safe-area-inset-top, 0px); z-index: 4; background: var(--chrome); border-bottom: 1px solid var(--line); }
  .rg-solve { order: -1; }
  .tabs button { text-transform: none; letter-spacing: 0; font-size: 12.5px; flex: 1; border: 0; background: transparent; padding: 10px 4px; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; cursor: pointer; }
  .tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
  .dock { border: 0 !important; overflow: visible; }
  .dock.right { order: 4; } .dock.left { order: 5; } .dock.bottom { order: 6; }
  .sim-body, .props-body, .bbody { flex: none; max-height: none; overflow: visible; }
  .btabs { display: none; }
  .dock.bottom[data-on] .bbody > :not([hidden]) { display: block !important; }
  .dock.bottom[data-on] .bbody > :where(#sec-runs, #sec-files, #sec-warnings):not([hidden]) { display: grid !important; }
  #log { max-height: 14rem; min-height: 0; }
  #log:empty { display: none !important; }
  .wb[data-tab="results"] .dock.left, .wb[data-tab="results"] #sec-display, .wb[data-tab="results"] #log, .wb[data-tab="results"] #estimate { display: none !important; }
  .wb[data-tab="display"] .dock.left, .wb[data-tab="display"] .dock.bottom, .wb[data-tab="display"] #sec-kpis { display: none !important; }
  .wb[data-tab="spec"] .dock.right, .wb[data-tab="spec"] #sec-runs, .wb[data-tab="spec"] #sec-files, .wb[data-tab="spec"] #sec-warnings { display: none !important; }
  #spec { height: 50vh; }
  .sbar { display: none; }
}
#layers .rstack { gap: 0; }
#layers .rstack .s { min-height: 20px; }
.params .pg-row.par > label { padding: 0; min-height: 0; border: 0; }
.params .pg-row.par input { margin: 0; width: 0; }
.kgroup h4.sub { margin: 12px 0 4px; font: 600 11px/1.3 var(--font); color: var(--ink-2); }
svg.mon.buildup { margin-top: 2px; }
