/* Layout: lecture-notes column (76ch reading measure) between a sticky contents rail and a right margin for line illustrations (≥1280px). Cards, widgets and examples get soft modern surfaces; running text keeps its plain, high-contrast setting. */
:root {
  --bg: #F4F6F9;          /* cool drafting-paper white */
  --surface: #FFFFFF;
  --surface-2: #F9FAFC;
  --ink: #17202A;
  --muted: #586473;
  --rule: #D8DEE6;
  --accent: #2147A6;      /* fountain-pen blue: velocity, links, emphasis */
  --accent-soft: #E8EEFB;
  --force: #C23B22;       /* forces and accelerations */
  --force-soft: #FCECE8;
  --trap: #A9231A;
  --ok: #1D7149;
  --ok-soft: #E3F3EA;
  --grid: #E7ECF1;
  --shadow: 0 1px 2px rgba(23, 32, 42, 0.05), 0 6px 24px -8px rgba(23, 32, 42, 0.12);
  --radius: 14px;

  --f-display: "IBM Plex Sans", "Helvetica Neue", Arial, sans-serif;
  --f-body: "Source Serif 4", "Source Serif Pro", Georgia, "Times New Roman", serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --step--1: 0.875rem;
  --step-0: 1.0625rem;
  --step-1: 1.25rem;
  --step-2: 1.65rem;
  --step-3: clamp(2.4rem, 1.6rem + 3vw, 3.8rem);
  --measure: 76ch;
  --measure-wide: 96ch;  /* strona treningu: bez spisu treści i marginesu, same zadania */
  --carbon: none;        /* faktura splotu karbonu pod powierzchniami (tylko motyw złoto-karbon) */
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0E1318; --surface: #151C24; --surface-2: #121920; --ink: #E2E7EE; --muted: #9AA6B5; --rule: #29333F;
    --accent: #8EAEFF; --accent-soft: #1A2540; --force: #FF8A70; --force-soft: #2E1D1A;
    --trap: #FF8F80; --ok: #67CF9B; --ok-soft: #16281F; --grid: #1E2731;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 28px -10px rgba(0, 0, 0, 0.55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0E1318; --surface: #151C24; --surface-2: #121920; --ink: #E2E7EE; --muted: #9AA6B5; --rule: #29333F;
  --accent: #8EAEFF; --accent-soft: #1A2540; --force: #FF8A70; --force-soft: #2E1D1A;
  --trap: #FF8F80; --ok: #67CF9B; --ok-soft: #16281F; --grid: #1E2731;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 28px -10px rgba(0, 0, 0, 0.55);
  color-scheme: dark;
}
/* Złoto-karbon (paleta aplikacji Wilco): grafitowe tła, kremowy tekst, złoty akcent. Po bloku ciemnym, bo przy
   systemowym trybie ciemnym oba selektory pasują z tą samą specyficznością. */
:root[data-theme="gold"] {
  --bg: #0C0C0D; --surface: #17171A; --surface-2: #141416; --ink: #E7E1D3; --muted: #9A9282; --rule: #36322A;
  --accent: #D4AF37; --accent-soft: #2A2414; --force: #FF7B5C; --force-soft: #2E1A14;
  --trap: #FF7A6E; --ok: #4CC35E; --ok-soft: #14251A; --grid: #211F1A;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 8px 28px -10px rgba(0, 0, 0, 0.6);
  --gilt: linear-gradient(180deg, #F5E3A1 0%, #D4AF37 55%, #9A7724 100%);
  --carbon: repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.022) 0 4px, transparent 4px 8px),
    repeating-linear-gradient(-45deg, rgba(0, 0, 0, 0.18) 0 4px, transparent 4px 8px);
  color-scheme: dark;
}
/* pozłacane tytuły; nie przy wzorach KaTeX, bo kreski ułamków biorą kolor tekstu i zniknęłyby */
:root[data-theme="gold"] h1:not(:has(.katex)) {
  background: var(--gilt); -webkit-background-clip: text; background-clip: text; color: transparent;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--f-body); font-size: var(--step-0); line-height: 1.64;
  font-optical-sizing: auto;
}

/* reading progress */
.progress {
  position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 50;
  padding-top: env(safe-area-inset-top, 0px); pointer-events: none;
}
.progress span { display: block; height: 3px; background: var(--accent); transform-origin: 0 50%; transform: scaleX(0); }

/* ---------- page grid ---------- */
.page {
  display: grid; grid-template-columns: minmax(0, 1fr);
  padding-inline: 16px; padding-block: 0 72px;
  max-width: 1480px; margin: 0 auto; column-gap: 56px;
}
.masthead, .toc, .flow, .colophon { min-width: 0; }
@media (min-width: 680px) and (max-width: 1023.98px) {
  .page { grid-template-columns: minmax(0, var(--measure)); justify-content: center; padding-inline: 28px; }
}
@media (min-width: 1024px) {
  .page { grid-template-columns: 200px minmax(0, var(--measure)); justify-content: center; padding-inline: 32px; }
  .masthead { grid-column: 1 / -1; }
  .toc { grid-column: 1; grid-row: 2; position: sticky; top: calc(env(safe-area-inset-top, 0px) + 28px); align-self: start; }
  .flow { grid-column: 2; grid-row: 2; }
  .colophon { grid-column: 2; }
}
@media (min-width: 1280px) {
  .page { grid-template-columns: 200px minmax(0, var(--measure)) 250px; }
}

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:focus-visible, summary:focus-visible, input:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px;
}
strong { font-weight: 600; }
cite { font-style: italic; }

/* ---------- hero ---------- */
.masthead {
  position: relative; overflow: hidden; isolation: isolate;
  margin: 0 -16px 36px; padding: 56px 16px 32px;
  border-bottom: 1px solid var(--rule);
  background:
    radial-gradient(900px 380px at 85% 0%, var(--accent-soft), transparent 70%),
    linear-gradient(var(--bg), var(--bg));
}
@media (min-width: 680px) { .masthead { margin-inline: -28px; padding-inline: 28px; } }
@media (min-width: 1024px) { .masthead { margin-inline: -32px; padding: 72px 32px 40px calc(200px + 56px + 32px); } }
@media (min-width: 1280px) { .masthead { padding-right: calc(250px + 56px + 32px); } }
.hero-art {
  position: absolute; z-index: -1; right: 0; top: 16px; width: min(640px, 52%); height: auto;
  color: var(--accent); opacity: 0.6; pointer-events: none;
  -webkit-mask-image: linear-gradient(to right, transparent 0%, #000 45%); mask-image: linear-gradient(to right, transparent 0%, #000 45%);
}
@media (max-width: 1023.98px) { .hero-art { width: 70%; top: 6px; opacity: 0.4; } }
@media (max-width: 679.98px) { .hero-art { width: 92%; right: -6%; top: 4px; opacity: 0.3; } }
.hero-art .trail { fill: none; stroke: currentColor; stroke-width: 1.2; stroke-dasharray: 2 6; opacity: 0.7; }
.hero-art .ghost { fill: var(--surface); stroke: currentColor; stroke-width: 1.4; transform-box: fill-box; transform-origin: center; }
.hero-art .ball { fill: var(--accent); }
.hero-art .vec { stroke: var(--force); stroke-width: 2; }
.hero-art .vech { fill: var(--force); }
.series {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--f-display); font-size: 0.78rem; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.1em; color: var(--accent); margin: 0 0 18px;
}
.series .chip { padding: 3px 10px; border-radius: 999px; background: var(--surface); border: 1px solid var(--rule); color: var(--ink); letter-spacing: 0.06em; }
h1 {
  font-family: var(--f-display); font-weight: 600; font-size: var(--step-3);
  line-height: 1.02; letter-spacing: -0.03em; margin: 0 0 18px; text-wrap: balance; max-width: 16ch;
}
.deck { font-size: var(--step-1); line-height: 1.5; color: var(--muted); max-width: 58ch; margin: 0 0 28px; }
.meta {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px; margin: 0; max-width: 900px;
}
@media (min-width: 900px) { .meta { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.meta div {
  min-width: 0; padding: 10px 14px; border-radius: 12px; background: color-mix(in srgb, var(--surface) 82%, transparent);
  border: 1px solid var(--rule); backdrop-filter: blur(6px);
}
.meta dt { font-family: var(--f-display); font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.09em; color: var(--muted); }
.meta dd { margin: 3px 0 0; font-size: 0.92rem; line-height: 1.4; }

/* ---------- toc ---------- */
.toc { font-family: var(--f-display); font-size: 0.86rem; margin-bottom: 32px; }
.toc-title { font-weight: 600; text-transform: uppercase; letter-spacing: 0.09em; font-size: 0.7rem; color: var(--muted); margin: 0 0 10px; }
.toc ol { list-style: none; padding: 0; margin: 0; counter-reset: toc -1; display: grid; gap: 1px; }
.toc li { counter-increment: toc; }
.toc a {
  display: grid; grid-template-columns: 2.2ch 1fr; gap: 8px; padding: 5px 10px; border-radius: 8px;
  color: var(--ink); text-decoration: none; line-height: 1.35;
}
.toc a::before { content: counter(toc); color: var(--muted); font-family: var(--f-mono); font-size: 0.8em; padding-top: 0.12em; }
.toc a:hover { background: var(--surface); }
.toc a.active { background: var(--accent-soft); color: var(--accent); font-weight: 500; }
.toc a.active::before { color: var(--accent); }
@media (min-width: 1024px) {
  .toc ol { border-left: 1px solid var(--rule); padding-left: 6px; }
}
@media (max-width: 1023.98px) {
  .toc { border: 1px solid var(--rule); background: var(--surface); padding: 16px 16px 12px; border-radius: var(--radius); }
  .toc ol { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
}

/* ---------- flow ---------- */
.flow > section { margin-bottom: 84px; position: relative; }
section { scroll-margin-top: 24px; }
h2 {
  font-family: var(--f-display); font-weight: 600; font-size: var(--step-2); line-height: 1.18;
  letter-spacing: -0.015em; margin: 0 0 22px; text-wrap: balance;
  display: flex; gap: 14px; align-items: center;
}
.secnum {
  flex: none; display: inline-grid; place-items: center; width: 2.1em; height: 2.1em; border-radius: 12px;
  font-family: var(--f-mono); font-weight: 500; font-size: 0.62em; color: var(--accent);
  background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
}
h3 {
  font-family: var(--f-display); font-weight: 600; font-size: var(--step-1); line-height: 1.3;
  margin: 40px 0 10px; text-wrap: balance;
}
p { margin: 0 0 14px; }
.flow p, .flow li { hyphens: auto; }
.katex { font-size: 1.06em; }
.katex-display { margin: 18px 0; overflow-x: auto; overflow-y: hidden; padding: 4px 0; position: relative; }

/* FLP references: quiet inline chips */
.flp {
  display: inline-block; font-family: var(--f-mono); font-size: 0.68rem; line-height: 1.5; color: var(--muted); white-space: nowrap;
  border: 1px solid var(--rule); border-radius: 999px; padding: 0 7px; margin-left: 6px; vertical-align: 2px;
  background: var(--surface);
}

/* ---------- margin illustrations ---------- */
.marg { display: block; margin: 8px auto 20px; max-width: 230px; color: var(--muted); opacity: 0.85; }
@media (min-width: 1280px) {
  .marg { position: absolute; left: calc(100% + 56px); width: 236px; max-width: none; margin: 2px 0 0; opacity: 0.8; }
}
.art { display: block; width: 100%; height: auto; overflow: visible; stroke-linecap: round; stroke-linejoin: round; }
.art .k { stroke: var(--ink); } .art .a { stroke: var(--accent); } .art .f { stroke: var(--force); } .art .m { stroke: var(--muted); }
.art .fk { fill: var(--ink); } .art .fa { fill: var(--accent); } .art .ff { fill: var(--force); } .art .fs { fill: var(--accent-soft); } .art .fb { fill: var(--surface); }
.art .nostroke, .art text { stroke: none; }
.art .t { font: italic 400 15px var(--f-body); fill: var(--ink); }
.art .l { font: 400 10.5px var(--f-display); fill: var(--muted); }
.art .t.fa, .art .l.fa { fill: var(--accent); } .art .t.ff, .art .l.ff { fill: var(--force); }

/* example diagrams */
.exfig { margin: 4px auto 16px; max-width: 320px; }
.exfig figcaption { font-family: var(--f-display); font-size: 0.75rem; color: var(--muted); text-align: center; margin-top: 4px; }
@media (min-width: 680px) { .exfig { float: right; width: 40%; max-width: 270px; margin: 2px 0 12px 24px; } }

/* ---------- blocks ---------- */
.label {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--f-display); font-size: 0.72rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.09em; margin: 0 0 8px;
}
.label.ico::before {
  content: ""; flex: none; width: 15px; height: 15px; background: currentColor;
  -webkit-mask: var(--ico) center / contain no-repeat; mask: var(--ico) center / contain no-repeat;
}
.law .label { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3v18M5 7h14M3 15l2-8 2 8a2.8 2.8 0 0 1-4 0zM17 15l2-8 2 8a2.8 2.8 0 0 1-4 0zM8 21h8'/%3E%3C/svg%3E"); }
.why .label { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 3h6M10 3v6L4.5 18.5A1.7 1.7 0 0 0 6 21h12a1.7 1.7 0 0 0 1.5-2.5L14 9V3M7 15h10'/%3E%3C/svg%3E"); }
.trap .label { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3 2 20h20L12 3zM12 10v4M12 17h.01'/%3E%3C/svg%3E"); }
.method .label { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 6h11M9 12h11M9 18h11M4 6h.01M4 12h.01M4 18h.01'/%3E%3C/svg%3E"); }

.law {
  border: 1.5px solid var(--ink); background: var(--surface); padding: 16px 22px 6px; margin: 26px 0;
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.law .label { color: var(--ink); }
.law .katex-display { margin: 8px 0 12px; }
.law p:last-child { color: var(--muted); font-size: 0.95rem; }

.why { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: 16px 20px 4px; margin: 28px 0; }
.why .label { color: var(--accent); }
.why p:not(.label) { font-size: 0.97rem; }

.trap { background: var(--force-soft); border-radius: var(--radius); padding: 16px 20px 4px; margin: 26px 0; }
.trap .label { color: var(--trap); }
.trap p:not(.label) { font-size: 0.97rem; }

blockquote.feynman {
  position: relative; margin: 32px 0; padding: 4px 0 4px 26px; border-left: 2px solid var(--accent);
  font-size: var(--step-1); line-height: 1.5; font-style: italic;
}
blockquote.feynman p { margin: 0 0 8px; }
blockquote.feynman footer { font-family: var(--f-display); font-style: normal; font-size: 0.78rem; color: var(--muted); letter-spacing: 0.02em; }

.next {
  position: relative;
  font-family: var(--f-display); font-size: 0.9rem; padding: 12px 16px 12px 38px; margin-top: 26px;
  background: var(--accent-soft); color: var(--ink); border-radius: 12px;
}
.next::before { content: "→"; position: absolute; left: 16px; top: 12px; color: var(--accent); font-weight: 600; }

ol.points { padding-left: 1.4em; }
ol.points li { margin-bottom: 10px; }

/* code listings */
figure.code { margin: 22px 0; border: 1px solid var(--rule); border-radius: 12px; background: var(--surface-2); overflow: hidden; }
.code-pair { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; margin: 22px 0; }
.code-pair figure.code { margin: 0; }
figure.code figcaption { font-family: var(--f-display); font-size: 0.72rem; font-weight: 600; letter-spacing: 0.06em; color: var(--muted); padding: 7px 14px; border-bottom: 1px solid var(--rule); background: var(--surface); }
figure.code pre { margin: 0; padding: 12px 14px; overflow-x: auto; font-family: var(--f-mono); font-size: 0.8rem; line-height: 1.55; color: var(--ink); tab-size: 4; }
:not(pre) > code { font-family: var(--f-mono); font-size: 0.86em; background: var(--surface-2); border: 1px solid var(--rule); padding: 0 0.3em; border-radius: 4px; }
details figure.code { margin: 10px 0; }

/* tables */
.table-wrap { overflow-x: auto; margin: 22px 0; border: 1px solid var(--rule); border-radius: 12px; background: var(--surface); }
table { border-collapse: collapse; font-size: 0.92rem; width: 100%; }
caption { caption-side: top; text-align: left; font-family: var(--f-display); font-size: 0.78rem; color: var(--muted); padding: 10px 14px 8px; }
th, td { padding: 7px 14px; border-bottom: 1px solid var(--rule); text-align: left; vertical-align: top; }
tbody tr:last-child td, tbody tr:last-child th { border-bottom: 0; }
thead th, thead td { background: var(--surface-2); border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); font-family: var(--f-display); font-weight: 600; font-size: 0.8rem; }
table.data td, table.data th { font-family: var(--f-mono); font-variant-numeric: tabular-nums; text-align: right; font-size: 0.84rem; white-space: nowrap; }
table.data tbody th, table.data thead th:first-child { text-align: left; }
table.data tr.limit td { color: var(--accent); font-weight: 600; background: var(--accent-soft); }
table.forces td:first-child { font-weight: 600; font-family: var(--f-display); font-size: 0.88rem; }
table.map td:last-child { font-family: var(--f-mono); font-size: 0.84rem; }
.pill { display: inline-block; font-family: var(--f-display); font-size: 0.7rem; font-weight: 500; padding: 1px 9px; border-radius: 999px; border: 1px solid currentColor; white-space: nowrap; }
.pill.fund { color: var(--accent); background: var(--accent-soft); border-color: transparent; }
.pill.emp { color: var(--muted); }
.pill.constr { color: var(--force); background: var(--force-soft); border-color: transparent; }

/* ---------- widgets ---------- */
figure.widget {
  margin: 30px 0; background: var(--carbon), var(--surface); border: 1px solid var(--rule); border-radius: 18px;
  padding: 18px; box-shadow: var(--shadow);
}
@media (min-width: 1280px) { figure.widget { margin-right: -96px; } }
figure.widget figcaption { font-size: 0.93rem; color: var(--muted); margin-bottom: 14px; line-height: 1.5; }
figure.widget figcaption .label {
  display: inline-flex; margin: 0 8px 0 0; padding: 3px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent);
  font-size: 0.68rem; vertical-align: 1px;
}
.w-canvas { width: 100%; display: block; touch-action: pan-y; border-radius: 10px; cursor: crosshair; }
.w-controls {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px 22px;
  margin-top: 14px; padding: 14px 16px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--rule);
  font-family: var(--f-display); font-size: 0.84rem;
}
.w-controls label { display: grid; gap: 6px; min-width: 0; align-content: start; }
.w-controls .lab { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); }
.w-controls output { font-family: var(--f-mono); color: var(--ink); font-variant-numeric: tabular-nums; }
.w-controls input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 20px; background: transparent; margin: 0; cursor: pointer;
  --p: 50%;
}
.w-controls input[type="range"]::-webkit-slider-runnable-track {
  height: 4px; border-radius: 999px; background: linear-gradient(to right, var(--accent) var(--p), var(--rule) var(--p));
}
.w-controls input[type="range"]::-moz-range-track { height: 4px; border-radius: 999px; background: var(--rule); }
.w-controls input[type="range"]::-moz-range-progress { height: 4px; border-radius: 999px; background: var(--accent); }
.w-controls input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px; margin-top: -7px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--accent); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18); transition: transform 0.15s;
}
.w-controls input[type="range"]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); }
.w-controls input[type="range"]:active::-webkit-slider-thumb { transform: scale(1.15); }
.seg { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; border-radius: 10px; background: var(--bg); border: 1px solid var(--rule); justify-self: start; }
.seg button {
  font: inherit; font-size: 0.8rem; padding: 5px 11px; border: 0; border-radius: 7px; background: transparent;
  color: var(--muted); cursor: pointer;
}
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--accent); font-weight: 500; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }
.w-btn {
  font: inherit; font-size: 0.84rem; font-weight: 500; padding: 7px 16px; border: 0; border-radius: 9px; color: var(--surface);
  background: var(--accent); cursor: pointer; justify-self: start;
}
.w-btn:hover { filter: brightness(1.08); }
.w-readout {
  display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px;
  font-family: var(--f-mono); font-size: 0.8rem; font-variant-numeric: tabular-nums;
}
.w-readout span { padding: 3px 9px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--rule); }
.w-readout span b { font-weight: 500; color: var(--muted); margin-right: 6px; font-family: var(--f-display); }
.w-readout .hl { color: var(--accent); background: var(--accent-soft); border-color: transparent; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-family: var(--f-display); font-size: 0.76rem; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 18px; height: 0; border-top: 2px solid; vertical-align: middle; margin-right: 6px; }
.legend i.dash { border-top-style: dashed; }
.w-hint { font-family: var(--f-display); font-size: 0.74rem; color: var(--muted); margin: 6px 0 0; }

/* ---------- worked examples ---------- */
.method { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: 18px 22px 8px; margin: 8px 0 40px; box-shadow: var(--shadow); }
.method .label { color: var(--accent); }
.method ol { padding-left: 1.3em; margin: 0 0 10px; }
.method li { margin-bottom: 6px; }
article.example {
  background: var(--surface); border: 1px solid var(--rule); border-radius: 18px; padding: 22px 22px 10px; margin: 32px 0;
}
article.example::after { content: ""; display: block; clear: both; }
article.example h3 { margin-top: 0; display: grid; gap: 6px; }
.exnum {
  justify-self: start; font-family: var(--f-mono); font-weight: 500; font-size: 0.72rem; color: var(--accent); letter-spacing: 0.02em;
  padding: 2px 10px; border-radius: 999px; background: var(--accent-soft);
}
.task { font-style: italic; }
ol.steps { padding: 0; margin: 0 0 16px; list-style: none; counter-reset: st; }
ol.steps > li { counter-increment: st; position: relative; padding-left: 2.4em; margin-bottom: 10px; }
ol.steps > li::before {
  content: counter(st); position: absolute; left: 0; top: 0.15em; width: 1.55em; height: 1.55em; border-radius: 50%;
  display: grid; place-items: center; font-family: var(--f-mono); font-size: 0.78rem; font-weight: 500;
  color: var(--accent); background: var(--accent-soft);
}
.result { background: var(--accent-soft); padding: 10px 16px; border-radius: 10px; clear: both; }
.check { font-size: 0.95rem; color: var(--muted); margin-top: 12px; }
.check strong { color: var(--ok); }

/* myths */
dl.myths { margin: 22px 0; display: grid; gap: 10px; }
dl.myths > div { background: var(--surface); border: 1px solid var(--rule); border-radius: 12px; padding: 14px 18px; }
dl.myths dt { position: relative; padding-left: 2em; font-family: var(--f-display); font-weight: 600; color: var(--trap); margin-bottom: 6px; }
dl.myths dt::before {
  content: "✗"; position: absolute; left: 0; top: 0.1em; display: grid; place-items: center; width: 1.45em; height: 1.45em; border-radius: 50%;
  background: var(--force-soft); font-size: 0.8em;
}
dl.myths dd { padding-left: 1.6em; }
dl.myths dd { margin: 0; }

/* quiz */
.quiz { display: grid; gap: 8px; }
.quiz details { background: var(--surface); border: 1px solid var(--rule); border-radius: 12px; padding: 12px 16px; transition: border-color 0.2s; }
.quiz details[open] { border-color: color-mix(in srgb, var(--accent) 40%, var(--rule)); }
.quiz summary { cursor: pointer; list-style: none; position: relative; padding: 0 4.5em 0 2.4em; font-weight: 600; font-family: var(--f-body); }
.quiz summary::-webkit-details-marker { display: none; }
.quiz summary .qn {
  position: absolute; left: 0; top: 0.1em; width: 1.6em; height: 1.6em; border-radius: 50%; display: grid; place-items: center;
  font-family: var(--f-mono); font-size: 0.8rem; color: var(--accent); background: var(--accent-soft); font-weight: 500;
}
.quiz summary::after {
  content: "pokaż"; position: absolute; right: 0; top: 0.15em; font-family: var(--f-display); font-weight: 500; font-size: 0.72rem;
  color: var(--accent); text-transform: uppercase; letter-spacing: 0.06em;
}
.quiz details[open] summary::after { content: "ukryj"; }
.quiz details p { margin: 10px 0 2px 2.4em; color: var(--ink); }

/* cheat sheet */
.cheat { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 0; border: 1.5px solid var(--ink); background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.cheat-col { padding: 16px 20px 6px; min-width: 0; overflow-x: auto; }
.cheat-col + .cheat-col { border-left: 1px solid var(--rule); }
@media (max-width: 640px) { .cheat-col + .cheat-col { border-left: 0; border-top: 1px solid var(--rule); } }
.cheat p { margin: 0 0 10px; }
.reading li { margin-bottom: 6px; }
.coda { margin-top: 28px; padding: 18px 20px; border-radius: var(--radius); background: var(--accent-soft); font-style: italic; }
.colophon { font-family: var(--f-display); font-size: 0.76rem; color: var(--muted); border-top: 1px solid var(--rule); padding-top: 16px; }
.tabnum { font-variant-numeric: tabular-nums; }
.w-print-params { display: none; font-family: var(--f-mono); font-size: 0.76rem; color: var(--muted); margin-top: 6px; }

/* ---------- print (A4) ---------- */
@media print {
  @page { size: A4; margin: 18mm 17mm 20mm 20mm; }
  /* wydruk zawsze w jasnych kolorach, niezależnie od motywu (selektory nadpisują motywy ciemne o tej samej specyficzności) */
  :root, :root[data-theme], :root:not([data-theme="light"]) {
    --bg: #FFFFFF; --surface: #FFFFFF; --surface-2: #FFFFFF; --ink: #17202A; --muted: #586473; --rule: #D8DEE6;
    --accent: #2147A6; --accent-soft: #E8EEFB; --force: #C23B22; --force-soft: #FCECE8;
    --trap: #A9231A; --ok: #1D7149; --ok-soft: #E3F3EA; --grid: #E7ECF1; --shadow: none; --carbon: none;
    color-scheme: light;
  }
  h1 { background: none !important; color: var(--ink) !important; }
  body { font-size: 10.6pt; line-height: 1.5; }
  .progress, .hero-art { display: none; }
  .page { display: block; padding: 0; max-width: none; }
  .masthead { margin: 0 0 12px; padding: 6mm 0 12px; background: none; border-bottom: 1.5px solid var(--ink); }
  .toc a { padding: 2px 6px; }
  .toc { font-size: 9pt; }
  .meta { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .meta div { background: none; backdrop-filter: none; }
  h1 { font-size: 30pt; }
  .toc { border: 1px solid var(--rule); padding: 10px 14px; break-after: page; break-inside: avoid; border-radius: 8px; }
  .toc ol { grid-template-columns: 1fr; border: 0; }
  .toc a.active { background: none; color: var(--ink); font-weight: 400; }
  .flow > section { margin-bottom: 36px; }
  #przyklady, #karta { break-before: page; }
  h2, h3 { break-after: avoid; }
  .law, .trap, .why, figure.widget, article.example, .method, .table-wrap, blockquote, dl.myths > div, .quiz details, .cheat, .exfig, .marg { break-inside: avoid; }
  figure.code { break-inside: avoid; border-radius: 6px; }
  figure.code pre { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 7.6pt; line-height: 1.4; padding: 6px 10px; }
  .marg { display: block; float: right; width: 44mm; margin: 0 0 6px 6mm; opacity: 0.85; }
  .exfig { float: right; width: 52mm; margin: 0 0 6px 6mm; }
  figure.widget { margin: 14px 0; padding: 10px; border-radius: 8px; }
  .w-controls, .w-hint { display: none; }
  .w-print-params { display: block !important; }
  .w-readout span { background: none; }
  .quiz summary::after, .quiz details[open] summary::after { content: none; }
  .quiz.print-key details > p { display: none; }
  .answer-key { break-before: page; }
  .answer-key ol { padding-left: 1.4em; }
  .answer-key li { margin-bottom: 8px; font-size: 0.95em; }
  a { color: var(--ink); text-decoration: none; }
  .next, .result, .coda { background: none; border: 1px solid var(--accent); }
  .trap { background: none; border: 1px solid var(--trap); }
  .colophon { font-size: 7pt; padding-top: 6px; }
  .cheat p { margin-bottom: 6px; }
}

/* ---------- inline problem sets ---------- */
.problems {
  margin: 34px 0 8px; border-radius: 18px; padding: 18px 20px 12px;
  background: var(--surface); border: 1px solid var(--rule); box-shadow: var(--shadow);
}
.problems .label { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 20h9M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4z'/%3E%3C/svg%3E"); color: var(--accent); margin: 0; }
.probs-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 16px; padding-bottom: 12px; border-bottom: 1px solid var(--rule); }
.probs-meta { margin: 0; font-family: var(--f-display); font-size: 0.78rem; color: var(--muted); }
.probs-meta .done { color: var(--ok); font-weight: 600; }
ol.probs { list-style: none; margin: 0; padding: 0; counter-reset: pr; }
li.prob { counter-increment: pr; position: relative; padding: 14px 0 12px 2.6em; border-bottom: 1px solid var(--rule); }
li.prob:last-child { border-bottom: 0; }
li.prob::before {
  content: counter(pr); position: absolute; left: 0; top: 14px; width: 1.75em; height: 1.75em; border-radius: 8px;
  display: grid; place-items: center; font-family: var(--f-mono); font-size: 0.8rem; font-weight: 500;
  color: var(--ink); background: var(--surface-2); border: 1px solid var(--rule);
}
li.prob > p { margin: 0 0 8px; }
li.prob[data-level]::after {
  content: ""; position: absolute; left: 0.35em; top: calc(14px + 2.05em); width: 1.05em; height: 4px; border-radius: 2px;
  background: linear-gradient(to right, var(--accent) 0 30%, transparent 30% 35%, var(--rule) 35% 65%, transparent 65% 70%, var(--rule) 70%);
}
li.prob[data-level="2"]::after { background: linear-gradient(to right, var(--accent) 0 30%, transparent 30% 35%, var(--accent) 35% 65%, transparent 65% 70%, var(--rule) 70%); }
li.prob[data-level="3"]::after { background: linear-gradient(to right, var(--force) 0 30%, transparent 30% 35%, var(--force) 35% 65%, transparent 65% 70%, var(--force) 70%); }
li.prob details { margin-top: 6px; }
li.prob details > summary {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer; list-style: none;
  font-family: var(--f-display); font-size: 0.78rem; font-weight: 500; padding: 3px 10px; border-radius: 999px;
  border: 1px solid var(--rule); color: var(--muted); background: var(--surface-2);
}
li.prob details > summary::-webkit-details-marker { display: none; }
li.prob details > summary:hover { color: var(--ink); }
li.prob details.ans > summary { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 35%, var(--rule)); }
li.prob details[open] > summary { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
li.prob details > *:not(summary) { margin: 8px 0 4px; font-size: 0.96rem; }
li.prob details.ans > :not(summary) { padding-left: 12px; border-left: 2px solid var(--accent); }
li.prob details.hint > :not(summary) { color: var(--muted); }
li.prob details ol { padding-left: 1.4em; }
li.prob details ol li { margin-bottom: 4px; }
.prob-done {
  position: absolute; right: 0; top: 12px; font: inherit; font-family: var(--f-display); font-size: 0.72rem; cursor: pointer;
  padding: 3px 9px; border-radius: 999px; border: 1px solid var(--rule); background: transparent; color: var(--muted);
}
.prob-done[aria-pressed="true"] { background: var(--ok-soft); border-color: transparent; color: var(--ok); font-weight: 600; }
/* miejsce na przycisk „rozwiązane” tylko obok pierwszego akapitu treści, reszta zadania (opcje, rozwiązanie) na całą szerokość */
li.prob.has-done > p:first-of-type { padding-right: 7.5em; }
@media (max-width: 520px) { li.prob.has-done > p:first-of-type { padding-right: 0; } li.prob.has-done { padding-top: 40px; } li.prob.has-done::before { top: 40px; } li.prob.has-done[data-level]::after { top: calc(40px + 2.05em); } .prob-done { left: 2.6em; right: auto; } }
.probs-more { margin: 10px 0 0; font-family: var(--f-display); font-size: 0.78rem; color: var(--muted); }
.probs-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 10px 0 0; font-family: var(--f-display); font-size: 0.74rem; color: var(--muted); }
@media print {
  .problems { box-shadow: none; padding: 10px 12px; border-radius: 8px; break-inside: auto; }
  li.prob { break-inside: avoid; }
  li.prob details { display: none; }
  .prob-done { display: none; }
  li.prob.has-done > p:first-of-type { padding-right: 0; }
  .answer-key h3 { font-size: 11pt; margin: 14px 0 6px; }
  .answer-key .ak-block ol { padding-left: 1.6em; }
  .answer-key .ak-block li { margin-bottom: 5px; font-size: 0.93em; }
  .answer-key .ak-block li ol { margin-top: 4px; }
}

li.prob details.ans > ol { padding-left: 2.2em; }

figure.exfig.wide { float: none; width: auto; max-width: 640px; margin: 22px auto 26px; }
@media print { figure.exfig.wide { float: none; width: 100%; max-width: 150mm; margin: 10px auto; } }
.hero-art.art { width: min(640px, 52%); overflow: hidden; }
@media (max-width: 1023.98px) { .hero-art.art { width: 70%; } }
@media (max-width: 679.98px) { .hero-art.art { width: 92%; } }

/* ---------- T01 vector widgets: draggable / rotatable canvases ---------- */
.w-canvas.w-drag { touch-action: none; }
.w-canvas.w-drag:focus { outline: none; }
.w-canvas.w-drag:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.w-readout b sub { font-size: 0.75em; }

/* Zestawy rachunkowe (lekcje maturalne): kilka przykładów a), b), c)… w jednym zadaniu, opcje A–D.
   Źródło zestawów: <ol class="drill"> w pliku <numer>.trening.html (lekcje/trening.py). */
.drill { display: grid; grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr)); gap: 6px 18px; margin: 4px 0 10px; padding: 0; list-style: none; counter-reset: dr; }
.drill > span, .drill > li { min-width: 0; }
ol.drill > li { counter-increment: dr; }
ol.drill > li::before { content: counter(dr, lower-alpha) ") "; }
ol.drill[data-more]::after { content: "… " attr(data-more); grid-column: 1 / -1; font-family: var(--f-display); font-size: 0.78rem; color: var(--muted); }
.drill .katex, .opts .katex { white-space: nowrap; }
/* odpowiedzi A–D: 4 w wierszu, gdy się mieszczą, inaczej 2×2 (nigdy 3 + 1); 6 odpowiedzi: 3 + 3; długie teksty: 2 kolumny */
li.prob { container-type: inline-size; }
.opts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 18px; margin: 4px 0 10px; font-variant-numeric: tabular-nums; }
@container (min-width: 30rem) {
  .opts { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .opts:has(> :nth-child(5)) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .opts.long { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@container (max-width: 14rem) { .opts { grid-template-columns: minmax(0, 1fr); } }
.opts b { font-family: var(--f-display); margin-right: 0.35em; }
.drill-level { font-family: var(--f-display); font-size: 0.78rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); margin: 22px 0 6px; }
.trening-intro { color: var(--muted); }
.trening-link { font-family: var(--f-display); font-weight: 600; margin-top: 14px; }

/* uwagi do punktacji w rozwiązaniach (styl zasad oceniania CKE) */
details.ans p.note { font-size: 0.92em; color: var(--muted); }

/* rozwiązania krok po kroku (zadania w stylu arkusza): jeden krok w wierszu, dłuższe rachunki jako wzory wystawione */
li.prob details.ans > ol.rozw, details.ans ol.rozw { list-style: none; padding-left: 12px; margin-top: 0; margin-bottom: 8px; }
li.prob details.ans > p + ol.rozw { margin-top: -4px; padding-top: 6px; }
details.ans ol.rozw > li { margin: 0 0 6px; }
details.ans ol.rozw .katex-display { margin: 4px 0 2px; overflow-x: auto; overflow-y: hidden; }
details.ans b.krok { font-family: var(--f-display); font-weight: 600; }
/* na szerszych ekranach wzór w treści nie łamie się w połowie: przechodzi do nowej linii w całości */
@media (min-width: 640px) { details.ans .katex, details.hint .katex { white-space: nowrap; } }

/* strona treningu: jedna szeroka kolumna zamiast trzech (nie ma spisu treści ani notatek na marginesie) */
@media (min-width: 680px) {
  .page.page-trening { grid-template-columns: minmax(0, var(--measure-wide)); }
  .page.page-trening > * { grid-column: 1; grid-row: auto; }
}

/* etykiety są pisane wersalikami: wzór w etykiecie ma zostać jak jest (α nie może zamienić się w A) */
.label .katex { text-transform: none; letter-spacing: normal; }

/* Rysunki geometryczne (inline SVG generowane przez tools/rys.py) */
figure.rys { margin: 0.9rem 0 1rem; text-align: center; color: var(--ink); break-inside: avoid; }
figure.rys svg { max-width: 100%; height: auto; overflow: visible; font-family: inherit; }
.prob figure.rys, .example figure.rys { margin: 0.6rem 0; }
