/* KSOS — wspólny zeszyt. Gładka kartka z czerwonym marginesem na tle kratki, niebieski długopis, zakreślacz.
   Czerwień UJD = margines i nagłówki, granat = linki i zaznaczenia, bordo = cytaty przepisów.
   Priorytet: czytelność — duży tekst, mocny kontrast, bez kursywy w tekstach interfejsu. */

/* Brygada 1918 — krój udostępniony przez Kancelarię Prezydenta RP, licencja SIL OFL 1.1 (pliki w assets/fonts/) */
@font-face { font-family: "Brygada 1918"; src: url("../assets/fonts/Brygada1918-Regular.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Brygada 1918"; src: url("../assets/fonts/Brygada1918-Italic.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Brygada 1918"; src: url("../assets/fonts/Brygada1918-SemiBold.woff2") format("woff2"); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: "Brygada 1918"; src: url("../assets/fonts/Brygada1918-Bold.woff2") format("woff2"); font-weight: 700 900; font-style: normal; font-display: swap; }

:root {
  --font: "Brygada 1918", Georgia, "Times New Roman", serif;
  --desk: #EFEDE6;                     /* tło za kartką (kratka) */
  --grid: rgba(10, 48, 135, .09);
  --sheet: #FFFEFB;                    /* kartka, na której jest tekst */
  --sheet-grid: rgba(10, 48, 135, .028);
  --sheet-edge: rgba(0, 0, 0, .08);
  --margin: rgba(199, 22, 34, .4);
  --text: #1A1B1F;
  --muted: #55514B;
  --line: rgba(26, 27, 31, .16);
  --red: #B8141F;          /* UJD (odrobinę ciemniejsza dla kontrastu tekstu) */
  --blue: #0A3087;         /* niebieski długopis */
  --maroon: #800000;       /* cytaty przepisów */
  --hl: rgba(255, 221, 0, .5);
  --ok: #12703A;
  --ok-bg: rgba(18, 112, 58, .1);
  --bad: #B8141F;
  --bad-bg: rgba(184, 20, 31, .08);
  --note-yellow: #FFF7C7;
  --note-blue: #E8EFFF;
  --note-pink: #FFE6ED;
  --note-green: #E5F5E7;
  --card: #FFFFFF;
  --zebra: rgba(10, 48, 135, .035);
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --desk: #121211; --grid: rgba(255, 255, 255, .05); --sheet: #1D1C1A; --sheet-grid: rgba(255, 255, 255, .02); --sheet-edge: rgba(255, 255, 255, .07);
    --margin: rgba(240, 110, 115, .38);
    --text: #F0ECE6; --muted: #BDB6AD; --line: rgba(240, 236, 230, .16);
    --red: #F28A8E; --blue: #A7BCFF; --maroon: #E8A3A3;
    --hl: rgba(255, 214, 0, .26);
    --ok: #74E3A0; --ok-bg: rgba(116, 227, 160, .12); --bad: #F28A8E; --bad-bg: rgba(242, 138, 142, .12);
    --note-yellow: #36321F; --note-blue: #1E2640; --note-pink: #3A232A; --note-green: #1D3224;
    --card: #252421; --zebra: rgba(255, 255, 255, .03); --shadow: 0 1px 2px rgba(0,0,0,.4), 0 2px 8px rgba(0,0,0,.3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --desk: #121211; --grid: rgba(255, 255, 255, .05); --sheet: #1D1C1A; --sheet-grid: rgba(255, 255, 255, .02); --sheet-edge: rgba(255, 255, 255, .07);
  --margin: rgba(240, 110, 115, .38);
  --text: #F0ECE6; --muted: #BDB6AD; --line: rgba(240, 236, 230, .16);
  --red: #F28A8E; --blue: #A7BCFF; --maroon: #E8A3A3;
  --hl: rgba(255, 214, 0, .26);
  --ok: #74E3A0; --ok-bg: rgba(116, 227, 160, .12); --bad: #F28A8E; --bad-bg: rgba(242, 138, 142, .12);
  --note-yellow: #36321F; --note-blue: #1E2640; --note-pink: #3A232A; --note-green: #1D3224;
  --card: #252421; --zebra: rgba(255, 255, 255, .03); --shadow: 0 1px 2px rgba(0,0,0,.4), 0 2px 8px rgba(0,0,0,.3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  font: 18px/1.65 var(--font); color: var(--text); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  background-color: var(--desk);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 24px 24px;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .4em; font-weight: 700; }
.ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; vertical-align: -3px; }
[hidden] { display: none !important; }

/* Kartka: gładka (z ledwo widoczną kratką), czerwony margines, na tle kratki */
.header, .view, .footer, #alerts {
  width: 100%; max-width: 860px; margin: 0 auto; padding-left: 76px; padding-right: 32px; position: relative;
  background-color: var(--sheet);
  background-image: linear-gradient(var(--sheet-grid) 1px, transparent 1px), linear-gradient(90deg, var(--sheet-grid) 1px, transparent 1px);
  background-size: 24px 24px;
  border-left: 1px solid var(--sheet-edge); border-right: 1px solid var(--sheet-edge);
}
.header::before, .view::before, .footer::before, #alerts::before { content: ""; position: absolute; top: 0; bottom: 0; left: 50px; width: 2px; background: var(--margin); }
.view { flex: 1; padding-top: 14px; padding-bottom: 56px; counter-reset: par; }
#alerts:empty { padding-top: 0; padding-bottom: 0; }
.sheet { position: relative; flex: 1; display: flex; flex-direction: column; width: 100%; max-width: 860px; margin: 0 auto; }

/* ---------- Kolory przedmiotów ---------- */
/* Na stronach przedmiotu: margines kartki, zakreślacz i nagłówki w kolorze przedmiotu + przekładka ze skrótem */
body { --subj-tekst: var(--subj); }
:root[data-theme="dark"] body { --subj-tekst: color-mix(in srgb, var(--subj) 50%, white); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) body { --subj-tekst: color-mix(in srgb, var(--subj) 50%, white); } }
body.z-przedmiotem { --margin: color-mix(in srgb, var(--subj) 65%, transparent); }
body.z-przedmiotem h1 .hl { background: linear-gradient(transparent 58%, color-mix(in srgb, var(--subj) 30%, transparent) 58%, color-mix(in srgb, var(--subj) 30%, transparent) 92%, transparent 92%); }
body.z-przedmiotem h2.red, body.z-przedmiotem .prose h2 { color: var(--subj-tekst); }
body.z-przedmiotem .prose li::marker, body.z-przedmiotem .prose h3::before, body.z-przedmiotem .row-mark { color: var(--subj-tekst); }
.przekladka {
  position: absolute; top: 30px; right: -44px; z-index: 2; writing-mode: vertical-rl;
  background: var(--subj); color: #fff; font-weight: 700; font-size: 16px; letter-spacing: .08em;
  padding: 16px 9px; border-radius: 0 8px 8px 0; box-shadow: var(--shadow);
}
.przekladka:hover { text-decoration: none; filter: brightness(1.08); }
.znak {
  display: inline-flex; align-items: center; justify-content: center; min-width: 48px; padding: 1px 8px;
  border-radius: 5px; background: var(--c); color: #fff; font-size: 14px; font-weight: 700; letter-spacing: .03em; line-height: 1.55;
}
.szkic { display: inline-block; font-size: 13.5px; font-weight: 600; color: #7A4F00; background: var(--note-yellow); padding: 0 7px; border-radius: 4px; vertical-align: 2px; }
:root[data-theme="dark"] .szkic { color: #F5C451; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .szkic { color: #F5C451; } }

/* ---------- Formularze ---------- */
.form { display: flex; flex-direction: column; gap: 14px; max-width: 680px; margin-top: 18px; }
.form label { display: flex; flex-direction: column; gap: 5px; font-weight: 600; font-size: 16.5px; }
.form input:not([type=radio]):not([type=checkbox]):not([type=file]), .form select, .form textarea {
  font: 18px var(--font); padding: 10px 12px; border: 2px solid var(--line); border-radius: 8px;
  background: var(--card); color: var(--text); width: 100%;
}
.form input:focus, .form select:focus, .form textarea:focus { outline: none; border-color: var(--blue); }
.form-inline { display: flex; flex-direction: row; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.form-inline > label { flex: 1 1 170px; }
.form-inline > .szeroki { flex: 3 1 280px; }
.form-inline > .btn { flex: none; }
.form-err { color: var(--bad); margin: 0; min-height: 1.2em; font-weight: 600; }
.osoba .row-meta { display: flex; gap: 12px; align-items: center; }
.osoba select { font: 16px var(--font); padding: 4px 6px; border-radius: 6px; border: 1.5px solid var(--line); background: var(--card); color: var(--text); }
.osoba .link-btn, .row-meta .link-btn { font-size: 15.5px; }
.paleta { border: 0; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.paleta legend { font-weight: 600; font-size: 16.5px; margin-bottom: 8px; padding: 0; }
.form .kolor { align-items: center; gap: 4px; cursor: pointer; font-weight: 400; position: relative; }
.kolor input { position: absolute; opacity: 0; pointer-events: none; }
.kolor span { display: block; width: 100%; height: 36px; border-radius: 7px; border: 3px solid transparent; box-shadow: 0 0 0 1px var(--line); }
.kolor input:checked + span { border-color: var(--text); box-shadow: inset 0 0 0 3px var(--card), 0 0 0 1px var(--text); }
.kolor input:focus-visible + span { outline: 3px solid var(--blue); outline-offset: 2px; }
.kolor small { font-size: 14px; color: var(--muted); }
.kolor.zajety { opacity: .35; cursor: not-allowed; }

/* ---------- Edytor notatek ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 6px; margin: 20px 0 8px; position: sticky; top: 0; z-index: 3; background: var(--sheet); padding: 8px 0; }
.toolbar button { font: 600 15.5px var(--font); padding: 6px 12px; border: 1.5px solid var(--line); border-radius: 7px; background: var(--card); color: var(--text); cursor: pointer; }
.toolbar button:hover { background: var(--hl); }
.ed-status { color: var(--muted); font-size: 15.5px; margin: 8px 0 0; }

/* ---------- Skan zeszytu ---------- */
.form .plik { flex-direction: row; align-items: center; justify-content: center; gap: 10px; padding: 22px; border: 2px dashed var(--line); border-radius: 10px; background: var(--card); cursor: pointer; }
.form .plik:hover { border-color: var(--blue); }
.plik input { display: none; }
.strony { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.strony:empty { display: none; }
.strony figure { margin: 0; text-align: center; font-size: 14px; color: var(--muted); }
.strony img { display: block; height: 130px; border: 1px solid var(--line); box-shadow: var(--shadow); }
.ocr-para { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; margin: 16px 0; align-items: start; }
.ocr-para img { width: 100%; border: 1px solid var(--line); box-shadow: var(--shadow); }
.ocr-para textarea { width: 100%; min-height: 440px; font: 17.5px/1.6 var(--font); padding: 10px 12px; border: 2px solid var(--line); border-radius: 8px; background: var(--card); color: var(--text); resize: vertical; }
.zglos { display: inline-block; margin-top: 10px; font-size: 15.5px; }

/* Nagłówek */
.header { display: flex; align-items: center; justify-content: space-between; padding-top: 22px; padding-bottom: 8px; }
.wordmark { display: flex; align-items: baseline; gap: 10px; color: var(--text); }
.wordmark:hover { text-decoration: none; }
.wordmark b { font-size: 28px; color: var(--red); letter-spacing: .03em; }
.wordmark span { font-size: 16px; color: var(--muted); }

/* Tytuły */
.hl { background: linear-gradient(transparent 58%, var(--hl) 58%, var(--hl) 92%, transparent 92%); padding: 0 4px; margin: 0 -4px; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
h1 { font-size: 36px; margin: 20px 0 8px; }
.sub { color: var(--muted); margin: 0 0 10px; font-size: 18px; }
h2.red { color: var(--red); font-size: 24px; margin: 40px 0 8px; }
/* Sekcje numerowane jak w akcie prawnym: § 1., § 2., … */
h2.red::before { counter-increment: par; content: "§ " counter(par) ". "; }
.back { display: inline-flex; align-items: center; gap: 4px; font-size: 16.5px; color: var(--muted); margin-top: 14px; }
.back:hover { color: var(--text); }
.muted { color: var(--muted); }
.small { font-size: 16px; }
.ok-text { color: var(--ok); }
.bad-text { color: var(--bad); }

/* Wiersze listy */
.rows { margin: 0; padding: 0; list-style: none; }
.row { display: flex; align-items: baseline; gap: 14px; padding: 13px 0; border-bottom: 1px solid var(--line); color: var(--text); }
a.row:hover { text-decoration: none; }
a.row:hover .row-title { background: linear-gradient(transparent 58%, var(--hl) 58%, var(--hl) 92%, transparent 92%); }
/* Zdjęcia z telefonu: kod QR w edytorze i przycisk aparatu na telefonie */
.sposoby { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0 4px; }
.sposob { flex: 1 1 240px; display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.sposob:hover { border-color: var(--blue); text-decoration: none; }
.sposob .ic { width: 26px; height: 26px; flex: none; color: var(--red); }
.sposob b { display: block; font-size: 17px; }
.sposob small { display: block; color: var(--muted); font-size: 15px; }
.sposob.on { border-color: var(--text); background: var(--hl); }
.tel-panel { display: flex; flex-wrap: wrap; gap: 18px; align-items: center; margin-top: 12px; padding: 16px 18px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
.tel-panel[hidden] { display: none; }
.tel-qr { flex: none; background: #fff; padding: 8px; border-radius: 8px; line-height: 0; }
.tel-qr svg, .tel-qr img { width: 180px; height: 180px; display: block; }
.tel-opis { flex: 1 1 260px; min-width: 0; }
.tel-opis p { margin: 6px 0; overflow-wrap: anywhere; }
.foto-btn { position: relative; font-size: 20px; padding: 18px 28px; margin: 18px 0 10px; cursor: pointer; }
.foto-btn.zajety { opacity: .6; pointer-events: none; }
.ukryty-plik { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
/* Termin z przyciskiem „usuń” */
.row-z-usun { display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); }
.row-z-usun > .row { flex: 1; min-width: 0; border-bottom: 0; }
.row-z-usun > .t-usun { flex: none; font-size: 15.5px; }
.termin-form { padding: 16px 18px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
.termin-form h3 { margin: 0; }
.row-mark { min-width: 22px; flex: none; color: var(--red); font-weight: 700; text-align: center; }
.row-title { font-weight: 600; font-size: 18.5px; }
.row-meta { margin-left: auto; color: var(--muted); font-size: 16px; white-space: nowrap; padding-left: 14px; }

/* Karteczki na starcie */
.todo { display: flex; flex-wrap: wrap; gap: 14px; margin: 24px 0 6px; }
.sticky { display: block; padding: 14px 18px; min-width: 200px; background: var(--note-yellow); color: var(--text); box-shadow: var(--shadow); border-radius: 3px; }
.sticky:nth-child(2) { background: var(--note-pink); }
.sticky:nth-child(3) { background: var(--note-blue); }
a.sticky:hover { text-decoration: none; transform: translateY(-2px); }
.sticky b { display: block; font-size: 28px; line-height: 1.1; }
.sticky span { font-size: 16.5px; }

.empty { margin: 24px 0; padding: 18px 20px; background: var(--note-yellow); box-shadow: var(--shadow); border-radius: 3px; max-width: 600px; }
.empty b { display: block; margin-bottom: 4px; }

/* Przyciski */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 6px 22px; border-radius: 10px; border: 2px solid var(--text); background: var(--card); color: var(--text); font-weight: 700; font-size: 18px; cursor: pointer; text-decoration: none !important; }
.btn:hover { background: var(--hl); }
.btn-primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red); filter: brightness(.92); }
:root[data-theme="dark"] .btn-primary { color: #161514; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn-primary { color: #161514; } }
.btn-sm { min-height: 38px; padding: 4px 14px; font-size: 16px; }
.btn[disabled] { opacity: .4; pointer-events: none; }
.actions { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; margin-top: 20px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--blue); cursor: pointer; font: inherit; font-size: 17px; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: rgba(10, 48, 135, .35); }
.link-btn:hover { text-decoration-color: currentColor; }

/* ---------- Notatka ---------- */
.note-meta { color: var(--muted); font-size: 16.5px; }
.prose { margin-top: 22px; font-size: 18.5px; line-height: 1.75; max-width: 70ch; }
.prose > :first-child { margin-top: 0; }
.prose h1 { font-size: 30px; }
.prose h2 { font-size: 26px; margin: 1.7em 0 .45em; color: var(--red); line-height: 1.3; }
.prose h3 { font-size: 21.5px; margin: 1.4em 0 .35em; }
.prose h3::before { content: "› "; color: var(--red); }
.prose h4 { font-size: 19px; margin: 1.2em 0 .3em; }
.prose p { margin: .8em 0; }
.prose ul, .prose ol { padding-left: 1.5em; margin: .7em 0; }
.prose li { margin: .4em 0; padding-left: .15em; }
.prose ul li::marker { content: "– "; color: var(--red); }
.prose ol li::marker { color: var(--red); font-weight: 700; }
.prose strong { font-weight: 700; }
.prose mark { background: linear-gradient(transparent 50%, var(--hl) 50%); color: inherit; }
.prose em { color: var(--blue); }
.prose code { font: 15.5px/1.4 Consolas, monospace; background: var(--note-yellow); padding: 1px 5px; border-radius: 3px; }
.prose pre { background: var(--card); padding: 12px 14px; overflow-x: auto; border-radius: 4px; border: 1px solid var(--line); }
.prose pre code { background: none; }
.prose blockquote { margin: 1em 0; padding: 0 0 0 16px; border-left: 3px solid var(--line); color: var(--muted); }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }
.prose a { text-decoration: underline; text-underline-offset: 3px; }
.table-wrap { overflow-x: auto; margin: 1.2em 0; border: 1px solid var(--line); border-radius: 6px; }
.prose table { border-collapse: collapse; width: 100%; font-size: 17px; line-height: 1.5; background: var(--card); }
.prose th, .prose td { padding: 10px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.prose th { background: var(--note-blue); font-weight: 700; }
.prose tbody tr:nth-child(even) td { background: var(--zebra); }
.prose tr:last-child td { border-bottom: 0; }

/* Ramki = karteczki */
.callout { margin: 1.3em 0; padding: 14px 20px; background: var(--note-yellow); box-shadow: var(--shadow); border-radius: 3px; font-size: 18px; line-height: 1.7; }
.callout > p:first-of-type { margin-top: .15em; }
.callout > :last-child { margin-bottom: 0; }
.callout-title { font-weight: 700; font-size: 16.5px; }
.callout-definicja { background: var(--note-blue); }
.callout-definicja .callout-title { color: var(--blue); }
.callout-wazne, .callout-uwaga { background: var(--note-pink); }
.callout-wazne .callout-title, .callout-uwaga .callout-title { color: var(--red); }
.callout-przyklad, .callout-kazus { background: var(--note-green); }
.callout-przyklad .callout-title, .callout-kazus .callout-title { color: var(--ok); }
.callout-zapamietaj .callout-title, .callout-pytanie .callout-title { color: #7A4F00; }
:root[data-theme="dark"] .callout-zapamietaj .callout-title, :root[data-theme="dark"] .callout-pytanie .callout-title { color: #F5C451; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .callout-zapamietaj .callout-title, :root:not([data-theme="light"]) .callout-pytanie .callout-title { color: #F5C451; } }
.callout-przepis, .callout-orzecznictwo { background: var(--card); border-left: 4px solid var(--maroon); }
.callout-przepis .callout-title, .callout-orzecznictwo .callout-title { color: var(--maroon); }
.callout-info { background: var(--card); }

.read-toggle { display: inline-flex; align-items: center; gap: 10px; margin-top: 30px; cursor: pointer; font-weight: 600; user-select: none; }
.read-toggle .box { width: 24px; height: 24px; border: 2px solid var(--text); border-radius: 4px; display: grid; place-items: center; color: var(--ok); font-weight: 700; line-height: 1; }

/* ---------- Quiz ---------- */
.q-top { display: flex; align-items: center; gap: 14px; margin: 18px 0 10px; color: var(--muted); font-size: 16.5px; }
.bar { flex: 1; height: 7px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--blue); transition: width .3s; }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--text); }
.timer.low { color: var(--bad); }
.q-text { font-size: 22px; font-weight: 600; line-height: 1.5; margin: 16px 0 6px; }
.q-text p { margin: 0 0 .3em; }
.q-hint { color: var(--muted); font-size: 16.5px; margin-bottom: 14px; }
.options { display: flex; flex-direction: column; gap: 10px; }
.opt { display: flex; gap: 12px; align-items: baseline; text-align: left; width: 100%; padding: 13px 16px; border-radius: 8px; border: 2px solid var(--line); background: var(--card); cursor: pointer; font-size: 18px; line-height: 1.5; }
.opt:hover:not([disabled]) { border-color: var(--blue); }
.opt .key { font-weight: 700; color: var(--muted); flex: none; min-width: 1.4em; }
.opt.sel { border-color: var(--blue); background: var(--note-blue); }
.opt.sel .key { color: var(--blue); }
.opt.correct { border-color: var(--ok); background: var(--ok-bg); }
.opt.correct .key { color: var(--ok); }
.opt.wrong { border-color: var(--bad); background: var(--bad-bg); }
.opt.wrong span:last-child { text-decoration: line-through; text-decoration-color: var(--bad); }
.opt.missed { border-style: dashed; }
.opt[disabled] { cursor: default; }
.tf { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tf .opt { justify-content: center; font-weight: 700; }
.answer-box { width: 100%; min-height: 100px; padding: 12px 14px; border-radius: 8px; border: 2px solid var(--line); background: var(--card); color: var(--text); font: 18px/1.55 var(--font); resize: vertical; }
.answer-box:focus { outline: none; border-color: var(--blue); }
.model-answer { margin-top: 12px; padding: 14px 18px; background: var(--note-blue); box-shadow: var(--shadow); border-radius: 3px; }
.feedback { margin-top: 16px; padding: 14px 18px; border-radius: 3px; box-shadow: var(--shadow); font-size: 17.5px; line-height: 1.65; }
.feedback.ok { background: var(--note-green); }
.feedback.bad { background: var(--note-pink); }
.feedback.plain { background: var(--note-yellow); }
.feedback .verdict { font-weight: 700; font-size: 20px; }
.feedback.ok .verdict { color: var(--ok); }
.feedback.bad .verdict { color: var(--bad); }
.feedback p { margin: .35em 0 0; }
.q-dots { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 18px; }
.q-dot { width: 36px; height: 36px; border-radius: 6px; border: 2px solid var(--line); background: var(--card); font-weight: 700; color: var(--muted); cursor: pointer; }
.q-dot.answered { border-color: var(--blue); color: var(--blue); }
.q-dot.current { background: var(--hl); color: var(--text); }
.kbd { font: 14px/1 Consolas, monospace; padding: 2px 6px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; }

.score { font-size: 64px; font-weight: 700; line-height: 1; margin: 24px 0 4px; }
.review { margin-top: 10px; }
.review-item { padding: 14px 0; border-bottom: 1px solid var(--line); }
.review-q { font-weight: 600; }
.review-a { font-size: 17px; color: var(--muted); margin-top: 2px; }
.review-a b { color: var(--text); }
.review-ex { font-size: 17px; margin-top: 6px; }
details.more { margin-top: 28px; }
details.more summary { cursor: pointer; color: var(--blue); font-weight: 600; width: max-content; }

/* ---------- Fiszki (jak kartki z pudełka) ---------- */
.fc-stage { perspective: 1400px; margin-top: 14px; }
.fc { position: relative; height: 330px; cursor: pointer; transform-style: preserve-3d; transition: transform .45s cubic-bezier(.3,.7,.3,1); }
.fc.flipped { transform: rotateY(180deg); }
.fc-face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: 4px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 44px 34px 26px;
  background-color: var(--card); box-shadow: var(--shadow); border: 1px solid var(--line);
  background-image: linear-gradient(transparent 46px, var(--margin) 46px, var(--margin) 48px, transparent 48px);
  overflow-y: auto;
}
.fc-face .lbl { position: absolute; top: 12px; left: 16px; font-size: 15px; color: var(--muted); }
.fc-front .fc-text { font-size: 28px; font-weight: 700; line-height: 1.3; }
.fc-back { transform: rotateY(180deg); }
.fc-back .fc-text { font-size: 20px; line-height: 1.6; }
.fc-text p { margin: .3em 0; }
.fc-hint { margin-top: 12px; font-size: 15.5px; color: var(--muted); }
.fc-grade { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 18px; }
.g-bad:hover { background: var(--note-pink); }
.g-mid:hover { background: var(--note-yellow); }
.g-ok:hover { background: var(--note-green); }

/* ---------- Terminy ---------- */
.ev-when { font-weight: 700; color: var(--red); }

/* ---------- Szukaj ---------- */
.search-big { width: 100%; height: 54px; padding: 0 4px; border: 0; border-bottom: 2px solid var(--text); background: transparent; color: var(--text); font: 22px var(--font); outline: none; margin: 12px 0 16px; }
.search-big:focus { border-bottom-color: var(--blue); }
.search-big::placeholder { color: var(--muted); opacity: .8; }
.hit mark { background: var(--hl); color: inherit; }
.snippet { display: block; font-size: 16.5px; color: var(--muted); font-weight: 400; margin-top: 2px; }

/* ---------- Ustawienia ---------- */
.set { padding: 16px 0; border-bottom: 1px solid var(--line); }
.set h3 { font-size: 19px; margin: 0 0 2px; }
.set p { margin: 0 0 12px; color: var(--muted); font-size: 17px; }
.seg { display: inline-flex; gap: 8px; flex-wrap: wrap; }
.seg button { border: 2px solid var(--line); background: var(--card); border-radius: 8px; padding: 6px 14px; cursor: pointer; font-weight: 600; font-size: 17px; }
.seg button.on { border-color: var(--text); background: var(--hl); }

/* ---------- Stopka ---------- */
.footer { display: flex; gap: 18px; align-items: center; padding-top: 20px; padding-bottom: 28px; font-size: 15.5px; line-height: 1.55; color: var(--muted); border-top: 1px solid var(--line); }
.footer p { margin: 0; }
.footer a { color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.footer-logos { display: flex; gap: 6px; flex: none; }
.logo-chip { height: 36px; min-width: 36px; display: grid; place-items: center; padding: 3px 5px; background: #fff; border-radius: 6px; box-shadow: var(--shadow); }
.logo-chip svg, .logo-chip img { display: block; max-width: 100%; }
.logo-chip svg { height: 100%; }
.logo-chip img { max-height: 28px; width: auto; height: auto; object-fit: contain; }

.alert { margin: 10px 0; padding: 12px 16px; background: var(--note-pink); box-shadow: var(--shadow); font-size: 16.5px; }
.alert ul { margin: 4px 0 0; padding-left: 20px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 30px); opacity: 0; pointer-events: none; background: var(--text); color: var(--sheet); padding: 10px 18px; border-radius: 8px; font-weight: 600; transition: .25s; z-index: 100; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Przekładka mieści się w kartce, gdy po bokach nie ma miejsca */
@media (max-width: 960px) {
  .przekladka { right: 0; top: 16px; border-radius: 8px 0 0 8px; padding: 12px 7px; font-size: 14.5px; }
}

/* ---------- Telefon ---------- */
@media (max-width: 640px) {
  .ocr-para { grid-template-columns: minmax(0, 1fr); }
  .ocr-para textarea { min-height: 300px; }
  .toolbar button { padding: 5px 9px; font-size: 14.5px; }
  .osoba .row-meta { margin-left: 0; flex-wrap: wrap; }
  .row-title { flex: 1 1 0; min-width: 0; }
  .wordmark span { display: none; }
  body { font-size: 17.5px; }
  .header, .view, .footer, #alerts { padding-left: 40px; padding-right: 18px; border: 0; }
  .header::before, .view::before, .footer::before, #alerts::before { left: 22px; }
  h1 { font-size: 29px; }
  h2.red { font-size: 22px; margin-top: 34px; }
  .prose { font-size: 18px; line-height: 1.7; }
  .prose h2 { font-size: 23px; }
  .row { flex-wrap: wrap; padding: 12px 0; }
  .row-meta { margin-left: 36px; padding-left: 0; width: 100%; white-space: normal; font-size: 15.5px; }
  .q-text { font-size: 20px; }
  .opt { font-size: 17.5px; }
  .fc { height: 300px; }
  .fc-front .fc-text { font-size: 23px; }
  .fc-back .fc-text { font-size: 18.5px; }
  .fc-face { padding: 44px 18px 22px; }
  .fc-grade .btn { padding: 6px 8px; font-size: 16.5px; }
  .footer { flex-direction: column; align-items: flex-start; }
  .sticky { min-width: 0; flex: 1 1 140px; }
  .score { font-size: 54px; }
}

/* ================= Nawigacja: menu z podpisami, kafelki, przyciski akcji ================= */
.header { gap: 16px; }
.menu { display: flex; align-items: center; gap: 1px; flex-wrap: nowrap; justify-content: flex-end; }
.menu a { display: inline-flex; align-items: center; gap: 4px; padding: 7px 8px; border-radius: 8px; color: var(--muted); font-weight: 600; font-size: 15.5px; white-space: nowrap; }
.menu a:hover { color: var(--text); background: var(--hl); text-decoration: none; }
.menu a.on { color: var(--text); box-shadow: inset 0 -3px 0 var(--red); border-radius: 8px 8px 0 0; }
.menu a.glowny { background: var(--red); color: #fff; margin: 0 3px; padding: 7px 11px; border-radius: 8px; box-shadow: none; }
.menu a.glowny:hover { background: var(--red); filter: brightness(.92); }
:root[data-theme="dark"] .menu a.glowny { color: #161514; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .menu a.glowny { color: #161514; } }
.licznik { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 99px; background: var(--red); color: #fff; font-size: 12.5px; line-height: 20px; text-align: center; font-weight: 700; }
.dolne-menu { display: none; }

.back { padding: 5px 12px 5px 8px; border: 1.5px solid var(--line); border-radius: 8px; background: var(--card); color: var(--text); font-weight: 600; }
.back:hover { border-color: var(--text); background: var(--hl); text-decoration: none; }
.sec-opis { margin: -4px 0 8px; color: var(--muted); font-size: 16px; }

.kafle { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin-top: 12px; }
.kafel {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 16px 18px 14px;
  background: var(--card); color: var(--text); border: 1px solid var(--line); border-top: 6px solid var(--c);
  border-radius: 8px; box-shadow: var(--shadow); transition: transform .12s;
}
.kafel:hover { text-decoration: none; transform: translateY(-2px); border-color: var(--c); }
.kafel b { font-size: 19.5px; line-height: 1.3; }
.kafel-meta { color: var(--muted); font-size: 15.5px; }
.kafel-cta { margin-top: auto; padding-top: 6px; color: var(--blue); font-weight: 700; display: inline-flex; align-items: center; gap: 2px; }

.row-akcja { align-items: center; }
.row-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row-sub { color: var(--muted); font-size: 15.5px; }
.row-cta {
  flex: none; display: inline-flex; align-items: center; gap: 2px; padding: 6px 10px 6px 14px;
  border: 1.5px solid var(--line); border-radius: 8px; color: var(--blue); font-weight: 700; font-size: 16px; background: var(--card);
}
a.row-akcja:hover .row-cta { border-color: var(--blue); background: var(--note-blue); }

.wybor { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin-top: 18px; }
.wybor > a, .wybor > button, .wybor > .pusty {
  display: flex; flex-direction: column; gap: 6px; text-align: left; padding: 20px; border-radius: 10px;
  border: 2px solid var(--line); background: var(--card); color: var(--text); font: inherit; cursor: pointer; box-shadow: var(--shadow);
}
.wybor .ic { width: 28px; height: 28px; color: var(--red); }
.wybor b { font-size: 20px; }
.wybor span { color: var(--muted); font-size: 16px; }
.wybor > a:hover, .wybor > button:hover { border-color: var(--red); text-decoration: none; transform: translateY(-2px); }
.wybor > .pusty { cursor: default; box-shadow: none; border-style: dashed; }
.wybor > .pusty .ic { color: var(--muted); }

/* Telefon i wąskie okna: menu na dole ekranu */
@media (max-width: 900px) {
  .menu { display: none; }
  body.z-menu .dolne-menu {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: var(--sheet);
    border-top: 1px solid var(--line); box-shadow: 0 -2px 10px rgba(0, 0, 0, .06);
    padding: 4px 2px calc(4px + env(safe-area-inset-bottom));
  }
  .dolne-menu a { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 5px 2px; color: var(--muted); font-size: 12.5px; font-weight: 600; position: relative; border-radius: 8px; }
  .dolne-menu a span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .dolne-menu a .ic { width: 22px; height: 22px; }
  /* „Dodaj” zawsze czerwone; aktywna zakładka — zakreślona jak w zeszycie */
  .dolne-menu a.glowny { color: var(--red); }
  .dolne-menu a.on { color: var(--text); background: var(--hl); }
  .dolne-menu a:hover { text-decoration: none; }
  .dolne-menu .licznik { position: absolute; top: 0; left: 50%; margin-left: 8px; font-size: 11px; line-height: 17px; min-width: 17px; padding: 0 4px; }
  body.z-menu { padding-bottom: 72px; }
  .toast { bottom: 86px; }
}
@media (max-width: 640px) {
  .row-akcja { flex-wrap: nowrap; }
  .row-cta { padding: 5px 8px 5px 10px; font-size: 15px; }
  .kafle { grid-template-columns: minmax(0, 1fr); }
  .przekladka { top: 12px; }
}

/* ---------- Edytor bez znaczników ---------- */
.ed-wysiwyg {
  min-height: 55vh; margin-top: 0; padding: 16px 20px 24px; border: 2px solid var(--line); border-radius: 8px;
  background: var(--card); outline: none; max-width: none; cursor: text;
}
.ed-wysiwyg:focus { border-color: var(--blue); }
.ed-wysiwyg:empty::before, .ed-wysiwyg > p:only-child:has(br:only-child)::before { content: attr(data-placeholder); color: var(--muted); pointer-events: none; }
.ed-wysiwyg > p:only-child:has(br:only-child)::before { content: "Zacznij pisać tutaj…"; float: left; }
.ed-wysiwyg .callout-title { outline: none; }
.ed-wysiwyg .callout-title:empty::before { content: "Tytuł ramki"; color: var(--muted); }

/* ---------- Wyszukiwarka na stronie głównej ---------- */
.szukaj-start { position: relative; margin: 14px 0 6px; max-width: 560px; }
.szukaj-start .ic { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.szukaj-start input {
  width: 100%; height: 48px; padding: 0 14px 0 42px; border: 2px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--text); font: 17px var(--font);
}
.szukaj-start input:focus { outline: none; border-color: var(--blue); }

/* ---------- Egzamin próbny i „Ucz się” ---------- */
.egzamin-box {
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-top: 20px;
  padding: 16px 18px; border-radius: 10px; background: var(--note-yellow); box-shadow: var(--shadow);
}
.egzamin-box b { display: block; font-size: 19px; }
.egzamin-box span { color: var(--muted); font-size: 16px; }
.ucz-sie { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 16px 0 4px; padding: 12px 14px; border-radius: 10px; background: var(--note-blue); }
.ucz-sie > span { font-weight: 600; }

/* ---------- Animacja generowania quizu i fiszek ---------- */
.gen-tlo { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 16px; background: rgba(20, 18, 17, .55); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.gen-tlo.znika { opacity: 0; transition: opacity .25s; }
.gen-okno { width: min(420px, 100%); padding: 24px 26px 20px; border-radius: 14px; background: var(--sheet); box-shadow: 0 20px 60px rgba(0, 0, 0, .3); text-align: center; }
.gen-okno h3 { font-size: 22px; margin: 14px 0 2px; }
.gen-okno .ocr-pasek { margin-top: 14px; }
.gen-czas { margin: 8px 0 0; }
.gen-talia { position: relative; width: 92px; height: 112px; margin: 4px auto 0; }
.gen-talia span, .gen-talia b {
  position: absolute; inset: 0; border-radius: 6px; background: var(--card); box-shadow: var(--shadow); border: 1px solid var(--line);
  background-image: linear-gradient(transparent 18px, var(--margin) 18px, var(--margin) 20px, transparent 20px);
}
.gen-talia span:nth-child(1) { animation: gen-tasuj 1.8s ease-in-out infinite; }
.gen-talia span:nth-child(2) { animation: gen-tasuj 1.8s ease-in-out .6s infinite; }
.gen-talia span:nth-child(3) { animation: gen-tasuj 1.8s ease-in-out 1.2s infinite; }
.gen-talia b { display: grid; place-items: center; font-size: 40px; color: var(--red); animation: gen-pulsuj 1.2s ease-in-out infinite; }
.gen-talia.stop span, .gen-talia.stop b { animation: none; }
.gen-talia.stop b { color: var(--ok); font-size: 0; }
.gen-talia.stop b::after { content: "✓"; font-size: 46px; }
@keyframes gen-tasuj {
  0%, 100% { transform: translate(0, 0) rotate(0); }
  30% { transform: translate(58px, -8px) rotate(14deg); }
  60% { transform: translate(-58px, -4px) rotate(-12deg); }
}
@keyframes gen-pulsuj { 50% { transform: scale(1.08); } }
.gen-etapy { list-style: none; margin: 14px auto 0; padding: 0; text-align: left; width: max-content; max-width: 100%; font-size: 15.5px; }
.gen-etapy li { padding: 2px 0 2px 28px; position: relative; color: var(--muted); opacity: .45; transition: opacity .3s, color .3s; }
.gen-etapy li::before { content: "○"; position: absolute; left: 4px; }
.gen-etapy li.teraz { opacity: 1; color: var(--text); font-weight: 600; }
.gen-etapy li.teraz::before { content: ""; left: 2px; top: 6px; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--red); animation: ocr-obrot .8s linear infinite; }
.gen-etapy li.zrobione { opacity: 1; }
.gen-etapy li.zrobione::before { content: "✓"; color: var(--ok); font-weight: 700; }
@media (prefers-reduced-motion: reduce) {
  .gen-talia span, .gen-talia b, .gen-etapy li.teraz::before { animation: none; }
}

/* ---------- Animacja odczytu skanu ---------- */
.ocr-postep { margin-top: 16px; max-width: 680px; }
.ocr-postep p { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 10px 0 0; font-size: 16.5px; }
.ocr-pasek { position: relative; height: 10px; border-radius: 99px; background: var(--line); overflow: hidden; }
.ocr-pasek span { position: relative; display: block; height: 100%; width: 0; border-radius: 99px; background: var(--blue); transition: width .4s ease; overflow: hidden; }
.ocr-pasek span::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .55), transparent);
  animation: ocr-blysk 1.3s linear infinite;
}
@keyframes ocr-blysk { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.kreciolek { width: 18px; height: 18px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--red); animation: ocr-obrot .8s linear infinite; flex: none; }
@keyframes ocr-obrot { to { transform: rotate(360deg); } }
.strony figure { position: relative; transition: opacity .3s; }
.strony figure.czyta img { outline: 3px solid var(--blue); outline-offset: 2px; }
.strony figure.czyta::after {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: var(--red);
  box-shadow: 0 0 10px 2px var(--red); animation: ocr-skan 1.6s ease-in-out infinite alternate;
}
@keyframes ocr-skan { from { top: 0; } to { top: 127px; } }
.strony figure.gotowe figcaption::after { content: " ✓"; color: var(--ok); font-weight: 700; }
@media (prefers-reduced-motion: reduce) {
  .ocr-pasek span::after, .kreciolek, .strony figure.czyta::after { animation: none; }
}

/* ---------- Druk ---------- */
@media print {
  .header, .footer, #alerts, .back, .read-toggle, .no-print, .przekladka, .dolne-menu { display: none !important; }
  body { background: #fff; color: #000; font-size: 12pt; }
  .view { padding: 0; max-width: none; background: none; border: 0; }
  .view::before { display: none; }
  .prose { max-width: none; font-size: 11.5pt; }
  .callout { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
}
