:root {
  color-scheme: dark;
  --bg: #0b1218;
  --panel: #121d26;
  --panel-2: #17242e;
  --panel-3: #1b2a35;
  --line: rgba(185, 207, 220, .12);
  --line-strong: rgba(185, 207, 220, .2);
  --text: #e7eef2;
  --muted: #92a4af;
  --faint: #647783;
  --accent: #55d6c2;
  --accent-soft: rgba(85, 214, 194, .13);
  --danger: #e6a48f;
  --radius: 14px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; min-width: 320px; color: var(--text); background: radial-gradient(ellipse at 20% -10%, rgba(41, 72, 84, .23), transparent 46%), var(--bg); }
button, input { font: inherit; }
button { color: inherit; }
.app-shell { height: 100vh; min-height: 0; display: flex; flex-direction: column; }
.topbar { height: 68px; flex: 0 0 68px; display: flex; align-items: center; padding: 0 24px; border-bottom: 1px solid var(--line); background: rgba(12, 20, 27, .88); gap: 13px; }
.brand-mark { width: 29px; height: 29px; display: grid; grid-template-columns: repeat(2, 1fr); grid-template-rows: repeat(2, 1fr); gap: 3px; transform: rotate(-8deg); }
.brand-mark span { display: block; border: 1px solid rgba(85, 214, 194, .7); background: rgba(85, 214, 194, .12); border-radius: 3px; }
.brand-mark span:nth-child(2), .brand-mark span:nth-child(3) { background: rgba(85, 214, 194, .3); }
.brand-copy { min-width: 0; }
.eyebrow { color: #81939e; font-size: 9px; line-height: 1.3; letter-spacing: .16em; font-weight: 750; }
.eyebrow span { color: var(--accent); padding: 0 4px; }
.brand-title { font-size: 15px; font-weight: 680; letter-spacing: -.025em; margin-top: 3px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.live-dot, .run-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px rgba(85, 214, 194, .45); }
.status-label { font-size: 9px; font-weight: 750; letter-spacing: .14em; color: #a4b5be; }
.quality-button { border: 1px solid var(--line-strong); background: #16232c; color: #b7c7ce; padding: 7px 10px; border-radius: 6px; font-size: 9px; letter-spacing: .1em; font-weight: 800; cursor: pointer; margin-left: 10px; }
.quality-button:hover { border-color: rgba(85, 214, 194, .5); color: var(--accent); }
.workspace { width: 100%; max-width: 1720px; margin: 0 auto; padding: 18px; display: grid; grid-template-columns: minmax(0, 1fr) 370px; grid-template-rows: minmax(0, 1fr); gap: 16px; flex: 1; min-height: 0; }
.visual-column { display: flex; flex-direction: column; min-width: 0; min-height: 0; gap: 12px; }
.stage-card, .readout-card, .panel { background: linear-gradient(145deg, rgba(22, 34, 44, .97), rgba(16, 27, 36, .98)); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 12px 32px rgba(0, 0, 0, .14); }
.stage-card { padding: 16px 16px 12px; display: flex; flex-direction: column; flex: 1 1 auto; min-height: 350px; overflow: hidden; }
.stage-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 0 2px 12px; }
.stage-title { font-size: 16px; font-weight: 680; letter-spacing: -.025em; margin-top: 4px; }
.specimen-chip { display: inline-flex; align-items: center; gap: 7px; padding: 6px 9px; border: 1px solid var(--line); border-radius: 5px; color: #b8c7cd; font-size: 9px; font-weight: 800; letter-spacing: .1em; white-space: nowrap; }
.chip-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.specimen-chip.damaged .chip-dot { background: var(--danger); box-shadow: 0 0 10px rgba(230, 164, 143, .4); }
.canvas-wrap { position: relative; flex: 1 1 auto; min-height: 265px; overflow: hidden; border: 1px solid rgba(168, 194, 207, .1); border-radius: 10px; background: #101a22; }
#fabricCanvas { display: block; width: 100%; height: 100%; touch-action: pan-y; }
.canvas-corner { position: absolute; pointer-events: none; color: rgba(185, 205, 215, .5); font-size: 8px; font-weight: 750; letter-spacing: .13em; }
.canvas-corner span { color: var(--accent); font-size: 12px; padding-left: 3px; }
.canvas-corner.top-left { top: 13px; left: 14px; }
.canvas-corner.top-right { top: 13px; right: 14px; }
.canvas-corner.bottom-left { bottom: 12px; left: 14px; }
.canvas-corner.bottom-right { bottom: 12px; right: 14px; text-align: right; }
.caption-band { display: flex; align-items: flex-start; gap: 10px; padding: 12px 3px 1px; min-height: 44px; }
.caption-icon { width: 17px; height: 17px; flex: 0 0 17px; display: grid; place-items: center; border-radius: 50%; border: 1px solid rgba(85, 214, 194, .5); color: var(--accent); font-family: Georgia, serif; font-size: 12px; font-style: italic; }
.caption-band p { margin: 0; color: #aebdc5; font-size: 11px; line-height: 1.5; }
.readout-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.readout-card { padding: 12px 13px 11px; min-width: 0; }
.readout-label { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; min-height: 17px; color: #8ea1ac; font-size: 8px; letter-spacing: .11em; font-weight: 800; }
.provenance { display: inline-flex; align-items: center; border-radius: 3px; padding: 2px 4px; font-size: 7px; line-height: 1.1; font-weight: 850; letter-spacing: .08em; white-space: nowrap; }
.provenance.textbook { color: #a9d8d0; background: rgba(85, 214, 194, .1); }
.provenance.scaled { color: #b8c9d5; background: rgba(151, 177, 193, .11); }
.provenance.illustrative { color: #d5bda1; background: rgba(213, 189, 161, .1); }
.readout-value { font-variant-numeric: tabular-nums; font-size: clamp(21px, 2.2vw, 29px); line-height: 1.25; font-weight: 650; letter-spacing: -.045em; margin-top: 5px; white-space: nowrap; }
.readout-value small { font-size: 12px; color: #9eb0b9; font-weight: 550; margin-left: 3px; letter-spacing: 0; }
.readout-foot { color: #6f828d; font-size: 9px; margin-top: 4px; line-height: 1.35; }
.lower-readout-row { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 4px; }
.torque-readout { display: flex; align-items: baseline; gap: 7px; min-width: 0; }
.mini-label { color: #778a95; font-size: 8px; font-weight: 800; letter-spacing: .1em; white-space: nowrap; }
.torque-readout strong { font-size: 13px; font-weight: 680; font-variant-numeric: tabular-nums; white-space: nowrap; }
.torque-readout strong small { font-size: 9px; color: #9eafb8; font-weight: 500; }
.travel-status { margin-left: auto; color: var(--accent); font-size: 8px; font-weight: 850; letter-spacing: .1em; white-space: nowrap; }
.travel-status.warning { color: #e1bd93; }
.travel-status.damaged { color: var(--danger); }
.control-column { display: flex; flex-direction: column; gap: 12px; min-width: 0; min-height: 0; overflow-y: auto; padding-right: 2px; scrollbar-width: thin; scrollbar-color: #344650 transparent; }
.panel { padding: 15px; }
.panel-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 13px; }
.panel-heading h1, .panel-heading h2 { font-size: 16px; font-weight: 680; letter-spacing: -.03em; margin: 4px 0 0; }
.panel-heading h1 { font-size: 18px; }
.panel-index { color: #617783; font-size: 9px; font-weight: 800; letter-spacing: .12em; padding-top: 2px; }
.preset-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.preset-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.preset { display: flex; align-items: center; gap: 8px; text-align: left; min-height: 34px; padding: 7px 8px; border: 1px solid var(--line); border-radius: 6px; background: #17242d; color: #aebdc5; font-size: 10px; font-weight: 650; cursor: pointer; transition: border-color .15s, background .15s, color .15s; }
.preset:hover { border-color: rgba(85, 214, 194, .35); }
.preset.active { border-color: rgba(85, 214, 194, .58); background: var(--accent-soft); color: #d6f3ed; }
.preset-mark { width: 13px; height: 13px; flex: 0 0 13px; border: 1px solid rgba(220, 231, 234, .55); border-radius: 3px; background: repeating-linear-gradient(45deg, #8f9e9e 0 2px, #33464b 2px 4px); }
.plain-mark { background: repeating-linear-gradient(0deg, #a99b86 0 3px, #52616a 3px 6px); }
.dense-mark { background: repeating-linear-gradient(45deg, #a99b86 0 3px, #52616a 3px 5px); }
.broken-mark { background: linear-gradient(135deg, #a99b86 0 42%, #17242d 43% 57%, #a99b86 58%); }
.preset-description { color: #81939d; font-size: 9px; line-height: 1.45; margin: 8px 0 0; min-height: 26px; }
.control-divider { height: 1px; background: var(--line); margin: 12px 0; }
.control-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-top: 10px; }
.control-row label { color: #d3dde2; font-size: 10px; font-weight: 650; }
.control-row .unit { color: #7c909b; font-size: 8px; font-weight: 500; margin-left: 4px; }
.control-row output { color: var(--accent); font-size: 10px; font-weight: 750; font-variant-numeric: tabular-nums; }
input[type="range"] { display: block; width: 100%; height: 15px; margin: 4px 0 0; appearance: none; background: transparent; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 3px; border-radius: 5px; background: linear-gradient(90deg, rgba(85, 214, 194, .8), rgba(85, 214, 194, .17)); }
input[type="range"]::-moz-range-track { height: 3px; border-radius: 5px; background: linear-gradient(90deg, rgba(85, 214, 194, .8), rgba(85, 214, 194, .17)); }
input[type="range"]::-webkit-slider-thumb { appearance: none; width: 11px; height: 11px; margin-top: -4px; border-radius: 50%; background: var(--accent); border: 2px solid #d9fff8; box-shadow: 0 0 0 3px rgba(85, 214, 194, .12); }
input[type="range"]::-moz-range-thumb { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); border: 2px solid #d9fff8; box-shadow: 0 0 0 3px rgba(85, 214, 194, .12); }
input[type="range"]:focus-visible { outline: 1px solid var(--accent); outline-offset: 4px; border-radius: 4px; }
.range-ends { display: flex; justify-content: space-between; color: #667984; font-size: 8px; font-variant-numeric: tabular-nums; margin-top: -1px; }
.transport-controls { display: grid; grid-template-columns: 1.1fr .9fr .9fr; gap: 6px; }
.transport-button { min-height: 35px; display: inline-flex; justify-content: center; align-items: center; gap: 7px; border: 1px solid var(--line-strong); border-radius: 6px; background: #182731; color: #aebdc5; font-size: 10px; font-weight: 700; cursor: pointer; }
.transport-button:hover { border-color: rgba(85, 214, 194, .5); color: var(--text); }
.transport-button.primary { background: var(--accent-soft); border-color: rgba(85, 214, 194, .45); color: #c8f4eb; }
.button-icon { font-size: 13px; color: var(--accent); }
.run-note { display: flex; align-items: center; gap: 7px; margin-top: 9px; color: #748792; font-size: 8px; }
.run-dot { width: 5px; height: 5px; flex: 0 0 5px; }
.run-note.paused .run-dot { background: #738792; box-shadow: none; }
.experiment-panel, .checks-panel { padding-top: 13px; padding-bottom: 13px; }
.compact-heading { margin-bottom: 8px; }
.compact-heading h2 { font-size: 14px; }
.panel-copy { color: #91a3ad; font-size: 9px; line-height: 1.5; margin: 0 0 10px; }
.experiment-button { width: 100%; display: flex; justify-content: space-between; align-items: center; padding: 9px 11px; border: 1px solid rgba(85, 214, 194, .45); border-radius: 6px; background: rgba(85, 214, 194, .1); color: #d1f4ec; font-size: 10px; font-weight: 750; cursor: pointer; }
.experiment-button:hover { background: rgba(85, 214, 194, .17); }
.experiment-button span:last-child { color: var(--accent); font-size: 15px; }
.experiment-result { color: #91a3ad; font-size: 9px; line-height: 1.5; margin-top: 9px; min-height: 27px; }
.experiment-result strong { color: #d8e7e8; font-variant-numeric: tabular-nums; }
.check-list { display: flex; flex-direction: column; gap: 7px; }
.check-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid rgba(185, 207, 220, .07); }
.check-row:last-child { border-bottom: 0; }
.check-name { color: #b8c6cc; font-size: 9px; }
.check-name em { display: inline-block; color: #748894; font-size: 7px; font-style: normal; text-transform: uppercase; letter-spacing: .07em; margin-left: 3px; }
.check-row strong { color: #c6d6da; font-size: 9px; font-variant-numeric: tabular-nums; }
.check-state { color: var(--accent); font-size: 7px; font-weight: 850; letter-spacing: .09em; }
.check-foot { color: #6e818b; font-size: 8px; line-height: 1.4; border-top: 1px solid var(--line); padding-top: 8px; margin-top: 5px; }
.science-panel { padding: 0; overflow: hidden; }
.science-panel summary { list-style: none; display: flex; align-items: center; justify-content: space-between; padding: 13px 15px; cursor: pointer; }
.science-panel summary::-webkit-details-marker { display: none; }
.science-panel summary strong { display: block; font-size: 14px; margin-top: 3px; }
.summary-plus { color: var(--accent); font-size: 19px; font-weight: 300; transition: transform .2s; }
.science-panel[open] .summary-plus { transform: rotate(45deg); }
.science-content { padding: 0 15px 15px; color: #9eafb8; font-size: 9px; line-height: 1.55; }
.science-content h3 { color: #d6e1e5; font-size: 10px; letter-spacing: .02em; margin: 12px 0 5px; }
.science-content p { margin: 5px 0 8px; }
.science-content ul { padding-left: 16px; margin: 6px 0 10px; }
.science-content li { margin: 4px 0; }
.equation { background: rgba(6, 13, 18, .42); border: 1px solid rgba(185, 207, 220, .09); border-radius: 5px; padding: 7px 9px; color: #d3e8e4; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 9px; margin: 5px 0; overflow-wrap: anywhere; }
.honesty-note { border-left: 2px solid var(--accent); padding-left: 9px; color: #b6c5c9; }
.panel-footer { text-align: center; color: #526570; font-size: 7px; letter-spacing: .13em; padding: 2px 0 5px; }

body.embed-mode { height: 100vh; height: 100dvh; overflow: hidden; }
body.embed-mode .app-shell { height: 100%; min-height: 0; }
body.embed-mode .topbar { display: none; }
body.embed-mode .workspace { height: 100%; min-height: 0; padding: 12px; }
body.embed-mode .control-column { overscroll-behavior: contain; }

@media (min-width: 1500px) {
  .workspace { grid-template-columns: minmax(0, 1fr) 390px; gap: 18px; padding: 20px; }
  .stage-card { padding: 18px; }
}
@media (max-width: 1050px) {
  .workspace { grid-template-columns: minmax(0, 1fr) 340px; padding: 12px; gap: 12px; }
  .readout-grid { gap: 7px; }
  .readout-card { padding: 10px; }
  .readout-label { font-size: 7px; }
  .lower-readout-row { flex-wrap: wrap; row-gap: 5px; }
}
@media (max-width: 760px) {
  .app-shell { height: auto; min-height: 100vh; }
  .topbar { height: 58px; flex-basis: 58px; padding: 0 14px; }
  .status-label, .live-dot { display: none; }
  .brand-title { font-size: 13px; }
  .eyebrow { font-size: 8px; }
  .quality-button { margin-left: 0; padding: 7px 8px; }
  .workspace { display: flex; flex-direction: column; padding: 10px; gap: 10px; flex: initial; }
  .visual-column { gap: 9px; }
  .stage-card { min-height: 0; padding: 12px 11px 9px; }
  .stage-heading { padding-bottom: 9px; }
  .stage-title { font-size: 14px; }
  .canvas-wrap { min-height: 0; height: clamp(255px, 43vh, 390px); flex: 0 0 auto; }
  .caption-band { padding-top: 9px; min-height: 36px; }
  .caption-band p { font-size: 10px; }
  .readout-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
  .readout-card { padding: 10px 11px; }
  .readout-value { font-size: 24px; }
  .readout-label { font-size: 8px; }
  .lower-readout-row { gap: 7px 14px; padding: 0 2px; }
  .torque-readout { flex-wrap: wrap; column-gap: 5px; row-gap: 1px; }
  .mini-label { font-size: 7px; }
  .torque-readout strong { font-size: 12px; }
  .travel-status { margin-left: auto; }
  .control-column { overflow: visible; padding: 0 0 8px; }
  body.embed-mode .workspace { display: flex; flex-direction: column; overflow: hidden; gap: 8px; padding: 8px; }
  body.embed-mode .visual-column { flex: 0 0 auto; min-height: 0; }
  body.embed-mode .stage-card { padding: 9px 9px 7px; }
  body.embed-mode .canvas-wrap { height: 39dvh; min-height: 180px; max-height: 360px; }
  body.embed-mode .readout-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; }
  body.embed-mode .readout-card { padding: 7px 6px; }
  body.embed-mode .readout-label { font-size: 6px; letter-spacing: .05em; }
  body.embed-mode .provenance { font-size: 5px; padding: 1px 2px; }
  body.embed-mode .readout-value { font-size: 17px; }
  body.embed-mode .readout-value small { font-size: 9px; }
  body.embed-mode .readout-foot { font-size: 7px; }
  body.embed-mode .lower-readout-row { min-height: 25px; flex-wrap: nowrap; overflow: hidden; }
  body.embed-mode .torque-readout { gap: 3px; }
  body.embed-mode .mini-label { font-size: 6px; }
  body.embed-mode .torque-readout strong { font-size: 10px; }
  body.embed-mode .torque-readout .provenance { display: none; }
  body.embed-mode .travel-status { font-size: 6px; }
  body.embed-mode .control-column { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
}
@media (max-width: 430px) {
  .workspace { padding: 8px; }
  .specimen-chip { font-size: 7px; padding: 5px 7px; }
  .canvas-corner { font-size: 6px; }
  .canvas-corner.top-left, .canvas-corner.top-right { top: 9px; }
  .canvas-corner.bottom-left, .canvas-corner.bottom-right { bottom: 8px; }
  .readout-value { font-size: 22px; }
  .readout-foot { font-size: 8px; }
  body.embed-mode .workspace { padding: 6px; gap: 6px; }
  body.embed-mode .canvas-wrap { height: 36dvh; min-height: 170px; }
  body.embed-mode .caption-band { min-height: 29px; padding-top: 6px; }
  body.embed-mode .caption-band p { font-size: 8px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; } }
