/* Transformer sizing and loading — on top of calc.css */
main.tx .tabs { grid-template-columns: repeat(4, 1fr); }
main.tx .stage-bar { justify-content: flex-start; gap: 8px; flex-wrap: wrap; }
main.tx .stage-bar .hist { margin-left: auto; }
#view { display: block; width: 100%; height: auto; user-select: none; touch-action: none; }
#view .hit { fill: transparent; stroke: none; }
#view .handle { cursor: grab; }
#view .handle.hx { cursor: ew-resize; }
#view .handle.hy { cursor: ns-resize; }
#view .handle .knob { fill: var(--surface); stroke: var(--sel); stroke-width: 1.8; }
#view .handle .knob.gr { stroke: var(--good); }
#view .handle:hover .knob, #view .handle:focus .knob { fill: var(--sel); }

/* duty cycle */
.tx-axis { fill: none; stroke: var(--steel-750); stroke-width: 1.2; }
.tx-grid { fill: none; stroke: var(--grid); stroke-width: 1; }
.tx-axt { font-size: 11px; fill: var(--text-3); font-variant-numeric: tabular-nums; }
.tx-per { fill: var(--steel-100); stroke: none; }
.tx-per.gov { fill: var(--sel-line); }
.tx-prof { fill: none; stroke: var(--moment); stroke-width: 1.8; stroke-linejoin: round; }
.tx-rand { fill: color-mix(in srgb, var(--x-e0a84a, #e0a84a) 28%, transparent); stroke: var(--x-c98a2a, #c98a2a); stroke-width: 1.2; stroke-dasharray: 4 2; }
.tx-sec { fill: none; stroke: var(--moment); stroke-width: 1.3; }
.tx-cell { fill: var(--steel-200); stroke: var(--steel-700); stroke-width: 1.1; }
.tx-term { fill: var(--steel-700); }
.tx-dots { stroke: var(--steel-700); stroke-width: 2; stroke-dasharray: 2 3; }
.tx-name { font-size: 12px; font-weight: 600; fill: var(--text); }
.tx-role { font-size: 10.5px; fill: var(--text-3); }
.tx-name2 { font-size: 11.5px; font-weight: 500; fill: var(--text-2); }
.tx-nm2 { cursor: text; }
.tx-nm2:hover .tx-name, .tx-nm2:focus .tx-name, .tx-nm2:hover .tx-name2, .tx-nm2:focus .tx-name2 { fill: var(--sel); }
.tx-nm2:focus { outline: none; }
#view .handle .knob.rd { stroke: var(--x-c98a2a, #c98a2a); }

/* pills */
#view .pill rect { fill: var(--surface); stroke: var(--steel-300); }
#view .pill text { font-size: 11.5px; font-weight: 500; fill: var(--text-2); font-variant-numeric: tabular-nums; }
#view .pill.pw rect { stroke: rgba(23, 24, 26, .35); } #view .pill.pw text { fill: var(--text); font-weight: 600; }
#view .pill.qq rect { stroke: color-mix(in srgb, var(--moment) 45%, transparent); } #view .pill.qq text { fill: var(--x-2c4a91, #2c4a91); }
#view .pill.gr rect { stroke: color-mix(in srgb, var(--good) 45%, transparent); } #view .pill.gr text { fill: var(--olive); }
#view .pill.ld rect { stroke: color-mix(in srgb, var(--moment) 45%, transparent); } #view .pill.ld text { fill: var(--x-2c4a91, #2c4a91); font-weight: 600; }
#view .pill.rd rect { stroke: color-mix(in srgb, var(--x-c98a2a, #c98a2a) 60%, transparent); } #view .pill.rd text { fill: var(--x-8a5a0e, #8a5a0e); }
#view .pill.gov rect { stroke: color-mix(in srgb, var(--moment) 45%, transparent); fill: var(--sel-bg); } #view .pill.gov text { fill: var(--x-2c4a91, #2c4a91); }
#view .pill.bad rect { stroke: color-mix(in srgb, var(--bad) 55%, transparent); } #view .pill.bad text { fill: var(--x-b0321f, #b0321f); font-weight: 600; }
#view .pill.editable { cursor: text; }
#view .pill.editable:hover rect, #view .pill.editable:focus rect { stroke: var(--sel); stroke-width: 1.4; }
#view .pill.editable:focus { outline: none; }

/* editors in the drawing */
.stage { position: relative; }
.tx-edit { position: absolute; transform: translate(-50%, -50%); z-index: 5; display: flex; align-items: center; gap: 4px; background: var(--surface); border: 1.5px solid var(--sel); border-radius: 9px; padding: 2px 8px 2px 4px; box-shadow: 0 6px 18px rgba(20, 22, 28, .14); }
.tx-edit input { width: 82px; border: 0; outline: none; font: inherit; font-size: 13px; text-align: right; font-variant-numeric: tabular-nums; padding: 3px 2px; }
.tx-edit-name input { width: 180px; text-align: center; }
.tx-edit span { font-size: 11.5px; color: var(--text-3); white-space: nowrap; }

/* live strip and flags */
.tx-live { display: flex; flex-wrap: wrap; gap: 4px 18px; padding: 8px 14px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--text-2); font-variant-numeric: tabular-nums; min-height: 38px; align-items: center; }
.tx-live b { font-weight: 500; color: var(--text-3); margin-right: 5px; }
.tx-live i { font-style: normal; color: var(--text-3); }
.tx-flags { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.tx-flags span { font-size: 11.5px; color: var(--text-3); border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; white-space: nowrap; }
.tx-flags span.bad, .tx-flags span.tx-err { color: var(--bad-ink, #b0321f); border-color: color-mix(in srgb, var(--bad) 35%, transparent); white-space: normal; }

/* panel */
.tx-seg { margin-bottom: 6px; }
.tx-lab { font-size: 12px; color: var(--text-3); margin: 8px 0 4px; }
.tx-chips { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0 6px; }
.tx-chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 2px 10px; font-size: 12px; color: var(--text-2); cursor: pointer; line-height: 1.5; }
.tx-chip:hover { border-color: var(--line-2); color: var(--text); }
.tx-link { border: 0; background: none; padding: 0; font: inherit; color: var(--sel); text-decoration: underline; cursor: pointer; }
.tx-head, .tx-row { display: grid; grid-template-columns: 16px minmax(0, 1fr) 84px 76px 22px; gap: 4px 6px; align-items: center; }
.tx-head { font-size: 11px; color: var(--text-3); margin-bottom: 2px; }
.tx-row { margin: 3px 0; }
.tx-ix { font-size: 11.5px; color: var(--text-3); text-align: right; font-variant-numeric: tabular-nums; }
.tx-nm, .tx-v input { width: 100%; min-width: 0; border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; font: inherit; font-size: 12.5px; background: var(--surface); color: var(--text); }
.tx-v { display: flex; align-items: center; gap: 3px; min-width: 0; }
.tx-v input { text-align: right; font-variant-numeric: tabular-nums; }
.tx-v span { font-size: 11px; color: var(--text-3); }
.tx-nm:focus, .tx-v input:focus { border-color: var(--sel); outline: none; }
.tx-v input.bad { border-color: var(--bad); color: var(--bad); }
.tx-x { border: 0; background: none; color: var(--text-3); font-size: 15px; cursor: pointer; padding: 0; line-height: 1; height: 22px; }
.tx-x:hover { color: var(--bad-ink, #b0321f); }
.tx-x:disabled { opacity: .3; cursor: default; }
.tx-chip:disabled { opacity: .4; cursor: default; }
#panel input.bad { color: var(--bad); }
#panel .num:has(input.bad) input { border-color: var(--bad); }
#panel .small-note a { color: inherit; }
#panel.fade-b { -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 32px), transparent); mask-image: linear-gradient(to bottom, #000 calc(100% - 32px), transparent); }
#panel.fade-t { -webkit-mask-image: linear-gradient(to bottom, transparent, #000 28px); mask-image: linear-gradient(to bottom, transparent, #000 28px); }
#panel.fade-t.fade-b { -webkit-mask-image: linear-gradient(to bottom, transparent, #000 28px, #000 calc(100% - 32px), transparent); mask-image: linear-gradient(to bottom, transparent, #000 28px, #000 calc(100% - 32px), transparent); }

/* summary */
.tx-say { margin-top: 6px; font-size: 12.5px; color: var(--text-2); line-height: 1.4; max-width: 36ch; }
.tx-big { font-weight: 600; color: var(--olive); }
.tx-tag { display: inline-block; font-size: 10.5px; color: var(--text-3); border: 1px solid var(--line); border-radius: 999px; padding: 0 7px; margin-left: 4px; white-space: nowrap; line-height: 1.5; }

/* charts */
.tx-two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
#eChart, #sChart, #tChart { touch-action: none; user-select: none; }
#eChart .cdrag { cursor: ew-resize; }
#tChart .cdrag { cursor: ns-resize; }
#sChart .tx-pick { cursor: pointer; }
#checks td.note { white-space: normal; min-width: 200px; line-height: 1.4; }

@media (max-width: 1100px) { .tx-two { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 760px) {
  #checks thead { display: none; }
  #checks, #checks tbody { display: block; width: 100%; }
  #checks tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
  #checks td { display: block; border: 0; padding: 0; text-align: left; white-space: normal; }
  #checks td.chk { grid-column: 1; grid-row: 1; }
  #checks td:nth-child(5) { grid-column: 2; grid-row: 1; align-self: center; }
  #checks td:nth-child(2) { grid-column: 1; grid-row: 2; font-size: 12.5px; }
  #checks td:nth-child(3) { grid-column: 2; grid-row: 2; font-size: 12.5px; text-align: right; }
  #checks td:nth-child(2)::before { content: "actual "; color: var(--text-3); }
  #checks td:nth-child(3)::before { content: "allowed "; color: var(--text-3); }
  #checks td:nth-child(4) { grid-column: 1 / -1; grid-row: 3; font-size: 12px; color: var(--text-3); min-width: 0; }
}
@media print { .tx-edit { display: none !important; } }


/* the transformer */
.tx-tank { fill: var(--steel-200); stroke: var(--steel-700); stroke-width: 1.2; }
.tx-fin { fill: var(--steel-100); stroke: var(--x-8f979f, #8f979f); stroke-width: 1; }
.tx-bush { fill: var(--steel-50); stroke: var(--steel-700); stroke-width: 1.1; }
.tx-lim { fill: none; stroke: var(--bad); stroke-width: 1; stroke-dasharray: 5 3; }
.tx-rated { fill: none; stroke: var(--text-2); stroke-width: 1; stroke-dasharray: 3 3; }
.tx-hs { fill: var(--load); }
.tx-oilT { fill: none; stroke: var(--x-c98a2a, #c98a2a); stroke-width: 2.2; }
.tx-wdg { fill: none; stroke: var(--x-b0321f, #b0321f); stroke-width: 2.2; }
.tx-par { fill: var(--steel-100); stroke: var(--x-8f979f, #8f979f); stroke-width: 1; stroke-dasharray: 4 2; }
#view .pill.tmp rect { stroke: color-mix(in srgb, var(--load) 50%, transparent); } #view .pill.tmp text { fill: var(--load-ink); font-weight: 600; }
#view .pill.oilp rect { stroke: color-mix(in srgb, var(--x-c98a2a, #c98a2a) 60%, transparent); } #view .pill.oilp text { fill: var(--x-8a5a0e, #8a5a0e); }

/* theme-auto:start · generated by scripts/theme/hexmap.py: dark values (the rule of scripts/theme/colour.py) for
   colours that are not tokens, written as var(--x-rrggbb, #rrggbb): light is the fallback, unchanged */
@media screen and (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --x-2c4a91: #81a0e0; --x-6e7177: #85827f; --x-8a5a0e: #c89e6a; --x-8f979f: #61676d; --x-b0321f: #ef8470;
    --x-b7c9bd: #3d4941; --x-c98a2a: #e9b46e; --x-e0a84a: #f1c37b; --x-e3b8b2: #71534f; --x-e3e8f1: #2c2f34;
  }
}
@media screen {
  :root[data-theme="dark"] {
    --x-2c4a91: #81a0e0; --x-6e7177: #85827f; --x-8a5a0e: #c89e6a; --x-8f979f: #61676d; --x-b0321f: #ef8470;
    --x-b7c9bd: #3d4941; --x-c98a2a: #e9b46e; --x-e0a84a: #f1c37b; --x-e3b8b2: #71534f; --x-e3e8f1: #2c2f34;
  }
}
/* theme-auto:end */
/* dark, picked by hand (after the generated block, so it wins): the failing ratings a muted brick, not the rule's
   brown-grey, so the bars still read as "too small" next to the green */
@media screen and (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --x-e3b8b2: #74403a; }
}
@media screen {
  :root[data-theme="dark"] { --x-e3b8b2: #74403a; }
}
