/* ICE Box: the equilibrium reconstruction desk. Scenes by art.js, colors from the --ib-* properties below (light and
   dark). Species differ by shape and stripe direction as well as colour, so colour is never the only cue. */
html {
  --ib-wall1: #e9f1f3; --ib-wall2: #d6e4e8; --ib-strip: #c7d8de; --ib-board1: #fbfdfc; --ib-board2: #eef5f3;
  --ib-bench1: #c89f73; --ib-bench2: #9c7650; --ib-line: #34495a; --ib-text: #142833; --ib-muted: #4a5f6b;
  --ib-chip: #ffffff; --ib-lampbg: #f4f7f8; --ib-lamp-on: #18b26b; --ib-lamp-off: #9aa8b0; --ib-ice: #d9f1fb;
  --ib-glass: #ffffff; --ib-glassbg: rgba(225, 240, 246, .55); --ib-liquid1: rgba(160, 214, 236, .55); --ib-liquid2: rgba(110, 182, 214, .6); --ib-meniscus: #6aa9c4;
  --ib-gas1: rgba(232, 222, 190, .65); --ib-gas2: rgba(214, 196, 150, .6); --ib-stopper: #8a5a3a;
  --ib-solid1: #f6f2e9; --ib-solid2: #cfc6b4; --ib-stripe: #ffffff;
  --ib-s0: #1f6f9c; --ib-s0-hi: #6cb8e0; --ib-s1: #b8541a; --ib-s1-hi: #f2a46a; --ib-s2: #6a3f9a; --ib-s2-hi: #b897e0;
  --ib-propose: #1c2a35; --ib-model: #1d7a3a; --ib-k: #b8541a;
  --ib-panel1: #f7fbfc; --ib-panel2: #e9f2f4; --ib-chipbg: #ffffff; --ib-chip-on: #d7ecf2; --ib-chip-line: #8eaab5; --ib-accent: #245e76;
  --ib-neg: #b8541a; --ib-pos: #1f6f9c;
}
html[data-theme="dark"] {
  --ib-wall1: #15232b; --ib-wall2: #0f1a20; --ib-strip: #1c2d36; --ib-board1: #13232b; --ib-board2: #0f1c23;
  --ib-bench1: #5a4330; --ib-bench2: #3c2c1f; --ib-line: #8fa9b6; --ib-text: #e8f0f3; --ib-muted: #a9bcc6;
  --ib-chip: #1c2d36; --ib-lampbg: #14232b; --ib-lamp-on: #3ee68e; --ib-lamp-off: #4d5d66; --ib-ice: #24566a;
  --ib-glass: #cfe8f2; --ib-glassbg: rgba(80, 120, 140, .25); --ib-liquid1: rgba(70, 140, 175, .45); --ib-liquid2: rgba(40, 100, 135, .55); --ib-meniscus: #7fc4dc;
  --ib-gas1: rgba(120, 105, 70, .45); --ib-gas2: rgba(95, 80, 50, .5); --ib-stopper: #a87452;
  --ib-solid1: #c9c2b3; --ib-solid2: #8f8778; --ib-stripe: #0f1a20;
  --ib-s0: #4fb3e8; --ib-s0-hi: #a8dcf6; --ib-s1: #ff9a52; --ib-s1-hi: #ffd0a8; --ib-s2: #c39bff; --ib-s2-hi: #e2d0ff;
  --ib-propose: #f1f6f8; --ib-model: #6fd68f; --ib-k: #ff9a52;
  --ib-panel1: #16242c; --ib-panel2: #1d2f3a; --ib-chipbg: #1f333f; --ib-chip-on: #24566a; --ib-chip-line: #4f7383; --ib-accent: #7fc4dc;
  --ib-neg: #ffad70; --ib-pos: #7fc4dc;
}

.core { height: 100%; display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(320px, 1fr); gap: 16px; padding: 16px; overflow: auto; color: var(--ib-text); 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(--ib-panel1), var(--ib-panel2)); border: 1px solid var(--ib-chip-line); box-shadow: 0 2px 10px rgba(16, 43, 56, .12); }
.core-kicker { margin: 0; text-transform: uppercase; letter-spacing: .08em; font-weight: 800; color: var(--ib-accent); }

.ib-eqcard { flex: 0 0 auto; padding: 10px 16px; border-radius: 14px; background: linear-gradient(180deg, var(--ib-panel1), var(--ib-panel2)); border: 1px solid var(--ib-chip-line); }
.ice-equation { margin: 4px 0; font-size: 24px; font-weight: 800; line-height: 1.35; }
.ice-note { margin: 4px 0; font-size: 16px; line-height: 1.45; }
.ib-model-note { color: var(--ib-muted); font-style: italic; }

.core-scene { flex: 0 0 auto; overflow: auto; border-radius: 14px; border: 2px solid var(--ib-line); background: var(--ib-wall2); box-shadow: 0 4px 14px rgba(16, 43, 56, .22); }
.core-scene:focus-visible { outline: 3px solid #dd9823; outline-offset: 3px; }
.core-scene svg { display: block; width: 100%; height: auto; }
.core-scene svg text { font-family: inherit; fill: var(--ib-text); font-size: 20px; }
.core-scene svg .ib-head { font-size: 22px; font-weight: 800; }
.core-scene svg .ib-chiptext, .core-scene svg .ib-lamptext { font-size: 20px; font-weight: 700; }
.core-scene svg .ib-axislab { font-weight: 700; fill: var(--ib-muted); }
.core-scene svg .ib-species { font-weight: 800; }
.core-scene svg .ib-val { font-variant-numeric: tabular-nums; fill: var(--ib-muted); }
.core-scene svg .ib-val-prop { fill: var(--ib-text); font-weight: 700; }
.core-scene svg .ib-small { fill: var(--ib-muted); }
.core-scene svg .ib-solidlab { fill: #3b3326; font-weight: 700; }
.core-scene svg .ib-model { fill: var(--ib-model); font-weight: 800; }
.core-scene svg .ib-ktext { fill: var(--ib-k); font-weight: 800; }
.core-scene svg .ib-qtext { fill: var(--ib-text); font-weight: 800; }
.core-scene svg .ib-tile { font-weight: 800; }
.core-scene svg .ib-axis { fill: none; stroke: var(--ib-line); stroke-width: 2.4; }
.core-observation { margin: 0; min-height: 3em; padding: 10px 14px; line-height: 1.45; font-weight: 600; border-left: 5px solid var(--ib-accent); background: var(--ib-panel1); border-radius: 0 10px 10px 0; }

/* ICE board */
.ib-board { flex: 0 0 auto; padding: 12px 16px; border-radius: 14px; background: var(--ib-board1); border: 2px solid var(--ib-chip-line); }
.ib-board-title { margin: 0 0 4px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--ib-accent); }
.ice-palette { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.core .ib-tile { font: inherit; font-size: 18px; font-weight: 800; min-width: 56px; min-height: 44px; padding: 6px 12px; border-radius: 10px; cursor: grab; color: inherit;
  border: 2px solid var(--ib-chip-line); background: linear-gradient(180deg, var(--ib-chipbg), var(--ib-panel2)); box-shadow: 0 3px 0 var(--ib-chip-line); }
.core .ib-tile[aria-pressed="true"] { border-color: var(--ib-accent); background: var(--ib-chip-on); box-shadow: 0 0 0 3px var(--ib-accent); transform: translateY(-2px); }
.ice-table-scroll { overflow: auto; margin: 6px 0 0; }
.ice-table { width: 100%; min-width: 430px; border-collapse: separate; border-spacing: 0; font-size: 16px; font-variant-numeric: tabular-nums; }
.ice-table th, .ice-table td { padding: 8px 8px; text-align: center; border-bottom: 1px solid var(--ib-chip-line); }
.ice-table tr > th:first-child { text-align: left; white-space: nowrap; }
.ice-table tr:first-child th { font-size: 18px; }
.ice-table th svg { vertical-align: -4px; }
.ice-row-change td { background: var(--ib-panel2); }
.ice-row-final td { font-weight: 700; }
.core .ib-cell { font: inherit; font-size: 18px; font-weight: 800; min-width: 84px; min-height: 44px; margin: 0; border-radius: 10px; cursor: pointer; color: var(--ib-muted);
  border: 2px dashed var(--ib-chip-line); background: var(--ib-chipbg); }
.core .ib-cell.armed { border-color: var(--ib-accent); }
.core .ib-cell.over { background: var(--ib-chip-on); }
.core .ib-cell.filled { border-style: solid; color: var(--ib-pos); }
.core .ib-cell.filled.neg { color: var(--ib-neg); }

/* panel */
.ib-case { margin: 0 0 12px; padding: 10px 14px; border-radius: 12px; background: var(--ib-chipbg); border: 1px dashed var(--ib-chip-line); }
.ib-case p { margin: 6px 0; line-height: 1.45; }
.ib-case .ib-case-kicker { margin-top: 0; text-transform: uppercase; letter-spacing: .08em; font-weight: 800; color: var(--ib-accent); }
.ib-request { padding: 6px 10px; border-radius: 8px; background: var(--ib-chip-on); }
.ib-table { border-collapse: collapse; margin: 6px 0; width: 100%; font-variant-numeric: tabular-nums; }
.ib-table th, .ib-table td { border: 1px solid var(--ib-chip-line); padding: 5px 8px; text-align: center; }
.ib-table tr:first-child th { background: var(--ib-panel2); }
.ib-table tr > th:first-child { text-align: left; }
.ib-step { margin: 14px 0 8px; padding-top: 10px; border-top: 1px solid var(--ib-chip-line); font-size: 16px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--ib-accent); }
.ib-field { display: grid; gap: 6px; margin: 0 0 12px; }
.ib-num { display: grid; gap: 6px; }
.ib-label { font-weight: 700; line-height: 1.35; }
.ib-numrow { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ib-numrow input { flex: 1 1 auto; min-width: 0; font: inherit; font-size: 18px; font-weight: 700; min-height: 44px; padding: 8px 10px; border-radius: 10px; border: 2px solid var(--ib-chip-line); background: var(--ib-chipbg); color: inherit; font-variant-numeric: tabular-nums; }
.ib-unit { flex: 0 0 auto; font-weight: 600; }
.ice-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.core .ib-dir { flex: 1 1 140px; font: inherit; font-size: 16px; font-weight: 700; min-height: 48px; padding: 8px 10px; border-radius: 12px; border: 2px solid var(--ib-chip-line); background: var(--ib-chipbg); color: inherit; cursor: pointer; line-height: 1.3; }
.core .ib-dir[aria-pressed="true"] { background: var(--ib-chip-on); border-color: var(--ib-accent); box-shadow: inset 0 0 0 1px var(--ib-accent); }
.core .ib-dir[aria-pressed="true"]::before { content: "✓ "; }
.ib-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.core .ib-chip { font: inherit; font-size: 16px; font-weight: 700; min-height: 44px; padding: 8px 14px; border-radius: 22px; border: 2px solid var(--ib-chip-line); background: var(--ib-chipbg); color: inherit; cursor: pointer; text-align: left; line-height: 1.3; }
.core .ib-chip.on { background: var(--ib-chip-on); border-color: var(--ib-accent); box-shadow: inset 0 0 0 1px var(--ib-accent); }
.core .ib-chip.on::before { content: "✓ "; }
.core .ib-chip:hover:not(:disabled), .core .ib-dir:hover:not(:disabled), .core .ib-tile:hover:not(:disabled), .core .ib-cell:hover:not(:disabled) { border-color: var(--ib-accent); }
.ice-manual { margin: 12px 0; }
.ice-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-field select { font: inherit; font-size: 16px; min-height: 44px; border-radius: 8px; border: 2px solid var(--ib-chip-line); padding: 8px; background: var(--ib-chipbg); color: inherit; width: 100%; }
.ib-actions { display: flex; gap: 10px; margin-top: 8px; }
.core-run, .core-revise { font: inherit; font-size: 16px; font-weight: 800; min-height: 46px; border-radius: 12px; padding: 10px 16px; cursor: pointer; }
.core-run { flex: 1 1 auto; background: #245e76; color: #fff; border: 0; box-shadow: 0 3px 0 #163c4c; }
.core-revise { background: var(--ib-chipbg); color: inherit; border: 2px solid var(--ib-chip-line); }
.core button:disabled, .core input:disabled, .core select:disabled { opacity: .6; cursor: default; }
.core .ib-chip.on:disabled, .core .ib-cell.filled:disabled, .core .ib-dir[aria-pressed="true"]:disabled { opacity: .85; }
.core-run:disabled { box-shadow: none; }
.core :focus-visible { outline: 3px solid #dd9823; outline-offset: 2px; }
.core-status { margin: 8px 0 4px; line-height: 1.4; font-weight: 600; }
.ib-precision { margin: 0 0 6px; line-height: 1.4; }
.core-about summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; font-weight: 700; }
.core-about p { line-height: 1.5; margin: 0 0 8px; }
.ib-example { margin: 8px 0; }

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-panel { padding-bottom: 30px; }
  .core-scene svg { min-width: 620px; }
}
@media (prefers-reduced-motion: reduce) { .core * { animation: none !important; transition: none !important; } .core .ib-tile[aria-pressed="true"] { transform: none; } }
