:root {
  --brand: #4208A8;
  --brand-ink: #2b0670;
  --brand-soft: #f0ebfc;
  --grey: #CCCCCC;
  --bg: #f6f7fb;
  --card: #ffffff;
  --line: #eceaf4;
  --ink: #17121f;
  --ink-2: #5c5568;
  --danger: #d92d20;
  --ok: #12805c;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(23, 18, 31, .04), 0 4px 16px rgba(23, 18, 31, .05);
  --font: 'Onest', 'Segoe UI', system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: var(--font); background: var(--bg); color: var(--ink); font-size: 15px; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 26px; font-weight: 800; letter-spacing: -.02em; margin: 10px 0 16px; }
h2 { font-size: 18px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 700; }

/* шапка — белая, как в BossFree */
.topbar { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30; }
.topbar-inner { max-width: 1600px; margin: 0 auto; padding: 10px 20px; display: flex; align-items: center; gap: 16px; }
.logo { color: var(--brand); font-size: 20px; font-weight: 600; flex-shrink: 0; white-space: nowrap; }
.logo b { font-weight: 800; }
.logo:hover { text-decoration: none; }
.topnav { display: flex; align-items: center; gap: 0; flex: 1; min-width: 0; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.topnav::-webkit-scrollbar { display: none; }
.topsearch { flex: 0 1 180px; min-width: 120px; margin-right: 8px; }
.topnav a { color: var(--ink-2); font-weight: 500; font-size: 13px; padding: 6px 8px; border-radius: 10px; white-space: nowrap; flex-shrink: 0; }
.topnav a:hover { background: var(--brand-soft); color: var(--brand); text-decoration: none; }
.topuser { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--ink-2); flex-shrink: 0; white-space: nowrap; }
.topuser .avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand-soft); color: var(--brand);
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; }

.page { max-width: 1280px; margin: 24px auto; padding: 0 20px; }
.footer { text-align: center; color: #9a93a8; font-size: 13px; padding: 28px; }

/* карточки */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.layout { display: grid; grid-template-columns: 280px 1fr; gap: 20px; align-items: start; }
.content-narrow { max-width: 880px; margin: 0 auto; display: grid; gap: 16px; }

/* дерево разделов */
.side-title { margin: 0 0 8px; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: #9a93a8; }
.tree { list-style: none; padding-left: 14px; margin: 4px 0; }
.sidebar > .tree { padding-left: 0; }
.tree-link { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 10px;
  border-radius: 10px; color: var(--ink); font-size: 14px; font-weight: 500; }
.tree-link:hover { background: var(--brand-soft); text-decoration: none; }
.tree-link.active { background: var(--brand); color: #fff; }
.tree.trash { border-top: 1px dashed var(--grey); margin-top: 12px; padding-top: 8px; }
.menu-col { list-style: none; margin: 2px 0 10px; padding: 0 0 0 4px; display: flex; flex-direction: column; gap: 2px; }
.menu-item { display: flex; align-items: flex-start; gap: 8px; padding: 6px 8px; border-radius: 8px;
  border: 1px solid transparent; color: #3e4d78; font-size: 14px; font-weight: 500; line-height: 1.35; }
.menu-item:hover { background: #f3f5fb; text-decoration: none; }
.menu-item.active { background: #fff; border-color: #1c2430; color: #243056; }
.menu-ico { width: 1.25em; flex: none; text-align: center; line-height: 1.35; }
.count { background: #efeaf9; border-radius: 999px; padding: 1px 9px; font-size: 12px; color: var(--brand); font-weight: 600; }
.tree-link.active .count { background: rgba(255,255,255,.22); color: #fff; }

/* кнопки */
.btn { display: inline-block; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 12px; padding: 9px 18px; cursor: pointer; font-size: 14px; font-weight: 600; font-family: var(--font);
  transition: box-shadow .15s, background .15s; }
.btn:hover { text-decoration: none; box-shadow: var(--shadow); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-ink); }
.btn.small { padding: 5px 12px; font-size: 13px; border-radius: 10px; }
.btn.tiny { padding: 2px 8px; font-size: 12px; border-radius: 8px; }
.btn.danger { border-color: #f3c6c2; color: var(--danger); }
.btn.danger:hover { background: #fdf1f0; }
.btn.link, button.link { border: 0; background: none; color: var(--brand); cursor: pointer; font-size: 14px; padding: 0; }
.btn.wide { width: 100%; margin-top: 6px; }
.btn:disabled { opacity: .5; cursor: default; }

/* формы */
label { display: block; margin: 12px 0; font-size: 14px; font-weight: 500; color: var(--ink-2); }
input[type=text], input:not([type]), input[type=password], input[type=number], input[type=url], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; font-size: 14px;
  margin-top: 6px; font-family: var(--font); background: #fbfbfe; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; background: #fff; }
textarea { min-height: 90px; }
label.check { display: flex; gap: 8px; align-items: center; font-weight: 500; color: var(--ink); margin: 8px 0; }
label.check input { width: auto; margin: 0; }
fieldset.groups { border: 1px solid var(--line); border-radius: 12px; margin: 12px 0; max-height: 260px; overflow: auto; padding: 8px 12px; }
fieldset.groups legend { font-size: 13px; font-weight: 700; color: var(--ink-2); padding: 0 6px; }

/* фильтры и таблицы */
.bar { margin-bottom: 16px; }
.filters { display: flex; gap: 8px; }
.filters input { flex: 2; margin-top: 0; }
.filters select { flex: 1; width: auto; margin-top: 0; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; padding: 10px 12px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em;
  color: #9a93a8; border-bottom: 1px solid var(--line); }
.table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid #f4f2fa; font-size: 14px; vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.tablecard { padding: 8px; }
.tablecard .table th, .tablecard .table td { padding: 10px 12px; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.actions form { display: inline; }

/* бейджи и статусы */
.badge { display: inline-block; background: var(--brand-soft); color: var(--brand); border-radius: 8px;
  padding: 3px 10px; font-size: 12px; font-weight: 600; }
.badge.brand { color: #fff; }
.status { font-size: 12px; border-radius: 8px; padding: 3px 10px; font-weight: 600; white-space: nowrap; }
.status.draft { background: #fff4d6; color: #8a6d00; }
.status.ready { background: #dff5ea; color: var(--ok); }
.status.trash { background: #fde8e7; color: var(--danger); }

/* витрина материалов */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.card.mat { display: block; transition: box-shadow .15s, transform .1s; }
.card.mat:hover { box-shadow: 0 6px 24px rgba(23,18,31,.10); text-decoration: none; transform: translateY(-1px); }
.card.mat h3 { margin: 10px 0 6px; font-size: 15px; color: var(--ink); font-weight: 700; }

.alert { background: #fdecea; border: 1px solid #f5c6c0; color: var(--danger); border-radius: 12px; padding: 12px 16px; }
.notice { background: #eef0fe; border: 1px solid #d9dffc; border-radius: 12px; padding: 12px 16px; }
.pass { background: #e4f7ee; border: 1px solid #bfe8cf; color: var(--ok); border-radius: 12px; padding: 12px 16px; }
.fail { background: #fdecea; border: 1px solid #f5c6c0; color: var(--danger); border-radius: 12px; padding: 12px 16px; }
.muted { color: #9a93a8; }
.small { font-size: 12px; }
.mono { font-family: Consolas, monospace; font-size: 11px; word-break: break-all; }
.empty { text-align: center; padding: 48px; color: #9a93a8; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
summary { cursor: pointer; }

/* вход: две панели, как в BossFree */
.login-wrap { display: flex; justify-content: center; padding-top: 48px; }
.login-split { display: grid; grid-template-columns: 420px 440px; max-width: 920px; width: 100%; overflow: hidden; padding: 0; }
.login-form { padding: 40px; }
.login-form h1 { font-size: 22px; margin: 18px 0; }
.login-side { background: var(--brand); color: #fff; padding: 48px 40px; display: flex; flex-direction: column; justify-content: center; gap: 14px; }
.login-side h2 { color: #fff; font-size: 26px; font-weight: 800; line-height: 1.25; margin: 0; }
.login-side p { color: #cfc3f2; font-size: 15px; line-height: 1.5; margin: 0; }
.login-side .foot { margin-top: 40px; color: #cfc3f2; font-size: 13px; }

/* страница урока */
.lesson h1 { margin-top: 4px; }
.lesson.has-doc { padding-bottom: 12px; }
.doc-frame { width: 100%; min-height: calc(100vh - 280px); border: 0; border-radius: 12px; background: #fff; display: block; }
body.doc-open .page { max-width: 1600px; }
.lesson img, .lesson video { max-width: 100%; border-radius: 12px; }
.lesson figure { margin: 16px 0; }
.lesson figcaption { margin-top: 8px; color: var(--ink-2); font-size: 14px; }
.block { margin: 12px 0; }
.block.text p { margin: 6px 0; line-height: 1.6; }
fieldset.question { border: 1px solid var(--line); border-radius: 12px; margin: 12px 0; padding: 12px 16px; }
fieldset.question legend { font-weight: 700; padding: 0 8px; }
label.option { display: flex; gap: 10px; align-items: center; margin: 8px 0; font-weight: 500; color: var(--ink); }
label.option input { width: auto; margin: 0; }

/* программы: прогресс и статусы шагов */
.progress { background: #efedf5; border-radius: 999px; height: 8px; margin: 10px 0; }
.progress-fill { background: var(--brand); height: 8px; border-radius: 999px; }
.step { font-size: 12px; border-radius: 8px; padding: 3px 10px; white-space: nowrap; font-weight: 600; }
.step.done { background: #dff5ea; color: var(--ok); }
.step.failed, .step.overdue { background: #fde8e7; color: var(--danger); }
.step.opened, .step.pending { background: #fff4d6; color: #8a6d00; }
.step.new { background: #efedf5; color: #6b6478; }
.step.removed { background: #efedf5; color: #9a93a8; text-decoration: line-through; }
ol.steps { padding-left: 0; list-style: none; counter-reset: step; }
ol.steps li { counter-increment: step; padding: 12px 12px 12px 48px; position: relative; border-bottom: 1px solid #f4f2fa; }
ol.steps li::before { content: counter(step); position: absolute; left: 2px; top: 10px; width: 26px; height: 26px;
  border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: flex; align-items: center;
  justify-content: center; font-size: 13px; font-weight: 700; }

/* блочный редактор */
.editor-page { display: grid; gap: 12px; }
.editor-layout { display: grid; grid-template-columns: 1fr 330px; gap: 20px; align-items: start; }
.editor-side { display: grid; gap: 16px; position: sticky; top: 84px; }
.canvas { min-height: 300px; padding: 12px; }
.blk { border: 1px solid transparent; border-radius: 12px; margin: 4px 0; background: #fff; transition: border-color .15s; }
.blk:hover { border-color: var(--line); }
.blk-head { display: flex; justify-content: space-between; align-items: center; padding: 4px 8px; }
.blk-kind { font-size: 11px; color: var(--brand); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.blk-tools { display: flex; gap: 4px; opacity: 0; }
.blk:hover .blk-tools { opacity: 1; }
.blk-body { padding: 4px 8px 10px; display: grid; gap: 8px; }
.blk-text { border: 0; resize: none; font-size: 15px; line-height: 1.6; min-height: 40px; padding: 6px; width: 100%;
  background: transparent; margin-top: 0; }
.blk-text:focus { outline: 1px solid var(--brand); border-radius: 8px; background: #fff; }
.rich-editor { min-width: 0; }
.rich-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 8px; border: 1px solid var(--line);
  border-radius: 10px 10px 0 0; background: #f7f6fb; }
.rich-btn { min-width: 30px; height: 32px; padding: 4px 7px; border: 1px solid transparent; border-radius: 7px;
  background: transparent; color: var(--ink); font-family: var(--font); font-size: 14px; cursor: pointer; }
.rich-btn:hover, .rich-btn:focus { border-color: var(--line); background: #fff; color: var(--brand); outline: none; }
.rich-btn.bold { font-weight: 800; }
.rich-btn.italic { font-style: italic; font-family: Georgia, serif; }
.rich-btn.underline { text-decoration: underline; }
.rich-btn.strike { text-decoration: line-through; }
.rich-sep { width: 1px; height: 24px; margin: 0 3px; background: var(--line); }
.rich-toolbar select { width: auto; min-width: 0; height: 32px; margin: 0; padding: 4px 24px 4px 8px; border-radius: 7px;
  background: #fff; font-size: 13px; }
.rich-toolbar .font-select { max-width: 145px; }
.rich-toolbar .size-select { width: 78px; }
.rich-toolbar .format-select { max-width: 135px; }
.rich-color { width: 32px; height: 32px; padding: 3px; border: 1px solid var(--line); border-radius: 7px; background: #fff; cursor: pointer; }
.rich-text { min-height: 120px; max-height: 700px; overflow-y: auto; padding: 12px; border: 1px solid var(--line);
  border-top: 0; border-radius: 0 0 10px 10px; background: #fff; line-height: 1.6; overflow-wrap: anywhere; }
.rich-text:focus { outline: 2px solid var(--brand); outline-offset: -2px; border-radius: 0 0 10px 10px; }
.rich-text:empty::before { content: attr(data-placeholder); color: #9a93a8; pointer-events: none; }
.rich-text p, .block.text p { margin: 6px 0; }
.rich-text h1, .rich-text h2, .rich-text h3, .block.text h1, .block.text h2, .block.text h3 { margin: 14px 0 8px; line-height: 1.3; }
.rich-text blockquote, .block.text blockquote { margin: 12px 0; padding: 8px 14px; border-left: 4px solid var(--brand);
  background: var(--brand-soft); border-radius: 0 8px 8px 0; }
.rich-text ul, .rich-text ol, .block.text ul, .block.text ol { margin: 8px 0; padding-left: 28px; }
.rich-text a, .block.text a { color: var(--brand); text-decoration: underline; }
.blk-file, .blk-caption, .opt-text { font-size: 14px; margin-top: 0; }
.blk-preview img, .blk-preview video { max-width: 100%; border-radius: 12px; border: 1px solid var(--line); }
.blk-options { display: grid; gap: 6px; }
.opt-row { display: flex; gap: 8px; align-items: center; }
.opt-row input[type=radio] { width: auto; }
.opt-row .opt-text { margin-top: 0; }

.addbar { position: relative; text-align: center; height: 18px; }
.addbtn { opacity: .35; border: 1px solid var(--brand); background: #fff; color: var(--brand); border-radius: 50%;
  width: 22px; height: 22px; cursor: pointer; font-size: 14px; line-height: 1; }
.addbar:hover .addbtn, .addbtn:focus { opacity: 1; }
.addmenu { position: absolute; left: 50%; transform: translateX(-50%); top: 20px; z-index: 20;
  background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 32px rgba(23,18,31,.16);
  display: flex; flex-direction: column; min-width: 150px; overflow: hidden; }
.addmenu.hidden { display: none; }
.addmenu-item { border: 0; background: none; padding: 10px 16px; text-align: left; cursor: pointer; font-size: 14px;
  font-weight: 500; font-family: var(--font); color: var(--ink); }
.addmenu-item:hover { background: var(--brand-soft); }

.save-indicator { position: fixed; right: 20px; bottom: 20px; background: var(--ok); color: #fff;
  padding: 10px 18px; border-radius: 12px; font-weight: 600; opacity: 0; transition: opacity .3s; pointer-events: none; z-index: 50; }
.save-indicator.show { opacity: 1; }

@media (max-width: 1400px) {
  .topuser > span:not(.avatar) { display: none; }
}
@media (max-width: 1150px) {
  .topbar-inner { gap: 10px; padding-left: 14px; padding-right: 14px; }
  .topsearch { flex-basis: 135px; min-width: 100px; }
  .topnav a { padding: 6px; font-size: 12px; }
}
@media (max-width: 900px) {
  .topsearch, .topuser .avatar { display: none; }
  .logo { font-size: 17px; }
  .layout, .editor-layout, .login-split { grid-template-columns: 1fr; }
  .login-side { order: -1; padding: 28px; }
  .sidebar { position: static; }
}

/* профиль с прогрессом (BossFree) */
.card.profile { display: flex; align-items: center; gap: 28px; flex-wrap: wrap; }
.profile-left { display: flex; align-items: center; gap: 16px; flex: 1; min-width: 220px; }
.avatar.big { width: 64px; height: 64px; font-size: 22px; }
.profile-name { margin: 0; font-size: 20px; }
.profile-ring { display: flex; align-items: center; gap: 12px; }
.ring { width: 80px; height: 80px; }
.ring-text { font-size: 16px; font-weight: 800; fill: var(--brand); font-family: var(--font); }
.ring-label { font-size: 12px; color: #9a93a8; line-height: 1.4; }
.profile-bars { display: grid; gap: 8px; min-width: 260px; flex: 1; }
.barline { display: grid; grid-template-columns: 70px 1fr 44px; align-items: center; gap: 10px; font-size: 13px; }
.barline .progress { margin: 0; }
.barline b { text-align: right; }

/* фильтры кабинета */
.filters-panel { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 12px 16px; }
.filters-panel input, .filters-panel select { width: auto; margin-top: 0; }
.filters-panel input[name=q] { flex: 2; min-width: 180px; }

/* словарь */
.letters { display: flex; gap: 4px; flex-wrap: wrap; }
.letter { padding: 4px 10px; border-radius: 8px; font-weight: 600; color: var(--ink-2); }
.letter:hover { background: var(--brand-soft); text-decoration: none; }
.letter.active { background: var(--brand); color: #fff; }
.glossary { margin: 0; }
.glossary dt { font-weight: 700; margin-top: 12px; }
.glossary dd { margin: 2px 0 0; color: var(--ink-2); line-height: 1.55; }

/* оценка материала */
.stars .star { color: #d8d4e2; font-size: 18px; }
.stars .star.on { color: #f5a623; }
.rate-row { display: flex; flex-direction: row-reverse; justify-content: flex-end; gap: 4px; margin: 8px 0; }
.rate input { position: absolute; opacity: 0; pointer-events: none; }
.rate span { font-size: 26px; color: #d8d4e2; cursor: pointer; }
.rate:has(input:checked) span, .rate:has(input:checked) ~ .rate span { color: #f5a623; }
.rate-row:hover .rate span { color: #d8d4e2; }
.rate-row .rate:hover span, .rate-row .rate:hover ~ .rate span { color: #f5a623; }
.rate:has(input:focus-visible) span { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }

/* поиск в шапке */
.topsearch { flex: 0 1 260px; }
.topsearch input { width: 100%; margin: 0; padding: 7px 12px 7px 32px; border-radius: 999px; border: 1px solid var(--line);
  background: #f6f5fa url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%239a93a8' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat 11px center; }

/* дерево-аккордеон (BossFree) */
.tnode > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: 10px; font-size: 14px; font-weight: 600; }
.tnode > summary::-webkit-details-marker { display: none; }
.tnode > summary::before { content: '›'; color: #9a93a8; font-weight: 700; transition: transform .15s; display: inline-block; }
.tnode[open] > summary::before { transform: rotate(90deg); }
.tnode > summary:hover { background: var(--brand-soft); }
.tnode > summary .tname { color: inherit; flex: 1; }
.tnode > summary .tname:hover { text-decoration: underline; }
.tree.mats { padding-left: 22px; }
.tree-link.mat { font-size: 13.5px; font-weight: 500; padding: 4px 10px; display: flex; align-items: center; gap: 6px; }
.tree-link.mat.done { color: #6b6478; }
.tree-link.mat.done::after { content: '✓'; color: var(--ok); font-weight: 700; margin-left: auto; }
.tree-link.mat.active { background: var(--brand-soft); color: var(--brand); border-left: 3px solid var(--brand); border-radius: 0 10px 10px 0; }

/* хлебные крошки */
.crumbs { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 12px; flex-wrap: wrap; }
.crumbs a { color: var(--ink-2); }
.crumbs .sep { color: #c9c3d6; }

/* блоки «только для администраторов» */
.admin-blocks { margin-top: 20px; border-top: 1px dashed var(--grey); padding-top: 12px; }
.admin-blocks summary { font-weight: 700; color: var(--ink-2); }

.lock-toggle { color: #9a93a8; }
