/* EMC LAB · shared shell for RS / ESD / CE simulations */
:root {
  --bg: #0e2630;
  --bg-2: #14323c;
  --panel: #183844;
  --panel-2: #1d4250;
  --line: rgba(142, 226, 222, 0.16);
  --line-strong: rgba(142, 226, 222, 0.30);
  --ink: #e9f8f6;
  --muted: #8fb4b8;
  --dim: #62868b;
  --teal: #7ff0e0;
  --teal-soft: rgba(127, 240, 224, 0.14);
  --amber: #ffc46b;
  --amber-soft: rgba(255, 196, 107, 0.14);
  --red: #ff7078;
  --red-soft: rgba(255, 112, 120, 0.14);
  --green: #7dffb2;
  --green-soft: rgba(125, 255, 178, 0.12);
  --accent: #7ff0e0;
  --accent-2: #ffc46b;
  --mono: "Cascadia Mono", "JetBrains Mono", Consolas, "Courier New", monospace;
  --display: "Bahnschrift", "Segoe UI", "Microsoft YaHei", sans-serif;
  --sans: "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(1200px 700px at 18% -10%, rgba(128, 224, 218, 0.16), transparent 55%),
    radial-gradient(1000px 600px at 92% 110%, rgba(255, 186, 104, 0.09), transparent 60%),
    var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.22;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='.20'/%3E%3C/svg%3E");
  mix-blend-mode: soft-light;
  z-index: 1;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
.app { position: relative; z-index: 2; height: 100%; display: flex; flex-direction: column; }

/* top bar */
.topbar {
  height: 56px;
  flex: 0 0 56px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(18, 40, 50, 0.98), rgba(12, 28, 36, 0.96));
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.02), 0 8px 24px rgba(0, 0, 0, 0.24);
}
.lab-back {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 28px;
  padding: 0 9px;
  border: 1px solid rgba(127, 240, 224, 0.28);
  border-radius: 3px;
  color: var(--muted);
  text-decoration: none;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.08em;
  white-space: nowrap;
  transition: 0.18s ease;
}
.lab-back:hover { color: var(--ink); border-color: var(--teal); background: rgba(127, 240, 224, 0.07); }
.lab-back b { font-weight: 400; }
.lab-back span { color: var(--teal); font-size: 13px; line-height: 1; }

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark { width: 26px; height: 26px; color: var(--teal); flex: 0 0 26px; filter: drop-shadow(0 0 8px rgba(127, 240, 224, 0.28)); }
.brand-name {
  font-family: var(--display);
  font-size: 19px;
  line-height: 1.05;
  letter-spacing: 0.11em;
  font-weight: 600;
  white-space: nowrap;
}
.brand-name em { font-style: normal; color: var(--accent-2); }
.brand-sub {
  margin-top: 3px;
  font-family: var(--mono);
  font-size: 8px;
  line-height: 1;
  letter-spacing: 0.14em;
  color: var(--dim);
  white-space: nowrap;
}

.top-meta { display: flex; align-items: center; gap: 7px; margin-left: 6px; min-width: 0; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 8px;
  border: 1px solid var(--line);
  background: rgba(9, 24, 31, 0.62);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.05em;
  color: var(--muted);
  white-space: nowrap;
}
.chip i { width: 5px; height: 5px; border-radius: 50%; background: var(--green); box-shadow: 0 0 7px var(--green); }
.chip.amber i { background: var(--amber); box-shadow: 0 0 7px var(--amber); }
.chip b { font-weight: 400; color: var(--ink); }

.top-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.clock { text-align: right; font-family: var(--mono); line-height: 1.15; color: var(--ink); font-size: 13px; letter-spacing: 0.06em; }
.clock small { display: block; font-size: 7px; letter-spacing: 0.2em; color: var(--dim); }
.icon-btn {
  width: 28px; height: 28px; border: 1px solid var(--line); background: transparent;
  color: var(--muted); font-family: var(--mono); font-size: 12px; border-radius: 2px;
}
.icon-btn:hover { color: var(--ink); border-color: var(--line-strong); background: rgba(127, 240, 224, 0.05); }

/* workspace */
.workspace {
  flex: 1;
  min-height: 0;
  padding: 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 372px;
  grid-template-rows: minmax(0, 1fr) 258px;
  gap: 12px;
}
.pane {
  position: relative;
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--line);
  background: linear-gradient(160deg, rgba(24, 54, 65, 0.98), rgba(14, 34, 43, 0.98));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035), 0 10px 30px rgba(0, 0, 0, 0.18);
  overflow: hidden;
}
.pane::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border: 1px solid rgba(255, 255, 255, 0.025);
  z-index: 3;
}

/* stage */
.stage { grid-column: 1; grid-row: 1; background: #15343f; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; filter: brightness(1.16) saturate(1.06); }
.stage-tl { position: absolute; left: 22px; top: 18px; z-index: 2; pointer-events: none; max-width: 62%; }
.eyebrow { font-family: var(--mono); font-size: 8.5px; letter-spacing: 0.18em; color: var(--teal); text-transform: uppercase; text-shadow: 0 1px 5px rgba(0, 0, 0, 0.5); }
.stage-title { margin: 5px 0 4px; font-family: var(--display); font-size: 30px; line-height: 1.15; font-weight: 500; letter-spacing: 0.02em; text-shadow: 0 2px 16px rgba(0, 0, 0, 0.6); }
.stage-sub { font-family: var(--mono); font-size: 9px; letter-spacing: 0.06em; color: #a8c8ca; text-shadow: 0 1px 4px rgba(0, 0, 0, 0.7); }
.stage-tr { position: absolute; right: 18px; top: 16px; z-index: 2; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.legend { display: flex; align-items: center; gap: 7px; font-family: var(--mono); font-size: 8.5px; color: #a9c5c7; letter-spacing: 0.05em; text-shadow: 0 1px 4px #000; }
.legend i { width: 15px; height: 2px; background: var(--teal); box-shadow: 0 0 7px rgba(127, 240, 224, 0.55); }
.legend.amber i { background: var(--amber); box-shadow: 0 0 7px rgba(255, 196, 107, 0.55); }
.legend.red i { background: var(--red); box-shadow: 0 0 7px rgba(255, 112, 120, 0.55); }

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 4px;
  padding: 5px 9px;
  border: 1px solid rgba(127, 240, 224, 0.23);
  background: rgba(4, 15, 19, 0.72);
  backdrop-filter: blur(4px);
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: 0.12em;
  color: var(--teal);
  text-transform: uppercase;
}
.live-pill i { width: 6px; height: 6px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 8px var(--teal); animation: dotPulse 2.2s infinite; }
.live-pill.idle { color: var(--muted); border-color: var(--line); }
.live-pill.idle i { background: var(--dim); box-shadow: none; animation: none; }
.live-pill.scanning { color: var(--teal); border-color: rgba(127, 240, 224, 0.38); }
.live-pill.scanning i { background: var(--teal); box-shadow: 0 0 9px var(--teal); animation: dotPulse 1.2s infinite; }
.live-pill.fail { color: var(--red); border-color: rgba(255, 112, 120, 0.35); }
.live-pill.fail i { background: var(--red); box-shadow: 0 0 8px var(--red); }
.live-pill.pass { color: var(--green); border-color: rgba(125, 255, 178, 0.3); }
.live-pill.pass i { background: var(--green); box-shadow: 0 0 8px var(--green); }

.stage-bl { position: absolute; left: 16px; bottom: 14px; z-index: 2; display: flex; gap: 10px; align-items: center; }
.hint { font-family: var(--mono); font-size: 8px; letter-spacing: 0.06em; color: rgba(190, 220, 220, 0.72); background: rgba(3, 12, 16, 0.58); border: 1px solid rgba(142, 226, 222, 0.14); padding: 5px 8px; backdrop-filter: blur(4px); }
.stage-br { position: absolute; right: 16px; bottom: 14px; z-index: 2; display: flex; align-items: flex-end; gap: 14px; }
.readout { text-align: right; font-family: var(--mono); }
.readout small { display: block; font-size: 7px; letter-spacing: 0.18em; color: #7ca0a2; margin-bottom: 2px; }
.readout b { font-weight: 500; font-size: 12px; color: #e8f6f4; }
.readout b em { font-style: normal; color: var(--amber); }

.stage-badge {
  position: absolute;
  left: 16px;
  top: 50%;
  z-index: 2;
  transform: translateY(-50%);
  writing-mode: vertical-rl;
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.28em;
  color: rgba(127, 240, 224, 0.38);
  pointer-events: none;
}

.scan-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; z-index: 2; background: rgba(127, 240, 224, 0.08); }
.scan-progress span { display: block; height: 100%; width: 0%; background: linear-gradient(90deg, var(--teal), var(--amber)); box-shadow: 0 0 10px var(--teal); transition: width 0.08s linear; }

/* right panel */
.panel { grid-column: 2; grid-row: 1 / span 2; display: flex; flex-direction: column; background: linear-gradient(180deg, #183844, #122d37); }
.panel-head {
  flex: 0 0 auto;
  height: 36px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  color: var(--muted);
}
.panel-head b { font-weight: 500; color: var(--teal); letter-spacing: 0.16em; }
.panel-head span { color: var(--dim); font-size: 8px; }
.panel-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 0 14px 12px; scrollbar-width: thin; scrollbar-color: rgba(127, 240, 224, 0.35) transparent; }
.panel-scroll::-webkit-scrollbar { width: 5px; }
.panel-scroll::-webkit-scrollbar-thumb { background: rgba(127, 240, 224, 0.28); border-radius: 4px; }
.panel-scroll::-webkit-scrollbar-track { background: transparent; }

.group { padding: 9px 0 10px; border-bottom: 1px solid rgba(142, 226, 222, 0.10); }
.group:last-child { border-bottom: 0; }
.group-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.group-title { display: flex; align-items: center; gap: 7px; font-family: var(--display); font-size: 12px; font-weight: 600; letter-spacing: 0.03em; color: var(--ink); }
.group-title::before { content: ""; width: 2px; height: 11px; background: var(--teal); box-shadow: 0 0 8px rgba(127, 240, 224, 0.5); }
.group-tag { font-family: var(--mono); font-size: 7.5px; letter-spacing: 0.16em; color: var(--dim); }

.field { margin-bottom: 8px; }
.field:last-child { margin-bottom: 0; }
.field-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 5px; }
.field-label { font-family: var(--mono); font-size: 9px; letter-spacing: 0.05em; color: var(--muted); white-space: nowrap; }
.field-val { font-family: var(--mono); font-size: 10px; color: var(--ink); white-space: nowrap; }
.field-val em { font-style: normal; color: var(--amber); }
.field-val small { color: var(--dim); font-size: 8px; }

.seg { display: flex; border: 1px solid var(--line); background: rgba(7, 19, 24, 0.55); padding: 2px; gap: 2px; }
.seg button {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 4px 8px;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.03em;
  white-space: nowrap;
  transition: 0.15s ease;
}
.seg button:hover { color: var(--ink); background: rgba(127, 240, 224, 0.06); }
.seg button[aria-pressed="true"] { background: var(--teal-soft); color: var(--teal); box-shadow: inset 0 0 0 1px rgba(127, 240, 224, 0.25); }
.seg.amber button[aria-pressed="true"] { background: var(--amber-soft); color: var(--amber); box-shadow: inset 0 0 0 1px rgba(255, 196, 107, 0.26); }

/* range */
.range-wrap { display: flex; align-items: center; gap: 9px; }
.range { -webkit-appearance: none; appearance: none; width: 100%; height: 18px; background: transparent; --p: 50%; }
.range::-webkit-slider-runnable-track {
  height: 2px;
  background: linear-gradient(90deg, var(--teal) var(--p), rgba(142, 226, 222, 0.16) var(--p));
  border-radius: 2px;
}
.range::-moz-range-track { height: 2px; background: rgba(142, 226, 222, 0.16); }
.range::-moz-range-progress { height: 2px; background: var(--teal); }
.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 11px;
  height: 11px;
  margin-top: -4.5px;
  border-radius: 50%;
  background: #eafffc;
  border: 2px solid var(--teal);
  box-shadow: 0 0 9px rgba(127, 240, 224, 0.55);
}
.range::-moz-range-thumb { width: 9px; height: 9px; border-radius: 50%; background: #eafffc; border: 2px solid var(--teal); }
.range.amber::-webkit-slider-runnable-track { background: linear-gradient(90deg, var(--amber) var(--p), rgba(255, 196, 107, 0.16) var(--p)); }
.range.amber::-webkit-slider-thumb { border-color: var(--amber); box-shadow: 0 0 9px rgba(255, 196, 107, 0.5); }

/* buttons */
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 6px; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
  padding: 8px 9px;
  border: 1px solid var(--line-strong);
  background: rgba(8, 22, 28, 0.7);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.03em;
  transition: 0.16s ease;
  white-space: nowrap;
}
.btn:hover { border-color: var(--teal); background: rgba(127, 240, 224, 0.08); }
.btn.primary { background: linear-gradient(180deg, #ffd488, #ffc064); color: #24170a; border-color: #ffd58b; font-weight: 700; box-shadow: 0 0 18px rgba(255, 196, 107, 0.16); }
.btn.primary:hover { background: #ffd48a; }
.btn.primary b { font-family: var(--mono); font-size: 8px; opacity: 0.65; font-weight: 400; letter-spacing: 0.1em; }
.btn.running { background: linear-gradient(180deg, #ff8c92, #f26670); color: #2a0b0e; border-color: #ffa1a6; }
.btn:disabled { opacity: 0.38; cursor: default; }
.btn .kbd { margin-left: auto; }
.kbd { border: 1px solid rgba(255, 255, 255, 0.22); padding: 1px 4px; font-family: var(--mono); font-size: 7px; color: rgba(255, 255, 255, 0.65); font-weight: 400; }

.link-btn { border: 0; background: transparent; color: var(--muted); font-family: var(--mono); font-size: 8.5px; padding: 3px 0; letter-spacing: 0.04em; }
.link-btn:hover { color: var(--teal); }
.link-btn:disabled { opacity: 0.35; cursor: default; }

/* EUT dropdown */
.eut { position: relative; }
.eut-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 9px;
  border: 1px solid var(--line);
  background: rgba(7, 20, 25, 0.55);
  color: var(--ink);
  text-align: left;
}
.eut-btn:hover { border-color: var(--line-strong); }
.eut-icon { width: 30px; height: 30px; flex: 0 0 30px; display: grid; place-items: center; border: 1px dashed rgba(255, 196, 107, 0.34); color: var(--amber); font-family: var(--display); font-size: 13px; }
.eut-info { min-width: 0; flex: 1; }
.eut-name { font-family: var(--display); font-size: 12.5px; font-weight: 600; letter-spacing: 0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.eut-meta { margin-top: 2px; font-family: var(--mono); font-size: 8px; color: var(--dim); letter-spacing: 0.04em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.eut-caret { color: var(--dim); font-size: 9px; }
.eut-note { margin-top: 6px; padding-left: 8px; border-left: 1px solid rgba(255, 196, 107, 0.28); font-size: 9px; line-height: 1.55; color: #86a6a8; }
.eut-menu {
  position: absolute;
  left: 0; right: 0; top: calc(100% + 4px);
  z-index: 20;
  background: #0c2028;
  border: 1px solid var(--line-strong);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
  display: none;
}
.eut-menu.open { display: block; animation: menuIn 0.14s ease both; }
.eut-menu button { display: flex; width: 100%; align-items: center; gap: 8px; padding: 8px 9px; border: 0; border-bottom: 1px solid rgba(142, 226, 222, 0.08); background: transparent; text-align: left; }
.eut-menu button:hover { background: rgba(127, 240, 224, 0.07); }
.eut-menu .mi { width: 20px; color: var(--amber); font-family: var(--display); font-size: 11px; }
.eut-menu .mn { font-size: 11px; color: var(--ink); }
.eut-menu .mm { font-family: var(--mono); font-size: 7.5px; color: var(--dim); margin-left: auto; }

/* spec line */
.spec-line { display: flex; flex-wrap: wrap; gap: 4px 10px; padding: 6px 0 0; font-family: var(--mono); font-size: 7.5px; letter-spacing: 0.03em; color: var(--dim); }
.spec-line b { font-weight: 400; color: #b0cccd; }

/* verdict */
.verdict {
  margin-top: 1px;
  border: 1px solid rgba(255, 196, 107, 0.26);
  background: linear-gradient(180deg, rgba(255, 196, 107, 0.07), rgba(255, 196, 107, 0.015));
  padding: 9px 10px 8px;
}
.verdict .vtop { display: flex; justify-content: space-between; align-items: center; font-family: var(--mono); font-size: 8px; letter-spacing: 0.1em; color: var(--dim); }
.verdict .vtop b { font-weight: 400; color: var(--amber); }
.v-hero { display: flex; align-items: baseline; gap: 5px; margin: 5px 0 3px; }
.v-num { font-family: var(--mono); font-size: 28px; line-height: 1; font-weight: 500; color: var(--amber); letter-spacing: -0.03em; }
.v-unit { font-family: var(--mono); font-size: 9px; color: var(--dim); }
.v-meta { display: flex; justify-content: space-between; gap: 8px; font-family: var(--mono); font-size: 8px; color: #9db9ba; line-height: 1.5; }
.v-meta b { font-weight: 400; color: var(--ink); }
.v-note { margin-top: 6px; padding-top: 6px; border-top: 1px dashed rgba(255, 196, 107, 0.2); font-size: 8.5px; line-height: 1.5; color: #94b2b3; }
.verdict.pass { border-color: rgba(125, 255, 178, 0.28); background: linear-gradient(180deg, rgba(125, 255, 178, 0.07), rgba(125, 255, 178, 0.012)); }
.verdict.pass .vtop b { color: var(--green); }
.verdict.pass .v-num { color: var(--green); }
.verdict.pass .v-note { border-top-color: rgba(125, 255, 178, 0.2); }
.verdict.fail { border-color: rgba(255, 112, 120, 0.32); background: linear-gradient(180deg, rgba(255, 112, 120, 0.09), rgba(255, 112, 120, 0.015)); }
.verdict.fail .vtop b { color: var(--red); }
.verdict.fail .v-num { color: var(--red); }
.verdict.fail .v-note { border-top-color: rgba(255, 112, 120, 0.24); }
.verdict.idle .v-num { color: var(--dim); }
.verdict.scanning .v-num { color: var(--teal); }

/* peaks / log */
.table { width: 100%; border-collapse: collapse; font-family: var(--mono); }
.table th { padding: 3px 0 4px; font-size: 7.5px; font-weight: 400; letter-spacing: 0.1em; color: var(--dim); text-align: left; border-bottom: 1px solid rgba(142, 226, 222, 0.12); }
.table th:nth-child(2), .table th:nth-child(3) { text-align: right; }
.table td { padding: 4px 0; font-size: 9px; color: #b8d2d2; border-bottom: 1px dashed rgba(142, 226, 222, 0.07); }
.table td:nth-child(2), .table td:nth-child(3) { text-align: right; }
.table td.bad { color: var(--red); }
.table td.good { color: var(--green); }
.table tr:last-child td { border-bottom: 0; }
.empty { padding: 7px 0 3px; font-size: 8.5px; line-height: 1.5; color: var(--dim); }
.log-row { display: grid; grid-template-columns: 26px 1fr 54px; gap: 6px; align-items: center; padding: 4px 0; border-bottom: 1px dashed rgba(142, 226, 222, 0.07); font-family: var(--mono); font-size: 8px; color: #a8c4c5; }
.log-row:last-child { border-bottom: 0; }
.log-row .no { color: var(--dim); }
.log-row .ok { color: var(--green); text-align: right; }
.log-row .bad { color: var(--red); text-align: right; }
.log-row .warn { color: var(--amber); text-align: right; }

/* scope */
.scope { grid-column: 1; grid-row: 2; display: flex; flex-direction: column; background: linear-gradient(180deg, #173743, #112a34); }
.scope-head { flex: 0 0 34px; height: 34px; display: flex; align-items: center; gap: 12px; padding: 0 12px; border-bottom: 1px solid var(--line); }
.scope-title { display: flex; align-items: baseline; gap: 7px; font-family: var(--display); font-size: 12px; font-weight: 600; color: var(--ink); white-space: nowrap; }
.scope-title span { font-family: var(--mono); font-size: 7.5px; letter-spacing: 0.12em; color: var(--dim); }
.scope-state { font-family: var(--mono); font-size: 8px; letter-spacing: 0.1em; color: var(--teal); }
.scope-state.fail { color: var(--red); }
.scope-state.pass { color: var(--green); }
.scope-legend { margin-left: auto; display: flex; align-items: center; gap: 10px; font-family: var(--mono); font-size: 7.5px; color: var(--dim); }
.scope-legend span { display: inline-flex; align-items: center; gap: 5px; }
.scope-legend i { width: 12px; height: 2px; background: var(--teal); }
.scope-legend i.amber { background: var(--amber); }
.scope-legend i.red { background: var(--red); }
.scope-legend i.dash { background: repeating-linear-gradient(90deg, var(--dim) 0 3px, transparent 3px 6px); }
.scope-readout { margin-left: auto; display: flex; align-items: baseline; gap: 8px; font-family: var(--mono); }
.scope-readout b { font-size: 15px; font-weight: 500; color: var(--ink); letter-spacing: 0.02em; }
.scope-readout span { font-size: 9px; color: var(--teal); }
.scope-readout small { font-size: 7.5px; color: var(--dim); }
.scope canvas { flex: 1; min-height: 0; width: 100%; display: block; }
.scope-body { position: relative; flex: 1; min-height: 0; }
.scope-body canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.scope-hint { position: absolute; right: 10px; bottom: 5px; font-family: var(--mono); font-size: 7px; color: rgba(143, 180, 184, 0.6); pointer-events: none; }

/* footer bits */
.fine { font-family: var(--mono); font-size: 7px; line-height: 1.6; color: rgba(143, 180, 184, 0.5); letter-spacing: 0.02em; }

/* toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%) translateY(12px);
  z-index: 80;
  padding: 8px 13px;
  border: 1px solid var(--line-strong);
  background: rgba(8, 23, 29, 0.96);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.03em;
  opacity: 0;
  pointer-events: none;
  transition: 0.22s ease;
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.4);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(3, 10, 14, 0.72);
  backdrop-filter: blur(7px);
  opacity: 0;
  visibility: hidden;
  transition: 0.2s ease;
}
.modal.open { opacity: 1; visibility: visible; }
.modal-card {
  width: min(860px, 100%);
  max-height: 88vh;
  overflow-y: auto;
  background: linear-gradient(180deg, #102730, #0a1a22);
  border: 1px solid var(--line-strong);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.55);
  padding: 24px 28px 22px;
  transform: translateY(10px);
  transition: 0.2s ease;
}
.modal.open .modal-card { transform: none; }
.modal-kicker { font-family: var(--mono); font-size: 8px; letter-spacing: 0.2em; color: var(--teal); }
.modal-title { margin: 7px 0 8px; font-family: var(--display); font-size: 28px; font-weight: 500; }
.modal-lede { margin: 0 0 16px; font-size: 12px; line-height: 1.7; color: #a8c5c6; max-width: 62ch; }
.modal-close { position: absolute; top: 14px; right: 16px; }
.modal h3 { margin: 16px 0 6px; font-family: var(--display); font-size: 12px; color: var(--teal); letter-spacing: 0.04em; }
.modal p { margin: 0 0 8px; font-size: 10.5px; line-height: 1.7; color: #a8c5c6; }
.modal ul { margin: 0 0 10px; padding-left: 16px; }
.modal li { font-size: 10px; line-height: 1.7; color: #a8c5c6; }
.modal .formula { margin: 8px 0 14px; padding: 11px 13px; border: 1px solid var(--line); background: rgba(3, 13, 17, 0.55); font-family: var(--mono); font-size: 10px; line-height: 1.9; color: #cfe7e5; overflow-x: auto; }
.modal .split { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.modal .note { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }
.modal .keys { display: flex; flex-wrap: wrap; gap: 7px 12px; margin-top: 10px; }
.modal .keys span { font-family: var(--mono); font-size: 8px; color: var(--muted); display: inline-flex; align-items: center; gap: 5px; }
.modal .keys kbd { border: 1px solid var(--line-strong); padding: 2px 5px; color: var(--ink); }

/* animations */
@keyframes dotPulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.45; transform: scale(0.82); } }
@keyframes menuIn { from { opacity: 0; transform: translateY(-3px); } to { opacity: 1; transform: none; } }
@keyframes flashPulse { 0%, 100% { opacity: 0.15; } 50% { opacity: 0.55; } }

/* responsive */
@media (max-width: 1240px) {
  .workspace { grid-template-columns: minmax(0, 1fr) 344px; }
  .top-meta .chip:nth-child(2) { display: none; }
  .stage-title { font-size: 27px; }
}
@media (max-width: 1100px) {
  .workspace { grid-template-columns: minmax(0, 1fr) 320px; grid-template-rows: minmax(0, 1fr) 236px; }
  .brand-sub { display: none; }
  .top-meta .chip:first-child { display: none; }
  .stage-tl { max-width: 70%; }
}
@media (max-width: 960px) {
  body { overflow: auto; }
  .app { height: auto; min-height: 100%; }
  .topbar { position: sticky; top: 0; z-index: 40; }
  .workspace {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 10px;
  }
  .stage { flex: 0 0 auto; height: 52vh; min-height: 330px; }
  .scope { flex: 0 0 250px; height: 250px; order: 2; }
  .panel { flex: 0 0 auto; order: 3; }
  .panel-scroll { overflow: visible; }
  .panel-head { position: static; }
  .stage-tl { left: 16px; top: 14px; }
  .stage-title { font-size: 26px; }
  .stage-br { display: none; }
  .stage-badge { display: none; }
  .scope-legend { display: none; }
}
@media (max-width: 700px) {
  .topbar { gap: 8px; padding: 0 10px; height: 50px; flex-basis: 50px; }
  .lab-back { padding: 0 7px; font-size: 9px; }
  .lab-back b { display: none; }
  .brand-mark { width: 22px; height: 22px; flex-basis: 22px; }
  .brand-name { font-size: 16px; letter-spacing: 0.07em; }
  .top-meta { display: none; }
  .clock { font-size: 11px; }
  .workspace { padding: 8px; gap: 8px; }
  .stage { height: 46vh; min-height: 300px; }
  .stage-tl { left: 13px; top: 11px; max-width: 100%; }
  .stage-title { font-size: 22px; }
  .stage-sub { font-size: 7.5px; line-height: 1.5; max-width: 92%; }
  .stage-bl .hint { display: none; }
  .stage-tr { right: 12px; top: auto; bottom: 12px; flex-direction: row; align-items: center; }
  .stage-tr .legend { display: none; }
  .stage-br { display: none; }
  .panel-scroll { padding: 0 11px 10px; }
  .scope { height: 228px; flex-basis: 228px; }
  .scope-head { gap: 7px; padding: 0 9px; }
  .scope-title { font-size: 11px; }
  .scope-readout b { font-size: 12px; }
  .scope-readout small { display: none; }
  .modal-card { padding: 20px 18px 18px; }
  .modal-title { font-size: 23px; }
  .modal .split { grid-template-columns: 1fr; }
}
@media (max-height: 760px) and (min-width: 961px) {
  .workspace { grid-template-rows: minmax(0, 1fr) 228px; }
  .stage-title { font-size: 26px; }
}
