/* ==========================================================
   SHIFRLAB — Axborotlarni himoyalash usullari
   ========================================================== */
:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --ink: #15171b;
  --ink-2: #2c3038;
  --muted: #606874;
  --line: #e5e2d9;
  --line-2: #d6d2c6;
  --accent: #0e7468;
  --accent-ink: #ffffff;
  --accent-soft: #e3f1ee;
  --amber: #a85a06;
  --amber-soft: #fbf0df;
  --red: #b42318;
  --red-soft: #fdecea;
  --green: #18794e;
  --green-soft: #e6f4ec;
  --violet: #5b4bc4;
  --violet-soft: #eeebfb;
  --code-bg: #f1efe8;
  --shadow: 0 1px 2px rgba(20, 22, 26, .04), 0 4px 18px rgba(20, 22, 26, .05);
  --radius: 12px;
  --serif: "Iowan Old Style", "Charter", "Source Serif Pro", "Palatino Linotype", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --side-w: 288px;
  --top-h: 60px;
}
[data-theme="dark"] {
  --bg: #0c0f13;
  --surface: #13181e;
  --surface-2: #171d24;
  --ink: #e9ebee;
  --ink-2: #cfd3d9;
  --muted: #949ca7;
  --line: #232a33;
  --line-2: #2e3742;
  --accent: #35c9b4;
  --accent-ink: #062320;
  --accent-soft: #10302c;
  --amber: #f0a23c;
  --amber-soft: #2e2213;
  --red: #f47067;
  --red-soft: #321816;
  --green: #4fc98a;
  --green-soft: #12291d;
  --violet: #a395ff;
  --violet-soft: #1f1b3a;
  --code-bg: #1b222a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 22px rgba(0, 0, 0, .25);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--top-h) + 16px); }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.68 var(--sans); -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
::selection { background: var(--accent); color: var(--accent-ink); }
button, input, select, textarea { font: inherit; color: inherit; }
code, kbd, .mono { font-family: var(--mono); font-size: .9em; }
code { background: var(--code-bg); padding: .12em .4em; border-radius: 5px; word-break: break-word; }
pre { margin: 0; }

/* ---------------- Top bar ---------------- */
.topbar {
  position: fixed; inset: 0 0 auto 0; height: var(--top-h); z-index: 50;
  display: flex; align-items: center; gap: 16px; padding: 0 20px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-weight: 650; letter-spacing: -.01em; white-space: nowrap; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center;
  background: var(--ink); color: var(--bg); font: 600 15px/1 var(--mono);
}
.brand small { display: block; font-weight: 450; color: var(--muted); font-size: 12px; letter-spacing: 0; }
.top-search { flex: 1; max-width: 420px; margin-left: auto; position: relative; }
.top-search input {
  width: 100%; height: 38px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); padding: 0 12px 0 36px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.top-search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.top-search svg { position: absolute; left: 11px; top: 11px; color: var(--muted); }
.search-results {
  position: absolute; top: 44px; left: 0; right: 0; background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow); max-height: 60vh; overflow: auto; display: none; padding: 6px;
}
.search-results.open { display: block; }
.search-results a { display: block; padding: 8px 10px; border-radius: 8px; text-decoration: none; color: var(--ink); }
.search-results a:hover, .search-results a.active { background: var(--accent-soft); }
.search-results a small { display: block; color: var(--muted); font-size: 12.5px; }
.icon-btn {
  height: 38px; min-width: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface);
  display: inline-grid; place-items: center; cursor: pointer; color: var(--ink-2); padding: 0 10px; gap: 6px;
}
.icon-btn:hover { border-color: var(--line-2); }
.menu-btn { display: none; }
.progress-pill { font-size: 13px; color: var(--muted); white-space: nowrap; display: flex; align-items: center; gap: 8px; }
.progress-pill .bar { width: 70px; height: 6px; border-radius: 6px; background: var(--line); overflow: hidden; }
.progress-pill .bar i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .4s; }

/* ---------------- Layout ---------------- */
.layout { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); padding-top: var(--top-h); min-height: 100vh; }
.sidebar {
  position: sticky; top: var(--top-h); height: calc(100vh - var(--top-h)); overflow-y: auto;
  border-right: 1px solid var(--line); padding: 18px 12px 40px; scrollbar-width: thin;
}
.nav-group { margin-bottom: 14px; }
.nav-group > .nav-title {
  font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
  font-weight: 650; padding: 6px 10px; display: flex; gap: 8px; align-items: baseline;
}
.nav-group > .nav-title b { font-family: var(--mono); color: var(--accent); font-weight: 600; }
.nav-link {
  display: flex; align-items: center; gap: 9px; padding: 6px 10px; border-radius: 8px;
  color: var(--ink-2); text-decoration: none; font-size: 14.5px; line-height: 1.35;
}
.nav-link:hover { background: var(--surface); }
.nav-link.active { background: var(--accent-soft); color: var(--ink); font-weight: 560; }
.nav-link .dot { width: 16px; height: 16px; flex: none; border-radius: 50%; border: 1.5px solid var(--line-2); display: grid; place-items: center; }
.nav-link.done .dot { background: var(--accent); border-color: var(--accent); }
.nav-link.done .dot::after { content: ""; width: 7px; height: 4px; border: 2px solid var(--accent-ink); border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -1px); }
.nav-link .tag { margin-left: auto; font-size: 10.5px; font-family: var(--mono); color: var(--muted); }

.main { min-width: 0; padding: 40px clamp(20px, 4vw, 64px) 80px; }
.content { max-width: 860px; margin: 0 auto; }

/* ---------------- Lesson ---------------- */
.lesson { display: none; animation: fadeIn .35s ease; }
.lesson.active { display: block; }
@keyframes fadeIn { from { transform: translateY(8px); } to { transform: none; } }

.crumb { font-size: 13px; color: var(--muted); margin-bottom: 10px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.crumb .chip { font-family: var(--mono); font-size: 11.5px; padding: 2px 8px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line); }
h1, h2, h3, h4 { font-family: var(--serif); letter-spacing: -.012em; line-height: 1.2; color: var(--ink); }
h1 { font-size: clamp(32px, 4.4vw, 46px); margin: 0 0 14px; font-weight: 600; }
h2 { font-size: 27px; margin: 52px 0 14px; font-weight: 600; padding-top: 6px; }
h3 { font-size: 20.5px; margin: 32px 0 10px; font-weight: 600; }
h4 { font-size: 17px; margin: 22px 0 8px; font-family: var(--sans); font-weight: 650; letter-spacing: 0; }
.lead { font-size: 19px; line-height: 1.6; color: var(--ink-2); margin: 0 0 22px; max-width: 70ch; }
p { margin: 0 0 14px; }
.content p, .content li { max-width: 74ch; }
ul, ol { padding-left: 22px; margin: 0 0 16px; }
li { margin: 4px 0; }
hr { border: 0; border-top: 1px solid var(--line); margin: 40px 0; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

.meta-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 28px; }
.meta { font-size: 13px; padding: 4px 10px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); display: inline-flex; gap: 6px; align-items: center; }
.meta b { font-weight: 600; }

/* callouts */
.callout {
  border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius);
  padding: 16px 18px 14px 18px; margin: 20px 0; position: relative;
}
.callout > .c-title { font-weight: 650; font-size: 14px; letter-spacing: .01em; display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.callout p:last-child, .callout ul:last-child { margin-bottom: 0; }
.callout.kid { background: var(--amber-soft); border-color: color-mix(in srgb, var(--amber) 25%, transparent); }
.callout.kid > .c-title { color: var(--amber); }
.callout.why { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 22%, transparent); }
.callout.why > .c-title { color: var(--accent); }
.callout.hist { background: var(--violet-soft); border-color: color-mix(in srgb, var(--violet) 22%, transparent); }
.callout.hist > .c-title { color: var(--violet); }
.callout.danger { background: var(--red-soft); border-color: color-mix(in srgb, var(--red) 22%, transparent); }
.callout.danger > .c-title { color: var(--red); }
.callout.note > .c-title { color: var(--muted); }

/* formula */
.formula {
  font-family: var(--serif); font-size: 21px; text-align: center; padding: 18px 16px; margin: 18px 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto;
}
.formula small { display: block; font-family: var(--sans); font-size: 13px; color: var(--muted); margin-top: 6px; }
.formula .lbl { font-family: var(--sans); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); display: block; margin-bottom: 4px; }
.formulas { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin: 18px 0; }
.formulas .formula { margin: 0; }

/* algorithm steps list */
.algo { counter-reset: s; list-style: none; padding: 0; margin: 16px 0 20px; }
.algo > li { counter-increment: s; position: relative; padding: 10px 14px 10px 50px; border-left: 2px solid var(--line); margin: 0; }
.algo > li::before {
  content: counter(s); position: absolute; left: -15px; top: 9px; width: 28px; height: 28px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--accent); color: var(--accent); font: 600 13px/24px var(--mono); text-align: center;
}
.algo > li:last-child { border-left-color: transparent; }

/* tables */
.table-wrap { overflow-x: auto; margin: 16px 0 22px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table.data { border-collapse: collapse; width: 100%; font-size: 14.5px; }
table.data th, table.data td { padding: 10px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.data th { background: var(--surface-2); font-weight: 650; font-size: 13px; color: var(--ink-2); }
table.data tr:last-child td { border-bottom: 0; }

table.grid { border-collapse: separate; border-spacing: 3px; margin: 10px 0; font-family: var(--mono); font-size: 14px; }
table.grid td, table.grid th { min-width: 30px; height: 30px; text-align: center; border-radius: 6px; padding: 2px 6px; }
table.grid td { background: var(--surface); border: 1px solid var(--line); }
table.grid td.pad { color: var(--muted); background: var(--surface-2); border-style: dashed; }
table.grid th { background: var(--accent-soft); color: var(--accent); font-weight: 650; }
table.grid th.corner { background: transparent; }

/* cards grid */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin: 18px 0 24px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 16px 14px;
  text-decoration: none; color: var(--ink); transition: transform .18s, border-color .18s, box-shadow .18s; display: block;
}
a.card:hover { transform: translateY(-2px); border-color: var(--line-2); box-shadow: var(--shadow); }
.card .k { font: 600 11.5px/1 var(--mono); color: var(--accent); letter-spacing: .04em; }
.card h4 { margin: 8px 0 4px; font-size: 16px; }
.card p { font-size: 14px; color: var(--muted); margin: 0; line-height: 1.5; }

.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 18px 0; }
.compare > div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.compare h4 { margin-top: 0; }
.pros li::marker { content: "+  "; color: var(--green); font-weight: 700; }
.cons li::marker { content: "−  "; color: var(--red); font-weight: 700; }

/* details / Q&A */
details.qa { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); margin: 8px 0; }
details.qa > summary { cursor: pointer; padding: 12px 16px; font-weight: 560; list-style: none; display: flex; gap: 10px; align-items: flex-start; }
details.qa > summary::-webkit-details-marker { display: none; }
details.qa > summary::before { content: "+"; font: 600 16px/1.4 var(--mono); color: var(--accent); width: 14px; flex: none; }
details.qa[open] > summary::before { content: "−"; }
details.qa > div { padding: 0 16px 14px 40px; color: var(--ink-2); }
details.qa > div p:last-child { margin-bottom: 0; }

/* ---------------- Interactive tool ---------------- */
.tool {
  border: 1px solid var(--line); border-radius: 16px; background: var(--surface); margin: 22px 0 28px;
  box-shadow: var(--shadow); overflow: hidden;
}
.tool-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); background: var(--surface-2); flex-wrap: wrap; }
.tool-head .t-badge { font: 600 11px/1 var(--mono); letter-spacing: .06em; text-transform: uppercase; padding: 5px 8px; border-radius: 6px; background: var(--ink); color: var(--bg); }
.tool-head h4 { margin: 0; font-size: 15.5px; }
.tool-examples { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 18px 0; align-items: center; }
.tool-examples span { font-size: 12.5px; color: var(--muted); margin-right: 4px; }
.chip-btn {
  border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 4px 11px; font-size: 13px;
  cursor: pointer; color: var(--ink-2); transition: background .15s, border-color .15s;
}
.chip-btn:hover { border-color: var(--accent); color: var(--accent); }
.tool-body { padding: 16px 18px 18px; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px 14px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink-2); display: flex; justify-content: space-between; gap: 8px; }
.field label em { font-style: normal; font-weight: 450; color: var(--muted); font-size: 12px; }
.field input, .field select, .field textarea {
  border: 1px solid var(--line-2); background: var(--bg); border-radius: 9px; padding: 9px 11px; outline: none; min-width: 0;
  transition: border-color .15s, box-shadow .15s; font-family: var(--mono); font-size: 14.5px;
}
.field textarea { min-height: 76px; resize: vertical; line-height: 1.5; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; align-items: center; }
.btn {
  border: 1px solid var(--line-2); background: var(--surface); border-radius: 10px; padding: 9px 16px; cursor: pointer;
  font-weight: 600; font-size: 14.5px; display: inline-flex; align-items: center; gap: 8px; transition: transform .1s, background .15s, border-color .15s;
}
.btn:hover { border-color: var(--ink-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.dark { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn.ghost { background: transparent; }
.btn.hack { color: var(--amber); border-color: color-mix(in srgb, var(--amber) 45%, transparent); }
.toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin-left: auto; cursor: pointer; user-select: none; }
.toggle input { accent-color: var(--accent); }

.result { margin-top: 16px; display: none; }
.result.show { display: block; animation: fadeIn .3s ease; }
.out-box {
  border-radius: 12px; background: var(--ink); color: var(--bg); padding: 14px 16px; font-family: var(--mono); font-size: 15px;
  display: flex; gap: 12px; align-items: flex-start; word-break: break-all;
}
[data-theme="dark"] .out-box { background: #05080b; color: var(--accent); border: 1px solid var(--line); }
.out-box .lbl { font: 600 10.5px/1.9 var(--sans); text-transform: uppercase; letter-spacing: .1em; opacity: .6; flex: none; }
.out-box .val { flex: 1; white-space: pre-wrap; }
.out-box button { flex: none; background: rgba(255, 255, 255, .12); border: 0; color: inherit; border-radius: 7px; padding: 4px 9px; cursor: pointer; font-size: 12px; }
.err { margin-top: 14px; padding: 11px 14px; border-radius: 10px; background: var(--red-soft); color: var(--red); font-size: 14px; display: none; }
.err.show { display: block; }
.steps-head { display: flex; align-items: center; gap: 10px; margin: 18px 0 8px; flex-wrap: wrap; }
.steps-head h5 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.steps-head .ctrl { margin-left: auto; display: flex; gap: 6px; }
.steps { list-style: none; padding: 0; margin: 0; counter-reset: st; }
.steps li {
  counter-increment: st; position: relative; padding: 9px 12px 9px 46px; border-radius: 10px; margin: 6px 0; max-width: none;
  background: var(--surface-2); border: 1px solid var(--line); font-size: 14.5px; overflow-x: auto;
  animation: stepIn .35s ease both;
}
.steps li::before { content: counter(st); position: absolute; left: 12px; top: 10px; width: 22px; height: 22px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); font: 600 12px/22px var(--mono); text-align: center; }
.steps li.hidden { display: none; }
@keyframes stepIn { from { transform: translateX(-8px); } to { transform: none; } }
.steps code { background: var(--code-bg); }
.ok { color: var(--green); font-weight: 600; }
.warn { color: var(--amber); font-weight: 560; }
.hack { color: var(--amber); }
.fail { color: var(--red); font-weight: 600; }

/* bar chart */
.freq { display: grid; grid-template-columns: repeat(26, 1fr); gap: 3px; align-items: end; height: 140px; margin: 10px 0 2px; }
.freq .b { position: relative; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 2px; transition: height .4s; }
.freq .b.ref { background: var(--line-2); }
.freq-l { display: grid; grid-template-columns: repeat(26, 1fr); gap: 3px; font: 11px var(--mono); color: var(--muted); text-align: center; }
.brute { max-height: 300px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; font-family: var(--mono); font-size: 13.5px; }
.brute div { padding: 5px 12px; border-bottom: 1px solid var(--line); display: flex; gap: 12px; }
.brute div:last-child { border-bottom: 0; }
.brute div b { color: var(--accent); width: 34px; flex: none; }
.brute div.best { background: var(--green-soft); }

/* ---------------- Diagrams ---------------- */
.flow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center; margin: 22px 0; padding: 20px; border: 1px dashed var(--line-2); border-radius: var(--radius); background: var(--surface-2); }
.flow .node { background: var(--surface); border: 1px solid var(--line-2); border-radius: 10px; padding: 10px 14px; text-align: center; font-size: 14px; min-width: 110px; }
.flow .node b { display: block; font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.flow .node.key { border-color: var(--amber); background: var(--amber-soft); }
.flow .node.lock { border-color: var(--accent); background: var(--accent-soft); }
.flow .node.bad { border-color: var(--red); background: var(--red-soft); }
.flow .arr { color: var(--muted); font: 18px var(--mono); }
.flow .arr small { display: block; font-size: 11px; text-align: center; }

.seq { margin: 22px 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 18px; }
.seq-row { display: grid; grid-template-columns: 110px 1fr 110px; align-items: center; gap: 10px; margin: 6px 0; font-size: 14px; }
.seq-row.head { font-weight: 650; text-align: center; border-bottom: 1px solid var(--line); padding-bottom: 8px; margin-bottom: 12px; }
.seq-row .msg { position: relative; text-align: center; padding: 6px 10px 14px; color: var(--ink-2); }
.seq-row .msg::after { content: ""; position: absolute; left: 6px; right: 6px; bottom: 4px; height: 2px; background: var(--accent); }
.seq-row .msg.r::before { content: "▶"; position: absolute; right: 0; bottom: -4px; color: var(--accent); font-size: 12px; }
.seq-row .msg.l::before { content: "◀"; position: absolute; left: 0; bottom: -4px; color: var(--accent); font-size: 12px; }
.seq-row .side { text-align: center; font-size: 12.5px; color: var(--muted); }

.timeline { position: relative; margin: 24px 0; padding-left: 28px; }
.timeline::before { content: ""; position: absolute; left: 8px; top: 6px; bottom: 6px; width: 2px; background: var(--line-2); }
.tl-item { position: relative; margin: 0 0 22px; }
.tl-item::before { content: ""; position: absolute; left: -26px; top: 6px; width: 14px; height: 14px; border-radius: 50%; background: var(--surface); border: 3px solid var(--accent); }
.tl-item.era::before { background: var(--accent); }
.tl-item .when { font: 600 13px var(--mono); color: var(--accent); }
.tl-item h4 { margin: 2px 0 4px; font-family: var(--serif); font-size: 18px; font-weight: 600; }
.tl-item p { margin: 0; color: var(--ink-2); font-size: 15px; }

.layers { margin: 20px 0; display: grid; gap: 6px; }
.layer { display: grid; grid-template-columns: 160px 1fr; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface); }
.layer > b { padding: 10px 12px; background: var(--surface-2); font-size: 13.5px; border-right: 1px solid var(--line); }
.layer > div { padding: 10px 12px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.pill { font: 600 12.5px var(--mono); padding: 3px 9px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); }
.pill.dim { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }

/* paint mixing (DH) */
.paint { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; margin: 20px 0; text-align: center; font-size: 13.5px; }
.paint .col { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 10px; }
.paint .col h5 { margin: 0 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.swatch { width: 46px; height: 46px; border-radius: 50%; margin: 6px auto 2px; border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--line-2); }
.paint .plus { color: var(--muted); font-size: 12px; }

/* ---------------- Hero (home) ---------------- */
.hero { padding: 28px 0 10px; }
.hero .eyebrow { font: 600 12px var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--accent); }
.hero h1 { font-size: clamp(38px, 5.6vw, 62px); line-height: 1.04; margin: 14px 0 18px; }
.hero h1 .scr { font-family: var(--mono); font-weight: 500; font-size: .78em; color: var(--accent); white-space: nowrap; }
.hero .lead { font-size: 20px; }
.hero-cta { display: flex; gap: 10px; flex-wrap: wrap; margin: 24px 0 10px; }
.hero-cta .btn { padding: 12px 20px; font-size: 15.5px; }
.cipher-demo {
  margin: 34px 0 10px; border: 1px solid var(--line); border-radius: 16px; background: var(--ink); color: #e9ebee; padding: 22px 24px;
  font-family: var(--mono); position: relative; overflow: hidden;
}
[data-theme="dark"] .cipher-demo { background: #070a0d; border-color: var(--line); }
.cipher-demo .row { display: flex; gap: 14px; align-items: baseline; margin: 4px 0; flex-wrap: wrap; }
.cipher-demo .row span:first-child { color: #8b949e; font-size: 12px; text-transform: uppercase; letter-spacing: .1em; width: 92px; flex: none; }
.cipher-demo .big { font-size: clamp(18px, 2.6vw, 26px); letter-spacing: .06em; color: #4fe0c9; word-break: break-all; }
.cipher-demo .key { color: #f0a23c; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 26px 0; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat b { display: block; font: 600 28px/1.1 var(--serif); }
.stat span { font-size: 13px; color: var(--muted); }

/* chapter map */
.chapters { display: grid; gap: 10px; margin: 18px 0; }
.chapter {
  display: grid; grid-template-columns: 64px 1fr auto; gap: 14px; align-items: center; padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--ink);
  transition: border-color .15s, transform .15s;
}
.chapter:hover { border-color: var(--accent); transform: translateX(3px); }
.chapter .num { font: 600 26px var(--serif); color: var(--accent); text-align: center; }
.chapter h4 { margin: 0 0 2px; font-size: 16px; }
.chapter p { margin: 0; font-size: 13.5px; color: var(--muted); }
.chapter .cnt { font-size: 12px; color: var(--muted); font-family: var(--mono); }

/* lesson footer */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 56px; padding-top: 24px; border-top: 1px solid var(--line); }
.pager a { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; text-decoration: none; color: var(--ink); background: var(--surface); transition: border-color .15s; }
.pager a:hover { border-color: var(--accent); }
.pager a small { display: block; color: var(--muted); font-size: 12.5px; }
.pager a.next { text-align: right; grid-column: 2; }
.done-btn { margin-top: 36px; display: flex; justify-content: center; }

/* quiz */
.quiz-q { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin: 12px 0; }
.quiz-q h4 { margin: 0 0 10px; font-family: var(--sans); font-size: 15.5px; }
.quiz-q label { display: flex; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; border: 1px solid transparent; font-size: 15px; }
.quiz-q label:hover { background: var(--surface-2); }
.quiz-q label.right { background: var(--green-soft); border-color: color-mix(in srgb, var(--green) 30%, transparent); }
.quiz-q label.wrong { background: var(--red-soft); border-color: color-mix(in srgb, var(--red) 30%, transparent); }
.quiz-q .explain { font-size: 14px; color: var(--muted); margin-top: 8px; display: none; }
.quiz-q.answered .explain { display: block; }
.score { font: 600 22px var(--serif); }

/* glossary */
.gloss { display: grid; grid-template-columns: 200px 1fr; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.gloss > dt, .gloss > dd { padding: 10px 14px; border-bottom: 1px solid var(--line); margin: 0; }
.gloss > dt { font-weight: 650; background: var(--surface-2); border-right: 1px solid var(--line); }
.gloss > dt:nth-last-of-type(1), .gloss > dd:last-child { border-bottom: 0; }

/* canvas stego */
.stego-imgs { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.stego-imgs figure { margin: 0; border: 1px solid var(--line); border-radius: 10px; padding: 8px; background: var(--surface-2); text-align: center; font-size: 12.5px; color: var(--muted); }
.stego-imgs canvas, .stego-imgs img { max-width: 100%; border-radius: 6px; display: block; margin: 0 auto 6px; image-rendering: pixelated; }

/* overlay for mobile */
.scrim { display: none; }

@media (max-width: 1020px) {
  :root { --side-w: 260px; }
  .progress-pill { display: none; }
}
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .menu-btn { display: inline-grid; }
  .sidebar {
    position: fixed; left: 0; top: var(--top-h); bottom: 0; width: 86vw; max-width: 320px; z-index: 40;
    background: var(--bg); transform: translateX(-100%); transition: transform .25s ease; height: auto;
  }
  body.nav-open .sidebar { transform: none; box-shadow: var(--shadow); }
  body.nav-open .scrim { display: block; position: fixed; inset: var(--top-h) 0 0 0; background: rgba(0, 0, 0, .3); z-index: 30; }
  .brand small { display: none; }
  .compare, .stego-imgs { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .seq-row { grid-template-columns: 70px 1fr 70px; font-size: 13px; }
  .layer { grid-template-columns: 1fr; }
  .layer > b { border-right: 0; border-bottom: 1px solid var(--line); }
  .gloss { grid-template-columns: 1fr; }
  .gloss > dt { border-right: 0; border-bottom: 0; }
  .paint { grid-template-columns: 1fr; }
  .chapter { grid-template-columns: 44px 1fr; }
  .chapter .cnt { display: none; }
  .main { padding-top: 28px; }
}
@media (max-width: 520px) {
  .top-search { display: none; }
  .freq { height: 100px; }
}
@media print {
  .topbar, .sidebar, .pager, .tool, .done-btn { display: none !important; }
  .layout { display: block; padding: 0; }
  .lesson { display: block !important; page-break-after: always; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- SEO build qo'shimchalari ---------- */
.crumb a.chip { text-decoration: none; color: var(--ink-2); }
.crumb a.chip:hover { border-color: var(--accent); color: var(--accent); }
.site-foot { margin-top: 48px; padding-top: 18px; border-top: 1px solid var(--line); font-size: 13.5px; color: var(--muted); }
.site-foot p { margin: 0 0 6px; max-width: none; }
.site-foot a { color: var(--muted); }
