/* Design Blocks: Design help tab. Everything is scoped under .dh; colours inherit from the page. */
.dh {
  --dh-accent: #2563eb; --dh-line: rgba(127, 127, 127, .28); --dh-soft: rgba(127, 127, 127, .07);
  --dh-good: #15803d; --dh-warn: #b45309; --dh-bad: #c62828;
  --dh-c1: #2563eb; --dh-c2: #d97706; --dh-c3: #0f9d58; --dh-wire: #111827;
  color: inherit; font: inherit; line-height: 1.45;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .dh { --dh-accent: #6ea8fe; --dh-good: #4ade80; --dh-warn: #fbbf24; --dh-bad: #f87171; --dh-c1: #6ea8fe; --dh-c2: #fbbf24; --dh-c3: #4ade80; --dh-wire: #e5e7eb; } }
:root[data-theme="dark"] .dh { --dh-accent: #6ea8fe; --dh-good: #4ade80; --dh-warn: #fbbf24; --dh-bad: #f87171; --dh-c1: #6ea8fe; --dh-c2: #fbbf24; --dh-c3: #4ade80; --dh-wire: #e5e7eb; }
/* a host page with its own dark class can set the same variables on .dh */
.dh *, .dh *::before, .dh *::after { box-sizing: border-box; }
.dh h3 { margin: 0 0 4px; font-size: 1.25em; }
.dh h4 { margin: 0 0 10px; font-size: 1em; }
.dh-hide { display: none; }
.dh-muted { opacity: .72; }
.dh-good { color: var(--dh-good); font-weight: 600; }
.dh-bad { color: var(--dh-bad); font-weight: 600; }

.dh-lib { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 8px 12px; margin-bottom: 14px; border: 1px solid var(--dh-line); border-radius: 8px; background: var(--dh-soft); font-size: .92em; }
.dh-dot2 { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.dh-dot2.dh-on { background: var(--dh-good); } .dh-dot2.dh-off { background: var(--dh-warn); }
.dh-btn { font: inherit; font-size: .92em; padding: 4px 10px; border-radius: 6px; border: 1px solid var(--dh-line); background: transparent; color: inherit; cursor: pointer; }
.dh-btn:hover { border-color: var(--dh-accent); }

.dh-body { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 20px; align-items: start; }
.dh-nav { position: sticky; top: 8px; display: flex; flex-direction: column; gap: 2px; }
.dh-ng { font-size: .75em; text-transform: uppercase; letter-spacing: .06em; opacity: .6; margin: 12px 8px 4px; }
.dh-ng:first-child { margin-top: 0; }
.dh-nb { display: block; text-align: left; white-space: normal; font: inherit; font-weight: 500; padding: 7px 10px; border: 0; border-radius: 6px; background: transparent; color: inherit; cursor: pointer; }
.dh-nb:hover { background: var(--dh-soft); }
.dh-nb.dh-act { background: var(--dh-accent); color: #fff; }
.dh-main { min-width: 0; }
.dh-blurb { margin: 0 0 14px; opacity: .8; max-width: 70ch; }

.dh-card { border: 1px solid var(--dh-line); border-radius: 10px; padding: 14px; margin-bottom: 14px; }
.dh-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px 14px; }
.dh-f { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.dh-f > label { font-size: .85em; opacity: .85; }
.dh-wide { grid-column: 1 / -1; }
.dh-fc { flex-direction: row; align-items: center; gap: 8px; font-size: .92em; cursor: pointer; }
.dh-in { display: flex; align-items: stretch; border: 1px solid var(--dh-line); border-radius: 6px; overflow: hidden; }
.dh-in:focus-within { border-color: var(--dh-accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--dh-accent) 25%, transparent); }
.dh-in input, .dh-in select { flex: 1; width: 100%; min-width: 0; font: inherit; padding: 6px 8px; border: 0; border-radius: 0; background: transparent; color: inherit; outline: none; }
.dh-in select option { color: #111; }
.dh-u { padding: 6px 8px; font-size: .85em; opacity: .7; background: var(--dh-soft); white-space: nowrap; display: flex; align-items: center; }
.dh-hint { font-size: .78em; opacity: .62; }
.dh-tip { margin-top: 10px; font-size: .8em; opacity: .62; }

.dh-kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; margin-bottom: 12px; }
.dh-kv-i { border: 1px solid var(--dh-line); border-radius: 8px; padding: 8px 10px; }
.dh-kv-l { font-size: .8em; opacity: .75; }
.dh-kv-v { font-size: 1.15em; font-weight: 600; font-variant-numeric: tabular-nums; }
.dh-kv-s { font-size: .76em; opacity: .62; }
.dh-kv-i.dh-hi { border-color: var(--dh-accent); background: color-mix(in srgb, var(--dh-accent) 7%, transparent); }
.dh-kv-i.dh-ok .dh-kv-v { color: var(--dh-good); }
.dh-kv-i.dh-warn .dh-kv-v { color: var(--dh-warn); }
.dh-kv-i.dh-bad .dh-kv-v { color: var(--dh-bad); }

.dh-note { padding: 8px 12px; border-radius: 8px; margin: 10px 0; font-size: .9em; border-left: 3px solid; background: var(--dh-soft); }
.dh-note.dh-info { border-color: var(--dh-accent); }
.dh-note.dh-warn { border-color: var(--dh-warn); }
.dh-note.dh-ok { border-color: var(--dh-good); }
.dh-sec { margin-top: 16px; }
.dh-sec p { margin: 6px 0; }

.dh-tw { overflow-x: auto; margin: 6px 0 10px; }
.dh-table { width: 100%; border-collapse: collapse; font-size: .9em; font-variant-numeric: tabular-nums; }
.dh-table th { text-align: left; font-weight: 600; font-size: .85em; opacity: .8; padding: 6px 8px; border-bottom: 1px solid var(--dh-line); white-space: nowrap; }
.dh-table td { padding: 6px 8px; border-top: 0; border-bottom: 1px solid var(--dh-line); vertical-align: top; }
.dh-table td:not(:first-child):not(:last-child) { white-space: nowrap; }
.dh-row-bad td { background: color-mix(in srgb, var(--dh-bad) 8%, transparent); }
.dh-row-ok td:first-child { box-shadow: inset 3px 0 var(--dh-good); }
.dh-part b { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .95em; }
.dh-tag { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 9px; font-size: .75em; background: color-mix(in srgb, var(--dh-good) 18%, transparent); }
.dh-pl + .dh-pl { margin-top: 3px; }

.dh-guide { border: 1px solid var(--dh-line); border-radius: 10px; padding: 0 14px; margin-bottom: 14px; }
.dh-guide > summary { cursor: pointer; padding: 12px 0; font-weight: 600; }
.dh-guide[open] > summary { border-bottom: 1px solid var(--dh-line); margin-bottom: 4px; }
.dh-guide p { max-width: 75ch; }
.dh-steps { padding-left: 1.4em; margin: 8px 0 4px; max-width: 80ch; }
.dh-steps li { margin: 4px 0; }
.dh-figs { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; margin: 8px 0; }
.dh-fig { margin: 8px 0; }
.dh-fig svg { width: 100%; height: auto; display: block; max-width: 640px; }
.dh-fig figcaption { font-size: .82em; opacity: .75; margin-top: 4px; max-width: 70ch; }
.dh-ideas { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.dh-idea { border: 1px solid var(--dh-line); border-radius: 8px; padding: 10px 12px; }
.dh-idea .dh-muted { font-size: .88em; margin-top: 2px; }

/* charts */
.dh-plot text, .dh-probe text, .dh-sch text { fill: currentColor; font: 11px system-ui, sans-serif; }
.dh-grid { stroke: var(--dh-line); stroke-width: 1; }
.dh-axis { stroke: currentColor; stroke-opacity: .5; }
.dh-tick { font-size: 10.5px; opacity: .8; }
.dh-alab { font-size: 11px; opacity: .85; }
.dh-ser { fill: none; stroke-width: 2.2; stroke-linejoin: round; }
.dh-s1 { stroke: var(--dh-c1); fill: var(--dh-c1); } .dh-ser.dh-s1 { fill: none; }
.dh-s2 { stroke: var(--dh-c2); fill: var(--dh-c2); } .dh-ser.dh-s2 { fill: none; }
.dh-ref { stroke: currentColor; stroke-opacity: .55; stroke-dasharray: 5 4; }
.dh-ref.dh-r1, .dh-rlab.dh-r1 { stroke: var(--dh-c3); fill: var(--dh-c3); stroke-opacity: .9; }
.dh-ref.dh-r2, .dh-rlab.dh-r2 { stroke: var(--dh-c2); fill: var(--dh-c2); stroke-opacity: .9; }
.dh-rlab { font-size: 10.5px; stroke: none !important; }

/* scope pictures: fixed colours, they show an instrument screen */
.dh-scope text { font: 11px ui-monospace, Menlo, Consolas, monospace; }
.dh-scr { fill: #0d1714; }
.dh-sg { stroke: #2b3d36; stroke-width: 1; } .dh-sgc { stroke: #3d5a4f; }
.dh-trace { fill: none; stroke: #ffd43b; stroke-width: 2; }
.dh-cur { stroke: #4dd4ff; stroke-dasharray: 4 3; }
.dh-cur2 { stroke: #8a9a94; stroke-dasharray: 2 4; }
.dh-arw { stroke: #4dd4ff; } .dh-arh { fill: #4dd4ff; }
.dh-stx { fill: #cfe8de; }
.dh-scope .dh-tick { fill: currentColor; }

/* probe and schematic drawings */
.dh-pcb { fill: #2e7d4f; fill-opacity: .16; stroke: #2e7d4f; stroke-opacity: .6; }
.dh-ic { fill: rgba(127, 127, 127, .25); stroke: currentColor; stroke-opacity: .6; }
.dh-pad { fill: #c9a227; stroke: #8a6d10; }
.dh-pbody { fill: #4b5563; stroke: #1f2937; } .dh-pbar { fill: #9ca3af; stroke: #4b5563; }
.dh-ptip { stroke: #9ca3af; stroke-width: 3; stroke-linecap: round; }
.dh-gnd-ok { fill: none; stroke: #16a34a; stroke-width: 3; stroke-linecap: round; }
.dh-gnd-bad { fill: none; stroke: var(--dh-wire); stroke-width: 2.5; }
.dh-loop { fill: #dc2626; fill-opacity: .14; stroke: none; }
.dh-okc { fill: #16a34a; } .dh-okm { fill: none; stroke: #fff; stroke-width: 3; }
.dh-badc { fill: #dc2626; } .dh-badm { fill: none; stroke: #fff; stroke-width: 3; }
.dh-plab { font-size: 11px; }
.dh-w { fill: none; stroke: currentColor; stroke-width: 1.6; }
.dh-dot { fill: currentColor; }
.dh-par { stroke: #d97706; stroke-dasharray: 4 3; } .dh-parl { fill: #d97706 !important; }
.dh-snb { stroke: #2563eb; } .dh-res.dh-snb { fill: none; stroke-width: 1.6; } .dh-snbl { fill: #2563eb !important; }
.dh-hot { fill: none; stroke: #dc2626; stroke-width: 1.4; stroke-dasharray: 6 4; } .dh-hotl { fill: #dc2626 !important; }

@media (max-width: 760px) {
  .dh-body { grid-template-columns: 1fr; gap: 10px; }
  .dh-nav { position: static; flex-direction: row; overflow-x: auto; gap: 6px; padding-bottom: 6px; -webkit-overflow-scrolling: touch; }
  .dh-ng { display: none; }
  .dh-nb { white-space: nowrap; border: 1px solid var(--dh-line); border-radius: 18px; padding: 6px 12px; flex: none; }
  .dh-form { grid-template-columns: 1fr 1fr; }
  .dh-kv { grid-template-columns: 1fr 1fr; }
  .dh-card { padding: 12px; }
}
@media (max-width: 420px) { .dh-form, .dh-kv { grid-template-columns: 1fr; } }

/* help-pack tools */
.dh-pk { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: -6px 0 14px; font-size: .88em; }
.dh-tag2 { display: inline-block; padding: 1px 8px; border-radius: 9px; border: 1px solid var(--dh-accent); color: var(--dh-accent); font-size: .85em; font-weight: 600; }
.dh-note.dh-bad { border-color: var(--dh-bad); }
.dh-note.dh-bad, .dh-note.dh-bad * { }
.dh-calc { margin-top: 14px; }
.dh-calc > summary { cursor: pointer; font-weight: 600; padding: 6px 0; }
.dh-expr { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85em; white-space: pre-wrap; word-break: break-word; }
.dh-table td .dh-expr { white-space: normal; }
.dh-pkfig { width: 100%; height: auto; max-width: 680px; display: block; }
.dh-sec ul.dh-steps { list-style: disc; }
/* 1.15: formulas and calculation, form sections, drawings, comparison, PDF */
.dh-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; margin-bottom: 4px; }
.dh-head h3 { margin: 0; }
.dh-pdfbtn { font-weight: 600; }
.dh-fsec { margin: 6px 0 -2px; padding-top: 8px; border-top: 1px solid var(--dh-line); font-size: .78em; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; opacity: .75; }
.dh-fsec:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.dh-calct td { vertical-align: top; }
.dh-table.dh-calct td:nth-child(2), .dh-table.dh-calct td:nth-child(3) { white-space: normal; min-width: 12ch; }
.dh-subst { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .82em; opacity: .85; word-break: break-word; }
.dh-calcnote { display: block; font-size: .82em; margin-top: 2px; }
.dh-table.dh-reft td, .dh-table.dh-reft td:not(:first-child):not(:last-child) { white-space: normal; vertical-align: top; }
.dh-row-cur td:first-child { box-shadow: inset 3px 0 var(--dh-accent); }
.dh-dwgfig { margin: 14px 0; }
.dh-dwgcap { font-weight: 600; margin: 0 0 6px; text-align: left; }
.dh-dwgbox { overflow-x: auto; border-radius: 8px; background: #fff; }
.dh-dwgbox svg.dh-dwg { display: block; width: 100%; min-width: 640px; height: auto; }
/* off-screen copy used to read light-mode colours for the PDF */
:root:not(#dh-x) .dh.dh-print { --dh-accent: #2563eb; --dh-good: #15803d; --dh-warn: #b45309; --dh-bad: #c62828; --dh-c1: #2563eb; --dh-c2: #d97706; --dh-c3: #0f9d58; --dh-wire: #111827; color: #111; background: #fff;
  position: fixed; left: -10000px; top: 0; width: 900px; pointer-events: none; }

/* PDF section chooser (dh-pdf.js), used by Design help and Lumen Pick */
.dhp-choose { position: absolute; z-index: 60; background: var(--surface, #fff); color: var(--ink, #16202b); border: 1px solid rgba(127,127,127,.35); border-radius: 10px; padding: 12px 14px; box-shadow: 0 10px 30px rgba(0,0,0,.25); font-size: 14px; }
.dhp-choose .dhp-t { font-weight: 600; margin-bottom: 6px; }
.dhp-choose label { display: flex; gap: 8px; align-items: center; padding: 3px 0; cursor: pointer; }
.dhp-choose .dhp-b { display: flex; gap: 6px; margin-top: 10px; align-items: center; flex-wrap: wrap; }
.dhp-choose button { font: inherit; font-size: 13px; padding: 4px 10px; border-radius: 6px; border: 1px solid rgba(127,127,127,.4); background: transparent; color: inherit; cursor: pointer; }
.dhp-choose button.primary { background: var(--dh-accent, #2563eb); border-color: var(--dh-accent, #2563eb); color: #fff; }
