:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-soft: #eef2ff;
  --sky: #0ea5e9;
  --green: #10b981;
  --green-soft: #ecfdf5;
  --amber: #f59e0b;
  --amber-soft: #fffbeb;
  --red: #ef4444;
  --red-soft: #fef2f2;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --bg: #f6f7fb;
  --card: #ffffff;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 4px 16px rgba(15, 23, 42, .05);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; }
h1 { font-size: 1.8rem; margin: .2em 0 .4em; }
.container { max-width: 980px; margin: 0 auto; padding: 20px 16px 80px; }
.narrow { max-width: 760px; margin: 0 auto; }
.loader { text-align: center; color: var(--muted); padding: 60px 0; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.mt { margin-top: 16px; }
.mt2 { margin-top: 28px; }

/* ---------- Верхняя панель ---------- */
.topbar { position: sticky; top: 0; z-index: 10; background: rgba(255,255,255,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.topbar-inner { max-width: 980px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 12px; }
.brand { display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 700; }
.brand:hover { text-decoration: none; }
.brand-logo { background: var(--primary); color: #fff; border-radius: 9px; font-size: .8rem; padding: 5px 7px; letter-spacing: .5px; }
.nav { margin-left: auto; display: flex; gap: 4px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.nav a, .nav button { color: var(--muted); padding: 6px 10px; border-radius: 8px; font-size: .95rem; background: none; border: 0; cursor: pointer; font-family: inherit; }
.nav a:hover, .nav button:hover { background: var(--primary-soft); color: var(--primary); text-decoration: none; }
.nav a.active { color: var(--primary); background: var(--primary-soft); }

/* ---------- Карточки и кнопки ---------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card + .card { margin-top: 16px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid transparent;
  background: var(--primary); color: #fff; padding: 10px 18px; border-radius: 10px; font: inherit; font-weight: 600;
  cursor: pointer; transition: background .15s, transform .05s; text-decoration: none; min-height: 44px;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.secondary { background: #fff; color: var(--primary); border-color: #c7d2fe; }
.btn.secondary:hover { background: var(--primary-soft); }
.btn.ghost { background: transparent; color: var(--muted); border-color: var(--border); }
.btn.ghost:hover { background: #f1f5f9; }
.btn.danger { background: #fff; color: var(--red); border-color: #fecaca; }
.btn.danger:hover { background: var(--red-soft); }
.btn.success { background: var(--green); }
.btn.small { padding: 6px 12px; min-height: 34px; font-size: .9rem; }
.btn.block { width: 100%; }

/* ---------- Формы ---------- */
label.field { display: block; margin-bottom: 14px; }
label.field span { display: block; font-size: .9rem; font-weight: 600; margin-bottom: 5px; }
input[type=text], input[type=password], input[type=search], textarea {
  width: 100%; padding: 11px 13px; border: 1px solid #cbd5e1; border-radius: 10px; font: inherit; background: #fff; color: var(--text);
}
input:focus, textarea:focus { outline: 2px solid #c7d2fe; border-color: var(--primary); }
textarea { min-height: 220px; resize: vertical; line-height: 1.5; }
.error-box { background: var(--red-soft); color: #b91c1c; border: 1px solid #fecaca; padding: 10px 12px; border-radius: 10px; margin-bottom: 14px; }
.ok-box { background: var(--green-soft); color: #047857; border: 1px solid #a7f3d0; padding: 10px 12px; border-radius: 10px; margin-bottom: 14px; }

/* ---------- Авторизация ---------- */
.auth-wrap { min-height: calc(100vh - 40px); display: flex; align-items: center; justify-content: center; padding: 20px 0; }
.auth { width: 100%; max-width: 420px; }
.auth-head { text-align: center; margin-bottom: 18px; }
.auth-head .brand-logo { font-size: 1.1rem; padding: 10px 12px; border-radius: 14px; display: inline-block; }
.auth-head h1 { font-size: 1.45rem; margin: 14px 0 4px; }
.tabs { display: flex; background: #f1f5f9; border-radius: 10px; padding: 4px; margin-bottom: 18px; }
.tabs a { flex: 1; text-align: center; padding: 8px; border-radius: 8px; color: var(--muted); font-weight: 600; }
.tabs a.active { background: #fff; color: var(--text); box-shadow: var(--shadow); }
.tabs a:hover { text-decoration: none; }

/* ---------- Прогресс ---------- */
.progress { height: 8px; background: #e2e8f0; border-radius: 99px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), var(--sky)); border-radius: 99px; transition: width .4s; }
.progress.done > i { background: var(--green); }
.hero { background: linear-gradient(135deg, #4f46e5 0%, #0ea5e9 100%); color: #fff; border-radius: 18px; padding: 24px; box-shadow: var(--shadow); }
.hero h1 { font-size: 1.6rem; margin: 0 0 6px; }
.hero p { margin: 0 0 16px; opacity: .92; }
.hero .progress { background: rgba(255,255,255,.3); }
.hero .progress > i { background: #fff; }
.hero .btn { background: #fff; color: var(--primary); }
.hero .btn:hover { background: #eef2ff; }
.hero-stats { display: flex; gap: 18px; flex-wrap: wrap; margin: 14px 0 18px; font-size: .95rem; }
.hero-stats b { font-size: 1.25rem; display: block; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 99px; font-size: .8rem; font-weight: 600; background: #f1f5f9; color: var(--muted); white-space: nowrap; }
.badge.green { background: var(--green-soft); color: #047857; }
.badge.blue { background: var(--primary-soft); color: var(--primary); }
.badge.amber { background: var(--amber-soft); color: #b45309; }
.badge.red { background: var(--red-soft); color: #b91c1c; }
.badge.white { background: rgba(255,255,255,.22); color: #fff; }

/* ---------- Список модулей ---------- */
.section-title { font-size: 1.2rem; margin: 30px 0 12px; }
.modules { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.module-card { display: flex; flex-direction: column; gap: 10px; color: var(--text); position: relative; transition: transform .12s, box-shadow .12s; }
a.module-card:hover { text-decoration: none; transform: translateY(-2px); box-shadow: 0 8px 26px rgba(15,23,42,.09); }
.module-card.locked { opacity: .6; }
.module-num { width: 38px; height: 38px; border-radius: 10px; background: var(--primary-soft); color: var(--primary); font-weight: 800; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.module-card.completed .module-num { background: var(--green); color: #fff; }
.module-card h3 { margin: 0; font-size: 1.05rem; }
.module-card p { margin: 0; color: var(--muted); font-size: .92rem; flex: 1; }
.meta { display: flex; gap: 10px; flex-wrap: wrap; color: var(--muted); font-size: .82rem; }

/* ---------- Страница модуля ---------- */
.crumbs { font-size: .9rem; color: var(--muted); margin-bottom: 10px; }
.crumbs a { color: var(--muted); }
.goals { margin: 0; padding-left: 20px; }
.goals li { margin: 4px 0; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { border-top: 1px solid var(--border); }
.list li:first-child { border-top: 0; }
.list a, .list .item { display: flex; align-items: center; gap: 12px; padding: 12px 4px; color: var(--text); }
.list a:hover { text-decoration: none; background: #f8fafc; }
.check { width: 26px; height: 26px; border-radius: 50%; border: 2px solid #cbd5e1; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: .8rem; color: #fff; }
.check.done { background: var(--green); border-color: var(--green); }
.part-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.part-head h2 { margin: 0; font-size: 1.15rem; }
.status-line { padding: 12px 14px; border-radius: 10px; background: var(--amber-soft); color: #92400e; font-size: .95rem; }
.status-line.done { background: var(--green-soft); color: #047857; }
.pager { display: flex; gap: 10px; justify-content: space-between; flex-wrap: wrap; margin-top: 24px; }

/* ---------- Урок ---------- */
.lesson-head h1 { margin-bottom: 4px; }
.lesson-content { font-size: 1.05rem; line-height: 1.75; overflow-wrap: break-word; }
.lesson-content h2 { font-size: 1.35rem; margin: 1.8em 0 .6em; }
.lesson-content h3 { font-size: 1.12rem; margin: 1.5em 0 .5em; }
.lesson-content p { margin: .8em 0; }
.lesson-content ul, .lesson-content ol { padding-left: 1.4em; }
.lesson-content li { margin: .35em 0; }
.lesson-content code { background: #f1f5f9; padding: 1px 6px; border-radius: 5px; font-size: .92em; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.lesson-content pre { background: #0f172a; color: #e2e8f0; padding: 14px 16px; border-radius: 10px; overflow-x: auto; font-size: .9rem; line-height: 1.55; white-space: pre; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.lesson-content pre code { background: none; padding: 0; color: inherit; }
.lesson-content pre.diagram { background: #f8fafc; color: #334155; border: 1px solid var(--border); }
.lesson-content blockquote { margin: 1em 0; padding: 8px 16px; border-left: 4px solid #c7d2fe; color: #475569; background: #f8fafc; border-radius: 0 8px 8px 0; }
.table-wrap { overflow-x: auto; margin: 1em 0; border: 1px solid var(--border); border-radius: 10px; }
.lesson-content table, .task-prompt table { border-collapse: collapse; width: 100%; font-size: .95rem; }
.lesson-content th, .lesson-content td, .task-prompt th, .task-prompt td { padding: 9px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.lesson-content th, .task-prompt th { background: #f8fafc; font-weight: 700; }
.lesson-content tr:last-child td { border-bottom: 0; }
.lesson-content details { border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; margin: 1em 0; background: #fff; }
.lesson-content summary { cursor: pointer; font-weight: 600; }
.lesson-content figure { margin: 1.4em 0; text-align: center; }
.lesson-content figure svg, .lesson-content svg.figure { max-width: 100%; height: auto; }
.lesson-content figcaption { font-size: .88rem; color: var(--muted); margin-top: 6px; }
.callout { border-radius: 12px; padding: 14px 16px; margin: 1.2em 0; border: 1px solid; }
.callout > strong:first-child { display: block; margin-bottom: 4px; }
.callout p:first-of-type { margin-top: .3em; }
.callout p:last-child, .callout ul:last-child { margin-bottom: 0; }
.callout.note { background: #f0f9ff; border-color: #bae6fd; }
.callout.note > strong:first-child::before { content: "ℹ️ "; }
.callout.tip { background: var(--green-soft); border-color: #a7f3d0; }
.callout.tip > strong:first-child::before { content: "💡 "; }
.callout.warning { background: var(--amber-soft); border-color: #fde68a; }
.callout.warning > strong:first-child::before { content: "⚠️ "; }
.callout.example { background: #faf5ff; border-color: #e9d5ff; }
.callout.example > strong:first-child::before { content: "🧪 "; }
.callout.key { background: var(--primary-soft); border-color: #c7d2fe; }
.callout.key > strong:first-child::before { content: "🎯 "; }
.term { border-left: 4px solid var(--primary); background: #fff; padding: 10px 14px; margin: 1em 0; border-radius: 0 10px 10px 0; box-shadow: var(--shadow); }
.flow { display: flex; flex-direction: column; align-items: center; margin: 1.4em 0; }
.flow-node { padding: .55em 1.2em; text-align: center; max-width: 92%; font-size: .95rem; line-height: 1.4; color: #1e293b; }
.flow-node.start, .flow-node.end { border-radius: 999px; background: #d1fae5; border: 2px solid #10b981; }
.flow-node.end { background: #fee2e2; border-color: #ef4444; }
.flow-node.process { border-radius: 6px; background: #e0e7ff; border: 2px solid #4f46e5; }
.flow-node.decision { background: #fde68a; padding: .8em 2.4em; clip-path: polygon(10% 0, 90% 0, 100% 50%, 90% 100%, 10% 100%, 0 50%); font-weight: 600; }
.flow-node.io { background: #e0f2fe; padding: .55em 2em; clip-path: polygon(8% 0, 100% 0, 92% 100%, 0 100%); }
.flow-node.subprocess { border-radius: 6px; background: #e0e7ff; border: 2px solid #4f46e5; box-shadow: inset 8px 0 0 -6px #4f46e5, inset -8px 0 0 -6px #4f46e5; padding-left: 1.6em; padding-right: 1.6em; }
.flow-arrow { width: 2px; height: 30px; background: #94a3b8; position: relative; margin-bottom: 6px; }
.flow-arrow::after { content: ""; position: absolute; left: -5px; bottom: -6px; border: 6px solid transparent; border-top: 7px solid #94a3b8; border-bottom: 0; }
.flow-arrow[data-label]::before { content: attr(data-label); position: absolute; left: 10px; top: 4px; font-size: .8rem; color: var(--muted); white-space: nowrap; }
.lesson-actions { margin-top: 32px; padding-top: 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; flex-wrap: wrap; justify-content: space-between; align-items: center; }

/* ---------- Тесты ---------- */
.question { margin-bottom: 14px; }
.question h3 { font-size: 1.02rem; margin: 0 0 4px; }
.q-num { color: var(--muted); font-size: .85rem; font-weight: 600; }
.q-hint { font-size: .85rem; color: var(--muted); margin-bottom: 10px; }
.option { display: flex; gap: 10px; align-items: flex-start; padding: 11px 12px; border: 1px solid var(--border); border-radius: 10px; margin-top: 8px; cursor: pointer; background: #fff; }
.option:hover { border-color: #c7d2fe; background: #fafaff; }
.option input { margin-top: 4px; accent-color: var(--primary); width: 18px; height: 18px; flex-shrink: 0; }
.option.selected { border-color: var(--primary); background: var(--primary-soft); }
.option.right { border-color: var(--green); background: var(--green-soft); }
.option.wrong { border-color: var(--red); background: var(--red-soft); }
.question.is-right { border-left: 4px solid var(--green); }
.question.is-wrong { border-left: 4px solid var(--red); }
.explanation { margin-top: 10px; padding: 10px 12px; background: #f8fafc; border-radius: 8px; font-size: .93rem; }
.result-box { text-align: center; padding: 26px 20px; }
.result-score { font-size: 2.6rem; font-weight: 800; line-height: 1; margin: 6px 0; }
.result-box.pass .result-score { color: var(--green); }
.result-box.fail .result-score { color: var(--red); }
.sticky-submit { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 30%); padding: 20px 0 12px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

/* ---------- Практика ---------- */
.task { scroll-margin-top: 70px; }
.task-head { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 6px; }
.task-head h3 { margin: 0; font-size: 1.08rem; flex: 1; }
.task-type { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; font-weight: 700; margin-bottom: 4px; }
.task-prompt { overflow-wrap: break-word; }
.task-prompt pre { background: #f8fafc; border: 1px solid var(--border); padding: 12px; border-radius: 8px; overflow-x: auto; font-size: .9rem; }
.task-input { margin-top: 14px; }
.task-input input[type=text] { max-width: 360px; }
.order-list { list-style: none; padding: 0; margin: 0; counter-reset: ord; }
.order-item { display: flex; gap: 8px; align-items: center; padding: 10px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 8px; background: #fff; counter-increment: ord; }
.order-item::before { content: counter(ord); width: 26px; height: 26px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: .85rem; }
.order-item span { flex: 1; }
.order-btns { display: flex; gap: 4px; }
.order-btns button { width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--border); background: #fff; cursor: pointer; font-size: 1rem; }
.order-btns button:hover:not(:disabled) { background: var(--primary-soft); }
.order-btns button:disabled { opacity: .35; }
.criteria { list-style: none; padding: 0; margin: 10px 0; font-size: .93rem; }
.criteria li { padding: 4px 0 4px 28px; position: relative; }
.criteria li::before { content: "○"; position: absolute; left: 6px; color: var(--muted); }
.criteria li.ok::before { content: "✓"; color: var(--green); font-weight: 700; }
.criteria li.no { color: #b91c1c; }
.criteria li.no::before { content: "✗"; color: var(--red); font-weight: 700; }
.task-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; align-items: center; }
.feedback { margin-top: 12px; padding: 10px 12px; border-radius: 10px; font-weight: 600; }
.feedback.ok { background: var(--green-soft); color: #047857; }
.feedback.no { background: var(--red-soft); color: #b91c1c; }
.hint-box { margin-top: 12px; background: var(--amber-soft); border: 1px solid #fde68a; padding: 10px 12px; border-radius: 10px; font-size: .95rem; }
.solution-box { margin-top: 14px; background: #f8fafc; border: 1px solid var(--border); padding: 12px 14px; border-radius: 10px; }
.solution-box > strong { display: block; margin-bottom: 6px; }
.solution-box pre { white-space: pre-wrap; background: #fff; border: 1px solid var(--border); padding: 10px; border-radius: 8px; font-size: .88rem; }
.counter { font-size: .82rem; color: var(--muted); margin-top: 4px; }

/* ---------- Режим ---------- */
.mode-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin-top: 16px; }
.mode-card { cursor: pointer; border: 2px solid var(--border); transition: border-color .15s; }
.mode-card:hover { border-color: #c7d2fe; }
.mode-card.active { border-color: var(--primary); background: var(--primary-soft); }
.mode-card h3 { margin: 6px 0; }
.mode-icon { font-size: 1.8rem; }

/* ---------- Таблицы (профиль/админка) ---------- */
.data-table { width: 100%; border-collapse: collapse; font-size: .93rem; }
.data-table th, .data-table td { padding: 10px 10px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
.data-table th { font-size: .8rem; text-transform: uppercase; letter-spacing: .3px; color: var(--muted); background: #f8fafc; }
.data-table tr.clickable { cursor: pointer; }
.data-table tr.clickable:hover td { background: #f8fafc; }
.data-table td.wrap { white-space: normal; min-width: 160px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 14px; }
.stat b { display: block; font-size: 1.5rem; }
.stat span { color: var(--muted); font-size: .85rem; }
.mini-progress { width: 90px; display: inline-block; vertical-align: middle; margin-right: 6px; }

.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: #0f172a; color: #fff; padding: 11px 18px; border-radius: 10px; z-index: 50; box-shadow: var(--shadow); max-width: 90vw; font-size: .95rem; }

@media (max-width: 640px) {
  body { font-size: 15.5px; }
  .container { padding: 14px 12px 70px; }
  h1 { font-size: 1.45rem; }
  .card { padding: 16px; }
  .hero { padding: 20px 16px; }
  .hero h1 { font-size: 1.35rem; }
  .brand-text { display: none; }
  .nav a, .nav button { padding: 6px 8px; font-size: .9rem; }
  .lesson-content { font-size: 1rem; }
  .lesson-actions .btn, .pager .btn { flex: 1; }
  .task-input input[type=text] { max-width: none; }
}
