:root {
  --bg: #ffffff;
  --surface: #f5f6f8;
  --text: #15181d;
  --muted: #5a6270;
  --line: #e2e5ea;
  --accent: #1d4ed8;
  --accent-ink: #ffffff;
  --accent-soft: #e8eefc;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101216;
    --surface: #181b21;
    --text: #eceef2;
    --muted: #9ca5b2;
    --line: #272b33;
    --accent: #86a8ff;
    --accent-ink: #0b1220;
    --accent-soft: #1b2542;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #101216;
  --surface: #181b21;
  --text: #eceef2;
  --muted: #9ca5b2;
  --line: #272b33;
  --accent: #86a8ff;
  --accent-ink: #0b1220;
  --accent-soft: #1b2542;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 17px/1.6 "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow-x: hidden;
}
a { color: inherit; }
h1, h2, h3, p, ul, ol { margin: 0; }
button, input, select { font: inherit; color: inherit; }
math { font-size: 1.1em; }
mi.v { font-weight: 700; font-style: normal; }
.sc { display: block; overflow-x: auto; overflow-y: hidden; }
.lesson p, .note { overflow-x: auto; overflow-y: hidden; }
.line { margin: .35em 0; overflow-x: auto; overflow-y: hidden; padding: 2px 0; }

.wrap {
  max-width: 1040px;
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.narrow { max-width: 740px; }

/* nav */
.nav { border-bottom: 1px solid var(--line); }
.nav .wrap { display: flex; align-items: center; gap: 22px; min-height: 60px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
.brand { font-weight: 700; text-decoration: none; letter-spacing: -.01em; }
.nav nav { display: flex; gap: 18px; }
.nav nav a { color: var(--muted); text-decoration: none; font-size: .95rem; }
.nav nav a:hover, .nav nav a.on { color: var(--text); }
.nav .cur { margin-left: auto; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 7px 8px; font-size: .9rem; }
.nav .cur + .btn { margin-left: 0; }
.owner-bar { background: var(--accent-soft); color: var(--text); font-size: .85rem; padding: 6px 0; }

/* buttons */
.btn {
  display: inline-block; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink);
  padding: 11px 20px; border-radius: 8px; font-weight: 600; text-decoration: none; cursor: pointer; line-height: 1.2;
}
.btn:hover { opacity: .92; }
.btn.sm { padding: 8px 14px; font-size: .9rem; }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--muted); opacity: 1; }

/* hero */
.hero { padding: 72px 0 48px; }
.hero h1 { font-size: clamp(2.1rem, 5.4vw, 3.4rem); line-height: 1.08; letter-spacing: -.025em; max-width: 15em; font-weight: 700; }
.hero .lead { color: var(--muted); font-size: 1.15rem; max-width: 34em; margin-top: 20px; }
.actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 28px; }
.stats { display: flex; gap: 40px; flex-wrap: wrap; margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--line); }
.stats b { display: block; font-size: 1.9rem; letter-spacing: -.02em; line-height: 1.1; }
.stats span { color: var(--muted); font-size: .9rem; }

/* sections */
section { padding: 44px 0; }
section + section { border-top: 1px solid var(--line); }
h2 { font-size: 1.55rem; letter-spacing: -.015em; line-height: 1.2; }
.sub { color: var(--muted); margin-top: 8px; max-width: 38em; }
.page-head { padding: 44px 0 8px; }
.page-head h1 { font-size: 2rem; letter-spacing: -.02em; line-height: 1.15; }

/* rows */
.rows { margin-top: 22px; border-top: 1px solid var(--line); }
.row {
  display: grid; grid-template-columns: 2.2rem 1fr auto; gap: 14px; align-items: baseline;
  padding: 15px 0; border-bottom: 1px solid var(--line); text-decoration: none;
}
a.row:hover .r-title { color: var(--accent); }
.r-num { color: var(--muted); font-variant-numeric: tabular-nums; }
.r-title { font-weight: 600; }
.r-meta { color: var(--muted); font-size: .9rem; }
.r-end { color: var(--muted); font-size: .9rem; white-space: nowrap; text-align: right; }
.topic-h { margin-top: 36px; font-size: 1.15rem; display: flex; gap: 10px; align-items: baseline; }
.topic-h small { color: var(--muted); font-weight: 400; font-size: .9rem; }
.dot { display: inline-block; width: .5em; height: .5em; border-radius: 50%; background: var(--accent); margin-right: 6px; vertical-align: .08em; }
.dot.lock { background: transparent; border: 1.5px solid var(--muted); }
.dot.done { background: var(--accent); }

/* tags */
.tag { display: inline-block; font-size: .75rem; font-weight: 600; padding: 2px 9px; border-radius: 99px; white-space: nowrap; line-height: 1.5; }
.tag.in { background: var(--accent-soft); color: var(--accent); }
.tag.out { border: 1px solid var(--line); color: var(--muted); }
.tag.hl { background: var(--text); color: var(--bg); }
.tag.sl { background: var(--surface); color: var(--text); border: 1px solid var(--line); }
.fcard .tags { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.tag.chk { border: 1px dashed var(--muted); color: var(--muted); margin-left: 6px; }
.tag.free { background: var(--surface); color: var(--text); }

/* feature list */
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 28px; margin-top: 24px; }
.cols h3 { font-size: 1.05rem; margin-bottom: 6px; }
.cols p { color: var(--muted); font-size: .97rem; }

/* pricing */
.price-box { border: 1px solid var(--line); border-radius: 12px; padding: 28px; margin-top: 24px; max-width: 520px; }
.price-box .amt { font-size: 2.6rem; font-weight: 700; letter-spacing: -.03em; line-height: 1; }
.price-box .amt small { font-size: .95rem; font-weight: 400; color: var(--muted); letter-spacing: 0; margin-left: 6px; }
.price-box ul { list-style: none; padding: 0; margin: 20px 0 24px; display: grid; gap: 8px; }
.price-box li { padding-left: 22px; position: relative; }
.price-box li::before { content: ""; position: absolute; left: 2px; top: .62em; width: 9px; height: 5px; border-left: 2px solid var(--accent); border-bottom: 2px solid var(--accent); transform: rotate(-45deg); }
.fine { color: var(--muted); font-size: .85rem; margin-top: 14px; }

/* faq */
details.faq { border-top: 1px solid var(--line); padding: 14px 0; }
details.faq:last-of-type { border-bottom: 1px solid var(--line); }
details.faq summary { cursor: pointer; font-weight: 600; }
details.faq p { color: var(--muted); margin-top: 8px; max-width: 42em; }
.faqs { margin-top: 22px; }

/* formulas page */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin: 20px 0 8px; }
.toolbar input[type=search], .toolbar select {
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; min-width: 0;
}
.toolbar input[type=search] { flex: 1 1 240px; }
.toolbar input:focus, .toolbar select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { background: transparent; border: 0; padding: 9px 13px; cursor: pointer; color: var(--muted); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.count { color: var(--muted); font-size: .9rem; margin: 6px 0 16px; }
.fgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 14px; padding-bottom: 56px; }
.fcard { border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; min-width: 0; }
.fcard header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 6px; }
.fcard h3 { font-size: 1rem; line-height: 1.35; }
.fcard .note { color: var(--muted); font-size: .9rem; margin-top: 8px; }
.fcard .tp { color: var(--muted); font-size: .8rem; margin-top: 10px; }

/* lesson */
.crumbs { padding-top: 28px; color: var(--muted); font-size: .9rem; }
.crumbs a { text-decoration: none; }
.crumbs a:hover { color: var(--text); }
.lesson h1 { font-size: clamp(1.8rem, 4.4vw, 2.5rem); letter-spacing: -.02em; line-height: 1.12; margin-top: 10px; }
.meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; align-items: center; color: var(--muted); font-size: .9rem; }
.video { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; width: 100%; aspect-ratio: 16 / 9;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; margin: 26px 0 8px; color: var(--muted); text-decoration: none; text-align: center; padding: 16px; }
a.video { color: var(--text); font-weight: 600; }
a.video:hover { border-color: var(--accent); }
a.video small { color: var(--muted); font-weight: 400; }
.lesson h2 { font-size: 1.2rem; margin: 40px 0 12px; }
.lesson ul.ideas { padding-left: 1.2em; display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.lesson ul.ideas li::marker { color: var(--accent); }
.eg { border-top: 1px solid var(--line); padding-top: 16px; margin-top: 18px; }
.eg .q { font-weight: 600; }
.eg ol { padding-left: 1.4em; margin-top: 10px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.eg li::marker { color: var(--muted); }
.flist { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.practice { border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; margin-top: 14px; }
.practice details { margin-top: 12px; }
.practice summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.practice details p { margin-top: 8px; }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 48px 0 0; }
.pager a { border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; text-decoration: none; min-width: 0; }
.pager a:hover { border-color: var(--accent); }
.pager small { display: block; color: var(--muted); font-size: .8rem; }
.pager a.next { text-align: right; grid-column: 2; }
.done-row { margin-top: 36px; }
.lock-panel { border: 1px solid var(--line); border-radius: 12px; padding: 24px; margin: 28px 0; background: var(--surface); }
.lock-panel h2 { margin: 0 0 6px; }
.lock-panel p { color: var(--muted); margin-bottom: 16px; }

footer { border-top: 1px solid var(--line); margin-top: 40px; padding: 28px 0 48px; color: var(--muted); font-size: .85rem; }
footer p + p { margin-top: 6px; }
.pb { padding-bottom: 56px; }

@media (max-width: 560px) {
  .hero { padding-top: 44px; }
  .nav .wrap { gap: 10px 16px; }
  .nav nav { gap: 14px; }
  .stats { gap: 24px; }
  .row { grid-template-columns: 1.8rem 1fr; }
  .r-end { grid-column: 2; text-align: left; margin-top: -8px; }
}
.r-end .tag { margin-right: 8px; }

/* diagrams */
.fig { margin: 26px 0 8px; border: 1px solid var(--line); border-radius: 10px; padding: 16px 14px 12px; background: var(--bg); }
.dg { display: block; width: 100%; max-width: 520px; height: auto; margin: 0 auto; }
.fig figcaption { color: var(--muted); font-size: .9rem; text-align: center; margin-top: 10px; }
.dg text { font: 500 13px "Figtree", system-ui, sans-serif; fill: var(--text); }
.dg text.m { fill: var(--muted); }
.dg text.sm { font-size: 11px; fill: var(--muted); }
.dg text.bt { font-weight: 700; }
.dg text.hl { fill: var(--accent); font-weight: 700; }
.dg .k { stroke: var(--text); stroke-width: 1.6; fill: none; }
.dg .g { stroke: var(--muted); stroke-width: 1; fill: none; }
.dg .g2 { stroke: var(--muted); stroke-width: 2; fill: none; }
.dg .a { stroke: var(--accent); stroke-width: 2.2; fill: none; }
.dg .a3 { stroke: var(--accent); stroke-width: 4; fill: none; }
.dg .ad { stroke: var(--accent); stroke-width: 2; stroke-dasharray: 6 4; fill: none; }
.dg .ds { stroke-dasharray: 4 4; }
.dg .dot { fill: var(--text); stroke: none; }
.dg .dota { fill: var(--accent); stroke: none; }
.dg .box { fill: var(--surface); stroke: var(--line); stroke-width: 1.2; }
.dg .bar { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 1; }
.dg .bar.hi { fill: var(--accent); }
.dg .mk { fill: var(--text); }
.dg .mka { fill: var(--accent); }
.dg .mkm { fill: var(--muted); }
.dg .f { fill: var(--accent-soft); stroke: none; }
.dg .f.k { stroke: var(--text); stroke-width: 1.6; }
.dg rect.g { fill: none; }

/* method steps */
.method { list-style: none; padding: 0; margin: 0; counter-reset: m; display: grid; grid-template-columns: minmax(0, 1fr); }
.method li { counter-increment: m; position: relative; padding: 2px 0 20px 46px; min-height: 30px; }
.method li::before { content: counter(m); position: absolute; left: 0; top: 0; width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: .9rem; display: grid; place-items: center; }
.method li::after { content: ""; position: absolute; left: 14px; top: 36px; bottom: 6px; width: 2px; background: var(--line); }
.method li:last-child { padding-bottom: 2px; }
.method li:last-child::after { display: none; }

/* purchase confirmation */
.nav-tag { margin-left: auto; }
.thanks { padding-top: 56px; }
.tick { display: block; width: 44px; height: 44px; border-radius: 50%; background: var(--accent-soft); position: relative; margin-bottom: 20px; }
.tick::after { content: ""; position: absolute; left: 14px; top: 12px; width: 15px; height: 8px; border-left: 3px solid var(--accent); border-bottom: 3px solid var(--accent); transform: rotate(-45deg); }
.stats.compact { margin-top: 18px; padding-top: 0; border-top: 0; }
section > .method { margin-top: 20px; }
