/* Net Ionic Express: the reaction dispatch bay. Scenes by art.js, colours from the --nx-* properties below (light and
   dark). Species are told apart by name, glyph shape and charge marks as well as colour; spectators in the reference
   endpoint are also dashed and labelled. */
html {
  --nx-wall1: #eef4f6; --nx-wall2: #dfe9ed; --nx-tile: rgba(36, 94, 118, .09); --nx-bench1: #8a6a4f; --nx-bench2: #5e4532; --nx-floor: #e6edf0;
  --nx-glass1: rgba(160, 200, 214, .35); --nx-glass2: rgba(255, 255, 255, .15); --nx-glass-line: #4d6b78; --nx-liq1: rgba(140, 205, 230, .32); --nx-liq2: rgba(70, 150, 190, .38);
  --nx-ink: #142833; --nx-muted: #4a5f6b; --nx-card: #ffffff; --nx-card-line: #9fb6c0; --nx-crystal: #f7f7f2; --nx-crystal-line: #50616b;
  --nx-model: #1d7a3a; --nx-e: #f2c94c; --nx-arrow: #3b5260;
  --nx-panel1: #f7fbfc; --nx-panel2: #e9f2f4; --nx-chipbg: #ffffff; --nx-chip-on: #d7ecf2; --nx-chip-line: #8eaab5; --nx-accent: #245e76;
  --nx-part: #b8541a; --nx-spec: #245e76; --nx-bad: #a32626; --nx-good: #1d7a3a;
}
html[data-theme="dark"] {
  --nx-wall1: #15232b; --nx-wall2: #0f1a20; --nx-tile: rgba(150, 210, 230, .07); --nx-bench1: #5e4532; --nx-bench2: #3a2a1f; --nx-floor: #121e25;
  --nx-glass1: rgba(150, 200, 220, .18); --nx-glass2: rgba(255, 255, 255, .05); --nx-glass-line: #9fc0cc; --nx-liq1: rgba(90, 170, 210, .22); --nx-liq2: rgba(60, 130, 180, .32);
  --nx-ink: #e8f0f3; --nx-muted: #a9bcc6; --nx-card: #1c2d36; --nx-card-line: #4f7383; --nx-crystal: #e9ecef; --nx-crystal-line: #c2ced4;
  --nx-model: #6fd68f; --nx-e: #f2d36b; --nx-arrow: #b9cbd4;
  --nx-panel1: #16242c; --nx-panel2: #1d2f3a; --nx-chipbg: #1f333f; --nx-chip-on: #24566a; --nx-chip-line: #4f7383; --nx-accent: #7fc4dc;
  --nx-part: #ffad70; --nx-spec: #7fc4dc; --nx-bad: #ff8a8a; --nx-good: #6fd68f;
}

.core { height: 100%; display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(330px, 1fr); gap: 16px; padding: 16px; overflow: auto; color: var(--nx-ink); font-size: 16px; box-sizing: border-box; }
.core * { box-sizing: border-box; }
.core-bench, .core-panel { min-width: 0; border-radius: 16px; overflow: auto; }
.core-bench { display: flex; flex-direction: column; gap: 10px; }
.core-panel { padding: 14px 16px; background: linear-gradient(180deg, var(--nx-panel1), var(--nx-panel2)); border: 1px solid var(--nx-chip-line); box-shadow: 0 2px 10px rgba(16, 43, 56, .12); }
.core :focus-visible { outline: 3px solid #dd9823; outline-offset: 3px; }

/* ticket */
.nx-ticket { position: relative; padding: 10px 16px 10px 22px; border-radius: 12px; background: var(--nx-card); border: 1px dashed var(--nx-card-line); }
.nx-ticket::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 6px; border-radius: 0 4px 4px 0; background: var(--nx-accent); }
.nx-ticket p { margin: 3px 0; line-height: 1.4; }
.nx-ticket-k { text-transform: uppercase; letter-spacing: .08em; font-weight: 800; color: var(--nx-accent); }
.nx-ticket-src { font-size: 19px; font-weight: 800; }

/* scene */
.core-scene { flex: 0 0 auto; overflow: auto; border-radius: 14px; border: 2px solid var(--nx-glass-line); background: var(--nx-wall1); box-shadow: 0 4px 14px rgba(16, 43, 56, .2); }
.core-scene svg { display: block; width: 100%; height: auto; }
.core-scene svg text, .nx-start text { font-family: inherit; fill: var(--nx-ink); font-size: 22px; }
.core-scene svg .nx-head, .nx-start .nx-head { font-size: 23px; font-weight: 800; }
.core-scene svg .nx-leg, .nx-start .nx-leg { font-size: 22px; font-weight: 700; }
.core-scene svg .nx-spect, .nx-start .nx-spect { fill: var(--nx-spec); }
.core-scene svg .nx-muted, .nx-start .nx-muted { fill: var(--nx-muted); font-style: italic; }
.core-scene svg .nx-model, .nx-start .nx-model { fill: var(--nx-model); font-weight: 800; }
.core-scene svg .nx-mid, .nx-start .nx-mid { font-size: 22px; }
.nx-floor { fill: var(--nx-floor); }
.nx-card { fill: var(--nx-card); stroke: var(--nx-card-line); stroke-width: 1.5; }
.nx-glass { fill: none; stroke: var(--nx-glass-line); stroke-width: 3.5; stroke-linejoin: round; }
.nx-lip { stroke: var(--nx-glass-line); stroke-width: 4; stroke-linecap: round; }
.nx-glint { stroke: #fff; stroke-opacity: .55; stroke-width: 5; stroke-linecap: round; }
.nx-meniscus { fill: var(--nx-liq1); stroke: var(--nx-glass-line); stroke-opacity: .5; stroke-width: 1.5; }
.nx-grad { stroke: var(--nx-glass-line); stroke-opacity: .6; stroke-width: 2; }
.nx-glyph { stroke: rgba(0, 0, 0, .45); stroke-width: 1.5; }
.nx-ring { fill: none; stroke: rgba(255, 255, 255, .7); stroke-width: 1.5; }
.nx-sign { stroke: #fff; stroke-width: 2.4; stroke-linecap: round; fill: none; }
.nx-dot { fill: rgba(255, 255, 255, .75); }
.nx-h { fill: #f4f7f8; stroke: rgba(0, 0, 0, .45); stroke-width: 1.2; }
.nx-bubble { fill: rgba(255, 255, 255, .25); stroke-width: 2.4; stroke-dasharray: 4 3; }
.nx-crystal { stroke: var(--nx-crystal-line); stroke-width: 1.6; }
.nx-lattice { stroke: var(--nx-crystal-line); stroke-opacity: .5; stroke-width: 1; }
.nx-strip { stroke: rgba(0, 0, 0, .45); stroke-width: 1.6; }
.nx-arrow { fill: none; stroke: var(--nx-arrow); stroke-width: 5; stroke-linecap: round; }
.nx-arrow.nx-flow { stroke-dasharray: 12 8; }
.nx-arrowhead { fill: none; stroke: var(--nx-arrow); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.nx-e { fill: var(--nx-e); stroke: rgba(0, 0, 0, .5); stroke-width: 1.5; }

/* cause → effect after Test and Check (skipped under reduced motion) */
@media (prefers-reduced-motion: no-preference) {
  .core-scene .nx-settle { animation: nx-settle 1.1s cubic-bezier(.3, .7, .4, 1) both; }
  .core-scene .nx-rise { animation: nx-rise 1.4s ease-out both; }
  .core-scene .nx-fade { animation: nx-fade .7s ease-out both; }
  .core-scene .nx-flow { animation: nx-flow 1s linear infinite; }
  .core-scene .nx-electrons { animation: nx-hop 1.6s ease-in-out infinite; }
}
@keyframes nx-settle { from { transform: translateY(-120px); opacity: 0; } 30% { opacity: 1; } to { transform: none; opacity: 1; } }
@keyframes nx-rise { from { transform: translateY(60px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes nx-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes nx-flow { to { stroke-dashoffset: -20; } }
@keyframes nx-hop { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(34px); } }

/* equation rail + ledger */
.nx-rail-box { padding: 8px 14px 10px; border-radius: 12px; background: var(--nx-card); border: 1px solid var(--nx-card-line); }
.nx-rail-k { margin: 0 0 4px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--nx-muted); }
.nie-equation { font-size: 18px; font-weight: 700; line-height: 1.5; padding: 10px 12px; border: 1px solid var(--nx-card-line); background: var(--nx-panel1); border-radius: 10px; overflow-wrap: anywhere; }
.nx-rail { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0; min-height: 52px; }
.nx-term { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 8px; background: var(--nx-chipbg); border: 1px solid var(--nx-chip-line); }
.nx-term-empty { color: var(--nx-muted); }
.nx-coefn { font-size: 20px; color: var(--nx-accent); }
.nx-op { font-size: 20px; font-weight: 800; }
.nx-yields { padding: 0 4px; }
.nx-swatch { display: inline-flex; flex: 0 0 auto; }
.nx-swatch svg { display: block; }
.nx-ledger[hidden] { display: none; }
.nx-ledger-t { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; background: var(--nx-card); border-radius: 10px; overflow: hidden; }
.nx-ledger-t th, .nx-ledger-t td { border: 1px solid var(--nx-card-line); padding: 5px 10px; text-align: center; }
.nx-ledger-t th:first-child { text-align: left; }
.nx-eq { color: var(--nx-good); font-weight: 800; font-size: 20px; }
.nx-neq { color: var(--nx-bad); font-weight: 800; font-size: 20px; }
.core-observation { margin: 0; min-height: 3em; padding: 10px 14px; line-height: 1.45; font-weight: 600; border-left: 5px solid var(--nx-accent); background: var(--nx-panel1); border-radius: 0 10px 10px 0; }
.core-about { padding: 0 4px; }
.core-about summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; font-weight: 700; }
.core-about p { line-height: 1.5; }

/* panel */
.nx-step { margin: 16px 0 6px; padding-top: 10px; border-top: 1px solid var(--nx-chip-line); font-size: 16px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--nx-accent); }
.nx-step:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.nie-note { font-size: 16px; line-height: 1.45; margin: 4px 0 10px; }
.core button { font: inherit; font-size: 16px; min-height: 44px; border-radius: 10px; color: inherit; cursor: pointer; }
.core button:disabled { opacity: .55; cursor: default; }
.nie-trays { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 10px 0; }
.nie-unrouted { grid-column: 1 / -1; }
.nie-trays h4 { font-size: 16px; margin: 0 0 6px; }
.nie-chip-list, .nie-palette { display: flex; flex-wrap: wrap; gap: 7px; min-height: 24px; }
.core .nx-token { display: inline-flex; align-items: center; gap: 4px; width: auto; padding: 6px 10px 6px 6px; margin: 0; font-weight: 700; background: var(--nx-chipbg); border: 2px solid var(--nx-chip-line); cursor: grab; box-shadow: 0 1px 2px rgba(0, 0, 0, .15); }
.core .nx-token[aria-pressed="true"] { border-color: #dd9823; background: var(--nx-chip-on); box-shadow: 0 0 0 3px rgba(221, 152, 35, .35); }
.core .nx-token:hover:not(:disabled) { background: var(--nx-chip-on); }
.nie-tray { padding: 8px; border: 2px dashed var(--nx-chip-line); border-radius: 12px; background: var(--nx-chipbg); min-height: 120px; }
.nx-tray-participating { border-color: var(--nx-part); }
.nx-tray-spectator { border-color: var(--nx-spec); }
.core .nie-drop { width: 100%; font-weight: 800; border: 2px solid var(--nx-chip-line); background: var(--nx-panel1); }
.nx-tray-participating .nie-drop { color: var(--nx-part); border-color: var(--nx-part); }
.nx-tray-spectator .nie-drop { color: var(--nx-spec); border-color: var(--nx-spec); }
.core .nie-drop.is-over { background: var(--nx-chip-on); }
.nx-tray-note { margin: 4px 2px 8px; color: var(--nx-muted); font-size: 16px; line-height: 1.3; }
.nie-manual { margin: 8px 0; }
.nie-manual summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; font-weight: 700; }
.core-field { display: grid; gap: 6px; margin: 0 0 12px; font-weight: 600; }
.core select, .core input { font: inherit; font-size: 16px; min-height: 44px; border-radius: 10px; border: 2px solid var(--nx-chip-line); padding: 8px 10px; background: var(--nx-chipbg); color: inherit; max-width: 100%; width: 100%; }
.core input[type="number"] { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.core input:disabled, .core select:disabled { opacity: .7; }
.nie-sides { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0; }
.core .nx-side { font-weight: 800; background: var(--nx-accent); color: #fff; border: 0; }
html[data-theme="dark"] .core .nx-side { color: #0f1d24; }
.nx-coef { width: 100%; border-collapse: collapse; }
.nx-coef th, .nx-coef td { padding: 5px 4px; border-bottom: 1px solid var(--nx-chip-line); }
.nx-coef thead th { font-size: 16px; text-align: center; color: var(--nx-muted); }
.nx-coef tbody th { text-align: left; font-weight: 700; }
.nx-coef tbody th > * { vertical-align: middle; }
.nx-coef td { width: 30%; }
.nx-coef td input { text-align: center; }
.core .nx-clear { margin: 8px 0 0; padding: 6px 14px; border: 2px solid var(--nx-chip-line); background: var(--nx-chipbg); font-weight: 700; }
.nx-label { font-weight: 700; line-height: 1.35; }
.nx-num { display: flex; align-items: center; gap: 8px; }
.nx-unit { color: var(--nx-muted); font-weight: 700; }
.nx-chips { display: grid; gap: 6px; }
.core .nx-chip { text-align: left; padding: 8px 12px; border: 2px solid var(--nx-chip-line); background: var(--nx-chipbg); line-height: 1.35; }
.core .nx-chip.is-on { border-color: var(--nx-accent); background: var(--nx-chip-on); font-weight: 700; box-shadow: inset 4px 0 0 var(--nx-accent); }
.core .nx-chip.is-on::before { content: "✓ "; }
.nx-actions { display: grid; grid-template-columns: 2fr 1fr; gap: 8px; margin-top: 8px; }
.core .core-run { background: var(--nx-accent); color: #fff; border: 0; font-weight: 800; }
html[data-theme="dark"] .core .core-run { color: #0f1d24; }
.core .core-revise { border: 2px solid var(--nx-chip-line); background: var(--nx-chipbg); font-weight: 700; }
.core-status { line-height: 1.4; }
.nx-example { margin: 8px 0; border-radius: 12px; overflow: hidden; border: 2px solid var(--nx-glass-line); }
.nx-example svg { display: block; width: 100%; height: auto; }
body .ps-kicker, body .ps-hint-note, body .ps-badge { font-size: 16px; }

@media (max-width: 900px) {
  .core { height: auto; grid-template-columns: 1fr; padding: 12px; }
  .core-bench, .core-panel { overflow: visible; }
  .core-scene svg { min-width: 620px; }
  .core-panel { padding-bottom: 30px; }
}
@media (prefers-reduced-motion: reduce) { .core * { animation: none !important; transition: none !important; } }
