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

/* the step test */
.pd-ax { fill: none; stroke: var(--steel-500); stroke-width: 1; }
.pd-t0 { fill: none; stroke: var(--steel-350); stroke-width: 1; stroke-dasharray: 3 3; }
.pd-u { fill: none; stroke: var(--x-b0421f, #b0421f); stroke-width: 1.8; stroke-linejoin: round; }
.pd-y { fill: none; stroke: var(--x-2b5ea7, #2b5ea7); stroke-width: 2.2; stroke-linejoin: round; }
.pd-dots { fill: none; stroke: var(--steel-550); stroke-width: 3.6; stroke-linecap: round; }
.pd-fin { fill: none; stroke: var(--steel-500); stroke-width: 1; stroke-dasharray: 5 4; }
.pd-guide { fill: none; stroke: var(--steel-500); stroke-width: .9; stroke-dasharray: 2 3; }
.pd-dim { fill: none; stroke: var(--text-2); stroke-width: 1.1; }
.pd-dot2 { fill: var(--surface); stroke: var(--x-2b5ea7, #2b5ea7); stroke-width: 1.6; }
.pd-lab { font-size: 11.5px; fill: var(--text-3); }
.pd-pct { font-size: 11px; fill: var(--text-3); font-variant-numeric: tabular-nums; }
.pd-tick { font-size: 11px; fill: var(--text-3); font-variant-numeric: tabular-nums; }

/* pills */
#view .pill rect, .pd-gains .pill rect { fill: var(--surface); stroke: var(--steel-300); }
#view .pill text, .pd-gains .pill text { font-size: 11.5px; font-weight: 500; fill: var(--text-2); font-variant-numeric: tabular-nums; }
#view .pill.eq rect, .pd-gains .pill.eq rect { stroke: rgba(23, 24, 26, .3); }
#view .pill.eq text, .pd-gains .pill.eq text { fill: var(--text); 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; }
.pd-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); }
.pd-edit input { width: 82px; border: 0; outline: none; font: inherit; font-size: 13px; text-align: right; font-variant-numeric: tabular-nums; padding: 3px 2px; }
.pd-edit span { font-size: 11.5px; color: var(--text-3); white-space: nowrap; }

/* live strip and flags */
.pd-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; }
.pd-live b { font-weight: 500; color: var(--text-3); margin-right: 5px; }
.pd-live i { font-style: normal; color: var(--text-3); }
.pd-flags { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.pd-flags span { font-size: 11.5px; color: var(--text-3); border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; white-space: nowrap; line-height: 1.4; }
.pd-flags span.bad, .pd-flags span.pd-err { color: var(--bad-ink, #b83225); border-color: color-mix(in srgb, var(--bad) 35%, transparent); white-space: normal; }

/* panel */
.pd-seg { margin-bottom: 6px; }
.pd-chips { display: flex; flex-wrap: wrap; gap: 4px; margin: 2px 0 6px; }
.pd-chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 2px 10px; font-size: 12px; color: var(--text-2); cursor: pointer; font-variant-numeric: tabular-nums; }
.pd-chip:hover { border-color: var(--line-2); }
.pd-chip.on { border-color: var(--text); color: var(--text); font-weight: 500; }
.pd-check { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-2); margin: 6px 0; cursor: pointer; }
.pd-check input { margin: 0; }
.pd-warn { color: var(--bad-ink, #b83225); }
.pd-data { width: 100%; box-sizing: border-box; border: 1px solid var(--line); border-radius: 7px; padding: 6px 8px; font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--text); resize: vertical; margin-bottom: 6px; }
.pd-data:hover { border-color: var(--line-2); }
.pd-data.bad { border-color: var(--bad); }
.linkb { border: 0; background: none; padding: 0; color: var(--sel); cursor: pointer; font: inherit; text-decoration: underline; }
#panel input.bad { color: var(--bad); }
#panel .num:has(input.bad) input { border-color: var(--bad); }
#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 */
.pd-say { margin-top: 6px; font-size: 12.5px; color: var(--text-2); line-height: 1.4; max-width: 38ch; }
.pd-big { font-weight: 600; color: var(--x-2b5ea7, #2b5ea7); }
.pd-stats .v small { font-size: 12px; color: var(--text-3); font-weight: 400; }

/* charts and the gain knobs */
.pd-two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
#respChart, #bodeChart { touch-action: none; user-select: none; }
.pd-gains { display: block; width: 100%; height: auto; margin-top: 6px; user-select: none; touch-action: none; overflow: hidden; }
.pd-track { fill: none; stroke: var(--line-2); stroke-width: 3; stroke-linecap: round; }
.pd-tk { fill: none; stroke: var(--steel-350); stroke-width: 1; }
.pd-rt { fill: none; stroke: var(--steel-400); stroke-width: 2; stroke-linecap: round; }
.pd-rt.cur { stroke: var(--x-2b5ea7, #2b5ea7); stroke-width: 2.4; }
.pd-gname { font-size: 13px; font-weight: 600; fill: var(--text-2); }
.pd-off { font-size: 11.5px; fill: var(--text-3); }
.pd-leg { font-size: 11px; fill: var(--text-3); }
.pd-hitline { fill: none; stroke: none; stroke-width: 14; pointer-events: stroke; }
#checks td.note { white-space: normal; min-width: 200px; line-height: 1.4; }

/* rules table */
.pd-rules { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.pd-rules th { font-size: 11.5px; font-weight: 500; color: var(--text-3); text-align: right; padding: 0 8px 6px; white-space: nowrap; }
.pd-rules th.l, .pd-rules td.l { text-align: left; }
.pd-rules td { padding: 7px 8px; border-top: 1px solid var(--line); text-align: right; white-space: nowrap; }
.pd-rules td.note { white-space: normal; color: var(--text-3); font-size: 12px; }
.pd-rules tr[data-rule]:not(.dis) { cursor: pointer; }
.pd-rules tr[data-rule]:not(.dis):hover td { background: var(--bg); }
.pd-rules tr.sel td { background: var(--x-eef3fe, #eef3fe); }
.pd-rules tr.sel td:first-child { font-weight: 600; }
.pd-rules tr.dis td { color: var(--text-3); }
.pd-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; line-height: 1.5; font-weight: 400; }

@media (max-width: 1100px) { .pd-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; }
  .pd-rules thead { display: none; }
  .pd-rules, .pd-rules tbody { display: block; width: 100%; }
  .pd-rules tr { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 2px 8px; padding: 9px 4px; border-top: 1px solid var(--line); }
  .pd-rules td { border: 0; padding: 0; text-align: left; white-space: normal; font-size: 12.5px; }
  .pd-rules td:first-child { grid-column: 1 / 4; }
  .pd-rules td:last-child { grid-column: 4; grid-row: 1; text-align: right; }
  .pd-rules td:nth-child(2)::before { content: "Kc "; color: var(--text-3); }
  .pd-rules td:nth-child(3)::before { content: "Ti "; color: var(--text-3); }
  .pd-rules td:nth-child(4)::before { content: "Td "; color: var(--text-3); }
  .pd-rules td:nth-child(5)::before { content: "GM "; color: var(--text-3); }
  .pd-rules td:nth-child(6)::before { content: "PM "; color: var(--text-3); }
  .pd-rules td:nth-child(7)::before { content: "Ms "; color: var(--text-3); }
  .pd-rules td:nth-child(8)::before { content: "OS "; color: var(--text-3); }
  .pd-rules td:nth-child(9)::before { content: "IAE "; color: var(--text-3); }
  .pd-rules tr.dis td.note { grid-column: 1 / -1; }
}
@media print { .pd-edit { display: none !important; } }

/* 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-2b5ea7: #79a5e5; --x-6e7177: #85827f; --x-7a5aa6: #b59bde; --x-b0321f: #ef8470; --x-b0421f: #eb8c6f;
    --x-eef3fe: #25282f;
  }
}
@media screen {
  :root[data-theme="dark"] {
    --x-2b5ea7: #79a5e5; --x-6e7177: #85827f; --x-7a5aa6: #b59bde; --x-b0321f: #ef8470; --x-b0421f: #eb8c6f;
    --x-eef3fe: #25282f;
  }
}
/* theme-auto:end */
