*{box-sizing:border-box}html{scroll-behavior:smooth}body{margin:0;font-family:Inter,system-ui,-apple-system,"Segoe UI",sans-serif;background:#f5f7fb;color:#172033;line-height:1.68}.wrap{max-width:1180px;margin:auto;padding:0 18px}.top{background:#fff;border-bottom:1px solid #dde3ec}.headrow{display:flex;justify-content:space-between;gap:20px;align-items:center;padding:18px}.eyebrow{font-size:.78rem;letter-spacing:.15em;font-weight:800;color:#375bb5}.top h1{margin:2px 0}.status{font-size:.86rem;background:#edf3ff;padding:10px 12px;border-radius:12px}.hero{display:grid;grid-template-columns:1.6fr .8fr;gap:18px;padding:28px 0}.hero>div{background:white;border:1px solid #dde3ec;border-radius:18px;padding:24px}.pill{display:inline-block;font-size:.78rem;font-weight:800;padding:5px 9px;border-radius:999px}.ready{background:#e8f7ee;color:#1e6b3e}.working{background:#fff4db;color:#865d00}.tabs{display:flex;gap:10px;margin-bottom:18px}.tab{padding:11px 16px;border-radius:10px;border:1px solid #cfd8e5;background:#fff;font-weight:800}.tab.active{background:#224fb2;color:#fff}.subject{display:none}.subject.active{display:block}.layout{display:grid;grid-template-columns:285px 1fr;gap:20px}.sidebar{background:#fff;border:1px solid #dde3ec;border-radius:16px;padding:14px;height:max-content;position:sticky;top:20px}.sidebar button{width:100%;display:grid;grid-template-columns:25px 1fr;text-align:left;gap:4px 6px;border:0;background:transparent;padding:10px 8px;border-radius:9px}.sidebar button em{grid-column:2;font-size:.68rem;color:#718096}.chapter{background:#fff;border:1px solid #dde3ec;border-radius:18px;padding:28px;margin-bottom:20px}.chapter-head{display:flex;justify-content:space-between;gap:20px;border-bottom:1px solid #e4e9f0;padding-bottom:20px}.chapter-meta{display:flex;gap:6px;flex-wrap:wrap}.chapter-meta span{font-size:.75rem;background:#f0f3f8;padding:5px 8px;border-radius:8px}.toc{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:7px;background:#f7f9fc;padding:18px;border-radius:14px;margin:22px 0}.toc b{grid-column:1/-1}.toc a{color:#294e9c;text-decoration:none}.lesson{padding:22px 0;border-top:1px solid #e7ebf1}.knowledge,.formula,.note,.worked,.trap,.checklist{padding:16px 18px;border-radius:12px;margin:14px 0}.knowledge{background:#f7f9fc}.formula{background:#edf3ff;border-left:4px solid #3a67c7}.note{background:#fff8e8;border-left:4px solid #d9a326}.worked{background:#f8fbff;border:1px solid #dce7f7}.trap{background:#fff0f2;border-left:4px solid #d9485f}.answer{background:#eef8f1;padding:8px 10px;border-radius:8px}.q{padding:12px 0;border-top:1px solid #e5e9ef}.q label{display:block;font-weight:700;margin-bottom:7px}.q input{width:100%;max-width:380px;padding:11px 12px;border:1px solid #cbd5e1;border-radius:9px;font-size:16px}.primary{border:0;background:#224fb2;color:#fff;font-weight:800;padding:11px 16px;border-radius:10px}.result{margin-top:14px;padding:14px;border-radius:10px;background:#f7f9fc;font-weight:800}@media(max-width:850px){.hero,.layout{grid-template-columns:1fr}.sidebar{position:static}.toc{grid-template-columns:1fr}.chapter{padding:20px}.chapter-head{flex-direction:column}}


/* --- FINAL UI POLISH --- */
body{min-height:100vh}
button,a,input{font:inherit}
button{cursor:pointer}
button:focus-visible,a:focus-visible,input:focus-visible{
  outline:3px solid rgba(34,79,178,.28);
  outline-offset:2px
}
.top{position:relative;z-index:20}
.top h1{font-size:clamp(1.8rem,4vw,2.6rem);line-height:1.05}
.hero h2{margin:.35rem 0 .65rem;font-size:clamp(1.35rem,3vw,2rem);line-height:1.15}
.hero-card{display:flex;flex-direction:column;justify-content:center}
.study-progress{
  margin:12px 0 0;
  padding:10px 12px;
  background:#eef4ff;
  border:1px solid #d6e2fb;
  border-radius:10px;
  font-weight:800;
  color:#24478f
}
.tabs{
  position:sticky;
  top:0;
  z-index:18;
  padding:10px 0;
  background:rgba(245,247,251,.94);
  backdrop-filter:blur(10px)
}
.tab{transition:.18s ease;box-shadow:0 1px 2px rgba(20,35,60,.04)}
.tab:hover{border-color:#8ea9dd;transform:translateY(-1px)}
.sidebar button{transition:.15s ease;color:#26354d}
.sidebar button:hover{background:#f2f6fd}
.sidebar button.active-chapter{
  background:#eaf1ff;
  color:#173d91;
  box-shadow:inset 3px 0 0 #224fb2
}
.chapter{scroll-margin-top:76px;box-shadow:0 6px 24px rgba(31,50,84,.035)}
.chapter h2{line-height:1.15}
.lesson{scroll-margin-top:76px}
.lesson h3{line-height:1.25}
.worked h4,.knowledge h4,.formula h4{margin-top:0}
pre{
  overflow:auto;
  padding:14px 16px;
  border-radius:10px;
  background:#172033;
  color:#f2f6ff;
  line-height:1.5;
  tab-size:4
}
code{font-family:"SFMono-Regular",Consolas,"Liberation Mono",monospace}
p code,li code{background:#eef2f7;color:#24334c;padding:2px 5px;border-radius:5px}
pre code{background:transparent;color:inherit;padding:0}
.q input:focus{border-color:#557dcc;box-shadow:0 0 0 3px rgba(34,79,178,.12)}
.primary{transition:.15s ease}
.primary:hover{background:#183f94;transform:translateY(-1px)}
.result:not(:empty){border:1px solid #d9e2ef}
.back-to-top{
  position:fixed;
  right:22px;
  bottom:22px;
  width:46px;
  height:46px;
  border:0;
  border-radius:50%;
  background:#224fb2;
  color:#fff;
  font-size:24px;
  font-weight:800;
  box-shadow:0 8px 24px rgba(34,79,178,.28);
  opacity:0;
  pointer-events:none;
  transform:translateY(8px);
  transition:.2s ease;
  z-index:50
}
.back-to-top.show{opacity:1;pointer-events:auto;transform:translateY(0)}
.site-footer{
  margin-top:34px;
  background:#172033;
  color:#d9e2ef;
  padding:24px 0;
  font-size:.9rem
}
.site-footer p{margin:0}
@media(max-width:850px){
  .headrow{align-items:flex-start;flex-direction:column}
  .status{width:100%}
  .hero{padding-top:18px}
  .tabs{overflow-x:auto;white-space:nowrap}
  .tab{flex:1 0 auto}
  .sidebar{
    max-height:none;
    display:grid;
    grid-template-columns:repeat(2,minmax(0,1fr));
    gap:4px
  }
  .side-title{grid-column:1/-1}
  .sidebar button{min-height:54px}
  .chapter{border-radius:14px}
  .worked,.knowledge,.formula,.note,.trap,.checklist{padding:14px}
  .back-to-top{right:14px;bottom:14px}
}
@media(max-width:540px){
  .wrap{padding:0 12px}
  .hero>div{padding:18px}
  .chapter{padding:16px}
  .sidebar{grid-template-columns:1fr}
  .toc{padding:14px}
}
@media print{
  .sidebar,.tabs,.back-to-top,.primary,.top .status{display:none!important}
  body{background:#fff;color:#000;font-size:10.5pt}
  .wrap{max-width:none;padding:0}
  .subject{display:block!important}
  .layout{display:block}
  .chapter{box-shadow:none;border:0;break-before:page;padding:0}
  .lesson,.worked,.knowledge,.formula,.note,.trap,.checklist{break-inside:avoid}
  a{color:#000;text-decoration:none}
}


/* --- FIX: wszystkie rozdziały zawsze w prawej kolumnie --- */
@media (min-width:851px){
  .layout > .sidebar{
    grid-column:1;
    grid-row:1 / span 12;
    align-self:start;
  }
  .layout > .chapter{
    grid-column:2;
  }
}
