/* ============================================================
   Плакат — визуальный язык портала.
   Жёлтое поле, чёрные линейки, один тяжёлый гротеск. Три цвета:
   жёлтый, чёрный и белый; синий — только для ссылок, красный —
   только для ошибок и просрочки. Сложность и статусы кодируются
   плотностью заливки, а не цветом.
   Тёмная тема — инверсия: чёрное поле, жёлтые линейки.
   ============================================================ */

@font-face { font-family: "Unbounded"; font-weight: 500 800; font-display: swap;
  src: local("Unbounded"), url("fonts/Unbounded-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Unbounded"; font-weight: 500 800; font-display: swap;
  src: local("Unbounded"), url("fonts/Unbounded-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Golos Text"; font-weight: 400 600; font-display: swap;
  src: local("Golos Text"), url("fonts/GolosText-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Golos Text"; font-weight: 400 600; font-display: swap;
  src: local("Golos Text"), url("fonts/GolosText-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "JetBrains Mono"; font-weight: 400; font-display: swap;
  src: local("JetBrains Mono"), url("fonts/JetBrainsMono-Regular.woff2") format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-weight: 700; font-display: swap;
  src: local("JetBrains Mono Bold"), url("fonts/JetBrainsMono-Bold.woff2") format("woff2"); }

:root {
  color-scheme: light;
  --bg: #f4c430;
  --panel: #f4c430;
  --panel-2: #f8d24f;

  --ink: #111111;
  --text: #111111;
  --text-2: #3b3312;
  --muted: #6e6030;
  --line: #111111;
  --line-soft: rgba(17, 17, 17, .28);

  --inv-bg: #111111;     /* инвертированный блок */
  --inv-text: #f4c430;

  --accent: #1d4ed8;     /* только ссылки */
  --err: #c1121f;        /* только ошибки, просрочка, live */
  --err-text: #ffffff;
  /* Подсветка кода: словарь такой же скупой, как и весь портал —
     структура начертанием, литералы цветом ссылки, комментарии тише. */
  --code-key: #111111;
  --code-str: #1d4ed8;
  --code-com: #6e6030;
  --code-num: #7a4b00;

  --rule: 3px;
  --display: "Unbounded", "Arial Black", Impact, sans-serif;
  --sans: "Golos Text", -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: "JetBrains Mono", Menlo, Consolas, monospace;
  --rail: 88px;
}


/* ============================================================
   Тёмная тема. По умолчанию портал светлый — жёлтое поле; тёмная включается
   кнопкой (data-theme="dark") или выбором «как в системе» (data-theme="auto").
   Два одинаковых набора правил, менять их нужно вместе.
   ============================================================ */
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    color-scheme: dark;
    --bg: #0f0e0a;
    --panel: #0f0e0a;
    --panel-2: #1a1810;
    --ink: #f4c430;
    --text: #f4e9c2;
    --text-2: #dcc985;
    --muted: #a8975a;
    --line: #f4c430;
    --line-soft: rgba(244, 196, 48, .3);
    --inv-bg: #f4c430;
    --inv-text: #111111;
    --accent: #9dbcff;
    --err: #ff5a5a;
    --err-text: #111111;
    --code-key: #f4c430;
    --code-str: #9dbcff;
    --code-com: #a8975a;
    --code-num: #e8b96a;
  }
  :root[data-theme="auto"] .only-light { display: none; }
  :root[data-theme="auto"] .only-dark { display: block; }
  :root[data-theme="auto"] input[type=text], :root[data-theme="auto"] input[type=email], :root[data-theme="auto"] input[type=file], :root[data-theme="auto"] input[type=number], :root[data-theme="auto"] input[type=datetime-local], :root[data-theme="auto"] select, :root[data-theme="auto"] textarea { background: #1a1810; color: var(--text); }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f0e0a;
  --panel: #0f0e0a;
  --panel-2: #1a1810;
  --ink: #f4c430;
  --text: #f4e9c2;
  --text-2: #dcc985;
  --muted: #a8975a;
  --line: #f4c430;
  --line-soft: rgba(244, 196, 48, .3);
  --inv-bg: #f4c430;
  --inv-text: #111111;
  --accent: #9dbcff;
  --err: #ff5a5a;
  --err-text: #111111;
  --code-key: #f4c430;
  --code-str: #9dbcff;
  --code-com: #a8975a;
  --code-num: #e8b96a;
}
:root[data-theme="dark"] .only-light { display: none; }
:root[data-theme="dark"] .only-dark { display: block; }
:root[data-theme="dark"] input[type=text], :root[data-theme="dark"] input[type=email], :root[data-theme="dark"] input[type=file], :root[data-theme="dark"] input[type=number], :root[data-theme="dark"] input[type=datetime-local], :root[data-theme="dark"] select, :root[data-theme="dark"] textarea { background: #1a1810; color: var(--text); }

*, *::before, *::after { box-sizing: border-box; }

/* Правило класса вроде .inline-form { display: flex } перебивает браузерное
   [hidden], и скрытый блок остаётся видимым. */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--sans); font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
/* Ссылки в тексте: подчёркивание вместо цвета — плакат остаётся трёхцветным.
   На ховере — инверсия, как маркером по бумаге. */
main a:not([class]) { color: var(--text); text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }
main a:not([class]):hover { background: var(--ink); color: var(--bg); text-decoration: none; }
::selection { background: var(--ink); color: var(--bg); }
:focus-visible { outline: var(--rule) solid var(--ink); outline-offset: 2px; }

.mono, .code-box { font-family: var(--mono); }
.num, .points, .value, .rank, .countdown, .bar-value { font-variant-numeric: tabular-nums; }

/* ---------- иконки ---------- */
.icon { width: 1.1em; height: 1.1em; flex: none; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: square; stroke-linejoin: miter; vertical-align: -.18em; }
.icon.lg { width: 1.5em; height: 1.5em; }
.icon.xl { width: 2em; height: 2em; stroke-width: 1.8; }

/* ---------- метки капсом (общий приём) ---------- */
.lbl, h2, th, label, .badge, .stat .label, .eyebrow, .feed-day, .ticker-label, .brand-text, .nav a, .tabbar a, .legend, .progress-line, .hm-legend, .heatmap-months, .heatmap-weekdays {
  font-family: var(--sans); font-weight: 600; text-transform: uppercase; letter-spacing: .1em;
}

/* ============================================================
   Рейка — чёрный блок плаката
   ============================================================ */
body.with-rail { padding-left: var(--rail); }
.rail {
  position: fixed; inset: 0 auto 0 0; width: var(--rail);
  background: var(--inv-bg); color: var(--inv-text);
  display: flex; flex-direction: column; z-index: 30;
}
.rail .brand { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 3px 12px; color: var(--inv-text); border-bottom: var(--rule) solid var(--inv-text); }
.rail .brand .icon { width: 30px; height: 30px; }
.rail .brand:hover { text-decoration: none; }
.brand-text { font-size: 9px; text-align: center; line-height: 1.3; }
.brand-logo { max-width: 82px; height: auto; display: block; }
/* Знак как маска: форма из SVG, цвет — текущий цвет текста. */
.brand-mark {
  display: block; width: 84px; height: 60px;
  background: currentColor;
  -webkit-mask: var(--mark) center / contain no-repeat;
  mask: var(--mark) center / contain no-repeat;
}
.brand-mark.small { width: 56px; height: 40px; }
.brand-mark.auth-mark { width: 182px; height: 130px; color: var(--ink); }

/* Переключатель темы: показываем иконку текущего состояния. */
[data-theme-toggle] .icon { display: none; }
[data-theme-toggle][data-theme-state="auto"] .t-auto,
[data-theme-toggle][data-theme-state="light"] .t-light,
[data-theme-toggle][data-theme-state="dark"] .t-dark { display: block; }
.only-dark { display: none; }

.rail .nav { display: flex; flex-direction: column; }
.nav a, .tabbar a {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 13px 4px 11px; color: var(--inv-text); font-size: 9.5px; letter-spacing: .06em;
  border-bottom: 1px solid var(--line-soft); opacity: .78;
}
.nav a .icon, .tabbar a .icon { width: 20px; height: 20px; }
.nav a:hover, .tabbar a:hover { opacity: 1; text-decoration: none; }
.nav a.active, .tabbar a.active { opacity: 1; background: var(--inv-text); color: var(--inv-bg); }
.rail-foot { margin-top: auto; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 14px 0 16px; border-top: var(--rule) solid var(--inv-text); }
.rail .whoami .avatar { width: 36px; height: 36px; }
.rail-btn { background: transparent; border: none; box-shadow: none; color: var(--inv-text); padding: 6px; opacity: .8; }
.rail-btn:hover { opacity: 1; background: transparent; transform: none; }
.tabbar { display: none; }
.mobile-bar { display: none; }

/* ---------- строка события — инвертированная полоса ---------- */
.ticker {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  min-height: 48px; padding: 8px 28px;
  background: var(--inv-bg); color: var(--inv-text);
}
.ticker:hover { text-decoration: none; }
.ticker-label { font-size: 10px; opacity: .8; }
.ticker-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.ticker .countdown { margin-left: auto; background: transparent; color: var(--inv-text); border: 2px solid var(--inv-text); }
.ticker .countdown[data-state="live"] { background: var(--err); color: var(--err-text); border-color: var(--err); }
.ticker-go { display: inline-flex; }

main { max-width: 1180px; margin: 0 auto; padding: 34px 32px 90px; }

/* ============================================================
   Типографика
   ============================================================ */
h1 { font-family: var(--display); font-weight: 800; font-size: 44px; line-height: .95; letter-spacing: -.02em; text-transform: uppercase; margin: 0 0 10px; }
h2 { font-size: 11px; color: var(--text); margin: 38px 0 12px; display: flex; align-items: center; gap: 12px; }
h2::before { content: ""; width: 28px; height: var(--rule); background: var(--ink); flex: none; }
h2::after { content: ""; flex: 1; height: 1px; background: var(--line-soft); }
h2 .icon { display: none; }
h3 { font-family: var(--display); font-weight: 800; font-size: 16px; letter-spacing: -.01em; margin: 0 0 10px; line-height: 1.2; }
.eyebrow { font-size: 10px; color: var(--text); margin: 0 0 8px; display: flex; align-items: center; gap: 8px; }
.eyebrow::before { content: "//"; opacity: .5; }
p.sub { color: var(--text-2); margin: 0 0 24px; max-width: 64ch; font-size: 15px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 4px; }

/* ============================================================
   Карточки — линейки, без заливки
   ============================================================ */
.card { background: var(--panel); border: var(--rule) solid var(--ink); padding: 20px 22px; margin-bottom: 16px; }
.card.flat { border-width: 1px; border-color: var(--line-soft); }
a.card { display: block; color: inherit; transition: background .12s, color .12s; }
a.card:hover { background: var(--inv-bg); color: var(--inv-text); text-decoration: none; }
a.card:hover .muted, a.card:hover h3 .icon { color: inherit; opacity: .85; }

/* ============================================================
   Инвертированные блоки: карточка под курсором, шаг онбординга,
   закреплённое объявление.

   Меняем сами переменные, а не каждый вложенный элемент: бейдж, полоса
   прогресса и линейки красятся «чернилами», и на чёрном фоне они просто
   исчезали. Правка по месту чинила бы то, что уже есть, и ломалась бы
   на каждой новой детали внутри.
   ============================================================ */
a.card:hover, .step:hover, .announce.pinned, .podium-card.p1 {
  --ink: var(--inv-text);
  --text: var(--inv-text);
  --text-2: var(--inv-text);
  --muted: var(--inv-text);
  --line: var(--inv-text);
  --line-soft: color-mix(in srgb, var(--inv-text) 35%, transparent);
  --panel: var(--inv-bg);
  --panel-2: var(--inv-bg);
}
/* Заливка бейджа внутри такого блока стала бы фоном в фон — оставляем контур. */
a.card:hover .badge, .step:hover .badge,
.announce.pinned .badge, .podium-card.p1 .badge {
  background: transparent; color: var(--inv-text); border-color: var(--inv-text);
}
/* Красный несёт смысл сам по себе — его не трогаем. */
a.card:hover .badge.bad, .step:hover .badge.bad,
.announce.pinned .badge.bad, .podium-card.p1 .badge.bad {
  background: var(--err); color: var(--err-text); border-color: var(--err);
}
.card.stretch { display: flex; flex-direction: column; }
.card.stretch .push-bottom { margin-top: auto; padding-top: 12px; }
.callout { border-left-width: 14px; }
.callout.warn { border-left-color: var(--err); }

.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); counter-reset: sec; }
.grid.three > a.card h3::before { counter-increment: sec; content: counter(sec, decimal-leading-zero); font-size: 12px; opacity: .55; margin-right: 6px; }
.grid.three > a.card h3 .icon { display: none; }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0; border: var(--rule) solid var(--ink); }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.between { justify-content: space-between; }

/* ---------- плитки статистики — ячейки одной таблицы ---------- */
.stat { padding: 18px 20px 20px; border-right: var(--rule) solid var(--ink); }
.stat:last-child { border-right: none; }
.stat .icon { display: none; }
.stat .value { font-family: var(--display); font-weight: 800; font-size: 52px; line-height: .9; letter-spacing: -.03em; }
.stat .label { font-size: 10px; color: var(--text-2); margin-top: 10px; }

/* ---------- аватарки ---------- */
.avatar { width: 32px; height: 32px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-family: var(--display); font-size: 11px; font-weight: 800; flex: none; position: relative; overflow: hidden; background: var(--inv-bg); color: var(--inv-text); }
/* Картинка Gravatar лежит поверх инициалов: не загрузилась — остаются они. */
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 24px; height: 24px; font-size: 9px; }
.avatar.lg { width: 60px; height: 60px; font-size: 20px; }
.rail .avatar { background: var(--inv-text); color: var(--inv-bg); }

/* ============================================================
   Таблицы
   ============================================================ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line-soft); font-size: 14px; }
th { font-size: 10px; color: var(--text); border-bottom: var(--rule) solid var(--ink); }
tbody tr:hover { background: var(--panel-2); }
tbody tr:last-child td { border-bottom: none; }
.card.table-wrap { padding: 0 6px; }

/* ============================================================
   Формы
   ============================================================ */
input[type=text], input[type=email], input[type=number], input[type=file], input[type=datetime-local], select, textarea {
  width: 100%; padding: 10px 12px;
  border: var(--rule) solid var(--ink); background: #fff; color: #111;
  font: inherit; border-radius: 0;
}
input:focus, select:focus, textarea:focus { outline: none; box-shadow: 4px 4px 0 var(--ink); }
input::placeholder, textarea::placeholder { color: #9a8f6a; }
textarea { min-height: 130px; resize: vertical; font-family: var(--mono); font-size: 13px; line-height: 1.6; }
label { display: block; font-size: 10px; color: var(--text); margin-bottom: 6px; }
label.check { display: inline-flex; align-items: center; gap: 8px; text-transform: none; letter-spacing: 0; font-weight: 400; font-size: 14px; cursor: pointer; }
label.check input { width: auto; margin: 0; accent-color: var(--ink); }
.field { margin-bottom: 14px; }
.inline-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { margin-bottom: 0; }

/* ============================================================
   Кнопки — чёрный блок / контур
   ============================================================ */
button, .btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px; border: var(--rule) solid var(--ink);
  background: var(--inv-bg); color: var(--inv-text);
  font: inherit; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; font-size: 12px;
  cursor: pointer; white-space: nowrap; border-radius: 0;
  transition: transform .08s, box-shadow .08s;
}
button:hover, .btn:hover { color: var(--inv-text); text-decoration: none; transform: translate(-2px, -2px); box-shadow: 4px 4px 0 var(--ink); }
button:active, .btn:active { transform: none; box-shadow: none; }
button.ghost, .btn.ghost { background: transparent; color: var(--text); }
button.ghost:hover, .btn.ghost:hover { color: var(--text); }
button.danger, .btn.danger { background: transparent; color: var(--text); border-color: var(--line-soft); }
button.danger:hover, .btn.danger:hover { background: var(--err); color: var(--err-text); border-color: var(--err); transform: none; box-shadow: none; }
button.small, .btn.small { padding: 6px 11px; font-size: 10.5px; }

/* ============================================================
   Бейджи — плотность заливки вместо цвета
   ============================================================ */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; font-size: 10px; border: 1.5px solid var(--ink); color: var(--text); white-space: nowrap; line-height: 1.5; }
.badge .icon { width: 1em; height: 1em; }
.badge.easy   { border-width: 1.5px; }
.badge.medium { border-width: 3px; padding: 1.5px 7.5px; }
.badge.hard, .badge.ok, .badge.info { background: var(--inv-bg); color: var(--inv-text); border-color: var(--inv-bg); }
.badge.warn   { border-width: 3px; padding: 1.5px 7.5px; }
.badge.bad    { background: var(--err); color: var(--err-text); border-color: var(--err); }
.badge.hot    { background: var(--inv-bg); color: var(--inv-text); }
a.badge:hover { text-decoration: none; opacity: .85; }
.tag { display: inline-block; padding: 3px 9px; font-size: 12px; margin: 0 6px 6px 0; border: 1.5px solid var(--ink); }

/* ============================================================
   Флеши
   ============================================================ */
.flash { display: flex; align-items: flex-start; gap: 10px; padding: 12px 16px; margin-bottom: 18px; font-weight: 600; border: var(--rule) solid var(--ink); }
.flash.ok { background: var(--inv-bg); color: var(--inv-text); }
.flash.err { background: var(--err); color: var(--err-text); border-color: var(--err); }

/* ============================================================
   Прогресс
   ============================================================ */
.bar { height: 14px; border: 2px solid var(--ink); background: transparent; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--ink); transition: width .3s; }
.progress-line { display: flex; justify-content: space-between; font-size: 10px; margin-top: 8px; color: var(--text-2); }
.progress-line b { color: var(--text); }

/* ============================================================
   Матрица — вердикты плотностью
   ============================================================ */
.matrix td, .matrix th { text-align: center; padding: 6px 4px; }
.matrix td:first-child, .matrix th:first-child { text-align: left; position: sticky; left: 0; background: var(--panel); min-width: 190px; }
.matrix th a { color: var(--text); }
.cell { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border: 2px solid var(--ink); font-weight: 800; }
.cell .icon { width: 14px; height: 14px; stroke-width: 3.2; }
.cell.solved_in_time { background: var(--inv-bg); color: var(--inv-text); }
.cell.solved_late    { background: transparent; color: var(--text); }
.cell.solved_before  { border-style: dashed; color: var(--muted); }
.cell.not_solved     { border-color: var(--line-soft); border-style: dotted; }
/* Решение отклонено: зачёт снят, и это должно быть видно без наведения. */
.cell.rejected { background: transparent; border-color: var(--err); color: var(--err); }
.cell a { color: inherit; text-decoration: none; }
.legend { display: flex; gap: 18px; flex-wrap: wrap; font-size: 10px; margin-top: 12px; }
.legend span.item { display: inline-flex; align-items: center; gap: 8px; }

/* ============================================================
   Лента
   ============================================================ */
.feed { display: flex; flex-direction: column; }
.feed-day { font-size: 10px; padding: 18px 0 8px; display: flex; align-items: center; gap: 12px; }
.feed-day::after { content: ""; flex: 1; height: 1px; background: var(--line-soft); }
.feed-day:first-child { padding-top: 0; }
.feed-item { display: flex; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.feed-item:last-child { border-bottom: none; }
.feed-body { min-width: 0; flex: 1; }
.feed-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.feed-head .who { font-weight: 600; color: var(--text); }
.feed-head .when { color: var(--muted); font-size: 12px; margin-left: auto; white-space: nowrap; }
.feed-what { display: flex; align-items: baseline; gap: 10px; flex-wrap: nowrap; margin-top: 3px; }
.feed-what .tick { flex: none; font-family: var(--display); font-size: 10px; font-weight: 800; padding: 2px 6px; background: var(--inv-bg); color: var(--inv-text); line-height: 1.5; }
.feed-what .tick .icon { display: none; }
.feed-what .tick::before { content: "AC"; }
.feed-what .title-wrap { min-width: 0; }
.feed-what .title { font-weight: 600; color: var(--text); }
.feed-meta { margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; }

/* ============================================================
   Лидерборд
   ============================================================ */
.rank { font-family: var(--display); font-weight: 800; font-size: 18px; white-space: nowrap; width: 1%; text-align: center; }
.rank .icon { display: none; }

/* --- табло ------------------------------------------------------------- */
/* Подиум: первое место крупнее и выворочено, соседние — обычными карточками. */
.podium { display: grid; grid-template-columns: 1fr 1.2fr 1fr; gap: 10px; align-items: end; margin-bottom: 14px; }
.podium-card { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 10px; border: 2px solid var(--ink); text-decoration: none; color: inherit; }
.podium-card.p1 { order: 2; padding-top: 22px; background: var(--inv-bg); color: var(--inv-text); }
.podium-card.p2 { order: 1; } .podium-card.p3 { order: 3; }
.podium-card.me { outline: 3px solid var(--ink); outline-offset: 2px; }
.podium-card.p1.me { outline-color: var(--inv-bg); }
.podium-place { font-family: var(--display); font-weight: 800; font-size: 12px; letter-spacing: .12em; }
.podium-name { font-weight: 700; font-size: 13px; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.podium-score { font-family: var(--display); font-weight: 800; font-size: 26px; line-height: 1; }
.podium-score .of { font-size: 14px; opacity: .6; }
.stat .value .of { font-size: 15px; opacity: .55; }
.podium-card.p1 .avatar { background: var(--inv-text); color: var(--inv-bg); }

/* Движение за неделю. Цветом не выделяем — плотность и стрелка и так читаются. */
.move { display: inline-block; font-family: var(--mono); font-size: 10px; font-weight: 700; margin-left: 2px; vertical-align: 2px; }
.move.down { opacity: .5; }

/* Клетка счёта: полоса доли и дробь рядом. */
.score-cell { display: flex; align-items: center; gap: 10px; }
.score-cell .bar { flex: 1; min-width: 60px; max-width: 220px; }
.score-cell .score-num { white-space: nowrap; }
.score-cell b { font-family: var(--display); font-size: 16px; }

@media (max-width: 640px) {
  .podium { grid-template-columns: 1fr; }
  .podium-card.p1, .podium-card.p2, .podium-card.p3 { order: 0; flex-direction: row; justify-content: flex-start; }
  .score-cell .bar { display: none; }
}
tr.me { outline: var(--rule) solid var(--ink); outline-offset: -3px; }
.points { font-family: var(--display); font-weight: 800; font-size: 18px; }

/* ============================================================
   Карта активности
   ============================================================ */
.heatmap-scroll { overflow-x: auto; padding-bottom: 4px; }
.heatmap-body { display: flex; gap: 8px; }
.heatmap { display: flex; gap: 3px; }
.hm-col { display: grid; grid-template-rows: repeat(7, 12px); gap: 3px; }
.heatmap i, .hm-legend i { width: 12px; height: 12px; display: block; border: 1px solid var(--line-soft); background: transparent; }
.heatmap i.l1, .hm-legend i.l1 { background: color-mix(in srgb, var(--ink) 25%, transparent); border-color: transparent; }
.heatmap i.l2, .hm-legend i.l2 { background: color-mix(in srgb, var(--ink) 50%, transparent); border-color: transparent; }
.heatmap i.l3, .hm-legend i.l3 { background: color-mix(in srgb, var(--ink) 75%, transparent); border-color: transparent; }
.heatmap i.l4, .hm-legend i.l4 { background: var(--ink); border-color: transparent; }
.heatmap i.future { border-color: transparent; }
.heatmap-weekdays { display: grid; grid-template-rows: repeat(7, 12px); gap: 3px; font-size: 8px; line-height: 12px; text-align: right; padding-right: 2px; letter-spacing: 0; }
.heatmap-months { display: flex; gap: 3px; height: 16px; font-size: 9px; margin-left: 26px; letter-spacing: .04em; }
.hm-slot { width: 12px; flex: none; white-space: nowrap; }
.hm-legend { display: inline-flex; align-items: center; gap: 4px; font-size: 9px; }
.hm-legend i { width: 11px; height: 11px; }

/* ---------- полосы ---------- */
.bar-row { display: grid; grid-template-columns: minmax(72px, 30%) 1fr auto; align-items: center; gap: 12px; padding: 5px 0; font-size: 13px; }
.bar-label { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 12px; border: 2px solid var(--ink); overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--ink); min-width: 2px; }
.bar-fill.easy { opacity: .35; } .bar-fill.medium { opacity: .65; } .bar-fill.hard { opacity: 1; }
.bar-value { min-width: 2.2em; text-align: right; font-weight: 600; font-size: 12px; }

/* ---------- профиль ---------- */
.rename-toggle {
  background: transparent; border: none; box-shadow: none; padding: 2px 6px;
  color: var(--muted); vertical-align: middle;
}
.rename-toggle:hover { background: transparent; color: var(--text); transform: none; box-shadow: none; }


.profile-head { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 24px; }
.profile-sync { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.assignment-line { padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.assignment-line:last-child { border-bottom: none; padding-bottom: 0; }
.assignment-line .bar { margin-top: 8px; }

/* ============================================================
   Объявления и отсчёт
   ============================================================ */
.announce { border: var(--rule) solid var(--ink); padding: 20px 22px; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; background: var(--panel); }
.announce.pinned { background: var(--inv-bg); color: var(--inv-text); }
.announce.pinned .muted, .announce.pinned .announce-body { color: inherit; opacity: .85; }
.announce.pinned .badge { border-color: var(--inv-text); color: var(--inv-text); background: transparent; }
.announce.pinned .btn { background: var(--inv-text); color: var(--inv-bg); border-color: var(--inv-text); }
.announce.pinned .btn:hover { box-shadow: 4px 4px 0 var(--inv-text); color: var(--inv-bg); }
.announce.pinned .countdown { background: var(--inv-text); color: var(--inv-bg); border-color: var(--inv-text); }
.announce-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; width: 100%; flex-wrap: wrap; }
.announce-head h3 { margin: 0; font-size: 20px; }
.announce .pin { display: none; }
.announce-meta { gap: 8px; margin: 0; }
.announce-body { margin: 0; color: var(--text-2); white-space: pre-line; }

.countdown { font-family: var(--display); font-weight: 800; font-size: 14px; letter-spacing: .01em; padding: 6px 12px; white-space: nowrap; background: var(--inv-bg); color: var(--inv-text); border: 2px solid var(--inv-bg); }
.countdown[data-state="live"] { background: var(--err); color: var(--err-text); border-color: var(--err); display: inline-flex; align-items: center; gap: 8px; }
.countdown[data-state="live"]::before { content: ""; width: 8px; height: 8px; background: currentColor; animation: pulse 1.2s ease-in-out infinite; }
.countdown[data-state="past"] { opacity: .55; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .countdown[data-state="live"]::before { animation: none; } }

/* ---------- шаги первого запуска ---------- */
.steps { display: grid; gap: 0; counter-reset: step; border: var(--rule) solid var(--ink); }
.step { display: flex; align-items: center; gap: 16px; padding: 16px 18px; border-bottom: var(--rule) solid var(--ink); color: inherit; }
.step:last-child { border-bottom: none; }
.step:hover { background: var(--inv-bg); color: var(--inv-text); text-decoration: none; }
.step:hover .step-hint { color: inherit; opacity: .8; }
.step .num { counter-increment: step; width: 40px; height: 40px; flex: none; display: inline-flex; align-items: center; justify-content: center; background: var(--inv-bg); color: var(--inv-text); font-family: var(--display); font-weight: 800; font-size: 14px; }
.step:hover .num { background: var(--inv-text); color: var(--inv-bg); }
.step .num::before { content: counter(step, decimal-leading-zero); }
.step.done .num::before { content: "✓"; }
.step.done .step-title { text-decoration: line-through; opacity: .6; }
.step-title { font-family: var(--display); font-weight: 800; font-size: 15px; }
.step-hint { font-size: 13px; color: var(--muted); }

details.formula { margin-top: 6px; }
details.formula summary { cursor: pointer; color: var(--text); text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; font-size: 13px; list-style: none; font-weight: 600; }
details.formula summary::-webkit-details-marker { display: none; }
details.formula summary::before { content: "▸ "; }
details.formula[open] summary::before { content: "▾ "; }
details.formula ul { margin: 8px 0 0; padding-left: 20px; color: var(--text-2); font-size: 13px; }

/* ---------- прочее ---------- */
.code-box { font-size: 16px; font-weight: 700; letter-spacing: .06em; background: var(--inv-bg); color: var(--inv-text); padding: 14px; word-break: break-all; user-select: all; text-align: center; }
.empty { color: var(--text-2); padding: 34px 20px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; font-size: 14px; border: var(--rule) dashed var(--line-soft); }
.empty .icon { opacity: .5; }
.card > .empty { margin: -8px; }
.auth-shell { max-width: 520px; margin: 8vh auto 0; }
.auth-logo { width: 72px; height: 72px; display: flex; align-items: center; justify-content: center; background: var(--inv-bg); color: var(--inv-text); margin-bottom: 22px; }
.auth-logo.bare { width: auto; height: auto; background: none; }
.auth-logo.bare img { max-height: 96px; max-width: 340px; width: auto; height: auto; }
.divider { height: 1px; background: var(--line-soft); margin: 16px 0; border: none; }

/* ============================================================
   Адаптив
   ============================================================ */
@media (max-width: 900px) { .col-extra { display: none; } }
@media (max-width: 760px) {
  body.with-rail { padding-left: 0; padding-bottom: 70px; }
  .rail { display: none; }
  .mobile-bar {
    display: flex; align-items: center; gap: 12px;
    padding: 4px 10px 4px 14px; background: var(--inv-bg); color: var(--inv-text);
  }
  .mobile-bar .rail-btn { margin-left: auto; color: var(--inv-text); }
  .mobile-brand {
    display: flex; align-items: center; gap: 12px; flex: 0 1 auto; min-width: 0;
    padding: 4px 0; color: var(--inv-text);
    font-family: var(--sans); font-weight: 600; text-transform: uppercase; letter-spacing: .1em; font-size: 11px;
  }
  .mobile-brand .icon { width: 28px; height: 28px; }
  .mobile-brand:hover { text-decoration: none; }
  .tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; background: var(--inv-bg); padding: 0 0 env(safe-area-inset-bottom); border-top: var(--rule) solid var(--inv-text); }
  .tabbar a { flex: 1; min-width: 0; padding: 9px 2px 7px; border-bottom: none; border-right: 1px solid var(--line-soft); font-size: 8px; letter-spacing: .04em; }
  .tabbar a:last-child { border-right: none; }
  .tabbar a span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .ticker { padding: 8px 14px; gap: 10px; }
  .ticker-label { display: none; }
  .ticker .countdown { font-size: 11px; padding: 4px 8px; }
  main { padding: 20px 16px 40px; }
  h1 { font-size: 30px; }
  h2 { margin-top: 28px; }
  .grid.two, .grid.three { grid-template-columns: 1fr; }
  .grid.stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat { border-right: none; border-bottom: var(--rule) solid var(--ink); }
  .stat:nth-child(odd) { border-right: var(--rule) solid var(--ink); }
  .stat .value { font-size: 40px; }
  .profile-sync { align-items: flex-start; width: 100%; }
}

/* Карточка материала: кнопка скачивания прижата вниз, карточки в ряду равны. */
.material { display: flex; flex-direction: column; }
.material .row:last-child { margin-top: auto; }
input[type=file] { padding: 7px 9px; font-family: var(--mono); font-size: 12px; }
input[type=file]::file-selector-button { font: inherit; margin-right: 10px; padding: 4px 10px; border: 2px solid var(--ink); background: var(--inv-bg); color: var(--inv-text); cursor: pointer; }

/* --- показ ноутбука ----------------------------------------------------- */
.notebook { display: flex; flex-direction: column; gap: 14px; margin-bottom: 18px; }
.nb-md { border-left: 3px solid var(--ink); padding: 2px 0 2px 14px; }
.nb-md > :first-child { margin-top: 0; }
.nb-md > :last-child { margin-bottom: 0; }
.nb-md h1, .nb-md h2, .nb-md h3 { font-family: var(--display); margin: 16px 0 8px; }
.nb-md h1 { font-size: 22px; } .nb-md h2 { font-size: 18px; } .nb-md h3 { font-size: 15px; }
.nb-md code { font-family: var(--mono); font-size: 12px; background: var(--inv-bg); color: var(--inv-text); padding: 1px 4px; }
.nb-md pre code { background: none; color: inherit; padding: 0; }
.nb-md table { border-collapse: collapse; width: 100%; margin: 12px 0; font-size: 13px; display: block; overflow-x: auto; }
.nb-md th, .nb-md td { border: 1px solid var(--line-soft); padding: 5px 9px; text-align: left; vertical-align: top; }
.nb-md th { font-family: var(--display); font-size: 11px; letter-spacing: .04em; text-transform: uppercase; border-bottom: 2px solid var(--line); }
.nb-md blockquote { margin: 10px 0; padding-left: 12px; border-left: 2px solid var(--line); color: var(--text-2); }
.nb-code { border: 2px solid var(--ink); position: relative; }
.nb-lang { position: absolute; top: 0; right: 0; font-family: var(--mono); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; background: var(--inv-bg); color: var(--inv-text); padding: 2px 7px; }
.nb-code pre { margin: 0; padding: 12px 14px; overflow-x: auto; font-family: var(--mono); font-size: 12.5px; line-height: 1.5; }
.nb-out { border-top: 2px dashed var(--line); color: var(--text-2); white-space: pre-wrap; }
.nb-img { display: block; max-width: 100%; border-top: 2px dashed var(--line); padding: 12px 14px; }
.nb-raw { white-space: pre-wrap; font-family: var(--mono); font-size: 12.5px; overflow-x: auto; margin: 0; }

/* Подсветка кода (классы Pygments). Цветов немного: смысл несёт начертание. */
.nb-code .k, .nb-code .kn, .nb-code .kc, .nb-code .kd, .nb-code .kr, .nb-code .ow { color: var(--code-key); font-weight: 700; }
.nb-code .nf, .nb-code .nc, .nb-code .nd { color: var(--code-key); font-weight: 600; }
.nb-code .s, .nb-code .s1, .nb-code .s2, .nb-code .sb, .nb-code .sd, .nb-code .se, .nb-code .sh, .nb-code .si, .nb-code .sx, .nb-code .sr, .nb-code .ss { color: var(--code-str); }
.nb-code .c, .nb-code .c1, .nb-code .cm, .nb-code .cs, .nb-code .cp { color: var(--code-com); font-style: italic; }
.nb-code .m, .nb-code .mi, .nb-code .mf, .nb-code .mh, .nb-code .mo, .nb-code .il { color: var(--code-num); }
.nb-code .nb, .nb-code .bp { color: var(--code-key); }
.nb-code .err { color: var(--err); }

/* Формулы. MathML браузер рисует сам — нам остаются размер и прокрутка. */
.nb-md math, .nb-out math { font-size: 1.05em; }
.math-block { display: block; overflow-x: auto; margin: 12px 0; text-align: center; }
.math-block math { font-size: 1.15em; }
.math-raw { font-family: var(--mono); font-size: 12px; color: var(--err); }
