/* CellScape 3D world shell (loaded after cellscape.css). */
.stage { background: #06121c; }
.cs-fade { position: absolute; inset: 0; opacity: 0; pointer-events: none; z-index: 5; }
#labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 2; }
.lbl3d { position: absolute; left: 0; top: 0; white-space: nowrap; font-size: 0.74rem; will-change: transform; }
.lbl3d.cs-tip {
  background: rgba(5, 11, 22, 0.88); border: 1px solid var(--panel-border); padding: 5px 9px; border-radius: 9px;
  font-weight: 600; z-index: 4; transform-origin: 0 0;
}
.lbl3d.cs-tip small { display: block; font-weight: 400; color: var(--ink-faint); font-size: 0.7rem; }
.lbl3d.org {
  background: rgba(5, 11, 22, 0.6); border: 1px solid rgba(120, 190, 255, 0.22); padding: 2px 8px; border-radius: 999px;
  color: var(--ink); backdrop-filter: blur(4px); text-align: center; line-height: 1.25;
}
.lbl3d.org small { display: block; font-size: 0.66rem; color: var(--ink-dim); }
.lbl3d.org.off { border-color: rgba(248, 113, 113, 0.6); }
.lbl3d.org.off small { color: #fca5a5; }
.lbl3d.dive {
  background: rgba(79, 209, 197, 0.16); border: 1px solid var(--accent); padding: 3px 9px; border-radius: 999px; color: #ccfbf1;
  font-weight: 600; animation: cs-pulse 2s ease-in-out infinite;
}
@keyframes cs-pulse { 50% { box-shadow: 0 0 16px rgba(79, 209, 197, 0.6); } }

.cs-scale {
  position: absolute; left: 14px; bottom: 14px; z-index: 3; display: flex; flex-direction: column; gap: 4px;
  font-size: 0.75rem; color: var(--ink-dim); pointer-events: none; text-shadow: 0 1px 6px #000;
}
.cs-scale i { display: block; height: 4px; border: 2px solid var(--ink-dim); border-top: 0; min-width: 10px; }
.cs-hint {
  position: absolute; right: 150px; bottom: 14px; z-index: 3; font-size: 0.72rem; color: var(--ink-dim);   /* left of the Pause / Microscope buttons */
  text-align: right; pointer-events: none; text-shadow: 0 1px 6px #000; max-width: 40%;
}
.cs-up { position: absolute; left: 14px; bottom: 46px; z-index: 3; background: rgba(5, 11, 22, 0.75); }
.cs-pause { position: absolute; right: 14px; bottom: 40px; z-index: 3; background: rgba(5, 11, 22, 0.75); }
.cs-scope { position: absolute; right: 14px; bottom: 84px; z-index: 3; background: rgba(5, 11, 22, 0.75); }
.cs-scope[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
@media (prefers-reduced-motion: reduce) { .lbl3d.dive { animation: none; } .cs-fade { transition: none !important; } }

/* header */
.crumbs { display: flex; align-items: center; gap: 6px; min-width: 0; overflow: hidden; font-family: var(--font-display); }
.crumbs button {
  background: none; border: 0; color: var(--ink-dim); cursor: pointer; padding: 4px 2px; font-size: 1rem; white-space: nowrap;
}
.crumbs button:hover { color: var(--ink); }
.crumbs button[aria-current="true"] { color: var(--ink); font-weight: 600; cursor: default; }
.crumbs .sep { color: var(--ink-faint); }
.lens-select {
  margin-left: auto; background: var(--btn-bg); border: 1px solid var(--panel-border); border-radius: 10px;
  padding: 6px 8px; color: var(--ink); font-size: 0.85rem;
}
.sim-header .lib { color: var(--ink-dim); font-size: 0.82rem; text-decoration: none; white-space: nowrap; }
.sim-header .lib:hover { color: var(--ink); }

/* panel helpers */
.hint { font-size: 0.8rem; color: var(--ink-faint); margin: 6px 0 0; }
.org-list { display: flex; flex-direction: column; gap: 6px; }
.org-row {
  display: grid; grid-template-columns: 12px 1fr auto; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 9px;
  background: var(--tint-1); font-size: 0.86rem; cursor: pointer;
}
.org-row:hover { background: var(--btn-bg); }
.org-row i { width: 10px; height: 10px; border-radius: 50%; }
.org-row .org-name { background: none; border: 0; padding: 0; text-align: left; color: var(--ink); cursor: pointer; font-size: 0.86rem; }
.org-row .org-name:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.org-row small { display: block; color: var(--ink-faint); font-size: 0.74rem; }
.org-row.off small { color: var(--danger); }
.switch { position: relative; width: 38px; height: 22px; flex: 0 0 38px; }
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; position: absolute; inset: 0; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--tint-3); box-shadow: inset 0 0 0 1px var(--danger); transition: background 0.2s; }
.switch span::after {
  content: ""; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform 0.2s;
}
.switch input:checked + span { background: var(--good); box-shadow: none; }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.flow-key { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px; font-size: 0.8rem; color: var(--ink-dim); }
.flow-key span { display: flex; align-items: center; gap: 6px; }
.flow-key label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.flow-key i { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 10px; }
.sel-card .io { display: grid; grid-template-columns: auto 1fr; gap: 3px 8px; font-size: 0.84rem; margin: 6px 0; }
.sel-card .io b { color: var(--ink-faint); font-weight: 600; }
.explain .chain { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--panel-border); font-size: 0.86rem; }
.explain .chain span { color: var(--accent); }
.mini-chart { width: 100%; height: 120px; display: block; }
.chip .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; }
.chip.warn { border-color: rgba(248, 113, 113, 0.6); }
.tour-cap {
  position: absolute; left: 50%; bottom: 46px; transform: translateX(-50%); z-index: 4; max-width: min(560px, calc(100% - 32px));
  background: rgba(5, 11, 22, 0.88); border: 1px solid var(--accent); border-radius: 14px; padding: 12px 14px; font-size: 0.92rem;
  display: none;
}
.tour-cap .row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }
.tour-cap b { color: var(--accent); }

@media (max-width: 860px) {
  .sim-shell { grid-template-rows: auto 64vh auto; }
  .cs-hint { display: none; }
  .crumbs button { font-size: 0.9rem; }
  .sim-header .lib { display: none; }
}

/* Light theme: the .stage subtree keeps dark tokens (cellscape.css), so overlays stay as authored.
   The off-state switch track needs a visible edge on light panels; the thumb is white in both themes. */
:root[data-theme="light"] .switch span::after { box-shadow: 0 1px 3px var(--shadow); }
:root[data-theme="light"] .switch input:not(:checked) + span::after { background: var(--danger); }
.cs-nogl { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center; color: var(--ink-dim); }
