/* ── Reset & Tokens ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* ── Background layers ── */
  --bg:        #0d1117;
  --surface:   #161b27;
  --surface2:  #1f2535;
  --border:    #2a3050;

  /* ── Accent — Valve Simulator (process blue) ── */
  --accent:    #29b6f6;
  --accent-lo: rgba(41,182,246,.22);

  /* ── Semantic colours — DO NOT CHANGE ── */
  --green:     #3ddc84;
  --red:       #ff5555;
  --gold:      #f5c842;

  /* ── Typography ── */
  --text:      #dde3f0;
  --text-dim:  #6b7a99;
  --font:      'Segoe UI', system-ui, sans-serif;
  --mono:      'Courier New', monospace;

  /* ── Layout ── */
  --radius:    12px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
  padding: 0 16px;
}

#app { max-width: 1180px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }

/* ── Header ─── */
header { text-align: center; padding: 4px 0; }
header h1 {
  font-size: 1.8rem; font-weight: 700;
  background: linear-gradient(120deg, #60a5fa 0%, #e8793a 55%, #22c55e 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.subtitle { color: var(--text-dim); font-size: 0.85rem; margin-top: 3px; }

/* ── Controls bar ─── */
.controls-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 14px;
  padding: 12px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.ctrl-group  { display: flex; align-items: center; gap: 8px; }
.ctrl-label  { font-size: 0.72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-dim); white-space: nowrap; }
.ctrl-value  { font-size: 0.82rem; color: var(--accent); font-weight: 600; min-width: 40px; }

/* ── Pill tabs ─── */
.pill-tabs { display: flex; background: var(--bg); border-radius: 8px; padding: 3px; gap: 2px; }
.pill {
  padding: 5px 13px; border: none; background: transparent; color: var(--text-dim);
  border-radius: 6px; cursor: pointer; font-size: 0.81rem;
  transition: background .18s, color .18s, box-shadow .18s;
}
.pill.active { background: var(--accent); color: #fff; box-shadow: 0 0 12px var(--accent-lo); }
.pill:hover:not(.active) { background: var(--surface2); color: var(--text); }

/* ── Buttons ─── */
.btn { padding: 8px 18px; border: none; border-radius: 8px; cursor: pointer; font-size: 0.84rem; font-weight: 600; transition: filter .18s, box-shadow .18s, opacity .18s; }
.btn:disabled { opacity: 0.38; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:not(:disabled):hover { filter: brightness(1.12); box-shadow: 0 0 12px var(--accent-lo); }
.btn-ghost { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--border); }

/* ── Sliders ─── */
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 120px; height: 6px;
  background: var(--surface2); border-radius: 3px; outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); cursor: pointer;
  box-shadow: 0 0 6px var(--accent-lo);
}

/* ── Canvas card ─── */
.canvas-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px;
  overflow-x: clip;
}
.canvas-card canvas { display: block; width: 100%; height: auto; touch-action: pan-y; }

/* ── Readout panel ─── */
.readout-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
}
.readout-cell {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 14px;
  display: flex; flex-direction: column; gap: 2px;
}
.readout-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-dim); }
.readout-value { font-size: 1.05rem; font-weight: 700; color: var(--text); font-family: var(--mono); }

/* ── Explore panel ─── */
.explore-tabs {
  display: flex; background: var(--bg); border-radius: 8px; padding: 3px; gap: 2px;
  flex-wrap: wrap; margin-bottom: 12px;
}
.concept-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}
.concept-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  transition: border-color .2s;
}
.concept-card:hover { border-color: var(--accent); }
.concept-card h3 { font-size: 0.95rem; color: var(--accent); margin-bottom: 4px; }
.concept-card .cc-formula {
  font-family: var(--mono); font-size: 0.82rem;
  background: var(--surface2); padding: 6px 10px; border-radius: 6px;
  margin: 8px 0; color: var(--gold);
}
.concept-card .cc-desc { font-size: 0.82rem; color: var(--text-dim); line-height: 1.45; }
.concept-card .cc-example {
  margin-top: 10px; padding: 10px; background: var(--bg);
  border-radius: 8px; border-left: 3px solid var(--accent);
}
.concept-card .cc-example-title { font-size: 0.72rem; text-transform: uppercase; color: var(--accent); margin-bottom: 4px; }
.concept-card .cc-example p { font-size: 0.8rem; color: var(--text-dim); margin: 2px 0; }

/* ── Practice panel ─── */
.practice-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.practice-prompt { font-size: 0.9rem; flex: 1 1 100%; margin-bottom: 4px; line-height: 1.5; }
.practice-input-group { display: flex; align-items: center; gap: 6px; }
.practice-input-group input {
  width: 120px; padding: 6px 10px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--surface2);
  color: var(--text); font-size: 0.9rem; font-family: var(--mono);
}
.practice-unit { font-size: 0.82rem; color: var(--text-dim); }
.pbar-score { font-size: 0.84rem; color: var(--text-dim); margin-left: auto; }
.pbar-score span { color: var(--text); font-weight: 700; }
.feedback { margin-top: 6px; padding: 0 16px; min-height: 22px; }
.feedback.ok  { color: var(--green); font-size: 0.88rem; font-weight: 600; }
.feedback.err { color: var(--red);   font-size: 0.88rem; font-weight: 600; }
.solution-panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 18px;
  font-size: 0.85rem; line-height: 1.6; color: var(--text-dim);
}
.solution-panel .step { margin: 4px 0; }
.solution-panel .step-num { color: var(--accent); font-weight: 600; }

/* ── Quiz panel ─── */
.quiz-bar {
  padding: 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.quiz-counter { font-size: 0.78rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: .08em; }
.quiz-prompt { display: block; font-size: 0.95rem; margin: 10px 0; line-height: 1.5; }
.quiz-options { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.quiz-opt {
  padding: 10px 14px; border-radius: 8px; cursor: pointer;
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); font-size: 0.88rem; transition: border-color .2s;
  text-align: left;
}
.quiz-opt:hover { border-color: var(--accent); }
.quiz-opt.selected { border-color: var(--accent); background: var(--accent-lo); }
.quiz-opt.correct { border-color: var(--green); background: rgba(61,220,132,.15); }
.quiz-opt.wrong { border-color: var(--red); background: rgba(255,85,85,.15); }
.quiz-input-group { display: flex; align-items: center; gap: 6px; margin: 8px 0; }
.quiz-input-group input {
  width: 140px; padding: 6px 10px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--surface2);
  color: var(--text); font-size: 0.9rem; font-family: var(--mono);
}
.quiz-unit { font-size: 0.82rem; color: var(--text-dim); }
.quiz-actions { display: flex; gap: 10px; margin-top: 10px; }

/* ── Quiz result ─── */
.quiz-result {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px 22px;
}
.qr-header { text-align: center; margin-bottom: 16px; }
.qr-score { font-size: 2rem; font-weight: 700; }
.qr-score.perfect { color: var(--gold); }
.qr-score.good    { color: var(--green); }
.qr-score.poor    { color: var(--red); }
.qr-stars { font-size: 1.4rem; margin-top: 4px; }
.qr-rows { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.qr-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px; border-radius: 8px; background: var(--surface2);
  font-size: 0.84rem;
}
.qr-row.ok  { border-left: 3px solid var(--green); }
.qr-row.err { border-left: 3px solid var(--red); }
.qr-row .qr-q { flex: 1; color: var(--text-dim); }
.qr-row .qr-a { color: var(--text); font-weight: 600; margin: 0 10px; }
.qr-row .qr-icon { font-size: 1rem; }
.qr-retry { text-align: center; margin-top: 14px; }

/* ── SEO article ─── */
.seo-article {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px 24px; line-height: 1.7;
}
.seo-article h2 { font-size: 1.3rem; color: var(--accent); margin-bottom: 12px; }
.seo-article h3 { font-size: 1.05rem; color: var(--text); margin: 18px 0 8px; }
.seo-article p { font-size: 0.92rem; color: var(--text-dim); margin-bottom: 10px; }
.seo-article a { color: var(--accent); text-decoration: none; }
.seo-article a:hover { text-decoration: underline; }

/* ── Responsive ──────────────────────────────────────────────── */

@media (max-width: 768px) {
  .readout-panel { grid-template-columns: repeat(3, 1fr); }
  .controls-bar { gap: 10px; }
  input[type="range"] { width: 90px; }
  .concept-grid { grid-template-columns: 1fr; }
}

@media (max-width: 500px) {
  header h1 { font-size: 1.4rem; }
  .subtitle  { font-size: 0.78rem; }
  .controls-bar { padding: 10px 12px; gap: 8px; }
  .pill { padding: 5px 10px; font-size: 0.76rem; }
  .readout-panel { grid-template-columns: repeat(2, 1fr); }
  input[type="range"] { width: 70px; }
  .practice-bar { flex-direction: column; align-items: stretch; }
  .pbar-score { margin-left: 0; }
}

/* INTERLINK-START  header quick-links */
.head-actions{display:flex;align-items:center;gap:8px;margin-left:auto;flex-wrap:wrap;justify-content:flex-end;}
.btn-link{display:inline-flex;align-items:center;gap:7px;padding:5px 12px;border-radius:8px;font-size:.82rem;font-weight:700;text-decoration:none;cursor:pointer;background:var(--surface2,#1f2535);color:var(--text,#dde3f0);border:1.5px solid var(--border,#2a3050);white-space:nowrap;transition:border-color .18s,background .18s,color .18s;}
.btn-link:hover{border-color:var(--accent,#4fc3f7);background:var(--accent-lo,rgba(79,195,247,.18));color:#fff;}
.btn-link img{width:20px;height:20px;border-radius:4px;flex:none;}
.btn-link .lbl{line-height:1;}
@media(max-width:560px){.btn-link .lbl{display:none;}.btn-link{padding:5px 9px;}}
/* With a third quick-link (Gearbox) the row overflowed by ~17 px and
   wrapped under the mode tabs — at every width, since #app caps the bar.
   Share keeps its icon and word; only the trailing "your setup" goes, as
   site.css already does below 640 px. */
.head-actions .btn-share-ext { display: none; }
/* ...and on a 1024-1100 px window it still did not fit, so the quick-links
   go icon-only there (title + aria-label keep the name), as they already
   do below 560 px. Wider than 1100 px the labels return. */
@media (max-width: 1100px) { .btn-link .lbl { display: none; } .btn-link { padding: 5px 9px; } }
/* INTERLINK-END */

/* ── Display Controls — collapsible overlay pinned to the canvas ── */
.canvas-toggles {
  position: absolute; top: 16px; left: 16px; z-index: 4;
  background: rgba(13,17,23,0.88);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  border: 1px solid var(--border); border-radius: 9px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.35);
  max-width: calc(100% - 32px);
}
.canvas-toggles > summary {
  list-style: none; cursor: pointer; user-select: none;
  display: flex; align-items: center; justify-content: center; gap: 0;
  padding: 0; white-space: nowrap;
  width: 34px; height: 34px;
  font-size: 0.66rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text); border-radius: 9px; transition: background .12s, color .12s;
}
.canvas-toggles > summary .cvt-title,
.canvas-toggles > summary .cvt-caret { display: none; }
.canvas-toggles .cvt-ico { width: 17px; height: 17px; }
/* Opened, it earns its caption back — the user has chosen to cover the canvas. */
.canvas-toggles[open] > summary {
  width: auto; height: auto; min-height: 30px;
  padding: 6px 10px; gap: 7px; justify-content: flex-start;
}
.canvas-toggles[open] > summary .cvt-title { display: inline; }
.canvas-toggles[open] > summary .cvt-caret { display: inline; }
.canvas-toggles > summary::-webkit-details-marker { display: none; }
.canvas-toggles > summary::marker { content: ''; }
.canvas-toggles > summary:hover { background: var(--accent-lo); color: var(--accent); }
.canvas-toggles > summary:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.canvas-toggles .cvt-ico { flex-shrink: 0; color: var(--accent); }
.canvas-toggles .cvt-caret {
  margin-left: auto; padding-left: 4px; color: var(--text-dim);
  font-size: 0.7rem; transition: transform .2s;
}
.canvas-toggles[open] > summary .cvt-caret { transform: rotate(180deg); color: var(--accent); }
.canvas-toggles[open] > summary {
  border-bottom: 1px solid var(--border); border-radius: 9px 9px 0 0;
}
.canvas-toggles .cvt-body {
  display: flex; flex-direction: column; gap: 5px;
  padding: 8px 11px 10px; max-height: 60vh; overflow-y: auto;
}
.canvas-toggles .cvt-group {
  font-size: 0.58rem; font-weight: 800; letter-spacing: .09em;
  text-transform: uppercase; color: var(--accent);
  margin-top: 4px; padding-bottom: 2px; border-bottom: 1px solid var(--border);
}
.canvas-toggles .cvt-group:first-child { margin-top: 0; }
.canvas-toggles .cvt-item {
  display: flex; align-items: center; gap: 6px;
  font-size: 0.72rem; color: var(--text-dim); cursor: pointer;
  white-space: nowrap; transition: color .12s;
}
.canvas-toggles .cvt-item:hover { color: var(--text); }
.canvas-toggles .cvt-item input[type="checkbox"] {
  accent-color: var(--accent); width: 14px; height: 14px; cursor: pointer; flex-shrink: 0;
}
.canvas-toggles .cvt-reset {
  margin-top: 7px; padding: 5px 9px; min-height: 28px;
  background: var(--surface2); border: 1px solid var(--border); border-radius: 6px;
  color: var(--text-dim); font-size: 0.66rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em; cursor: pointer;
  transition: border-color .12s, color .12s;
}
.canvas-toggles .cvt-reset:hover { border-color: var(--accent); color: var(--accent); }
.canvas-toggles .cvt-reset:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ── Calculation modal ── */
.calc-modal {
  display: none; position: fixed; inset: 0; z-index: 1200;
  background: rgba(0,0,0,0.72); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  align-items: flex-start; justify-content: center; padding: 24px 16px; overflow-y: auto;
}
.calc-modal.open { display: flex; }
.calc-modal-box {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  width: 100%; max-width: 780px; display: flex; flex-direction: column;
  box-shadow: 0 24px 64px rgba(0,0,0,0.6);
  max-height: calc(100vh - 48px); overflow: hidden;
}
.calc-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-bottom: 1px solid var(--border);
  background: var(--surface2); flex-shrink: 0;
}
.calc-modal-title { font-size: 1rem; font-weight: 800; color: var(--text); }
.calc-modal-close {
  width: 34px; height: 34px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text-dim);
  font-size: 1.4rem; line-height: 1; padding: 0;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}
.calc-modal-close:hover { border-color: var(--accent); color: var(--text); background: var(--surface2); }
.calc-modal-body { padding: 16px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
/* ── Learning panels ── */
.learn-panels {
  padding: 14px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.learn-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  padding-bottom: 10px; border-bottom: 1px solid var(--border); margin-bottom: 12px;
}
.learn-head-title { font-size: 0.95rem; font-weight: 700; color: var(--text); }
.learn-head-actions { display: flex; gap: 8px; }
.learn-toggle-all {
  padding: 6px 12px; min-height: 32px;
  background: var(--accent-lo); border: 1px solid var(--border);
  color: var(--text); border-radius: 6px;
  font-family: var(--font); font-size: 0.78rem; font-weight: 600; cursor: pointer;
  transition: background .15s, border-color .15s;
}
.learn-toggle-all:hover { background: var(--surface2); border-color: var(--accent); }
.learn-toggle-all:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.learn-card {
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg); margin-bottom: 10px; overflow: hidden;
  transition: border-color .2s;
}
.learn-card:last-child { margin-bottom: 0; }
.learn-card[open] { border-color: var(--accent); }
.learn-card > summary {
  list-style: none; cursor: pointer;
  padding: 11px 14px; min-height: 44px;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  font-size: 0.88rem; font-weight: 700; color: var(--text);
  user-select: none; transition: background .15s;
}
.learn-card > summary::-webkit-details-marker { display: none; }
.learn-card > summary::marker { content: ''; }
.learn-card > summary:hover { background: var(--accent-lo); }
.learn-card > summary:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; }
.learn-card > summary::after {
  content: '\25BE'; margin-left: auto; color: var(--text-dim);
  font-size: 0.78rem; transition: transform .2s;
}
.learn-card[open] > summary::after { transform: rotate(180deg); color: var(--accent); }
.lp-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 6px;
  background: var(--accent-lo); font-size: 0.9rem; flex-shrink: 0;
}
.lp-sub { color: var(--text-dim); font-weight: 500; font-size: 0.78rem; }
.learn-body { padding: 12px 14px 14px; }
.eq-line { margin: 8px 0; overflow-x: auto; overflow-y: hidden; font-size: 0.95rem; }
.lp-note { font-size: 0.8rem; line-height: 1.6; color: var(--text-dim); margin: 10px 0 0; }
.lp-note strong { color: var(--text); }

/* ── Canvas context menu ── */
.ctx-menu {
  position: fixed; z-index: 1300; min-width: 210px; padding: 5px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 9px;
  box-shadow: 0 10px 26px rgba(0,0,0,.5);
  display: flex; flex-direction: column; gap: 2px;
}
.ctx-item {
  text-align: left; padding: 8px 11px; min-height: 38px;
  background: transparent; border: none; border-radius: 6px;
  color: var(--text); font-family: var(--font); font-size: 0.8rem; font-weight: 600;
  cursor: pointer; transition: background .12s;
}
.ctx-item:hover { background: var(--surface2); }
.ctx-item:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; }
.ctx-sep { height: 1px; background: var(--border); margin: 3px 6px; }

/* ═══ Touch: the collapsed chip grows to the 44px minimum. Must stay LAST
   so it wins over the .canvas-toggles rules above. ═══ */
@media (max-width: 768px) {
  .canvas-toggles > summary { width: 44px; height: 44px; }
  .canvas-toggles .cvt-ico { width: 18px; height: 18px; }
  .canvas-toggles[open] > summary { width: auto; height: auto; padding: 7px 10px; }
}


/* ═══ Layout and controls ═══ */
.sim-layout { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 14px; align-items: stretch; }
.sim-main { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
#sim-panel { display: flex; flex-direction: column; gap: 12px; }
.canvas-card { position: relative; padding: 0; }
.canvas-card canvas#vl-canvas { display: block; width: 100%; touch-action: pan-y; border-radius: var(--radius) var(--radius) 0 0; }
.vl3d-stage { position: relative; width: 100%; aspect-ratio: 16 / 9; min-height: 340px; }
.vl3d-stage[hidden] { display: none; }
.vl3d-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.vl3d-hud { touch-action: none; cursor: move; }
.vl-note { position: absolute; left: 50%; bottom: 72px; transform: translateX(-50%); z-index: 5; display: flex; align-items: center; gap: 10px;
  background: rgba(13,17,23,.92); border: 1px solid var(--border); border-radius: 9px; padding: 8px 10px 8px 14px; font-size: .8rem; color: var(--text); max-width: calc(100% - 24px); }
.vl-note[hidden] { display: none; }
.vl-note button { background: var(--surface2); border: 1px solid var(--border); color: var(--text); border-radius: 6px; width: 30px; height: 30px; cursor: pointer; flex-shrink: 0; }
/* the experiment dock under the canvas: view, run, explain, flips, reset */
.canvas-dock { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 10px 12px; border-top: 1px solid var(--border); background: linear-gradient(180deg, rgba(255,255,255,.025), rgba(255,255,255,0)); border-radius: 0 0 var(--radius) var(--radius); }
.dock-sep { width: 1px; align-self: stretch; min-height: 32px; background: var(--border); margin: 0 2px; }
.canvas-dock .btn-big { flex: 0 1 auto; min-width: 160px; }
.canvas-dock .cond-row { flex: 1 1 auto; flex-wrap: wrap; }
.canvas-dock .cond-btn { flex: 0 1 auto; white-space: nowrap; min-height: 40px; padding: 6px 11px; }
.canvas-dock .dock-reset { margin-left: auto; min-height: 40px; padding: 6px 12px; font-size: .8rem; }
.vt-tabs { display: flex; background: rgba(13,17,23,.88); border: 1px solid var(--border); border-radius: 9px; padding: 3px; gap: 2px; }
.vt-pill { min-width: 44px; height: 32px; padding: 0 12px; border: none; border-radius: 7px; background: transparent; color: var(--text-dim); font-weight: 800; font-size: .8rem; cursor: pointer; }
.vt-pill.active { background: var(--accent); color: #fff; }
.vt-pill:hover:not(.active) { color: var(--text); background: var(--surface2); }
.vt-pill:focus-visible, .scen-btn:focus-visible, .cond-btn:focus-visible, .dir-btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.status-line { font-size: .88rem; line-height: 1.5; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 10px; padding: 9px 14px; min-height: 40px; }
.readout-panel { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.readout-value { font-size: .98rem; }

.sim-rail { display: flex; flex-direction: column; gap: 12px; }
.rail-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.rail-head { font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--text); display: flex; align-items: center; gap: 8px; }
.rail-num { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: #fff; font-size: .74rem; }
.scen-tabs { display: flex; flex-direction: column; gap: 6px; }
#sim-panel > .readout-panel { margin-top: -2px; }
.scen-btn { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; text-align: left; padding: 6px 12px; min-height: 44px; border-radius: 9px;
  background: var(--bg); border: 1px solid var(--border); color: var(--text); cursor: pointer; font-family: var(--font); transition: border-color .15s, background .15s; }
.scen-btn strong { font-size: .9rem; }
.scen-btn span { font-size: .74rem; color: var(--text-dim); }
.scen-btn:hover { border-color: var(--accent); }
.scen-btn.active { border-color: var(--accent); background: var(--accent-lo); }
.scen-btn.active span { color: var(--text); }
.act-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-big { flex: 1 1 160px; min-height: 44px; font-size: .9rem; background: #1f9d55; }
.btn-explain { min-height: 44px; background: rgba(253,230,138,.12); color: #fde68a; border: 1px solid rgba(253,230,138,.45); }
.btn-explain:hover, .btn-explain.on { background: rgba(253,230,138,.24); }
.cond-row { display: flex; flex-wrap: wrap; gap: 6px; }
.cond-btn { flex: 1 1 130px; min-height: 40px; font-size: .8rem; padding: 6px 10px; }
.param-grid { display: flex; flex-direction: column; gap: 9px; }
.prow { display: flex; flex-direction: column; gap: 5px; }
.prow-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.prow-label { font-size: .74rem; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: .04em; }
.prow-num { display: flex; align-items: center; gap: 4px; }
.prow-num input { width: 74px; height: 30px; padding: 3px 6px; border-radius: 6px; border: 1px solid var(--border); background: var(--bg); color: var(--accent); font-family: var(--mono); font-weight: 700; font-size: .85rem; text-align: right; }
.prow-unit { font-size: .74rem; color: var(--text-dim); min-width: 26px; }
.prow-note { font-size: .72rem; color: var(--text-dim); line-height: 1.35; }
.sim-slider { width: 100%; -webkit-appearance: none; appearance: none; height: 6px; background: rgba(255,255,255,.12); border-radius: 3px; outline: none; border: 1px solid rgba(255,255,255,.1); }
.sim-slider::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: linear-gradient(to right, var(--accent-lo), rgba(255,255,255,.12)); }
.sim-slider::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; margin-top: -6px; border-radius: 50%; background: var(--accent); cursor: pointer; box-shadow: 0 0 8px var(--accent-lo); border: 2px solid rgba(255,255,255,.2); }
.sim-slider::-moz-range-track { height: 6px; border-radius: 3px; background: linear-gradient(to right, var(--accent-lo), rgba(255,255,255,.12)); border: none; }
.sim-slider::-moz-range-thumb { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.2); border-radius: 50%; background: var(--accent); cursor: pointer; }
.rail-tools { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; }
.rail-tools .btn { flex: 1 1 auto; padding: 8px 10px; font-size: .8rem; min-height: 38px; }

/* Explain bar */
.explain-bar { background: linear-gradient(180deg, rgba(253,230,138,.10), rgba(253,230,138,.03)); border: 1px solid rgba(253,230,138,.38); border-radius: var(--radius); padding: 10px 14px 12px; }
.explain-bar[hidden] { display: none; }
.ex-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ex-step { font-family: var(--mono); font-weight: 700; color: #fde68a; font-size: .82rem; min-width: 46px; }
.ex-btn { width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface2); color: var(--text); cursor: pointer; font-size: .9rem; }
.ex-btn:hover { border-color: #fde68a; }
.ex-dots { display: flex; gap: 5px; flex: 1; flex-wrap: wrap; justify-content: center; }
.ex-dot { width: 14px; height: 14px; border-radius: 50%; border: 1px solid rgba(253,230,138,.6); background: transparent; cursor: pointer; padding: 0; position: relative; }
.ex-dot::after { content: ''; position: absolute; inset: -8px; }
.ex-dot.done { background: rgba(253,230,138,.45); }
.ex-dot.on { background: #fde68a; box-shadow: 0 0 8px rgba(253,230,138,.7); }
.ex-progress { height: 3px; background: rgba(255,255,255,.08); border-radius: 2px; margin: 8px 0 6px; overflow: hidden; }
.ex-progress > div { height: 100%; width: 0; background: #fde68a; }
.ex-title { font-weight: 800; color: #fde68a; font-size: .95rem; }
.ex-sub { font-size: .9rem; line-height: 1.55; color: var(--text); margin-top: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
#lp-equations .katex-display { margin: 6px 0; overflow-x: auto; overflow-y: hidden; }

/* Explore */
.concept-card .cc-desc code { font-family: var(--mono); color: var(--gold); }
.cc-note { font-size: .78rem; color: var(--text); margin-top: 8px; line-height: 1.45; border-top: 1px dashed var(--border); padding-top: 8px; }
.explore-tabs .pill { min-height: 34px; }

/* Practice */
.practice-topic { font-size: .7rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); flex: 1 1 100%; }
.practice-fig { width: 360px; max-width: 100%; aspect-ratio: 360 / 200; height: auto; border-radius: 10px; border: 1px solid var(--border); flex: 0 0 auto; }
.practice-fig[hidden], .dir-grid[hidden], .practice-input-group[hidden] { display: none; }
.dir-grid { display: grid; grid-template-columns: repeat(3, minmax(120px, 1fr)); gap: 6px; flex: 1 1 100%; }
.dir-btn { min-height: 44px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface2); color: var(--text); font-weight: 700; font-size: .85rem; cursor: pointer; font-family: var(--font); }
.dir-btn:hover { border-color: var(--accent); }
.dir-btn.correct { border-color: var(--green); background: rgba(61,220,132,.16); }
.dir-btn.wrong { border-color: var(--red); background: rgba(255,85,85,.16); }
.calc-modal-body p { font-size: .9rem; line-height: 1.6; color: var(--text); }
.calc-modal-body .calc-note { color: var(--text-dim); font-size: .82rem; }
.quiz-opt:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.seo-article table { border-collapse: collapse; width: 100%; margin: 10px 0 14px; font-size: .86rem; }
.seo-article th, .seo-article td { border: 1px solid var(--border); padding: 7px 10px; text-align: left; color: var(--text-dim); }
.seo-article th { color: var(--text); background: var(--surface2); }
.seo-article ul { margin: 0 0 12px 20px; color: var(--text-dim); font-size: .92rem; line-height: 1.7; }
.seo-article h4 { font-size: .95rem; color: var(--text); margin: 12px 0 4px; }

@media (max-width: 1100px) {
  .sim-layout { grid-template-columns: 1fr; }
  .sim-rail { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .sim-rail .rail-tools { grid-column: 1 / -1; }
}
@media (max-width: 768px) {
  .sim-rail { display: flex; align-items: stretch; }
  .vl3d-stage { aspect-ratio: 4 / 3; min-height: 300px; }
  .dir-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 500px) {
  .status-line { font-size: .82rem; }
  .readout-panel { grid-template-columns: repeat(2, 1fr); }
  .ex-dots { order: 5; flex-basis: 100%; justify-content: flex-start; }
  .canvas-dock { gap: 6px; padding: 8px; }
  .canvas-dock .dock-sep { display: none; }
  .canvas-dock .btn-big { flex: 1 1 100%; order: -1; }
  .canvas-dock .cond-row { flex: 1 1 100%; }
  .canvas-dock .cond-btn { flex: 1 1 0; white-space: normal; }
  .canvas-dock .btn-explain { flex: 1 1 auto; }
  .canvas-dock .dock-reset { margin-left: 0; order: 1; }
  .canvas-dock .cond-row { order: 2; }
}
@media (prefers-reduced-motion: reduce) { .scen-btn, .ex-dot { transition: none; } }
.ctx-menu[hidden], .calc-modal:not(.open) { display: none; }
.canvas-card canvas#vl-canvas[hidden] { display: none; }

/* ═══ Shared rail pieces ═══ */
.vl3d-stage { aspect-ratio: 16 / 8.4; min-height: 360px; }
.canvas-card canvas#vl-strip { display: block; width: 100%; border-top: 1px solid var(--border); background: #0d121b; }
.preset-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.preset-grid .scen-btn { min-height: 52px; }
.pill-row { display: flex; flex-wrap: wrap; gap: 4px; }
.pill-row .pill { flex: 1 1 auto; min-height: 32px; padding: 5px 9px; font-size: .78rem; }
.lambda-swatch { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-left: 6px; vertical-align: -1px; box-shadow: 0 0 8px currentColor; border: 1px solid rgba(255,255,255,.35); }
.prow[hidden] { display: none; }
.slot-list { display: flex; flex-direction: column; gap: 8px; }
.slot { border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; background: var(--bg); display: flex; flex-direction: column; gap: 6px; transition: border-color .15s, background .15s; }
.slot.focus { border-color: var(--accent); background: var(--accent-lo); }
.slot.off .slot-angle { opacity: .4; }
.slot-head { display: flex; align-items: center; gap: 8px; }
.slot-on { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.slot-on input { accent-color: var(--accent); width: 18px; height: 18px; cursor: pointer; }
.slot-num { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 50%; background: var(--surface2); color: var(--text); font-size: .74rem; font-weight: 800; }
.slot-head select { flex: 1; min-width: 0; height: 32px; border-radius: 7px; border: 1px solid var(--border); background: var(--surface2); color: var(--text); font-family: var(--font); font-size: .82rem; padding: 0 8px; }
.slot-angle { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 8px; }
.slot-axis { grid-column: 1 / -1; font-size: .68rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-dim); font-weight: 700; }
.slot-angle .prow-num input { width: 62px; }
.slot-angle .sim-slider { width: 100%; min-width: 0; justify-self: stretch; }
.canvas-dock .btn-spin { min-height: 40px; background: #1f9d55; color: #fff; }
.canvas-dock .btn-spin:disabled { opacity: .45; cursor: default; }
.canvas-dock .btn-play { min-height: 40px; padding: 6px 11px; font-size: .8rem; }
#cam-tabs[hidden] { display: none; }
@media (max-width: 768px) {
  .vl3d-stage { aspect-ratio: 4 / 3; min-height: 300px; }
}
@media (max-width: 500px) {
  .preset-grid { grid-template-columns: 1fr; }
  .canvas-dock .btn-spin { flex: 1 1 100%; order: -1; }
}

/* ═══ Phone layout (mobile-ui.js) ═══
   Scoped to body.vl-m, which mobile-ui.js sets only while the screen is ≤ 720 px — none of this can
   reach desktop. The dock is sticky inside #sim-panel, never position:fixed on the page. */
.m-stage-tabs, .m-dock, .m-setchip { display: none; }
@media (max-width: 720px) {
  body.vl-m header { padding: 0; }
  body.vl-m header h1 { font-size: 1.15rem; line-height: 1.2; }
  body.vl-m .subtitle { font-size: 0.7rem; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  body.vl-m .m-banner { padding: 6px; gap: 6px; flex-direction: column; align-items: stretch; }
  body.vl-m .m-banner .ctrl-label { display: none; }
  body.vl-m .m-banner .ctrl-group { display: block; }
  body.vl-m #mode-tabs { display: grid; grid-template-columns: repeat(4, 1fr); }
  body.vl-m #mode-tabs .pill { min-height: 36px; padding: 0 4px; font-size: 0.8rem; font-weight: 700; }
  body.vl-m .m-banner .head-actions { display: flex; flex-wrap: nowrap; justify-content: space-between; gap: 6px; margin: 0; width: 100%; }
  body.vl-m .m-banner .head-actions > a, body.vl-m .m-banner .head-actions > button { flex: 1 1 0; min-width: 0; height: 38px; padding: 0 !important; justify-content: center; border-radius: 9px; }
  body.vl-m .m-banner .btn-link .lbl, body.vl-m .m-banner .btn-share-ext { display: none; }
  body.vl-m .m-banner .btn-link img { width: 22px; height: 22px; }
  body.vl-m .m-banner .head-actions > button.btn-link, body.vl-m .m-banner .btn-guide { font-size: 0 !important; display: inline-flex; align-items: center; }
  body.vl-m .m-banner .head-actions > button.btn-link::before { content: '\1F517'; font-size: 17px; }
  body.vl-m .m-banner .btn-guide::before { content: '\1F4D6'; font-size: 17px; }
  body.vl-m .m-setchip { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 38px; margin: 0 0 8px; padding: 0 12px;
    background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 10px; color: var(--text); font: 600 .78rem/1.2 var(--font); cursor: pointer; text-align: left; }
  body.vl-m .m-setchip-txt { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  /* stage: bench + strip; the rail is emptied into the sheet */
  body.vl-m .sim-rail { display: none; }
  body.vl-m .sim-layout { gap: 0; }
  body.vl-m .canvas-dock { padding: 6px 8px; }
  body.vl-m .canvas-dock .dock-sep { display: none; }
  body.vl-m .canvas-dock .vt-pill { height: 38px; }
  body.vl-m #readouts { grid-template-columns: repeat(3, 1fr); gap: 4px; margin: 6px 0 0; }
  body.vl-m #readouts .readout-cell { padding: 5px 6px; min-width: 0; }
  body.vl-m #readouts .readout-label { font-size: .5rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  body.vl-m #readouts .readout-value { font-size: .75rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  /* dock */
  body.vl-m .m-dock { display: block; position: sticky; bottom: var(--m-anchor, 0px); z-index: 60; margin-top: 8px; padding: 0 0 env(safe-area-inset-bottom); pointer-events: none; }
  body.vl-m .m-dock > * { pointer-events: auto; }
  body.vl-m .m-bar { display: flex; gap: 6px; align-items: stretch; margin: 0 0 8px; padding: 6px; background: rgba(18,22,32,0.94); backdrop-filter: blur(8px); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 -6px 24px rgba(0,0,0,.45); }
  body.vl-m .m-run { flex: 1; display: flex; gap: 6px; min-width: 0; }
  body.vl-m .m-run .btn { flex: 1 1 0; min-width: 0; min-height: 46px; margin: 0; padding: 2px 4px; font-size: .74rem; line-height: 1.15; border-radius: 10px; white-space: normal; background: var(--surface2); color: var(--text); border: 1.5px solid var(--border); font-weight: 700; }
  body.vl-m .m-run .btn-spin { background: #1f9d55; border-color: #1f9d55; color: #fff; flex: 1.4 1 0; }
  body.vl-m .m-run .btn:disabled { opacity: .45; }
  body.vl-m .m-setup { flex: none; width: 58px; min-height: 46px; border-radius: 10px; border: 2px solid var(--border); background: var(--surface2); color: var(--text); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; font-family: inherit; cursor: pointer; }
  body.vl-m .m-setup-ic { font-size: 1.05rem; line-height: 1; }
  body.vl-m .m-setup-lbl { font-size: 0.6rem; font-weight: 700; letter-spacing: .03em; }
  body.vl-m .m-setup[aria-expanded="true"] { background: var(--accent); border-color: var(--accent); color: #0d1117; }
  body.vl-m .m-sheet { display: flex; flex-direction: column; margin: 0 0 6px; overflow: hidden; background: rgba(22,27,38,0.97); backdrop-filter: blur(10px); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 -8px 30px rgba(0,0,0,.5); }
  body.vl-m .m-sheet[hidden] { display: none; }
  body.vl-m .m-sheet-tabs { flex: none; display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px; padding: 4px; border-bottom: 1px solid var(--border); }
  body.vl-m .m-sheet-tabs button { min-height: 36px; border: 0; border-radius: 8px; background: transparent; color: var(--text-dim); font-family: inherit; font-size: 0.72rem; font-weight: 700; cursor: pointer; }
  body.vl-m .m-sheet-tabs button[aria-selected="true"] { background: var(--surface2); color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }
  body.vl-m .m-pane { flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain; padding: 10px; display: flex; flex-direction: column; gap: 10px; }
  body.vl-m .m-pane[hidden] { display: none; }
  body.vl-m .m-pane .rail-card { border: 0; padding: 0; background: none; }
  body.vl-m .m-pane .rail-head { display: none; }
  body.vl-m .m-pane .preset-grid { grid-template-columns: 1fr 1fr; }
  body.vl-m .m-pane .pill-row .pill { min-height: 38px; }
  body.vl-m .m-pane .prow-num input, body.vl-m .m-pane .slot-angle .prow-num input { width: 64px; height: 36px; }
  body.vl-m .m-pane .slot-head select { height: 38px; }
  body.vl-m .m-pane .slot-on input { width: 22px; height: 22px; }
  body.vl-m .m-pane .rail-tools .btn { min-height: 44px; }
  body.vl-m .m-pane .status-line { font-size: .8rem; }
}

/* ═══ Valve Simulator ═══ */
.rail-sub { margin-left: auto; font-size: .64rem; font-weight: 600; color: var(--text-dim); text-transform: none; letter-spacing: 0; }
.valve-groups { display: flex; flex-direction: column; gap: 8px; }
.vg-head { display: flex; align-items: center; gap: 7px; font-size: .66rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--text-dim); margin-bottom: 4px; }
.vg-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.vg-job { font-weight: 500; text-transform: none; letter-spacing: 0; font-size: .7rem; opacity: .85; }
.vg-chips { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.valve-chip { display: flex; align-items: center; gap: 7px; min-height: 46px; padding: 5px 8px; border-radius: 9px; text-align: left;
  background: var(--bg); border: 1px solid var(--border); color: var(--text); cursor: pointer; font-family: var(--font); transition: border-color .15s, background .15s; }
.valve-chip:hover { border-color: var(--vc, var(--accent)); }
.valve-chip.active { border-color: var(--vc, var(--accent)); background: color-mix(in srgb, var(--vc, var(--accent)) 16%, transparent); }
.valve-chip svg { flex-shrink: 0; width: 34px; height: 22px; }
.vc-txt { display: flex; flex-direction: column; min-width: 0; }
.vc-name { font-size: .8rem; font-weight: 700; line-height: 1.15; }
.vc-tag { font-size: .64rem; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.valve-chip:focus-visible, .size-row .pill:focus-visible, .op-btn:focus-visible, .id-opt:focus-visible, .game-fn:focus-visible, .game-valve:focus-visible, .cmp-pick:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
#variant-row .pill { flex: 1 1 auto; }
#variant-row:empty { display: none; }
.size-row .pill { flex: 1 1 0; min-width: 0; padding: 5px 4px; font-size: .74rem; }
.size-row .pill:disabled { opacity: .3; cursor: not-allowed; }
#sel-scen { min-width: 0; flex: 1; max-width: 210px; height: 32px; border-radius: 6px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font-size: .8rem; padding: 0 6px; }
.op-grp { display: flex; gap: 4px; flex-wrap: wrap; }
.op-grp[hidden] { display: none; }
.op-btn { min-height: 40px; padding: 6px 11px; font-size: .8rem; white-space: nowrap; }
.op-btn.on { border-color: var(--accent); background: var(--accent-lo); }
.btn-slam { border-color: rgba(255,170,60,.55); color: #ffcf8a; }
.btn-slam:hover { background: rgba(255,170,60,.16); }
.canvas-dock #btn-tour { min-height: 40px; padding: 6px 12px; font-size: .82rem; white-space: nowrap; }
.vl3d-stage { aspect-ratio: 1000 / 620; min-height: 360px; }
#vl-canvas:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; }
.readout-cell.warn { border-color: rgba(255,170,60,.6); }
.readout-cell.bad { border-color: rgba(255,85,85,.7); }
.readout-cell.warn .readout-value { color: #ffcf8a; }
.readout-cell.bad .readout-value { color: #ff8a8a; }
.readout-sub { font-size: .66rem; color: var(--text-dim); }

/* practice: identify the valve */
.id-opts { display: grid; grid-template-columns: repeat(2, minmax(150px, 1fr)); gap: 6px; flex: 1 1 100%; }
.id-opts:empty, .id-opts[hidden] { display: none; }
.id-opt { min-height: 44px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface2); color: var(--text); font-weight: 700; font-size: .86rem; cursor: pointer; font-family: var(--font); }
.id-opt:hover:not(:disabled) { border-color: var(--accent); }
.id-opt.correct { border-color: var(--green); background: rgba(61,220,132,.16); }
.id-opt.wrong { border-color: var(--red); background: rgba(255,85,85,.16); }
.practice-input-group[hidden] { display: none; }

/* explore: the classification matrix */
.concept-card.wide { grid-column: 1 / -1; }
.cls-matrix { width: 100%; border-collapse: separate; border-spacing: 4px; margin-top: 10px; font-size: .78rem; }
.cls-matrix th { font-size: .66rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-dim); font-weight: 800; text-align: left; padding: 4px 6px; }
.cls-matrix td { background: var(--bg); border-radius: 7px; padding: 6px 8px; vertical-align: top; color: var(--text-dim); min-width: 70px; }
.cls-matrix td.on { background: var(--surface2); color: var(--text); }
.cls-matrix .cm-v { display: block; font-weight: 700; color: var(--text); cursor: pointer; background: none; border: 0; padding: 0; font: inherit; text-align: left; }
.cls-matrix .cm-v:hover { color: var(--accent); text-decoration: underline; }
.cls-matrix .cm-fn { font-weight: 800; white-space: nowrap; }
.cmw { overflow-x: auto; }

/* game */
.game-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.game-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: .78rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: .07em; font-weight: 700; }
.game-score strong { color: var(--gold); font-size: 1rem; }
.game-best { text-transform: none; letter-spacing: 0; font-weight: 500; margin-left: 6px; }
.game-text { font-size: 1.02rem; line-height: 1.55; color: var(--text); border-left: 3px solid var(--accent); padding: 6px 0 6px 12px; background: linear-gradient(90deg, var(--accent-lo), transparent 70%); border-radius: 0 8px 8px 0; }
.game-q { font-size: .82rem; font-weight: 800; color: var(--text); display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.game-num { display: inline-flex; width: 22px; height: 22px; border-radius: 50%; align-items: center; justify-content: center; background: var(--accent); color: #fff; font-size: .74rem; }
.game-fns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.game-fn { min-height: 52px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); color: var(--text); cursor: pointer; font-family: var(--font); padding: 6px 10px; text-align: left; display: flex; flex-direction: column; gap: 1px; }
.game-fn strong { font-size: .9rem; }
.game-fn span { font-size: .72rem; color: var(--text-dim); }
.game-fn:hover:not(:disabled) { border-color: var(--gc); }
.game-fn.picked { border-color: var(--gc); background: color-mix(in srgb, var(--gc) 16%, transparent); }
.game-valves { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.game-valve { min-height: 64px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); color: var(--text); cursor: pointer; font-family: var(--font); font-weight: 700; font-size: .82rem; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 6px; }
.game-valve svg { width: 42px; height: 26px; }
.game-valve:hover:not(:disabled) { border-color: var(--accent); }
.game-valve:disabled, .game-fn:disabled { cursor: default; }
.game-valve.best, .game-fn.right { border-color: var(--green); background: rgba(61,220,132,.16); }
.game-valve.ok { border-color: var(--gold); background: rgba(245,200,66,.14); }
.game-valve.wrong, .game-fn.wrong { border-color: var(--red); background: rgba(255,85,85,.14); }
.game-step.locked { opacity: .45; pointer-events: none; }
.game-result { font-size: .88rem; line-height: 1.55; color: var(--text); min-height: 1.2em; }
.game-result .gr-pts { font-weight: 800; color: var(--gold); }
.game-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

/* compare */
#compare-panel { display: flex; flex-direction: column; gap: 12px; }
.cmp-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.cmp-title { font-weight: 800; font-size: .95rem; }
.cmp-sub { font-size: .78rem; color: var(--text-dim); margin-top: 3px; }
.cmp-picks { display: flex; flex-wrap: wrap; gap: 5px; }
.cmp-pick { min-height: 34px; padding: 4px 10px 4px 8px; border-radius: 18px; border: 1px solid var(--border); background: var(--bg); color: var(--text-dim); cursor: pointer; font-family: var(--font); font-size: .78rem; font-weight: 700; display: inline-flex; align-items: center; gap: 6px; }
.cmp-pick i { width: 10px; height: 10px; border-radius: 50%; background: var(--pc); opacity: .35; }
.cmp-pick[aria-pressed="true"] { color: var(--text); border-color: var(--pc); }
.cmp-pick[aria-pressed="true"] i { opacity: 1; }
.cmp-grid { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 12px; align-items: start; }
.cmp-chart-card canvas { display: block; width: 100%; height: auto; }
.cmp-side { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.cmp-x { font-family: var(--mono); font-weight: 700; color: var(--accent); }
.cmp-table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.cmp-table { width: 100%; border-collapse: collapse; font-size: .8rem; }
.cmp-table th { text-align: left; padding: 8px 10px; color: var(--text-dim); font-size: .66rem; text-transform: uppercase; letter-spacing: .05em; border-bottom: 1px solid var(--border); white-space: nowrap; }
.cmp-table td { padding: 7px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; font-family: var(--mono); color: var(--text); }
.cmp-table td:first-child { font-family: var(--font); font-weight: 700; }
.cmp-table tr:last-child td { border-bottom: 0; }
.cmp-table .rg-clean { color: var(--green); }
.cmp-table .rg-incipient { color: var(--gold); }
.cmp-table .rg-cavitating, .cmp-table .rg-choked, .cmp-table .rg-flashing { color: #ff8a65; }
.cmp-table .sw { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: 0; }

@media (max-width: 900px) { .cmp-grid { grid-template-columns: 1fr; } }
@media (max-width: 768px) {
  .game-valves { grid-template-columns: repeat(2, 1fr); }
  .vl3d-stage { aspect-ratio: 4 / 3.2; min-height: 300px; }
}
@media (max-width: 500px) {
  .game-fns { grid-template-columns: 1fr; }
  .id-opts { grid-template-columns: 1fr; }
  .canvas-dock .op-grp { flex: 1 1 100%; }
  .canvas-dock .op-grp .btn { flex: 1 1 0; }
  #mode-tabs { flex-wrap: wrap; }
}
@media (max-width: 720px) {
  body.vl-m #mode-tabs { grid-template-columns: repeat(3, 1fr); }
  body.vl-m .m-run .op-grp { flex: 1 1 100%; display: flex; gap: 6px; }
  body.vl-m .m-run .op-grp .btn { flex: 1 1 0; }
  body.vl-m .m-pane .vg-chips { grid-template-columns: 1fr 1fr; }
  body.vl-m .m-pane .valve-chip { min-height: 44px; }
  body.vl-m .m-pane .size-row .pill { min-height: 38px; }
  body.vl-m .m-pane #sel-scen { height: 38px; max-width: none; }
}
/* Line & water: a wide card under the picture */
.line-card { margin-top: 0; }
.line-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 18px; align-items: start; }
.line-grid .prow:nth-child(2) { grid-column: span 2; }
.prow .sim-slider, .line-grid .sim-slider, .rail-card .sim-slider { width: 100%; }
.vg-head { flex-wrap: wrap; row-gap: 0; }
.vg-job { flex: 1 1 auto; }
@media (max-width: 900px) { .line-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .line-grid .prow:nth-child(2) { grid-column: 1 / -1; } }
@media (max-width: 500px) { .line-grid { grid-template-columns: 1fr; } }
@media (max-width: 720px) {
  body.vl-m .m-pane .line-card { border: 0; padding: 0; background: none; }
  body.vl-m .m-pane .line-grid { grid-template-columns: 1fr; }
  body.vl-m .m-pane .line-grid .prow:nth-child(2) { grid-column: auto; }
  body.vl-m .m-run .op-grp .btn, body.vl-m .m-run #pump-grp .btn { background: var(--surface2); border: 1px solid var(--border); color: var(--text); min-height: 46px; font-size: .74rem; }
  body.vl-m .m-run .btn-slam { color: #ffcf8a; border-color: rgba(255,170,60,.55); }
  body.vl-m .canvas-dock #btn-tour { flex: 1 1 auto; }
}
@media (max-width: 720px) { body.vl-m .m-run .op-grp[hidden] { display: none; } }

/* ═══ Control valve lab ═══ */
.faceplate { border: 1px solid var(--border, #273049); border-radius: 10px; padding: 10px; background: rgba(255,255,255,.02); display: flex; flex-direction: column; gap: 9px; }
.fp-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.fp-tag { font-weight: 800; letter-spacing: .04em; color: #ffd166; font-size: .85rem; }
.fp-bars { display: flex; flex-direction: column; gap: 4px; }
.fp-bar { display: grid; grid-template-columns: 46px 1fr 38px; align-items: center; gap: 6px; font-size: .72rem; color: var(--text-dim, #9aa4b8); }
.fp-track { height: 7px; border-radius: 4px; background: #0d1220; border: 1px solid #273049; overflow: hidden; }
.fp-fill { display: block; height: 100%; border-radius: 4px; }
.fp-v { text-align: right; font-variant-numeric: tabular-nums; color: #d7deea; }
.fp-tune { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-items: end; }
.fp-tune .pill-row, .fp-tune .btn { grid-column: 1 / -1; }
.fp-k { display: flex; flex-direction: column; gap: 3px; font-size: .74rem; color: var(--text-dim, #9aa4b8); }
.fp-k input { width: 100%; background: #0d1220; border: 1px solid #2a3350; color: #e8eef8; border-radius: 6px; padding: 5px 7px; font: inherit; font-size: .82rem; }
#cl-upset.active { border-color: #ff9b7a; color: #ffb59c; }
#cl-air[aria-pressed="true"] { background: rgba(255,107,107,.18); border-color: #ff6b6b; }
.sizing-card { margin-top: 12px; }
.sz-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.sz-f { display: flex; flex-direction: column; gap: 4px; font-size: .76rem; color: var(--text-dim, #9aa4b8); min-width: 0; }
.sz-f select, .sz-in input { width: 100%; background: #0d1220; border: 1px solid #2a3350; color: #e8eef8; border-radius: 6px; padding: 6px 8px; font: inherit; font-size: .84rem; min-width: 0; }
.sz-in { display: flex; align-items: center; gap: 6px; }
.sz-out { margin-top: 10px; }
.sz-info { font-size: .82rem; color: #c9d2e3; margin: 0 0 8px; }
.sz-warn { color: #ffb59c; font-size: .84rem; }
.sz-table td.sz-ok { color: #7be0b0; font-weight: 700; } .sz-table td.sz-choked, .sz-table td.sz-flashing { color: #ff8a65; font-weight: 700; } .sz-table td.sz-cavitating { color: #ffd166; font-weight: 700; }
.sz-load { padding: 3px 10px; font-size: .76rem; }
@media (max-width: 900px) { .sz-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 500px) { .sz-grid { grid-template-columns: 1fr; } .fp-tune { grid-template-columns: 1fr 1fr; } }
#ctrl-panel .line-grid .prow:nth-child(2) { grid-column: auto; }
#ctrl-panel .line-grid .prow[hidden] { display: none; }
@media (max-width: 720px) { body.vl-m #ctrl-panel .sim-rail { display: flex; flex-direction: column; } body.vl-m #ctrl-panel .sim-layout { gap: 12px; } }
@media (max-width: 720px) {
  body.vl-m #ctrl-panel .sim-layout { display: flex; flex-direction: column; }
  body.vl-m #ctrl-panel .sim-main { display: contents; }
  body.vl-m #ctrl-panel #cl-card { order: 1; } body.vl-m #ctrl-panel #cl-status { order: 2; }
  body.vl-m #ctrl-panel #cl-readouts { order: 3; } body.vl-m #ctrl-panel .sim-rail { order: 4; }
  #ctrl-panel .canvas-dock { flex-wrap: wrap; }
}
.canvas-card canvas#cl-canvas { display: block; width: 100%; touch-action: pan-y; border-radius: var(--radius) var(--radius) 0 0; }
.canvas-card canvas#cl-canvas[hidden] { display: none; }
#cl3d-stage { aspect-ratio: 1000 / 700; min-height: 380px; }
@media (max-width: 720px) { #cl3d-stage { aspect-ratio: 3 / 4; min-height: 320px; } }
.vt-tabs[hidden] { display: none !important; }
.cc-lab { margin-top: 10px; font-size: .8rem; }

/* ═══ Layout polish (2026-11-18): one reading order on the page ═══
   picture → operate it (bar under the picture) → what happened (status + readings under it) ;
   the valve / assembly choice in the rail beside it ; the line and process settings full width below. */
.sim-layout { align-items: stretch; }
.sim-rail > .rail-card:last-of-type { flex: 1 1 auto; }
.rail-sub { margin-left: auto; font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--text-dim); font-size: .72rem; }
/* the operate bar: what you do to the valve, right under the valve */
.op-bar { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; padding: 10px 14px; border-top: 1px solid var(--border); background: rgba(56,189,248,.045); }
.op-tag { display: inline-flex; align-items: center; gap: 7px; font-size: .74rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--text); white-space: nowrap; }
.op-ctrls { flex: 1 1 300px; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.op-ctrls .prow { gap: 4px; }
.op-ctrls .prow-note { margin: 0; }
.op-ctrls > .prow-note:not([hidden]) { font-size: .78rem; color: var(--text); }
.op-bar .op-grp { flex: 0 0 auto; }
.op-bar .dock-tools { margin-left: auto; }
/* the dock: how you look at it */
.canvas-dock { padding: 8px 12px; }
.dock-tools { display: flex; gap: 6px; }
.dock-tools .btn { min-height: 40px; padding: 6px 11px; font-size: .8rem; white-space: nowrap; }
.canvas-dock .dock-tools { margin-left: auto; }
.canvas-dock .dock-tools + .dock-reset { margin-left: 0; }
/* readings under the picture: whole rows of equal cards */
.sim-main .readout-panel { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin: 0; }
.sim-main .readout-cell { padding: 9px 11px; min-width: 0; }
.sim-main .readout-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sim-main .readout-value { font-size: .95rem; }
.sim-main .readout-sub { font-size: .7rem; }
/* full-width settings cards: one row of controls each */
#sim-panel > .line-card .line-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px 20px; }
#sim-panel > .line-card .line-grid .prow:nth-child(1) { grid-column: span 2; }
#sim-panel > .line-card .line-grid .prow:nth-child(2) { grid-column: span 3; }
#sim-panel > .line-card #sel-scen { width: 100%; max-width: none; }
#ctrl-panel > .line-card .line-grid { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px 20px; }
#ctrl-panel .sim-rail { gap: 12px; }
@media (max-width: 1100px) {
  .sim-rail > .rail-card:last-of-type { flex: initial; }
  #sim-panel .sim-rail { display: flex; }
  #sim-panel .vg-chips { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .sim-main .readout-panel { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  #sim-panel > .line-card .line-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  #sim-panel > .line-card .line-grid .prow:nth-child(1) { grid-column: span 1; }
  #sim-panel > .line-card .line-grid .prow:nth-child(2) { grid-column: span 2; }
}
@media (max-width: 900px) {
  #sim-panel .vg-chips { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .sim-main .readout-panel { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}
@media (max-width: 900px) {
  #sim-panel > .line-card .line-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #sim-panel > .line-card .line-grid .prow:nth-child(1), #sim-panel > .line-card .line-grid .prow:nth-child(2) { grid-column: 1 / -1; }
}
@media (max-width: 500px) {
  #sim-panel > .line-card .line-grid, #ctrl-panel > .line-card .line-grid { grid-template-columns: 1fr; }
  .op-bar { padding: 8px; }
  .op-bar .op-grp, .op-bar .dock-tools { flex: 1 1 100%; margin-left: 0; }
  .op-bar .op-grp .btn, .op-bar .dock-tools .btn { flex: 1 1 0; }
  .canvas-dock .dock-tools { margin-left: 0; }
}
/* identify practice: the picker would give the answer away, so it steps back */
body.vl-identify #valve-card .valve-groups { opacity: .35; pointer-events: none; filter: grayscale(.6); }
body.vl-identify #valve-card .rail-head::after { content: 'locked until you answer'; margin-left: auto; font-size: .7rem; font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--gold); }
body.vl-identify #valve-card .rail-sub { display: none; }
/* phone: the operate bar's contents move into the dock and the Setup sheet */
@media (max-width: 720px) {
  body.vl-m #op-bar { display: none; }
  body.vl-m .m-pane .op-ctrls { flex: initial; }
  body.vl-m .m-pane .dock-tools { flex-wrap: wrap; }
  body.vl-m .m-pane .dock-tools .btn { flex: 1 1 0; min-height: 44px; }
}

/* Compare: the side panel runs the height of the chart and says how to read it */
.cmp-grid { align-items: stretch; }
.cmp-read { border-top: 1px dashed var(--border); padding-top: 10px; }
.cmp-read-h { font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--text); margin-bottom: 6px; }
.cmp-read ul { margin: 0 0 0 16px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.cmp-read li { font-size: .78rem; line-height: 1.45; color: var(--text-dim); }
.cmp-read strong { color: var(--text); }
.cmp-foot { margin-top: auto; }
/* Explore: cards fill every row (no holes); a wide card takes a row of its own */
.concept-grid { display: flex; flex-wrap: wrap; gap: 12px; }
.concept-grid > .concept-card { flex: 1 1 280px; min-width: 0; }
.concept-grid > .concept-card.wide { flex-basis: 100%; }
@media (max-width: 720px) { body.vl-m #sim-panel .vg-chips { grid-template-columns: 1fr 1fr; } }
#sim-panel > .line-card .prow-num input, #ctrl-panel > .line-card .prow-num input { width: 62px; }
