/* Pracownia - arkusz stylow. Motyw "Linia": kazdy kurs ma swoj kolor, postep jak linia metra ze stacjami.
   Jasny i ciemny (data-theme na <html>), zmienne w :root. Fonty serwowane lokalnie (static/fonts). */
@font-face { font-family: "Schibsted Grotesk"; font-style: normal; font-display: swap; font-weight: 400 900;
  src: url("fonts/schibsted-grotesk-latin-ext.woff2") format("woff2-variations");
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }
@font-face { font-family: "Schibsted Grotesk"; font-style: normal; font-display: swap; font-weight: 400 900;
  src: url("fonts/schibsted-grotesk-latin.woff2") format("woff2-variations");
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: "DM Mono"; font-style: normal; font-display: swap; font-weight: 400;
  src: url("fonts/dm-mono-latin-ext-400.woff2") format("woff2");
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }
@font-face { font-family: "DM Mono"; font-style: normal; font-display: swap; font-weight: 400;
  src: url("fonts/dm-mono-latin-400.woff2") format("woff2");
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: "DM Mono"; font-style: normal; font-display: swap; font-weight: 500;
  src: url("fonts/dm-mono-latin-ext-500.woff2") format("woff2");
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }
@font-face { font-family: "DM Mono"; font-style: normal; font-display: swap; font-weight: 500;
  src: url("fonts/dm-mono-latin-500.woff2") format("woff2");
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }

:root {
  color-scheme: light;
  --ink: #1c2b36;          /* ciemny granat: tekst, przyciski */
  --muted: #4f5e69;
  --paper: #f7f6f1;
  --surface: #fdfcf8;
  --rule: #1c2b36;
  --line: #d7d4c6;
  --field: #1c2b36;
  --soft: #ecebe0;
  --code: #f1efe6;
  --track: #d7d4c6;
  --faint: #76848e;
  --acc: #0b6b7a;          /* kolor akcji i fokusu (kolor kursu 1) */
  --on-acc: #ffffff;
  --acc-bg: #d9ecef;
  --acc-ink: #0b6b7a;
  --timer-fg: #f2b33d;
  --board: var(--ink);
  --board-deep: #2b3f4d;
  --on-board: #f7f6f1;
  --chalk: #f2c96b;        /* zakreslacz */
  --on-chalk: #1c2b36;
  --c1: #0b6b7a; --c2: #1f7a4d; --c3: #f2b33d; --c4: #3b63a8;   /* kolory kursow */
  --on-c: #ffffff;
  --c: var(--c1);
  --badge-ok: #1f7a4d; --on-badge-ok: #ffffff;
  --ok: #1f7a4d;  --ok-bg: #dfede0;  --ok-line: #8fbfa3;
  --bad: #b3261e; --bad-bg: #f8e0dc;  --bad-line: #e3a7a1;
  --warn: #8a4b00; --warn-bg: #fce9cf; --warn-line: #e3b66f;
  --shadow: none;
  --side: #1c2b36; --onside: #f7f6f1; --side2: #a9b7c0;
  --sans: "Schibsted Grotesk", "Segoe UI", system-ui, sans-serif;
  --head: "Schibsted Grotesk", "Segoe UI", system-ui, sans-serif;
  --mono: "DM Mono", Consolas, "Courier New", monospace;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #eaf0f2;
  --muted: #a3b3bc;
  --paper: #121a20;
  --surface: #19242c;
  --rule: #8ea1ad;
  --line: #2f414c;
  --field: #8ea1ad;
  --soft: #223039;
  --code: #0f161b;
  --track: #2f414c;
  --faint: #7b8d98;
  --acc: #4cc3d3;
  --on-acc: #08232a;
  --acc-bg: #12343b;
  --acc-ink: #4cc3d3;
  --timer-fg: #f2b33d;
  --board: var(--ink);
  --board-deep: #223039;
  --on-board: #121a20;
  --chalk: #6b5316;
  --on-chalk: #fff1cf;
  --c1: #4cc3d3; --c2: #78cfa0; --c3: #f2b33d; --c4: #8fa8e8;
  --on-c: #08232a;
  --badge-ok: #78cfa0; --on-badge-ok: #08232a;
  --ok: #78cfa0;  --ok-bg: #16332a;  --ok-line: #1f6b4d;
  --bad: #ff8f85; --bad-bg: #3a1a1e;  --bad-line: #7a2c34;
  --warn: #f5b84b; --warn-bg: #3a2a0b; --warn-line: #7a5a17;
  --side: #0d1317; --onside: #eaf0f2; --side2: #8fa0aa;
}
.cc1 { --c: var(--c1); } .cc2 { --c: var(--c2); } .cc3 { --c: var(--c3); } .cc4 { --c: var(--c4); }
.cc3 { --on-c: #1c2b36; }
:root[data-theme="dark"] .cc3 { --on-c: #121a20; }

* { box-sizing: border-box; }
html { font-size: 16px; }
body { margin: 0; font-family: var(--sans); color: var(--ink); background: var(--paper); line-height: 1.5; }
a { color: var(--board); text-underline-offset: 3px; }
a:hover { color: var(--board-deep); }
h1 { font-size: 1.75rem; line-height: 1.2; margin: 0 0 .5rem; }
h2 { font-size: 1.25rem; line-height: 1.3; margin: 0 0 .75rem; }
h3 { font-size: 1.05rem; margin: 0 0 .5rem; }
p { margin: 0 0 .75rem; }
code, pre, .mono { font-family: var(--mono); font-size: .9em; }
:focus-visible { outline: 3px solid var(--chalk); outline-offset: 2px; }

/* ---------- pasek gorny */
.topbar { background: var(--board); color: var(--on-board); }
.topbar-in { max-width: 1280px; margin: 0 auto; padding: 0 1.25rem; display: flex; align-items: center; gap: 1.5rem; min-height: 56px; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 1.2rem; color: var(--on-board); text-decoration: none; display: flex; align-items: center; gap: .55rem; }
.brand-mark { width: 22px; height: 22px; border: 2px solid var(--chalk); border-radius: 3px; position: relative; }
.brand-mark::after { content: ""; position: absolute; left: 3px; right: 3px; bottom: 3px; height: 6px; background: var(--chalk); }
.topnav { display: flex; gap: .25rem; flex: 1; }
.topnav a { color: var(--muted); text-decoration: none; padding: .45rem .7rem; border-radius: 4px; }
.topnav a:hover, .topnav a.on { background: var(--board-deep); color: var(--on-board); }
.who { display: flex; align-items: center; gap: .75rem; color: var(--muted); font-size: .95rem; }
.who a { color: var(--on-board); }
.who form { margin: 0; }
.linkbtn { background: none; border: 0; color: var(--on-board); font: inherit; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; padding: 0; }

.page { max-width: 1280px; margin: 0 auto; padding: 1.75rem 1.25rem 4rem; }
.page.narrow { max-width: 460px; }
.crumbs { font-size: .92rem; color: var(--muted); margin-bottom: .6rem; }
.crumbs a { color: var(--muted); }
.lead { color: var(--muted); max-width: 70ch; }
.muted { color: var(--muted); }
.small { font-size: .9rem; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* ---------- komunikaty */
.flash { padding: .7rem 1rem; border-radius: 6px; margin-bottom: 1rem; border-left: 5px solid; white-space: pre-wrap; }
.flash.ok { background: var(--ok-bg); border-color: var(--ok); }
.flash.error { background: var(--bad-bg); border-color: var(--bad); }

/* ---------- panele i formularze */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 1.25rem; margin-bottom: 1.25rem; }
.panel > h2:first-child { margin-top: 0; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 1.25rem; align-items: start; }
.head-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }

label { display: block; font-weight: 700; margin: .9rem 0 .3rem; }
label.check { font-weight: 400; display: flex; gap: .5rem; align-items: flex-start; margin: .5rem 0; }
label.check input { margin-top: .3rem; }
.hint { font-weight: 400; color: var(--muted); font-size: .9rem; margin: .2rem 0 .4rem; }
input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%; font: inherit; color: inherit; padding: .55rem .7rem; border: 1px solid var(--field); border-radius: 6px; background: var(--surface); }
textarea { min-height: 7rem; resize: vertical; }
textarea.code { font-family: var(--mono); font-size: .9rem; }
input[type=number] { width: 7rem; }
.inline-form { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin: 0; }
.inline-form input[type=text] { flex: 1; min-width: 10rem; }

.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-top: 1rem; }

/* ---------- tabele */
.tablewrap { overflow: auto; max-height: 420px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: .45rem .7rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--soft); font-weight: 700; position: sticky; top: 0; }
table.data { font-family: var(--mono); font-size: .86rem; }
table.data td, table.data th { white-space: nowrap; padding: .3rem .6rem; }
td.null { color: var(--faint); font-style: italic; }
table.plain th { background: none; position: static; }
tr:last-child td { border-bottom: 0; }

.badge { display: inline-block; font-size: .82rem; padding: .1rem .5rem; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); }
.badge.ok { background: var(--ok-bg); border-color: var(--ok-line); }
.badge.warn { background: var(--warn-bg); border-color: var(--warn-line); }
.badge.bad { background: var(--bad-bg); border-color: var(--bad-line); }
.code-pill { font-family: var(--mono); font-size: 1.5rem; letter-spacing: .12em; background: var(--warn-bg); border: 1px dashed var(--warn-line); border-radius: 6px; padding: .2rem .7rem; display: inline-block; }

/* ---------- kafelki krokow: znak rozpoznawczy aplikacji */
.tiles { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 0; padding: 0; }
.tile { width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; border-radius: 4px; border: 2px solid var(--field); color: var(--ink); background: var(--surface); text-decoration: none; font-weight: 700; font-size: .9rem; position: relative; }
.tile.theory { border-style: dashed; }
.tile.done { background: var(--chalk); border-color: var(--chalk); color: var(--on-chalk); }
.tile.tried { border-color: var(--warn-line); }
.tile.tried::after { content: ""; position: absolute; right: 3px; top: 3px; width: 6px; height: 6px; border-radius: 50%; background: var(--warn-line); }
.tile:hover { border-color: var(--board); }

.stepband { background: var(--board-deep); color: var(--on-board); }
.stepband-in { max-width: 1280px; margin: 0 auto; padding: .7rem 1.25rem; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.stepband .where { font-size: .92rem; color: var(--muted); }
.stepband .where a { color: var(--on-board); }
.stepband .tile { background: transparent; border-color: var(--field); color: var(--on-board); }
.stepband .tile.done { background: var(--chalk); border-color: var(--chalk); color: var(--on-chalk); }
.stepband .tile.tried { border-color: var(--chalk); }
.stepband .tile.tried::after { background: var(--chalk); }
.stepband .tile.current { box-shadow: 0 0 0 3px var(--board-deep), 0 0 0 5px #fff; }

/* ---------- lista kursow i kurs */
.course-row { display: grid; grid-template-columns: 1fr auto; gap: 1rem; align-items: center; }
.bar { height: 10px; background: var(--track); border-radius: 5px; overflow: hidden; margin: .5rem 0 .25rem; max-width: 420px; }
.bar > span { display: block; height: 100%; background: var(--chalk); }
.lesson { display: grid; grid-template-columns: minmax(200px, 320px) 1fr; gap: 1rem; padding: 1rem 0; border-top: 1px solid var(--line); align-items: center; }
.lesson:first-of-type { border-top: 0; }
.lesson h3 { margin: 0; }

/* ---------- krok */
.stepgrid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 1.5rem; align-items: start; }
.stepgrid.single { grid-template-columns: minmax(0, 920px); }
.prose { max-width: 72ch; }
.prose pre { background: var(--code); border: 1px solid var(--line); border-radius: 6px; padding: .8rem 1rem; overflow: auto; }
.prose code { background: var(--code); padding: .05rem .3rem; border-radius: 3px; }
.prose pre code { background: none; padding: 0; }
.prose table { width: auto; margin-bottom: .75rem; }
details { border: 1px solid var(--line); border-radius: 6px; background: var(--surface); margin-bottom: .75rem; }
details > summary { cursor: pointer; padding: .55rem .8rem; font-weight: 700; }
details > .inside { padding: 0 .8rem .8rem; }
.schema-table { margin-bottom: 1rem; }
.schema-table h4 { margin: 0 0 .3rem; font-family: var(--mono); font-size: .95rem; }
.schema-cols { font-family: var(--mono); font-size: .84rem; color: var(--muted); margin: 0 0 .4rem; }
.schema-cols b { color: var(--ink); font-weight: 400; }

.CodeMirror { border: 1px solid var(--field); border-radius: 6px; font-family: var(--mono); font-size: .95rem; height: auto; }
.CodeMirror-scroll { min-height: 170px; max-height: 420px; }
.teacher-sql + .CodeMirror .CodeMirror-scroll { min-height: 90px; }
.CodeMirror-focused { outline: 3px solid var(--chalk); outline-offset: 1px; }

.verdict { padding: .8rem 1rem; border-radius: 6px; margin: 1rem 0; border-left: 5px solid; font-weight: 700; white-space: pre-wrap; }
.verdict.ok { background: var(--ok-bg); border-color: var(--ok); }
.verdict.bad { background: var(--bad-bg); border-color: var(--bad); }
.verdict.info { background: var(--code); border-color: var(--muted); font-weight: 400; font-family: var(--mono); font-size: .9rem; }
.result-title { font-weight: 700; margin: 1rem 0 .4rem; }
.quiz-options label { font-weight: 400; display: flex; gap: .6rem; padding: .6rem .8rem; border: 1px solid var(--line); border-radius: 6px; margin: .5rem 0; background: var(--surface); cursor: pointer; }
.quiz-options label:hover { border-color: var(--board); }
.stepnav { display: flex; justify-content: space-between; margin-top: 2rem; gap: 1rem; }
.history pre { margin: .3rem 0 0; white-space: pre-wrap; font-size: .84rem; }
.history li { margin-bottom: .7rem; }
.history ol { padding-left: 1.2rem; margin: 0; }

/* ---------- wyniki klasy */
.results td, .results th { text-align: center; white-space: nowrap; }
.results td:first-child, .results th:first-child { text-align: left; position: sticky; left: 0; background: var(--surface); z-index: 1; }
.results th:first-child { background: var(--soft); z-index: 2; }
.results th.lesson-head { background: var(--board); color: var(--on-board); font-weight: 400; font-size: .88rem; }
.results .tablewrap { max-height: none; }
.cell { display: inline-block; min-width: 2rem; padding: .1rem .35rem; border-radius: 4px; text-decoration: none; color: var(--ink); }
.cell.done { background: var(--chalk); }
.cell.tried { background: var(--bad-bg); color: var(--bad); }
.cell.none { color: var(--faint); }
.steplist { list-style: none; padding: 0; margin: 0; }
.steplist li { display: flex; align-items: center; gap: .6rem; padding: .4rem 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.steplist li > a.title { flex: 1; min-width: 12rem; }
.steplist form { margin: 0; display: inline-flex; gap: .25rem; }

@media (max-width: 900px) {
  .stepgrid { grid-template-columns: 1fr; }
  .lesson { grid-template-columns: 1fr; }
  .course-row { grid-template-columns: 1fr; }
}
@media print {
  .topbar, .noprint, .flash { display: none !important; }
  body { background: var(--surface); }
  .panel { border: 0; padding: 0; }
  .tablewrap { max-height: none; overflow: visible; border: 0; }
}

/* ---------- teoria i polecenia w wyraznych ramkach */
.sheet { background: var(--surface); border: 1px solid var(--line); border-top: 6px solid var(--board); border-radius: 8px; padding: 1.6rem 2rem 1.2rem; font-size: 1.06rem; line-height: 1.6; max-width: none; }
.sheet > :first-child { margin-top: 0; }
.task { background: var(--surface); border: 2px solid var(--board); border-radius: 8px; margin-bottom: 1rem; overflow: hidden; }
.task-head { margin: 0; padding: .4rem 1rem; background: var(--board); color: var(--on-board); font-size: .95rem; font-weight: 700; display: flex; align-items: center; gap: .5rem; }
.task-head::before { content: ""; width: 10px; height: 10px; background: var(--chalk); border-radius: 2px; }
.task-body { padding: 1rem 1.1rem .4rem; font-size: 1.1rem; line-height: 1.55; max-width: none; }
.prose h1, .prose h2, .prose h3 { margin: 1.3rem 0 .5rem; }
.prose h1 { font-size: 1.4rem; } .prose h2 { font-size: 1.2rem; } .prose h3 { font-size: 1.05rem; }
.prose ul, .prose ol { margin: 0 0 .75rem; padding-left: 1.4rem; }
.prose li { margin: .2rem 0; }
.prose blockquote { margin: 0 0 .75rem; padding: .6rem 1rem; background: var(--warn-bg); border-left: 5px solid var(--chalk); border-radius: 0 6px 6px 0; }
.prose blockquote > :last-child { margin-bottom: 0; }
.prose table { border: 1px solid var(--line); }
.prose th { position: static; }
.prose img { max-width: 100%; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 1.2rem 0; }

/* ---------- pasek formatowania w edytorze nauczyciela */
.md-wrap { border: 1px solid var(--field); border-radius: 6px; background: var(--surface); }
.md-wrap:focus-within { outline: 3px solid var(--chalk); outline-offset: 1px; }
.md-bar { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; padding: 6px; background: var(--soft); border-bottom: 1px solid var(--line); border-radius: 6px 6px 0 0; }
.md-bar button { font: inherit; font-size: .9rem; min-width: 34px; height: 32px; padding: 0 .55rem; border: 1px solid transparent; border-radius: 4px; background: transparent; color: var(--ink); cursor: pointer; }
.md-bar button:hover { background: var(--surface); border-color: var(--field); }
.md-bar button[aria-pressed=true] { background: var(--board); color: var(--on-board); }
.md-bar .sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
.md-bar .swatch { min-width: 26px; width: 26px; height: 26px; padding: 0; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--field); }
.md-bar .swatch:hover { box-shadow: 0 0 0 2px var(--ink); border-color: var(--on-board); }
.md-bar .grow { flex: 1; }
.md-wrap textarea { border: 0; border-radius: 0 0 6px 6px; display: block; outline: none; font-family: var(--mono); font-size: .92rem; line-height: 1.55; }
.md-preview { padding: 1rem; background: var(--paper); border-radius: 0 0 6px 6px; min-height: 8rem; }
.md-preview .task { margin-bottom: 0; }

.md-wrap textarea[hidden], .md-preview[hidden] { display: none; }

/* ---------- nawigacja w pasku krokow (pasek zostaje na ekranie przy przewijaniu) */
.stepband { position: sticky; top: 0; z-index: 20; }
.bandnav { margin-left: auto; display: flex; gap: .5rem; }

/* ---------- nowe haslo ucznia */
.pwnote { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; background: var(--warn-bg); border: 1px solid var(--warn-line); border-left: 6px solid var(--chalk); border-radius: 6px; padding: .9rem 1rem; margin-bottom: 1rem; }
.pwnote p { margin: .4rem 0 0; }
.pwnote .code-pill { background: var(--surface); font-size: 1.3rem; }
tr.hl td { background: var(--warn-bg); }
#uczniowie { scroll-margin-top: 1rem; }

/* ---------- arkusz PDF do pobrania */
.pdfcard { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--line); border-left: 6px solid var(--chalk); border-radius: 8px; padding: .9rem 1.1rem; margin-bottom: 1rem; }
.pdfcard p { margin: 0; }

.ok-text { color: var(--ok); }
.err-text { color: var(--bad, var(--bad)); }
.ai-profile .actions { flex-wrap: wrap; }

td.grade { text-align: center; font-size: 1.05rem; white-space: nowrap; }

/* ======================================================================
   Motyw "Linia": nadpisania i dopracowanie komponentow
   ====================================================================== */
body { font-size: 16px; line-height: 1.6; -webkit-font-smoothing: antialiased; background: var(--paper); }
h1, h2, h3, h4 { font-family: var(--head); font-weight: 800; }
h1 { font-size: 2.75rem; line-height: 1.05; letter-spacing: -.04em; margin: 0 0 1rem; padding: 0; border: 0; background: none; }
h2 { font-size: 1.6rem; line-height: 1.2; letter-spacing: -.03em; }
h3 { font-size: 1.2rem; line-height: 1.25; letter-spacing: -.02em; font-weight: 700; }
a { color: var(--ink); text-decoration-color: var(--c); text-decoration-thickness: 2px; text-underline-offset: 3px; }
a:hover { color: var(--ink); text-decoration-thickness: 3px; }
:focus-visible { outline: 3px solid var(--c); outline-offset: 3px; }
code, pre, .mono, table.data, .CodeMirror, .timer, .code-pill { font-family: var(--mono); font-stretch: 100%; }
code, pre, .mono { font-size: .88em; }
.lead, .muted { color: var(--muted); }
.crumbs a { color: var(--muted); }
.page { padding-top: 2.25rem; }

/* pasek gorny */
.topbar { background: var(--paper); color: var(--ink); border-bottom: 1px solid var(--line); }
.topbar-in { min-height: 68px; gap: 1rem; padding-top: .4rem; padding-bottom: .4rem; row-gap: .3rem; }
.brand { color: var(--ink); font-family: var(--head); font-weight: 800; font-size: 1.55rem; letter-spacing: -.04em; gap: .7rem; text-decoration: none; }
.brand:hover { color: var(--ink); }
.brand-mark { display: inline-flex; gap: 3px; width: auto; height: 22px; border: 0; background: none; border-radius: 0; position: static; }
.brand-mark::before, .brand-mark::after { content: ""; display: block; position: static; width: 8px; height: 22px; border-radius: 4px; border: 0; inset: auto; }
.brand-mark::before { background: var(--c1); }
.brand-mark::after { background: var(--c2); }
.topnav { gap: .2rem; margin-left: .5rem; flex: 1 1 480px; row-gap: .25rem; flex-wrap: wrap; }
.topnav a { color: var(--ink); font-weight: 600; font-size: .95rem; padding: .4rem .8rem; border: 0; border-radius: 999px; line-height: 1.3; white-space: nowrap; text-decoration: none; }
.topnav a:hover { background: var(--soft); color: var(--ink); }
.topnav a.on { background: var(--ink); color: var(--on-board); }
.who { color: var(--muted); font-size: .92rem; gap: .8rem; flex: none; }
.who a, .linkbtn { color: var(--ink); }
.who a:hover, .linkbtn:hover { color: var(--ink); }
.theme-toggle { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 50%; border: 2px solid var(--ink); background: transparent; color: var(--ink); cursor: pointer; padding: 0; }
.theme-toggle:hover { background: var(--ink); color: var(--on-board); }
.theme-toggle svg { width: 18px; height: 18px; }
.topbar-in .theme-toggle { order: 2; margin-left: auto; }
.topbar-in .who { order: 2; }
.topnav:has(> a:nth-child(5)) { order: 3; flex: 1 0 100%; margin: 0 0 .25rem; }
.theme-toggle .i-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: block; }

/* panele */
.panel, .sheet { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: none; }
.panel::before, .panel::after, .sheet::before, .sheet::after { display: none; }
.sheet { border-top: 1px solid var(--line); }
.panel .panel { margin-bottom: 1rem; }

/* formularze i przyciski */
label { font-weight: 700; }
input[type=text], input[type=password], input[type=number], select, textarea { border: 2px solid var(--field); border-radius: 10px; background: var(--surface); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--c); outline-offset: 1px; }
input::placeholder, textarea::placeholder { color: var(--faint); }
select option { background: var(--surface); color: var(--ink); }
input[type=checkbox], input[type=radio] { accent-color: var(--ink); }
.btn, .bandbtn { font-family: var(--sans); font-weight: 700; border: 2px solid var(--ink); border-radius: 999px; min-height: 42px; padding: .55rem 1.3rem; line-height: 1.2; background: var(--ink); color: var(--on-board); text-decoration: none; cursor: pointer; transition: background .15s, color .15s, border-color .15s; }
.btn:hover { background: var(--c); border-color: var(--c); color: var(--on-c); }
.btn:focus-visible, .bandbtn:focus-visible { outline: 3px solid var(--c); outline-offset: 3px; }
.btn.ghost, .bandbtn { background: transparent; color: var(--ink); border-color: var(--ink); }
.btn.ghost:hover, .bandbtn:hover, .bandbtn.primary:hover { background: var(--ink); border-color: var(--ink); color: var(--on-board); }
.btn.danger { background: transparent; color: var(--bad); border-color: var(--bad); }
.btn.danger:hover { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.sm { min-height: 34px; padding: .25rem .9rem; font-size: .9rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; pointer-events: none; }
.btn.big { font-size: 1.15rem; padding: .85rem 1.9rem; }
.bandbtn.primary { background: var(--ink); color: var(--on-board); }

/* komunikaty, werdykty, plakietki */
.flash, .verdict, .pwnote { border: 1px solid; border-left-width: 1px; border-radius: 10px; }
.flash.ok, .verdict.ok { background: var(--ok-bg); border-color: var(--ok); color: var(--ink); }
.flash.error, .verdict.bad { background: var(--bad-bg); border-color: var(--bad); color: var(--ink); }
.verdict.ok { font-weight: 600; }
.verdict.info { background: var(--code); border-color: var(--line); color: var(--ink); }
.pwnote { background: var(--warn-bg); border-color: var(--warn-line); }
.badge { display: inline-block; font-family: var(--sans); font-weight: 700; font-size: .78rem; line-height: 1.4; white-space: nowrap; padding: .12rem .65rem; margin: .15rem .3rem .15rem 0;
  border: 0; border-radius: 12px; background: var(--soft); color: var(--ink); vertical-align: middle; }
.badge.ok { background: var(--badge-ok); color: var(--on-badge-ok); }
.badge.warn { background: var(--c3); color: #1c2b36; }
.badge.bad { background: var(--bad); color: #fff; }
:root[data-theme="dark"] .badge.bad { color: #121a20; }
td:has(> .badge) { line-height: 2; }
.code-pill { color: var(--ink); background: var(--warn-bg); border: 1px dashed var(--warn-line); border-radius: 8px; }

/* tabele */
.tablewrap { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
th { background: var(--soft); color: var(--ink); font-weight: 700; font-size: .88rem; border-bottom: 1px solid var(--line); }
th, td { border-bottom-color: var(--line); }
table.plain th { background: none; }
table.data { font-size: .8rem; }
details { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
details > summary { font-family: var(--head); font-size: 1.05rem; font-weight: 700; }

/* kafelki krokow: stacje */
.tiles { gap: 10px; }
.tile { width: 40px; height: 40px; margin: 0; border: 3px solid var(--line); border-radius: 50%; background: var(--surface); color: var(--muted); font-family: var(--sans); font-weight: 700; font-size: .9rem; text-decoration: none; }
.tile.theory { border-style: dashed; }
.tile.done { background: var(--c); border-color: var(--c); color: var(--on-c); }
.tile.tried { border-color: var(--c3); color: var(--ink); }
.tile.tried::after { background: var(--c3); border-radius: 50%; width: 8px; height: 8px; right: 2px; top: 2px; }
.tile.sent { background: var(--acc-bg); color: var(--ink); }
.tile:hover { border-color: var(--c); color: var(--ink); }
.tile.done:hover { color: var(--on-c); }
.tile.current { background: var(--surface); border-color: var(--c); color: var(--ink); box-shadow: 0 0 0 4px var(--surface), 0 0 0 7px var(--c); position: relative; }
.stepband { background: var(--surface); color: var(--ink); border-bottom: 1px solid var(--line); }
.stepband-in { gap: 1.25rem; padding-top: .9rem; padding-bottom: .9rem; }
.stepband .where { color: var(--muted); }
.stepband .where a { color: var(--ink); }
.stepband .tiles { position: relative; flex-wrap: nowrap; gap: 14px; padding: 8px 8px; }
.stepband .tiles::before { content: ""; position: absolute; left: 28px; right: 28px; top: 50%; height: 4px; margin-top: -2px; background: var(--line); }
.stepband .tile { position: relative; background: var(--surface); border-color: var(--line); color: var(--muted); }
.stepband .tile.done { background: var(--c); border-color: var(--c); color: var(--on-c); }
.stepband .tile.tried { border-color: var(--c3); color: var(--ink); }
.stepband .tile.sent { background: var(--acc-bg); color: var(--ink); }
.stepband .tile.current { background: var(--surface); border-color: var(--c); color: var(--ink); box-shadow: 0 0 0 4px var(--surface), 0 0 0 7px var(--c); }
.stepband .tile:hover { border-color: var(--c); }

/* lista kursow jak linia metra */
.courseline { position: relative; padding-left: 56px; margin-top: 1.25rem; }
.courseline::before { content: ""; position: absolute; left: 19px; top: 28px; bottom: 28px; width: 4px; background: var(--line); border-radius: 2px; }
.courseline > .panel { background: none; border: 0; border-radius: 0; padding: 1.2rem 0 1.5rem; margin: 0; }
.courseline > .panel::before { display: block; content: ""; position: absolute; left: -47px; top: 1.6rem; width: 26px; height: 26px; border: 4px solid var(--c); border-radius: 50%; background: var(--paper); box-shadow: 0 0 0 6px var(--paper); }
.courseline > .panel.finished::before { background: var(--c); }
.courseline > .panel.waiting::before { border-style: dashed; }
.courseline > .panel::after { display: none; }
.course-row h2 { font-size: 1.7rem; line-height: 1.15; letter-spacing: -.03em; margin-bottom: .35rem; }
.course-row h2 a { text-decoration: none; }
.course-row h2 a:hover { text-decoration: underline; text-decoration-color: var(--c); text-decoration-thickness: 3px; text-underline-offset: 4px; }

/* paski postepu */
.bar { height: 10px; background: var(--track); border-radius: 5px; overflow: hidden; }
.bar > span { background: var(--c); border-radius: 5px; }
.lesson { border-top: 1px solid var(--line); }

/* tresc krokow */
.task { border: 1px solid var(--line); border-radius: 14px; box-shadow: none; background: var(--surface); }
.task-head { background: var(--c); color: var(--on-c); border-bottom: 0; font-family: var(--head); font-weight: 800; font-size: .98rem; letter-spacing: -.01em; padding: .5rem 1.1rem; }
.task-head::before { background: var(--on-c); border-radius: 50%; width: 10px; height: 10px; }
.sheet { border-top: 6px solid var(--c); }
.task-body mark, .prose mark { background: var(--chalk); color: var(--on-chalk); padding: 0 .25rem; border-radius: 4px; }
.prose pre { background: var(--code); border: 1px solid var(--line); border-radius: 10px; color: var(--ink); }
.prose code { color: var(--ink); background: var(--code); border-radius: 4px; }
.prose blockquote { background: var(--acc-bg); border: 0; border-left: 5px solid var(--c); border-radius: 0 10px 10px 0; color: var(--ink); }
.prose table { border: 1px solid var(--line); }
.quiz-options label { border: 2px solid var(--line); border-radius: 12px; background: var(--surface); font-weight: 400; }
.quiz-options label:hover { border-color: var(--c); background: var(--surface); }
.pdfcard { border: 1px solid var(--line); border-left: 1px solid var(--line); border-radius: 12px; background: var(--surface); }

/* wyniki klasy */
.results th.lesson-head { background: var(--ink); color: var(--on-board); font-weight: 700; }
.results td:first-child { background: var(--surface); }
.results th:first-child { background: var(--soft); }
.cell { border-radius: 6px; }
.cell.done { background: var(--ok-bg); color: var(--ok); }
.cell.tried { background: var(--bad-bg); color: var(--bad); }

/* edytor Markdown */
.md-wrap { border: 2px solid var(--field); border-radius: 10px; background: var(--surface); overflow: hidden; }
.md-bar { background: var(--soft); border-radius: 0; border-bottom: 1px solid var(--line); }
.md-bar button { color: var(--ink); border-radius: 6px; }
.md-bar button:hover { background: var(--surface); border-color: var(--line); }
.md-bar button[aria-pressed=true] { background: var(--ink); color: var(--on-board); }
.md-bar .swatch { border-radius: 50%; border-color: var(--surface); }
.md-wrap textarea { background: var(--surface); border-radius: 0; }
.md-preview { background: var(--paper); border-radius: 0; }

/* edytor SQL (CodeMirror) */
.CodeMirror { border: 2px solid var(--field); border-radius: 10px; background: var(--code); color: var(--ink); font-size: .86rem; }
.CodeMirror-gutters { background: var(--soft); border-right: 1px solid var(--line); border-radius: 8px 0 0 8px; }
.CodeMirror-linenumber { color: var(--faint); }
.CodeMirror-cursor { border-left-color: var(--ink); }
.CodeMirror-focused { outline: 3px solid var(--c); outline-offset: 1px; }
.CodeMirror-selected, .CodeMirror-focused .CodeMirror-selected { background: var(--acc-bg); }
.cm-s-default .cm-keyword, .cm-s-default .cm-builtin { color: var(--acc-ink); font-weight: 500; }
.cm-s-default .cm-number, .cm-s-default .cm-atom { color: var(--ok); }
.cm-s-default .cm-string, .cm-s-default .cm-string-2 { color: #3b63a8; }
.cm-s-default .cm-comment { color: var(--faint); }
.cm-s-default .cm-variable-2, .cm-s-default .cm-variable-3, .cm-s-default .cm-def { color: var(--ink); }
:root[data-theme="dark"] .cm-s-default .cm-string, :root[data-theme="dark"] .cm-s-default .cm-string-2 { color: #8fa8e8; }
.CodeMirror-matchingbracket { color: var(--ink) !important; background: var(--acc-bg); }

/* sprawdzian: pasek czasu, blokada okna, rozpoczecie */
.testbar { display: flex; align-items: center; gap: .75rem; margin-left: auto; }
.testbar form { margin: 0; }
.timer { font-family: var(--mono); font-weight: 500; font-size: 1.3rem; padding: .2rem .9rem; border-radius: 10px; background: var(--ink); color: var(--timer-fg); }
:root[data-theme="dark"] .timer { background: #223039; }
.testbar.low .timer { background: var(--bad); color: #fff; }
.testbar + .bandnav { margin-left: 0; }
.lockdown { position: fixed; inset: 0; z-index: 9999; display: flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--paper) 94%, transparent); backdrop-filter: blur(6px); }
.lockdown[hidden] { display: none; }
.lockdown-box { max-width: 30rem; padding: 1.6rem 1.8rem; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.lockdown-box h2 { margin-top: 0; }
body.locked { overflow: hidden; }
.launchbox { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; background: var(--ink); color: var(--on-board); border-color: var(--ink); }
.launchbox h2, .launchbox p, .launchbox .muted { color: var(--on-board); }
.launchbox .btn { background: var(--c3); border-color: var(--c3); color: #1c2b36; }
.launchbox .btn:hover { background: var(--on-board); border-color: var(--on-board); color: var(--ink); }

@media (max-width: 700px) { .topbar-in { gap: .5rem; } .who { margin-left: auto; } h1 { font-size: 2.1rem; } .courseline { padding-left: 40px; } .courseline::before { left: 11px; } .courseline > .panel::before { left: -39px; } }
@media print {
  :root, :root[data-theme="dark"] { --ink: #000; --paper: #fff; --surface: #fff; --line: #ccc; --soft: #fff; --code: #fff; --muted: #333; }
  .theme-toggle { display: none !important; }
  .courseline::before, .courseline > .panel::before { display: none; }
}

/* ======================================================================
   Uklad z boczna nawigacja (plansze „Nowy uklad strony”)
   ====================================================================== */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--side); color: var(--onside); padding: 26px 18px; display: flex; flex-direction: column; gap: 28px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side .brand { color: var(--onside); font-size: 1.45rem; padding: 0 8px; }
.side .brand:hover { color: var(--onside); }
.side .brand-mark::after { background: var(--c3); }
.sidenav { display: flex; flex-direction: column; gap: 4px; }
.sidenav > a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; font-weight: 600; font-size: .95rem; color: var(--side2); text-decoration: none; line-height: 1.25; }
.sidenav > a svg { width: 20px; height: 20px; flex: none; }
.sidenav > a:hover { color: var(--onside); background: #ffffff14; }
.sidenav > a.on { background: var(--onside); color: var(--side); }
.sidenav > small { margin: 16px 12px 4px; font-size: .82rem; color: var(--side2); font-weight: 500; }
.sidedots { display: flex; flex-direction: column; gap: 2px; }
.sidedots a { display: flex; align-items: center; gap: 12px; padding: 7px 12px; font-size: .92rem; color: var(--onside); border-radius: 10px; text-decoration: none; line-height: 1.3; }
.sidedots a:hover { background: #ffffff14; }
.sidedots a b { display: block; width: 12px; height: 12px; border-radius: 50%; border: 3px solid var(--c); flex: none; }
.sidedots a.on b { background: var(--c); }
.side .who { display: flex; flex-direction: column; gap: 6px; margin-top: auto; border-top: 1px solid #ffffff22; padding: 16px 8px 0; color: var(--side2); font-size: .9rem; }
.side .who strong { color: var(--onside); font-weight: 600; font-size: .95rem; }
.side .who > div { display: flex; gap: 14px; }
.side .who a, .side .linkbtn { color: var(--side2); text-decoration: underline; text-underline-offset: 3px; }
.side .who a:hover, .side .linkbtn:hover { color: var(--onside); }
.stage { min-width: 0; display: flex; flex-direction: column; }
.stage > .page { width: 100%; max-width: none; margin: 0; padding: 0 clamp(20px, 3.2vw, 64px) 64px; flex: 1; }
.stagebar { display: flex; align-items: center; gap: 1rem; padding: 26px clamp(20px, 3.2vw, 64px) 0; color: var(--muted); font-size: .92rem; }
.stagebar .crumb { flex: 1; }
.stagebar .theme-toggle, .stepband .theme-toggle { order: 0; margin-left: 0; }
.stage > .page > h1:first-child, .stage > .page > .head-row:first-child { margin-top: 1.4rem; }
.stage > .page > .cc > .head-row { margin-top: 1.7rem; }
.stage > .page > h1:first-child { font-size: 2.75rem; line-height: 1.05; letter-spacing: -.03em; }
.page.narrow { margin: 0 auto; }
.stepband { border-bottom: 1px solid var(--line); }
.stepband-in { max-width: none; padding: 16px clamp(20px, 3.2vw, 64px); }
.stepband .theme-toggle { flex: none; }
.stage > .page.stepwide { max-width: none; }
.stepband + .page { padding-top: 1.6rem; }

/* strona glowna ucznia */
.stage > .page > .lead { margin: .35rem 0 0; color: var(--muted); }
.resume { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 32px; align-items: center; border: 1.5px solid var(--ink); border-radius: 18px; padding: 30px 34px; margin: 26px 0 0; background: var(--surface); }
.resume-k { display: flex; align-items: center; gap: 8px; font-size: .88rem; font-weight: 700; color: var(--c3); }
.resume h2 { font-size: 1.9rem; font-weight: 800; letter-spacing: -.02em; margin: 6px 0 4px; }
.resume .bar { margin-top: 16px; max-width: 460px; height: 8px; }
.resume .btn { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.resume .btn:hover { background: var(--c); border-color: var(--c); color: var(--on-c); }
.homecols { display: grid; grid-template-columns: minmax(0, 1fr) clamp(320px, 28vw, 460px); gap: 32px; margin-top: 36px; align-items: start; }
.sect { font-size: 1.4rem; font-weight: 700; letter-spacing: -.01em; margin: 0; }
.sect.small { font-size: 1.1rem; margin-bottom: .8rem; }
.homeside { display: flex; flex-direction: column; gap: 20px; }
.homeside .panel { margin: 0; }
.stats dl { margin: 0; display: flex; flex-direction: column; }
.stats dl > div { display: flex; justify-content: space-between; align-items: baseline; padding: .55rem 0; border-bottom: 1px solid var(--line); }
.stats dl > div:last-child { border-bottom: 0; }
.stats dt { color: var(--muted); font-size: .95rem; }
.stats dd { margin: 0; font-size: 1.25rem; font-weight: 500; }
.testcard { border: 1.5px solid var(--c3); }
.testcard h2 { font-size: 1.35rem; margin: .7rem 0 .3rem; }
.testcard .btn { margin-top: .9rem; }
.btn.wide { display: flex; justify-content: center; width: 100%; }
.course-row h3 { font-size: 1.3rem; line-height: 1.2; letter-spacing: -.02em; margin: 0 0 .25rem; }
.course-row h3 a { text-decoration: none; }
.course-row .bar { max-width: 640px; }
.course-row { grid-template-columns: minmax(0, 640px) auto; justify-content: start; column-gap: 2rem; }
.resume .bar { max-width: 640px; }

/* pulpit nauczyciela */
.row-actions { display: flex; gap: 10px; }
.live { border: 1.5px solid var(--c3); border-radius: 16px; background: var(--surface); padding: 22px 26px; margin: 0 0 24px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 20px; align-items: center; }
.live h2 { font-size: 1.35rem; font-weight: 800; margin: 6px 0 2px; }
.pulse { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: .85rem; }
.pulse i { width: 10px; height: 10px; border-radius: 50%; background: var(--bad); }
.ppl { display: flex; gap: 6px; margin: 12px 0 10px; flex-wrap: wrap; }
.ppl i { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-style: normal; font-size: .72rem; font-weight: 700; background: var(--soft); color: var(--ink); }
.ppl i.g { background: var(--ok); color: var(--surface); }
.ppl i.w { background: var(--c3); color: #1c2b36; }
.livebtns { display: flex; flex-direction: column; gap: 10px; }
.livebtns form { margin: 0; }
.livebtns .btn { width: 100%; text-align: center; }
.clrow { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 13px 0; border-bottom: 1px solid var(--line); }
.clrow:has(> input) { grid-template-columns: 22px 34px minmax(0, 1fr) auto; }
.clrow:last-of-type { border-bottom: 0; }
.clrow > b { width: 34px; height: 34px; border-radius: 10px; background: var(--c); color: var(--on-c); display: grid; place-items: center; font-size: .8rem; }
.clrow a { font-weight: 700; font-size: 1.05rem; text-decoration: none; }
.clrow a:hover { text-decoration: underline; text-decoration-color: var(--c); text-decoration-thickness: 3px; text-underline-offset: 4px; }
.clrow p { margin: 0; }
.clrow .badges { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.selall { display: flex; align-items: center; gap: .5rem; font-weight: 500; font-size: .88rem; color: var(--muted); margin: 0 0 .3rem; }

/* zadanie: dwie kolumny z kreska */
.stepgrid:not(.single) { grid-template-columns: minmax(340px, 5fr) minmax(0, 7fr); gap: 2rem; }
.stepgrid:not(.single) > div:first-child { padding-right: 2rem; border-right: 1px solid var(--line); }

@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 14px 18px; gap: 10px 18px; }
  .sidenav { flex-direction: row; flex-wrap: wrap; flex: 1 1 100%; order: 3; }
  .sidenav > small, .sidedots { display: none; }
  .side .who { margin: 0 0 0 auto; border: 0; padding: 0; flex-direction: row; align-items: center; gap: 12px; }
  .stage > .page, .stagebar { padding-left: 20px; padding-right: 20px; }
  .stepband-in { padding: 12px 20px; }
  .homecols, .resume, .live { grid-template-columns: 1fr; }
  .stepgrid:not(.single) > div:first-child { padding-right: 0; border-right: 0; }
}
@media print { .side { display: none; } .shell { display: block; } }

/* nagroda: mini gra po ukonczeniu lekcji */
.gamecard { margin-top: 1.5rem; max-width: 560px; border: 1.5px solid var(--c); }
.gamecard[hidden] { display: none; }
.gamecard h2 { margin: 0 0 .3rem; font-size: 1.35rem; }
.gamecard canvas { display: block; width: 100%; max-width: 480px; height: auto; aspect-ratio: 3 / 2; margin: .8rem 0; border: 2px solid var(--ink); border-radius: 12px; background: var(--code); touch-action: none; }
.gamecard canvas:focus-visible { outline: 3px solid var(--c); outline-offset: 3px; }
@media print { .gamecard { display: none; } }
.gamecard:fullscreen { max-width: none; width: 100vw; height: 100vh; border: 0; border-radius: 0; margin: 0; background: var(--paper); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 1.5rem; overflow: auto; }
.gamecard:fullscreen canvas { max-width: none; width: auto; height: min(72vh, calc((100vw - 3rem) * 2 / 3)); }
.gamecard:fullscreen .actions { justify-content: center; }
.gamesetting { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; padding: .9rem 1.25rem; }
.gamesetting form { margin: 0; }
.gamesetting .muted { margin-left: .6rem; }
.gamestats { margin: .2rem 0 0; color: var(--ink); line-height: 1.6; }
.gamestats span { font-weight: 500; }
.gamestats [data-stat="by"]:not(:empty)::before { content: "("; }
.gamestats [data-stat="by"]:not(:empty)::after { content: ")"; }
.gamecard:fullscreen .gamestats { font-size: 1.05rem; }

/* ---- Szachy ---- */
.chess-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .55rem 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.chess-row:first-of-type { border-top: 0; }
.chess { display: grid; grid-template-columns: minmax(0, 560px) minmax(220px, 1fr); gap: 1.5rem; align-items: start; }
.chess-main { width: 100%; }
.chess-player { display: flex; align-items: center; gap: .6rem; padding: .45rem .2rem; font-weight: 700; }
.chess-player i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--ink); display: inline-block; }
.chess-player i.w { background: #fff; } .chess-player i.b { background: var(--ink); }
.chess-player.turn { color: var(--acc-ink); }
.chess-player .badge { margin-left: auto; }
.chess-board { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); grid-template-rows: repeat(8, minmax(0, 1fr)); aspect-ratio: 1; border: 3px solid var(--ink); border-radius: 6px; overflow: hidden; user-select: none; }
.chess-sq { position: relative; display: flex; align-items: center; justify-content: center; border: 0; padding: 0; margin: 0; border-radius: 0; cursor: default; font-family: "Segoe UI Symbol", "Noto Sans Symbols 2", "DejaVu Sans", sans-serif; font-size: clamp(1.6rem, 6.4vw, 3.4rem); line-height: 1; background: #e9e2c8; color: #111; }
.chess-sq.dark { background: #8da36b; }
:root[data-theme="dark"] .chess-sq { background: #b8b090; }
:root[data-theme="dark"] .chess-sq.dark { background: #4f6a4a; }
.chess-sq.mine { cursor: pointer; }
.chess-sq .pc { pointer-events: none; }
.chess-sq .pc.w { color: #fff; text-shadow: 0 0 2px #000, 0 0 2px #000, 0 1px 1px #000; }
.chess-sq .pc.b { color: #14181c; text-shadow: 0 0 1px rgba(255,255,255,.5); }
.chess-sq.last { box-shadow: inset 0 0 0 100px rgba(242, 201, 107, .55); }
.chess-sq.sel { box-shadow: inset 0 0 0 100px rgba(11, 107, 122, .45); }
.chess-sq.chk { box-shadow: inset 0 0 0 100px rgba(179, 38, 30, .55); }
.chess-sq.dest::after { content: ""; position: absolute; width: 28%; height: 28%; border-radius: 50%; background: rgba(11, 107, 122, .6); }
.chess-sq.dest.cap::after { width: 86%; height: 86%; background: transparent; border: 4px solid rgba(11, 107, 122, .65); }
.chess-sq:focus-visible { outline: 3px solid var(--acc); outline-offset: -3px; z-index: 1; }
.chess-sq .co { position: absolute; font: 700 .62rem/1 var(--sans, sans-serif); opacity: .65; pointer-events: none; }
.chess-sq .co.f { right: 3px; bottom: 2px; } .chess-sq .co.r { left: 3px; top: 2px; }
.chess-status { font-weight: 700; font-size: 1.1rem; margin-top: 0; }
.chess-actions, .chess-offer { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-bottom: .8rem; }
.chess-offer { background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: 8px; padding: .6rem .8rem; }
.chess-h { font-size: 1.1rem; margin: 1rem 0 .4rem; }
.chess-moves { margin: 0; padding-left: 0; list-style: none; display: grid; grid-template-columns: 2.4rem 1fr 1fr; gap: .15rem .5rem; max-height: 340px; overflow: auto; font-variant-numeric: tabular-nums; }
.chess-moves .n { color: var(--muted); }
.chess-moves .cur { font-weight: 700; background: var(--acc-bg); border-radius: 4px; padding: 0 .3rem; }
.chess-promo { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); display: flex; align-items: center; justify-content: center; z-index: 50; }
.chess-promo[hidden] { display: none; }
.chess-promo > div { background: var(--surface); border: 2px solid var(--ink); border-radius: 10px; padding: 1rem 1.2rem; display: flex; gap: .5rem; flex-wrap: wrap; max-width: 90vw; }
.chess-promo p { width: 100%; margin: 0 0 .3rem; font-weight: 700; }
@media (max-width: 900px) { .chess { grid-template-columns: 1fr; } }
.chess-actions[hidden], .chess-offer[hidden], .chess-actions [hidden] { display: none; }

/* pomocnik SQL: czat w prawym dolnym rogu */
.chatbot { position: fixed; right: 1.1rem; bottom: 1.1rem; z-index: 60; display: flex; flex-direction: column; align-items: flex-end; gap: .6rem; }
.chat-fab { width: 3.4rem; height: 3.4rem; border-radius: 50%; border: 0; cursor: pointer; background: var(--acc); color: var(--on-acc);
  display: grid; place-items: center; box-shadow: 0 4px 14px rgba(0,0,0,.3); }
.chat-fab svg { width: 1.6rem; height: 1.6rem; }
.chat-fab:hover, .chat-fab.on { filter: brightness(1.08); }
.chat-win { width: min(22rem, calc(100vw - 2.2rem)); height: min(30rem, calc(100vh - 8rem)); display: flex; flex-direction: column;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: .6rem; box-shadow: 0 8px 28px rgba(0,0,0,.35); overflow: hidden; }
.chat-win[hidden] { display: none; }
.chat-head { display: flex; align-items: center; justify-content: space-between; padding: .55rem .8rem; background: var(--acc); color: var(--on-acc); }
.chat-x { border: 0; background: none; color: inherit; font-size: 1.4rem; line-height: 1; cursor: pointer; }
.chat-log { flex: 1; overflow-y: auto; padding: .7rem; display: flex; flex-direction: column; gap: .5rem; }
.chat-msg { max-width: 88%; padding: .45rem .7rem; border-radius: .6rem; font-size: .92rem; word-wrap: break-word; overflow-wrap: anywhere; }
.chat-msg p { margin: .25rem 0; }
.chat-msg pre { margin: .35rem 0; padding: .4rem .55rem; overflow-x: auto; background: var(--code); border-radius: .35rem; }
.chat-msg.bot { align-self: flex-start; background: var(--soft); }
.chat-msg.me { align-self: flex-end; background: var(--acc); color: var(--on-acc); }
.chat-msg.warn { border: 1px solid var(--line); }
.chat-msg.wait { color: var(--muted); font-style: italic; }
.chat-in { display: flex; gap: .4rem; padding: .55rem; border-top: 1px solid var(--line); }
.chat-in input { flex: 1; min-width: 0; }
@media print { .chatbot { display: none; } }
