/* ВсОШ ИИ · тренажёр — канон EdTech, планка: Яндекс Практикум.
   Светлая тема (дневная учёба за Mac), один акцент, спокойная взрослая типографика. */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --text: #1c2126;
  --text-2: #5b6570;
  --line: #e3e7ec;
  --accent: #3550f0;
  --accent-hover: #2a41d0;
  --accent-weak: #eaedfe;
  --ok: #0e7a34;
  --ok-weak: #e7f5ec;
  --warn: #9a6700;
  --warn-weak: #fff4d6;
  --bad: #c92a35;
  --bad-weak: #fdebec;
  --radius: 12px;
  --radius-s: 8px;
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 4px 14px rgba(16,24,40,.05);
  --font: 'Inter', -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --on-accent: #ffffff;
  --surface-hover: #fafbfd;
  --callout-border: #d5dbfc;
  --ok-border: #bfe3cb;
  --warn-border: #ecd9a0;
  --exam-border: #f2c6c9;
  --exam-bg: #fffafa;
  --scroll-thumb: #c6cdd6;
  --code-bg: #f1f3f6;
  color-scheme: light;
  --tshadow: rgba(16, 24, 40, .22);
}

[data-theme="dark"] {
  --bg: #12151a;
  --surface: #1a1e25;
  --surface-2: #232830;
  --text: #e6e9ee;
  --text-2: #9aa4b1;
  --line: #2c333d;
  --accent: #8a98ff;
  --accent-hover: #a3aeff;
  --accent-weak: #262d52;
  --ok: #55c982;
  --ok-weak: #17311f;
  --warn: #e3b64f;
  --warn-weak: #332a12;
  --bad: #ff7079;
  --bad-weak: #3b1c20;
  --shadow: 0 1px 2px rgba(0,0,0,.45), 0 4px 14px rgba(0,0,0,.35);
  --on-accent: #0f1322;
  --surface-hover: #1f242c;
  --callout-border: #38427c;
  --ok-border: #2c5a3c;
  --warn-border: #6a5622;
  --exam-border: #5a2b30;
  --exam-bg: #221619;
  --scroll-thumb: #3a424d;
  --code-bg: #0f1216;
  color-scheme: dark;
  --tshadow: rgba(0, 0, 0, .6);
}
[data-theme="dark"] .CodeMirror { background: var(--code-bg); color: var(--text); }
[data-theme="dark"] .CodeMirror-gutters { background: #161a20; border-right: 1px solid var(--line); }
[data-theme="dark"] .CodeMirror-linenumber { color: var(--text-2); }
[data-theme="dark"] .CodeMirror-cursor { border-left-color: var(--text); }
[data-theme="dark"] .cm-s-default .cm-keyword { color: #c792ea; }
[data-theme="dark"] .cm-s-default .cm-string { color: #c3e88d; }
[data-theme="dark"] .cm-s-default .cm-number { color: #f78c6c; }
[data-theme="dark"] .cm-s-default .cm-comment { color: #7a8594; }
[data-theme="dark"] .cm-s-default .cm-builtin { color: #82aaff; }
[data-theme="dark"] .cm-s-default .cm-def, [data-theme="dark"] .cm-s-default .cm-variable { color: var(--text); }
[data-theme="dark"] .statement img, [data-theme="dark"] details.spoiler .body img { filter: invert(0.92) hue-rotate(180deg); }

.theme-btn {
  border: 1px solid var(--line); background: var(--surface); color: var(--text-2);
  width: 36px; height: 36px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; flex: none;
}
.theme-btn:hover { color: var(--text); background: var(--surface-2); }
.theme-btn svg { width: 17px; height: 17px; }
.theme-btn .ic-moon { display: none; }
[data-theme="dark"] .theme-btn .ic-sun { display: none; }
[data-theme="dark"] .theme-btn .ic-moon { display: block; }

* { 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;
  font-feature-settings: 'tnum' 0;
}
::selection { background: var(--accent-weak); color: var(--accent-hover); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
* { scrollbar-width: thin; scrollbar-color: var(--scroll-thumb) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--scroll-thumb); border-radius: 6px; border: 2px solid var(--bg); }
*::-webkit-scrollbar-track { background: transparent; }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; text-underline-offset: 3px; }

/* ---------- каркас ---------- */
.topbar {
  background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 50;
}
.topbar-in {
  max-width: 1120px; margin: 0 auto; padding: 0 24px;
  display: flex; align-items: center; gap: 28px; height: 60px;
}
.brand { font-weight: 800; font-size: 17px; color: var(--text); letter-spacing: -.01em; }
.brand:hover { text-decoration: none; color: var(--text); }
.brand em { font-style: normal; color: var(--accent); }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a {
  color: var(--text-2); font-size: 14.5px; font-weight: 550; padding: 8px 12px;
  border-radius: var(--radius-s);
}
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.on { color: var(--accent); background: var(--accent-weak); }
.deadline-chip {
  font-family: var(--mono); font-size: 12.5px; color: var(--text-2);
  border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; white-space: nowrap;
}
.deadline-chip b { color: var(--text); font-weight: 700; }

.container { max-width: 1120px; margin: 0 auto; padding: 32px 24px 80px; }
.container.narrow { max-width: 880px; }

/* ---------- дашборд ---------- */
.hero-panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 28px 32px; margin-bottom: 36px;
  display: flex; justify-content: space-between; align-items: center; gap: 32px; flex-wrap: wrap;
}
.hero-panel h1 { margin: 0 0 6px; font-size: 24px; letter-spacing: -.02em; line-height: 1.25; }
.hero-panel .sub { color: var(--text-2); font-size: 15px; margin: 0; max-width: 62ch; }
.hero-dates { display: flex; gap: 14px; }
.date-tile {
  border: 1px solid var(--line); border-radius: var(--radius-s); padding: 12px 18px; text-align: center;
  min-width: 128px; background: var(--bg);
}
.date-tile .num { font-family: var(--mono); font-size: 26px; font-weight: 700; line-height: 1.15; }
.date-tile .lbl { font-size: 12px; color: var(--text-2); margin-top: 3px; }

.block-head { margin: 40px 0 6px; }
.block-head h2 { font-size: 19px; margin: 0 0 4px; letter-spacing: -.015em; }
.block-head p { margin: 0 0 14px; color: var(--text-2); font-size: 14.5px; max-width: 78ch; }

.mod-list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.mod-row {
  display: grid; grid-template-columns: 1fr auto auto; gap: 20px; align-items: center;
  padding: 15px 22px; border-top: 1px solid var(--line); color: inherit;
}
.mod-row:first-child { border-top: none; }
.mod-row:hover { background: var(--surface-hover); text-decoration: none; color: inherit; }
.mod-row .t { font-weight: 650; font-size: 15.5px; }
.mod-row .d { color: var(--text-2); font-size: 13.5px; margin-top: 2px; max-width: 72ch; }
.mod-prog { display: flex; align-items: center; gap: 10px; min-width: 170px; justify-content: flex-end; }
.bar { width: 90px; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.bar.done i { background: var(--ok); }
.mod-count { font-family: var(--mono); font-size: 12.5px; color: var(--text-2); white-space: nowrap; }

/* статусы: всегда значок + слово */
.st { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.st svg { flex: none; }
.st.solved { color: var(--ok); }
.st.tried { color: var(--warn); }
.st.none { color: var(--text-2); font-weight: 500; }

/* ---------- страница модуля ---------- */
.mod-header { margin-bottom: 26px; }
.mod-header .crumbs { font-size: 13.5px; color: var(--text-2); margin-bottom: 10px; }
.mod-header h1 { margin: 0 0 8px; font-size: 28px; letter-spacing: -.02em; }
.mod-header .goal { color: var(--text-2); font-size: 16px; max-width: 74ch; }

.zone { margin-top: 36px; }
.zone-title {
  display: flex; align-items: center; gap: 12px; margin-bottom: 14px;
}
.zone-title h2 { font-size: 17px; margin: 0; letter-spacing: .01em; }
.zone-title .line { flex: 1; height: 1px; background: var(--line); }

/* теория */
.theory {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 34px 40px; font-size: 16.5px; line-height: 1.68;
}
.theory .lead { font-size: 18px; color: var(--text); font-weight: 500; line-height: 1.6; margin-top: 0; }
.theory h2 { font-size: 20px; margin: 34px 0 10px; letter-spacing: -.015em; }
.theory h2:first-child { margin-top: 0; }
.theory h3 { font-size: 17px; margin: 24px 0 8px; }
.theory p, .theory li { max-width: 74ch; }
.theory ul, .theory ol { padding-left: 24px; }
.theory li { margin: 5px 0; }
.theory .callout {
  background: var(--accent-weak); border: 1px solid var(--callout-border); border-radius: var(--radius-s);
  padding: 14px 18px; margin: 18px 0; font-size: 15.5px;
}
.theory .example {
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-s);
  padding: 14px 18px; margin: 16px 0; font-size: 15.5px;
}
.theory table.theory-table { border-collapse: collapse; margin: 14px 0; font-size: 15px; }
.theory table.theory-table th, .theory table.theory-table td { border: 1px solid var(--line); padding: 8px 14px; text-align: left; }
.theory table.theory-table th { background: var(--surface-2); font-size: 13.5px; }
.theory code { font-family: var(--mono); font-size: .88em; background: var(--surface-2); border-radius: 4px; padding: 1.5px 5px; }
.theory pre, .trainer-q pre {
  background: var(--code-bg); border: 1px solid var(--line); border-radius: var(--radius-s);
  padding: 14px 18px; margin: 14px 0; overflow-x: auto; font-family: var(--mono); font-size: 13.5px; line-height: 1.55;
}
.theory pre code, .trainer-q pre code { background: none; padding: 0; font-size: inherit; }
.theory table.theory-table code { white-space: nowrap; }

/* тренажёр */
.trainer-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px 28px; }
.gen-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.gen-tabs button {
  border: 1px solid var(--line); background: var(--surface); color: var(--text-2);
  font: 550 13.5px var(--font); border-radius: 999px; padding: 7px 15px; cursor: pointer;
}
.gen-tabs button:hover { border-color: #c9d0da; color: var(--text); }
.gen-tabs button.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.trainer-q { font-size: 16px; line-height: 1.6; max-width: 76ch; }
.trainer-q table.mini { border-collapse: collapse; margin: 10px 0; font-size: 14px; }
.trainer-q table.mini th, .trainer-q table.mini td { border: 1px solid var(--line); padding: 4px 12px; }
.trainer-q table.mini th { background: var(--surface-2); }
.trainer-stats { color: var(--text-2); font-size: 13px; font-family: var(--mono); }

/* формы ответа */
.answer-form { margin-top: 18px; display: flex; flex-direction: column; gap: 12px; }
.afield { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.afield label { font-size: 14px; color: var(--text-2); min-width: 130px; }
.afield input[type="text"] {
  font: 500 15px var(--mono); color: var(--text);
  border: 1.5px solid var(--line); border-radius: var(--radius-s); padding: 9px 13px; width: 240px;
  background: var(--surface); caret-color: var(--accent);
}
.afield input[type="text"]:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-weak); }
.afield input.good { border-color: var(--ok); background: var(--ok-weak); }
.afield input.badf { border-color: var(--bad); background: var(--bad-weak); }
.aactions { display: flex; align-items: center; gap: 14px; margin-top: 4px; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; gap: 8px; border: none; cursor: pointer;
  background: var(--accent); color: var(--on-accent); font: 600 14.5px var(--font);
  padding: 10px 20px; border-radius: var(--radius-s);
  transition: background .12s ease-out, transform .06s ease-out;
}
.btn:hover { background: var(--accent-hover); }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: var(--surface); color: var(--text); border: 1px solid var(--line); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.small { padding: 7px 14px; font-size: 13.5px; }
.btn:disabled { opacity: .55; cursor: default; }

.verdict { font: 700 14px var(--mono); display: inline-flex; align-items: center; gap: 7px; }
.verdict.ok { color: var(--ok); }
.verdict.bad { color: var(--bad); }

/* задачи всош */
.task-row {
  display: grid; grid-template-columns: 1fr auto auto; gap: 18px; align-items: center;
  padding: 13px 22px; border-top: 1px solid var(--line); color: inherit;
}
.task-row:first-child { border-top: none; }
.task-row:hover { background: var(--surface-hover); text-decoration: none; color: inherit; }
.task-row .t { font-weight: 600; font-size: 15px; }
.task-row .src { color: var(--text-2); font-size: 12.5px; margin-top: 1px; }
.task-row .pts { font-family: var(--mono); font-size: 12.5px; color: var(--text-2); }

/* ---------- страница задачи ---------- */
.task-head { margin-bottom: 20px; }
.task-head .crumbs { font-size: 13.5px; color: var(--text-2); margin-bottom: 8px; }
.task-head h1 { margin: 0 0 6px; font-size: 24px; letter-spacing: -.02em; }
.task-meta { display: flex; gap: 10px; flex-wrap: wrap; font-size: 13px; color: var(--text-2); align-items: center; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 4px 12px; }
.chip.warn-chip { background: var(--warn-weak); border-color: var(--warn-border); color: var(--warn); }
.proto-line { margin: 10px 0 0; font-size: 14px; color: var(--text-2); max-width: 76ch; }

.statement {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; margin-bottom: 22px;
}
.statement img { width: 100%; height: auto; display: block; border-radius: 6px; }
.statement .note { padding: 10px 14px 4px; color: var(--text-2); font-size: 13.5px; }

.solution-box { margin-top: 26px; }
details.spoiler { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
details.spoiler > summary {
  cursor: pointer; padding: 14px 20px; font-weight: 650; font-size: 15px; color: var(--accent);
  list-style: none; display: flex; align-items: center; gap: 10px;
}
details.spoiler > summary::-webkit-details-marker { display: none; }
details.spoiler > summary .arr { transition: transform .15s ease-out; }
details.spoiler[open] > summary .arr { transform: rotate(90deg); }
details.spoiler .body { padding: 4px 20px 20px; }
details.spoiler .body img { width: 100%; height: auto; border-radius: 6px; }

/* код-задачи */
.code-wrap { border: 1px solid var(--line); border-radius: var(--radius-s); overflow: hidden; }
.CodeMirror { height: 380px; font-family: var(--mono); font-size: 13.5px; line-height: 1.5; }
.tests-table { width: 100%; border-collapse: collapse; font-size: 13.5px; margin-top: 14px; }
.tests-table th { text-align: left; padding: 7px 12px; background: var(--surface-2); font-size: 12px; letter-spacing: .04em; text-transform: uppercase; color: var(--text-2); }
.tests-table td { padding: 7px 12px; border-top: 1px solid var(--line); vertical-align: top; }
.tests-table pre { margin: 0; font-family: var(--mono); font-size: 12.5px; white-space: pre-wrap; }
.vd { font: 700 12.5px var(--mono); }
.vd.OK { color: var(--ok); } .vd.WA, .vd.RE { color: var(--bad); } .vd.TL { color: var(--warn); }
.run-summary { font: 650 14px var(--mono); margin-left: 12px; }

/* ---------- пробники ---------- */
.probe-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px 26px; margin-bottom: 16px;
  display: flex; justify-content: space-between; gap: 24px; align-items: center; flex-wrap: wrap;
}
.probe-card h3 { margin: 0 0 6px; font-size: 17px; }
.probe-card p { margin: 0; color: var(--text-2); font-size: 14px; max-width: 70ch; }
.probe-card .facts { font-family: var(--mono); font-size: 12.5px; color: var(--text-2); margin-top: 8px; }

.probe-timer {
  position: sticky; top: 60px; z-index: 40; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-s); box-shadow: var(--shadow);
  padding: 12px 20px; display: flex; align-items: center; gap: 18px; margin-bottom: 24px;
}
.probe-timer .time { font: 700 22px var(--mono); letter-spacing: .02em; }
.probe-timer.low .time { color: var(--bad); }
.probe-task { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 24px; margin-bottom: 20px; }
.probe-task h3 { margin: 0 0 12px; font-size: 16px; }
.probe-task .saved { color: var(--ok); font-size: 13px; font-weight: 600; }

.result-table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.result-table th { text-align: left; background: var(--surface-2); padding: 10px 16px; font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); }
.result-table td { padding: 11px 16px; border-top: 1px solid var(--line); font-size: 14.5px; }
.result-table .num { font-family: var(--mono); }

/* ---------- календарь ---------- */
.key-dates { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; margin-bottom: 34px; }
.kd {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 22px;
}
.kd .when { font: 700 14px var(--mono); color: var(--accent); }
.kd.exam .when { color: var(--bad); }
.kd .what { font-size: 14.5px; margin-top: 6px; color: var(--text); }

.week {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 24px; margin-bottom: 14px;
  display: grid; grid-template-columns: 150px 1fr; gap: 20px;
}
.week .wn { font: 700 14px var(--mono); color: var(--text-2); }
.week .wn b { display: block; font-size: 16px; color: var(--text); margin-bottom: 2px; }
.week .goal { font-size: 14.5px; }
.week .mods { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 8px; }
.week .milestone { margin-top: 8px; font-weight: 650; color: var(--accent); font-size: 14px; }
.week.exam-week { border-color: var(--exam-border); background: var(--exam-bg); }
.week.exam-week .milestone { color: var(--bad); }
.mod-chip { font-size: 13px; border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; color: var(--text-2); }
.mod-chip:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.mod-chip.done-chip { border-color: var(--ok-border); color: var(--ok); background: var(--ok-weak); }
.statement-text { padding: 14px 18px 6px; font-size: 16px; line-height: 1.6; }
.statement-text p, .statement-text li { max-width: 76ch; }
.statement-text h3 { font-size: 15px; margin: 18px 0 6px; }
.statement-text pre { background: var(--code-bg); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 10px 14px; font-family: var(--mono); font-size: 13.5px; overflow-x: auto; }
.statement-text table.mini { border-collapse: collapse; font-size: 14px; margin: 8px 0; }
.statement-text table.mini th, .statement-text table.mini td { border: 1px solid var(--line); padding: 4px 12px; vertical-align: top; }
.statement-text table.mini th { background: var(--surface-2); }

.pace-note { color: var(--text-2); font-size: 14px; max-width: 80ch; margin-bottom: 26px; }

/* ---------- разное ---------- */
.muted { color: var(--text-2); }
.mono { font-family: var(--mono); }
.mt0 { margin-top: 0; }
.hidden { display: none !important; }
.footer { max-width: 1120px; margin: 0 auto; padding: 0 24px 40px; color: var(--text-2); font-size: 12.5px; }


/* лестница тренажёра и практика по уровням */
.ladder { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 12px; }
.ladder-step { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 12px 14px; }
.ladder-step.done { border-color: var(--ok-border); background: var(--ok-weak); }
.ladder-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.ladder-num { font: 700 12px var(--mono); width: 22px; height: 22px; border-radius: 999px; background: var(--accent-weak); color: var(--accent); display: inline-flex; align-items: center; justify-content: center; }
.ladder-step.done .ladder-num { background: var(--ok); color: var(--on-accent); }
.ladder-title { font-weight: 650; font-size: 14px; flex: 1; }
.ladder-step .bar { width: 100%; }
.ladder-hint { font-size: 13.5px; margin: 0 0 16px; max-width: 80ch; }
.gen-group { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; width: 100%; padding: 6px 0; border-top: 1px solid var(--line); }
.gen-group:first-child { border-top: none; padding-top: 0; }
.gen-group-label { font: 600 12px var(--font); color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; margin-right: 6px; white-space: nowrap; }
.practice-group { margin-bottom: 16px; }
.practice-label { font-size: 14px; font-weight: 600; margin: 0 0 8px; display: flex; align-items: center; gap: 10px; }
.lvl-badge { font: 700 11.5px var(--mono); border-radius: 999px; padding: 3px 10px; border: 1px solid var(--line); color: var(--text-2); }
.lvl-badge.lvl-1 { background: var(--ok-weak); color: var(--ok); border-color: var(--ok-border); }
.lvl-badge.lvl-2 { background: var(--accent-weak); color: var(--accent); border-color: var(--callout-border); }
.lvl-badge.lvl-3 { background: var(--warn-weak); color: var(--warn); border-color: var(--warn-border); }
.solution-text { padding-top: 6px; }

/* авторизация */
.user-chip { display: inline-flex; align-items: center; gap: 10px; font-size: 13.5px; white-space: nowrap; }
.user-name { font-weight: 650; color: var(--text); }
.user-logout { color: var(--text-2); font-size: 13px; }
.login-wrap { display: flex; justify-content: center; padding: 40px 0; }
.login-card { width: 100%; max-width: 440px; }
.login-card h1 { margin: 0 0 6px; font-size: 22px; letter-spacing: -.02em; }
.login-card .muted { font-size: 14px; margin: 0 0 18px; }
.login-card .afield { margin-bottom: 12px; }
.login-card .afield label { min-width: 70px; }
.login-card .afield input[type="text"], .login-card .afield input[type="password"] {
  font: 500 15px var(--font); color: var(--text); border: 1.5px solid var(--line); border-radius: var(--radius-s);
  padding: 9px 13px; width: 260px; background: var(--surface); caret-color: var(--accent);
}
.login-card .afield input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-weak); }
.login-error { color: var(--bad); font-weight: 600; font-size: 14px; margin: 4px 0 10px; }

/* ---------- поток ---------- */
.flow-head {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px 20px; margin-bottom: 22px;
}
.flow-head-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.flow-back {
  border: 1px solid var(--line); background: var(--surface); color: var(--text-2); cursor: pointer;
  width: 28px; height: 28px; border-radius: 999px; font-size: 15px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center; flex: none;
}
.flow-back:hover { background: var(--surface-2); color: var(--text); }
.chip-done { background: var(--ok-weak); color: var(--ok); border-color: var(--ok-border); font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px; }
.chip-seen { background: var(--warn-weak); color: var(--warn); border-color: var(--warn-border); }
.flow-day { font: 700 15px var(--font); letter-spacing: -.01em; }
.flow-facts { font-family: var(--mono); font-size: 12.5px; color: var(--text-2); margin-left: auto; }
.flow-facts b { color: var(--text); }
.flow-progress { width: 100%; height: 6px; display: block; }
.flow-sub { font-size: 13px; color: var(--text-2); margin-top: 8px; }
.flow-title { margin: 0 0 6px; font-size: 22px; letter-spacing: -.02em; }
.chip-real { background: var(--accent-weak); color: var(--accent); border-color: var(--accent-weak); font-weight: 600; }
.chip-clone { background: var(--accent-weak); color: var(--accent); border-color: var(--accent-weak); font-weight: 600; }
.chip-author { background: var(--ok-weak); color: var(--ok); border-color: var(--ok-border); font-weight: 600; }
.chip-theory { background: var(--warn-weak); color: var(--warn); border-color: var(--warn-border); font-weight: 600; }
.chip-why { font-style: italic; }
.flow-theory { padding: 22px 26px; }
.flow-theory .task-meta { margin-bottom: 12px; }
.flow-theory-body { padding: 0; border: none; box-shadow: none; background: none; }
.flow-theory-body p:first-child { margin-top: 0; }
.flow-theory .aactions { margin-top: 18px; }
.flow-solution { margin-top: 18px; }
.flow-answer { font-size: 16px; }
.flow-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 22px; }
.flow-done { opacity: .75; }
.flow-skip { margin-top: 18px; font-size: 13px; }
.flow-skip a { color: var(--text-2); }
.flow-cta {
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  background: var(--accent-weak); border: 1px solid var(--accent-weak); border-radius: var(--radius);
  padding: 20px 24px; margin-bottom: 30px;
}
.flow-cta h2 { margin: 0 0 4px; font-size: 19px; letter-spacing: -.015em; }
.flow-cta p { margin: 0; color: var(--text-2); font-size: 14.5px; max-width: 64ch; }
.flow-cta .btn { margin-left: auto; }

/* ---------- широкий контент внутри карточек ---------- */
.tscroll {
  overflow-x: auto; max-width: 100%; -webkit-overflow-scrolling: touch; position: relative; /* position: скрытый MathML KaTeX не выпрыгивает из прокрутки */
  /* тени по краям появляются только когда есть что листать (background-attachment: local) */
  background:
    linear-gradient(to right, var(--surface) 30%, rgba(255, 255, 255, 0)),
    linear-gradient(to right, rgba(255, 255, 255, 0), var(--surface) 70%) 100% 0,
    radial-gradient(farthest-side at 0 50%, var(--tshadow), rgba(0, 0, 0, 0)),
    radial-gradient(farthest-side at 100% 50%, var(--tshadow), rgba(0, 0, 0, 0)) 100% 0;
  background-repeat: no-repeat; background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
  background-attachment: local, local, scroll, scroll;
}
.tscroll > table { margin-top: 0; margin-bottom: 0; }
.katex-display { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }
.img-full { display: block; }
.img-full:hover { text-decoration: none; }
.img-hint { font-size: 13px; color: var(--text-2); padding: 8px 4px 0; }
.only-m, .only-m-inline { display: none; }

/* ---------- телефон ---------- */
@media (max-width: 760px) {
  .only-m { display: block; }
  .only-m-inline { display: inline; }
  .hide-m { display: none; }

  /* шапка: две строки, не липнет, чтобы не съедать экран */
  .topbar { position: static; }
  .topbar-in { flex-wrap: wrap; height: auto; gap: 6px 10px; padding: 10px 14px 8px; }
  .brand { white-space: nowrap; font-size: 16px; }
  .deadline-chip { display: none; }
  .user-chip { margin-left: auto; gap: 8px; font-size: 13px; }
  .nav { order: 10; flex: 0 0 100%; gap: 2px; margin-top: 2px; }
  .nav a { padding: 7px 10px; font-size: 14px; }

  .container { padding: 16px 14px 56px; }
  .footer { padding: 0 14px 32px; }

  /* дашборд */
  .hero-panel { padding: 18px 16px; gap: 18px; margin-bottom: 26px; }
  .hero-panel h1 { font-size: 21px; }
  .hero-panel .sub { font-size: 14.5px; }
  .hero-dates { width: 100%; }
  .date-tile { flex: 1; min-width: 0; padding: 10px 8px; }
  .block-head { margin-top: 30px; }
  .mod-row, .task-row { grid-template-columns: 1fr; gap: 6px; padding: 13px 16px; }
  .mod-prog { justify-content: flex-start; min-width: 0; }

  /* модуль */
  .mod-header h1 { font-size: 23px; }
  .mod-header .goal { font-size: 15px; }
  .zone { margin-top: 28px; }
  .zone-title { flex-wrap: wrap; gap: 8px 12px; }
  .zone-title .trainer-stats { margin-left: auto; }
  .theory { padding: 18px 16px; font-size: 16px; overflow-x: auto; position: relative; }
  .theory h2 { font-size: 18px; margin-top: 26px; }
  .theory .lead { font-size: 17px; }
  .theory pre, .trainer-q pre, .statement-text pre { padding: 10px 12px; font-size: 12.5px; }
  .theory table.theory-table { width: max-content; min-width: 100%; max-width: 640px; }
  .theory table.theory-table th, .theory table.theory-table td { padding: 7px 10px; font-size: 14px; }
  .ladder { grid-template-columns: 1fr; }
  .trainer-panel { padding: 16px 14px; }
  .gen-tabs { gap: 6px; }
  .gen-tabs button { padding: 7px 11px; font-size: 13px; }
  .gen-group { gap: 6px; }
  .gen-group-label { flex: 0 0 100%; margin: 0; }
  .trainer-q, .statement-text, .solution-text, details.spoiler .body { overflow-x: auto; position: relative; }

  /* формы: поле во всю ширину, подпись сверху, 16px без автозума iOS */
  .afield { flex-direction: column; align-items: stretch; gap: 6px; }
  .afield label { min-width: 0; }
  .afield input[type="text"], .login-card .afield input[type="text"], .login-card .afield input[type="password"] { width: 100%; font-size: 16px; }
  .aactions { gap: 10px; }
  .btn { padding: 11px 18px; font-size: 15px; }
  .btn.small { padding: 9px 14px; font-size: 14px; }

  /* задача */
  .task-head h1 { font-size: 22px; }
  .statement { padding: 12px; }
  .statement-text { padding: 8px 6px 2px; font-size: 15.5px; }
  details.spoiler > summary { padding: 12px 14px; font-size: 14.5px; }
  details.spoiler .body { padding: 2px 14px 16px; }
  .CodeMirror { height: 300px; font-size: 13px; }
  .tests-table th, .tests-table td { padding: 6px 8px; }
  .run-summary { margin-left: 0; }

  /* пробники */
  .probe-card { padding: 16px; gap: 12px; }
  .probe-card .btn { width: 100%; justify-content: center; }
  .probe-timer { top: 0; padding: 8px 12px; gap: 10px; flex-wrap: nowrap; }
  .probe-timer .time { font-size: 19px; }
  .probe-timer .muted { display: none; }
  .probe-timer .btn { margin-left: auto; padding: 8px 14px; font-size: 13.5px; }
  .probe-task { padding: 16px 14px; }
  .result-table th, .result-table td { padding: 8px 10px; font-size: 13.5px; }

  /* календарь */
  .key-dates { grid-template-columns: 1fr; gap: 10px; }
  .kd { padding: 14px 16px; }
  .week { grid-template-columns: 1fr; gap: 8px; padding: 14px 16px; }

  .flow-head { padding: 12px 14px; }
  .flow-facts { margin-left: 0; width: 100%; }
  .flow-theory { padding: 16px 14px; }
  .flow-actions { flex-direction: column; }
  .flow-actions .btn { width: 100%; justify-content: center; }
  .flow-cta { padding: 16px 14px; }
  .flow-cta .btn { margin-left: 0; width: 100%; justify-content: center; }

  /* вход */
  .login-wrap { padding: 12px 0; }
}
