/* ==========================================================================
   Elektr zanjiri laboratoriyasi
   Butun oynani egallaydigan ish joyi: yuqorida boshqaruv, chapda
   jihozlar, markazda laboratoriya stoli, o'ngda o'lchashlar, pastda holat.
   ========================================================================== */

.lab {
  --lab-bg: #e9edf2;
  --lab-surface: #ffffff;
  --lab-surface-2: #f5f7fa;
  --lab-border: #dce2ea;
  --lab-text: #15202b;
  --lab-muted: #5b6878;
  --lab-faint: #8a96a6;
  --lab-accent: #1d64d8;
  --lab-accent-ink: #164fb0;
  --lab-accent-soft: #e5eeff;
  --lab-success: #0f9f5b;
  --lab-success-soft: #e3f7ec;
  --lab-danger: #d92d20;
  --lab-danger-soft: #fdeceb;
  --lab-warning: #c97a06;
  --lab-warning-soft: #fff4e0;
  --lab-table: #dfe6df;
  --lab-grid-minor: rgba(34, 68, 48, .08);
  --lab-grid-major: rgba(34, 68, 48, .17);
  --lab-shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 14px rgba(16, 24, 40, .06);
  --lab-radius: 12px;
  --lab-font: "Montserrat", system-ui, -apple-system, "Segoe UI", sans-serif;
  --lab-mono: ui-monospace, "Cascadia Mono", "Consolas", monospace;

  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  /* Ustun ekran kengligidan oshmasin — uzun panel sahifani kengaytirmasin */
  grid-template-columns: minmax(0, 1fr);
  background: var(--lab-bg);
  color: var(--lab-text);
  font-family: var(--lab-font);
  font-size: 14px;
  line-height: 1.45;
  overflow: hidden;
}

[data-bs-theme="dark"] .lab {
  --lab-bg: #0d1218;
  --lab-surface: #151c25;
  --lab-surface-2: #1b2430;
  --lab-border: #283341;
  --lab-text: #e7edf5;
  --lab-muted: #9aa7b8;
  --lab-faint: #6f7c8d;
  --lab-accent: #4b8bf5;
  --lab-accent-ink: #8db5ff;
  --lab-accent-soft: #1b2b47;
  --lab-success: #32d583;
  --lab-success-soft: #10301f;
  --lab-danger: #f97066;
  --lab-danger-soft: #3a1714;
  --lab-warning: #fdb022;
  --lab-warning-soft: #36270b;
  --lab-table: #17241d;
  --lab-grid-minor: rgba(255, 255, 255, .045);
  --lab-grid-major: rgba(255, 255, 255, .09);
  --lab-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .25);
}

.lab *, .lab *::before, .lab *::after { box-sizing: border-box; }
.lab button { font-family: inherit; }
.lab [hidden] { display: none !important; }
.lab kbd {
  font-family: var(--lab-mono); font-size: .8em; padding: 1px 6px; border-radius: 5px;
  background: var(--lab-surface-2); border: 1px solid var(--lab-border); color: var(--lab-text);
}

/* ------------------------------------------------------------ Tugmalar */
.lab-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 36px; padding: 7px 14px; border-radius: 9px;
  border: 1px solid var(--lab-border); background: var(--lab-surface); color: var(--lab-text);
  font-weight: 700; font-size: .86rem; cursor: pointer; text-decoration: none;
  transition: background .15s, border-color .15s, box-shadow .15s;
}
.lab-btn:hover:not(:disabled) { border-color: var(--lab-accent); color: var(--lab-accent-ink); }
.lab-btn:focus-visible, .tb-btn:focus-visible, .tb-icon:focus-visible, .tb-pill:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--lab-accent) 45%, transparent); outline-offset: 2px;
}
.lab-btn:disabled { opacity: .5; cursor: not-allowed; }
.lab-btn--primary { background: var(--lab-accent); border-color: var(--lab-accent); color: #fff; }
.lab-btn--primary:hover:not(:disabled) { background: var(--lab-accent-ink); color: #fff; }
.lab-btn--danger { color: var(--lab-danger); }
.lab-btn--danger:hover:not(:disabled) { border-color: var(--lab-danger); color: var(--lab-danger); background: var(--lab-danger-soft); }
.lab-btn--success { background: var(--lab-success-soft); border-color: var(--lab-success); color: var(--lab-success); }
.lab-btn--ghost { background: transparent; border-color: transparent; color: var(--lab-muted); }
.lab-btn--sm { min-height: 30px; padding: 4px 10px; font-size: .8rem; }
.lab-btn--lg { min-height: 50px; padding: 12px 26px; font-size: 1.05rem; border-radius: 12px; }
.lab-btn--wide { width: 100%; margin-top: 10px; }
.link-btn {
  background: none; border: 0; padding: 0; color: var(--lab-accent-ink); font-weight: 700;
  font-size: .82rem; cursor: pointer; display: inline-flex; gap: 6px; align-items: center;
}
.icon-btn-sm {
  width: 26px; height: 26px; border: 0; border-radius: 6px; background: transparent;
  color: var(--lab-faint); cursor: pointer;
}
.icon-btn-sm:hover { background: var(--lab-danger-soft); color: var(--lab-danger); }

/* ------------------------------------------------------------ Yuqori panel */
.lab-top {
  background: var(--lab-surface);
  border-bottom: 1px solid var(--lab-border);
  box-shadow: var(--lab-shadow);
  position: relative; z-index: 5;
}
.lab-bar, .lab-controls {
  display: flex; align-items: center; gap: 10px; padding: 8px 14px;
}
.lab-controls {
  border-top: 1px solid var(--lab-border); background: var(--lab-surface-2); padding-block: 6px;
}
.lab-exit {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 9px;
  color: var(--lab-text); text-decoration: none; font-weight: 700; font-size: .86rem;
  border: 1px solid var(--lab-border); white-space: nowrap;
}
.lab-exit:hover { background: var(--lab-surface-2); color: var(--lab-accent-ink); }
.lab-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.lab-brand__icon {
  width: 38px; height: 38px; border-radius: 11px; flex: 0 0 auto; display: grid; place-items: center;
  background: linear-gradient(135deg, #f7b500, #f05a28); color: #fff; font-size: 1.05rem;
}
.lab-brand__text { display: flex; flex-direction: column; min-width: 0; }
.lab-brand strong { font-size: .98rem; font-weight: 800; white-space: nowrap; }
.lab-brand small { color: var(--lab-muted); font-size: .74rem; white-space: nowrap; }
.lab-experiment { display: flex; align-items: center; gap: 8px; margin: 0 0 0 8px; min-width: 0; flex: 0 1 auto; }
.lab-experiment__label { font-size: .8rem; font-weight: 700; color: var(--lab-muted); }
.lab-experiment select {
  min-height: 38px; padding: 6px 34px 6px 12px; border-radius: 9px; max-width: 320px; min-width: 0; width: 100%;
  border: 1px solid var(--lab-border); background-color: var(--lab-surface-2); color: var(--lab-text);
  font-weight: 700; font-family: inherit; font-size: .88rem;
}
.tb-group { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.tb-group + .tb-group { padding-left: 10px; border-left: 1px solid var(--lab-border); }
.tb-group--end { margin-left: auto; }
.lab-bar .tb-group--end { border-left: 0; }

.tb-btn, .tb-pill, .tb-icon {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 36px; border-radius: 9px; border: 1px solid transparent; background: transparent;
  color: var(--lab-text); font-weight: 700; font-size: .84rem; cursor: pointer; white-space: nowrap;
  transition: background .15s, color .15s, border-color .15s;
}
.tb-btn { padding: 6px 12px; border-color: var(--lab-border); background: var(--lab-surface); }
.tb-btn:hover:not(:disabled), .tb-icon:hover:not(:disabled), .tb-pill:hover { background: var(--lab-accent-soft); color: var(--lab-accent-ink); }
.tb-btn i { font-size: .95em; }
.tb-btn--start.is-active { background: var(--lab-success); border-color: var(--lab-success); color: #fff; }
.tb-btn--stop.is-active { background: var(--lab-warning); border-color: var(--lab-warning); color: #fff; }
.tb-btn--accent { background: var(--lab-accent); border-color: var(--lab-accent); color: #fff; }
.tb-btn--accent:hover:not(:disabled) { background: var(--lab-accent-ink) !important; color: #fff !important; }
.tb-icon { width: 36px; padding: 0; color: var(--lab-muted); }
.tb-icon:disabled { opacity: .35; cursor: default; }
.tb-icon.is-on { color: var(--lab-accent); }
.tb-icon[data-pref="sound"]:not(.is-on) i::before { content: "\f6a9"; }
.tb-pill { padding: 6px 12px; border-color: var(--lab-border); color: var(--lab-muted); }
.tb-pill.is-on { background: var(--lab-accent-soft); border-color: var(--lab-accent); color: var(--lab-accent-ink); }
.tb-pill--teacher.is-on { background: #fef0c7; border-color: #f79009; color: #93370d; }
.tb-pill--fs { background: var(--lab-text); border-color: var(--lab-text); color: var(--lab-surface); }
.tb-pill--fs:hover { background: var(--lab-accent) !important; color: #fff !important; }
.tb-drawer { display: none; }

/* ------------------------------------------------------------ Ish maydoni */
.lab-body {
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr) 372px;
  min-height: 0;
}

/* ------------------------------------------------------------ Jihozlar */
.lab-palette {
  background: var(--lab-surface); border-right: 1px solid var(--lab-border);
  overflow-y: auto; min-height: 0; padding: 12px 12px 24px;
}
.pal-head { position: sticky; top: -12px; background: var(--lab-surface); padding: 2px 0 10px; z-index: 1; }
.pal-heading { font-size: .78rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--lab-muted); margin: 0 0 8px; }
.pal-search {
  width: 100%; min-height: 34px; border-radius: 8px; border: 1px solid var(--lab-border);
  background: var(--lab-surface-2); color: var(--lab-text); padding: 5px 10px; font-family: inherit; font-size: .84rem;
}
.pal-group { margin-top: 10px; }
.pal-title { font-size: .72rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--lab-faint); margin: 6px 2px 6px; }
.pal-list { display: grid; gap: 5px; }
.pal-item {
  display: grid; grid-template-columns: 50px 1fr 34px; align-items: center; gap: 8px;
  width: 100%; padding: 5px 8px 5px 5px; border-radius: 10px; text-align: left;
  border: 1px solid var(--lab-border); background: var(--lab-surface-2); color: var(--lab-text);
  cursor: grab; touch-action: none; user-select: none;
}
.pal-item:hover { border-color: var(--lab-accent); background: var(--lab-accent-soft); }
.pal-item:active { cursor: grabbing; }
.pal-thumb { width: 50px; height: 40px; display: grid; place-items: center; background: var(--lab-table); border-radius: 7px; }
.pal-thumb svg { width: 46px; height: 36px; }
.pal-name { font-size: .8rem; font-weight: 700; line-height: 1.2; }
.pal-symbol { width: 34px; height: 24px; color: var(--lab-muted); }
.pal-note { font-size: .74rem; color: var(--lab-muted); margin: 6px 2px; }
.pal-note--tip { color: var(--lab-accent-ink); }
.pal-colors { display: flex; gap: 8px; margin: 4px 2px 8px; }
.pal-color {
  width: 30px; height: 30px; border-radius: 50%; border: 3px solid var(--lab-surface);
  background: var(--wire); box-shadow: 0 0 0 1px var(--lab-border); cursor: pointer;
}
.pal-color.is-active { box-shadow: 0 0 0 3px var(--lab-accent); }
.pal-lengths { display: flex; gap: 6px; }
.pal-length {
  flex: 1; min-height: 32px; border-radius: 8px; border: 1px dashed var(--lab-border);
  background: var(--lab-surface-2); color: var(--lab-text); font-weight: 700; font-size: .8rem; cursor: pointer;
}
.pal-length:hover { border-color: var(--lab-accent); color: var(--lab-accent-ink); }
.pal-ghost {
  position: fixed; z-index: 1000; pointer-events: none; width: 120px; height: 96px;
  transform: translate(-50%, -50%) scale(.9); opacity: .75; filter: drop-shadow(0 8px 16px rgba(0, 0, 0, .3));
}
.pal-ghost.is-over { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.pal-ghost svg { width: 100%; height: 100%; }
body.is-dragging-part, body.is-dragging-part * { cursor: grabbing !important; }

/* ------------------------------------------------------------ Stol */
.lab-stage { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: var(--lab-table); }
.stage-svg { display: block; width: 100%; height: 100%; touch-action: none; user-select: none; outline: none; cursor: default; }
.stage-table { fill: var(--lab-table); }
.grid-minor { stroke: var(--lab-grid-minor); stroke-width: 1; }
.grid-major { stroke: var(--lab-grid-major); stroke-width: 1.2; }
.stage-svg.is-wiring { cursor: crosshair; }

.part { cursor: grab; }
.part:active { cursor: grabbing; }
.part.is-locked { cursor: default; }
.part-select { fill: none; stroke: none; }
.part.is-selected .part-select { stroke: var(--lab-accent); stroke-width: 2; stroke-dasharray: 7 5; fill: color-mix(in srgb, var(--lab-accent) 7%, transparent); }
.part.is-flagged .part-select { stroke: var(--lab-danger); stroke-width: 3; stroke-dasharray: none; fill: color-mix(in srgb, var(--lab-danger) 10%, transparent); }
.part.is-locked .part-art { opacity: .97; }
.part.is-symbol { color: var(--lab-text); }
.part-tag { font-size: 12px; font-weight: 700; fill: var(--lab-muted); font-family: var(--lab-font); }
.part [data-action] { cursor: pointer; }
.part [data-action="slider"] { cursor: ew-resize; }
.art-label, .art-sign, .art-scale, .art-letter { font-family: var(--lab-font); pointer-events: none; }
.art-sign { font-weight: 800; }
.art-lcd { font-family: var(--lab-mono); font-weight: 700; pointer-events: none; }
.sym-text { font-family: var(--lab-font); pointer-events: none; }
.art-waves { opacity: 0; }
.art-waves.is-active { animation: buzz .45s ease-in-out infinite; }
@keyframes buzz { 0%, 100% { opacity: .15; } 50% { opacity: 1; } }

.term { cursor: crosshair; }
.term-hit { fill: transparent; }
.term-dot { fill: none; stroke: transparent; stroke-width: 2; pointer-events: none; }
.part.is-symbol .term-dot { stroke: currentColor; fill: var(--lab-table); }
.term:hover .term-dot, .stage-svg.is-wiring .term-dot { stroke: var(--lab-accent); fill: color-mix(in srgb, var(--lab-accent) 25%, transparent); }
.term.is-candidate .term-dot { stroke: var(--lab-success); stroke-width: 3; fill: color-mix(in srgb, var(--lab-success) 35%, transparent); r: 8px; }
.badge-error { fill: var(--lab-danger); stroke: #fff; stroke-width: 2; }
.badge-warning { fill: #f79009; stroke: #fff; stroke-width: 2; }
.badge-text { fill: #fff; font-weight: 900; font-size: 14px; font-family: var(--lab-font); pointer-events: none; }

.wire { cursor: pointer; }
.wire-hit { stroke: transparent; stroke-width: 16; fill: none; }
.wire-body { stroke-width: 5.5; fill: none; stroke-linecap: round; }
.wire-shine { stroke: rgba(255, 255, 255, .35); stroke-width: 1.4; fill: none; stroke-linecap: round; pointer-events: none; transform: translate(-1px, -1.4px); }
.wire-flow { stroke: #fff7c2; stroke-width: 2.6; stroke-dasharray: 2.5 13; stroke-linecap: round; fill: none; opacity: 0; pointer-events: none; }
.wire.is-live .wire-flow { opacity: .95; }
.wire.is-live .wire-body { filter: drop-shadow(0 0 3px rgba(255, 214, 90, .55)); }
.wire.is-selected .wire-body { filter: drop-shadow(0 0 4px var(--lab-accent)); stroke-width: 6.5; }
.wire.is-flagged .wire-body, .wire.is-short .wire-body { filter: drop-shadow(0 0 6px #ff2d2d); }
.wire.is-short .wire-body { animation: short-pulse .6s ease-in-out infinite; }
@keyframes short-pulse { 50% { stroke: #ff3b30; } }
.wire-plug { stroke: rgba(0, 0, 0, .35); stroke-width: 1; pointer-events: none; }
.wire-end-free { cursor: grab; }
.wire-end-halo { fill: color-mix(in srgb, var(--lab-accent) 18%, transparent); stroke: var(--lab-accent); stroke-dasharray: 3 3; }
.wire-end-tip { stroke: #fff; stroke-width: 1.5; }
.wire-handle { fill: var(--lab-surface); stroke: var(--lab-accent); stroke-width: 2.5; cursor: grab; }
.wire-handle--bend { fill: var(--lab-accent); stroke: #fff; }
.wire-temp { stroke-width: 5; fill: none; stroke-linecap: round; stroke-dasharray: 10 6; opacity: .85; pointer-events: none; }
.wire-temp.is-snapped { stroke-dasharray: none; opacity: 1; }

.stage-tools {
  position: absolute; right: 14px; bottom: 14px; display: flex; flex-direction: column; gap: 6px; z-index: 2;
}
.stage-tools button {
  width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--lab-border);
  background: var(--lab-surface); color: var(--lab-text); box-shadow: var(--lab-shadow); cursor: pointer;
}
.stage-tools button:hover { color: var(--lab-accent-ink); border-color: var(--lab-accent); }
.stage-legend {
  position: absolute; left: 14px; bottom: 10px; margin: 0; z-index: 2; pointer-events: none;
  font-size: .74rem; color: var(--lab-muted); background: color-mix(in srgb, var(--lab-surface) 80%, transparent);
  padding: 4px 10px; border-radius: 999px;
}
.stage-legend i { color: #e8a200; }
.stage-banner {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%); z-index: 3;
  padding: 10px 20px; border-radius: 999px; font-weight: 800; font-size: 1rem; box-shadow: var(--lab-shadow);
  display: flex; gap: 8px; align-items: center; pointer-events: none; white-space: nowrap;
}
.stage-banner--danger { background: var(--lab-danger); color: #fff; animation: banner-pulse 1s ease-in-out infinite; }
.stage-banner--muted { background: var(--lab-surface); color: var(--lab-muted); border: 1px solid var(--lab-border); font-size: .86rem; }
@keyframes banner-pulse { 50% { box-shadow: 0 0 0 8px rgba(217, 45, 32, .25); } }
.lab-stage.is-short::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 1;
  box-shadow: inset 0 0 0 4px rgba(217, 45, 32, .8), inset 0 0 80px rgba(217, 45, 32, .35);
  animation: fade-pulse 1s ease-in-out infinite;
}
@keyframes fade-pulse { 50% { opacity: .55; } }
.stage-empty {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 1;
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; pointer-events: none;
  max-width: 360px; padding: 26px 28px; border-radius: 16px; color: var(--lab-muted);
  background: color-mix(in srgb, var(--lab-surface) 88%, transparent); border: 2px dashed var(--lab-border);
}
.stage-empty i { font-size: 2rem; color: var(--lab-accent); }
.stage-empty strong { color: var(--lab-text); font-size: 1.05rem; }
.stage-chip {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%); z-index: 3;
  background: var(--lab-accent); color: #fff; padding: 7px 16px; border-radius: 999px; font-weight: 700; font-size: .84rem;
  pointer-events: none;
}

/* ------------------------------------------------------------ O'ng panel */
.lab-side {
  background: var(--lab-bg); border-left: 1px solid var(--lab-border);
  overflow-y: auto; min-height: 0; padding: 10px; display: flex; flex-direction: column; gap: 10px;
}
.side-card {
  background: var(--lab-surface); border: 1px solid var(--lab-border); border-radius: var(--lab-radius);
  box-shadow: var(--lab-shadow); padding: 12px 14px;
}
.panel-title {
  display: flex; align-items: center; gap: 8px; margin: 0 0 8px;
  font-size: .76rem; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; color: var(--lab-muted);
}
.panel-title i { color: var(--lab-accent); }

.ro-context { margin: 0 0 8px; font-size: .78rem; color: var(--lab-muted); min-height: 1.1em; }
.ro-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ro-cell {
  border-radius: 10px; padding: 8px 10px; background: var(--lab-surface-2); border: 1px solid var(--lab-border);
  border-left: 4px solid var(--ro-color);
}
.ro-cell--U { --ro-color: #1d64d8; }
.ro-cell--I { --ro-color: #d92d20; }
.ro-cell--R { --ro-color: #7c3aed; }
.ro-cell--P { --ro-color: #0f9f5b; }
.ro-label { display: block; font-size: .72rem; font-weight: 700; color: var(--lab-muted); }
.ro-label b { color: var(--ro-color); font-size: .9rem; }
.ro-value { display: block; font-family: var(--lab-mono); font-size: 1.45rem; font-weight: 800; letter-spacing: -.02em; white-space: nowrap; }
.ro-check { margin: 8px 0 0; font-size: .78rem; color: var(--lab-muted); }
.ro-check b { color: var(--lab-text); }

.insp-head { display: grid; grid-template-columns: 64px 1fr; gap: 10px; align-items: start; margin-bottom: 8px; }
.insp-symbol { width: 64px; height: 50px; border-radius: 9px; background: var(--lab-surface-2); display: grid; place-items: center; color: var(--lab-text); }
.insp-symbol svg { width: 58px; height: 44px; }
.insp-symbol--wire { font-size: 1.4rem; color: #d62828; }
.insp-title { margin: 0; font-size: 1rem; font-weight: 800; }
.insp-desc { margin: 2px 0 0; font-size: .78rem; color: var(--lab-muted); }
.insp-body { display: flex; flex-direction: column; gap: 10px; }
.insp-field { display: flex; flex-direction: column; gap: 5px; margin: 0; font-size: .8rem; font-weight: 700; }
.insp-field > span { color: var(--lab-muted); }
.insp-input {
  min-height: 36px; border-radius: 8px; border: 1px solid var(--lab-border); background: var(--lab-surface-2);
  color: var(--lab-text); padding: 5px 10px; font-family: inherit; font-size: .9rem; font-weight: 600; width: 100%;
}
.insp-input.is-invalid { border-color: var(--lab-danger); }
.insp-input--sm { max-width: 140px; }
.insp-range { width: 100%; accent-color: var(--lab-accent); }
.insp-output, .ohm-output { font-family: var(--lab-mono); color: var(--lab-text); font-weight: 800; }
.insp-toggle { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--lab-surface-2); border: 1px solid var(--lab-border); align-self: flex-start; }
.insp-seg { border: 0; background: transparent; padding: 6px 14px; border-radius: 7px; font-weight: 800; font-size: .78rem; color: var(--lab-muted); cursor: pointer; }
.insp-seg.is-active { background: var(--lab-accent); color: #fff; }
.insp-seg:disabled { cursor: not-allowed; opacity: .6; }
.insp-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.insp-chip {
  border: 1px solid var(--lab-border); background: var(--lab-surface-2); color: var(--lab-text);
  border-radius: 999px; padding: 4px 10px; font-size: .78rem; font-weight: 700; cursor: pointer;
}
.insp-chip.is-active { background: var(--lab-accent); border-color: var(--lab-accent); color: #fff; }
.insp-chip--color::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--wire); margin-right: 5px; }
.insp-custom { display: flex; gap: 6px; }
.insp-error { color: var(--lab-danger); font-size: .74rem; }
.insp-values { display: grid; grid-template-columns: auto 1fr auto 1fr; gap: 3px 8px; margin: 0; font-size: .84rem; }
.insp-values dt { font-weight: 800; color: var(--lab-muted); }
.insp-values dd { margin: 0; font-family: var(--lab-mono); font-weight: 700; }
.insp-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.insp-note { margin: 0; font-size: .8rem; color: var(--lab-muted); }
.insp-locked, .insp-fault {
  margin: 0; padding: 8px 10px; border-radius: 9px; font-size: .8rem; font-weight: 600;
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between;
}
.insp-locked { background: var(--lab-warning-soft); color: var(--lab-warning); }
.insp-fault { background: var(--lab-danger-soft); color: var(--lab-danger); }
.insp-empty p { margin: 0 0 8px; font-size: .84rem; color: var(--lab-muted); }
.insp-keys { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px; font-size: .76rem; color: var(--lab-muted); }

.side-card--tabs { padding: 0; }
.side-tabs { display: flex; border-bottom: 1px solid var(--lab-border); padding: 6px 4px 0; gap: 0; overflow-x: auto; scrollbar-width: none; }
.side-tabs::-webkit-scrollbar { display: none; }
.side-tab {
  flex: 1 1 auto; position: relative; border: 0; background: transparent; padding: 9px 5px; font-weight: 800; font-size: .76rem;
  color: var(--lab-muted); border-bottom: 3px solid transparent; cursor: pointer; white-space: nowrap;
}
.side-tab.is-active { color: var(--lab-accent-ink); border-bottom-color: var(--lab-accent); }
.tab-dot { position: absolute; top: 7px; right: 3px; width: 7px; height: 7px; border-radius: 50%; background: #f79009; }
.side-panel { padding: 12px 14px 16px; }
.side-subtitle { margin: 14px 0 6px; font-size: .74rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--lab-muted); }

.exp-title { font-size: 1.02rem; font-weight: 800; margin: 0 0 6px; }
.exp-goal, .exp-desc { font-size: .82rem; margin: 0 0 8px; color: var(--lab-muted); }
.exp-goal b { color: var(--lab-text); }
.progress { position: relative; height: 22px; border-radius: 999px; background: var(--lab-surface-2); border: 1px solid var(--lab-border); overflow: hidden; margin: 8px 0; }
.progress span { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, #12b76a, #32d583); transition: width .4s; }
.progress em { position: relative; display: block; text-align: center; font-style: normal; font-size: .74rem; font-weight: 800; line-height: 20px; }
.steps { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.step { display: grid; grid-template-columns: 26px 1fr; gap: 8px; align-items: start; font-size: .82rem; }
.step-mark {
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: .74rem;
  background: var(--lab-surface-2); border: 1px solid var(--lab-border); color: var(--lab-muted);
}
.step.is-done .step-mark { background: var(--lab-success); border-color: var(--lab-success); color: #fff; }
.step.is-done > span:last-child { color: var(--lab-muted); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--lab-muted) 50%, transparent); }
.done-card, .pending-card {
  margin: 10px 0; padding: 10px 12px; border-radius: 10px; font-size: .84rem; display: flex; flex-direction: column; gap: 4px;
}
.done-card { background: var(--lab-success-soft); color: var(--lab-success); border: 1px solid color-mix(in srgb, var(--lab-success) 40%, transparent); }
.done-card span { color: var(--lab-text); }
.pending-card { background: var(--lab-surface-2); color: var(--lab-muted); }

.lab-table { width: 100%; border-collapse: collapse; font-size: .8rem; }
.lab-table th { text-align: left; font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; color: var(--lab-muted); padding: 6px 6px; border-bottom: 1px solid var(--lab-border); white-space: nowrap; }
.lab-table td { padding: 5px 6px; border-bottom: 1px solid var(--lab-border); font-family: var(--lab-mono); white-space: nowrap; }
.lab-table td:first-child { font-family: var(--lab-font); font-weight: 600; white-space: normal; }
.ohm-table-wrap { overflow-x: auto; margin-top: 6px; }
.calc { display: grid; gap: 4px; margin-top: 10px; font-size: .82rem; }
.calc p { margin: 0; }
.calc-group + .calc-group { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--lab-border); }
.calc-ok { color: var(--lab-success); font-weight: 800; }
.calc-note { font-size: .78rem; color: var(--lab-muted); margin: 6px 0; }

.ohm-controls { display: grid; gap: 10px; }
.ohm-live { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 10px; }
.ohm-live div { background: var(--lab-surface-2); border-radius: 9px; padding: 6px 8px; border: 1px solid var(--lab-border); }
.ohm-live span { display: block; font-size: .7rem; color: var(--lab-muted); font-weight: 700; }
.ohm-live b { font-family: var(--lab-mono); font-size: .95rem; }
.ohm-conclusion { font-size: .8rem; background: var(--lab-accent-soft); color: var(--lab-text); padding: 8px 10px; border-radius: 9px; }
.seg { display: flex; gap: 4px; padding: 3px; background: var(--lab-surface-2); border-radius: 10px; border: 1px solid var(--lab-border); }
.seg-btn { flex: 1; border: 0; background: transparent; padding: 6px 8px; font-size: .74rem; font-weight: 800; border-radius: 7px; color: var(--lab-muted); cursor: pointer; }
.seg-btn.is-active { background: var(--lab-surface); color: var(--lab-accent-ink); box-shadow: var(--lab-shadow); }
.chart-box { margin-top: 8px; }
.chart { width: 100%; height: auto; display: block; }
.chart-grid { stroke: var(--lab-border); stroke-width: 1; }
.chart-axis { stroke: var(--lab-muted); stroke-width: 1.4; }
.chart-tick { font-size: 9px; fill: var(--lab-muted); font-family: var(--lab-mono); }
.chart-label { font-size: 10px; font-weight: 800; fill: var(--lab-text); font-family: var(--lab-font); }
.chart-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: .74rem; margin-top: 4px; }
.chart-key { display: inline-flex; align-items: center; gap: 5px; }
.chart-key i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.chart-empty { padding: 26px 12px; text-align: center; color: var(--lab-muted); font-size: .8rem; border: 1px dashed var(--lab-border); border-radius: 10px; }

.task-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.task-item {
  width: 100%; display: grid; grid-template-columns: 30px 1fr; gap: 10px; align-items: start; text-align: left;
  padding: 8px 10px; border-radius: 10px; border: 1px solid var(--lab-border); background: var(--lab-surface-2);
  color: var(--lab-text); cursor: pointer; font-size: .82rem;
}
.task-item:hover { border-color: var(--lab-accent); }
.task-item small { display: block; color: var(--lab-muted); font-size: .76rem; margin-top: 2px; }
.task-num { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--lab-accent-soft); color: var(--lab-accent-ink); font-weight: 800; }
.task-item.is-done .task-num { background: var(--lab-success); color: #fff; }
.req-list { list-style: none; padding: 0; margin: 0 0 8px; display: grid; gap: 3px; font-size: .82rem; }
.req-list li { color: var(--lab-muted); }
.req-list li.is-ok { color: var(--lab-success); font-weight: 700; }
.task-steps { padding-left: 18px; margin: 0; font-size: .82rem; display: grid; gap: 4px; }
.task-condition { font-size: .8rem; margin: 10px 0; padding: 8px 10px; border-radius: 9px; background: var(--lab-surface-2); }
.hints { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 6px; }
.hint { display: grid; grid-template-columns: 18px 1fr; gap: 6px; font-size: .8rem; background: var(--lab-warning-soft); border-radius: 9px; padding: 7px 9px; }
.hint i { color: var(--lab-warning); margin-top: 2px; }

.formula-block { border: 1px solid var(--lab-border); border-radius: 10px; margin-bottom: 8px; background: var(--lab-surface-2); }
.formula-block summary { cursor: pointer; padding: 8px 12px; font-weight: 800; font-size: .86rem; }
.formula-block dl { margin: 0; padding: 0 12px 6px; display: grid; gap: 2px 12px; }
.formula-block dt { font-family: "Cambria Math", "Times New Roman", serif; font-size: 1.2rem; font-weight: 600; color: var(--lab-accent-ink); margin-top: 6px; }
.formula-block dd { margin: 0; font-size: .76rem; color: var(--lab-muted); }
.formula-note { margin: 0; padding: 0 12px 10px; font-size: .74rem; color: var(--lab-muted); }
.frac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; font-size: .82em; line-height: 1.1; margin: 0 2px; }
.frac span:first-child { border-bottom: 1.5px solid currentColor; padding: 0 3px; }

/* ------------------------------------------------------------ Holat paneli */
.lab-status {
  display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: start;
  background: var(--lab-surface); border-top: 1px solid var(--lab-border); padding: 8px 14px;
  max-height: 128px; overflow: hidden;
}
.lab-status.is-expanded { max-height: 40vh; overflow-y: auto; }
.st-side { display: flex; flex-direction: column; gap: 4px; min-width: 190px; }
.st-pill { display: inline-flex; align-items: center; gap: 6px; font-weight: 800; font-size: .8rem; padding: 5px 12px; border-radius: 999px; align-self: flex-start; }
.st-pill--running { background: var(--lab-success-soft); color: var(--lab-success); }
.st-pill--stopped { background: var(--lab-surface-2); color: var(--lab-muted); }
.st-pill--short { background: var(--lab-danger); color: #fff; animation: banner-pulse 1s infinite; }
.st-counts { font-size: .74rem; color: var(--lab-faint); }
.st-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.st-msg { display: grid; grid-template-columns: 18px 1fr; gap: 8px; font-size: .82rem; padding: 5px 10px; border-radius: 8px; cursor: default; }
.st-msg i { margin-top: 3px; }
.st-msg b { margin-right: 4px; }
.st-msg--danger { background: var(--lab-danger); color: #fff; }
.st-msg--error { background: var(--lab-danger-soft); color: var(--lab-text); }
.st-msg--error i { color: var(--lab-danger); }
.st-msg--error b { color: var(--lab-danger); }
.st-msg--warning { background: var(--lab-warning-soft); }
.st-msg--warning i, .st-msg--warning b { color: var(--lab-warning); }
.st-msg--info { background: var(--lab-surface-2); }
.st-msg--info i { color: var(--lab-accent); }
.st-msg--hint { background: color-mix(in srgb, #f7b500 12%, var(--lab-surface)); }
.st-msg--hint i { color: #c98900; }
.st-msg--ok { color: var(--lab-success); }
.st-toggle { border: 1px solid var(--lab-border); background: var(--lab-surface-2); color: var(--lab-text); border-radius: 8px; padding: 5px 10px; font-weight: 700; font-size: .78rem; cursor: pointer; white-space: nowrap; }

/* ------------------------------------------------------------ Maslahat oynasi */
.lab-tip {
  position: fixed; z-index: 1100; max-width: 290px; pointer-events: none;
  background: #101828; color: #f2f4f7; border-radius: 10px; padding: 9px 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .3); font-size: .8rem; display: flex; flex-direction: column; gap: 3px;
}
.lab-tip strong { font-size: .86rem; }
.lab-tip span { color: #d0d5dd; }
.lab-tip .tip-value { color: #7df9a6; font-family: var(--lab-mono); font-weight: 700; }
.lab-tip .tip-hint { color: #fec84b; font-weight: 700; }
.lab-tip .tip-lock { color: #fec84b; }

/* ------------------------------------------------------------ Oynalar */
.dlg-layer { position: fixed; inset: 0; z-index: 1200; background: rgba(8, 12, 20, .55); display: grid; place-items: center; padding: 20px; }
.dlg {
  width: min(460px, 100%); max-height: calc(100vh - 40px); overflow: auto; background: var(--lab-surface); color: var(--lab-text);
  border-radius: 16px; box-shadow: 0 30px 80px rgba(0, 0, 0, .35); border: 1px solid var(--lab-border); outline: none;
}
.dlg--wide { width: min(760px, 100%); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--lab-border); position: sticky; top: 0; background: var(--lab-surface); z-index: 1; }
.dlg-head h2 { margin: 0; font-size: 1.05rem; font-weight: 800; }
.dlg-close { width: 34px; height: 34px; border-radius: 9px; border: 0; background: var(--lab-surface-2); color: var(--lab-text); cursor: pointer; }
.dlg-body { padding: 16px 18px; font-size: .9rem; }
.dlg-body p { margin: 0 0 8px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px 16px; }
.help ol { padding-left: 20px; display: grid; gap: 6px; }
.save-list { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 8px; }
.save-item { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--lab-border); border-radius: 10px; background: var(--lab-surface-2); }
.save-item small { display: block; color: var(--lab-muted); font-size: .76rem; }
.save-files { border-top: 1px solid var(--lab-border); padding-top: 12px; }

.tp { display: grid; gap: 16px; }
.tp section h3 { font-size: .78rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--lab-muted); margin: 0 0 8px; }
.tp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px; }
.tp-card { text-align: left; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--lab-border); background: var(--lab-surface-2); color: var(--lab-text); font-weight: 700; font-size: .82rem; cursor: pointer; }
.tp-card:hover, .tp-card.is-active { border-color: var(--lab-accent); background: var(--lab-accent-soft); color: var(--lab-accent-ink); }
.tp-toggle { display: grid; grid-template-columns: 22px 1fr; gap: 10px; align-items: start; margin: 0 0 8px; cursor: pointer; }
.tp-toggle input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--lab-accent); }
.tp-toggle small { display: block; color: var(--lab-muted); font-size: .76rem; font-weight: 500; }
.tp-toggle--main { padding: 12px; border-radius: 12px; background: #fef0c7; color: #7a2e0e; }
.tp-toggle--main small { color: #93370d; }
.tp-defaults { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 8px; }

.lab-toasts {
  position: fixed; left: 50%; bottom: 140px; transform: translateX(-50%); z-index: 1300;
  display: grid; justify-items: center; gap: 8px; width: max-content; max-width: min(520px, 90vw); pointer-events: none;
}
.lab-toast {
  display: grid; grid-template-columns: 20px 1fr; gap: 8px; align-items: start; padding: 10px 14px; border-radius: 12px;
  background: var(--lab-surface); color: var(--lab-text); border: 1px solid var(--lab-border); box-shadow: 0 12px 30px rgba(0, 0, 0, .18);
  font-size: .86rem; font-weight: 600; animation: toast-in .25s ease-out; transition: opacity .35s, transform .35s;
}
.lab-toast.is-leaving { opacity: 0; transform: translateX(20px); }
.lab-toast--success i { color: var(--lab-success); }
.lab-toast--error i { color: var(--lab-danger); }
.lab-toast--warning i { color: var(--lab-warning); }
.lab-toast--info i { color: var(--lab-accent); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

/* ------------------------------------------------------------ Kirish oynasi */
.lab-splash {
  position: absolute; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px;
  background:
    radial-gradient(circle at 20% 20%, rgba(247, 181, 0, .18), transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(29, 100, 216, .22), transparent 45%),
    rgba(10, 16, 26, .78);
  backdrop-filter: blur(6px);
}
.splash-card {
  width: min(620px, 100%); background: var(--lab-surface); color: var(--lab-text); border-radius: 22px; padding: 34px 34px 26px;
  box-shadow: 0 40px 100px rgba(0, 0, 0, .45); text-align: center;
}
.splash-icon {
  width: 76px; height: 76px; border-radius: 22px; display: inline-grid; place-items: center; font-size: 2rem; color: #fff;
  background: linear-gradient(135deg, #f7b500, #f05a28); box-shadow: 0 14px 30px rgba(240, 90, 40, .35);
}
.splash-eyebrow { margin: 16px 0 4px; font-size: .78rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--lab-accent-ink); }
.splash-card h1 { font-size: clamp(1.5rem, 3vw, 2.1rem); font-weight: 900; margin: 0 0 10px; }
.splash-text { color: var(--lab-muted); margin: 0 auto 16px; max-width: 480px; }
.splash-points { list-style: none; padding: 0; margin: 0 0 18px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; text-align: left; }
.splash-points li { background: var(--lab-surface-2); border-radius: 10px; padding: 8px 12px; font-size: .84rem; font-weight: 700; }
.splash-points i { color: var(--lab-accent); width: 18px; }
.splash-restored { background: var(--lab-success-soft); color: var(--lab-success); border-radius: 10px; padding: 8px 12px; font-weight: 700; font-size: .84rem; }
.splash-actions { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-bottom: 12px; }
.splash-back { font-size: .82rem; color: var(--lab-muted); text-decoration: none; }
.splash-back:hover { color: var(--lab-accent-ink); }
.lab-noscript { position: absolute; inset: auto 0 0; background: var(--lab-danger); color: #fff; padding: 12px; text-align: center; z-index: 60; }

/* ------------------------------------------------------------ Moslashuvchanlik */
@media (max-width: 1700px) {
  .lab-brand small { display: none; }
}
@media (max-width: 1500px) {
  .lab-body { grid-template-columns: 228px minmax(0, 1fr) 340px; }
  .lab-bar .tb-pill .tb-text { display: none; }
  .lab-bar .tb-pill { width: 38px; padding: 0; }
  .lab-exit .tb-text { display: none; }
}
@media (max-width: 1280px) {
  .lab-brand__text { display: none; }
  .lab-controls .tb-group:nth-child(3) .tb-text { display: none; }
  .ro-value { font-size: 1.2rem; }
}
@media (max-width: 1100px) {
  .lab-body { grid-template-columns: minmax(0, 1fr); }
  .tb-drawer { display: inline-flex; }
  .lab-palette, .lab-side {
    position: absolute; top: 0; bottom: 0; z-index: 30; box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
    transition: transform .25s ease; width: min(340px, 88vw);
  }
  .lab-palette { left: 0; transform: translateX(-105%); }
  .lab-side { right: 0; transform: translateX(105%); background: var(--lab-bg); }
  .lab.show-palette .lab-palette { transform: none; }
  .lab.show-side .lab-side { transform: none; }
  .lab-body { position: relative; }
  .lab-controls { overflow-x: auto; }
  .lab-controls .tb-text { display: none; }
  .lab-controls .tb-btn { width: 40px; padding: 0; }
  .lab-controls .tb-drawer:last-child { margin-left: auto; }
}
@media (max-width: 700px) {
  .lab-experiment__label { display: none; }
  .lab-experiment select { max-width: 170px; }
  .lab-bar { flex-wrap: wrap; }
  .tb-group--end { margin-left: 0; }
  .lab-status { grid-template-columns: 1fr; max-height: 110px; }
  .st-side { flex-direction: row; min-width: 0; }
  .splash-points { grid-template-columns: 1fr; }
  .stage-legend { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .wire.is-short .wire-body, .stage-banner--danger, .lab-stage.is-short::after, .art-waves.is-active, .st-pill--short { animation: none; }
}

.side-subtitle--row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.side-subtitle--row .link-btn { text-transform: none; letter-spacing: 0; }
.chart-box--large .chart { max-height: 62vh; }
.chart-box--large .chart-tick { font-size: 8px; }
