/* ELECNora+ — the full lab-work page (elecplus/labwork.js). Colours from the theme; two signal colours as in the lesson
   cards (blue = input / cause, orange = output / effect); every measure in rem/% so it holds from 360 px up. */
.lw-page { --lr-in: #2f6fb3; --lr-out: #c55e19; --lr-ok: #2c7a4c; --lr-bad: #b03838;
  --lw-ink: var(--text); --lw-red: #d23b3b; --lw-blk: #3a3f47; --lw-ch1: #c9a227; --lw-ch2: #2f6fb3; --lw-res: #e6cf9c; --lw-gen: #7a4fd6; --lw-meter: #23915a; }
/* these are starting points: labwork.js (lwTune) moves each one per theme until it reads on that theme's surfaces */
:root[data-theme="dark"] .lw-page { --lr-in: #72a9e5; --lr-out: #f08f48; --lr-ok: #62c38f; --lr-bad: #e57474; --lw-blk: #9aa3ae; --lw-ch1: #e3c35a; --lw-ch2: #72a9e5; --lw-res: #b89a5c; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .lw-page { --lr-in: #72a9e5; --lr-out: #f08f48; --lr-ok: #62c38f; --lr-bad: #e57474; --lw-blk: #9aa3ae; --lw-ch1: #e3c35a; --lw-ch2: #72a9e5; --lw-res: #b89a5c; } }

.lw-intro p { margin: 0 0 6px; }
.lw-gear { margin: 0 0 12px; padding-left: 1.2em; line-height: 1.55; }
.lw-fold { margin: 12px 0; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.lw-fold > summary { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 8px 14px; font-weight: 800; cursor: pointer; list-style: none; }
.lw-fold > summary::-webkit-details-marker { display: none; }
.lw-fold > summary::after { content: "＋"; margin-left: auto; color: var(--muted); }
.lw-fold[open] > summary::after { content: "−"; }
.lw-fold > summary small { padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-weight: 700; }
.lw-theory-body { display: grid; gap: 8px; padding: 0 14px 14px; }
.lw-f { display: grid; grid-template-columns: 3.4rem minmax(0, 1fr); gap: 8px; align-items: start; }
.lw-fn { font: 700 0.8rem/1.9 "JetBrains Mono", ui-monospace, monospace; color: var(--lr-out); }
.lw-f code { display: block; padding: 6px 10px; border-radius: 8px; background: color-mix(in srgb, var(--lr-in) 11%, transparent); font: 600 0.9rem/1.6 "JetBrains Mono", ui-monospace, monospace; white-space: normal; overflow-wrap: anywhere; }
.lw-f p { margin: 4px 0 0; color: var(--muted); font-size: 0.86rem; }
.lw-toc { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0; }
.lw-toc .chip { font-family: "JetBrains Mono", ui-monospace, monospace; }

.lw-exp { margin: 22px 0; padding: 16px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); scroll-margin-top: 90px; }
.lw-exp-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.lw-exp-head h3 { margin: 0; font-size: 1.12rem; }
.lw-num { padding: 4px 9px; border-radius: 6px; background: color-mix(in srgb, var(--lr-out) 16%, transparent); color: var(--lr-out); font: 700 0.85rem/1 "JetBrains Mono", ui-monospace, monospace; white-space: nowrap; }
.lw-q { padding: 10px 12px; border-left: 3px solid var(--lr-in); border-radius: 0 8px 8px 0; background: color-mix(in srgb, var(--lr-in) 7%, transparent); line-height: 1.6; }

/* the circuit, two views */
.lw-circ { margin: 14px 0; }
.lw-circ-top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; }
.lw-cap { color: var(--muted); font-size: 0.86rem; }
.lw-switch { display: inline-flex; gap: 4px; margin-left: auto; padding: 3px; border-radius: 999px; background: var(--surface-2); }
.lw-switch .chip { min-height: 36px; border: 0; }
/* «Схем ◯ Багажтай»: a toggle switch; the side that is on is in bold */
.lw-toggle { display: inline-flex; align-items: center; gap: 8px; margin-left: auto; min-height: 44px; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); font: 700 0.86rem var(--font-ui); cursor: pointer; user-select: none; }
.lw-toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.lw-toggle i { position: relative; flex: none; width: 44px; height: 24px; border-radius: 12px; background: var(--lr-in); transition: background 0.2s; }
.lw-toggle i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35); transition: transform 0.2s; }
.lw-toggle input:checked + i { background: var(--lr-out); }
.lw-toggle input:checked + i::after { transform: translateX(20px); }
.lw-toggle input:focus-visible + i { outline: 3px solid var(--lr-in); outline-offset: 2px; }
.lw-toggle span { color: var(--muted); } .lw-toggle .lw-tg-a, .lw-toggle input:checked ~ .lw-tg-b { color: var(--text); }
.lw-toggle:has(input:checked) .lw-tg-a { color: var(--muted); }
:root[data-gfx="low"] .lw-toggle i, :root[data-gfx="low"] .lw-toggle i::after { transition: none; }
@media (max-width: 640px) { .lw-toggle { margin-left: 0; width: 100%; justify-content: center; } }
.lw-circ-pair { display: grid; grid-template-columns: minmax(0, 1fr); }
.lw-fig { margin: 0; padding: 8px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.lw-circ-pair[data-view="schem"] .lw-fig[data-v="bench"], .lw-circ-pair[data-view="bench"] .lw-fig[data-v="schem"] { display: none; }
/* one view at a time at every width (side by side made the text ≈ 7 px); the drawing never grows past a readable size */
.lw-svg { display: block; width: 100%; max-width: 680px; height: auto; margin: 0 auto; }
.lw-svg-bench { max-width: 900px; }
/* every drawing fits its window: the box is cropped to the drawing itself (labwork.js lwFit), and on phones the
   labels are drawn a little larger so they stay readable at that size */
.lw-pan { display: none; }
@media (max-width: 640px) {
  /* less padding around the drawing on phones: the circuit gets the screen's width */
  .card.lw-page { padding-inline: 10px; } .lw-page .lw-exp { padding-inline: 8px; } .lw-page .lw-circ-pair { margin-inline: -4px; }
  .lw-fig { padding: 2px; }
  .lw-svg .lw-t { font-size: 16px; } .lw-svg .lw-tv { font-size: 14px; } .lw-svg .lw-tch1, .lw-svg .lw-tch2, .lw-svg .lw-tflow-a, .lw-svg .lw-tflow-b { font-size: 14px; }
}

/* one experiment at a time */
.lw-exp.is-off { display: none; }
.lw-toc .chip.is-cur { border-color: var(--lr-in); box-shadow: 0 0 0 2px color-mix(in srgb, var(--lr-in) 40%, transparent); font-weight: 800; }
.lw-nav { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.lw-nav > :first-child { justify-self: start; } .lw-nav > :last-child { justify-self: end; }
.lw-pos { color: var(--muted); font: 700 0.82rem "JetBrains Mono", ui-monospace, monospace; }

/* the formulas under a table: small, but set apart so they are seen */
.lw-fx { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 8px 0 0; padding: 6px 8px; border-left: 3px solid var(--lr-out); border-radius: 0 8px 8px 0; background: color-mix(in srgb, var(--lr-out) 8%, transparent); }
.lw-fx > b { color: var(--lr-out); font: italic 800 1rem/1 Georgia, serif; }
.lw-fx code { padding: 2px 7px; border-radius: 6px; background: var(--surface); color: var(--text); font: 600 0.78rem/1.5 "JetBrains Mono", ui-monospace, monospace; white-space: nowrap; }
@media (max-width: 640px) { .lw-fx code { white-space: normal; } }
.lw-table.is-narrow { min-width: 0; }
@media (max-width: 640px) {
  /* a table of four columns or fewer fits a phone without sliding */
  .lw-table.is-narrow th, .lw-table.is-narrow td { padding: 6px 4px; white-space: normal; }
  .lw-table.is-narrow .lw-in { min-width: 0; font-size: 0.82rem; }
  .lw-table.is-narrow .lw-in::placeholder { font-size: max(12px, 0.66rem); }
}
.lw-w { fill: none; stroke: var(--lw-ink); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.lw-dot { fill: var(--lw-ink); }
.lw-term { fill: var(--surface); stroke: var(--lw-ink); stroke-width: 2; }
.lw-r { fill: var(--lw-res); stroke: var(--lw-ink); stroke-width: 1.6; }
.lw-ldr-ring { fill: none; stroke: var(--lw-ink); stroke-width: 1.4; }
.lw-light { fill: none; stroke: var(--lr-out); stroke-width: 1.6; stroke-linecap: round; }
.lw-plate { stroke: var(--lw-ink); stroke-width: 3; stroke-linecap: round; }
.lw-src { fill: var(--surface); stroke: var(--lw-ink); stroke-width: 2; }
.lw-sig { fill: none; stroke: var(--lr-in); stroke-width: 2; }
.lw-t { fill: var(--text); font: 600 13px Inter, system-ui, sans-serif; }
.lw-tb { font-weight: 800; }
.lw-tv { fill: var(--muted); font-size: 12px; }
.lw-tch1 { fill: var(--lw-ch1); font-weight: 800; font-size: 12px; }
.lw-tch2 { fill: var(--lw-ch2); font-weight: 800; font-size: 12px; }
.lw-box { fill: var(--surface); stroke: var(--border); stroke-width: 1.6; }
.lw-box-psu { stroke: var(--lw-red); } .lw-box-gen { stroke: var(--lw-gen); } .lw-box-scope { stroke: var(--lw-ch2); } .lw-box-dmm { stroke: var(--lw-meter); }
.lw-jack { stroke: var(--lw-ink); stroke-width: 1.6; }
.lw-jack.lw-red { fill: var(--lw-red); } .lw-jack.lw-blk { fill: var(--lw-blk); } .lw-jack.lw-bnc { fill: #c0c6ce; } .lw-jack.lw-ch1 { fill: var(--lw-ch1); } .lw-jack.lw-ch2 { fill: var(--lw-ch2); }
.lw-lead { fill: none; stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.lw-lead.lw-red { stroke: var(--lw-red); } .lw-lead.lw-blk { stroke: var(--lw-blk); } .lw-lead.lw-ch1 { stroke: var(--lw-ch1); } .lw-lead.lw-ch2 { stroke: var(--lw-ch2); }

/* the table */
.lw-table-wrap { margin: 14px 0; }
.lw-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; }
.lw-table { width: 100%; min-width: 520px; border-collapse: collapse; font-size: 0.88rem; }
.lw-table th, .lw-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); text-align: center; vertical-align: middle; }
.lw-table th { background: var(--surface-2); font-weight: 800; white-space: nowrap; }
.lw-table tr:last-child td { border-bottom: 0; }
.lw-calc { color: var(--lr-out); font: 700 0.88rem "JetBrains Mono", ui-monospace, monospace; }
.lw-meas { color: var(--lr-in); font: 700 0.88rem "JetBrains Mono", ui-monospace, monospace; }
.lw-in { width: 100%; min-width: 4.5rem; min-height: 36px; padding: 4px 6px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: 600 0.88rem "JetBrains Mono", ui-monospace, monospace; text-align: center; }
.lw-in:focus-visible { outline: 2px solid var(--lr-in); outline-offset: 1px; }
.lw-in::placeholder { color: var(--muted); font: 400 max(12px, 0.72rem) var(--font-ui); }
.lw-note { margin: 6px 0 0; color: var(--muted); font-size: 0.86rem; line-height: 1.55; }

/* the graph */
.lw-graph { margin: 14px 0; }
.lw-graph-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 10px; }
.lw-graph figure { margin: 0; }
.lw-cv { width: 100%; height: 210px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.lw-graph figcaption { margin-top: 4px; color: var(--muted); font-size: 0.82rem; text-align: center; }
.lw-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 6px 0 0; font-size: 0.82rem; color: var(--muted); }
.lw-key { display: inline-block; width: 18px; height: 4px; border-radius: 2px; }
.lw-key-out { background: var(--lr-out); } .lw-key-in { width: 10px; height: 10px; border-radius: 50%; background: var(--lr-in); }
.lw-minis { margin: 12px 0; }

/* how to connect, what each part does */
.lw-steps { margin: 0; padding: 4px 14px 14px 2.6em; counter-reset: none; }
.lw-steps li { margin: 0 0 8px; padding-left: 4px; line-height: 1.55; }
.lw-steps li::marker { color: var(--lr-out); font: 700 0.85rem "JetBrains Mono", ui-monospace, monospace; }
.lw-steps small { display: block; margin-top: 2px; color: var(--muted); font-size: 0.82rem; }
.lw-roles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 10px; padding: 0 12px 12px; }
.lw-role-card { padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.lw-role-card h4 { display: flex; align-items: center; gap: 8px; margin: 0 0 6px; }
.lw-el { min-width: 2.2rem; padding: 3px 8px; border-radius: 6px; background: var(--lr-in); color: var(--lw-on-in, #fff); font: 800 0.85rem/1.2 "JetBrains Mono", ui-monospace, monospace; text-align: center; }
.lw-role-card p { margin: 0 0 6px; line-height: 1.55; }
.lw-page .lw-without { color: var(--text); padding: 6px 8px; border-left: 3px solid var(--lr-bad); border-radius: 0 6px 6px 0; background: color-mix(in srgb, var(--lr-bad) 9%, transparent); font-size: 0.9rem; }
.lw-role-card .lr-mini { margin-top: 8px; }

@media (max-width: 640px) {
  .lw-exp { padding: 12px; border-radius: 12px; }
  .lw-switch { margin-left: 0; width: 100%; } .lw-switch .chip { flex: 1; justify-content: center; }
  .lw-f { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .lw-steps { padding-left: 2.2em; }
}
:root[data-gfx="low"] .lw-circ-pair .lw-fig { transition: none; }

/* easier navigation: the experiment menu stays at the top while scrolling and shows how many steps are ticked */
.lw-toc { position: sticky; top: var(--lw-top, 64px); z-index: 3; padding: 6px; border: 1px solid var(--border); border-radius: 12px; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(6px); scroll-margin-top: 90px; }
.lw-toc .chip { position: relative; overflow: hidden; min-height: 40px; background-image: linear-gradient(90deg, color-mix(in srgb, var(--lr-ok) 22%, transparent) var(--p, 0%), transparent var(--p, 0%)); }
.lw-toc .chip small { font-family: var(--font-ui, Inter, sans-serif); font-weight: 600; color: var(--muted); }
.lw-toc .chip.is-done { border-color: var(--lr-ok); }
.lw-toc .chip.is-done span::after { content: " ✓"; color: var(--lr-ok); }
.lw-tick { display: flex; gap: 8px; align-items: flex-start; cursor: pointer; }
.lw-tick input { flex: none; width: 18px; height: 18px; margin-top: 3px; accent-color: var(--lr-ok); }
.lw-steps li.is-done > .lw-tick span { color: var(--muted); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--lr-ok) 70%, transparent); }
.lw-steps li { list-style-position: outside; }
.lw-steps small { margin-left: 26px; }
.lw-prog { color: var(--lr-ok); }
.lw-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 12px 0 0; }
.lw-totop { margin-left: auto; color: var(--muted); font-size: 0.85rem; }
.lw-page .lw-exp { scroll-margin-top: calc(var(--lw-top, 64px) + 64px); }
/* phones: the lab's own tab bar is already pinned, so the experiment strip scrolls with the page */
@media (max-width: 640px) { .lw-toc { position: static; flex-wrap: nowrap; overflow-x: auto; } .lw-toc .chip { flex: none; } .lw-page .lw-exp { scroll-margin-top: calc(var(--lw-top, 56px) + 8px); } }

/* Lab 4 drawings: diodes, LEDs and the current's path (moves along the conducting branch; still with Low graphics / reduced motion) */
.lw-diode { fill: var(--lw-ink); stroke: var(--lw-ink); stroke-width: 1.6; stroke-linejoin: round; }
.lw-led { fill: color-mix(in srgb, var(--lw-red) 70%, var(--surface)); }
.lw-glow { fill: none; stroke: var(--lw-red); stroke-width: 1.6; stroke-linecap: round; }
.lw-flow { fill: none; stroke-width: 4; stroke-linecap: round; stroke-dasharray: 2 12; opacity: 0.95; animation: lwFlow 0.9s linear infinite; }
.lw-flow-a { stroke: var(--lr-in); } .lw-flow-b { stroke: var(--lr-out); }
.lw-half-a { animation: lwHalfA 2.4s steps(1, end) infinite; } .lw-half-b { animation: lwHalfB 2.4s steps(1, end) infinite; }
@keyframes lwFlow { to { stroke-dashoffset: -14; } }
@keyframes lwHalfA { 0% { opacity: 1; } 50% { opacity: 0.08; } }
@keyframes lwHalfB { 0% { opacity: 0.08; } 50% { opacity: 1; } }
.lw-circ > .lw-legend { display: block; line-height: 1.6; }
.lw-circ > .lw-legend .lw-key { vertical-align: middle; margin-right: 4px; }
.lw-tflow-a { fill: var(--lr-in); font-weight: 800; font-size: 12px; } .lw-tflow-b { fill: var(--lr-out); font-weight: 800; font-size: 12px; }
/* still pictures (reduced motion, Low graphics): both halves shown at full strength, told apart by the line — dots for +, dashes for − */
@media (prefers-reduced-motion: reduce) { .lw-flow, .lw-half-a, .lw-half-b { animation: none; opacity: 1; } .lw-flow-b { stroke-dasharray: 9 6; } }
:root[data-gfx="low"] .lw-flow, :root[data-gfx="low"] .lw-half-a, :root[data-gfx="low"] .lw-half-b { animation: none; opacity: 1; }
:root[data-gfx="low"] .lw-flow-b { stroke-dasharray: 9 6; }
/* Lab 5: the Zener's bar with its two hooks is a line, not a filled shape */
.lw-diode.lw-zbar { fill: none; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

/* «Тоонууд хэрхэн холбогдох вэ?»: the fold under a table (labwork.js → lwRelRun) */
.lw-rel { margin-top: .75rem; }
.lw-rel-body { display: grid; gap: .75rem; padding-top: .5rem; }
.lw-rel-fig { margin: 0; }
.lw-rel-fig .lw-cv { width: 100%; height: 14rem; }
.lw-rel-text { line-height: 1.65; }
.lw-rel-text h4 { margin: .75rem 0 .25rem; font-size: 1rem; }
.lw-rel-text ul { margin: .25rem 0; padding-left: 1.2rem; }
.lw-rel-text li { margin: .2rem 0; }
.lw-rel-text .lw-rel-warn { border-left: 3px solid var(--lr-bad, #c0392b); padding: .25rem 0 .25rem .6rem; margin: .5rem 0; }
.lw-rel-text .lw-rel-ex { color: var(--muted); font-size: .9em; }
.lw-rel-text b.n { font-variant-numeric: tabular-nums; }
.lw-key-iin { background: var(--lr-in); } .lw-key-ok { background: var(--lr-ok); } .lw-key-mut { background: var(--muted); }
@media (max-width: 640px) { .lw-rel > summary small { display: none; } }

/* phones: the role cards' minis lose two layers of padding, so their graphs keep ≈ 80 % of the screen instead of 57 % */
@media (max-width: 520px) {
  .lw-roles { padding: 0 0 10px; }
  .lw-role-card { padding: 10px 8px; }
  .lw-role-card .lr-mini { padding-left: 6px; padding-right: 6px; margin-left: -4px; margin-right: -4px; }
}

/* the sticky experiment menu is always one row that scrolls sideways (Lab 9's 11 experiments wrapped it into 3–4 rows, ≈ 190 px of the screen) */
@media (min-width: 641px) { .lw-toc { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: thin; } .lw-toc .chip { flex: none; } }
.lw-in.is-ans { color: var(--lr-out); font-weight: 700; }

/* Lab 9's theory: one formula at a time (≈ 3 lines), chips in one row to jump; a tap on the card shows its whole note */
.lw-fchips { display: flex; flex-wrap: nowrap; gap: 6px; overflow-x: auto; scrollbar-width: thin; padding: 2px 2px 8px; }
.lw-fchips .chip { flex: none; min-height: 36px; font-family: "JetBrains Mono", ui-monospace, monospace; }
.lw-fchips .chip.is-cur { border-color: var(--lr-in); box-shadow: 0 0 0 2px color-mix(in srgb, var(--lr-in) 40%, transparent); font-weight: 800; }
.lw-theory-body.is-one { display: flex; flex-wrap: nowrap; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; gap: 0; }
.lw-theory-body.is-one::-webkit-scrollbar { display: none; }
.lw-theory-body.is-one .lw-f { flex: 0 0 100%; scroll-snap-align: start; margin: 0; cursor: pointer; }
.lw-theory-body.is-one .lw-f > div { min-width: 0; }
.lw-theory-body.is-one .lw-f code { white-space: nowrap; overflow-x: auto; display: block; }
.lw-theory-body.is-one .lw-f p { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-bottom: 0; }
.lw-theory-body.is-one .lw-f.is-open p { display: block; }
.lw-simlink { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 10px 0 0; } .lw-simlink small { color: var(--muted); }
