/* AC power practice: a rating-plate look. Warm cream board, brown-black ink, a cable-green accent for what the
   capacitor adds (Q_C, I_C) and the set code. Condensed headings like stamped plate text, tabular figures, each
   problem set on a plate with a double rule. Figures are drawn in a 250-unit box and fill their column. */
:root {
  --bg: #f3eee2; --paper: #fffdf7; --ink: #231d14; --muted: #4d4436; --line: #d6ccb6; --line2: #7a6e58;
  --accent: #0b6650; --accent-ink: #ffffff; --accent-soft: #dcefe8;
  --plate: #faf6ec;
  --ok: #1b6a37; --ok-soft: #ddf0e2; --bad: #a3261b; --bad-soft: #fbe4e1; --warn: #735000; --warn-soft: #f6ebcd;
  --head: "Avenir Next Condensed", "Roboto Condensed", "Arial Narrow", "Helvetica Neue", Arial, sans-serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --r: 3px; --r2: 8px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16140f; --paper: #1f1c16; --ink: #efe8d8; --muted: #c2b8a3; --line: #3b3529; --line2: #8a7f69;
    --accent: #5fd3b4; --accent-ink: #0b211b; --accent-soft: #163a31;
    --plate: #24201a;
    --ok: #7fd39b; --ok-soft: #16301f; --bad: #ff9b8f; --bad-soft: #3d1f1b; --warn: #efc46a; --warn-soft: #382e15;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.55 var(--sans); }
.wrap { max-width: 1060px; margin: 0 auto; padding: 0 16px; }
a { color: var(--accent); }
.skip { position: absolute; left: -999px; top: 8px; background: var(--paper); padding: 8px 12px; z-index: 9; }
.skip:focus { left: 8px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--head); line-height: 1.15; font-weight: 700; font-stretch: condensed; }
sub { font-size: 0.8em; line-height: 0; }

/* hero */
.hero { padding: 22px 0 4px; }
.hero h1 { font-size: clamp(1.75rem, 5vw, 2.6rem); margin: 0 0 8px; letter-spacing: -0.01em; }
.lede { margin: 4px 0 0; max-width: 66ch; color: var(--muted); }
.safe { margin: 8px 0 0; font-weight: 600; }

/* setup */
.setup { margin: 14px 0 10px; display: grid; gap: 10px; }
.setrow { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; }
.inline { display: inline-flex; gap: 8px; align-items: center; font-weight: 600; }
select, input { font: inherit; font-size: 16px; color: var(--ink); background: var(--paper); border: 1px solid var(--line2); border-radius: var(--r); }
select { min-height: 44px; padding: 6px 10px; max-width: 100%; }
.btn { font: inherit; min-height: 44px; padding: 8px 16px; border-radius: var(--r2); border: 1px solid var(--ink); background: var(--paper); color: var(--ink); cursor: pointer; font-weight: 600; }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.btn.small { padding: 6px 14px; }
.btn:hover { filter: brightness(0.96); }
.link { font: inherit; background: none; border: 0; color: var(--accent); text-decoration: underline; cursor: pointer; padding: 10px 4px; min-height: 44px; }
.note { margin: 8px 0; padding: 10px 12px; background: var(--warn-soft); border-radius: var(--r); }
#store-note { overflow-wrap: anywhere; }
.note.info { background: var(--paper); border: 1px solid var(--line); }
@media (max-width: 600px) {
  .hero { padding-top: 12px; }
  .setup { gap: 6px; margin-top: 8px; }
  .sheet { padding: 12px 10px 14px; }
}

/* the sheet */
.sheet { background: var(--paper); border: 1px solid var(--line2); box-shadow: inset 0 0 0 3px var(--paper), inset 0 0 0 4px var(--line); border-radius: var(--r2); padding: 14px 18px 16px; margin: 10px 0 18px; }
.sheet:focus { outline: none; }
.sheet-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 16px; }
.sheet-head h2 { margin: 0; font-size: 1.4rem; }
.code { font-family: var(--mono); letter-spacing: 0.08em; color: var(--accent); }
.lvname { font-family: var(--sans); font-size: 1rem; font-weight: 400; color: var(--muted); }
.score { margin: 0; color: var(--muted); }
.rules { margin: 6px 0 2px; }
.rules summary, .work summary, .recent summary, .faq summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; gap: 8px; font-weight: 600; list-style: none; }
.rules summary::-webkit-details-marker, .work summary::-webkit-details-marker, .recent summary::-webkit-details-marker, .faq summary::-webkit-details-marker { display: none; }
.rules summary::before, .work summary::before, .recent summary::before, .faq summary::before { content: ""; flex: none; width: 0; height: 0; border-style: solid; border-width: 5px 0 5px 8px; border-color: transparent transparent transparent currentColor; }
.rules[open] > summary::before, .work[open] > summary::before, .recent[open] > summary::before, .faq[open] > summary::before { transform: rotate(90deg); }
.rules ul { margin: 4px 0 8px; padding-left: 20px; max-width: 80ch; }
.rules li { margin: 0 0 4px; }
.src { margin: 0 0 8px; color: var(--muted); max-width: 80ch; }
.qs { list-style: none; margin: 0; padding: 0; }
.q { padding: 14px 0 6px; border-top: 3px double var(--line2); margin-top: 12px; }
.q:first-child { margin-top: 6px; }
.qhead { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 16px; margin: 0 0 6px; }
.qhead .see { font-weight: 600; }
.q h3 { margin: 0; font-size: 1.3rem; display: flex; gap: 10px; align-items: baseline; }
.qn { font-family: var(--mono); color: var(--paper); background: var(--ink); border-radius: 2px; padding: 0 7px; font-size: 1rem; }
.scen { margin: 0 0 10px; max-width: 75ch; }

/* figures: drawn in a 250-unit box, shown at the full width of the column (at least 250 px on a 320 px phone) and at
   most 1.4 times larger; never a sideways scroll */
.figs { display: flex; flex-wrap: wrap; gap: 6px 28px; margin: 0 0 10px; }
.fw { margin: 0; min-width: 0; flex: 1 1 250px; max-width: 350px; overflow: hidden; }
.fw figcaption { color: var(--muted); }
svg.fig { display: block; width: 100%; height: auto; font-family: var(--sans); }
svg.fig text { font-size: 16px; fill: var(--ink); paint-order: stroke; stroke: var(--paper); stroke-width: 4px; stroke-linejoin: round; }
svg.fig .sb { font-size: 15px; }
svg.fig .uk { fill: var(--accent); font-weight: 700; }
svg.fig .ln { stroke: var(--ink); stroke-width: 1.8; fill: none; }
svg.fig .ah { fill: var(--ink); stroke: none; }
svg.fig .ln.lp, svg.fig .ln.lq, svg.fig .ln.ls { stroke-width: 2.4; }
svg.fig .ln.ls2 { stroke-width: 1.8; stroke-dasharray: 6 4; }
svg.fig .ln.lqc, svg.fig .ln.uk { stroke: var(--accent); stroke-width: 3.6; }
svg.fig .ah.uk { fill: var(--accent); }
svg.fig .ln.dim { stroke: var(--muted); stroke-width: 1.2; }
svg.fig .ln.dash { stroke-dasharray: 5 4; }
svg.fig .ln.plate { stroke-width: 3; }
svg.fig .arc { stroke: var(--muted); stroke-width: 1.4; fill: none; }
svg.fig .box { fill: var(--paper); stroke: var(--ink); stroke-width: 1.8; }
svg.fig .dot { fill: var(--ink); }
svg.fig .cur { stroke-width: 1.4; }

/* answer rows */
.ans { display: grid; gap: 2px; margin: 6px 0 4px; }
.arow { display: grid; grid-template-columns: minmax(0, 20em) minmax(0, 1fr); align-items: center; gap: 4px 14px; padding: 3px 0; }
.alab { font-weight: 600; }
.sym { font-family: var(--mono); font-weight: 400; white-space: nowrap; }
.aval { display: inline-flex; align-items: center; gap: 6px; min-width: 0; max-width: 100%; }
.eqs { font-family: var(--mono); color: var(--muted); }
.u { font-family: var(--mono); color: var(--muted); white-space: nowrap; }
.asel .aval { display: flex; width: 100%; }
@media (max-width: 640px) { .arow { grid-template-columns: minmax(0, 1fr); gap: 2px; padding: 4px 0; } }
input.cell { min-height: 44px; padding: 6px 8px; text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; max-width: 100%; width: calc(var(--w, 9) * 1ch + 22px); }
.cell.is-right { border-color: var(--ok); background: var(--ok-soft); box-shadow: inset 0 0 0 1px var(--ok); }
.cell.is-wrong, .cell.is-unread { border-color: var(--bad); background: var(--bad-soft); box-shadow: inset 0 0 0 1px var(--bad); }
.cell.is-close { border-color: var(--warn); background: var(--warn-soft); box-shadow: inset 0 0 0 1px var(--warn); }
.cell.is-own { border-color: var(--warn); border-style: dashed; box-shadow: inset 0 0 0 1px var(--warn); }
.cwopts { display: flex; align-items: flex-start; gap: 6px; width: 100%; }
.cwopts .mk { align-self: flex-start; margin-top: 12px; }
.opts { flex: 1 1 auto; display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.opt { display: flex; align-items: flex-start; gap: 10px; min-height: 44px; padding: 9px 12px; border: 1px solid var(--line2); border-radius: var(--r2); background: var(--paper); cursor: pointer; min-width: 0; }
.opt input.cell { flex: none; width: 20px; height: 20px; min-height: 0; margin: 2px 0 0; padding: 0; border: 0; background: none; box-shadow: none; accent-color: var(--ink); cursor: pointer; }
.opt:has(input:checked) { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.opts.is-right .opt:has(input:checked) { border-color: var(--ok); background: var(--ok-soft); box-shadow: inset 0 0 0 1px var(--ok); }
.opts.is-wrong .opt:has(input:checked), .opts.is-unread .opt:has(input:checked) { border-color: var(--bad); background: var(--bad-soft); box-shadow: inset 0 0 0 1px var(--bad); }

/* feedback */
.fbwrap { margin: 6px 0; }
.fbl { margin: 4px 0; padding: 0 0 0 2.2em; max-width: 78ch; }
.fb { margin: 4px 0; padding: 6px 10px; border-radius: var(--r); background: var(--bad-soft); max-width: 78ch; }
.fbl .fb::marker { font-weight: 700; }
.fb.right { background: var(--ok-soft); }
.fb.close { background: var(--warn-soft); }
.fb.own { background: var(--paper); border: 1px dashed var(--warn); }
.fb.empty { background: var(--paper); border: 1px solid var(--line); }
.cw { display: inline-flex; align-items: center; gap: 3px; max-width: 100%; min-width: 0; }
.cw > .cell { flex: none; }
.mk { flex: none; min-width: 1.2em; font-weight: 700; font-size: 1.1rem; line-height: 1; white-space: nowrap; }
.mk:empty { min-width: 0; }
/* the note number sits raised and in brackets after the mark, so "✗(3)" never reads as "× 3" */
.mn { font-size: 1rem; font-weight: 400; vertical-align: 0.45em; margin-left: 0.15em; }
.mk-right { color: var(--ok); }
.mk-close, .mk-own { color: var(--warn); }
.mk-wrong, .mk-unread { color: var(--bad); }
.qfoot { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 6px 0; }
.work { margin: 4px 0 8px; }
.keyfig { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.kans { list-style: none; margin: 4px 0; padding: 0; display: grid; gap: 2px 24px; grid-template-columns: repeat(auto-fill, minmax(16em, 1fr)); }
.kn { color: var(--muted); }
.kv { font-family: var(--mono); white-space: nowrap; }
.steps { margin: 4px 0 8px; padding-left: 2.2em; font-family: var(--mono); font-size: 1rem; max-width: 92ch; }
.steps li { margin: 3px 0; overflow-wrap: anywhere; }

.sheet-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-top: 10px; padding-top: 10px; border-top: 3px double var(--line2); }
.confirm { flex-basis: 100%; margin: 0; padding: 10px; background: var(--warn-soft); border-radius: var(--r); }
.save-hint { flex-basis: 100%; margin: 0; color: var(--muted); }

/* print and share */
.share { margin: 0 0 24px; }
.print-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.print-row label { display: inline-flex; gap: 8px; align-items: center; font-weight: 600; flex-wrap: wrap; }
.share-out label { display: grid; gap: 4px; font-weight: 600; }
.share-out input { width: 100%; min-height: 44px; padding: 6px 10px; font-family: var(--mono); }
.recent { margin-top: 12px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); padding: 4px 12px; }
.recent ul { list-style: none; margin: 0; padding: 0; }
.recent li { display: flex; justify-content: space-between; gap: 10px; align-items: center; border-top: 1px solid var(--line); padding: 6px 0; }
.recent .when { display: block; color: var(--muted); }
.hint { color: var(--muted); }

/* content */
.content { max-width: 75ch; padding-bottom: 20px; }
.content h2 { font-size: 1.55rem; margin: 28px 0 8px; }
.flist { padding-left: 20px; }
.flist li { margin: 0 0 4px; }
.faq details { border-bottom: 1px solid var(--line); }
.faq details p { margin: 0 0 12px; }
.sources { color: var(--muted); overflow-wrap: anywhere; }
footer { border-top: 3px double var(--line2); padding: 18px 0 30px; color: var(--muted); }
.indep { margin: 0 0 10px; }
.sb-footer p { margin: 6px 0; }
.sb-more { line-height: 1.8; }
.sb-more a { color: var(--muted); }
.sb-credit a { color: var(--accent); }

.toast { position: fixed; left: 50%; bottom: 16px; transform: translate(-50%, 140%); background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: var(--r2); max-width: min(92vw, 560px); z-index: 20; pointer-events: none; transition: transform 0.2s; }
.toast.on { transform: translate(-50%, 0); }
.toast.top { top: 16px; bottom: auto; transform: translate(-50%, -140%); }
.toast.top.on { transform: translate(-50%, 0); }
@media (max-width: 600px) {
  .toast { left: 8px; right: 8px; bottom: 8px; max-width: none; text-align: center; transform: translateY(140%); }
  .toast.top { top: 8px; bottom: auto; transform: translateY(-140%); }
  .toast.on, .toast.top.on { transform: none; }
}
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }
[hidden] { display: none !important; }
.print-root { display: none; }

/* ---------- print ---------- */
@page { margin: 12mm; }
@media print {
  :root { --ink: #000; --muted: #333; --line: #888; --line2: #444; --paper: #fff; --bg: #fff; --accent: #000; --plate: #fff; }
  body { background: #fff; color: #000; font: 10.5pt/1.35 var(--sans); }
  main, footer, .skip, .toast { display: none !important; }
  .print-root { display: block; }
  .psheet, .pkey { break-after: page; }
  .pkey:last-child, .psheet:last-child { break-after: auto; }
  table.pt { width: 100%; border-collapse: collapse; }
  .pt > thead .prun { font-size: 9.5pt; color: #222; padding-bottom: 4px; border-bottom: 0.5pt solid #888; text-align: left; font-weight: 400; }
  .psafe { display: block; font-weight: 700; color: #000; }
  .ph { display: flex; justify-content: space-between; align-items: baseline; gap: 6pt 12pt; flex-wrap: wrap; margin-bottom: 4pt; }
  .ph h2 { margin: 4px 0 0; font-size: 15pt; }
  .pmeta { display: flex; gap: 14pt; margin: 0; }
  .prules { margin: 4px 0 6px; padding-left: 14pt; font-size: 10pt; columns: 2; column-gap: 18pt; }
  .prules li { margin: 0 0 2px; break-inside: avoid; }
  .pq, .pk { list-style: none; margin: 0; padding: 0; }
  .pq > li { margin: 0 0 8pt; padding-top: 6pt; border-top: 1.2pt solid #000; break-inside: avoid; }
  .pk > li { margin: 0 0 8pt; padding-top: 4pt; border-top: 1pt solid #000; break-inside: avoid; }
  /* nothing may hang below the last problem: a few points of margin past the page end open a page that holds only the
     repeated running header */
  .pq > li:last-child, .pk > li:last-child, .pt > tbody td > :last-child { margin-bottom: 0; }
  .pt > tbody td { padding: 0; }
  .pq h3, .pk h3 { font-size: 12pt; margin: 0 0 3pt; break-after: avoid; }
  .scen { margin: 0 0 4pt; max-width: none; }
  .figs { gap: 4pt 18pt; margin: 0 0 4pt; flex-wrap: nowrap; }
  .fw { flex: 0 0 auto; width: 2.35in; max-width: none; break-inside: avoid; }
  .pk .fw { width: 2.1in; }
  .pk .figs { flex-wrap: wrap; }
  .fw figcaption { font-size: 9pt; color: #222; }
  svg.fig text { fill: #000; stroke: #fff; }
  svg.fig .ln, svg.fig .ln.lqc, svg.fig .ln.uk { stroke: #000; }
  svg.fig .ah, svg.fig .ah.uk, svg.fig .dot { fill: #000; }
  svg.fig .uk { fill: #000; }
  svg.fig .box { fill: #fff; stroke: #000; }
  .ans { display: grid; grid-template-columns: 1fr 1fr; gap: 3pt 18pt; margin: 4pt 0 0; }
  .arow { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 6pt; padding: 0; break-inside: avoid; }
  .arow .alab { font-weight: 400; }
  .arow .aval { gap: 3pt; }
  .arow .sym { font-family: inherit; }
  .arow .u { display: inline-block; min-width: 2.3em; }
  .pblank { display: inline-block; width: 0.95in; border-bottom: 0.75pt solid #000; height: 16pt; }
  .popts { display: inline-flex; gap: 4pt; }
  .psheet .asel .alab::after { content: " (circle one)"; color: #333; }
  .keyfig { display: block; }
  .kans { grid-template-columns: 1fr 1fr; gap: 0 14pt; font-size: 10pt; margin: 0 0 2pt; }
  .steps { font-size: 9.5pt; margin: 0 0 3pt; padding-left: 18pt; max-width: none; }
  .steps li { margin: 0.5pt 0; break-inside: avoid; }
  * { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}
