/* Matter Sorting Plant: the plant floor. The scene (activity.js SVG) keeps its own lit-plant colours in both themes,
 * like a lit factory floor; the ticket panel and controls follow the site theme. */
html {
  --ms-accent: #245a60; --ms-accent-ink: #ffffff; --ms-card: #ffffff; --ms-ink: #173a3d; --ms-muted: #4b5f63; --ms-line: #9db2b5;
  --ms-panel1: #f2f7f7; --ms-panel2: #e2eded; --ms-ok: #13704a; --ms-bad: #b3261e; --ms-focus: #b77a00;
}
html[data-theme="dark"] {
  --ms-accent: #7fc9c9; --ms-accent-ink: #0f2526; --ms-card: #1f2a2c; --ms-ink: #e6efef; --ms-muted: #b6c7c8; --ms-line: #4f6669;
  --ms-panel1: #1c2729; --ms-panel2: #162022; --ms-ok: #4fd08c; --ms-bad: #ff8a80; --ms-focus: #f4c542;
}

.ms { position: absolute; inset: 0; display: grid; grid-template-columns: minmax(0, 1fr) 368px; gap: 10px; padding: 8px 10px;
  color: var(--ms-ink); font-size: 16px; overflow: hidden; }
.ms *, .ms *::before, .ms *::after { box-sizing: border-box; }
.ms p { margin: 0; line-height: 1.3; }
.ms input, .ms button, .ms select { font: inherit; font-size: 16px; }
.ms-left { display: flex; flex-direction: column; gap: 6px; min-width: 0; min-height: 0; }

/* scene */
.ms-scene { flex: none; min-width: 0; overflow-x: auto; overflow-y: hidden; border-radius: 12px; box-shadow: 0 2px 6px rgba(0,0,0,.18); background: #c9d3d9; }
.ms-svg { display: block; width: 100%; min-width: 0; height: auto; }
.ms-svg text { font-family: var(--tlg-font, system-ui, sans-serif); }
.ms-svg .ms-t { fill: #1d2a36; }
.ms-svg .ms-t-head { fill: #1d2a36; }
.ms-svg .ms-mlab { fill: #1d2a36; font-weight: 700; paint-order: stroke; stroke: #ffffff; stroke-width: 4px; stroke-linejoin: round; }
.ms-svg .ms-t-bin { fill: #3d2c00; }
.ms-svg .ms-t-kick { fill: #245a60; letter-spacing: .05em; }
.ms-svg .ms-k-head { fill: #7fd0d0; letter-spacing: .06em; }
.ms-svg .ms-k-main { fill: #f1f7f7; }
.ms-svg .ms-k-dim { fill: #c4d3d7; }
.ms-svg .ms-tag { fill: #1d2a36; paint-order: stroke; stroke: #ffffff; stroke-width: 4px; stroke-linejoin: round; }
.ms-svg .ms-t-stamp { font-weight: 800; }
.ms-stamp { animation: ms-stamp .35s ease-out both; transform-box: fill-box; }
@keyframes ms-stamp { from { opacity: 0; } to { opacity: 1; } }
.ms-scene:focus-visible { outline: 3px solid var(--ms-focus); outline-offset: -3px; }

/* toolbar (inspect / probes / process steps) */
.ms-toolbar { display: flex; gap: 6px; flex-wrap: wrap; }
.ms-vbtn { flex: 1 1 0; min-width: 0; min-height: 44px; padding: 4px 10px; border: 2px solid var(--ms-line); border-radius: 10px; cursor: pointer;
  background: var(--ms-card); color: var(--ms-ink); font-weight: 700; line-height: 1.15; }
.ms-vbtn[aria-pressed="true"] { border-color: var(--ms-accent); background: var(--ms-accent); color: var(--ms-accent-ink); }
.ms-vbtn[aria-pressed="true"]::before { content: '● '; }
.ms-vbtn:disabled { cursor: default; opacity: .75; }
.ms-vbtn[aria-pressed="true"]:disabled { opacity: .9; }
.ms--classify .ms-vbtn[data-view="whole"] { flex: 1.35 1 0; }
.ms-caption { min-height: 21px; font-weight: 600; color: var(--ms-muted); }

/* primary decision deck under the scene */
.ms-deck { min-width: 0; }
.ms-routes { border: 0; margin: 0; padding: 0; min-width: 0; }
.ms-routes-g { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.ms-bin { min-height: 50px; padding: 4px 8px; border: 2px solid #8a6408; border-radius: 10px; cursor: pointer; font-weight: 800; line-height: 1.15;
  background: linear-gradient(#ffe08a, #f1bf3c); color: #3d2c00; box-shadow: 0 3px 0 #8a6408; }
.ms-bin[aria-pressed="true"] { background: linear-gradient(#2f7591, #1d4c5e); border-color: #123542; color: #ffffff; box-shadow: 0 1px 0 #123542; transform: translateY(2px); }
.ms-bin[aria-pressed="true"]::before { content: '● '; }
.ms-bin:disabled { cursor: default; }
.ms-bin:disabled:not([aria-pressed="true"]) { opacity: .65; }
.ms-l { display: block; font-weight: 700; font-size: 16px; line-height: 1.2; padding: 0; margin-bottom: 3px; }

/* tiles (radio groups) */
.ms-tiles { border: 0; margin: 0; padding: 0; min-width: 0; }
.ms-tiles-g { display: grid; grid-template-columns: 1fr; gap: 4px; }
.ms-tiles--stamp .ms-tiles-g { grid-template-columns: 1fr 1fr; gap: 8px; }
.ms-tiles--method .ms-tiles-g { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; }
.ms-tile { position: relative; display: block; min-width: 0; cursor: pointer; }
.ms-tile input { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.ms-tile-b { pointer-events: none; display: flex; align-items: center; gap: 6px; min-height: 40px; padding: 3px 8px;
  border: 2px solid var(--ms-line); border-radius: 9px; background: var(--ms-card); color: var(--ms-ink); line-height: 1.18; text-align: left; }
.ms-tile-t { min-width: 0; overflow-wrap: anywhere; }
.ms-tile.is-on .ms-tile-b { border-color: var(--ms-accent); background: var(--ms-accent); color: var(--ms-accent-ink); box-shadow: 0 2px 6px rgba(36,90,96,.35); }
.ms-tile-b::before { content: '○'; flex: none; opacity: .6; }
.ms-tile.is-on .ms-tile-b::before { content: '●'; opacity: 1; }
.ms-tile input:focus-visible + .ms-tile-b { outline: 3px solid var(--ms-focus); outline-offset: 2px; }
.ms-tile input:disabled { cursor: default; }
.ms-tile input:disabled + .ms-tile-b { opacity: .6; }
.ms-tile.is-on input:disabled + .ms-tile-b { opacity: .9; }
.ms-tiles--stamp .ms-tile-b { min-height: 50px; justify-content: center; font-weight: 800;
  border-style: dashed; border-width: 3px; }
.ms-tiles--method .ms-tile-b { min-height: 52px; padding: 3px 5px; gap: 4px; font-weight: 600; }
.ms-tiles--method .ms-tile-b::before { display: none; }
.ms-tiles--method .ms-tile.is-on .ms-tile-t::before { content: '● '; }
.ms-ico { flex: none; display: inline-flex; color: currentColor; }

/* ticket and report panel */
.ms-panel { display: flex; flex-direction: column; gap: 6px; min-height: 0; overflow: auto; padding: 8px 10px;
  background: linear-gradient(var(--ms-panel1), var(--ms-panel2)); border: 3px solid var(--ms-accent); border-radius: 14px; box-shadow: 0 3px 8px rgba(0,0,0,.16); }
.ms-kicker { font-size: 16px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: var(--ms-accent); }
.ms-k2 { margin-top: 2px !important; }
.ms-ticket { padding: 5px 8px; line-height: 1.28 !important; background: var(--ms-card); border: 2px dashed var(--ms-line); border-radius: 10px; }
.ms-report { display: grid; gap: 8px; }
.ms-num { display: grid; gap: 2px; }
.ms-num-in { display: flex; align-items: center; gap: 6px; }
.ms-num-in input, .ms-num select { flex: 1 1 0; width: 100%; min-width: 0; min-height: 42px; padding: 4px 8px; border: 2px solid var(--ms-line); border-radius: 8px;
  background: var(--ms-card); color: var(--ms-ink); font-variant-numeric: tabular-nums; }
.ms-num-in input:disabled, .ms-num select:disabled { opacity: .75; }
.ms-unit { font-weight: 700; }
.ms :focus-visible { outline: 3px solid var(--ms-focus); outline-offset: 2px; }
.ms-verdict { min-height: 21px; font-weight: 800; padding: 0 8px; line-height: 1.3 !important; border-left: 4px solid currentColor; }
.ms-verdict.is-ok { color: var(--ms-ok); } .ms-verdict.is-bad { color: var(--ms-bad); }
.ms-k2row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; position: relative; }
.ms-about summary { font-weight: 700; cursor: pointer; color: var(--ms-accent); white-space: nowrap; }
.ms-about p { position: absolute; z-index: 6; top: calc(100% + 4px); left: 0; right: 0; padding: 8px 10px; font-size: 16px; line-height: 1.3;
  background: var(--ms-card); color: var(--ms-ink); border: 2px solid var(--ms-accent); border-radius: 10px; box-shadow: 0 6px 18px rgba(0,0,0,.25); }
.is-assess .ms-verdict { display: none; }

/* Briefing example */
.ms-ex { display: block; width: 100%; max-width: 620px; height: auto; }
.ms-ex text { font-family: var(--tlg-font, system-ui, sans-serif); }

/* narrower screens: one column, the page scrolls; the diagram scrolls sideways (focusable) */
@media (max-width: 900px) {
  .ms { position: static; display: flex; flex-direction: column; height: 100%; overflow: auto; }
  .ms-panel { overflow: visible; flex: none; }
  .ms-left { flex: none; }
  .ms-scene { max-width: 100%; }
}
@media (max-width: 560px) {
  .ms { padding: 6px; }
  .ms-routes-g, .ms-tiles--method .ms-tiles-g { grid-template-columns: 1fr 1fr; }
  .ms-toolbar .ms-vbtn, .ms--classify .ms-vbtn[data-view="whole"] { flex: 1 1 40%; }
}
@media (prefers-reduced-motion: reduce) { .ms * { animation: none !important; transition: none !important; } }
.ms-deck--atoms { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 10px; align-items: end; }
@media (max-width: 560px) { .ms-deck--atoms { grid-template-columns: 1fr; } }

/* narrow layout (< 650 px scene, set by activity.js): the chamber, its key and the belt/bins are separate pictures,
   each drawn at 1:1 or larger so every label stays >= 16 px; nothing scrolls sideways */
.ms-nhead { font-weight: 700; }
.ms-scene.is-narrow { display: flex; flex-direction: column; gap: 6px; overflow: hidden; background: transparent; box-shadow: none; border-radius: 0; }
.ms-scene.is-narrow .ms-svg { min-width: 0; width: 100%; border-radius: 10px; box-shadow: 0 2px 6px rgba(0,0,0,.18); }
.ms-scene.is-narrow .ms-svg-key { max-width: 300px; align-self: center; }
.ms-scene.is-narrow .ms-svg-card { max-width: 230px; align-self: center; }
.ms-scene.is-narrow .ms-svg-tank { max-width: 220px; align-self: center; }
