:root {
  --bg: #f6f7fb;
  --panel: #ffffff;
  --text: #1c2033;
  --muted: #646b85;
  --line: #e4e7f0;
  --brand: #6d4aff;
  --brand-2: #00c2ff;
  --grad: linear-gradient(135deg, #6d4aff 0%, #b04bff 50%, #00c2ff 100%);
  --code-bg: #1e2230;
  --inline-code: #eef0fb;
  --tip: #0ea371; --uwaga: #e08600; --egzamin: #6d4aff; --info: #1f8fff; --zadanie: #e0407a;
  --radius: 14px;
  --sidebar: 300px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1020; --panel: #151933; --text: #e7e9f6; --muted: #9aa1c2; --line: #262b4d;
    --inline-code: #232848; --code-bg: #0b0d1a;
  }
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16.5px/1.7 Inter, system-ui, sans-serif; }
a { color: var(--brand); }
code, pre { font-family: 'JetBrains Mono', Consolas, monospace; font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0; }

/* ---------- górny pasek ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px;
  height: 62px; padding: 0 20px; background: rgba(14, 16, 32, .92); backdrop-filter: blur(10px); color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand { color: #fff; text-decoration: none; font-weight: 800; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.brand-badge { background: var(--grad); padding: 3px 9px; border-radius: 8px; font-size: 14px; }
.menu-btn { display: none; background: none; border: 0; color: #fff; font-size: 24px; cursor: pointer; }
.progress { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 13px; }
.progress-bar { width: 160px; height: 8px; border-radius: 9px; background: rgba(255,255,255,.12); overflow: hidden; }
.progress-bar span { display: block; height: 100%; width: 0; background: var(--grad); transition: width .6s; }
.btn-ghost { text-decoration: none; white-space: nowrap; background: rgba(255,255,255,.08); color: #fff; border: 1px solid rgba(255,255,255,.18); padding: 8px 14px; border-radius: 10px; cursor: pointer; font: inherit; font-size: 14px; }
.btn-ghost:hover { background: rgba(255,255,255,.16); }
.btn-buy { background: var(--grad); color: #fff; text-decoration: none; font-weight: 700; padding: 9px 16px; border-radius: 10px; font-size: 14px; white-space: nowrap; box-shadow: 0 6px 20px rgba(109,74,255,.35); }
.btn-buy.big { display: inline-block; padding: 14px 28px; font-size: 17px; margin: 8px 0; }

/* ---------- układ ---------- */
.layout { display: flex; }
.sidebar {
  position: sticky; top: 62px; height: calc(100vh - 62px); overflow-y: auto; width: var(--sidebar); flex-shrink: 0;
  padding: 18px 12px 40px; background: var(--panel); border-right: 1px solid var(--line);
}
.mod { margin-bottom: 14px; }
.mod-title { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; color: var(--muted); padding: 6px 10px; }
.sidebar a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 9px; color: var(--text); text-decoration: none; font-size: 14px; line-height: 1.35; }
.sidebar a:hover { background: var(--inline-code); }
.sidebar a.active { background: linear-gradient(90deg, rgba(109,74,255,.16), rgba(0,194,255,.08)); color: var(--brand); font-weight: 600; }
.sidebar a.locked span { opacity: .55; }
.sidebar a em { margin-left: auto; font-style: normal; font-size: 12px; }
.sidebar a em.free { background: var(--tip); color: #fff; padding: 1px 6px; border-radius: 6px; font-size: 10px; font-weight: 700; text-transform: uppercase; }
.dot { width: 14px; height: 14px; flex-shrink: 0; border-radius: 50%; border: 2px solid var(--line); }
.sidebar a.done .dot { background: var(--tip); border-color: var(--tip); box-shadow: inset 0 0 0 2px var(--panel); }

.content { flex: 1; min-width: 0; max-width: 900px; margin: 0 auto; padding: 36px 40px 80px; }
.crumbs { color: var(--muted); font-size: 14px; font-weight: 600; }
.content h1 { font-size: clamp(28px, 4vw, 40px); line-height: 1.2; margin: 6px 0 26px; letter-spacing: -.02em;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ---------- treść lekcji ---------- */
.lesson h2 { font-size: 26px; margin: 48px 0 12px; padding-top: 10px; letter-spacing: -.01em; scroll-margin-top: 80px; }
.lesson h2::before { content: ''; display: block; width: 44px; height: 4px; border-radius: 4px; background: var(--grad); margin-bottom: 14px; }
.lesson h3 { font-size: 20px; margin: 32px 0 8px; scroll-margin-top: 80px; }
.lesson h4 { font-size: 17px; margin: 22px 0 6px; }
.lesson p, .lesson li { color: var(--text); }
.lesson ul, .lesson ol { padding-left: 24px; }
.lesson li { margin: 4px 0; }
.lesson li::marker { color: var(--brand); font-weight: 700; }
.lesson :not(pre) > code { background: var(--inline-code); padding: 2px 6px; border-radius: 6px; font-size: .88em; color: #c03b8a; }
@media (prefers-color-scheme: dark) { .lesson :not(pre) > code { color: #ff8ccf; } }
.lesson hr { border: 0; height: 1px; background: var(--line); margin: 36px 0; }
.lesson img { max-width: 100%; border-radius: 10px; }

.code { margin: 18px 0; border-radius: 12px; overflow: hidden; background: var(--code-bg); box-shadow: 0 10px 30px rgba(20,20,50,.18); }
.code-bar { display: flex; justify-content: space-between; align-items: center; padding: 8px 14px; background: rgba(255,255,255,.05); color: #9aa3c7; font: 600 12px Inter, sans-serif; letter-spacing: .05em; }
.code-bar span::before { content: '● ● ●'; color: #3f4566; margin-right: 12px; letter-spacing: 2px; }
.copy { background: rgba(255,255,255,.08); color: #cfd5f5; border: 0; border-radius: 6px; padding: 4px 10px; cursor: pointer; font: 600 12px Inter, sans-serif; }
.copy:hover { background: rgba(255,255,255,.18); }
.code pre { margin: 0; padding: 16px 18px; overflow-x: auto; font-size: 14px; line-height: 1.6; }
.code pre code.hljs { padding: 0; background: transparent; }
.demo { margin: -10px 0 22px; border: 2px dashed var(--line); border-top: 0; border-radius: 0 0 12px 12px; overflow: hidden; background: #fff; }
.demo-bar { font: 700 12px Inter, sans-serif; color: #0ea371; padding: 8px 14px; background: #effbf6; letter-spacing: .03em; }
.demo iframe { width: 100%; height: 150px; border: 0; display: block; background: #fff; }

.table-wrap { overflow-x: auto; margin: 16px 0; border: 1px solid var(--line); border-radius: 12px; }
.lesson table { border-collapse: collapse; width: 100%; font-size: 15px; background: var(--panel); }
.lesson th { background: var(--inline-code); text-align: left; font-weight: 700; }
.lesson th, .lesson td { padding: 9px 13px; border-bottom: 1px solid var(--line); vertical-align: top; }
.lesson tr:last-child td { border-bottom: 0; }

.box { border-radius: var(--radius); padding: 14px 18px; margin: 20px 0; background: var(--panel); border: 1px solid var(--line); border-left: 5px solid var(--c); }
.box-title { font-weight: 800; color: var(--c); margin-bottom: 4px; }
.box p:first-of-type { margin-top: 4px; }
.box p:last-child { margin-bottom: 4px; }
.box-tip { --c: var(--tip); } .box-uwaga { --c: var(--uwaga); } .box-egzamin { --c: var(--egzamin); }
.box-info { --c: var(--info); } .box-zadanie { --c: var(--zadanie); }
.box-egzamin { background: linear-gradient(135deg, rgba(109,74,255,.07), rgba(0,194,255,.05)); }

details.reveal { margin: 14px 0; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
details.reveal summary { cursor: pointer; padding: 12px 16px; font-weight: 700; color: var(--brand); list-style: none; }
details.reveal summary::before { content: '▸ '; display: inline-block; transition: transform .2s; }
details.reveal[open] summary::before { transform: rotate(90deg); }
.reveal-body { padding: 0 16px 8px; border-top: 1px solid var(--line); }

.downloads { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0; }
.btn-download { display: inline-flex; align-items: center; gap: 6px; padding: 9px 14px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); font-weight: 600; font-size: 14px; text-decoration: none; }
.btn-download:hover { border-color: var(--brand); background: var(--inline-code); }
.file-name { margin: 18px 0 -10px; font: 600 13px 'JetBrains Mono', monospace; color: var(--muted); }
.lesson li.check { list-style: none; margin-left: -22px; }
.lesson li.check input { width: 17px; height: 17px; accent-color: var(--tip); vertical-align: -3px; margin-right: 6px; }
.lesson li.check label { cursor: pointer; }

.done-row { margin: 40px 0 10px; text-align: center; }
.btn-done { background: var(--panel); color: var(--tip); border: 2px solid var(--tip); padding: 12px 24px; border-radius: 12px; font: 700 15px Inter, sans-serif; cursor: pointer; transition: .2s; }
.btn-done:hover, .btn-done.is-done { background: var(--tip); color: #fff; }

.pager { display: flex; justify-content: space-between; gap: 16px; margin-top: 30px; padding-top: 24px; border-top: 1px solid var(--line); }
.pager a { padding: 12px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); text-decoration: none; font-weight: 600; font-size: 14px; max-width: 48%; }
.pager a:hover { border-color: var(--brand); }
.pager a.next { margin-left: auto; text-align: right; }

.locked-box { text-align: center; padding: 40px 24px; border-radius: 20px; background: var(--panel); border: 1px solid var(--line); box-shadow: 0 20px 60px rgba(109,74,255,.12); }
.locked-box.small { margin-top: 40px; padding: 28px; }
.locked-icon { font-size: 54px; }
.muted { color: var(--muted); font-size: 14px; }

/* ---------- quiz ---------- */
.quiz-q { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; margin: 14px 0; }
.quiz-q h4 { margin: 0 0 10px; font-size: 16px; }
.quiz-q h4 small { color: var(--muted); font-weight: 600; margin-right: 6px; }
.quiz-q label { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border-radius: 9px; cursor: pointer; border: 1px solid transparent; }
.quiz-q label:hover { background: var(--inline-code); }
.quiz-q label.ok { background: rgba(14,163,113,.14); border-color: var(--tip); }
.quiz-q label.bad { background: rgba(224,64,122,.12); border-color: var(--zadanie); }
.quiz-q .why { display: none; margin-top: 8px; font-size: 14px; color: var(--muted); }
.quiz.checked .why { display: block; }
.quiz-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 18px; }
.quiz-actions button { background: var(--grad); color: #fff; border: 0; padding: 12px 22px; border-radius: 12px; font: 700 15px Inter, sans-serif; cursor: pointer; }
.quiz-actions button.secondary { background: var(--panel); color: var(--text); border: 1px solid var(--line); }
.quiz-score { font-weight: 800; font-size: 18px; }

.toast { position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 120px); background: #151933; color: #fff; padding: 12px 20px; border-radius: 12px; font-weight: 600; transition: transform .3s; z-index: 50; box-shadow: 0 10px 30px rgba(0,0,0,.3); }
.toast.show { transform: translate(-50%, 0); }

@media (max-width: 960px) {
  .menu-btn { display: block; }
  .sidebar { position: fixed; left: 0; top: 62px; z-index: 15; transform: translateX(-100%); transition: transform .25s; box-shadow: 10px 0 40px rgba(0,0,0,.2); }
  .sidebar.open { transform: none; }
  .content { padding: 24px 16px 60px; }
  .progress-bar { width: 70px; }
  .btn-ghost { font-size: 13px; padding: 7px 10px; white-space: nowrap; }
}
@media (max-width: 560px) {
  .progress { display: none; }
  .btn-buy { margin-left: auto; padding: 8px 10px; font-size: 12px; }
}

/* ---- linki do słownika składni ---- */
.lesson a.syn { text-decoration: none; }
.lesson a.syn code { border-bottom: 2px dotted rgba(109,74,255,.55); cursor: help; transition: background .15s, color .15s; }
.lesson a.syn:hover code { background: var(--brand); color: #fff; border-bottom-color: transparent; }
.lesson a.syn:hover code::after { content: " ↗"; font-size: .8em; }
.syn-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 9px 14px 11px; border-top: 1px solid rgba(255,255,255,.07); background: rgba(255,255,255,.02); font-size: 12.5px; }
.syn-bar span { color: #8b93b8; margin-right: 2px; }
.syn-bar a { font-family: 'JetBrains Mono', Consolas, monospace; color: #cfd5ff; text-decoration: none; padding: 2px 8px; border-radius: 999px; background: rgba(124,92,255,.16); border: 1px solid rgba(124,92,255,.28); line-height: 1.6; }
.syn-bar a:hover { background: var(--brand); color: #fff; }
.btn-syntax { text-decoration: none; white-space: nowrap; color: #fff; font-weight: 700; font-size: 14px; padding: 8px 14px; border-radius: 10px; background: linear-gradient(135deg, #6d4aff, #00c2ff); margin-left: auto; margin-right: 14px; box-shadow: 0 6px 18px rgba(109,74,255,.35); }
.btn-syntax:hover { filter: brightness(1.1); }
@media (max-width: 700px) { .btn-syntax { font-size: 12.5px; padding: 7px 10px; margin-right: 8px; } }

/* diagramy tekstowe (ramki ┌─┐│) – ciasna interlinia, żeby pionowe kreski się stykały */
.code pre code.language-plaintext { line-height: 1.32; }

/* ---------- reset postępu (dół lekcji) ---------- */
.reset-box { margin: 46px 0 10px; padding: 16px 18px; border: 1px dashed var(--line); border-radius: var(--radius); display: flex; gap: 14px; align-items: center; justify-content: space-between; flex-wrap: wrap; color: var(--muted); font-size: 14px; line-height: 1.5; }
.reset-box span { flex: 1 1 260px; }
.btn-reset { background: transparent; color: #d0384f; border: 1px solid #d0384f; border-radius: 10px; padding: 8px 14px; font: 600 14px Inter, system-ui, sans-serif; cursor: pointer; white-space: nowrap; }
.btn-reset:hover { background: #d0384f; color: #fff; }

/* ---------- quiz: wyjaśnienia odpowiedzi ---------- */
.quiz-q .why p { margin: 4px 0; line-height: 1.5; }
.quiz-q .why .why-wrong { color: #d0384f; }
.quiz-q .why .why-ok { color: var(--tip); }