/* ===== Цвета и базовые размеры ===== */
/* Светлая «тетрадная» палитра: тёплая бумага, глубокий бирюзово-зелёный (школьная доска), коралловый акцент.
   Сайт всегда светлый — тёмная тема системы на него не влияет. */
:root {
  --bg: #fbf8f2;
  --surface: #ffffff;
  --surface-2: #f5f1e8;
  --text: #22302d;
  --muted: #65706c;
  --line: #e7e0d3;
  --primary: #1d7566;
  --primary-2: #26907e;
  --primary-ink: #ffffff;
  --soft: #e3f1ec;
  --accent: #e0693a;
  --accent-soft: #fdece2;
  --violet: #5b5bb7;
  --violet-soft: #ebebfa;
  --ok: #278a4a;
  --ok-soft: #e3f4e8;
  --bad: #c8463a;
  --bad-soft: #fbe9e6;
  --grid: rgba(29, 117, 102, .075);
  --shadow: 0 1px 2px rgba(60, 50, 30, .05), 0 6px 18px rgba(60, 50, 30, .06);
  --radius: 14px;
  --font: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-head: 'Unbounded', 'Manrope', sans-serif;
  color-scheme: light;
}
/* Тёмная тема — включается кнопкой в шапке */
:root[data-theme="dark"] {
  --bg: #131917;
  --surface: #1b2321;
  --surface-2: #222c29;
  --text: #e6eeeb;
  --muted: #9aaaa4;
  --line: #2d3936;
  --primary: #4fbfa9;
  --primary-2: #6fd2be;
  --primary-ink: #0f1614;
  --soft: #1e3330;
  --accent: #f08a5d;
  --accent-soft: #392820;
  --violet: #a2a2f2;
  --violet-soft: #2a2a45;
  --ok: #5ccf86;
  --ok-soft: #173024;
  --bad: #f08074;
  --bad-soft: #3a211e;
  --grid: rgba(79, 191, 169, .07);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  color-scheme: dark;
}
/* ===== Палитры (выбираются в админке → Настройки). Базовые цвета выше — палитра «Доска». ===== */
:root[data-palette="ink"] {          /* Тетрадь: синие чернила + красные поля */
  --primary: #2c56b0; --primary-2: #3a68c8; --soft: #e7eefb; --accent: #d64f45; --accent-soft: #fcebea;
  --violet: #1f8a78; --violet-soft: #e3f3ef; --grid: rgba(44, 86, 176, .08);
}
:root[data-palette="ink"][data-theme="dark"] {
  --bg: #121620; --surface: #1a1f2b; --surface-2: #212736; --line: #2c3446; --text: #e6eaf2; --muted: #9aa3b5;
  --primary: #86a8f0; --primary-2: #a3bdf5; --primary-ink: #10141d; --soft: #1f2a44; --accent: #f07f77; --accent-soft: #3a2221;
  --violet: #5cc9b5; --grid: rgba(134, 168, 240, .07);
}
:root[data-palette="lilac"] {        /* Сирень: фиолетовый + оранжевый */
  --primary: #5a48c0; --primary-2: #6c5bd4; --soft: #eeebfb; --accent: #d9750f; --accent-soft: #fdf0e0;
  --violet: #1d8f7e; --violet-soft: #e3f3ef; --grid: rgba(90, 72, 192, .075);
}
:root[data-palette="lilac"][data-theme="dark"] {
  --bg: #15131d; --surface: #1d1a28; --surface-2: #252134; --line: #322d44; --text: #ebe8f3; --muted: #a39db5;
  --primary: #a99cf5; --primary-2: #bdb3f8; --primary-ink: #14121c; --soft: #272240; --accent: #f5a554; --accent-soft: #3a2a18;
  --violet: #5cc9b5; --grid: rgba(169, 156, 245, .07);
}
:root[data-palette="sea"] {          /* Море: морской синий + коралловый */
  --primary: #0b6f8c; --primary-2: #1287a8; --soft: #e0f1f6; --accent: #e2674c; --accent-soft: #fdebe6;
  --violet: #7a5cc2; --violet-soft: #efeafa; --grid: rgba(11, 111, 140, .075);
}
:root[data-palette="sea"][data-theme="dark"] {
  --bg: #10181b; --surface: #172126; --surface-2: #1e2a30; --line: #2a3a41; --text: #e4eef1; --muted: #98aab0;
  --primary: #52c1dd; --primary-2: #7ad0e6; --primary-ink: #0d1518; --soft: #17313a; --accent: #f08a72; --accent-soft: #3a231d;
  --violet: #b39cf0; --grid: rgba(82, 193, 221, .07);
}
.palettes { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.palettes label { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; cursor: pointer; font-weight: 600; }
.palettes label:has(input:checked) { border-color: var(--primary); box-shadow: 0 0 0 2px var(--soft); }
.palettes input { position: absolute; opacity: 0; pointer-events: none; }
.swatch { display: inline-flex; }
.swatch i { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--surface); margin-left: -5px; }
.swatch i:first-child { margin-left: 0; }
.theme-btn { flex-shrink: 0; padding: 7px 10px; font-size: 1.05rem; line-height: 1; }
.paper {
  background-color: var(--surface);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 24px 24px;
}

/* ===== База ===== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 16px; line-height: 1.55; }
a { color: var(--primary); text-decoration-thickness: 1px; text-underline-offset: 3px; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: clamp(1.7rem, 4vw, 2.5rem); font-weight: 800; letter-spacing: -.02em; }
h2 { font-size: 1.3rem; font-weight: 800; }
h3 { font-size: 1.05rem; font-weight: 700; }
p { margin: 0 0 .8em; }
img { max-width: 100%; }
.wrap { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 16px; }
main { padding-top: 28px; padding-bottom: 48px; min-height: 70vh; outline: none; }
section { margin-bottom: 36px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.eyebrow { color: var(--primary); font-weight: 700; font-size: .82rem; letter-spacing: .06em; text-transform: uppercase; margin-bottom: .4em; }
.prose p:last-child { margin-bottom: 0; }
.prose ul { margin: 0 0 .8em; padding-left: 1.2em; }
.prose li { margin-bottom: .2em; }
.katex { font-size: 1.08em; }
.katex-display { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }

/* ===== Кнопки и поля ===== */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 600; font-size: .95rem; text-decoration: none; cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s; }
.btn:hover { border-color: var(--primary); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { background: var(--primary-2); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { border-color: var(--bad); }
.btn.small { padding: 5px 11px; font-size: .85rem; border-radius: 8px; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 2px solid var(--primary); outline-offset: 2px; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; width: 100%; }
textarea { resize: vertical; min-height: 90px; line-height: 1.5; }
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--primary); }
input[type="file"] { padding: 6px; }
label { display: block; font-weight: 600; font-size: .92rem; }
label > input, label > select, label > textarea { margin-top: 5px; font-weight: 400; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.hint { font-weight: 400; color: var(--muted); font-size: .82rem; margin-top: 4px; display: block; }

/* ===== Шапка ===== */
.site-header { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.site-header .wrap { display: flex; align-items: center; gap: 16px; min-height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); flex-shrink: 0; }
.logo { width: 38px; height: 38px; border-radius: 11px; background: var(--primary); color: var(--primary-ink); display: grid; place-items: center;
  font-family: var(--font-head); font-weight: 700; font-size: 1.15rem; }
.brand b { font-family: var(--font-head); font-weight: 700; font-size: 1.05rem; display: block; line-height: 1.1; }
.brand small { color: var(--muted); font-size: .78rem; display: block; }
.nav { display: flex; gap: 2px; margin-left: auto; flex-wrap: wrap; justify-content: flex-end; }
.nav a { padding: 7px 10px; border-radius: 9px; color: var(--text); text-decoration: none; font-weight: 600; font-size: .9rem; white-space: nowrap; }
.nav a:hover { background: var(--surface-2); }
.nav a.active { background: var(--soft); color: var(--primary); }
.nav .cls-link { font-family: var(--font-head); font-size: .82rem; }
.burger { display: none; margin-left: auto; font-size: 1.4rem; line-height: 1; padding: 8px 12px; }
.admin-strip { background: var(--accent-soft); border-bottom: 1px solid var(--line); font-size: .85rem; }
.admin-strip.student-mode { background: var(--soft); }
.strip-select { width: auto; padding: 3px 8px; font-size: .82rem; border-radius: 8px; }
.admin-strip .wrap { display: flex; gap: 12px; align-items: center; justify-content: space-between; min-height: 36px; flex-wrap: wrap; }

@media (max-width: 1180px) {
  .burger { display: inline-flex; margin-left: 2px; }
  .theme-btn { margin-left: auto; }
  .nav { display: none; position: absolute; left: 0; right: 0; top: 100%; background: var(--surface); border-bottom: 1px solid var(--line);
    flex-direction: column; padding: 8px 16px 14px; box-shadow: var(--shadow); }
  .nav.open { display: flex; }
  .nav a { padding: 11px 12px; font-size: 1rem; }
}

/* ===== Подвал ===== */
.site-footer { border-top: 1px solid var(--line); background: var(--surface); padding: 22px 0; color: var(--muted); font-size: .88rem; }
.site-footer .wrap { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.site-footer a { color: var(--muted); }

/* ===== Главная ===== */
.hero { display: grid; grid-template-columns: 1.5fr 1fr; gap: 32px; align-items: center; border: 1px solid var(--line);
  border-radius: 22px; padding: clamp(22px, 4vw, 44px); box-shadow: var(--shadow); position: relative; overflow: hidden;
  background-color: var(--surface);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 24px 24px; }
.hero::before { content: ""; position: absolute; top: 0; bottom: 0; right: 56px; width: 2px; background: var(--accent); opacity: .35; }
.hero > * { position: relative; }
.hero h1 { color: var(--text); }
.hero h1 { margin-bottom: .4em; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.hero-photo { justify-self: center; text-align: center; }
.photo { width: min(240px, 60vw); aspect-ratio: 1; border-radius: 50%; object-fit: cover; object-position: 50% 22%; border: 6px solid var(--soft); display: block; margin: 0 auto; }
.photo.placeholder { display: grid; place-items: center; background: linear-gradient(135deg, var(--soft), var(--accent-soft));
  font-family: var(--font-head); font-size: 3.4rem; color: var(--primary); }
.hero-photo .caption { margin-top: 10px; font-size: .85rem; color: var(--muted); }
@media (max-width: 760px) { .hero { grid-template-columns: 1fr; } .hero-photo { order: -1; } .photo { width: 150px; } .photo.placeholder { font-size: 2.4rem; } }

.grid { display: grid; gap: 16px; }
.cls-grid { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
a.card { color: var(--text); text-decoration: none; display: block; transition: border-color .15s, transform .15s; }
a.card:hover { border-color: var(--primary); transform: translateY(-2px); }
.cls-name { font-family: var(--font-head); font-size: 1.8rem; color: var(--primary); line-height: 1; margin-bottom: 8px; }
/* у каждого класса свой цвет — и в покое, и при наведении */
.cls-card { --cls: var(--primary); border-top: 5px solid var(--cls); }
.cls-grid > :nth-child(3n+2) { --cls: var(--accent); }
.cls-grid > :nth-child(3n+3) { --cls: var(--violet); }
.cls-card .cls-name { color: var(--cls); }
a.card.cls-card:hover { border-color: var(--cls); box-shadow: 0 0 0 1px var(--cls), var(--shadow); }
.cls-hw { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line); font-weight: 600; }
.label { display: inline-block; font-size: .75rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-right: 6px; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
@media (max-width: 760px) { .split { grid-template-columns: 1fr; } }
.week-card { background: linear-gradient(135deg, var(--accent-soft), var(--surface) 70%); border-color: color-mix(in srgb, var(--accent) 30%, var(--line)); }
.gen-box { background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px); background-size: 24px 24px; }
.quick { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.quick a { display: flex; flex-direction: column; gap: 4px; }
.quick b { font-size: 1.02rem; }

/* ===== Заголовки страниц ===== */
.page-head { margin-bottom: 24px; }
.page-head .actions, .chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; align-items: center; }
.edit-row { margin: -16px 0 24px; }

/* ===== Страница класса и записи ===== */
.class-layout { display: grid; grid-template-columns: 1.6fr 1fr; gap: 24px; align-items: start; }
@media (max-width: 860px) { .class-layout { grid-template-columns: 1fr; } }
.post { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 12px; }
.post-date { font-size: .8rem; font-weight: 700; color: var(--primary); margin-bottom: 4px; }
.post h3 { margin-bottom: .35em; }
.post.hw { border-left: 4px solid var(--primary); }
.post.news { border-left: 4px solid var(--accent); }
.empty { color: var(--muted); padding: 16px; border: 1px dashed var(--line); border-radius: var(--radius); text-align: center; }

/* ===== Банк задач ===== */
.filters { display: grid; grid-template-columns: repeat(4, 1fr) auto; gap: 10px; align-items: end; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 16px; }
.filters label { font-size: .8rem; color: var(--muted); }
@media (max-width: 860px) { .filters { grid-template-columns: 1fr 1fr; } }
.bank-stats { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; color: var(--muted); font-size: .9rem; }
.num-map { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 8px; margin-bottom: 18px; }
.num-tile { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 8px 4px; text-align: center; text-decoration: none; color: var(--text); }
.num-tile b { display: block; font-family: var(--font-head); font-size: 1.05rem; }
.num-tile span { font-size: .72rem; color: var(--muted); }
.num-tile:hover { border-color: var(--primary); }
.num-tile.active { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.num-tile.active span { color: var(--primary-ink); opacity: .85; }
.num-tile.zero { opacity: .45; }

.task { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 14px; box-shadow: var(--shadow); transition: border-color .2s; }
.task.ok { border-color: var(--ok); }
.task.bad { border-color: var(--bad); }
.task-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; font-size: .85rem; }
.badge { background: var(--soft); color: var(--primary); font-weight: 700; border-radius: 7px; padding: 2px 9px; }
.badge.accent { background: var(--accent-soft); color: color-mix(in srgb, var(--accent) 70%, var(--text)); }
.topic { color: var(--muted); }
.lvl { margin-left: auto; color: var(--accent); letter-spacing: 1px; }
.done-mark { color: var(--ok); font-weight: 700; }
.task-text { font-size: 1.02rem; }
.task-img { display: block; margin: 10px 0; max-height: 460px; max-width: 100%; height: auto; background: #fff; border-radius: 10px; padding: 6px; border: 1px solid var(--line); }
a .task-img { cursor: zoom-in; }
.img-picker .img-prev { max-height: 200px; }
.answer-row { display: flex; gap: 8px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.answer-row input { max-width: 200px; }
.verdict { font-weight: 700; font-size: .92rem; }
.verdict.ok { color: var(--ok); }
.verdict.bad { color: var(--bad); }
.solution { margin-top: 12px; border-top: 1px dashed var(--line); padding-top: 10px; }
.solution summary { cursor: pointer; color: var(--primary); font-weight: 600; font-size: .92rem; }
.solution[open] summary { margin-bottom: 8px; }
.solution .answer-line { background: var(--surface-2); border-radius: 8px; padding: 6px 10px; display: inline-block; margin-top: 4px; }
.task-tools { margin-left: 4px; }

/* ===== Варианты ===== */
.variant { list-style: none; padding: 0; margin: 0; }
.variant .solution { display: none; }
.variant.done .solution { display: block; }
.score { margin-top: 14px; font-size: 1.05rem; font-weight: 700; }
.score .big { font-family: var(--font-head); font-size: 1.6rem; color: var(--primary); }
.variant-foot { position: sticky; bottom: 0; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(6px); padding: 12px 0; border-top: 1px solid var(--line); }
.var-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.var-card .meta { color: var(--muted); font-size: .88rem; margin-bottom: 12px; }
.var-card .chips { margin-top: 0; }
.gen-box { background-color: var(--soft); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.print-answers { display: none; }

/* ===== Админка ===== */
.admin-tabs { display: flex; gap: 6px; flex-wrap: wrap; border-bottom: 1px solid var(--line); padding-bottom: 10px; margin-bottom: 20px; }
.admin-tabs a { padding: 8px 12px; border-radius: 9px; text-decoration: none; color: var(--text); font-weight: 600; font-size: .92rem; }
.admin-tabs a.active { background: var(--primary); color: var(--primary-ink); }
.admin-tabs .spacer { flex: 1; }
.notice { background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--line)); border-radius: 12px; padding: 10px 14px; font-size: .9rem; margin-bottom: 18px; }
.admin-form { display: grid; gap: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.row3 { display: grid; grid-template-columns: 1fr 1fr 2fr; gap: 12px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 700px) { .row3, .row2 { grid-template-columns: 1fr; } }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; margin: 0; }
legend { font-weight: 600; font-size: .92rem; padding: 0 6px; }
.inline-checks { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.preview { background: var(--surface-2); border-radius: 10px; padding: 10px 14px; min-height: 42px; font-size: .97rem; }
.preview:empty::before { content: "Здесь появится предпросмотр с формулами"; color: var(--muted); font-size: .85rem; }
.toolbar { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0 0; }
.toolbar button { font: inherit; font-size: .85rem; padding: 4px 9px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-2); color: var(--text); cursor: pointer; min-width: 34px; }
.toolbar button:hover { border-color: var(--primary); }
.adm-list { display: grid; gap: 8px; }
.adm-row { display: grid; grid-template-columns: 150px 1fr 120px auto; gap: 12px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; }
.adm-row .txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.adm-row .acts { display: flex; gap: 6px; }
@media (max-width: 760px) { .adm-row { grid-template-columns: 1fr; } .adm-row .txt { white-space: normal; } }
.task-picks { max-height: 360px; overflow: auto; display: grid; gap: 4px; padding: 6px; background: var(--surface-2); border-radius: 10px; }
.task-picks label { font-weight: 400; display: flex; gap: 8px; align-items: baseline; padding: 4px 6px; border-radius: 6px; }
.task-picks label:hover { background: var(--surface); }
.class-edit { display: grid; grid-template-columns: 100px 160px 1fr 190px auto; gap: 8px; align-items: end; margin-bottom: 10px; }
@media (max-width: 860px) { .class-edit { grid-template-columns: 1fr 1fr; padding-bottom: 10px; border-bottom: 1px dashed var(--line); } }
.code-edit { display: flex; gap: 6px; margin-top: 5px; }
.code-edit input { margin: 0; }
.upper { text-transform: uppercase; letter-spacing: .08em; }

/* ===== Вход и регистрация ===== */
.gate { max-width: 600px; margin: 10px auto 0; }
.gate-intro { text-align: center; margin-bottom: 20px; }
.gate-intro h1 { font-size: clamp(1.5rem, 4vw, 2.1rem); }
.gate-tabs { display: flex; gap: 6px; justify-content: center; margin-bottom: 14px; }
.gate-tabs a { padding: 9px 22px; border-radius: 10px; text-decoration: none; color: var(--text); font-weight: 700; border: 1px solid var(--line); background: var(--surface); }
.gate-tabs a.active { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.pw-wrap { position: relative; display: block; margin-top: 5px; }
.pw-wrap input { margin: 0; padding-right: 46px; }
.pw-eye { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; cursor: pointer;
  font-size: 1.05rem; padding: 6px 9px; border-radius: 8px; line-height: 1; }
.pw-eye:hover { background: var(--surface-2); }
.code-input { font-size: 1.5rem; letter-spacing: .4em; text-align: center; font-family: var(--font-head); }
.role-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.role-pick label { position: relative; }
.role-pick input { position: absolute; opacity: 0; pointer-events: none; }
.role-pick span { display: block; text-align: center; padding: 11px 10px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; font-weight: 700; background: var(--surface-2); }
.role-pick input:checked + span { border-color: var(--primary); background: var(--soft); color: var(--primary); box-shadow: 0 0 0 2px var(--soft); }
.role-pick input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }
[hidden] { display: none !important; }
.role-badge { font-size: .75rem; font-weight: 700; border-radius: 6px; padding: 2px 7px; }
.role-badge.admin { background: var(--soft); color: var(--primary); }
.role-badge.teacher { background: var(--accent-soft); color: color-mix(in srgb, var(--accent) 75%, var(--text)); }
.gate-err { color: var(--bad); font-weight: 600; min-height: 1em; }
.sent { margin-top: 6px; font-size: .92rem; font-weight: 600; }
.ok-mark { color: var(--ok); font-weight: 700; }
.bad-mark { color: var(--bad); font-weight: 700; }

/* ===== Гости, статистика, ФИПИ, формулы ===== */
.guest-note { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; background: var(--soft);
  border: 1px solid color-mix(in srgb, var(--primary) 25%, var(--line)); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 22px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat b { display: block; font-family: var(--font-head); font-size: 1.7rem; color: var(--primary); line-height: 1.1; }
.stat span { color: var(--muted); font-size: .88rem; }
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.doc-card { display: flex !important; gap: 12px; align-items: flex-start; padding: 14px 16px; }
.doc-card b { display: block; font-size: .95rem; margin-bottom: 2px; }
.doc-ic { font-size: 1.5rem; line-height: 1; }
.fipi-table td.num-cell { font-family: var(--font-head); color: var(--primary); width: 44px; }
.fipi-table .c { text-align: center; }
.fipi-table tbody tr:nth-child(even) { background: var(--surface-2); }
.fipi-link { background: var(--surface); border: 1px dashed var(--line); border-radius: 10px; padding: 9px 14px; font-size: .92rem; }
.formula-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 16px; align-items: start; }
.formula-card h2 { font-size: 1.1rem; color: var(--primary); }
.f-item { border-top: 1px dashed var(--line); padding: 6px 0; overflow-x: auto; }
.f-item:first-of-type { border-top: 0; }
.f-item .katex-display { margin: .35em 0; }
.f-cap { color: var(--muted); font-size: .8rem; text-align: center; margin-top: -4px; }
@media (max-width: 420px) { .formula-grid { grid-template-columns: 1fr; } }
@media print { .formula-grid { grid-template-columns: 1fr 1fr; } .formula-card { break-inside: avoid; box-shadow: none; } }

/* ===== Банк ФИПИ и кодификатор ===== */
.fipi-bank-cta { display: flex !important; align-items: center; gap: 14px; margin-bottom: 22px; border: 2px solid var(--primary); }
.fipi-bank-cta > span:nth-child(2) { flex: 1; }
.fipi-bank-cta b { display: block; font-size: 1.05rem; }
.fipi-frame-wrap { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: #fff; box-shadow: var(--shadow); }
.fipi-frame { display: block; width: 100%; height: min(85vh, 1100px); min-height: 560px; border: 0; }
.kes { display: grid; gap: 6px; }
.kes details { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
.kes summary { cursor: pointer; }
.kes summary b { color: var(--primary); margin-right: 4px; }
.kes ul { margin: 8px 0 2px; padding-left: 1.2em; color: var(--muted); font-size: .92rem; }

.hb-grid { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.hb-card { display: flex; gap: 14px; align-items: flex-start; }
.hb-cover { font-size: 2.4rem; line-height: 1; background: var(--soft); border-radius: 12px; padding: 12px; }
.hb-card h3 { margin-bottom: .25em; }

/* ===== Профиль, одноклассники, контрольные ===== */
.avatar { width: var(--s); height: var(--s); border-radius: 50%; object-fit: cover; display: inline-grid; place-items: center; flex-shrink: 0;
  background: linear-gradient(135deg, var(--soft), var(--accent-soft)); color: var(--primary); font-family: var(--font-head); font-size: calc(var(--s) * .36);
  border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--line); }
.profile-card { display: flex; gap: 28px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 22px;
  padding: clamp(18px, 3vw, 30px); box-shadow: var(--shadow); margin-bottom: 24px;
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px); background-size: 24px 24px; }
.profile-photo { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.profile-info h1 { margin-bottom: .2em; }
@media (max-width: 640px) { .profile-card { flex-direction: column; text-align: center; } .profile-info .actions { justify-content: center; } }
.mates { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.mate { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; font-weight: 600; font-size: .92rem; }
.tests-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.test-card { display: flex; gap: 12px; align-items: flex-start; }
.test-ic { font-size: 1.8rem; line-height: 1; }
.post.test { border-left: 4px solid var(--violet); }

.student-row .who { display: flex; gap: 10px; align-items: center; }
.student-row.banned { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 30%, var(--line)); }
.badge.ban { background: var(--bad-soft); color: var(--bad); }
.student-row { grid-template-columns: 1.6fr 100px .9fr auto; }
.student-row .acts { flex-wrap: wrap; justify-content: flex-end; }
.msg-del { border: 0; background: transparent; color: var(--muted); cursor: pointer; float: right; font-size: .8rem; padding: 0 0 0 8px; }
.msg-del:hover { color: var(--bad); }

/* ===== Конструктор варианта ===== */
.v-list { display: grid; gap: 6px; }
.v-bank { max-height: 420px; overflow: auto; padding: 6px; background: var(--surface-2); border-radius: 10px; }
.v-row { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; }
.v-num { font-family: var(--font-head); color: var(--primary); min-width: 22px; text-align: right; }
.v-txt { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .9rem; }
.v-acts { display: flex; gap: 2px; flex-shrink: 0; }
.v-new { border: 1px dashed var(--primary); border-radius: 10px; padding: 10px 14px; }
.v-new summary { cursor: pointer; font-weight: 700; color: var(--primary); }
.v-new-body { display: grid; gap: 12px; margin-top: 12px; }
@media (max-width: 640px) { .v-row { flex-wrap: wrap; } .v-txt { white-space: normal; flex-basis: 100%; order: 3; } }

/* ===== Окно обрезки фото ===== */
body.modal-open { overflow: hidden; }
.crop-modal { position: fixed; inset: 0; z-index: 100; background: rgba(15, 20, 30, .6); display: grid; place-items: center; padding: 16px; }
.crop-dialog { background: var(--surface); border-radius: 18px; padding: 18px 20px; width: min(620px, 100%); max-height: 100%; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.crop-dialog h2 { margin-bottom: .2em; }
.crop-body { display: flex; gap: 18px; align-items: center; margin: 10px 0 12px; }
.crop-stage { position: relative; width: min(360px, 78vw); aspect-ratio: 1; overflow: hidden; border-radius: 14px; background: #111; touch-action: none; cursor: grab; flex-shrink: 0; user-select: none; }
.crop-stage:active { cursor: grabbing; }
.crop-stage img { position: absolute; max-width: none; pointer-events: none; }
.crop-ring { position: absolute; left: 50%; top: 50%; width: var(--c, 84%); height: var(--c, 84%); transform: translate(-50%, -50%); border-radius: 50%;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, .55); outline: 2px solid rgba(255, 255, 255, .85); pointer-events: none; }
.crop-side { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.crop-prev { border-radius: 50%; border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--line); background: var(--surface-2); }
.crop-prev.big { width: 96px; height: 96px; }
.crop-prev.small { width: 40px; height: 40px; }
.crop-zoom { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.crop-zoom input { flex: 1; accent-color: var(--primary); padding: 0; }
@media (max-width: 560px) { .crop-body { flex-direction: column; } .crop-side { flex-direction: row; } }

/* ===== Переписка ===== */
.ask-row { margin-top: 10px; text-align: right; }
.ask-btn { font-size: .88rem; font-weight: 600; text-decoration: none; color: var(--muted); }
.ask-btn:hover { color: var(--primary); }
.chat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.chat-box { max-height: 60vh; min-height: 220px; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; background: var(--surface-2); }
.msg { max-width: 78%; align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-radius: 14px 14px 14px 4px; padding: 8px 12px; }
.msg.mine { align-self: flex-end; background: var(--soft); border-color: color-mix(in srgb, var(--primary) 25%, var(--line)); border-radius: 14px 14px 4px 14px; }
.msg.teacher:not(.mine) { border-left: 3px solid var(--accent); }
.msg-meta { font-size: .75rem; color: var(--muted); margin-bottom: 3px; }
.msg-text p { margin: 0 0 .4em; }
.msg-task { display: block; font-size: .82rem; margin-bottom: 4px; text-decoration: none; background: var(--surface-2); border-radius: 8px; padding: 4px 8px; }
.msg-form { padding: 12px 16px; border-top: 1px solid var(--line); display: grid; gap: 8px; }
.msg-attach { font-size: .88rem; background: var(--accent-soft); border-radius: 8px; padding: 6px 10px; display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.thread-row { text-decoration: none; color: var(--text); grid-template-columns: 180px 1fr 130px 90px; }
.thread-row.unread { border-color: var(--accent); background: var(--accent-soft); }
.thread-row:hover { border-color: var(--primary); }
@media (max-width: 760px) { .msg { max-width: 92%; } .thread-row { grid-template-columns: 1fr; } }

/* ===== Результаты ===== */
.result { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; }
.result summary { display: flex; align-items: center; gap: 12px; padding: 10px 14px; cursor: pointer; list-style: none; }
.result summary::-webkit-details-marker { display: none; }
.result[open] summary { border-bottom: 1px solid var(--line); }
.r-score { font-family: var(--font-head); font-size: .95rem; min-width: 58px; text-align: center; padding: 5px 8px; border-radius: 8px; }
.r-score.good { background: var(--ok-soft); color: var(--ok); }
.r-score.mid { background: var(--accent-soft); color: color-mix(in srgb, var(--accent) 75%, var(--text)); }
.r-score.low { background: var(--bad-soft); color: var(--bad); }
.r-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.r-wrap { overflow-x: auto; padding: 6px 14px 12px; }
.r-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.r-table th { text-align: left; color: var(--muted); font-weight: 600; font-size: .8rem; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.r-table td { padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.r-table tr:last-child td { border-bottom: none; }
.codes { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 6px; }
.code-chip { background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 5px 10px; }
.code-chip code { font-size: 1.05rem; letter-spacing: .1em; color: var(--primary); font-weight: 700; }
.student-row { grid-template-columns: 1.4fr 110px 1fr auto; }
@media (max-width: 760px) { .student-row { grid-template-columns: 1fr; } }
.img-prev { max-height: 140px; display: block; margin-top: 8px; background: #fff; border-radius: 8px; padding: 4px; border: 1px solid var(--line); }
.login { max-width: 380px; margin: 40px auto; }

/* ===== Уведомление ===== */
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: var(--text); color: var(--bg);
  padding: 10px 18px; border-radius: 10px; font-weight: 600; opacity: 0; pointer-events: none; transition: .25s; z-index: 50; max-width: calc(100% - 32px); }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== Печать вариантов ===== */
@media print {
  :root { --bg: #fff; --surface: #fff; --text: #000; --line: #bbb; --shadow: none; }
  #header, #footer, #toast, .no-print, .answer-row, .solution, .variant-foot, .edit-row, .page-head .actions { display: none !important; }
  main { padding: 0; }
  .task { box-shadow: none; break-inside: avoid; border: none; border-bottom: 1px solid #ccc; border-radius: 0; padding: 10px 0; }
  .lvl, .done-mark { display: none; }
  body.print-answers-on .print-answers { display: block; break-before: page; }
}
