:root {
  /* Zeszyt w kratkę: granatowy atrament, czerwony margines, papier z siatką 24px.
     Układ: lewy spis treści | środkowa kolumna nauki | wysuwana karta wzorów z prawej. */
  --paper: #f8fafd;
  --surface: #ffffff;
  --surface-2: #f1f4fa;
  --ink: #18233d;
  --ink-soft: #55607a;
  --line: #dde3ee;
  --grid: rgba(36, 72, 165, 0.075);
  --accent: #2448a5;
  --accent-soft: #e6ecfa;
  --margin: #d64541;
  --ok: #17804a;
  --ok-soft: #e3f4ea;
  --bad: #b93a26;
  --bad-soft: #fbe9e5;
  --rlevel: #a35f00;
  --rlevel-soft: #fdf1dc;
  --tip: #0f7a74;
  --tip-soft: #e1f3f1;
  --shadow: 0 1px 2px rgba(20, 30, 60, .06), 0 6px 24px rgba(20, 30, 60, .07);
  --font-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --font-body: "Source Sans 3", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-hand: "Caveat", "Comic Sans MS", cursive;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0e1424; --surface: #151d31; --surface-2: #1b2540; --ink: #e6ebf6; --ink-soft: #9ba7c2;
    --line: #27324d; --grid: rgba(140, 170, 255, 0.055); --accent: #93b1ff; --accent-soft: #1f2c52;
    --margin: #ff7b6f; --ok: #5fd394; --ok-soft: #133524; --bad: #ff8a73; --bad-soft: #3a1b16;
    --rlevel: #f3b451; --rlevel-soft: #3a2a10; --tip: #5fd0c7; --tip-soft: #10302e;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 28px rgba(0,0,0,.35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0e1424; --surface: #151d31; --surface-2: #1b2540; --ink: #e6ebf6; --ink-soft: #9ba7c2;
  --line: #27324d; --grid: rgba(140, 170, 255, 0.055); --accent: #93b1ff; --accent-soft: #1f2c52;
  --margin: #ff7b6f; --ok: #5fd394; --ok-soft: #133524; --bad: #ff8a73; --bad-soft: #3a1b16;
  --rlevel: #f3b451; --rlevel-soft: #3a2a10; --tip: #5fd0c7; --tip-soft: #10302e;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 28px rgba(0,0,0,.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 24px 24px;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.55;
}
h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.2; text-wrap: balance; margin: 0; }
a { color: var(--accent); }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
mjx-container { max-width: 100%; overflow-x: auto; overflow-y: hidden; }
mjx-container[display="true"] { margin: .6em 0 !important; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); min-width: 0; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 8px; flex: none;
  display: grid; place-items: center;
  background: var(--accent); color: var(--surface);
  font-family: var(--font-display); font-weight: 800; font-size: 18px;
}
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 18px; white-space: nowrap; }
.brand-sub { font-size: 13px; color: var(--ink-soft); white-space: nowrap; }
.topbar .spacer { flex: 1; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface);
  cursor: pointer; font-weight: 600; font-size: 15px; text-decoration: none; color: var(--ink);
  transition: background .15s, border-color .15s;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--surface); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.small { padding: 5px 10px; font-size: 14px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.icon { width: 18px; height: 18px; flex: none; }
.sync-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--ink-soft); padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); white-space: nowrap;
}
.sync-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-soft); }
.sync-chip.cloud .dot { background: var(--ok); }
.sync-chip.busy .dot { background: var(--rlevel); }
.sync-chip.local .dot { background: var(--ink-soft); }
.menu-btn { display: none; }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: 290px minmax(0, 1fr); min-height: calc(100% - 57px); }
.sidebar {
  position: sticky; top: 57px; height: calc(100vh - 57px); overflow-y: auto;
  border-right: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 88%, transparent);
  padding: 16px 10px 40px;
}
.side-link {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; border-radius: 7px; text-decoration: none; color: var(--ink); font-size: 15px;
}
.side-link:hover { background: var(--surface-2); }
.side-link.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.side-part { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-soft); font-weight: 700; padding: 18px 10px 6px; }
.side-dzial > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; border-radius: 7px; font-weight: 600; font-size: 15px;
}
.side-dzial > summary::-webkit-details-marker { display: none; }
.side-dzial > summary:hover { background: var(--surface-2); }
.side-dzial > summary .chev { transition: transform .15s; color: var(--ink-soft); }
.side-dzial[open] > summary .chev { transform: rotate(90deg); }
.side-dzial .side-link { padding-left: 30px; font-size: 14px; color: var(--ink-soft); }
.side-dzial .side-link.active { color: var(--accent); }
.side-num { font-variant-numeric: tabular-nums; color: var(--ink-soft); min-width: 1.4em; }
.soon { font-size: 11px; font-weight: 700; color: var(--ink-soft); border: 1px solid var(--line); border-radius: 999px; padding: 0 7px; margin-left: auto; }
.mini-ring { margin-left: auto; flex: none; }

main { min-width: 0; padding: 28px 24px 120px; }
.page { max-width: 860px; margin: 0 auto; }

/* ---------- notebook sheet ---------- */
.sheet {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px 28px 26px 52px;
}
.sheet::before {
  content: ""; position: absolute; top: 0; bottom: 0; left: 34px; width: 2px;
  background: var(--margin); opacity: .55;
}
.crumbs { font-size: 14px; color: var(--ink-soft); display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.crumbs a { color: var(--ink-soft); text-decoration: none; }
.crumbs a:hover { color: var(--accent); text-decoration: underline; }
.page-title { font-size: clamp(26px, 4vw, 36px); font-weight: 800; letter-spacing: -.01em; }
.page-lead { color: var(--ink-soft); margin: 8px 0 0; max-width: 65ch; }
.section-title { font-size: 22px; font-weight: 700; margin: 36px 0 14px; display: flex; align-items: center; gap: 10px; }
.section-title .count { font-family: var(--font-body); font-size: 14px; font-weight: 600; color: var(--ink-soft); }

/* ---------- theory blocks ---------- */
.theory { display: flex; flex-direction: column; gap: 14px; margin-top: 18px; }
.theory p { margin: 0 0 .6em; max-width: 68ch; }
.theory p:last-child { margin-bottom: 0; }
.theory ul, .theory ol { margin: .2em 0 .6em; padding-left: 1.3em; }
.theory li { margin: .15em 0; }
.blk { border-radius: 8px; padding: 14px 16px; border: 1px solid var(--line); background: var(--surface); }
.blk-h { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-family: var(--font-display); font-weight: 700; font-size: 16px; margin-bottom: 6px; }
.blk-tag { white-space: nowrap; font-family: var(--font-body); font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; padding: 2px 7px; border-radius: 4px; }
.blk.text { border: none; padding: 0 2px; background: transparent; }
.blk.def { border-left: 4px solid var(--accent); background: var(--accent-soft); border-color: transparent; border-left-color: var(--accent); }
.blk.def .blk-tag { background: var(--accent); color: var(--surface); }
.blk.ex { border-style: dashed; }
.blk.ex .blk-tag { background: var(--surface-2); color: var(--ink-soft); border: 1px solid var(--line); }
.blk.tip { background: var(--tip-soft); border-color: transparent; border-left: 4px solid var(--tip); }
.blk.tip .blk-tag { background: var(--tip); color: var(--surface); }
.blk.trap { background: var(--bad-soft); border-color: transparent; border-left: 4px solid var(--bad); }
.blk.trap .blk-tag { background: var(--bad); color: var(--surface); }
.blk.r { background: var(--rlevel-soft); border-color: transparent; border-left: 4px solid var(--rlevel); }
.blk.r .blk-tag { background: var(--rlevel); color: var(--surface); }
.blk.rex { background: var(--rlevel-soft); border: 1px dashed var(--rlevel); border-left: 4px solid var(--rlevel); }
.blk.rex .blk-tag { background: var(--surface); color: var(--rlevel); border: 1px solid var(--rlevel); }
.blk.r + .blk.rex { margin-top: -4px; }
.scope { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 18px; }
.scope > div { border-radius: 8px; padding: 12px 14px; font-size: 15px; }
.scope .p { background: var(--accent-soft); }
.scope .rr { background: var(--rlevel-soft); }
.scope h4 { font-size: 14px; letter-spacing: .04em; text-transform: uppercase; margin-bottom: 4px; }
.scope ul { margin: 0; padding-left: 1.1em; }
table.t { border-collapse: collapse; margin: .4em 0; font-variant-numeric: tabular-nums; }
table.t td, table.t th { border: 1px solid var(--line); padding: 4px 10px; text-align: center; }
table.t th { background: var(--surface-2); }
.tablewrap { overflow-x: auto; }

/* ---------- tasks ---------- */
.tasks { display: flex; flex-direction: column; gap: 18px; }
.task {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
  border-left: 5px solid var(--line);
}
.task.st-ok { border-left-color: var(--ok); }
.task.st-bad { border-left-color: var(--bad); }
.task.st-tried { border-left-color: var(--rlevel); }
.task-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 14px 18px 0; }
.task-no { font-family: var(--font-display); font-weight: 800; font-size: 17px; }
.lvl { font-size: 12px; font-weight: 800; padding: 2px 8px; border-radius: 4px; letter-spacing: .04em; }
.lvl.P { background: var(--accent-soft); color: var(--accent); }
.lvl.Pp { background: var(--accent-soft); color: var(--accent); }
.lvl.R { background: var(--rlevel-soft); color: var(--rlevel); }
.kind { font-size: 13px; color: var(--ink-soft); }
.status { margin-left: auto; font-size: 13px; font-weight: 700; padding: 2px 10px; border-radius: 999px; }
.status.ok { background: var(--ok-soft); color: var(--ok); }
.status.bad { background: var(--bad-soft); color: var(--bad); }
.status.tried { background: var(--rlevel-soft); color: var(--rlevel); }
.task-body { padding: 10px 18px 16px; }
.task-q p { margin: 0 0 .5em; }
.task-q p:last-child { margin-bottom: 0; }
.opts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.opts.long { grid-template-columns: 1fr; }
.opt {
  display: flex; align-items: center; gap: 10px; text-align: left;
  padding: 10px 12px; border-radius: 8px; border: 1.5px solid var(--line); background: var(--surface);
  cursor: pointer; min-height: 48px;
}
.opt:hover { border-color: var(--accent); }
.opt .letter {
  flex: none; width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 800; font-size: 14px;
  border: 1.5px solid var(--line); color: var(--ink-soft);
}
.opt.sel { border-color: var(--accent); background: var(--accent-soft); }
.opt.sel .letter { background: var(--accent); border-color: var(--accent); color: var(--surface); }
.opt.right { border-color: var(--ok); background: var(--ok-soft); }
.opt.right .letter { background: var(--ok); border-color: var(--ok); color: var(--surface); }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt.wrong .letter { background: var(--bad); border-color: var(--bad); color: var(--surface); }
.answer-row { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; align-items: center; }
.answer-row label { font-weight: 600; font-size: 15px; }
.answer-input {
  flex: 1 1 220px; min-width: 0; padding: 9px 12px; border-radius: 8px;
  border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); font: inherit;
}
.answer-input:focus { border-color: var(--accent); outline: none; }
.verdict { margin-top: 10px; font-weight: 600; font-size: 15px; }
.verdict.ok { color: var(--ok); }
.verdict.bad { color: var(--bad); }
.verdict.info { color: var(--ink-soft); font-weight: 500; }
.self-check { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; font-size: 15px; }
.task-tools { display: flex; gap: 6px; flex-wrap: wrap; padding: 10px 14px; border-top: 1px solid var(--line); background: var(--surface-2); }
.tool-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px; border-radius: 7px;
  border: 1px solid transparent; background: transparent; cursor: pointer; font-weight: 600; font-size: 14px; color: var(--ink-soft);
}
.tool-btn:hover { background: var(--surface); border-color: var(--line); color: var(--ink); }
.tool-btn.on { background: var(--surface); border-color: var(--accent); color: var(--accent); }
.tool-btn .has { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.reveal { padding: 14px 18px; border-top: 1px dashed var(--line); }
.reveal h5 { font-family: var(--font-display); font-size: 15px; margin: 0 0 6px; }
.reveal.hint { background: var(--tip-soft); }
.reveal.ans { background: var(--ok-soft); }
.reveal.sol ol { margin: 0; padding-left: 1.3em; }
.reveal.sol li { margin: .3em 0; padding-left: 4px; }
.reveal.sol .more { margin-top: 8px; }
.feedback { padding: 12px 18px; border-top: 1px solid var(--line); background: var(--accent-soft); font-size: 15px; }
.feedback b { font-family: var(--font-display); }

/* ---------- notes ---------- */
.notes { border-top: 1px solid var(--line); padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 10px; }
.notes-text {
  width: 100%; min-height: 96px; resize: vertical; padding: 4px 12px; border-radius: 8px;
  border: 1px solid var(--line); color: var(--ink);
  font-family: var(--font-hand); font-size: 23px; line-height: 28px;
  background-color: var(--surface);
  background-image: linear-gradient(transparent 27px, var(--grid) 27px);
  background-size: 100% 28px; background-attachment: local;
}
.canvas-wrap {
  position: relative; border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
  background-color: var(--surface);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 20px 20px;
}
.canvas-wrap canvas {
  display: block; width: 100%; height: auto; aspect-ratio: 1200 / 680; /* bez rozciągania – współrzędne logiczne 1200×680 */
  touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; cursor: crosshair;
}
.draw-bar { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1.5px var(--line); cursor: pointer; padding: 0; }
.swatch.on { box-shadow: 0 0 0 2.5px var(--accent); }
.draw-bar .sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
.notes-hint { font-size: 13px; color: var(--ink-soft); }

/* ---------- home ---------- */
.hero { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 20px; align-items: stretch; }
.hero .sheet { display: flex; flex-direction: column; gap: 12px; }
.hero-title { font-size: clamp(30px, 5vw, 44px); font-weight: 800; letter-spacing: -.02em; }
.hero-title em { font-style: normal; color: var(--margin); }
.stat-card { display: flex; flex-direction: column; gap: 14px; }
.stat-row { display: flex; align-items: center; gap: 16px; }
.big-num { font-family: var(--font-display); font-size: 40px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; }
.muted { color: var(--ink-soft); font-size: 15px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.card {
  display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow); transition: transform .15s, border-color .15s;
}
a.card:hover { border-color: var(--accent); transform: translateY(-2px); }
.card.dim { opacity: .62; box-shadow: none; background: color-mix(in srgb, var(--surface) 70%, transparent); }
.card-num { font-family: var(--font-display); font-weight: 800; font-size: 28px; color: var(--accent); line-height: 1; }
.card h3 { font-size: 17px; }
.card .muted { font-size: 14px; }
.bar { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin-top: auto; }
.bar > span { display: block; height: 100%; background: var(--ok); border-radius: 999px; }
.formula-cta {
  display: flex; align-items: center; gap: 16px; padding: 18px 20px; border-radius: var(--radius);
  background: var(--accent); color: var(--surface); text-decoration: none; box-shadow: var(--shadow);
}
.formula-cta h3 { font-size: 20px; }
.formula-cta p { margin: 2px 0 0; opacity: .85; font-size: 15px; }
.formula-cta .go { margin-left: auto; font-weight: 700; white-space: nowrap; }
.topic-list { display: flex; flex-direction: column; gap: 8px; margin-top: 18px; }
.topic-row {
  display: flex; align-items: center; gap: 14px; padding: 12px 16px; border-radius: 8px;
  background: var(--surface); border: 1px solid var(--line); text-decoration: none; color: var(--ink);
}
.topic-row:hover { border-color: var(--accent); }
.topic-row .num { font-family: var(--font-display); font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; min-width: 2.6em; }
.topic-row .meta { margin-left: auto; font-size: 13px; color: var(--ink-soft); white-space: nowrap; font-variant-numeric: tabular-nums; }
.pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 36px; flex-wrap: wrap; }
.roadmap li { margin: .2em 0; }
.roadmap .done { color: var(--ok); font-weight: 700; }

/* ---------- formula drawer ---------- */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(10, 16, 32, .35); z-index: 40; opacity: 0; pointer-events: none; transition: opacity .2s; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 41; width: min(620px, 100%);
  background: var(--surface); border-left: 1px solid var(--line); box-shadow: -10px 0 40px rgba(0,0,0,.18);
  transform: translateX(102%); transition: transform .25s ease; display: flex; flex-direction: column;
}
body.drawer-open .drawer { transform: none; }
body.drawer-open .drawer-backdrop { opacity: 1; pointer-events: auto; }
.drawer-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { font-size: 19px; }
.drawer-search { padding: 10px 16px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.drawer-search input { width: 100%; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); font: inherit; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.chip { flex: none; font-size: 13px; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; white-space: nowrap; }
.chip:hover { border-color: var(--accent); color: var(--accent); }
.drawer-body { overflow-y: auto; padding: 8px 18px 60px; flex: 1; }
.wz-sec { padding: 14px 0; border-bottom: 1px solid var(--line); }
.wz-sec h3 { font-size: 17px; margin-bottom: 8px; color: var(--accent); }
.wz-sec p { margin: .3em 0; }
.wz-sec .rtag { font-size: 11px; font-weight: 800; color: var(--rlevel); background: var(--rlevel-soft); padding: 1px 6px; border-radius: 4px; margin-left: 6px; vertical-align: middle; }
.wz-note { font-size: 14px; color: var(--ink-soft); }
.formula-page .wz-sec h3 { font-size: 20px; }

/* ---------- panel ---------- */
.panel-grid { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 16px; margin-top: 18px; }
.who { display: flex; flex-direction: column; gap: 6px; }
.who button { text-align: left; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; }
.who button.on { border-color: var(--accent); background: var(--accent-soft); }
.who small { display: block; color: var(--ink-soft); font-size: 13px; }
.rev { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.rev-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.rev img { max-width: 100%; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.rev .hand { font-family: var(--font-hand); font-size: 21px; white-space: pre-wrap; background: var(--surface-2); padding: 6px 10px; border-radius: 6px; }
.rev textarea { width: 100%; min-height: 60px; padding: 8px; border-radius: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; }
.notice { padding: 12px 16px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); font-size: 15px; }
.notice.warn { background: var(--rlevel-soft); border-color: transparent; }

@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; top: 57px; left: 0; bottom: 0; width: 300px; z-index: 35; transform: translateX(-102%); transition: transform .2s; height: auto; background: var(--surface); box-shadow: var(--shadow); }
  body.nav-open .sidebar { transform: none; }
  .menu-btn { display: inline-flex; }
  .hero { grid-template-columns: 1fr; }
  .panel-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  body { font-size: 16px; }
  main { padding: 16px 12px 100px; }
  .sheet { padding: 18px 16px 18px 34px; }
  .sheet::before { left: 20px; }
  .opts { grid-template-columns: 1fr; }
  .brand-sub, .sync-chip .label, .btn .label { display: none; }
  .scope { grid-template-columns: 1fr; }
  .task-head, .task-body { padding-left: 14px; padding-right: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
[data-ring-t], [data-ring-d] { margin-left: auto; display: flex; flex: none; }
[hidden] { display: none !important; }
.dm { overflow-x: auto; margin: .3em 0; }

/* ---------- motywy wybierane przez użytkownika ---------- */
:root[data-skin="white"] {
  --paper: #ffffff; --surface: #ffffff; --surface-2: #f4f5f8; --ink: #15181f; --ink-soft: #5b6270;
  --line: #e3e6ec; --grid: transparent; --accent: #2448a5; --accent-soft: #eaeffb;
  --margin: transparent; --ok: #17804a; --ok-soft: #e5f5ec; --bad: #b93a26; --bad-soft: #fcebe7;
  --rlevel: #a35f00; --rlevel-soft: #fdf2df; --tip: #0f7a74; --tip-soft: #e3f4f2;
  --shadow: 0 1px 2px rgba(20, 25, 40, .05), 0 4px 16px rgba(20, 25, 40, .05);
  color-scheme: light;
}
:root[data-skin="dark"] {
  --paper: #0b0b0d; --surface: #151518; --surface-2: #1d1d22; --ink: #ececf0; --ink-soft: #a0a0ab;
  --line: #2a2a31; --grid: rgba(255, 255, 255, 0.035); --accent: #8fb0ff; --accent-soft: #1c2440;
  --margin: #ff7b6f; --ok: #5fd394; --ok-soft: #12301f; --bad: #ff8a73; --bad-soft: #36191500;
  --bad-soft: #361915; --rlevel: #f3b451; --rlevel-soft: #33260e; --tip: #5fd0c7; --tip-soft: #0f2a28;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 28px rgba(0,0,0,.45);
  color-scheme: dark;
}
:root[data-skin="white"] .sheet::before { display: none; }
:root[data-skin="white"] .sheet { padding-left: 28px; }
.skin-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface); }
.skin-switch button { border: 0; background: transparent; padding: 6px 10px; font-size: 13px; font-weight: 600; color: var(--ink-soft); cursor: pointer; }
.skin-switch button + button { border-left: 1px solid var(--line); }
.skin-switch button[aria-pressed="true"] { background: var(--accent); color: var(--surface); }
@media (max-width: 600px) { .skin-switch button { padding: 6px 7px; font-size: 12px; } :root[data-skin="white"] .sheet { padding-left: 16px; } }
.topic-row > span:nth-child(2) { flex: 1; min-width: 0; }
.topic-row .meta { margin-left: 0; min-width: 3.2em; text-align: right; }
.katex-display { overflow-x: auto; overflow-y: hidden; padding: 2px 0; }
.wz-box { margin-top: 14px; padding: 12px 14px; border-radius: 8px; border: 1px dashed var(--accent); background: color-mix(in srgb, var(--accent-soft) 55%, transparent); display: flex; flex-direction: column; gap: 8px; }
.wz-box h4 { font-size: 14px; letter-spacing: .04em; text-transform: uppercase; color: var(--accent); }
.wz-item { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; font-size: 15px; }
.wz-item > span:last-child { flex: 1 1 260px; }
.wz-pill { flex: none; font: inherit; font-size: 13px; font-weight: 700; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--accent); background: var(--surface); color: var(--accent); cursor: pointer; white-space: nowrap; }
button.wz-pill:hover { background: var(--accent); color: var(--surface); }
.wz-pill.none { border-color: var(--line); color: var(--ink-soft); cursor: default; background: var(--surface-2); }
.reveal.wzr { background: color-mix(in srgb, var(--accent-soft) 60%, transparent); display: flex; flex-direction: column; gap: 8px; }
.reveal.wzr h5 { margin: 0; }
@keyframes wzflash { 0% { background: var(--rlevel-soft); } 100% { background: transparent; } }
.wz-sec.flash { animation: wzflash 2.4s ease-out; border-radius: 6px; }
.modal-back { position: fixed; inset: 0; z-index: 60; background: rgba(10, 16, 32, .45); display: grid; place-items: center; padding: 16px; }
.modal { background: var(--surface); color: var(--ink); border-radius: 12px; box-shadow: var(--shadow); padding: 22px; width: min(560px, 100%); display: flex; flex-direction: column; gap: 12px; border: 1px solid var(--line); }
.modal h2 { font-size: 22px; }
.modal p { margin: 0; }
.code-box { width: 100%; font-family: ui-monospace, Consolas, monospace; font-size: 12px; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); word-break: break-all; resize: vertical; }
.import-box { margin-top: 16px; padding: 14px; border-radius: 8px; border: 1px dashed var(--accent); display: flex; flex-direction: column; gap: 8px; }
.rev-top { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.rev-top .btn { margin-left: auto; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.side-search { padding: 0 4px 10px; }
.side-search input { width: 100%; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); font: inherit; font-size: 15px; }
.side-search input:focus { outline: none; border-color: var(--accent); }
.search-hit { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; border-radius: 7px; text-decoration: none; color: var(--ink); font-size: 14px; border: 0; background: transparent; text-align: left; width: 100%; cursor: pointer; }
.search-hit:hover { background: var(--surface-2); }
.search-hit small { color: var(--ink-soft); font-size: 12.5px; line-height: 1.35; }
#userBtn .label { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fig { display: block; max-width: 100%; height: auto; margin: 8px 0; color: var(--ink); }
@media (max-width: 760px) { .skin-switch { display: none; } }
.side-skin { display: none; margin: 0 4px 10px; }
@media (max-width: 760px) { .side-skin { display: inline-flex; } }
.reveal.explain { background: var(--rlevel-soft); border-top: 2px solid var(--rlevel); }
.reveal.explain p { margin: 0 0 .6em; max-width: 70ch; }
.reveal.explain ol, .reveal.explain ul { margin: .2em 0 .6em; padding-left: 1.3em; }
.reveal .more { margin-top: 10px; display: flex; gap: 6px; flex-wrap: wrap; }
@media (max-width: 1100px) { .sync-chip .label { display: none; } }

/* ---------- konto (logowanie) ---------- */
.modal { position: relative; }
.acc-x { position: absolute; top: 10px; right: 10px; }
.acc-form { display: flex; flex-direction: column; gap: 6px; }
.acc-form label { font-weight: 600; font-size: 15px; margin-top: 4px; }
.acc-form .btn.primary { margin-top: 8px; justify-content: center; }
.acc-form .answer-input { flex: none; width: 100%; }
.acc-pw, .acc-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.acc-pw .answer-input, .acc-row .answer-input { flex: 1 1 200px; width: auto; }
.acc-links { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 15px; }
.acc-links a { color: var(--accent); }
.acc-msg.notice.warn { color: var(--bad); background: var(--bad-soft); }
.acc-details summary { cursor: pointer; font-weight: 600; padding: 4px 0; }
.acc-details .acc-form { margin-top: 6px; }
/* urządzenia konta (etap 9) */
.acc-devbox { margin-top: 10px; }
.acc-devs { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.acc-dev { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }
.acc-dev.is-current { border-color: var(--accent); }
.acc-dev-info { display: flex; flex-direction: column; min-width: 0; }
.acc-dev-info b { overflow-wrap: anywhere; }
.acc-dev .btn { flex: none; }
.acc-lead { line-height: 1.45; }
.acc-dev .small, .acc-swaps, .acc-devsum { font-size: 14px; }
@media (max-width: 420px) { .acc-dev { flex-wrap: wrap; } .acc-dev .btn { margin-left: auto; } }

/* ---------- treści z kluczem (wersja serwerowa) ---------- */
.lock-ico { vertical-align: -1px; flex: none; }
.side-link.is-locked, .topic-row.is-locked { opacity: .75; }
.lock-box { margin-top: 18px; padding: 22px; border: 1px dashed var(--line); border-radius: 10px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.lock-box .lock-big .lock-ico { width: 36px; height: 36px; color: var(--muted, currentColor); }
.lock-box .btn { margin-top: 8px; }
.task-locked { opacity: .8; }
.task-locked .lock-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0; }
.acc-key { margin: 14px 0 4px; }
.acc-form .acc-row .btn.primary { margin-top: 0; }
.acc-access.notice.ok { border-color: var(--ok); }
/* wersja serwerowa: wczytywanie tematu i części zadań */
.load-box .notice { margin: 0; }
.spinner { display: inline-block; width: 14px; height: 14px; margin-right: 6px; vertical-align: -2px; border: 2px solid var(--line); border-top-color: currentColor; border-radius: 50%; animation: mzspin .8s linear infinite; }
@keyframes mzspin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
.slot-err, .chk-err { margin-top: 8px; }
.tool-btn:disabled { cursor: progress; opacity: .6; }

/* Wąskie ekrany: tytuł w pasku nie może wchodzić pod przyciski */
.brand > div, .brand > span:not(.brand-mark) { min-width: 0; }
.brand-name, .brand-sub { overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 480px) { .brand-name, .brand-sub { display: none; } }
/* Tablety: w pasku tylko ikony (napisy w podpowiedziach), przełącznik motywu w menu bocznym */
@media (max-width: 900px) {
  .btn .label, .sync-chip .label, .brand-sub { display: none; }
  .skin-switch { display: none; }
  .side-skin { display: inline-flex; }
}

/* ---------- synchronizacja z kontem (wersja serwerowa) ---------- */
.notes-msg { font-size: 14px; }
.notes-msg.notice.warn { color: var(--bad); background: var(--bad-soft); }
.canvas-wrap.loading { opacity: .55; pointer-events: none; }
.mig { display: flex; flex-direction: column; gap: 12px; }
.mig h2 { padding-right: 8px; overflow-wrap: anywhere; }
.mig-btns { display: flex; gap: 10px; flex-wrap: wrap; }
.mig-btns .btn { justify-content: center; }
@media (max-width: 480px) {
  .mig h2 { font-size: 19px; }
  .mig-btns { flex-direction: column; }
  .mig-btns .btn { width: 100%; }
}
.modal { max-height: calc(100dvh - 32px); overflow-y: auto; }

/* ---------- zgłoszenia do sprawdzenia (etap 6, wersja serwerowa) ---------- */
.sub-badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--bad); color: var(--surface); font-size: 12px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.sub-badge[hidden] { display: none; }
.side-link .sub-badge { margin-left: auto; }
.topbar [data-subs] { position: relative; }
.tool-btn.sub-ask { color: var(--accent); border-color: var(--accent); background: var(--surface); }
.tool-btn.sub-ask.is-off { color: var(--ink-soft); border-color: var(--line); opacity: .7; }
.tool-btn[hidden] { display: none; }
.slot-sub:empty { display: none; }
.slot-sub { border-top: 1px solid var(--line); padding: 10px 18px; display: flex; flex-direction: column; gap: 8px; }
.sub-hint { font-size: 14px; }
.sub-box { display: flex; flex-direction: column; gap: 8px; }
.sub-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sub-acts { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.sub-st { font-size: 13px; font-weight: 700; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.sub-st.pending { background: var(--accent-soft); color: var(--accent); }
.sub-st.ok { background: var(--ok-soft); color: var(--ok); }
.sub-st.partial { background: var(--rlevel-soft); color: var(--rlevel); }
.sub-st.fix { background: var(--bad-soft); color: var(--bad); }
.sub-st.withdrawn { background: var(--surface-2); color: var(--ink-soft); }
.sub-new { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; padding: 2px 7px; border-radius: 4px; background: var(--bad); color: var(--surface); }
.sub-date { font-size: 13px; }
.sub-review { padding: 10px 14px; border-radius: 8px; border-left: 4px solid var(--accent); background: var(--accent-soft); font-size: 15px; }
.sub-review.v-ok { border-left-color: var(--ok); background: var(--ok-soft); }
.sub-review.v-partial { border-left-color: var(--rlevel); background: var(--rlevel-soft); }
.sub-review.v-fix { border-left-color: var(--bad); background: var(--bad-soft); }
.sub-review-h { font-family: var(--font-display); font-weight: 700; margin-bottom: 4px; }
.sub-comment p { margin: 0 0 .5em; overflow-wrap: anywhere; }
.sub-comment p:last-child { margin-bottom: 0; }
.sub-comment .katex-display { overflow-x: auto; overflow-y: hidden; }
/* okno wysyłki */
.sub-send { display: flex; flex-direction: column; gap: 10px; }
.sub-send h2 { padding-right: 40px; }
.sub-prev { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); }
.sub-prev-h { font-size: 14px; color: var(--ink-soft); }
.sub-field { overflow-wrap: anywhere; }
.sub-note { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; max-height: 220px; overflow-y: auto; padding: 6px 8px; margin-top: 4px; border-radius: 6px; background: var(--surface); border: 1px solid var(--line); }
.sub-img { display: block; width: 100%; max-width: 100%; height: auto; margin-top: 6px; border-radius: 6px; border: 1px solid var(--line); background: #fff; }
.sub-lbl { font-weight: 600; font-size: 15px; }
.sub-q { width: 100%; min-height: 70px; padding: 8px 10px; border-radius: 8px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; resize: vertical; }
.sub-q:focus { border-color: var(--accent); outline: none; }
.sub-msg.notice.warn { color: var(--bad); background: var(--bad-soft); }
.sub-btns { display: flex; gap: 10px; flex-wrap: wrap; }
.sub-btns .btn { justify-content: center; }
/* strona „Moje zgłoszenia” */
.sub-ready { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin-bottom: 12px; }
.sub-ready-row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-top: 1px solid var(--line); cursor: pointer; min-height: 48px; }
.sub-ready-row:first-child { border-top: 0; }
.sub-ready-row:hover { background: var(--surface-2); }
.sub-ready-row input { width: 22px; height: 22px; flex: none; accent-color: var(--accent); }
.sub-ready-t { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.sub-ready-t small { color: var(--ink-soft); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sub-res { font-size: 13px; font-weight: 700; flex: none; max-width: 45%; text-align: right; }
.sub-res.ok { color: var(--ok); }
.sub-res.err { color: var(--bad); }
.sub-res.busy { color: var(--ink-soft); }
.sub-bulk-msg { margin-bottom: 12px; }
.sub-bulk-msg ul { margin: 6px 0 0; padding-left: 1.2em; }
.sub-list { display: flex; flex-direction: column; gap: 10px; }
.sub-item { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.sub-item.unread { border-color: var(--bad); box-shadow: 0 0 0 1px var(--bad) inset; }
.sub-item > summary { list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 6px 12px; flex-wrap: wrap; padding: 12px 14px; min-height: 48px; }
.sub-item > summary::-webkit-details-marker { display: none; }
.sub-item > summary:hover { background: var(--surface-2); border-radius: 10px; }
.sub-sum-t { min-width: 0; overflow-wrap: anywhere; }
.sub-sum-m { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sub-body { display: flex; flex-direction: column; gap: 10px; padding: 4px 14px 14px; border-top: 1px dashed var(--line); padding-top: 12px; }
.sub-body .sub-acts { margin-left: 0; }
.sub-imgs { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.sub-fig { margin: 0; width: 100%; }
.sub-fig figcaption { font-size: 13px; margin-top: 2px; }
@keyframes taskflash { 0% { box-shadow: 0 0 0 3px var(--accent); } 100% { box-shadow: 0 0 0 0 transparent; } }
.task.flash { animation: taskflash 2.2s ease-out; }
.task { scroll-margin-top: 72px; }
/* dotyk: przyciski zgłoszeń co najmniej 40 px */
@media (max-width: 900px), (pointer: coarse) {
  .task-tools .tool-btn, .sub-acts .btn, .sub-btns .btn, .slot-sub .btn, .sub-imgs .btn { min-height: 40px; }
}
@media (max-width: 480px) {
  .slot-sub { padding: 10px 14px; }
  .sub-acts { margin-left: 0; width: 100%; }
  .sub-acts .btn, .sub-btns .btn { flex: 1 1 auto; }
  .sub-btns { flex-direction: column; }
  .sub-btns .btn { width: 100%; }
  .sub-send h2 { font-size: 19px; }
  .sub-item > summary { flex-direction: column; align-items: flex-start; }
}
