:root {
  --bg: #f6f7fb;
  --panel: #ffffff;
  --text: #182033;
  --muted: #5c667a;
  --line: #e1e5ee;
  --brand: #3b5bfd;
  --brand-dark: #2a45d6;
  --brand-soft: #eaeefe;
  --accent: #0fa968;
  --warn: #b7791f;
  --bad: #d64545;
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1220;
    --panel: #161b2e;
    --text: #e8ebf4;
    --muted: #a0a8bd;
    --line: #283049;
    --brand: #6f8bff;
    --brand-dark: #8aa0ff;
    --brand-soft: #1d2645;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--brand); }
img { max-width: 100%; }

header.top {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
header.top .wrap { display: flex; align-items: center; gap: 16px; height: 60px; }
.logo { font-weight: 800; font-size: 19px; color: var(--text); text-decoration: none; display: flex; align-items: center; gap: 8px; }
.logo small { font-weight: 500; color: var(--muted); font-size: 13px; }
nav.menu { margin-left: auto; display: flex; gap: 14px; align-items: center; }
nav.menu a { color: var(--text); text-decoration: none; font-weight: 500; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px; }
main.wrap { padding-top: 28px; padding-bottom: 60px; }

h1 { font-size: 30px; line-height: 1.25; margin: 0 0 8px; }
h2 { font-size: 22px; margin: 28px 0 10px; }
.muted { color: var(--muted); }

.btn {
  display: inline-block; border: 0; border-radius: 10px; padding: 10px 18px;
  background: var(--brand); color: #fff; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--brand-dark); }
.btn.ghost { background: transparent; color: var(--brand); border: 1px solid var(--brand); }
.btn.small { padding: 6px 12px; font-size: 14px; }
.btn.danger { background: var(--bad); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.card h3 { margin: 0 0 6px; font-size: 18px; }
a.card { color: var(--text); text-decoration: none; display: block; }
a.card:hover { border-color: var(--brand); }
.price { font-weight: 700; }
.tag { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); }
.tag.ok { background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); }

.promo {
  background: linear-gradient(120deg, var(--brand), #7b4dff);
  color: #fff; border-radius: var(--radius); padding: 22px 24px; margin: 26px 0;
  display: flex; gap: 18px; align-items: center; justify-content: space-between; flex-wrap: wrap;
}
.promo p { margin: 4px 0 0; opacity: .92; }
.promo .btn { background: #fff; color: var(--brand-dark); }

form.stack { display: grid; gap: 14px; max-width: 420px; }
label { display: grid; gap: 6px; font-weight: 600; font-size: 14px; }
input, textarea, select {
  font: inherit; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); width: 100%;
}
textarea { min-height: 160px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 14px; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.check input { width: auto; }

.alert { padding: 10px 14px; border-radius: 10px; margin: 12px 0; background: var(--brand-soft); }
.alert.error { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); }
.alert.ok { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.hidden { display: none !important; }

.layout { display: grid; grid-template-columns: 1fr 320px; gap: 24px; align-items: start; }
@media (max-width: 860px) { .layout { grid-template-columns: 1fr; } }

ol.lessons { list-style: none; margin: 0; padding: 0; }
ol.lessons li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
ol.lessons li:last-child { border-bottom: none; }
ol.lessons .n { width: 26px; height: 26px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-size: 13px; font-weight: 700; flex-shrink: 0; }
ol.lessons .done .n { background: var(--accent); color: #fff; }
ol.lessons .locked { color: var(--muted); }

.progress { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); }

article.lesson { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px 32px; }
article.lesson pre { background: var(--bg); border: 1px solid var(--line); padding: 12px 14px; border-radius: 8px; overflow-x: auto; }
article.lesson code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 14px; }
.lesson-nav { display: flex; justify-content: space-between; gap: 12px; margin-top: 18px; flex-wrap: wrap; }

table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--bg); }

.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 18px; flex-wrap: wrap; }
.tabs button { background: none; border: none; padding: 10px 14px; font: inherit; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; }
.tabs button.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

footer.bottom { border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; padding: 22px 0; }
