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

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

  /* ── Accent — Robot Arm (teal) ── */
  --accent:    #12a594;
  --accent-lo: rgba(18,165,148,.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; }
.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; }
}

.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; }

/* ═══ Robot Arm Simulator — layout ═══ */
.ctx-menu[hidden], .lib-modal[hidden], .edit-modal[hidden], .rb-msg[hidden], .run-dock[hidden], .lesson-bar[hidden] { display: none !important; }
.bi { width: 15px; height: 15px; fill: currentColor; stroke: currentColor; vertical-align: -2px; }
.btn-xs { padding: 5px 10px; font-size: 0.76rem; border-radius: 7px; }
.btn-explain { background: linear-gradient(120deg, #12a594, #0e7f8f); color: #fff; }
.btn-explain:hover { filter: brightness(1.1); }
.btn-explain[aria-pressed="true"] { background: var(--gold); color: #1b1606; }

.lesson-bar {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: start;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 12px;
}
.lb-lib { display: inline-flex; align-items: center; gap: 6px; }
.lb-title { font-weight: 700; font-size: 0.95rem; color: var(--text); }
.lb-goal { font-size: 0.82rem; color: var(--text-dim); margin-top: 2px; }
.lb-checks { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.lb-checks li { font-size: 0.74rem; padding: 3px 9px 3px 7px; border-radius: 999px; background: var(--surface2); border: 1px solid var(--border); color: var(--text-dim); display: inline-flex; gap: 5px; align-items: center; }
.lb-checks li::before { content: '○'; color: var(--text-dim); }
.lb-checks li.ok { border-color: rgba(61,220,132,.55); color: var(--text); background: rgba(61,220,132,.1); }
.lb-checks li.ok::before { content: '✓'; color: var(--green); font-weight: 800; }
.lb-done { font-size: 0.8rem; color: var(--green); font-weight: 700; margin-top: 6px; }
.lb-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.sim-layout { display: grid; grid-template-columns: minmax(0, 1fr) 390px; gap: 14px; align-items: start; }
.sim-main { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.canvas-card { position: relative; padding: 0; overflow: hidden; }
.rb-stage { position: relative; width: 100%; height: clamp(420px, calc(100vh - 260px), 640px); background: #0b0f16; border-radius: var(--radius); }
.rb-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.rb-stage .rb3d-hud { touch-action: none; cursor: grab; }
.rb-stage .rb3d-hud:active { cursor: grabbing; }
.rb-msg { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; padding: 30px; color: var(--text-dim); font-size: 0.9rem; background: rgba(11,15,22,.92); border-radius: var(--radius); }
.view-bar { position: absolute; right: 12px; bottom: 34px; display: flex; gap: 4px; z-index: 3; }
.vb { padding: 5px 9px; min-height: 30px; border-radius: 7px; border: 1px solid var(--border); background: rgba(13,17,23,.85); color: var(--text-dim); font-size: 0.74rem; font-weight: 700; cursor: pointer; }
.vb:hover { color: var(--text); border-color: var(--accent); }

.run-dock { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 10px; }
.rd-group { display: flex; background: var(--bg); border-radius: 8px; padding: 3px; gap: 2px; }
.mode-btn { padding: 6px 11px; border: none; background: transparent; color: var(--text-dim); border-radius: 6px; font-weight: 800; font-size: 0.78rem; cursor: pointer; }
.mode-btn[aria-pressed="true"] { background: var(--accent); color: #fff; }
.mode-btn[data-mode="AUTO"][aria-pressed="true"] { background: #c2410c; }
.run-dock .btn { padding: 7px 12px; font-size: 0.8rem; }
.rd-step[aria-pressed="true"] { background: var(--gold); color: #1b1606; border-color: var(--gold); }
.btn-dead { background: #3b2f12; color: var(--gold); border: 1.5px solid #8a6d1f; user-select: none; -webkit-user-select: none; touch-action: none; }
.btn-dead.on { background: var(--gold); color: #1b1606; box-shadow: 0 0 14px rgba(245,200,66,.45); }
.rd-ovr { display: inline-flex; align-items: center; gap: 6px; font-size: 0.74rem; color: var(--text-dim); margin-left: auto; }
.rd-ovr input { width: 110px; }
.rd-ovr b { color: var(--accent); font-family: var(--mono); min-width: 38px; }

.readouts { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; }
.ro { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 4px 8px; min-width: 0; }
.ro-l { font-size: 0.64rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-dim); }
.ro-v { font-family: var(--mono); font-size: 0.8rem; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ro-wide { grid-column: span 2; }

/* ── pendant ── */
.pendant, .kinpanel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; display: flex; flex-direction: column; gap: 8px; max-height: calc(100vh - 140px); min-height: 520px; overflow: hidden; }
.kinpanel { overflow-y: auto; }
.pendant[hidden], .kinpanel[hidden] { display: none; }
.pd-status { font-family: var(--mono); font-size: 0.74rem; background: #0a0e14; border: 1px solid var(--border); border-radius: 8px; padding: 6px 9px; color: #9fe8d6; display: grid; grid-template-columns: 1fr 1fr; gap: 2px 10px; }
.pd-status .st-fault { grid-column: 1 / -1; color: #fca5a5; white-space: normal; }
.pd-tabs { display: flex; flex-wrap: wrap; gap: 3px; background: var(--bg); border-radius: 8px; padding: 3px; }
.pd-tab { flex: 1 1 auto; padding: 6px 8px; border: none; border-radius: 6px; background: transparent; color: var(--text-dim); font-size: 0.76rem; font-weight: 700; cursor: pointer; }
.pd-tab.active { background: var(--accent); color: #fff; }
.pd-pane { display: flex; flex-direction: column; gap: 8px; min-height: 0; flex: 1 1 auto; overflow-y: auto; }
.pd-pane[hidden] { display: none; }
.pd-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.pd-row select, .pd-lab select { background: var(--surface2); color: var(--text); border: 1px solid var(--border); border-radius: 7px; padding: 5px 8px; font-size: 0.8rem; }
#sel-prog { flex: 1 1 120px; min-width: 0; }
.pd-lab { font-size: 0.72rem; color: var(--text-dim); display: inline-flex; align-items: center; gap: 5px; }
.pd-note { font-size: 0.74rem; color: var(--text-dim); line-height: 1.45; }
.pd-err { font-size: 0.76rem; color: var(--red); }
.seg { display: inline-flex; background: var(--bg); border-radius: 7px; padding: 2px; gap: 2px; }
.seg-wide { display: flex; }
.seg-wide .seg-b { flex: 1; }
.seg-b { padding: 5px 9px; border: none; border-radius: 5px; background: transparent; color: var(--text-dim); font-size: 0.74rem; font-weight: 700; cursor: pointer; }
.seg-b.active { background: var(--surface2); color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.softkeys { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.sk { padding: 6px 2px; min-height: 30px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface2); color: var(--text); font-size: 0.72rem; font-weight: 700; cursor: pointer; }
.sk:hover { border-color: var(--accent); color: var(--accent); }
.sk-touch { color: var(--gold); border-color: #6b5413; }
.sk-touch { grid-column: 1 / -1; }
/* the program editor: a transparent textarea over a coloured copy (keep font, size, line height and padding identical) */
.pd-ed { position: relative; height: 340px; background: #0a0e14; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.pd-ed:focus-within { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-lo); }
.pd-ed.locked { border-color: #6b5413; }
.ed-hl { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.ed-hl-in { padding: 6px 0; will-change: transform; }
.ed-hl .el, #ed-ta { font-family: var(--mono); font-size: 13px; line-height: 20px; }
.ed-hl .el { height: 20px; white-space: pre; color: #cfd8e6; border-left: 3px solid transparent; padding-right: 10px; }
.ed-hl .el i { display: inline-block; width: 34px; padding-right: 9px; text-align: right; color: #5b6780; font-style: normal; }
.ed-hl .el.sel { background: rgba(18,165,148,.12); }
.ed-hl .el.cur { border-left-color: var(--gold); background: rgba(245,200,66,.16); }
.ed-hl .el.fault, .ed-hl .el.err { background: rgba(255,85,85,.10); }
.ed-hl .el.err span { color: #fca5a5; text-decoration: underline wavy rgba(255,85,85,.7); }
.ed-hl .c-mo { color: #7dd3fc; } .ed-hl .c-io { color: #fbbf24; } .ed-hl .c-fl { color: #c4b5fd; } .ed-hl .c-cm { color: #6b7a99; font-style: italic; } .ed-hl .c-rg { color: #86efac; }
#ed-ta { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; border: 0; outline: none; resize: none; background: transparent; color: transparent; caret-color: #f8fafc; padding: 6px 10px 6px 37px; white-space: pre; overflow: auto; tab-size: 4; }
#ed-ta::selection { background: rgba(125,211,252,.28); color: transparent; }
#ed-ta[readonly] { cursor: default; }
.ed-msg { display: flex; flex-direction: column; gap: 2px; min-height: 0; font-size: 0.76rem; }
.ed-msg:empty { display: none; }
.em-err { color: #fca5a5; } .em-info { color: var(--text-dim); }
.pd-hint { font-size: 0.72rem; color: var(--text-dim); margin-left: auto; }
.ed-ref summary { cursor: pointer; font-size: 0.74rem; color: var(--text-dim); }
.ed-ref pre { margin: 6px 0 0; padding: 8px 10px; background: #0a0e14; border: 1px solid var(--border); border-radius: 8px; font-family: var(--mono); font-size: 0.74rem; color: #cfd8e6; white-space: pre-wrap; }
.pd-file { border-top: 1px solid var(--border); padding-top: 7px; }

.jog-grid { display: grid; grid-template-columns: 44px minmax(0, 1fr) 54px 54px; gap: 5px 6px; align-items: center; }
.jg-l { font-weight: 800; font-size: 0.82rem; color: var(--text); }
.jg-v { font-family: var(--mono); font-size: 0.82rem; color: var(--accent); text-align: right; padding-right: 4px; }
.jg-b { min-height: 38px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface2); color: var(--text); font-size: 1rem; font-weight: 800; cursor: pointer; user-select: none; -webkit-user-select: none; touch-action: none; }
.jg-b:hover { border-color: var(--accent); }
.jg-b:active, .jg-b.on { background: var(--accent); color: #fff; }

.pos-list { display: flex; flex-direction: column; gap: 3px; max-height: 220px; overflow-y: auto; }
.pos-it { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 6px; padding: 5px 8px; border-radius: 7px; background: var(--surface2); border: 1px solid transparent; cursor: pointer; font-size: 0.76rem; text-align: left; color: var(--text); }
.pos-it b { color: var(--accent); }
.pos-it span { font-family: var(--mono); color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pos-it.sel { border-color: var(--accent); }
.pos-edit { display: flex; flex-direction: column; gap: 6px; }
.pe-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.pe-grid label { font-size: 0.68rem; color: var(--text-dim); display: flex; flex-direction: column; gap: 2px; }
.pe-grid input, .fr-grid input, .data-wrap input { width: 100%; background: var(--surface2); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 4px 6px; font-family: var(--mono); font-size: 0.78rem; }

.io-wrap, .data-wrap, .frames-wrap { display: flex; flex-direction: column; gap: 10px; }
.io-h { font-size: 0.66rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); border-bottom: 1px solid var(--border); padding-bottom: 3px; }
.io-row { display: grid; grid-template-columns: 54px minmax(0, 1fr) auto; gap: 6px; align-items: center; font-size: 0.76rem; }
.io-row b { font-family: var(--mono); }
.io-row span { color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lamp { width: 30px; height: 18px; border-radius: 9px; background: #262c36; border: 1px solid var(--border); }
.lamp.on { background: var(--green); box-shadow: 0 0 8px rgba(61,220,132,.5); }
.io-tg { padding: 3px 9px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface2); color: var(--text-dim); font-size: 0.72rem; font-weight: 800; cursor: pointer; min-width: 46px; }
.io-tg.on { background: var(--green); color: #062b17; border-color: var(--green); }
.data-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px 8px; }
.data-grid label { display: grid; grid-template-columns: 46px minmax(0, 1fr); gap: 4px; align-items: center; font-family: var(--mono); font-size: 0.74rem; color: var(--text-dim); }
.pr-row { display: grid; grid-template-columns: 50px minmax(0, 1fr) auto auto; gap: 5px; align-items: center; font-size: 0.72rem; font-family: var(--mono); color: var(--text-dim); }
.fr-card { background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.fr-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.fr-grid label { font-size: 0.66rem; color: var(--text-dim); display: flex; flex-direction: column; gap: 2px; }
.fr-steps { display: flex; flex-wrap: wrap; gap: 4px; }
.fr-steps .btn.done { border-color: var(--green); color: var(--green); }
.fr-out { font-family: var(--mono); font-size: 0.74rem; color: var(--text-dim); }

/* ── kinematics ── */
.kin-card { background: var(--surface2); border: 1px solid var(--border); border-radius: 9px; padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; }
.kin-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: 0.74rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: var(--accent); }
.kin-joints { display: grid; grid-template-columns: 26px minmax(0, 1fr) 64px; gap: 4px 6px; align-items: center; font-size: 0.78rem; }
.kin-joints input[type="range"] { width: 100%; }
.kin-joints output { font-family: var(--mono); color: var(--text); text-align: right; font-size: 0.78rem; }
.kin-table { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: 0.72rem; }
.kin-table th, .kin-table td { border: 1px solid var(--border); padding: 3px 5px; text-align: right; color: var(--text-dim); }
.kin-table th { color: var(--text); background: var(--bg); }
.kin-mat { font-family: var(--mono); font-size: 0.72rem; color: var(--text); line-height: 1.45; white-space: pre; overflow-x: auto; }
.kin-ik-in { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.kin-ik-in label { font-size: 0.66rem; color: var(--text-dim); display: flex; flex-direction: column; gap: 2px; }
.kin-ik-in input { width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 4px 6px; font-family: var(--mono); font-size: 0.76rem; }
.ik-sol { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 6px; padding: 4px 6px; border-radius: 6px; cursor: pointer; font-family: var(--mono); font-size: 0.7rem; color: var(--text-dim); border: 1px solid transparent; background: none; text-align: left; }
.ik-sol:hover { border-color: var(--accent); }
.ik-sol.lim { color: #fca5a5; }
.ik-sol.sel { border-color: var(--gold); color: var(--text); }
.kin-chk { font-size: 0.74rem; color: var(--text-dim); display: flex; gap: 6px; align-items: center; }
#kin-map { width: 100%; height: auto; border-radius: 7px; background: #0a0e14; }

/* ── library and edit dialogs ── */
.lib-modal, .edit-modal { position: fixed; inset: 0; z-index: 1400; background: rgba(5,8,12,.7); display: flex; align-items: center; justify-content: center; padding: 16px; }
.lib-box { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; width: min(760px, 100%); max-height: 88vh; overflow-y: auto; padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; }
.edit-box { width: min(560px, 100%); }
.lib-headr { display: flex; justify-content: space-between; align-items: center; font-weight: 800; font-size: 1.02rem; color: var(--text); }
.calc-modal-close { background: var(--surface2); border: 1px solid var(--border); color: var(--text); border-radius: 8px; width: 34px; height: 34px; cursor: pointer; }
.lib-intro { font-size: 0.84rem; color: var(--text-dim); }
.lib-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.lib-item { text-align: left; background: var(--surface2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; cursor: pointer; color: var(--text); display: flex; flex-direction: column; gap: 3px; }
.lib-item:hover { border-color: var(--accent); }
.lib-item.cur { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent-lo); }
.lib-item b { font-size: 0.86rem; }
.lib-item span { font-size: 0.74rem; color: var(--text-dim); line-height: 1.4; }
.lib-item i { font-style: normal; font-size: 0.68rem; color: var(--accent); font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.lib-item .lib-done { color: var(--green); }
#edit-input { width: 100%; background: #0a0e14; color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 9px 10px; font-family: var(--mono); font-size: 0.88rem; }

/* ── explore extras ── */
.lang-wrap { margin-top: 14px; overflow-x: auto; }
.lang-wrap table { border-collapse: collapse; width: 100%; font-size: 0.8rem; }
.lang-wrap th, .lang-wrap td { border: 1px solid var(--border); padding: 6px 9px; text-align: left; color: var(--text-dim); }
.lang-wrap td { font-family: var(--mono); font-size: 0.76rem; }
.lang-wrap th { color: var(--text); background: var(--surface2); }
.practice-topic { font-size: 0.68rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); flex: 1 1 100%; }
.mode-panel { display: flex; flex-direction: column; gap: 10px; }

.seo-article { content-visibility: auto; contain-intrinsic-size: auto none auto 5800px; }
.seo-article code { font-family: var(--mono); font-size: 0.85em; background: var(--surface2); padding: 1px 5px; border-radius: 4px; color: var(--gold); }
.seo-article h4 { font-size: 0.95rem; color: var(--text); margin: 14px 0 4px; }
.user-guide code { font-family: var(--mono); font-size: 0.85em; color: var(--gold); }

.rb-phone-note { display: none; }

@media (max-width: 1100px) {
  .readouts { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .pd-ed { height: 320px; }
}
@media (max-width: 768px) {
  .readouts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .lib-list { grid-template-columns: 1fr; }
  .rd-ovr { margin-left: 0; }
  .seo-article { contain-intrinsic-size: auto none auto 7200px; }
}
@media (max-width: 500px) {
  .readouts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .softkeys { grid-template-columns: repeat(4, 1fr); }
  .seo-article { contain-intrinsic-size: auto none auto 12000px; }
}
.rb-toast { font-size: 0.8rem; color: var(--text); background: var(--surface2); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 8px; padding: 0 12px; max-height: 0; opacity: 0; overflow: hidden; transition: max-height .2s, opacity .2s, padding .2s; }
.rb-toast.show { max-height: 80px; opacity: 1; padding: 7px 12px; }
.rb-phone { display: none; }
@media (max-width: 720px) {
  body.rb-m .rb-phone { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 16px; text-align: center; color: var(--text-dim); font-size: 0.9rem; line-height: 1.5; }
  body.rb-m .rb-phone b { color: var(--text); }
  body.rb-m #sim-panel { display: none !important; }
  body.rb-m .controls-bar { padding: 10px 12px; }
}
.seo-article pre { background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.08); border-radius: 8px; padding: 12px 14px; overflow-x: auto; max-width: 100%; font-size: 13px; line-height: 1.5; }
.seo-article pre code { background: none; padding: 0; }
.lb-run { min-width: 96px; font-weight: 700; }
.lb-run[aria-pressed="true"] { background: var(--gold); color: #1b1606; border-color: var(--gold); }

/* ── [RB-SHELL] one block for the whole simulator: lesson strip, 3D view, program panel, run bar and
   readouts are grid items of ONE card, so an auto ad has no gap between them to land in ── */
.sim-shell { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 8px 10px;
  grid-template-areas: "lesson lesson" "stage pend" "dock pend" "ro pend" "toast toast";
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; }
.sim-shell .sim-layout, .sim-shell .sim-main { display: contents; }
.sim-shell .lesson-bar { grid-area: lesson; margin: 0; padding: 0 0 8px; border: 0; border-bottom: 1px solid var(--border); border-radius: 0; background: none;
  grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; }
.sim-shell .lesson-bar[hidden] { display: none !important; }
.sim-shell .canvas-card { grid-area: stage; border: 0; }
.sim-shell .run-dock { grid-area: dock; flex-wrap: nowrap; gap: 5px; padding: 6px 8px; background: var(--bg); }
.sim-shell .readouts { grid-area: ro; }
.sim-shell .pendant, .sim-shell .kinpanel { grid-area: pend; height: 0; min-height: 100%; max-height: none; background: var(--bg); }
.sim-shell .rb-toast { grid-area: toast; }
.sim-shell .rb-toast:not(.show) { margin-top: -8px; }   /* an empty toast takes no row gap */
.rb-stage { height: clamp(380px, calc(100vh - 290px), 620px); }
.pd-ed { height: auto; flex: 1 1 180px; min-height: 160px; }
.readouts { grid-template-columns: repeat(7, minmax(0, 1fr)); }
.ro { padding: 3px 7px; background: var(--bg); }
.run-dock .btn { padding: 6px 9px; font-size: 0.76rem; white-space: nowrap; }
.mode-btn { padding: 6px 9px; }
.sim-shell .rd-ovr { flex: 1 1 60px; min-width: 56px; justify-content: flex-end; }
.sim-shell .rd-ovr input { width: auto; flex: 0 1 100px; min-width: 24px; }
.rd-ovr span { display: none; }
.lb-lib { padding: 6px 10px; }
.lb-main { display: flex; flex-wrap: wrap; align-items: center; gap: 3px 6px; min-width: 0; }
.lb-head { display: flex; align-items: baseline; gap: 8px; min-width: 0; flex: 1 1 100%; }
.lb-title { flex: none; font-size: 0.9rem; }
.lb-goal { margin: 0; font-size: 0.78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.lb-checks { margin: 0; gap: 4px; }
.lb-checks li { font-size: 0.7rem; padding: 1px 8px 1px 6px; }
.lb-done { margin: 0; font-size: 0.74rem; }
.lb-actions { flex-wrap: nowrap; }
.lb-actions .btn { padding: 6px 12px; }
@media (max-width: 1180px) {
  .sim-shell { grid-template-columns: minmax(0, 1fr) 330px; }
  .sim-shell .run-dock { gap: 3px; padding: 5px 6px; }
  .run-dock .btn { padding: 5px 7px; font-size: 0.7rem; }
  .mode-btn { padding: 5px 7px; font-size: 0.72rem; }
  .rd-ovr { gap: 4px; }
  .ro { padding: 3px 5px; }
  .ro-v { font-size: 0.7rem; }
  .pd-tabs { flex-wrap: nowrap; }
  .pd-tab { padding: 6px 4px; font-size: 0.7rem; }
}
@media (max-width: 1000px) and (min-width: 901px) {
  .run-dock .btn, .mode-btn { padding: 5px 4px; font-size: 0.64rem; }
  .rd-ovr b { min-width: 30px; font-size: 0.7rem; }
  .ro { padding: 3px 4px; }
  .ro-v { font-size: 0.64rem; }
  .ro:nth-child(n+13) .ro-v { font-size: 0.58rem; letter-spacing: -0.02em; }   /* Config and Frames are the two longest values */
}
@media (max-width: 900px) {
  .sim-shell { grid-template-columns: minmax(0, 1fr); grid-template-areas: "lesson" "stage" "dock" "ro" "pend" "toast"; }
  .sim-shell .pendant, .sim-shell .kinpanel { height: auto; min-height: 0; }
  .pd-ed { flex: none; height: 300px; }
}
@media (max-width: 760px) {
  .sim-shell .lesson-bar { grid-template-columns: auto minmax(0, 1fr); }
  .sim-shell .lb-actions { grid-column: 1 / -1; }
  .readouts { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.pd-row .ed-example { flex: 1 1 auto; min-width: 0; }
#sel-prog[hidden] { display: none; }

/* ── Program menu (opens upward from the foot of the pendant) ── */
.pm-wrap { position: relative; }
.pm-menu { position: absolute; left: 0; bottom: calc(100% + 4px); z-index: 20; min-width: 240px; padding: 5px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.45); display: flex; flex-direction: column; }
.pm-menu[hidden] { display: none; }
.pm-item { text-align: left; padding: 7px 10px; border: 0; border-radius: 7px; background: none; color: var(--text); font-size: 0.8rem; cursor: pointer; display: flex; justify-content: space-between; gap: 12px; }
.pm-item i { font-style: normal; color: var(--text-dim); font-family: var(--mono); font-size: 0.72rem; }
.pm-item:hover, .pm-item:focus-visible { background: var(--surface2); color: var(--accent); outline: none; }
.pm-sep { height: 1px; background: var(--border); margin: 4px 2px; }
.saved-list { display: flex; flex-direction: column; gap: 6px; max-height: 60vh; overflow-y: auto; }
.saved-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px; align-items: center; padding: 8px 10px; background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; }
.saved-row b { display: block; color: var(--text); font-size: 0.86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.saved-row span { font-size: 0.74rem; color: var(--text-dim); }
.vb-fs { color: var(--gold); border-color: #6b5413; }
.vb-fs[aria-pressed="true"] { background: var(--gold); color: #1b1606; }

/* ── [RB-FS] full screen: the same grid, filling the window; the 3D view takes the spare height and
   the program panel gets a wider column. Dialogs (z 1400) and the context menu (1300) stay on top. ── */
body.rb-fs { overflow: hidden; }
.sim-shell.fs { position: fixed; inset: 0; z-index: 1200; margin: 0; border: 0; border-radius: 0; padding: 10px 12px; width: 100vw; height: 100vh; height: 100dvh; max-width: none;
  grid-template-columns: minmax(0, 1fr) clamp(380px, 34vw, 600px); grid-template-rows: auto minmax(0, 1fr) auto auto auto; }
.sim-shell.fs .canvas-card { min-height: 0; }
.sim-shell.fs .rb-stage { height: 100%; }
@media (min-width: 1500px) { .sim-shell.fs .readouts { grid-template-columns: repeat(14, minmax(0, 1fr)); } }
@media (max-width: 900px) {
  .sim-shell.fs { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(260px, 1fr) auto auto minmax(0, 1.1fr) auto; overflow: hidden; }
  .sim-shell.fs .pendant, .sim-shell.fs .kinpanel { height: auto; min-height: 0; overflow: auto; }
  .sim-shell.fs .pd-ed { flex: 1 1 140px; height: auto; }
}
.jog-keep { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.jog-keep .btn { padding: 8px 6px; }
.jog-real { font-size: 0.74rem; color: var(--text-dim); display: inline-flex; gap: 6px; align-items: center; }
.btn-dead[hidden] { display: none; }
/* beginner flow: pendant buttons behind a toggle; the Sandbox steps are buttons */
.rd-adv { display: contents; }
.rd-adv[hidden] { display: none; }
.rd-adv-btn { white-space: nowrap; }
.rd-adv-btn[aria-expanded="true"] { color: var(--accent); border-color: var(--accent); }
.lb-checks li[data-go] { cursor: pointer; }
.lb-checks li[data-go]:not(.ok):hover, .lb-checks li[data-go]:not(.ok):focus-visible { border-color: var(--gold); color: var(--text); outline: none; }
/* mode buttons carry a plain-word caption under the code */
.mode-btn { display: inline-flex; flex-direction: column; align-items: center; line-height: 1.05; padding: 4px 8px; }
.mode-btn small { font-size: 0.58rem; font-weight: 600; opacity: 0.8; letter-spacing: 0.01em; white-space: nowrap; }
/* with the pendant buttons open the bar may take a second line rather than run off the edge */
.sim-shell .run-dock:has(.rd-adv:not([hidden])) { flex-wrap: wrap !important; row-gap: 5px; }
.sim-shell .rd-ovr input { min-width: 80px; }
.sim-shell .rd-ovr { min-width: 130px; flex-shrink: 0; }   /* slider + value: wraps as one piece, never overlaps the buttons */
/* ── the display rail: glassy round toggles down the left of the cell ── */
.vrail { position: absolute; left: 6px; top: 56px; z-index: 4; display: flex; flex-direction: column; gap: 5px; }
/* a short cell (small window): smaller buttons so all seven fit above the view bar */
.vrail.mid { gap: 4px; } .vrail.mid .vr-b { width: 38px; height: 38px; border-radius: 11px; } .vrail.mid .vr-b svg { width: 16px; height: 16px; } .vrail.mid .vr-b span { font-size: 0.46rem; }
.vrail.compact { gap: 4px; } .vrail.compact .vr-b { width: 34px; height: 34px; border-radius: 10px; } .vrail.compact .vr-b span { display: none; }
.vr-b { width: 42px; height: 42px; flex: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 0;
  border-radius: 12px; border: 1px solid rgba(255,255,255,.14); color: #8b96ad; cursor: pointer;
  background: linear-gradient(160deg, rgba(255,255,255,.12), rgba(255,255,255,.03)); -webkit-backdrop-filter: blur(8px) saturate(1.3); backdrop-filter: blur(8px) saturate(1.3);
  box-shadow: 0 6px 18px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.18); transition: color .15s, background .15s, border-color .15s, transform .1s; }
.vr-b svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.vr-b span { font-size: 0.5rem; font-weight: 700; letter-spacing: .02em; line-height: 1; }
.vr-b:hover { color: #e5ecf6; border-color: rgba(255,255,255,.3); }
.vr-b:active { transform: scale(.95); }
.vr-b:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.vr-b[aria-pressed="true"] { color: #5eead4; border-color: rgba(94,234,212,.55); background: linear-gradient(160deg, rgba(18,165,148,.38), rgba(18,165,148,.10)); box-shadow: 0 6px 18px rgba(0,0,0,.35), 0 0 12px rgba(94,234,212,.25), inset 0 1px 0 rgba(255,255,255,.22); }
.vr-b[aria-pressed="true"] svg circle { fill: currentColor; fill-opacity: .25; }
.vr-b[hidden] { display: none; }
.vr-b { will-change: transform; }

/* the Display Controls button is the top tile of the rail, in the same glass; its panel opens ABOVE the rail */
.canvas-card .canvas-toggles { top: 8px; left: 6px; z-index: 6; background: transparent; border: 0; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; max-width: calc(100% - 12px); }
.canvas-card .canvas-toggles > summary, .canvas-card .canvas-toggles[open] > summary {
  width: 42px; height: 42px; min-height: 0; padding: 0; gap: 2px; flex-direction: column; justify-content: center; align-items: center;
  border-radius: 12px; border: 1px solid rgba(255,255,255,.14); color: #8b96ad; text-transform: none; letter-spacing: .02em;
  background: linear-gradient(160deg, rgba(255,255,255,.12), rgba(255,255,255,.03)); -webkit-backdrop-filter: blur(8px) saturate(1.3); backdrop-filter: blur(8px) saturate(1.3);
  box-shadow: 0 6px 18px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.18); }
.canvas-card .canvas-toggles > summary .cvt-title, .canvas-card .canvas-toggles > summary .cvt-caret { display: none !important; }
.canvas-card .canvas-toggles .cvt-ico { width: 18px; height: 18px; color: currentColor; }
.canvas-card .canvas-toggles .cvt-knob { fill: currentColor; fill-opacity: .25; }
.canvas-card .canvas-toggles .vr-lbl { font-size: 0.5rem; font-weight: 700; line-height: 1; }
.canvas-card .canvas-toggles > summary:hover { color: #e5ecf6; background: linear-gradient(160deg, rgba(255,255,255,.16), rgba(255,255,255,.05)); border-color: rgba(255,255,255,.3); }
.canvas-card .canvas-toggles[open] > summary { color: #fcd34d; border-color: rgba(250,204,21,.55); background: linear-gradient(160deg, rgba(250,204,21,.28), rgba(250,204,21,.07)); }
.canvas-card .canvas-toggles .cvt-body { margin-top: 6px; min-width: 210px; background: rgba(13,17,23,.94); border: 1px solid rgba(255,255,255,.14); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.5); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
/* camera buttons in the bottom-right corner; Follow first */
.view-bar { right: 8px; bottom: 8px; }
.vb-follow { display: inline-flex; align-items: center; gap: 5px; }
.vb-follow svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.vb-follow[aria-pressed="true"] { color: #1b1606; background: var(--gold); border-color: var(--gold); }

/* HOLD latched: red and blinking until it is released */
#btn-hold.held, #btn-run.held { background: #dc2626; border-color: #fca5a5; color: #fff; font-weight: 700; animation: rb-hold-blink 1s steps(1, end) infinite; }
#btn-hold.held:hover, #btn-run.held:hover { background: #b91c1c; }
@keyframes rb-hold-blink { 0% { background: #dc2626; box-shadow: 0 0 12px rgba(239,68,68,.75); } 50% { background: #7f1d1d; box-shadow: none; } }
@media (prefers-reduced-motion: reduce) { #btn-hold.held, #btn-run.held { animation: none; } }
/* gripper picker: a button and a list, each gripper with a small drawing */
.gp { position: relative; flex: 0 1 auto; min-width: 0; }
.gp-btn { display: flex; align-items: center; gap: 7px; min-height: 36px; padding: 3px 9px 3px 5px; background: var(--surface2); color: var(--text); border: 1px solid var(--border); border-radius: 8px; cursor: pointer; font: inherit; text-align: left; }
.gp-btn:hover:not(:disabled) { border-color: var(--accent); }
.gp-btn:disabled { opacity: .6; cursor: not-allowed; }
.gp-btn:focus-visible, .gp-list:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.gp-tx { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.gp-tx small { font-size: .62rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted, #94a3b8); }
.gp-tx b { font-size: .8rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gp-car { font-size: .7rem; opacity: .7; margin-left: 2px; }
.gp-ic { display: inline-flex; width: 22px; height: 28px; flex: none; }
.gp-svg { width: 100%; height: 100%; fill: #8b97a6; stroke: #1b2230; stroke-width: .6; }
.gp-svg .b { fill: #3b78c4; }
.gp-svg .f { fill: #c8d0da; }
.gp-svg .w { fill: none; stroke: #c8d0da; stroke-width: 2.2; stroke-linecap: round; }
.gp-svg .g { fill: #e8c26a; stroke: none; }
.gp-list { position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; width: 270px; max-width: calc(100vw - 32px); margin: 0; padding: 4px; list-style: none; background: #151b29; border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 10px 28px rgba(0,0,0,.45); }
.gp-list[hidden] { display: none; }
.gp-list li { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 7px; cursor: pointer; }
.gp-list li .gp-svg { width: 26px; height: 34px; flex: none; }
.gp-list li span { display: flex; flex-direction: column; line-height: 1.2; }
.gp-list li b { font-size: .82rem; font-weight: 600; color: var(--text); }
.gp-list li i { font-style: normal; font-size: .7rem; color: var(--muted, #94a3b8); }
.gp-list li.act { background: var(--surface2); }
.gp-list li[aria-selected="true"] { box-shadow: inset 3px 0 0 var(--accent); }
