:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --text: #1c2030;
  --muted: #6b7185;
  --border: #e2e5ee;
  --accent: #3b5bdb;
  --accent-soft: #e8edff;
  --ok: #2b8a3e;
  --ok-soft: #e6f6ea;
  --bad: #c92a2a;
  --bad-soft: #fdecec;
  --l1: #2b8a3e;
  --l2: #e67700;
  --l3: #c2255c;
  --code-bg: #f1f3f8;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12141b;
    --surface: #1b1e28;
    --text: #e6e8ef;
    --muted: #9298ab;
    --border: #2c3040;
    --accent: #7c95ff;
    --accent-soft: #252c4a;
    --ok: #51cf66;
    --ok-soft: #1c3324;
    --bad: #ff6b6b;
    --bad-soft: #3a1f22;
    --l1: #51cf66;
    --l2: #ffa94d;
    --l3: #f06595;
    --code-bg: #232735;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.8rem; margin: 0 0 .3em; line-height: 1.2; }
h2 { font-size: 1.25rem; margin: 1.6em 0 .6em; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.footer { padding: 40px 16px; font-size: .9rem; }

/* top bar */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.topbar-inner { display: flex; align-items: center; justify-content: flex-start; gap: 16px; min-height: 60px; flex-wrap: wrap; }
.logo { font-weight: 700; font-size: 1.15rem; color: var(--text); }
.logo span { color: var(--accent); margin: 0 2px; }
.logo:hover { text-decoration: none; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; margin-left: auto; }
.nav a { padding: 6px 12px; border-radius: 8px; color: var(--muted); font-weight: 500; }
.nav a:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); }

main { padding-top: 28px; min-height: 60vh; }
.crumbs { font-size: .9rem; color: var(--muted); margin-bottom: 12px; }
.crumbs a { color: var(--muted); }

/* cards */
.grid { display: grid; gap: 14px; }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid-types { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  color: var(--text);
  display: block;
}
a.card:hover { border-color: var(--accent); text-decoration: none; }
.card h3 { margin: 0 0 6px; font-size: 1.1rem; }
.card p { margin: 0; }
.level-card { border-top: 4px solid var(--lvl, var(--accent)); }
.level-card .count { margin-top: 12px; font-size: .9rem; color: var(--muted); }
.lvl-1 { --lvl: var(--l1); }
.lvl-2 { --lvl: var(--l2); }
.lvl-3 { --lvl: var(--l3); }
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: .78rem; font-weight: 600;
  background: var(--accent-soft); color: var(--accent);
}
.badge.lvl { background: transparent; border: 1px solid var(--lvl); color: var(--lvl); }

.type-card { display: flex; gap: 12px; align-items: flex-start; }
.type-num {
  flex: none; width: 40px; height: 40px; border-radius: 10px;
  display: grid; place-items: center; font-weight: 700;
  background: var(--accent-soft); color: var(--accent);
}
.type-card .t { font-weight: 600; line-height: 1.3; }
.type-card .s { font-size: .85rem; color: var(--muted); line-height: 1.35; margin-top: 2px; }
.type-card .c { font-size: .8rem; color: var(--muted); margin-top: 6px; }
.type-card.empty { opacity: .6; }

.progress { height: 4px; background: var(--border); border-radius: 2px; margin-top: 8px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--ok); }

/* tabs & chips */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 16px 0; }
.tab, .chip {
  padding: 6px 14px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-size: .9rem; cursor: pointer;
}
.tab:hover, .chip:hover { border-color: var(--accent); text-decoration: none; }
.tab.active, .chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--lvl); margin-right: 6px; vertical-align: 1px; }
.tab.active .dot { background: #fff; }
.lv { color: var(--lvl); font-weight: 600; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: .9rem; color: var(--muted); margin: 8px 0 20px; }
.level-sep { display: flex; align-items: center; color: var(--lvl); font-size: 1.05rem; margin: 24px 0 12px; }
.level-sep::after { content: ""; flex: 1; height: 1px; background: var(--border); margin-left: 12px; }
#task-list > .level-sep:first-child { margin-top: 8px; }

.empty-state {
  text-align: center; padding: 48px 16px; border: 1px dashed var(--border);
  border-radius: var(--radius); color: var(--muted); background: var(--surface);
}

/* task */
.task { margin-bottom: 16px; scroll-margin-top: 80px; }
.task.solved { border-left: 4px solid var(--ok); }
.task-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; font-size: .9rem; color: var(--muted); }
.task-head .num { font-weight: 700; color: var(--text); font-size: 1rem; }
.task-head .spacer { flex: 1; }
.task-body { overflow-x: auto; }
.task-body img { max-width: 100%; height: auto; }
.task-body table { border-collapse: collapse; margin: 8px 0; }
.task-body td, .task-body th { border: 1px solid var(--border); padding: 4px 10px; text-align: center; }
.task-body p { margin: 0 0 .8em; }
.task-body > :last-child { margin-bottom: 0; }
.task-body .graph-container { display: flex; flex-wrap: wrap; gap: 16px 24px; align-items: center; margin: 8px 0 12px; }
.task-body .graph-container img { max-width: min(100%, 420px); }
.task-body .graph-container > p { margin: 0; }
.task-body td.filled { background: var(--code-bg); }
.task-body th { background: var(--code-bg); font-weight: 600; }
.task-body th.vertical-text { writing-mode: vertical-rl; transform: rotate(180deg); padding: 8px 4px; }
.task-body .align-center { text-align: center; }
.task-body img { background: #fff; border-radius: 6px; }
.task-body .katex { font-size: 1.05em; }
.task-head .topic { padding: 1px 8px; border-radius: 6px; background: var(--code-bg); font-size: .8rem; }
pre, code { font-family: ui-monospace, Consolas, "Cascadia Mono", monospace; font-size: .9rem; }
pre { background: var(--code-bg); padding: 12px; border-radius: 8px; overflow-x: auto; }
.files { margin-top: 12px; display: flex; gap: 8px; flex-wrap: wrap; }
.files a { font-size: .9rem; padding: 4px 10px; border: 1px solid var(--border); border-radius: 8px; }
.files a.video { border-color: var(--bad); color: var(--bad); }
.task-body hr { border: none; border-top: 1px dashed var(--border); margin: 14px 0; }

.answer { display: flex; gap: 10px; align-items: flex-start; flex-wrap: wrap; margin-top: 16px; }
.answer-grid { display: grid; gap: 4px; }
input.ans {
  font: inherit; padding: 7px 10px; width: 140px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
}
input.ans:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input.ans.ok { border-color: var(--ok); background: var(--ok-soft); }
input.ans.bad { border-color: var(--bad); background: var(--bad-soft); }
.btn {
  font: inherit; font-weight: 600; padding: 7px 16px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--accent); background: var(--accent); color: #fff;
}
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; color: var(--accent); }
.verdict { align-self: center; font-weight: 600; }
.verdict.ok { color: var(--ok); }
.verdict.bad { color: var(--bad); }
details.solution { margin-top: 14px; }
details.solution summary { cursor: pointer; color: var(--accent); font-weight: 500; }

/* variants */
.variant-group { margin-bottom: 8px; }
.variant-card .meta { font-size: .85rem; color: var(--muted); margin-top: 4px; }

.exam-bar {
  position: sticky; top: 61px; z-index: 5; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 14px; margin-bottom: 16px;
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
}
.timer { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.1rem; }
.jump { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.jump a {
  width: 30px; height: 30px; display: grid; place-items: center; border-radius: 6px;
  border: 1px solid var(--border); font-size: .8rem; color: var(--text);
}
.jump a.filled { background: var(--accent-soft); border-color: var(--accent); }
.jump a.ok { background: var(--ok-soft); border-color: var(--ok); }
.jump a.bad { background: var(--bad-soft); border-color: var(--bad); }
.jump a:hover { text-decoration: none; border-color: var(--accent); }

.results { margin-bottom: 20px; }
.score { font-size: 2.2rem; font-weight: 700; line-height: 1.1; }
.results table { border-collapse: collapse; width: 100%; margin-top: 14px; font-size: .9rem; }
.results th, .results td { border-bottom: 1px solid var(--border); padding: 6px 8px; text-align: left; }
.results td.ok { color: var(--ok); font-weight: 600; }
.results td.bad { color: var(--bad); font-weight: 600; }

/* profile */
.profile-head { display: flex; gap: 14px; align-items: center; margin-bottom: 20px; }
.avatar {
  flex: none; width: 56px; height: 56px; border-radius: 50%;
  display: grid; place-items: center; font-size: 1.5rem; font-weight: 700;
  background: var(--accent); color: #fff;
}
.pname {
  font: inherit; font-size: 1.5rem; font-weight: 700; color: var(--text);
  background: transparent; border: 1px solid transparent; border-radius: 8px;
  padding: 2px 6px; margin-left: -6px; width: 100%; max-width: 420px;
}
.pname:hover, .pname:focus { border-color: var(--border); outline: none; }
.stats { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.stat-v { font-size: 1.9rem; font-weight: 700; line-height: 1.1; }
.stat-v small { font-size: 1rem; color: var(--muted); font-weight: 500; }
.stat-l { color: var(--muted); font-size: .9rem; margin-top: 2px; }
.stat-s { font-size: .8rem; color: var(--muted); margin-top: 6px; }

.lvl-row { display: flex; align-items: center; gap: 12px; padding: 6px 0; }
.lvl-name { width: 130px; flex: none; font-weight: 600; color: var(--lvl); }
.lvl-bar { flex: 1; }
.lvl-bar .progress { margin: 0; height: 8px; border-radius: 4px; }
.lvl-fill > i { background: var(--lvl); }
.lvl-num { width: 70px; text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); font-size: .9rem; }

.activity { display: flex; align-items: flex-end; gap: 3px; height: 90px; }
.activity .day { flex: 1; height: 100%; display: flex; align-items: flex-end; background: var(--code-bg); border-radius: 3px; }
.activity .day i { display: block; width: 100%; background: var(--ok); border-radius: 3px; }
.activity-axis { display: flex; justify-content: space-between; font-size: .8rem; margin-top: 6px; }

.table-wrap { padding: 6px 12px; overflow-x: auto; }
.stat-table { border-collapse: collapse; width: 100%; font-size: .9rem; }
.stat-table th { text-align: left; color: var(--muted); font-weight: 500; font-size: .8rem; }
.stat-table th, .stat-table td { padding: 7px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.stat-table tr:last-child td { border-bottom: none; }
.stat-table td a { color: var(--text); }
.stat-table .progress { margin-top: 3px; }

.recent { list-style: none; margin: 0; padding: 0; }
.recent li { padding: 7px 0; border-bottom: 1px solid var(--border); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: .9rem; }
.recent li:last-child { border-bottom: none; }
.btn.danger { border-color: var(--bad); color: var(--bad); }

@media (max-width: 600px) {
  .hide-sm { display: none; }
  h1 { font-size: 1.45rem; }
  .exam-bar { top: 0; position: static; }
  input.ans { width: 110px; }
}

/* показать ответ */
.reveal { margin-top: 12px; padding: 10px 14px; border-radius: 8px; background: var(--accent-soft); }
.answer-table { border-collapse: collapse; margin-top: 6px; font-weight: 600; font-variant-numeric: tabular-nums; }
.answer-table td { border: 1px solid var(--border); padding: 3px 10px; background: var(--surface); }

/* инструменты карточки: редактор кода и маркер */
article.task { position: relative; }
.task-tools { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.tool-btn {
  font: inherit; font-size: .85rem; padding: 4px 10px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--muted);
}
.tool-btn:hover { border-color: var(--accent); color: var(--accent); }
.tool-btn.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.tool-btn.has-ink::after { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--bad); margin-left: 6px; vertical-align: 2px; }
.btn.small { padding: 4px 10px; font-size: .85rem; }

.code-panel { margin-top: 10px; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface); }
.code-editor textarea {
  display: block; width: 100%; min-height: 220px; resize: vertical; border: 0; padding: 10px;
  font: 14px/1.5 ui-monospace, Consolas, "Cascadia Mono", monospace; background: var(--code-bg); color: var(--text); tab-size: 4;
}
.code-editor .CodeMirror { height: auto; min-height: 220px; font: 14px/1.5 ui-monospace, Consolas, "Cascadia Mono", monospace; }
.code-editor .CodeMirror-scroll { min-height: 220px; max-height: 60vh; }
.code-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 8px 10px; border-top: 1px solid var(--border); }
.code-bar .spacer { flex: 1; }
.code-status { font-size: .85rem; }
.code-status.bad { color: var(--bad); }
.code-check { font-size: .85rem; color: var(--muted); display: flex; gap: 4px; align-items: center; cursor: pointer; }
.code-files { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 0 10px 8px; font-size: .85rem; }
.file-state.ok { color: var(--ok); }
.file-state.fail { color: var(--bad); }
.file-upload { color: var(--accent); cursor: pointer; text-decoration: underline; }
.code-stdin {
  display: block; width: calc(100% - 20px); margin: 0 10px 8px; min-height: 60px; resize: vertical;
  font: 13px/1.4 ui-monospace, Consolas, monospace; border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg); color: var(--text); padding: 6px 8px;
}
.code-out {
  margin: 0; border-radius: 0; border-top: 1px solid var(--border); max-height: 300px; overflow: auto;
  white-space: pre-wrap; word-break: break-word; font-size: 13px;
}
.code-out .err { color: var(--bad); }

.ink-layer { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 3; border-radius: inherit; }
article.task.inking { outline: 2px dashed var(--accent); outline-offset: 2px; }
article.task.inking .ink-layer { pointer-events: auto; cursor: crosshair; touch-action: none; }
.ink-palette {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 50;
  display: flex; gap: 6px; align-items: center; padding: 8px 10px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: 0 6px 24px rgba(0, 0, 0, .18);
  max-width: calc(100vw - 32px); flex-wrap: wrap; justify-content: center;
}

/* экран решения: условие слева, редактор справа (как в КЕГЭ) */
body.solve-mode #app { max-width: none; padding-top: 12px; }
body.solve-mode .footer { display: none; }
.solve-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; min-height: 44px; margin-bottom: 10px; }
.solve-top .back { font-weight: 500; }
.solve-top .spacer { flex: 1; }
.solve-ink-slot { display: flex; }
.solve-ink-slot .ink-palette { position: static; transform: none; box-shadow: none; padding: 4px 8px; }
.solve-split {
  display: grid; grid-template-columns: minmax(280px, var(--split-left, 1fr)) 10px minmax(320px, 1fr);
  height: calc(100vh - 61px - 12px - 54px - 12px);
}
.solve-left { overflow: auto; padding-right: 6px; }
.solve-left article.task { margin: 0; }
.solve-divider { cursor: col-resize; position: relative; }
.solve-divider::after { content: ""; position: absolute; left: 4px; top: 0; bottom: 0; width: 2px; border-radius: 1px; background: var(--border); }
.solve-divider:hover::after, .solve-split.resizing .solve-divider::after { background: var(--accent); }
.solve-split.resizing { user-select: none; }
.solve-right { min-width: 0; display: flex; flex-direction: column; }
.solve-right .code-panel { flex: 1; min-height: 0; display: flex; flex-direction: column; margin: 0; }
.solve-right .code-editor { flex: 1 1 auto; min-height: 160px; display: flex; flex-direction: column; overflow: hidden; }
.solve-right .code-editor textarea { flex: 1; min-height: 0; resize: none; }
.solve-right .code-editor .CodeMirror { height: 100%; min-height: 0; }
.solve-right .code-editor .CodeMirror-scroll { min-height: 0; max-height: none; }
.solve-right .code-out { flex: 0 0 auto; max-height: 35vh; }
.solve-variant-note { margin-top: 14px; }
@media (max-width: 899px) {
  .solve-split { display: block; height: auto; }
  .solve-divider { display: none; }
  .solve-left { overflow: visible; padding: 0; margin-bottom: 12px; }
  .solve-right .code-panel { min-height: 70vh; }
}

/* номера задач сверху и переход к следующей */
.task-strip { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; margin: 4px 0 16px; }
.task-strip a {
  min-width: 34px; height: 34px; padding: 0 6px; display: grid; place-items: center;
  border-radius: 8px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font-size: .85rem; font-variant-numeric: tabular-nums;
}
.task-strip a:hover { border-color: var(--accent); text-decoration: none; }
.task-strip a.ok { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.task-strip a.bad { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.task-strip a.current { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.strip-group { display: inline-flex; align-items: center; font-size: .8rem; font-weight: 600; color: var(--lvl); margin: 0 4px 0 8px; }
.strip-group:first-child { margin-left: 0; }
.task-nav { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 4px; }
.task-nav .btn:hover { text-decoration: none; }
.solve-close:hover { text-decoration: none; border-color: var(--bad); color: var(--bad); }

/* палитра маркера */
.ink-palette { gap: 4px 10px; }
.ink-group { display: flex; gap: 3px; align-items: center; }
.ink-group + .ink-group { padding-left: 10px; border-left: 1px solid var(--border); }
.ink-tool, .ink-act, .ink-color, .ink-size {
  width: 34px; height: 34px; padding: 0; border-radius: 8px; border: 1px solid transparent;
  background: none; color: var(--text); cursor: pointer; display: grid; place-items: center;
  font: inherit; font-size: 1rem; line-height: 1;
}
.ink-tool:hover, .ink-act:hover:not(:disabled), .ink-color:hover, .ink-size:hover { background: var(--code-bg); }
.ink-tool.active, .ink-size.active, .ink-act.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.ink-act:disabled { opacity: .35; cursor: default; }
.ink-color i { width: 20px; height: 20px; border-radius: 50%; display: block; border: 1px solid rgba(127,127,127,.35); }
.ink-color.active { border-color: var(--accent); }
.ink-color.custom { position: relative; }
.ink-color.custom i { background: conic-gradient(#e03131, #f08c00, #fab005, #2f9e44, #1c7ed6, #9c36b5, #e03131); }
.ink-color.custom input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.ink-size i { display: block; border-radius: 50%; background: var(--text); }
article.task.inking.ink-tool-eraser .ink-layer { cursor: cell; }
article.task.inking.ink-tool-text .ink-layer { cursor: text; }
.ink-text-input {
  position: absolute; z-index: 4; min-width: 60px; padding: 2px 4px; margin: -3px 0 0 -5px;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif; font-weight: 600; line-height: 1.25;
  background: var(--surface); border: 1px dashed var(--accent); border-radius: 4px;
  resize: none; overflow: hidden; white-space: pre;
}
@media (max-width: 600px) {
  .ink-group + .ink-group { padding-left: 0; border-left: 0; }
}

/* главная */
.home-hero { display: flex; align-items: center; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap; margin: 12px 0 14px; }
.continue { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.btn.big { padding: 11px 22px; font-size: 1.05rem; border-radius: 10px; }
.btn.big:hover, .btn:hover { text-decoration: none; }
.home-stats { display: flex; gap: 6px 18px; flex-wrap: wrap; color: var(--text); font-size: .95rem; }
.home-stats:hover { text-decoration: none; }
.home-stats:hover .muted { color: var(--accent); }
.home-row { display: flex; align-items: center; justify-content: space-between; gap: 10px 16px; flex-wrap: wrap; margin-bottom: 8px; }
.weak-block { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: .9rem; }
.weak-block .label { font-weight: 600; margin-right: 4px; }
.weak-chip { padding: 5px 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.weak-chip:hover { border-color: var(--bad); text-decoration: none; }
.bad-text { color: var(--bad); font-size: .8rem; }
.random-block { display: flex; gap: 6px; flex-wrap: wrap; }
.home-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; }
.home-head .legend { margin: 0; }
.topics { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 18px 22px; }
.topic h3 { margin: 0 0 8px; font-size: .9rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; }
.tile {
  display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text); min-height: 92px;
}
.tile:hover { border-color: var(--accent); text-decoration: none; }
.tile-top { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; }
.tile-top b { font-size: 1.25rem; line-height: 1; }
.tile-top span { font-size: .75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.tile-title { font-size: .8rem; line-height: 1.25; color: var(--muted); flex: 1; }
.tile .progress { margin-top: 2px; }
.tile .progress > i { background: var(--accent); }
.tile.started .tile-top b { color: var(--accent); }
.tile.done { border-color: var(--ok); }
.tile.done .progress > i { background: var(--ok); }
.tile.done .tile-top b { color: var(--ok); }
.tile.empty { opacity: .5; }
.probes-note { margin-top: 24px; }

/* аккаунт: кнопка входа, меню пользователя */
.auth { display: flex; align-items: center; }
.user-menu { position: relative; }
.user-btn { display: flex; align-items: center; gap: 8px; font: inherit; background: none; border: 1px solid transparent; border-radius: 999px; padding: 3px 10px 3px 3px; cursor: pointer; color: var(--text); }
.user-btn:hover { border-color: var(--border); }
.user-avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: #fff; font-weight: 700; font-size: .9rem; }
.user-name { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.user-pop {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; min-width: 220px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 8px 28px rgba(0,0,0,.16);
  padding: 6px; display: flex; flex-direction: column;
}
.user-pop-head { display: flex; flex-direction: column; padding: 8px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; font-size: .9rem; }
.user-pop a, .user-pop button { text-align: left; font: inherit; font-size: .9rem; padding: 8px 10px; border-radius: 8px; color: var(--text); background: none; border: 0; cursor: pointer; }
.user-pop a:hover, .user-pop button:hover { background: var(--code-bg); text-decoration: none; }

/* окно входа / регистрации */
.modal-backdrop { position: fixed; inset: 0; z-index: 100; background: rgba(10, 12, 20, .45); display: grid; place-items: center; padding: 16px; overflow: auto; }
.modal { position: relative; width: 100%; max-width: 420px; padding: 22px; }
.modal-close { position: absolute; right: 10px; top: 10px; width: 32px; height: 32px; border-radius: 8px; border: 0; background: none; color: var(--muted); font-size: 1rem; cursor: pointer; }
.modal-close:hover { background: var(--code-bg); color: var(--text); }
.auth-tabs { display: flex; gap: 4px; margin-bottom: 18px; background: var(--code-bg); padding: 4px; border-radius: 10px; margin-right: 36px; }
.auth-tabs button { flex: 1; font: inherit; font-weight: 600; padding: 7px; border: 0; border-radius: 8px; background: none; color: var(--muted); cursor: pointer; }
.auth-tabs button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.1); }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form label { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; font-weight: 500; color: var(--muted); }
.auth-form input:not([type=radio]) {
  font: inherit; font-size: 1rem; padding: 9px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text);
}
.auth-form input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.auth-form .btn { padding: 10px; font-size: 1rem; }
.auth-form .btn:disabled { opacity: .6; cursor: wait; }
.auth-form p { margin: 0; text-align: center; }
.small { font-size: .85rem; }
.auth-error { color: var(--bad); background: var(--bad-soft); border-radius: 8px; padding: 8px 10px; font-size: .9rem; }
.role-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.role-card {
  position: relative; cursor: pointer; border: 2px solid var(--border); border-radius: 12px; padding: 14px 10px;
  display: flex !important; flex-direction: column; align-items: center; text-align: center; gap: 2px !important; color: var(--text) !important;
}
.role-card input { position: absolute; opacity: 0; pointer-events: none; }
.role-card:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.role-card:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.role-icon { font-size: 1.8rem; line-height: 1.2; }
.role-card b { font-size: 1rem; }
.role-card .muted { font-weight: 400; font-size: .8rem; }
.account-note { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: .85rem; }

/* учитель и домашка */
.nav-count { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--bad); color: #fff; font-size: .72rem; font-weight: 700; margin-left: 2px; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .8rem; font-weight: 600; font-variant-numeric: tabular-nums; background: var(--code-bg); color: var(--muted); }
.pill.started { background: var(--accent-soft); color: var(--accent); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin: 1.6em 0 .6em; }
.section-head h2, .section-head h3 { margin: 0; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.add-student { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.add-student label { display: flex; flex-direction: column; gap: 2px; }
.add-row { display: flex; gap: 8px; flex-wrap: wrap; }
.add-row input { flex: 1; min-width: 180px; font: inherit; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text); }
.pending { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; font-size: .9rem; }
.pending-chip { display: inline-flex; gap: 6px; align-items: center; padding: 4px 6px 4px 12px; border-radius: 999px; border: 1px dashed var(--border); background: var(--surface); }
.pending-chip button { border: 0; background: none; color: var(--muted); cursor: pointer; border-radius: 50%; width: 22px; height: 22px; }
.pending-chip button:hover { background: var(--bad-soft); color: var(--bad); }
.stat-table.students td { vertical-align: middle; }
.asg { margin-bottom: 10px; }
.asg-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.asg-note { margin: 8px 0 0; white-space: pre-wrap; font-size: .9rem; }
.asg-students { display: flex; gap: 6px 14px; flex-wrap: wrap; margin-top: 10px; font-size: .9rem; }
.asg-student { display: inline-flex; gap: 6px; align-items: center; }
.tiles-wide { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); }
.tile-acc { font-size: .72rem; }
.asg-form { display: flex; flex-direction: column; gap: 14px; }
.asg-form > label { display: flex; flex-direction: column; gap: 4px; font-weight: 500; }
.asg-form input:not([type=checkbox]), .asg-form textarea, .asg-form select {
  font: inherit; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text);
}
.asg-form textarea { resize: vertical; }
.asg-form .due input { max-width: 200px; }
.asg-form fieldset { border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px 14px; display: flex; flex-direction: column; gap: 10px; }
.asg-form legend { font-weight: 600; padding: 0 4px; }
.pick-students { display: flex; gap: 6px 18px; flex-wrap: wrap; }
.check { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; font-weight: 400; }
.pick-rows { display: flex; flex-direction: column; gap: 8px; }
.pick-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pick-row select[name=type] { flex: 1 1 260px; min-width: 0; }
.pick-row input[name=count] { width: 80px; }
.pick-info { min-width: 140px; }
.asg-submit { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.homework-home { margin-bottom: 14px; }
.homework-home .section-head { margin: 0 0 8px; }
.invite { padding: 6px 0; font-size: .95rem; }
.hw-line { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--border); color: var(--text); }
.hw-line:hover { text-decoration: none; color: var(--accent); }
.hw-line .muted { margin-left: 6px; }
.hw-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.hw-card { display: flex; flex-direction: column; gap: 6px; color: var(--text); }
.hw-card:hover { border-color: var(--accent); text-decoration: none; }
.hw-card.complete { opacity: .8; }
.invite-card { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; border-color: var(--accent); }
.asg-note-card { white-space: pre-wrap; margin-bottom: 12px; border-left: 4px solid var(--accent); }
.recent li .spacer { flex: 1; }
.asg-form #add-row { align-self: flex-start; }

/* подсмотренный ответ, номер задачи сайта */
.verdict.peek { color: var(--l2); }
.task-strip a.peek { background: color-mix(in srgb, var(--l2) 14%, var(--surface)); border-color: var(--l2); color: var(--l2); }
.task-no { font-variant-numeric: tabular-nums; }

/* аккаунты учеников, созданные учителем */
.create-students { margin-bottom: 14px; }
.create-students summary { cursor: pointer; }
.create-students form { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.create-students label { display: flex; flex-direction: column; gap: 4px; font-weight: 500; }
.create-students textarea { font: inherit; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text); resize: vertical; }
.create-students form .btn { align-self: flex-start; }
.create-students p { margin: 0; }
.creds { margin-top: 14px; padding: 12px; border-radius: 10px; background: var(--ok-soft); border: 1px solid var(--ok); }
.creds-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 6px; }
.creds code { font-size: .95rem; font-weight: 600; }
.creds p { margin: 8px 0 0; }
.pass-change { margin-bottom: 18px; max-width: 460px; }
.pass-change summary { cursor: pointer; font-weight: 500; }
.pass-change form { margin-top: 12px; }
.auth-error.ok-note { color: var(--ok); background: var(--ok-soft); }

/* наборы задач */
.set-card { display: flex; flex-direction: column; gap: 6px; color: var(--text); }
.set-card:hover { border-color: var(--accent); text-decoration: none; }
.set-desc { font-size: .85rem; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.set-builder { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.set-picker .pick-row input[name=byNo] { flex: 1; min-width: 0; }
.pick-list { max-height: 460px; overflow: auto; display: flex; flex-direction: column; gap: 6px; padding-right: 4px; }
.pick-item { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; font-weight: 400; }
.pick-item:hover { border-color: var(--accent); }
.pick-item.on { background: var(--accent-soft); border-color: var(--accent); }
.pick-item input { grid-row: span 2; margin-top: 3px; }
.pick-meta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.pick-text { font-size: .8rem; color: var(--muted); line-height: 1.35; }
.set-chosen { position: sticky; top: 72px; }
.chosen-list { margin: 0; padding-left: 22px; max-height: 460px; overflow: auto; display: flex; flex-direction: column; gap: 4px; }
.chosen-list li { font-size: .9rem; }
.chosen-list li > span:first-child { display: inline-flex; gap: 6px; align-items: center; }
.chosen-actions { float: right; display: inline-flex; gap: 2px; }
.chosen-actions button { width: 24px; height: 24px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--muted); cursor: pointer; font-size: .75rem; padding: 0; }
.chosen-actions button:disabled { opacity: .3; cursor: default; }
.chosen-actions button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.task-tools { position: relative; }
.set-pop {
  position: absolute; left: 0; top: calc(100% + 6px); z-index: 20; min-width: 260px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 28px rgba(0,0,0,.16);
  padding: 10px 12px; display: flex; flex-direction: column; gap: 6px;
}
.set-pop .btn { align-self: flex-start; margin-top: 4px; }
@media (max-width: 760px) { .set-builder { grid-template-columns: 1fr; } .set-chosen { position: static; } }
.asg-form > label.check { flex-direction: row; align-items: baseline; gap: 8px; font-weight: 500; text-align: left; }
