/* Тренажёр РК «МГТУ ИНФА». Стиль как у стартовой: лист с сеткой, тёмно-синие чернила, оранжевый — главное действие.

   Всегда светлая тема (решение владельца), в том числе в тёмном Telegram. */

:root {

  --bg: #f4f6fa;

  --card: #ffffff;

  --text: #0c1630;

  --muted: #5a6580;

  --line: rgba(12, 22, 48, .12);

  --line-2: rgba(12, 22, 48, .22);

  --grid: rgba(12, 22, 48, .05);

  --soft: rgba(12, 22, 48, .05);

  --accent: #ff8a1f;

  --accent-hi: #ff9d45;

  --accent-text: #0c1630;

  --accent-ink: #b34d00;

  --ok: #15803d;

  --ok-bg: #e6f4ea;

  --bad: #c62828;

  --bad-bg: #fdecec;

  --warn-bg: #fff3e4;

  --shadow: 0 1px 0 rgba(12, 22, 48, .04), 0 1px 3px rgba(12, 22, 48, .06), 0 18px 40px -26px rgba(12, 22, 48, .28);

  --radius: 18px;

  color-scheme: light;

}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {

  background-color: var(--bg); color: var(--text);

  font: 16px/1.55 "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;

  -webkit-font-smoothing: antialiased;

  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);

  background-size: 24px 24px; background-attachment: fixed;

}

a { color: var(--accent-ink); text-decoration: none; font-weight: 600; }

a:hover { text-decoration: underline; text-underline-offset: 3px; }



/* шапка */

.top {

  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px;

  padding: 10px max(16px, calc(50% - 380px)); min-height: 60px;

  background: color-mix(in srgb, var(--bg) 84%, transparent); backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);

  border-bottom: 1px solid var(--line);

}

.brand { font: 600 15px/1 "Unbounded", "Manrope", sans-serif; letter-spacing: -.01em; color: var(--text); display: flex; align-items: center; gap: 10px; white-space: nowrap; }

.brand:hover { text-decoration: none; }

.logo { display: block; width: 34px; height: 34px; border-radius: 50%; background: #07101b; box-shadow: 0 0 0 1px var(--line-2); }

.brand-home { color: var(--muted); font-size: 18px; padding: 4px 6px; border-radius: 8px; font-weight: 500; }

.brand-home:hover { color: var(--text); background: var(--soft); text-decoration: none; }

.who { margin-left: auto; color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }

.timer { margin-left: auto; font: 600 15px/1 "Unbounded", sans-serif; font-variant-numeric: tabular-nums; letter-spacing: .02em;

  padding: 8px 12px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); }

.timer.low { background: var(--bad-bg); color: var(--bad); border-color: transparent; }

.timer + .who { margin-left: 0; }

/* полоска времени под шапкой: --left от 1 до 0 (ставит app.js) */

.timebar { position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; background: transparent; pointer-events: none; }

.timebar i { display: block; height: 100%; width: 100%; transform-origin: left center; transform: scaleX(var(--left, 1));

  background: var(--accent); transition: transform 1s linear, background-color .3s ease; }

.timebar.low i { background: var(--bad); }

.timebar[hidden] { display: none; }



/* подсказка формата под полем ответа */

.fmt { grid-column: 1 / -1; min-height: 18px; margin: 0; font-size: 13px; font-weight: 600; color: var(--muted); }

.fmt.ok { color: var(--muted); }

.fmt.bad { color: var(--bad); }



/* подсказки ступенями в разборе */

.hints { margin-top: 14px; }

.hint-step { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line-2); }

.hint-step[hidden] { display: none; }

.hint-cap { margin: 0 0 6px; font-size: 13px; font-weight: 700; color: var(--accent-ink); }

.hint-actions { margin-top: 12px; gap: 14px; }

.link-btn { appearance: none; border: 0; background: none; padding: 4px 2px; font: inherit; font-size: 14px; font-weight: 600;

  color: var(--muted); cursor: pointer; border-bottom: 1.5px dashed var(--line-2); }

.link-btn:hover { color: var(--text); border-bottom-color: var(--text); }

@media (prefers-reduced-motion: no-preference) {

  .hint-step.pop { animation: hint-in .35s cubic-bezier(.2, .8, .2, 1); }

  .bar > i { transition: width .9s cubic-bezier(.2, .8, .2, 1); }

}

@keyframes hint-in { from { opacity: 0; transform: translateY(6px); } }



main { max-width: 760px; margin: 0 auto; padding: 20px 16px 48px; }

h1, h2 { font-family: "Unbounded", "Manrope", sans-serif; font-weight: 500; letter-spacing: -.02em; }

h1 { font-size: 26px; line-height: 1.2; margin: 12px 0 6px; }

h2 { font-size: 19px; margin: 32px 0 10px; }

.muted { color: var(--muted); }

.center { text-align: center; }

.small { font-size: 13px; }



/* карточки */

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin: 14px 0; box-shadow: var(--shadow); }

.rk-card > .muted:first-child { font-size: 14px; font-weight: 600; color: var(--accent-ink); }

.rk-card h3 { margin: 6px 0 4px; font-size: 19px; line-height: 1.3; letter-spacing: -.01em; }

.meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 16px; }

.chip { font-size: 13px; font-weight: 600; padding: 4px 10px; border-radius: 8px; background: var(--soft); color: var(--muted); }



/* кнопки */

.btn {

  appearance: none; border: 0; border-radius: 999px; min-height: 46px; padding: 0 22px; font: inherit; font-weight: 700;

  display: inline-flex; align-items: center; justify-content: center; gap: 6px;

  background: var(--accent); color: var(--accent-text); cursor: pointer;

  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .4), inset 0 -1px 0 rgba(150, 60, 0, .2), 0 8px 20px -10px rgba(255, 122, 20, .7);

  transition: background-color .18s ease, transform .12s ease, box-shadow .18s ease;

}

.btn:hover { background: var(--accent-hi); text-decoration: none; }

.btn:active { transform: scale(.97); }

.btn:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }

.btn:disabled { opacity: .45; cursor: default; transform: none; }

.btn.secondary { background: transparent; color: var(--text); box-shadow: inset 0 0 0 1.5px var(--line-2); }

.btn.secondary:hover { background: var(--soft); box-shadow: inset 0 0 0 1.5px var(--text); }

.btn.small { min-height: 36px; padding: 0 14px; font-size: 14px; }

.btn.block { width: 100%; }

.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.spacer { flex: 1; }



/* поля */

input[type=text], textarea {

  width: 100%; font: inherit; font-weight: 600; color: var(--text); background: var(--card);

  border: 1.5px solid var(--line-2); border-radius: 12px; padding: 11px 14px; min-height: 46px;

  transition: border-color .15s ease, box-shadow .15s ease;

}

input[type=text]::placeholder, textarea::placeholder { color: var(--muted); font-weight: 500; }

input[type=text]:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px rgba(255, 138, 31, .18); }



/* попытка */

.nav { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 10px; }

.nav button {

  width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--card);

  color: var(--muted); font: inherit; font-weight: 700; cursor: pointer; transition: border-color .15s ease, background-color .15s ease;

}

.nav button:hover { border-color: var(--line-2); color: var(--text); }

.nav button.filled { background: var(--soft); color: var(--text); border-color: var(--line-2); }

.nav button.current { border: 1.5px solid var(--text); color: var(--text); }

.statement { font-size: 16.5px; line-height: 1.65; }

.statement p { margin: 0 0 10px; }

.field { display: grid; grid-template-columns: minmax(70px, auto) 1fr auto; gap: 10px; align-items: center; margin-top: 14px; }

.field label { font-weight: 700; }

.unit { color: var(--muted); font-weight: 600; min-width: 40px; }

.choices { display: flex; gap: 8px; flex-wrap: wrap; }

.choices label { display: flex; gap: 8px; align-items: center; padding: 9px 14px; border: 1.5px solid var(--line-2); border-radius: 12px; cursor: pointer; font-weight: 500; }

.choices label:has(input:checked) { border-color: var(--accent); background: rgba(255, 138, 31, .1); }

.choices input { accent-color: var(--accent); }

.choices label { max-width: 100%; }

.choices label > span { min-width: 0; overflow-x: auto; overflow-y: hidden; padding: 4px 0; }

.choices:has(.katex) { flex-direction: column; align-items: flex-start; }

.hint { font-size: 13px; color: var(--muted); margin-top: 12px; }

code { font: 600 .92em "Manrope", sans-serif; background: var(--soft); padding: 1px 6px; border-radius: 6px; }



/* результат и разбор */

.score { font: 500 44px/1.1 "Unbounded", sans-serif; letter-spacing: -.02em; margin: 6px 0 10px; }

.res { position: relative; padding-left: 24px; }

.res::before { content: ""; position: absolute; left: 0; top: 18px; bottom: 18px; width: 4px; border-radius: 0 4px 4px 0; background: var(--line-2); }

.res.ok::before { background: var(--ok); }

.res.part::before { background: #e0a100; }

.res.bad::before { background: var(--bad); }

.res h3 { margin: 0 0 10px; font-size: 16.5px; line-height: 1.35; }

.ans { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 12px 0; font-size: 15px; padding: 10px 12px; border-radius: 12px; background: var(--soft); }

.ans .ok { color: var(--ok); }

.ans .bad { color: var(--bad); }

details { margin-top: 12px; }

summary { cursor: pointer; font-weight: 700; color: var(--accent-ink); }

.formula { overflow-x: auto; padding: 4px 0; }

.mistake { background: var(--warn-bg); border-radius: 12px; padding: 12px 14px; margin-top: 12px; font-size: 15px; }

.mistake b { color: var(--accent-ink); }

.bar { height: 8px; border-radius: 999px; background: var(--soft); overflow: hidden; }

.bar > i { display: block; height: 100%; border-radius: 999px; background: var(--accent); }

.topic { display: grid; grid-template-columns: 1fr 120px 48px; gap: 10px; align-items: center; font-size: 14px; margin: 8px 0; }

table.hist { width: 100%; border-collapse: collapse; font-size: 14px; }

table.hist td { padding: 9px 4px; border-top: 1px solid var(--line); }

table.hist tr:first-child td { border-top: 0; }

table.hist td:nth-child(3), table.hist td:nth-child(4) { white-space: nowrap; }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--text); color: var(--bg);

  padding: 12px 18px; border-radius: 12px; font-size: 14px; font-weight: 600; max-width: calc(100% - 32px); box-shadow: var(--shadow);

  pointer-events: none; /* не перекрывает кнопку «Сдать РК» под собой */ }

.katex-display { overflow-x: auto; overflow-y: hidden; padding: 2px 0; }

.figure { display: block; max-width: 100%; max-height: 340px; margin: 12px auto; background: #fff; border-radius: 12px; padding: 8px; border: 1px solid var(--line); }



/* предметы: переключатель и заголовки групп */

.subj { display: flex; gap: 6px; overflow-x: auto; margin: 4px 0 6px; padding-bottom: 4px; scrollbar-width: none; }

.subj::-webkit-scrollbar { display: none; }

.subj a { flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 999px;

  font-size: 14px; font-weight: 600; color: var(--text); background: var(--card); border: 1px solid var(--line); text-decoration: none; }

.subj a span { font-size: 12px; color: var(--muted); }

.subj a:hover { border-color: var(--line-2); text-decoration: none; }

.subj a.on { background: var(--text); color: #fff; border-color: var(--text); }

.subj a.on span { color: rgba(255,255,255,.7); }

.subj-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; margin: 26px 0 0; }

.card:has(> table.hist) { overflow-x: auto; }

.subj-head h2 { margin: 0; }

.subj-head a { font-size: 14px; white-space: nowrap; }

.rk-card h3 a { color: inherit; font-weight: inherit; }

.rk-card h3 a:hover { color: var(--accent-ink); text-decoration: none; }



/* страница одного РК */

.back-link { display: inline-block; margin: 4px 0 6px; font-size: 14px; color: var(--muted); }

.back-link:hover { color: var(--text); }

.rk-one h1 { margin: 6px 0 6px; }

.rk-one .btn { margin-top: 4px; }



/* имя в шапке и меню профиля */

.who { position: relative; overflow: visible; }

.who-btn { appearance: none; border: 1px solid var(--line); background: var(--card); color: var(--muted); font: 600 14px "Manrope", sans-serif;

  padding: 6px 12px; border-radius: 999px; cursor: pointer; max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.who-btn:hover { color: var(--text); border-color: var(--line-2); }

.who-menu { position: absolute; right: 0; top: calc(100% + 8px); z-index: 20; display: grid; min-width: 230px; padding: 6px;

  background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }

.who-menu button, .who-menu a { appearance: none; border: 0; background: none; text-align: left; padding: 10px 12px; border-radius: 10px;

  font: 600 14px "Manrope", sans-serif; color: var(--text); cursor: pointer; text-decoration: none; }

.who-menu button:hover, .who-menu a:hover { background: var(--soft); text-decoration: none; }

.who-menu .danger { color: var(--bad); }

.tg-login { min-height: 46px; margin: 8px 0 4px; }

.login-card .hint a { color: var(--accent-ink); }



/* вход */

.login-simple { max-width: 420px; margin: 12vh auto 0; }

.login-simple h1 { text-align: center; margin-bottom: 16px; }

.login-card { display: grid; gap: 10px; }



/* наследие старой стартовой тренажёра (разметка ещё может встречаться) */

.hero { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; align-items: center; margin: 12px 0 8px; }

.eyebrow { font-size: 14px; font-weight: 600; color: var(--accent-ink); }

.hero-title { font: 500 32px/1.15 "Unbounded", sans-serif; margin: 8px 0 12px; letter-spacing: -.02em; }

.lead { font-size: 17px; color: var(--muted); margin: 0 0 16px; }

.stats { display: flex; gap: 24px; flex-wrap: wrap; }

.stats div { display: flex; flex-direction: column; }

.stats b { font-size: 26px; }

.stats span { font-size: 13px; color: var(--muted); }

.h-card { margin: 0; font-size: 18px; }

.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

.step { margin: 0; }

.step .num { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; border: 1.5px solid var(--text); font-weight: 700; margin-right: 8px; }

.step p { margin: 8px 0 0; font-size: 14px; }

.rk-card.mini { display: grid; grid-template-columns: 44px 1fr; gap: 12px; align-items: start; }

.rk-ic { width: 44px; height: 44px; border-radius: 12px; background: var(--soft); display: grid; place-items: center; font-size: 22px; }

.rk-card.mini .meta { margin-bottom: 0; }

.soon { font-size: 14px; color: var(--muted); }

.faq details { margin: 8px 0; }

.faq p { margin: 8px 0 0; color: var(--muted); }

.foot { text-align: center; padding: 24px 0 8px; }



@media (max-width: 640px) {

  .hero { grid-template-columns: 1fr; }

  .hero-title { font-size: 26px; }

  .steps { grid-template-columns: 1fr; }

  h1 { font-size: 22px; }

  .card { padding: 16px; }

}

@media (max-width: 480px) {

  .field { grid-template-columns: 1fr auto; }

  .field label { grid-column: 1 / -1; }

  .topic { grid-template-columns: 1fr 80px 40px; }

  .brand span.t { display: none; }

}

@media (prefers-reduced-motion: reduce) { .btn, .nav button, input[type=text] { transition: none; } }



/* Long physics expressions stay readable inside a narrow task card. */

.ans { grid-template-columns: minmax(0, max-content) minmax(0, 1fr); }

.ans > span { min-width: 0; overflow-wrap: anywhere; }

.who { min-width: 0; }

.who-btn { max-width: 100%; }

.rk-card.rk-soon{background:#eef0f4;border-color:rgba(12,22,48,.12);box-shadow:none;color:#5a6580}.rk-soon h1,.rk-soon h3{color:#5a6580}.rk-soon .btn:disabled{background:#e2e6ed;color:#5a6580;opacity:1;box-shadow:none;cursor:default}



/* без входа: заметка о входе и одна задача РК (только «верно / неверно») */
.guest-note { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; }
.guest-note p { flex: 1 1 280px; margin: 0; }
.dm-mark { font-weight: 800; margin-left: 4px; }
.dm-mark.ok { color: var(--ok); }
.dm-mark.bad { color: var(--bad); }
.demo-res { margin: 12px 0 0; padding: 10px 14px; border-radius: 12px; }
.demo-res.ok { background: var(--ok-bg); }
.demo-res.bad { background: var(--bad-bg); }


.rk-card.rk-soon>.muted:first-child{color:#5a6580}

/* шпаргалка формул */
.fsheet h2 { margin: 0 0 8px; font-size: 18px; }
.fsheet .formula { overflow-x: auto; padding: 4px 0; }
.fsheet-link { margin: 4px 0 10px; font-weight: 600; }
.fsheet-link a { color: var(--accent-ink, #b34d00); }

/* «Прислать задачу» */
.send-f { display: block; margin: 12px 0; }
.send-f label { display: block; font-weight: 600; margin-bottom: 6px; }
.send-f input, .send-f select, .send-f textarea { width: 100%; font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
.send-ok { display: flex; gap: 8px; align-items: center; margin: 10px 0; font-weight: 600; }
.fsheet-link { display: flex; flex-wrap: wrap; gap: 6px 22px; }
.send-f[hidden] { display: none; }
/* скрытый MathML у KaTeX позиционирован абсолютно: без этого длинная формула растягивает страницу на телефоне */
.katex-display, .formula { position: relative; }
.katex { position: relative; }
.katex .katex-mathml { width: 1px; height: 1px; overflow: hidden; }
/* длинная формула внутри текста не переносится — прокрутка внутри условия, а не всей страницы */
.statement { overflow-x: auto; overflow-y: hidden; padding-bottom: 2px; }

.theory-link { display: inline-block; margin: 2px 0 12px; font-weight: 600; color: var(--accent-ink); }
.rk-card .theory-link { display: block; }
.theory h2 { margin: 18px 0 8px; font-size: 21px; line-height: 1.3; }
.theory h3 { margin: 16px 0 6px; font-size: 18px; line-height: 1.3; }
.theory h4 { margin: 14px 0 6px; font-size: 16.5px; }
.theory > :first-child { margin-top: 0; }
.theory ul { margin: 0 0 10px; padding-left: 22px; }
.theory li { margin-bottom: 4px; }
