/* Mars Base Life Support: the life-support desk of a small Mars base. Scene drawn by art.js (colors from the --mb-* properties below). */
html {
  --mb-sky1: #f1cba4; --mb-sky2: #dc9466; --mb-hill: #c06a42; --mb-hill2: #a9532f; --mb-ground1: #b85a33; --mb-ground2: #8c3f21; --mb-rock: #6f2f17;
  --mb-panel1: #4a8ad0; --mb-panel2: #1d4178; --mb-panel-line: #c9def5; --mb-stow: #8d969c; --mb-leg: #4a4f55; --mb-dustc: #b8754a;
  --mb-in1: #f4f6f8; --mb-in2: #dde3e8; --mb-dome-line: #5b6a74; --mb-rib: #c4ccd2; --mb-floor: #8b959c;
  --mb-steel1: #eef1f3; --mb-steel2: #a7b1b8; --mb-steel-line: #56616a; --mb-o2a: #8fd3f2; --mb-o2b: #3e9cc9; --mb-co: #9a8f86;
  --mb-water1: #63b6e6; --mb-water2: #2a76b0; --mb-crate1: #d9a65c; --mb-crate2: #a8742f; --mb-crate-line: #6c4718;
  --mb-suit1: #e07a3f; --mb-suit2: #3f7fa8; --mb-suit3: #6c8f3e; --mb-patch: #f4f1ea;
  --mb-plate: #2b3238; --mb-plate-text: #ffffff; --mb-text: #2a1a12; --mb-haze: #c98a5a; --mb-cable: #2f3438; --mb-pulse: #ffd23f;
  --mb-ink: #22201e; --mb-panel-bg1: #fbf6f1; --mb-panel-bg2: #f3e8de; --mb-accent: #a4442a; --mb-ok: #13704a; --mb-bad: #b3261e;
  --mb-gauge-bg: #efe7df;
}
html[data-theme="dark"] {
  --mb-sky1: #4a2c22; --mb-sky2: #7a3d27; --mb-hill: #6e3420; --mb-hill2: #5a2917; --mb-ground1: #5e2c18; --mb-ground2: #3e1c0f; --mb-rock: #2a120a;
  --mb-panel1: #5b9be0; --mb-panel2: #24508f; --mb-panel-line: #d5e6fa; --mb-stow: #6b7378; --mb-leg: #9aa2a8; --mb-dustc: #8a5536;
  --mb-in1: #2f363c; --mb-in2: #232a30; --mb-dome-line: #a9b6bf; --mb-rib: #3d464d; --mb-floor: #56616a;
  --mb-steel1: #6f7a82; --mb-steel2: #434c53; --mb-steel-line: #c3ccd2; --mb-co: #7d736b;
  --mb-crate1: #b88843; --mb-crate2: #855a22; --mb-crate-line: #e2b877;
  --mb-plate: #e9edf0; --mb-plate-text: #1b2025; --mb-text: #f6e9df; --mb-haze: #6b3a22; --mb-cable: #c3ccd2;
  --mb-ink: #f1ece7; --mb-panel-bg1: #2b2422; --mb-panel-bg2: #221c1a; --mb-accent: #f0a083; --mb-ok: #4fd08c; --mb-bad: #ff8a80;
  --mb-gauge-bg: #3a3230;
}

/* ── layout ── */
.mb { position: absolute; inset: 0; display: grid; grid-template-columns: 330px minmax(0, 1fr); gap: 12px; padding: 10px;
  color: var(--tlg-text); font-size: 16px; }
.mb input, .mb button { font: inherit; }
.mb-controls { display: flex; flex-direction: column; gap: 8px; min-height: 0; overflow: auto; padding: 10px 12px;
  background: linear-gradient(var(--mb-panel-bg1), var(--mb-panel-bg2)); color: var(--mb-ink); border: 3px solid var(--mb-accent);
  border-radius: 14px; box-shadow: 0 3px 8px rgba(0,0,0,.16); }
.mb-right { display: flex; flex-direction: column; gap: 6px; min-width: 0; min-height: 0; }
.mb-kicker { margin: 0; font-size: 16px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--mb-accent); }
.mb-step { display: grid; gap: 4px; }
.mb-step-b { display: grid; gap: 6px; }
.mb-step-h { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 17px; line-height: 1.2; }
.mb-n { flex: none; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--mb-accent);
  color: #fff; font-size: 16px; font-weight: 800; }
html[data-theme="dark"] .mb-n { color: #2a1510; }
.mb-step.is-done .mb-n { background: var(--mb-ok); }

/* sliders */
.mb-slider { display: grid; gap: 0; }
.mb-slider-h { display: flex; justify-content: space-between; gap: 8px; font-weight: 700; }
.mb-slider-v { font-weight: 800; color: var(--mb-accent); white-space: nowrap; }
.mb-slider.is-unset .mb-slider-v { font-weight: 600; font-style: italic; color: var(--mb-ink); opacity: .8; }
.mb-slider input { width: 100%; min-height: 28px; margin: 0; accent-color: var(--mb-accent); cursor: pointer; }
.mb-slider.is-unset input { opacity: .55; }
.mb-slider input:focus-visible { outline: 3px solid var(--tlg-focus, #1a73e8); outline-offset: 2px; }
.mb-ticks { display: flex; justify-content: space-between; font-size: 16px; line-height: 1.1; opacity: .8; padding: 0 2px; margin-top: -4px; }

/* number fields (AP) */
.mb-num { display: grid; grid-template-columns: minmax(0, 1fr) 150px; align-items: center; gap: 2px 8px; }
.mb-num-l { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 6px; font-weight: 700; font-size: 16px; line-height: 1.2; }
.mb-num-row { display: flex; align-items: center; gap: 5px; min-width: 0; }
.mb-num input { flex: 1 1 auto; min-width: 0; width: 100%; font-size: 17px; min-height: 42px; padding: 5px 8px; border: 2px solid #9c8a80;
  border-radius: 8px; background: #fff; color: #1f2a30; }
html[data-theme="dark"] .mb-num input { background: #1d1a1a; color: #f2ecea; border-color: #8f7a72; }
.mb-num input:focus-visible { outline: 3px solid var(--tlg-focus, #1a73e8); outline-offset: 2px; }
.mb-num input[readonly] { background: repeating-linear-gradient(135deg, transparent 0 6px, rgba(164,68,42,.09) 6px 12px), #f3eeea; }
html[data-theme="dark"] .mb-num input[readonly] { background: repeating-linear-gradient(135deg, transparent 0 6px, rgba(240,160,131,.1) 6px 12px), #2a2424; }
.mb-num input:disabled { opacity: 1; }
.mb-unit { flex: none; font-weight: 700; min-width: 34px; }
.mb-mark { font-weight: 800; white-space: nowrap; }
.mb-mark.is-ok { color: var(--mb-ok); } .mb-mark.is-bad { color: var(--mb-bad); }
.mb-seal { margin: 0; font-size: 16px; font-weight: 700; color: var(--mb-accent); }

/* run button */
.mb-run { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 8px 12px; font-size: 18px; font-weight: 800;
  color: #fff; background: linear-gradient(#c45a33, #9a3d20); border: 2px solid #7a2c14; border-radius: 10px; cursor: pointer; box-shadow: 0 3px 0 #5e210f; }
.mb-run:hover:not(:disabled) { filter: brightness(1.06); }
.mb-run:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 #5e210f; }
.mb-run:focus-visible { outline: 3px solid var(--tlg-focus, #1a73e8); outline-offset: 3px; }
.mb-run:disabled { cursor: default; background: #cfc9c6; border-color: #aea6a2; color: #3f3936; box-shadow: none; }
html[data-theme="dark"] .mb-run:disabled { background: #403936; border-color: #5c5350; color: #ddd5d1; }
.mb-run.is-done:disabled { background: #f1e3db; color: #7a2c14; border-color: #d29a83; }
html[data-theme="dark"] .mb-run.is-done:disabled { background: #3d2820; color: #f6cbb9; border-color: #8a4d36; }
.mb-run-i { font-size: 18px; }
.mb-run.is-done .mb-run-t { font-size: 16px; }

/* mission sheet */
.mb-sheet { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 6px; }
.mb-card { padding: 4px 10px; border-radius: 10px; background: var(--tlg-surface, #fff); border: 2px solid var(--tlg-border, #ccd); }
.mb-card h3 { margin: 0; font-size: 16px; color: var(--mb-accent); }
.mb-card p { margin: 0; font-size: 16px; line-height: 1.3; }

/* scene */
.mb-scene { flex: 1 1 auto; min-height: 0; display: flex; justify-content: center; border-radius: 10px; overflow: hidden; }
.mb-svg { display: block; width: 100%; height: 100%; max-height: 100%; }
.mb-hills { fill: var(--mb-hill); } .mb-hills2 { fill: var(--mb-hill2); }
.mb-rocks ellipse { fill: var(--mb-rock); opacity: .7; }
.mb-leg { stroke: var(--mb-leg); stroke-width: 3; fill: none; }
.mb-face { fill: url(#mb-g-panel); stroke: #102846; stroke-width: 1.5; }
.mb-grid { stroke: var(--mb-panel-line); stroke-width: 1; fill: none; opacity: .55; }
.mb-dust { fill: var(--mb-dustc); opacity: var(--mb-dust-o, 0); }
.mb-glint { fill: #fff; opacity: 0; }
.mb-stow { fill: var(--mb-stow); stroke: var(--mb-leg); stroke-width: 1.5; stroke-dasharray: 4 3; }
.mb-kit .mb-kit-on { display: none; } .mb-kit.is-on .mb-kit-on { display: inline; } .mb-kit.is-on .mb-kit-off { display: none; }
.mb-kit .mb-leg { opacity: .5; } .mb-kit.is-on .mb-leg { opacity: 1; }
.mb-svg.is-running .mb-kit.is-on .mb-glint { animation: mb-glint 1.3s ease-in-out 2 alternate; }
@keyframes mb-glint { 0%, 70% { opacity: 0; } 100% { opacity: .35; } }
.mb-cable { fill: none; stroke: var(--mb-cable); stroke-width: 4; stroke-linecap: round; }
.mb-pulse { fill: var(--mb-pulse); stroke: #7a5a00; stroke-width: 1.5; }
.mb-co2 { fill: #f6e2cf; stroke: #8c5a3c; stroke-width: 1.2; }
.mb-dome-in { fill: url(#mb-g-dome); }
.mb-dome { fill: none; stroke: var(--mb-dome-line); stroke-width: 5; }
.mb-dome-glare { fill: none; stroke: #fff; stroke-width: 5; stroke-linecap: round; opacity: .55; }
html[data-theme="dark"] .mb-dome-glare { opacity: .2; }
.mb-dome-rib { stroke: var(--mb-rib); stroke-width: 3; fill: none; }
.mb-floor { fill: var(--mb-floor); }
.mb-pipe { stroke: var(--mb-steel-line); stroke-width: 7; fill: none; stroke-linecap: round; }
.mb-pipe-o2 { stroke: var(--mb-o2b); }
.mb-gen { fill: url(#mb-g-steel); stroke: var(--mb-steel-line); stroke-width: 2.5; }
.mb-gen-win { fill: #1c2a33; }
.mb-gen-core circle { fill: #ff9a4d; opacity: .5; }
.mb-svg.is-running .mb-gen-core circle { animation: mb-core .5s ease-in-out infinite alternate; }
@keyframes mb-core { from { opacity: .4; } to { opacity: 1; } }
.mb-tank-body { fill: url(#mb-g-steel); stroke: var(--mb-steel-line); stroke-width: 2.5; }
.mb-tank-cap { fill: var(--mb-steel1); stroke: var(--mb-steel-line); stroke-width: 2; }
.mb-tank-glare { stroke: #fff; stroke-width: 3; opacity: .5; stroke-linecap: round; }
.mb-tick { stroke: var(--mb-text); stroke-width: 2.5; stroke-dasharray: 5 3; }
.mb-tank-w.is-dry .mb-tank-body { stroke: var(--mb-bad); stroke-width: 4; }
.mb .is-assess .mb-tank-w.is-dry .mb-tank-body, .mb.is-assess .mb-tank-w.is-dry .mb-tank-body { stroke: var(--mb-steel-line); stroke-width: 2.5; }
.mb-loop { fill: none; stroke: var(--mb-water2); stroke-width: 3; opacity: .35; }
.mb-loop-arrows, .mb-loop-heads { fill: none; stroke: var(--mb-water2); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.mb-recycler.is-off .mb-loop-arrows, .mb-recycler.is-off .mb-loop-heads { stroke: var(--mb-stow); }
.mb-loop-spin { transform-box: view-box; transform-origin: 0 0; }
.mb-svg.is-running .mb-recycler:not(.is-off) .mb-loop-spin { animation: mb-spin var(--mb-spin, 3s) linear infinite; }
@keyframes mb-spin { to { transform: rotate(360deg); } }
.mb-shelf { fill: var(--mb-steel2); stroke: var(--mb-steel-line); stroke-width: 2; }
.mb-shelf-board { stroke: var(--mb-steel-line); stroke-width: 3; }
.mb-crate { transition: opacity .25s; }
.mb-crew-in { transform-box: fill-box; transform-origin: 50% 100%; }
.mb-crew.is-cheer .mb-crew-in { animation: mb-hop .5s ease-in-out 3 alternate; animation-delay: var(--mb-d, 0s); }
.mb-crew.is-cheer .mb-arm { transform-box: fill-box; transform-origin: 50% 0; transform: rotate(180deg); }
@keyframes mb-hop { to { transform: translateY(-8px); } }
.mb-crew.is-worry .mb-crew-in { animation: mb-sway 1s ease-in-out 2 alternate; }
@keyframes mb-sway { from { transform: rotate(-3deg); } to { transform: rotate(3deg); } }
.mb-placard rect { fill: var(--mb-plate); }
.mb-t { font-family: var(--tlg-font, sans-serif); font-size: 18px; fill: var(--mb-text); }
.mb-t-plate { fill: var(--mb-plate-text); font-weight: 800; font-size: 17px; letter-spacing: .04em; }
.mb-t-tank { font-weight: 900; fill: #10212b; paint-order: stroke; stroke: rgba(255,255,255,.75); stroke-width: 3px; }
.mb-deck { fill: var(--mb-steel2); }
.mb-intake-mouth { stroke: var(--mb-steel-line); stroke-width: 6; stroke-linecap: round; }
.mb-pipe-w { stroke: var(--mb-water2); stroke-width: 5; }
.mb-pipe-co { stroke-width: 5; }
.mb-t-kits { font-weight: 800; fill: #fff; paint-order: stroke; stroke: rgba(60,20,8,.75); stroke-width: 4px; }
.mb-t-model { font-size: 17px; font-weight: 700; fill: #fff; paint-order: stroke; stroke: rgba(60,20,8,.7); stroke-width: 4px; }
.mb-lamp { opacity: 0; } .mb-lamp.is-ok, .mb-lamp.is-bad { opacity: 1; }
.mb-lamp circle { fill: #5c5f63; stroke: #fff; stroke-width: 2; }
.mb-lamp.is-ok circle { fill: #2fae6a; } .mb-lamp.is-bad circle { fill: #d93025; }
.mb-lamp.is-bad circle { animation: mb-blink .5s steps(2) 6; }
@keyframes mb-blink { 50% { fill: #5c5f63; } }
.mb-lamp-t { font-family: var(--tlg-font, sans-serif); font-size: 13px; font-weight: 900; fill: #fff; }
.mb-haze { fill: var(--mb-haze); pointer-events: none; }
.mb-storm circle { fill: #f3d2b5; opacity: .7; }
.mb-storm { animation: mb-storm 4s linear infinite; }
@keyframes mb-storm { from { transform: translateX(-40px); } to { transform: translateX(40px); } }
.mb-badge rect { fill: #5a2412; } .mb-t-badge { fill: #fff; font-weight: 800; font-size: 17px; }

/* ledger */
.mb-ledger { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; }
.mb-gauge { display: grid; gap: 2px; }
.mb-g-h { display: flex; align-items: baseline; gap: 8px; font-size: 16px; line-height: 1.25; }
.mb-g-h b { flex: none; }
.mb-g-v { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mb-g-s { flex: none; font-weight: 800; white-space: nowrap; }
.mb-gauge.is-ok .mb-g-s { color: var(--mb-ok); } .mb-gauge.is-bad .mb-g-s { color: var(--mb-bad); }
.mb-g-row { display: flex; align-items: center; gap: 8px; min-height: 20px; }
.mb-g-row .mb-g-track { flex: 1 1 auto; }
.mb-g-track { position: relative; height: 14px; border-radius: 7px; background: var(--mb-gauge-bg); border: 1px solid var(--tlg-border-strong, #888); overflow: visible; }
.mb-g-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 7px; transition: width .7s ease-out; }
.mb-g-fill--o2 { background: linear-gradient(90deg, #3e9cc9, #8fd3f2); }
.mb-g-fill--water { background: repeating-linear-gradient(45deg, #2a76b0 0 6px, #63b6e6 6px 12px); }
.mb-g-fill--food { background: repeating-linear-gradient(-45deg, #a8742f 0 6px, #d9a65c 6px 12px); }
.mb-g-fill--energy { background: linear-gradient(90deg, #c99a00, #ffd23f); }
.mb-g-tick { position: absolute; top: -4px; bottom: -4px; width: 3px; margin-left: -1.5px; background: var(--tlg-text); }
.mb-g-tick-l { position: absolute; right: 6px; top: -1px; font-size: 0; }
.mb-gauge.is-flash .mb-g-track { animation: mb-flash .5s ease-in-out 4 alternate; }
@keyframes mb-flash { to { box-shadow: 0 0 0 3px var(--mb-bad); } }
.mb-readout { margin: 0; font-size: 16px; line-height: 1.3; min-height: 21px; }
.mb-about { font-size: 16px; }
.mb-about summary { cursor: pointer; font-weight: 700; min-height: 26px; }
.mb-about p { margin: 4px 0 0; max-height: 160px; overflow: auto; }

/* worked example (Briefing) */
.mb-ex { border-collapse: collapse; font-size: 17px; width: 100%; max-width: 560px; }
.mb-ex caption { text-align: left; font-weight: 800; padding-bottom: 6px; }
.mb-ex th, .mb-ex td { text-align: left; padding: 4px 10px 4px 0; border-bottom: 1px solid var(--tlg-border, #ccd); }
.mb-ex td:last-child { text-align: right; white-space: nowrap; }

.mb.is-locked .mb-slider input { cursor: default; }

@media (max-width: 900px) {
  .mb { position: static; grid-template-columns: 1fr; }
  .mb-controls { overflow: visible; }
  .mb-sheet { grid-template-columns: 1fr; }
  .mb-scene { min-height: 200px; }
  .mb-ledger { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .mb *, .mb *::before { animation: none !important; transition: none !important; }
}
