/* Kirchhoff's Rules Workshop: the Circuit Bench inside the practice shell's stage (about 1066 x 628 at 1366 x 768).
 * Left: the circuit card (schematic + the solved-current chips when the question gives them).
 * Right: the coach line and the task card (one control per item kind). */
.kw { position: absolute; inset: 0; overflow: auto; display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(0, 1fr); gap: 12px; padding: 10px 12px; font-size: 17px; line-height: 1.3;
  color: #1f2933; background: linear-gradient(#e8eef4, #d8e2eb);
  --kw-card: #ffffff; --kw-line: #a9b8c4; --kw-soft: #44525f; --kw-accent: #0f5e73; --kw-head: #e2eef2; --kw-in: #ffffff;
  --kw-ok: #1f7a44; --kw-ok-bg: #e3f6e8; --kw-bad: #b42318; --kw-bad-bg: #fde7e4; --kw-amber: #b45309; --kw-amber-bg: #fff4e0; }
html[data-theme="dark"] .kw { color: #eef2f6; background: linear-gradient(#18212b, #121920);
  --kw-card: #202a35; --kw-line: #56657a; --kw-soft: #c9d3de; --kw-accent: #7dd3e8; --kw-head: #23404a; --kw-in: #121820;
  --kw-ok: #7fdca0; --kw-ok-bg: #173d27; --kw-bad: #ffb4a8; --kw-bad-bg: #4a1e1a; --kw-amber: #ffc078; --kw-amber-bg: #3d2a12; }
.kw *, .kw *::before, .kw *::after { box-sizing: border-box; }
.kw p { margin: 0; }
.kw-left, .kw-right { display: flex; flex-direction: column; gap: 8px; min-width: 0; min-height: 0; }
.kw-card { background: var(--kw-card); border: 1.5px solid var(--kw-line); border-radius: 12px; padding: 8px 10px; min-width: 0; }
.kw-k { font-weight: 800; color: var(--kw-accent); }

/* the circuit card */
.kw-diagram { flex: 1 1 auto; display: flex; flex-direction: column; gap: 6px; min-height: 0; }
.kw-dhead { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 2px 10px; }
.kw-tier { color: var(--kw-soft); font-weight: 700; }
.kw-svghost { flex: 1 1 auto; min-height: 0; display: flex; align-items: center; justify-content: center; }
.kw-svghost svg { display: block; width: 100%; height: 100%; max-height: 460px; }
.kw-given { display: flex; flex-wrap: wrap; gap: 6px 8px; }
.kw-given:empty { display: none; }
.kw-gchip { display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 3px 10px; border-radius: 999px; border: 2px solid currentColor; font-weight: 800; font-variant-numeric: tabular-nums; background: var(--kw-card); }
.kw-gchip small { font-size: 16px; font-weight: 600; color: var(--kw-soft); }
.kw-c0 { color: #1d4ed8; } .kw-c1 { color: #c2410c; } .kw-c2 { color: #7e22ce; } .kw-c3 { color: #0f766e; }
html[data-theme="dark"] .kw-c0 { color: #93c5fd; } html[data-theme="dark"] .kw-c1 { color: #fdba74; } html[data-theme="dark"] .kw-c2 { color: #d8b4fe; } html[data-theme="dark"] .kw-c3 { color: #5eead4; }

/* coach line */
.kw-coachbar { display: flex; align-items: center; gap: 10px; background: var(--kw-card); border: 1.5px solid var(--kw-line); border-left: 6px solid var(--kw-accent); border-radius: 10px; padding: 6px 10px; min-height: 46px; }
.kw-coach-k { flex: none; font-weight: 800; color: var(--kw-accent); text-transform: uppercase; letter-spacing: .06em; }
.kw-coach { line-height: 1.25; }

/* task card */
.kw-task { flex: 1 1 auto; display: flex; flex-direction: column; gap: 10px; min-height: 0; overflow: auto; box-shadow: 0 6px 16px rgba(20, 35, 50, .1); }
.kw-eq { padding: 6px 10px; border-radius: 8px; background: var(--kw-head); font-weight: 700; font-variant-numeric: tabular-nums; }
.kw-eq b { color: var(--kw-accent); }
.kw-say { color: var(--kw-soft); }
.kw-msg { color: var(--kw-bad); font-weight: 700; }
.kw-msg:empty { display: none; }
.kw-note { color: var(--kw-soft); font-size: 16px; }
.kw-ok-note { color: var(--kw-ok); font-weight: 700; }
.kw-ok-note:empty { display: none; }

/* buttons and inputs */
.kw button { font: inherit; color: inherit; }
.kw .kw-btn { min-height: 44px; min-width: 44px; padding: 6px 12px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-weight: 700; background: var(--kw-in); border: 2px solid var(--kw-line); border-radius: 10px; cursor: pointer; }
.kw .kw-btn[aria-checked="true"], .kw .kw-btn[aria-pressed="true"] { border: 3px solid var(--kw-accent); background: var(--kw-head); }
.kw .kw-btn:disabled { cursor: default; }
.kw .kw-btn.is-right { border: 3px solid var(--kw-ok); background: var(--kw-ok-bg); }
.kw .kw-btn.is-wrong { border: 3px solid var(--kw-bad); background: var(--kw-bad-bg); }
.kw .kw-in { width: 140px; min-width: 0; height: 46px; padding: 0 10px; font: inherit; font-size: 19px; font-weight: 700; text-align: center; color: inherit; background: var(--kw-in); border: 2px solid var(--kw-accent); border-radius: 8px; }
.kw .kw-in:disabled { opacity: 1; -webkit-text-fill-color: currentColor; }
.kw .kw-in.is-ok { border-color: var(--kw-ok); background: var(--kw-ok-bg); }
.kw .kw-in.is-bad { border-color: var(--kw-bad); background: var(--kw-bad-bg); }
.kw .kw-pm { width: 46px; height: 46px; flex: none; font-size: 21px; font-weight: 800; background: var(--kw-head); border: 2px solid var(--kw-line); border-radius: 8px; cursor: pointer; }
.kw .kw-pm:disabled { opacity: .55; cursor: default; }
.kw-numrow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.kw-numrow label { font-weight: 800; min-width: 0; }
.kw-unit { font-weight: 800; color: var(--kw-soft); }
.kw-mark { font-weight: 800; white-space: nowrap; }
.kw-mark:empty { display: none; }
.kw-mark.is-ok { color: var(--kw-ok); } .kw-mark.is-bad { color: var(--kw-bad); }
.kw-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.kw-rowlab { font-weight: 800; }
.kw-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.kw .kw-btn:focus-visible, .kw .kw-in:focus-visible, .kw .kw-pm:focus-visible, .kw-svg .k-hit:focus-visible { outline: 3px solid var(--tlg-focus, #b84c00); outline-offset: 2px; }

/* choice cards (negative-current meaning, charging, error steps) */
.kw-choices { display: flex; flex-direction: column; gap: 8px; }
.kw .kw-choice { justify-content: flex-start; text-align: left; width: 100%; padding: 8px 12px; font-weight: 600; line-height: 1.3; }
.kw-choice .kw-dot { flex: none; width: 26px; height: 26px; border-radius: 50%; border: 2.5px solid var(--kw-line); display: inline-flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 900; }
.kw-choice[aria-checked="true"] .kw-dot { border-color: var(--kw-accent); background: var(--kw-accent); box-shadow: inset 0 0 0 3px var(--kw-card); }
.kw-choice.is-right .kw-dot { border-color: var(--kw-ok); background: var(--kw-ok); box-shadow: none; color: #fff; }
.kw-choice.is-wrong .kw-dot { border-color: var(--kw-bad); background: var(--kw-bad); box-shadow: none; color: #fff; }
html[data-theme="dark"] .kw-choice.is-right .kw-dot, html[data-theme="dark"] .kw-choice.is-wrong .kw-dot { color: #111; }
.kw .kw-step { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 10px; align-items: start; justify-items: start; text-align: left; }
.kw-stepn { grid-row: span 2; width: 30px; height: 30px; border-radius: 50%; background: var(--kw-head); color: var(--kw-accent); display: inline-flex; align-items: center; justify-content: center; font-weight: 900; }
.kw-step[aria-checked="true"] .kw-stepn { background: var(--kw-accent); color: var(--kw-card); }
.kw-step.is-right .kw-stepn { background: var(--kw-ok); color: #fff; } .kw-step.is-wrong .kw-stepn { background: var(--kw-bad); color: #fff; }
.kw-stept { font-weight: 800; color: var(--kw-soft); font-size: 16px; }
.kw-stepx { font-weight: 700; font-variant-numeric: tabular-nums; }

/* junction sorter */
.kw-sort { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 8px; align-items: stretch; }
.kw-bin { border: 2px dashed var(--kw-line); border-radius: 12px; padding: 8px; min-height: 104px; display: flex; flex-direction: column; gap: 6px; background: var(--kw-in); }
.kw-bin-h { font-weight: 800; color: var(--kw-soft); font-size: 16px; }
.kw-bin-c { display: flex; flex-wrap: wrap; gap: 6px; }
.kw-eqsign { align-self: center; font-size: 28px; font-weight: 900; color: var(--kw-soft); }
.kw-tray { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; min-height: 48px; }
.kw-tray-h { font-weight: 700; color: var(--kw-soft); }
.kw .kw-cur { min-width: 64px; font-size: 19px; font-weight: 900; border-width: 3px; }
.kw .kw-cur.kw-c1 { border-color: #c2410c; } .kw .kw-cur.kw-c2 { border-color: #7e22ce; } .kw .kw-cur.kw-c3 { border-color: #0f766e; }
html[data-theme="dark"] .kw .kw-cur.kw-c1 { border-color: #fdba74; } html[data-theme="dark"] .kw .kw-cur.kw-c2 { border-color: #d8b4fe; } html[data-theme="dark"] .kw .kw-cur.kw-c3 { border-color: #5eead4; }
.kw-live { font-weight: 800; font-size: 19px; font-variant-numeric: tabular-nums; }

/* loop terms */
.kw-terms { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.kw .kw-term { min-width: 84px; font-size: 19px; padding: 4px 10px; gap: 8px; }
.kw-term .kw-sg { width: 30px; height: 30px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 900; border: 2.5px solid var(--kw-amber); color: var(--kw-amber); background: var(--kw-card); }
.kw-term.is-set .kw-sg { background: var(--kw-amber); color: var(--kw-card); }
.kw-term.is-right { border-color: var(--kw-ok) !important; } .kw-term.is-wrong { border-color: var(--kw-bad) !important; }
.kw-zero { font-weight: 900; font-size: 20px; color: var(--kw-soft); }

/* real-flow setter */
.kw-real { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 10px; align-items: center; }
.kw-real .kw-rowlab { font-variant-numeric: tabular-nums; }
.kw-real small { display: block; color: var(--kw-soft); font-weight: 600; font-size: 16px; }

/* svg theme (light defaults are inline in art.js; dark overrides here) */
.kw-svg .k-t, .k-svg .k-t { font: 600 23px/1 system-ui, -apple-system, "Segoe UI", sans-serif; }
.k-svg .k-lab { font-weight: 700; }
.k-svg .k-curlab { font-weight: 900; font-size: 24px; }
.k-svg .k-nodelab { font-weight: 900; font-style: italic; font-size: 24px; }
.k-svg .k-sgn { font-weight: 900; font-size: 26px; }
.k-svg .k-signtxt { font-weight: 900; font-size: 24px; }
.k-svg .k-ptlab { font-weight: 900; font-style: italic; font-size: 25px; }
.k-svg .k-startlab { font-weight: 800; }
.k-svg .k-chip { font-weight: 800; font-size: 22px; }
.k-svg .k-pad { font-weight: 900; font-size: 22px; }
.k-svg .k-realq { font-weight: 900; }
.k-svg .k-hit { cursor: pointer; }
.k-svg .k-part, .k-svg .k-signtag { transition: opacity .2s; }
.k-svg .k-dot { fill: #f08c00; stroke: #fff; stroke-width: 1.5; }
html[data-theme="dark"] .k-svg .k-board { fill: #17212c; }
html[data-theme="dark"] .k-svg .k-gap { fill: #17212c; }
html[data-theme="dark"] .k-svg .k-grid { stroke: #223042; }
html[data-theme="dark"] .k-svg .k-wire, html[data-theme="dark"] .k-svg .k-res, html[data-theme="dark"] .k-svg .k-plate { stroke: #dbe3ec; }
html[data-theme="dark"] .k-svg .k-node { fill: #dbe3ec; }
html[data-theme="dark"] .k-svg .k-t { fill: #eef2f6; }
html[data-theme="dark"] .k-svg .k-plus { fill: #ff8787; } html[data-theme="dark"] .k-svg .k-minus { fill: #74c0fc; }
html[data-theme="dark"] .k-svg .k-arrow-0, html[data-theme="dark"] .k-svg .k-curlab-0 { fill: #93c5fd; }
html[data-theme="dark"] .k-svg .k-arrow-1, html[data-theme="dark"] .k-svg .k-curlab-1 { fill: #fdba74; }
html[data-theme="dark"] .k-svg .k-arrow-2, html[data-theme="dark"] .k-svg .k-curlab-2 { fill: #d8b4fe; }
html[data-theme="dark"] .k-svg .k-arrow-3, html[data-theme="dark"] .k-svg .k-curlab-3 { fill: #5eead4; }
html[data-theme="dark"] .k-svg .k-realarrow { fill: #17212c; }
html[data-theme="dark"] .k-svg .k-realbg { fill: #17212c; }
html[data-theme="dark"] .k-svg .k-pt { fill: #17212c; stroke: #66d9e8; }
html[data-theme="dark"] .k-svg .k-pt-ring { stroke: #66d9e8; }
html[data-theme="dark"] .k-svg .k-ptlab { fill: #66d9e8; }
html[data-theme="dark"] .k-svg .k-hl { stroke: #f59f00; stroke-opacity: .3; }
html[data-theme="dark"] .k-svg .k-chev, html[data-theme="dark"] .k-svg .k-looparc-l { stroke: #ffc078; }
html[data-theme="dark"] .k-svg .k-looparc-h { fill: #ffc078; }
html[data-theme="dark"] .k-svg .k-startlab { fill: #ffc078; }
html[data-theme="dark"] .k-svg .k-signbg { stroke: #ffc078; }
html[data-theme="dark"] .k-svg .k-signtag:not(.is-unset) .k-signbg { fill: #c2620a; }
html[data-theme="dark"] .k-svg .k-signtag.is-unset .k-signbg { fill: #17212c; }
html[data-theme="dark"] .k-svg .k-signtag.is-unset .k-signtxt { fill: #ffc078; }
html[data-theme="dark"] .k-svg .k-glow { fill: #5c4a12; stroke: #ffd43b; }
/* the circuit board picture keeps its own colors in both themes (its labels sit on white chips) */
html[data-theme="dark"] .k-svg-star .k-t { fill: #1b2a22; }
html[data-theme="dark"] .k-svg-star .k-pad { fill: #24313d; }

/* Briefing example and Start art */
.kw-example { display: flex; flex-direction: column; gap: 6px; align-items: center; color: #1f2933; }
html[data-theme="dark"] .kw-example { color: #eef2f6; }
.kw-example { margin: 0; }
.kw-exwrap { width: 100%; overflow-x: auto; display: flex; justify-content: safe center; }
.kw-example svg, .ps-brief-exstage .kw-example svg { width: 100%; min-width: 360px; max-width: 520px; height: auto; max-height: none; }
.kw-example figcaption { font-weight: 700; text-align: center; }
.kw-start { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.kw-start svg { width: 100%; height: auto; }

/* the assignment card and calculator stay off the answer area */
@media (min-width: 901px) { html.ps-locked .lga-card { right: auto !important; left: 12px; max-width: 276px; } }
@media (min-width: 901px) { .ps .ps-calc, .ps-calc { right: auto; left: 30px; bottom: 76px; } }

/* narrower than 1180: one column, the circuit above the task */
@media (max-width: 1180px) {
  .kw { grid-template-columns: minmax(0, 1fr); align-content: start; }
  .kw-left, .kw-right { min-height: auto; }
  .kw-diagram { flex: none; }
  .kw-svghost { flex: none; }
  .kw-svghost svg { height: auto; max-height: 420px; }
  .kw-task { flex: none; overflow: visible; }
}
@media (max-width: 900px) { .kw { position: static; overflow: visible; } }
@media (max-width: 640px) {
  .kw { padding: 8px; }
  .kw-card { padding: 8px; }
  .kw-sort { grid-template-columns: minmax(0, 1fr); }
  .kw-eqsign { justify-self: center; }
  .kw .kw-in { width: 120px; }
}
@media (prefers-reduced-motion: reduce) { .k-svg .k-part, .k-svg .k-signtag { transition: none; } }
