/* ==========================================================================
   S.I.T Education — дизайн-система
   Палитра, шрифт, логотип и «окна с кодом» — из портфолио alex-fgdev.ru.
   Структура и компоненты — из Сириус Wiki: капсула навигации с поиском,
   бенто-баннер, плитки материалов «стопкой», строки разделов, страница статьи.
   ========================================================================== */

@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&family=JetBrains+Mono:wght@400;500;700&display=swap");

/* ---------- Токены ---------- */

:root,
html[data-theme="dark"] {
    --bg: #090c0a;
    --bg-soft: #0d120f;
    --surface: #111713;
    --surface-2: #161d18;
    --text: #f1f5ef;
    --muted: #98a398;
    --line: rgba(240, 255, 238, 0.13);
    --line-strong: rgba(240, 255, 238, 0.28);
    --accent: #21aabe;
    --accent-soft: #62c7d4;
    --on-accent: #061316;
    --led: #3fe0f2;
    --shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
    --code-bg: #0c110e;
    --radius: 14px;
    --radius-sm: 8px;
    --header-h: 74px;
    --shell: min(1240px, calc(100vw - 48px));
    --font: "Inter", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
    color-scheme: dark;
}

html[data-theme="light"] {
    --bg: #eef2e9;
    --bg-soft: #e4eade;
    --surface: #f8faf4;
    --surface-2: #e8eee2;
    --text: #121713;
    --muted: #5e695f;
    --line: rgba(18, 23, 19, 0.13);
    --line-strong: rgba(18, 23, 19, 0.26);
    --accent: #147889;
    --accent-soft: #147889;
    --on-accent: #ffffff;
    --led: #1aa6b8;
    --shadow: 0 30px 80px rgba(45, 55, 44, 0.13);
    --code-bg: #f3f6ef;
    color-scheme: light;
}

/* Мост для старых страниц (курсы, редактор, задачи, VIM):
   их стили читают прежние переменные — направляем их в новую палитру. */
html[data-theme] {
    --bg-color: var(--bg);
    --background: var(--bg);
    --text-color: var(--text);
    --text-primary: var(--text);
    --heading-color: var(--text);
    --text-secondary: var(--muted);
    --secondary-text: var(--muted);
    --secondary-text-color: var(--muted);
    --card-bg: var(--surface);
    --sidebar-color: var(--surface);
    --secondary-bg: var(--surface-2);
    --input-bg: var(--surface-2);
    --hover-color: var(--surface-2);
    --hover-bg: var(--surface-2);
    --border-color: var(--line);
    --border: var(--line);
    --accent-color: var(--accent);
    --accent-hover: var(--accent-soft);
    --accent-color-dark: var(--accent);
    --primary: var(--accent);
    --primary-color: var(--accent);
    --secondary: var(--surface-2);
    --secondary-color: var(--surface-2);
    --link-color: var(--accent);
    --tag-bg: var(--surface-2);
    --tag-text: var(--text);
    --code-bg: var(--code-bg);
    --active-tab: var(--bg);
    --tab-color: var(--surface);
    --card-shadow: none;
    --hero-gradient: var(--bg);
    --editor-bg: var(--surface);
    --editor-text: var(--text);
    --editor-border: var(--line);
    --editor-toolbar: var(--surface-2);
    --editor-hover: var(--surface-2);
}

/* ---------- База ---------- */

* {
    box-sizing: border-box;
}

html {
    overflow-x: clip;
    scroll-behavior: smooth;
    scroll-padding-top: 110px;
    -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;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    transition: background 0.35s ease, color 0.35s ease;
}

body.menu-open {
    overflow: hidden;
}

::selection {
    background: var(--accent);
    color: var(--on-accent);
}

a {
    color: inherit;
    text-decoration: none;
}

img {
    max-width: 100%;
}

button,
input,
select,
textarea {
    font: inherit;
    color: inherit;
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
    border-radius: 6px;
}

/* Сеть частиц со старых страниц больше не нужна */
#particles {
    display: none !important;
}

.skip-link {
    position: fixed;
    left: 20px;
    top: -60px;
    z-index: 999;
    padding: 12px 16px;
    background: var(--accent);
    color: var(--on-accent);
    border-radius: 8px;
    font-weight: 800;
    transition: top 0.2s;
}

.skip-link:focus {
    top: 16px;
}

.page-noise {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 100;
    opacity: 0.035;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.55'/%3E%3C/svg%3E");
}

[hidden] {
    display: none !important;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.shell {
    width: var(--shell);
    margin-inline: auto;
}

/* ---------- Дополнительные токены (из Сириус Wiki) ---------- */

:root,
html[data-theme="dark"] {
    --outline: rgba(240, 255, 238, 0.22);
    --rule: rgba(240, 255, 238, 0.82);
    --accent-tint: rgba(33, 170, 190, 0.14);
    --plus: #7ce36f;
    --banner-bg: #0f1511;
    --banner-grid: rgba(240, 255, 238, 0.1);
    --radius-lg: 22px;
}

html[data-theme="light"] {
    --outline: rgba(18, 23, 19, 0.3);
    --rule: #121713;
    --accent-tint: rgba(20, 120, 137, 0.1);
    --plus: #3fae3b;
    --banner-bg: #f8faf4;
    --banner-grid: rgba(18, 23, 19, 0.16);
}

/* ---------- Хедер: логотип | EDU и капсула навигации ---------- */

header.site-header {
    width: var(--shell);
    max-width: none;
    height: var(--header-h);
    position: fixed;
    top: 14px;
    left: 50%;
    z-index: 80;
    transform: translateX(-50%);
    margin: 0;
    padding: 0 10px 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-lg);
    box-shadow: none;
    transition: background 0.3s, border-color 0.3s, box-shadow 0.3s, top 0.3s;
}

header.site-header.is-scrolled,
body.menu-open header.site-header {
    top: 8px;
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    border-color: var(--line);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    box-shadow: 0 16px 50px rgba(0, 0, 0, 0.15);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
}

.brand-logo-switch img {
    display: block;
    width: auto;
    height: 40px;
}

.brand-logo-light {
    display: none !important;
}

html[data-theme="light"] .brand-logo-dark {
    display: none !important;
}

html[data-theme="light"] .brand-logo-light {
    display: block !important;
}

.brand-sep {
    width: 1px;
    height: 28px;
    background: var(--line-strong);
}

/* Название платформы рядом с логотипом, как «WIKI» у Сириуса */
.brand-edu {
    color: var(--text);
    font-size: 1.02rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    white-space: nowrap;
}

.header-end {
    display: flex;
    align-items: center;
    gap: 10px;
}

nav.site-nav {
    max-width: none;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 5px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: color-mix(in srgb, var(--surface) 80%, transparent);
}

.site-nav a,
.search-open {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 15px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--muted);
    font-size: 0.93rem;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.18s, color 0.18s;
}

.site-nav a:hover,
.search-open:hover {
    background: var(--accent-tint);
    color: var(--text);
}

.site-nav a[aria-current="page"] {
    background: var(--accent);
    color: var(--on-accent);
}

.search-open svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
}

.search-open kbd {
    display: inline-grid;
    place-items: center;
    min-width: 22px;
    height: 22px;
    padding: 0 5px;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    font-family: var(--font);
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--muted);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.site-header .icon-button {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    margin: 0;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: color-mix(in srgb, var(--surface) 80%, transparent);
    color: var(--text);
    font-size: 0;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.site-header .icon-button:hover {
    border-color: var(--line-strong);
    background: var(--surface-2);
}

.icon-button svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.icon-button .moon,
html[data-theme="light"] .icon-button .sun {
    display: none;
}

html[data-theme="light"] .icon-button .moon {
    display: block;
}

.site-header .menu-toggle,
.site-header .search-mobile {
    display: none;
    position: relative;
}

.menu-toggle span {
    position: absolute;
    left: 13px;
    width: 17px;
    height: 1.5px;
    background: currentColor;
    transition: transform 0.25s, top 0.25s;
}

.menu-toggle span:first-child { top: 17px; }
.menu-toggle span:last-child { top: 25px; }

.menu-toggle[aria-expanded="true"] span:first-child {
    top: 21px;
    transform: rotate(45deg);
}

.menu-toggle[aria-expanded="true"] span:last-child {
    top: 21px;
    transform: rotate(-45deg);
}

.mobile-menu {
    display: none;
}

/* ---------- Круглая стрелка (Сириус Wiki) ---------- */

.round-arrow {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    border: 1px solid var(--outline);
    border-radius: 50%;
    background: var(--surface);
    color: var(--text);
    transition: background 0.3s, color 0.3s, border-color 0.3s;
}

.round-arrow svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform 0.3s;
}

a:hover .round-arrow,
a:focus-visible .round-arrow,
button:hover > .round-arrow {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--on-accent);
}

a:hover .round-arrow svg,
a:focus-visible .round-arrow svg {
    transform: rotate(-45deg);
}

/* ---------- Главная: бенто-hero ---------- */

.hero {
    width: var(--shell);
    margin-inline: auto;
    padding: calc(var(--header-h) + 40px) 0 0;
    display: grid;
    grid-template-columns: minmax(0, 1.75fr) minmax(0, 1fr);
    grid-template-rows: 1fr 1fr;
    gap: 18px;
}

.hero-banner {
    grid-row: 1 / 3;
    position: relative;
    isolation: isolate;
    overflow: hidden;
    container-type: inline-size;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 600px;
    padding: 96px 48px 56px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--banner-bg);
    text-align: center;
}

/* Сетка из линий — тот же рисунок, что в баннере вики */
.hero-banner::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -2;
    background: var(--banner-grid);
    -webkit-mask: url("images/patterns/hero-grid.svg") center / 100% 100% no-repeat;
    mask: url("images/patterns/hero-grid.svg") center / 100% 100% no-repeat;
}

.hero-deco {
    position: absolute;
    z-index: -1;
    pointer-events: none;
}

.hero-deco-circles {
    top: -26%;
    left: 40%;
    width: 30cqi;
    aspect-ratio: 1;
    border-radius: 50%;
    background: var(--surface-2);
}

.hero-deco-circles::after {
    content: "";
    position: absolute;
    top: -10%;
    left: 30%;
    width: 82%;
    aspect-ratio: 1;
    border-radius: 50%;
    background: color-mix(in srgb, var(--accent) 70%, var(--banner-bg));
}

.hero-deco-plus {
    top: 40px;
    left: -14px;
    width: 132px;
    height: 36px;
    background: var(--plus);
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 132 36' fill='none' stroke='%23000' stroke-width='6' stroke-linecap='round'%3E%3Cpath d='M18 4v28M4 18h28M66 4v28M52 18h28M114 4v28M100 18h28'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 132 36' fill='none' stroke='%23000' stroke-width='6' stroke-linecap='round'%3E%3Cpath d='M18 4v28M4 18h28M66 4v28M52 18h28M114 4v28M100 18h28'/%3E%3C/svg%3E") center / contain no-repeat;
}

.hero-deco-rings {
    right: -34px;
    bottom: 20px;
    width: 150px;
    height: 120px;
    background: var(--accent);
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 150 120' fill='none' stroke='%23000' stroke-width='5'%3E%3Cellipse cx='92' cy='58' rx='62' ry='26' transform='rotate(-32 92 58)'/%3E%3Cellipse cx='100' cy='70' rx='62' ry='26' transform='rotate(-32 100 70)'/%3E%3Cellipse cx='108' cy='82' rx='62' ry='26' transform='rotate(-32 108 82)'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 150 120' fill='none' stroke='%23000' stroke-width='5'%3E%3Cellipse cx='92' cy='58' rx='62' ry='26' transform='rotate(-32 92 58)'/%3E%3Cellipse cx='100' cy='70' rx='62' ry='26' transform='rotate(-32 100 70)'/%3E%3Cellipse cx='108' cy='82' rx='62' ry='26' transform='rotate(-32 108 82)'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* Заголовок на плашках, вторая строка «ступенькой» — как в вики */
.hero-banner h1 {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    margin: 0;
    font-size: clamp(2.2rem, 10.5cqi, 7rem);
    line-height: 1;
    letter-spacing: -0.03em;
    font-weight: 900;
    text-transform: uppercase;
    color: var(--on-accent);
}

.hero-banner h1 span {
    display: block;
    padding: 0.14em 0.3em 0.1em;
    border-radius: 0.3em;
    background: var(--accent);
}

.hero-banner h1 span + span {
    margin: -0.06em 0 0 0.9em;
    border-top-left-radius: 0;
}

.hero-tagline {
    margin: 0.55em 0 0;
    font-size: clamp(1.05rem, 4.4cqi, 2.8rem);
    line-height: 1.05;
    font-weight: 500;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--text);
}

.hero-text {
    max-width: 46ch;
    margin: 18px 0 0;
    color: var(--muted);
    font-size: 1rem;
    line-height: 1.6;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 12px 18px;
    margin-top: 32px;
}

.hero-chevrons {
    width: 64px;
    height: 40px;
    background: var(--accent);
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 40' fill='none' stroke='%23000' stroke-width='2' stroke-dasharray='3 3' stroke-linecap='round'%3E%3Cpath d='M4 4l18 16L4 36M22 4l18 16-18 16M40 4l18 16-18 16'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 40' fill='none' stroke='%23000' stroke-width='2' stroke-dasharray='3 3' stroke-linecap='round'%3E%3Cpath d='M4 4l18 16L4 36M22 4l18 16-18 16M40 4l18 16-18 16'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* Карточки разделов справа от баннера */
.section-card {
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    min-height: 260px;
    padding: 26px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
    transition: border-color 0.3s, background 0.3s;
}

.section-card:hover {
    border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
    background: var(--surface-2);
}

.section-card-foot {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
}

.section-card h2 {
    margin: 0;
    font-size: clamp(1.5rem, 2.2vw, 2rem);
    line-height: 1.05;
    letter-spacing: -0.04em;
    font-weight: 800;
}

.section-card p {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 0.92rem;
}

.section-card .card-art {
    position: absolute;
    top: 0;
    right: 0;
    width: 62%;
    height: 66%;
    object-fit: contain;
    object-position: right top;
    opacity: 0.85;
    mix-blend-mode: multiply;
}

html[data-theme="dark"] .section-card .card-art,
html[data-theme="dark"] .tile-art {
    filter: invert(1);
    mix-blend-mode: screen;
    opacity: 0.55;
}

/* Карточка «Курсы»: в ней живёт мигающий blink.ino (только loop()) */
.section-card {
    --card-fill: var(--surface);
}

.section-card:hover {
    --card-fill: var(--surface-2);
}

.section-card.courses-card .blink-card {
    position: absolute;
    top: 16px;
    right: -18px;
    width: min(270px, 70%);
    margin: 0;
    padding: 6px;
    border-radius: 12px;
    transform: rotate(3deg);
    pointer-events: none;
}

.section-card.courses-card .window-bar {
    height: 22px;
}

.section-card.courses-card .blink-code {
    padding: 8px 10px 10px;
    font-size: 0.66rem;
    line-height: 1.6;
}

.section-card.courses-card .blink-code .l:nth-child(-n+4) {
    display: none;
}

.section-card.courses-card .blink-board {
    padding: 7px 10px;
}

/* Подложка под текстом, чтобы окно с кодом не мешало читать */
.section-card.courses-card::after {
    content: "";
    position: absolute;
    inset: auto 0 0 0;
    height: 58%;
    background: linear-gradient(to bottom, transparent, var(--card-fill) 55%);
    pointer-events: none;
}

/* ---------- Заголовок раздела: линия 2px и счётчик справа ---------- */

.block {
    width: var(--shell);
    margin-inline: auto;
    padding: clamp(64px, 8vw, 104px) 0 0;
    position: relative;
}

.block:last-of-type {
    padding-bottom: clamp(64px, 8vw, 104px);
}

.section-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px 24px;
    padding-bottom: 20px;
    margin-bottom: 36px;
    border-bottom: 2px solid var(--rule);
}

.section-heading h2 {
    margin: 0;
    font-size: clamp(1.9rem, 3.6vw, 3rem);
    line-height: 1.05;
    letter-spacing: -0.045em;
    font-weight: 850;
}

.section-heading p {
    margin: 0;
    color: var(--muted);
}

.section-heading a {
    color: var(--text);
    font-weight: 700;
    border-bottom: 1px solid var(--line-strong);
}

.section-heading a:hover {
    color: var(--accent);
    border-color: var(--accent);
}

/* ---------- Плитки материалов: рамка со «стопкой» листов ---------- */

.article-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
    gap: 34px 30px;
    padding: 0 10px 10px 0;
}

.article-tile {
    position: relative;
    z-index: 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 28px;
    overflow: hidden;
}

.article-tile::before,
.article-tile::after {
    content: "";
    position: absolute;
    inset: 0;
    border: 1px solid var(--outline);
    background: var(--bg);
}

.article-tile::before {
    z-index: -2;
    transform: translate(10px, 10px);
}

.article-tile::after {
    z-index: -1;
    transition: border-color 0.3s;
}

.article-tile:hover::after,
.article-tile:focus-visible::after {
    border-color: var(--accent);
}

/* «Стопке» нужен выступ за край плитки */
.article-list .article-tile {
    overflow: visible;
}

.tile-meta {
    display: grid;
    gap: 2px;
    font-size: 0.82rem;
    line-height: 1.4;
}

.tile-subject {
    color: var(--accent);
    font-weight: 700;
}

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

.tile-body {
    flex: 1;
    min-width: 0;
}

.article-tile h3 {
    margin: 0 0 10px;
    font-size: 1.2rem;
    line-height: 1.28;
    letter-spacing: -0.02em;
    font-weight: 750;
    overflow-wrap: break-word;
    transition: color 0.3s;
}

.article-tile:hover h3 {
    color: var(--accent);
}

.article-tile p {
    margin: 0;
    color: var(--muted);
    font-size: 0.94rem;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.tile-foot {
    position: relative;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    min-height: 96px;
}

.tile-foot .round-arrow {
    width: 46px;
    height: 46px;
    background: transparent;
}

.tile-art {
    display: block;
    height: 120px;
    width: auto;
    max-width: 66%;
    margin: 0 -28px -28px 0;
    object-fit: contain;
    object-position: right bottom;
    opacity: 0.9;
    mix-blend-mode: multiply;
    pointer-events: none;
}

.tile-image {
    margin: -28px -28px 0;
    aspect-ratio: 16 / 9;
    border-bottom: 1px solid var(--outline);
    overflow: hidden;
    background: var(--surface);
}

.tile-image img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ---------- Темы статей на главной ---------- */

.topic-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.topic {
    display: inline-flex;
    align-items: baseline;
    gap: 10px;
    padding: 12px 18px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    font-weight: 700;
    transition: border-color 0.2s, background 0.2s, color 0.2s;
}

.topic small {
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.topic:hover {
    border-color: var(--accent);
    background: var(--accent-tint);
}

/* ---------- Курсы и практика ---------- */

.practice-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
}

.practice-grid .section-card {
    min-height: 220px;
}

.practice-grid .section-card code {
    position: absolute;
    top: 24px;
    left: 26px;
    padding: 6px 10px;
    border: 1px solid var(--line);
    border-radius: 7px;
    color: var(--accent);
    background: var(--code-bg);
    font-family: var(--mono);
    font-size: 0.8rem;
}

/* ---------- Строки материалов (новости, разделы) ---------- */

.entries {
    border-top: 1px solid var(--line);
}

.entry-row {
    display: grid;
    grid-template-columns: 150px minmax(0, 1fr) 32px;
    gap: 6px 28px;
    align-items: start;
    padding: 24px 8px;
    border-bottom: 1px solid var(--line);
}

.entry-label {
    padding-top: 3px;
    color: var(--accent);
    font-size: 0.86rem;
    font-weight: 700;
    line-height: 1.4;
}

.entry-label small {
    display: block;
    color: var(--muted);
    font-weight: 600;
}

.entry-row h3 {
    margin: 0 0 6px;
    font-size: 1.2rem;
    line-height: 1.3;
    letter-spacing: -0.02em;
    font-weight: 750;
}

.entry-row p {
    margin: 0;
    max-width: 62ch;
    color: var(--muted);
    font-size: 0.95rem;
}

.entry-row .chips {
    margin-top: 12px;
}

.entry-arrow {
    width: 24px;
    height: 24px;
    margin-top: 4px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform 0.3s, color 0.3s;
}

.entry-row:hover h3,
.entry-row:focus-visible h3 {
    color: var(--accent);
}

.entry-row:hover .entry-arrow {
    color: var(--accent);
    transform: translateX(4px);
}

/* ---------- Внутренние страницы: шапка раздела ---------- */

.page {
    width: var(--shell);
    margin-inline: auto;
    padding: calc(var(--header-h) + 64px) 0 clamp(72px, 9vw, 120px);
    min-height: 70vh;
}

.page-top {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 16px 48px;
    align-items: end;
    padding-bottom: 28px;
    border-bottom: 2px solid var(--rule);
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 13px;
    border-radius: 999px;
    background: var(--accent);
    color: var(--on-accent);
    font-size: 0.8rem;
    font-weight: 700;
}

.page-top h1 {
    margin: 16px 0 0;
    font-size: clamp(2.8rem, 7vw, 6.4rem);
    line-height: 0.95;
    letter-spacing: -0.06em;
    font-weight: 900;
}

.page-description {
    max-width: 34em;
    margin: 0;
    color: var(--muted);
    font-size: 1.06rem;
    line-height: 1.65;
}

/* Боковая колонка + список */
.content-layout {
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr);
    gap: clamp(28px, 4vw, 56px);
    align-items: start;
    padding-top: 32px;
}

.content-layout.wide {
    grid-template-columns: 1fr;
}

.sidebar {
    position: sticky;
    top: calc(var(--header-h) + 36px);
    display: grid;
    gap: 2px;
    max-height: calc(100vh - var(--header-h) - 60px);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
}

.sidebar-title {
    margin: 0 0 10px;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 600;
}

.sidebar-item,
#categoryList .filter-tag {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    padding: 10px 16px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--text);
    font-size: 0.95rem;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: background 0.18s, color 0.18s;
}

.sidebar-item small {
    color: var(--muted);
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
}

.sidebar-item:hover,
#categoryList .filter-tag:hover {
    background: var(--surface);
}

.sidebar-item.active,
#categoryList .filter-tag.active {
    background: var(--accent);
    color: var(--on-accent);
    font-weight: 650;
}

.sidebar-item.active small {
    color: inherit;
}

/* Поле поиска в списке */
.search-bar {
    position: relative;
    display: flex;
    align-items: center;
    margin-bottom: 8px;
}

.search-bar svg {
    position: absolute;
    left: 18px;
    width: 18px;
    height: 18px;
    fill: none;
    stroke: var(--muted);
    stroke-width: 1.8;
    stroke-linecap: round;
    pointer-events: none;
}

.search-bar input {
    width: 100%;
    height: 54px;
    padding: 0 56px 0 48px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
    font-size: 1rem;
    transition: border-color 0.2s, background 0.2s;
}

.search-bar input::placeholder {
    color: var(--muted);
}

.search-bar input:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--surface-2);
}

.search-bar kbd {
    position: absolute;
    right: 16px;
    padding: 2px 8px;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    color: var(--muted);
    font-family: var(--font);
    font-size: 0.76rem;
    font-weight: 700;
    pointer-events: none;
}

.list-status {
    margin: 18px 0 0;
    color: var(--muted);
    font-size: 0.88rem;
}

/* Фильтры-пилюли (новости) */
.filter-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 28px 0 0;
}

.filter-tag {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 0 16px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: transparent;
    color: var(--text);
    font-size: 0.92rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.18s, color 0.18s, border-color 0.18s;
}

.filter-tag:hover {
    background: var(--surface);
}

.filter-tag.active {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--on-accent);
    font-weight: 650;
}

/* Состояния */
.loading,
.no-results,
.error-message,
.empty-state {
    grid-column: 1 / -1;
    padding: 40px 28px;
    border: 1px dashed var(--line-strong);
    color: var(--muted);
}

.no-results h2,
.error-message h2 {
    margin: 0 0 6px;
    color: var(--text);
    font-size: 1.2rem;
    letter-spacing: -0.03em;
}

.no-results p,
.error-message p {
    margin: 0;
}

.error-message button {
    margin-top: 18px;
    min-height: 42px;
    padding: 0 16px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    background: var(--surface);
    font-weight: 700;
    cursor: pointer;
}

/* ---------- Страница статьи (как в вики) ---------- */

.article-page {
    max-width: 1080px;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 36px;
    padding: 0;
    border: 0;
    background: none;
    color: var(--accent);
    font-weight: 700;
    cursor: pointer;
}

.back-link svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

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

.article-head {
    padding-bottom: 28px;
    border-bottom: 2px solid var(--rule);
}

.article-kicker {
    color: var(--accent);
    font-size: 0.9rem;
    font-weight: 650;
}

.article-head h1 {
    margin: 12px 0 18px;
    max-width: 22ch;
    font-size: clamp(2.2rem, 5vw, 4.2rem);
    line-height: 1.04;
    letter-spacing: -0.045em;
    font-weight: 850;
    overflow-wrap: break-word;
    text-wrap: balance;
}

.article-head .summary {
    max-width: 44em;
    margin: 0;
    color: var(--muted);
    font-size: 1.15rem;
    line-height: 1.6;
}

.article-byline {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 18px;
    margin-top: 22px;
    color: var(--muted);
    font-size: 0.9rem;
}

.article-byline strong {
    color: var(--text);
    font-weight: 700;
}

.article-body {
    max-width: 780px;
    margin: 40px auto 0;
}

.article-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    max-width: 780px;
    margin: 56px auto 0;
    padding-top: 28px;
    border-top: 1px solid var(--line);
}

.related {
    margin-top: clamp(64px, 8vw, 100px);
}

/* ---------- Поиск по сайту (Ctrl/⌘ K) ---------- */

.search-dialog {
    width: min(680px, calc(100vw - 32px));
    max-height: min(640px, calc(100vh - 80px));
    margin: 10vh auto auto;
    padding: 0;
    border: 1px solid var(--line-strong);
    border-radius: 18px;
    background: var(--bg);
    color: var(--text);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.search-dialog::backdrop {
    background: color-mix(in srgb, #000 55%, transparent);
    backdrop-filter: blur(6px);
}

.search-dialog-field {
    position: relative;
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--line);
}

.search-dialog-field svg {
    position: absolute;
    left: 22px;
    width: 20px;
    height: 20px;
    fill: none;
    stroke: var(--muted);
    stroke-width: 1.8;
    stroke-linecap: round;
}

.search-dialog-field input {
    width: 100%;
    height: 66px;
    padding: 0 70px 0 56px;
    border: 0;
    background: transparent;
    font-size: 1.1rem;
    outline: none;
}

.search-close {
    cursor: pointer;
    background: transparent;
}

.search-close .on-touch {
    display: none;
}

.search-dialog-field .search-close {
    position: absolute;
    right: 18px;
    padding: 3px 8px;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    color: var(--muted);
    font-family: var(--font);
    font-size: 0.75rem;
    font-weight: 700;
}

.search-results {
    max-height: calc(min(640px, 100vh - 80px) - 68px);
    overflow-y: auto;
    padding: 8px;
}

.search-result {
    display: block;
    padding: 12px 16px;
    border-radius: 11px;
}

.search-result strong {
    display: block;
    font-weight: 700;
}

.search-result span {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 0.86rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-result:hover,
.search-result:focus-visible,
.search-result.is-active {
    background: var(--accent-tint);
    outline: none;
}

.search-result mark {
    background: none;
    color: var(--accent);
    font-weight: 700;
}

.search-empty {
    padding: 28px 16px;
    color: var(--muted);
}

/* ---------- Курсы (страница) ---------- */

.course-list {
    display: grid;
    gap: 18px;
    padding-top: 32px;
}

.course-row {
    display: grid;
    grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
    gap: clamp(24px, 4vw, 56px);
    align-items: center;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
    transition: border-color 0.3s, background 0.3s;
}

.course-row:hover {
    border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
    background: var(--surface-2);
}

.course-media {
    aspect-ratio: 16 / 9;
    border-radius: 14px;
    overflow: hidden;
    background: var(--code-bg);
    border: 1px solid var(--line);
}

.course-media.code {
    display: flex;
    flex-direction: column;
    padding: 6px 0 0;
}

.course-media .window-bar {
    padding: 0 12px;
}

.course-media.code pre {
    flex: 1;
    margin: 0;
    padding: 14px 20px 18px;
    font-family: var(--mono);
    font-size: clamp(0.74rem, 1.05vw, 0.9rem);
    line-height: 1.75;
    color: var(--text);
    overflow: hidden;
}

.cursor {
    display: inline-block;
    margin-left: 2px;
    width: 0.6em;
    height: 1.1em;
    vertical-align: -0.2em;
    background: var(--accent);
}

.course-copy {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 12px clamp(4px, 2vw, 24px) 12px 0;
}

.course-meta {
    color: var(--accent);
    font-size: 0.86rem;
    font-weight: 700;
}

.course-copy h3 {
    margin: 8px 0 12px;
    font-size: clamp(1.6rem, 2.6vw, 2.3rem);
    line-height: 1.05;
    letter-spacing: -0.045em;
    font-weight: 850;
}

.course-copy p {
    margin: 0 0 20px;
    color: var(--muted);
    max-width: 36em;
}

.course-copy .chips {
    margin-bottom: 26px;
}

/* ---------- Плитки проектов,
команды,
хакатонов,
новостей ---------- */

.projects-grid,
.team-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
    gap: 34px 30px;
    padding: 32px 10px 10px 0;
}

.team-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 460px), 1fr));
}

.project-card,
.team-member {
    position: relative;
    z-index: 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.project-card::before,
.project-card::after,
.team-member::before,
.team-member::after {
    content: "";
    position: absolute;
    inset: 0;
    border: 1px solid var(--outline);
    background: var(--bg);
}

.project-card::before,
.team-member::before {
    z-index: -2;
    transform: translate(10px, 10px);
}

.project-card::after,
.team-member::after {
    z-index: -1;
    transition: border-color 0.3s;
}

.project-card:hover::after {
    border-color: var(--accent);
}

.project-image {
    position: relative;
    aspect-ratio: 16 / 10;
    border-bottom: 1px solid var(--outline);
    overflow: hidden;
    background: var(--surface);
}

.project-image img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.project-status {
    position: absolute;
    left: 12px;
    top: 12px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 5px 11px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--bg) 85%, transparent);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: var(--text);
    font-size: 0.76rem;
    font-weight: 700;
}

.project-status i {
    display: none;
}

.project-status::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--muted);
}

.project-status.active::before,
.project-status.in-progress::before {
    background: var(--accent);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent);
}

.project-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 24px 26px 26px;
}

.project-content h2 {
    margin: 0 0 10px;
    font-size: 1.25rem;
    line-height: 1.25;
    letter-spacing: -0.025em;
    font-weight: 750;
    overflow-wrap: anywhere;
}

.project-description {
    margin: 0 0 18px;
    color: var(--muted);
    font-size: 0.94rem;
}

.project-tech {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 18px;
}

.tech-tag,
.wiki-tags .tag {
    padding: 4px 9px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    font-size: 0.74rem;
    font-weight: 700;
}

.project-author {
    margin: auto 0 14px;
    color: var(--muted);
    font-size: 0.86rem;
}

.project-author i {
    display: none;
}

.project-links,
.member-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.project-link,
.member-links .social-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 15px;
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: 0.88rem;
    font-weight: 700;
    transition: border-color 0.2s, background 0.2s;
}

.project-link:hover,
.member-links .social-link:hover {
    border-color: var(--accent);
    background: var(--accent-tint);
}

.read-more {
    align-self: flex-start;
    margin-top: auto;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 9px 15px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: none;
    font-weight: 700;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, color 0.2s;
}

.read-more:hover {
    border-color: var(--accent);
    background: var(--accent);
    color: var(--on-accent);
}

/* Команда */
.team-member {
    display: grid;
    grid-template-columns: 150px minmax(0, 1fr);
    gap: 24px;
    padding: 22px;
}

.member-photo {
    aspect-ratio: 4 / 5;
    overflow: hidden;
    border: 1px solid var(--outline);
    background: var(--surface);
}

.member-photo img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.member-info {
    display: flex;
    flex-direction: column;
}

.member-info h2 {
    margin: 0 0 4px;
    font-size: 1.45rem;
    line-height: 1.1;
    letter-spacing: -0.04em;
    font-weight: 850;
}

.member-handle {
    color: var(--accent);
    font-family: var(--mono);
    font-size: 0.8rem;
    font-weight: 500;
    letter-spacing: 0;
}

.member-role {
    margin: 10px 0 12px;
    font-size: 0.9rem;
    font-weight: 650;
}

.member-bio {
    margin: 0 0 18px;
    color: var(--muted);
    font-size: 0.93rem;
}

.member-links {
    margin-top: auto;
}

/* База знаний: плитки внутри раздела */
.wiki-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
    gap: 34px 30px;
    padding: 0 10px 10px 0;
}

/* Магазин */
.coming-soon {
    max-width: 760px;
    padding-top: 40px;
}

.coming-soon pre {
    margin: 0;
    padding: 22px;
    font-family: var(--mono);
    font-size: 0.9rem;
    line-height: 1.8;
    color: var(--muted);
    white-space: pre-wrap;
}

.coming-soon pre b {
    color: var(--accent);
    font-weight: 700;
}

.coming-soon .hero-actions {
    justify-content: flex-start;
}

/* Команда на главной */
.team-band {
    display: grid;
    grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
    gap: clamp(30px, 6vw, 90px);
    padding: clamp(28px, 4vw, 56px);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background:
        radial-gradient(circle at 0 0, color-mix(in srgb, var(--accent) 12%, transparent), transparent 45%),
        var(--surface);
}

.team-band-brand img {
    display: block;
    width: min(260px, 100%);
    height: auto;
}

.team-band-brand p {
    margin: 18px 0 0;
    color: var(--muted);
}

.team-band h2 {
    margin: 0 0 18px;
    font-size: clamp(1.9rem, 3.4vw, 3rem);
    line-height: 1;
    letter-spacing: -0.05em;
    font-weight: 900;
}

.team-band-copy > p {
    margin: 0 0 16px;
    color: var(--muted);
    font-size: 1.05rem;
    max-width: 38em;
}

.team-band-copy strong {
    color: var(--text);
}

.link-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 26px;
}

.link-row a {
    display: inline-flex;
    gap: 10px;
    align-items: center;
    padding: 11px 16px;
    border: 1px solid var(--line);
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.92rem;
    transition: border-color 0.2s, background 0.2s;
}

.link-row a:hover {
    border-color: var(--accent);
    background: var(--accent-tint);
}

.link-row b {
    color: var(--accent);
}

/* ---------- Кнопки, метки ---------- */

.button {
    min-height: 54px;
    padding: 0 22px;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-weight: 800;
    border: 1px solid var(--line);
    cursor: pointer;
    transition: transform 0.22s, box-shadow 0.22s, background 0.22s, border-color 0.22s;
}

.button:hover {
    transform: translateY(-3px);
}

.button-primary {
    background: var(--accent);
    color: var(--on-accent);
    border-color: var(--accent);
}

.button-secondary {
    background: color-mix(in srgb, var(--surface) 65%, transparent);
    backdrop-filter: blur(8px);
}

.button-secondary:hover {
    border-color: var(--line-strong);
    background: var(--surface);
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.chip,
.chips span {
    padding: 5px 9px;
    border: 1px solid var(--line);
    border-radius: 7px;
    color: var(--muted);
    background: color-mix(in srgb, var(--bg) 32%, transparent);
    font-size: 0.76rem;
    font-weight: 700;
    line-height: 1.3;
    white-space: nowrap;
}

.ext {
    color: var(--accent);
    font-weight: 700;
}

.text-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 750;
    border-bottom: 1px solid var(--line-strong);
    padding-bottom: 2px;
    transition: border-color 0.2s, color 0.2s;
}

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

/* ---------- Окно с «хромом» (из портфолио) ---------- */

.window {
    position: relative;
    padding: 10px;
    border-radius: 18px;
    background: linear-gradient(145deg,
        color-mix(in srgb, var(--surface-2) 90%, transparent),
        color-mix(in srgb, var(--surface) 70%, transparent));
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}

.window::before {
    content: "";
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    padding: 1px;
    background: linear-gradient(140deg,
        color-mix(in srgb, var(--accent) 52%, transparent),
        transparent 36%,
        color-mix(in srgb, var(--accent) 25%, transparent));
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
}

.window-bar {
    height: 34px;
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 0 8px;
}

.window-bar i {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--line-strong);
}

.window-bar i:nth-child(1) { background: #ff6e66; }
.window-bar i:nth-child(2) { background: #ffd15b; }
.window-bar i:nth-child(3) { background: #7ce36f; }

.window-bar small {
    margin-left: auto;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 0.7rem;
}

.window-body {
    border-radius: 12px;
    overflow: hidden;
    background: var(--code-bg);
    border: 1px solid var(--line);
}

/* ---------- blink.ino ---------- */

.blink-card {
    width: min(100%, 540px);
    margin-left: auto;
    transform: rotate(1.2deg);
}

.blink-code {
    margin: 0;
    padding: 22px 22px 24px;
    font-family: var(--mono);
    font-size: clamp(0.78rem, 1vw, 0.9rem);
    line-height: 1.75;
    color: var(--text);
    counter-reset: ln;
    overflow-x: auto;
}

.blink-code span.l {
    display: block;
    white-space: pre;
}

.blink-code span.l::before {
    counter-increment: ln;
    content: counter(ln);
    display: inline-block;
    width: 2.2em;
    margin-right: 0.9em;
    color: color-mix(in srgb, var(--muted) 55%, transparent);
    text-align: right;
}

.tk-k { color: #c792ea; }
.tk-f { color: var(--accent-soft); }
.tk-n { color: #f5a97f; }
.tk-c { color: var(--muted); font-style: italic; }
.tk-s { color: #9fd98a; }

html[data-theme="light"] .tk-k { color: #7a3eb1; }
html[data-theme="light"] .tk-n { color: #b4561c; }
html[data-theme="light"] .tk-s { color: #3b7d22; }

/* Строки loop(), которые сейчас «выполняются» */
.blink-code .l.run-on,
.blink-code .l.run-off {
    transition: background 0.15s;
}

.blink-board {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 18px;
    border-top: 1px solid var(--line);
    background: color-mix(in srgb, var(--surface) 70%, transparent);
}

.board-pin {
    display: flex;
    align-items: center;
    gap: 14px;
    font-family: var(--mono);
    font-size: 0.78rem;
    color: var(--muted);
}

.led {
    position: relative;
    width: 18px;
    height: 18px;
    border-radius: 50% 50% 4px 4px;
    background: color-mix(in srgb, var(--led) 18%, var(--surface-2));
    border: 1px solid var(--line-strong);
}

.led::after {
    content: "";
    position: absolute;
    inset: -14px;
    border-radius: 50%;
    background: radial-gradient(circle, color-mix(in srgb, var(--led) 55%, transparent), transparent 65%);
    opacity: 0;
}

.board-state {
    font-family: var(--mono);
    font-size: 0.78rem;
    color: var(--muted);
}

.board-state b {
    color: var(--text);
    font-weight: 700;
}

/* Мигание: 1 с горит, 1 с не горит — как delay(1000) в скетче */
@media (prefers-reduced-motion: no-preference) {
    .blink-card .led {
        animation: led-body 2s steps(1, end) infinite;
    }
    .blink-card .led::after {
        animation: led-glow 2s steps(1, end) infinite;
    }
    .blink-card .l.run-on {
        animation: line-on 2s steps(1, end) infinite;
    }
    .blink-card .l.run-off {
        animation: line-off 2s steps(1, end) infinite;
    }
    .blink-card .state-on {
        animation: state-on 2s steps(1, end) infinite;
    }
    .blink-card .state-off {
        animation: state-off 2s steps(1, end) infinite;
    }
}

@keyframes led-body {
    0% { background: var(--led); border-color: var(--led); }
    50% { background: color-mix(in srgb, var(--led) 18%, var(--surface-2)); border-color: var(--line-strong); }
}

@keyframes led-glow {
    0% { opacity: 1; }
    50% { opacity: 0; }
}

@keyframes line-on {
    0% { background: color-mix(in srgb, var(--accent) 16%, transparent); }
    50% { background: transparent; }
}

@keyframes line-off {
    0% { background: transparent; }
    50% { background: color-mix(in srgb, var(--accent) 16%, transparent); }
}

@keyframes state-on {
    0% { visibility: visible; }
    50% { visibility: hidden; }
}

@keyframes state-off {
    0% { visibility: hidden; }
    50% { visibility: visible; }
}

/* HIGH и LOW лежат в одной ячейке; без анимации виден только HIGH */
.states {
    display: inline-grid;
}

.states > * {
    grid-area: 1 / 1;
}

.state-off {
    visibility: hidden;
}

@media (prefers-reduced-motion: reduce) {
    .blink-card .led {
        background: var(--led);
        border-color: var(--led);
    }
}

.blink-caption {
    margin: 18px 6px 0 auto;
    max-width: 540px;
    color: var(--muted);
    font-size: 0.88rem;
}

.blink-caption a {
    color: var(--text);
    border-bottom: 1px solid var(--line-strong);
}

.blink-caption a:hover {
    color: var(--accent);
    border-color: var(--accent);
}

/* ---------- Типографика Markdown ---------- */

.markdown-body,
.prose {
    font-size: 1.075rem;
    line-height: 1.75;
    color: var(--text);
    overflow-wrap: anywhere;
}

.markdown-body > :first-child {
    margin-top: 0;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
    margin: 2.2em 0 0.6em;
    line-height: 1.15;
    letter-spacing: -0.035em;
    font-weight: 850;
    scroll-margin-top: 110px;
}

.markdown-body h1 { font-size: 2.1rem; letter-spacing: -0.05em; }
.markdown-body h2 { font-size: 1.65rem; }
.markdown-body h3 { font-size: 1.3rem; }
.markdown-body h4 { font-size: 1.1rem; }

.markdown-body p,
.markdown-body ul,
.markdown-body ol,
.markdown-body blockquote,
.markdown-body table,
.markdown-body pre {
    margin: 0 0 1.25em;
}

.markdown-body ul,
.markdown-body ol {
    padding-left: 1.4em;
}

.markdown-body li + li {
    margin-top: 0.35em;
}

.markdown-body li::marker {
    color: var(--accent);
}

.markdown-body a {
    color: var(--accent);
    border-bottom: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
}

.markdown-body a:hover {
    border-color: var(--accent);
}

.markdown-body strong {
    font-weight: 750;
}

.markdown-body blockquote {
    padding: 14px 20px;
    border-left: 2px solid var(--accent);
    border-radius: 0 12px 12px 0;
    background: var(--surface);
    color: var(--muted);
}

.markdown-body blockquote > :last-child {
    margin-bottom: 0;
}

.markdown-body hr {
    margin: 2.5em 0;
    border: 0;
    border-top: 1px solid var(--line);
}

.markdown-body img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 1.6em 0;
    border: 1px solid var(--line);
    border-radius: 11px;
}

.markdown-body .img-wrapper img {
    margin: 1.6em 0;
}

.markdown-body :not(pre) > code {
    padding: 0.12em 0.4em;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface);
    font-family: var(--mono);
    font-size: 0.86em;
}

.markdown-body pre {
    position: relative;
    padding: 20px 22px;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: var(--code-bg) !important;
    overflow-x: auto;
    font-size: 0.88rem;
    line-height: 1.65;
}

.markdown-body pre code {
    font-family: var(--mono);
    background: none !important;
    text-shadow: none !important;
    color: var(--text);
    white-space: pre;
}

.code-wrapper pre {
    margin: 0 0 1.25em;
}

.table-wrapper {
    overflow-x: auto;
    margin: 0 0 1.25em;
    border: 1px solid var(--line);
    border-radius: 10px;
}

.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.table-wrapper table {
    margin: 0;
}

.markdown-body th,
.markdown-body td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

.markdown-body th {
    background: var(--surface);
    font-weight: 750;
}

.markdown-body tr:last-child td {
    border-bottom: 0;
}

/* Подсветка Prism в палитре сайта */
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata { color: var(--muted); font-style: italic; }
.token.punctuation { color: color-mix(in srgb, var(--text) 70%, var(--muted)); }
.token.keyword,
.token.boolean,
.token.important,
.token.atrule { color: #c792ea; }
.token.string,
.token.char,
.token.attr-value,
.token.inserted { color: #9fd98a; }
.token.number,
.token.constant,
.token.symbol { color: #f5a97f; }
.token.function,
.token.class-name { color: var(--accent-soft); }
.token.operator,
.token.entity,
.token.url { color: var(--text); background: none; }
.token.tag,
.token.selector,
.token.property { color: #ff8c8c; }
.token.attr-name,
.token.builtin { color: #ffd15b; }
html[data-theme="light"] .token.keyword,
html[data-theme="light"] .token.boolean,
html[data-theme="light"] .token.atrule { color: #7a3eb1; }
html[data-theme="light"] .token.string,
html[data-theme="light"] .token.attr-value { color: #3b7d22; }
html[data-theme="light"] .token.number,
html[data-theme="light"] .token.constant { color: #b4561c; }
html[data-theme="light"] .token.tag,
html[data-theme="light"] .token.selector,
html[data-theme="light"] .token.property { color: #b83232; }
html[data-theme="light"] .token.attr-name,
html[data-theme="light"] .token.builtin { color: #8a6500; }

/* ---------- Футер ---------- */

footer.site-footer {
    width: var(--shell);
    margin: 0 auto;
    padding: 64px 0 36px;
    background: transparent;
    border-top: 1px solid var(--line);
    color: var(--text);
    text-align: left;
}

.footer-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) repeat(3, minmax(0, 0.7fr));
    gap: 40px;
}

.footer-about img {
    display: block;
    height: 40px;
    width: auto;
}

.footer-about p {
    max-width: 30em;
    margin: 18px 0 0;
    color: var(--muted);
    font-size: 0.93rem;
}

.footer-col h2 {
    margin: 0 0 14px;
    font-size: 0.95rem;
    font-weight: 800;
    letter-spacing: -0.01em;
}

.footer-col ul {
    margin: 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 9px;
}

.footer-col a {
    color: var(--muted);
    font-size: 0.93rem;
    transition: color 0.2s;
}

.footer-col a:hover {
    color: var(--text);
}

.footer-bottom {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    margin-top: 56px;
    color: var(--muted);
    font-size: 0.86rem;
}

.footer-bottom a:hover {
    color: var(--text);
}

/* ==========================================================================
   Старые страницы инструментов: подгоняем хром под новый хедер
   ========================================================================== */

body.legacy {
    padding-top: calc(var(--header-h) + 40px);
    font-family: var(--font);
}

/* Курсы задавали моноширинный шрифт всему через «*»:
   текст возвращаем в Inter, моноширинный оставляем только коду */
body.legacy *:not(code, pre, pre *, kbd, samp, .code-example, .code-example *, .CodeMirror, .CodeMirror *, .ace_editor, .ace_editor *, .ascii-logo, i[class*="fa"]) {
    font-family: var(--font);
}

body.legacy .code-example,
body.legacy .code-example *,
body.legacy pre,
body.legacy pre *,
body.legacy code {
    font-family: var(--mono);
}

body.legacy code,
body.legacy pre,
body.legacy kbd,
body.legacy .CodeMirror,
body.legacy .ace_editor,
body.legacy textarea.code,
body.legacy #editor {
    font-family: var(--mono);
}

body.legacy h1,
body.legacy h2,
body.legacy h3 {
    letter-spacing: -0.03em;
}

/* VIM-тренажёр — тёмный терминал в любой теме */
html[data-theme="light"] .vim-page .vim-container {
    --bg: #090c0a;
    --surface: #111713;
    --surface-2: #161d18;
    --text: #f1f5ef;
    --muted: #98a398;
    --line: rgba(240, 255, 238, 0.13);
    --bg-color: #090c0a;
    --card-bg: #111713;
    --text-color: #f1f5ef;
    --text-secondary: #98a398;
    --border-color: rgba(240, 255, 238, 0.13);
    --link-color: #62c7d4;
    --accent-color: #21aabe;
    background: #111713;
    color: #f1f5ef;
    color-scheme: dark;
}

body.legacy footer.site-footer {
    margin-top: 80px;
}

/* ==========================================================================
   Адаптив
   ========================================================================== */

@media (max-width: 1140px) {
    nav.site-nav {
        display: none;
    }

    .site-header .menu-toggle,
    .site-header .search-mobile {
        display: grid;
    }

    .mobile-menu {
        position: fixed;
        inset: 0;
        z-index: 70;
        display: flex;
        flex-direction: column;
        gap: 4px;
        padding: calc(var(--header-h) + 48px) 24px 40px;
        background: var(--bg);
        overflow-y: auto;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.25s, visibility 0.25s;
    }

    .mobile-menu.is-open {
        opacity: 1;
        visibility: visible;
    }

    .mobile-menu a {
        padding: 10px 0;
        font-size: clamp(1.6rem, 6vw, 2.2rem);
        font-weight: 850;
        letter-spacing: -0.05em;
        border-bottom: 1px solid var(--line);
    }

    .mobile-menu a[aria-current="page"] {
        color: var(--accent);
    }

    .mobile-menu .mobile-menu-minor {
        display: flex;
        flex-wrap: wrap;
        gap: 8px 20px;
        margin-top: 24px;
    }

    .mobile-menu .mobile-menu-minor a {
        font-size: 1rem;
        font-weight: 700;
        letter-spacing: 0;
        color: var(--muted);
        border: 0;
        padding: 4px 0;
    }

    .practice-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .footer-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .footer-about {
        grid-column: 1 / -1;
    }
}

@media (max-width: 1000px) {
    .hero {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto;
    }

    .hero-banner {
        grid-column: 1 / -1;
        grid-row: auto;
        min-height: 520px;
    }

    .team-band {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 820px) {
    :root {
        --shell: calc(100vw - 32px);
        --header-h: 64px;
    }

    header.site-header {
        top: 8px;
        padding: 0 8px 0 12px;
    }

    .brand-logo-switch img {
        height: 32px;
    }

    .brand {
        gap: 12px;
    }

    .page-top {
        grid-template-columns: 1fr;
        align-items: start;
    }

    .content-layout {
        grid-template-columns: 1fr;
        padding-top: 24px;
    }

    /* Темы — одной прокручиваемой строкой, чтобы список статей был сразу виден */
    .sidebar,
    #categoryList {
        position: static;
        max-height: none;
        display: flex;
        flex-wrap: nowrap;
        gap: 6px;
        margin-inline: -16px;
        padding: 0 16px 6px;
        overflow-x: auto;
        scrollbar-width: none;
    }

    .sidebar::-webkit-scrollbar,
    #categoryList::-webkit-scrollbar {
        display: none;
    }

    .sidebar-title {
        display: none;
    }

    .sidebar-item,
    #categoryList .filter-tag {
        flex: 0 0 auto;
        white-space: nowrap;
    }

    .sidebar-item,
    #categoryList .filter-tag {
        width: auto;
        padding: 8px 14px;
        border: 1px solid var(--line);
        font-size: 0.88rem;
    }

    .entry-row {
        grid-template-columns: minmax(0, 1fr) 24px;
        gap: 6px 16px;
        padding: 22px 0;
    }

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

    .course-row {
        grid-template-columns: 1fr;
    }

    .course-copy {
        padding: 4px 8px 10px;
    }

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

@media (max-width: 640px) {
    .hero {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .hero-banner {
        min-height: 0;
        padding: 72px 22px 40px;
        border-radius: 18px;
    }

    .hero-banner h1 {
        font-size: clamp(2.1rem, 13cqi, 3.4rem);
    }

    .hero-tagline {
        font-size: clamp(1rem, 5.4cqi, 1.4rem);
    }

    .hero-chevrons {
        display: none;
    }

    .hero-deco-plus {
        top: 18px;
        left: 14px;
        width: 88px;
        height: 24px;
    }

    .section-card {
        min-height: 190px;
        padding: 22px;
        border-radius: 18px;
    }

    .section-card.courses-card {
        min-height: 230px;
    }

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

    .practice-grid .section-card {
        min-height: 170px;
    }

    .article-list,
.projects-grid,
.team-grid,
.wiki-grid {
        gap: 26px;
    }

    .article-tile {
        padding: 22px;
    }

    .tile-art {
        margin: 0 -22px -22px 0;
        height: 100px;
    }

    .tile-image {
        margin: -22px -22px 0;
    }

    .team-member {
        grid-template-columns: 1fr;
    }

    .member-photo {
        width: 120px;
    }

    .page-top h1 {
        font-size: clamp(2.6rem, 12vw, 3.4rem);
    }



    .footer-bottom {
        flex-direction: column;
    }
}



@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ---------- Мелкие дополнения ---------- */

#categoryList .filter-tag small {
    color: var(--muted);
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
}

#categoryList .filter-tag.active small {
    color: inherit;
}

/* Свой «Esc»/«/» вместо системного крестика в полях поиска */
.search-dialog-field input::-webkit-search-cancel-button,
.search-bar input::-webkit-search-cancel-button {
    -webkit-appearance: none;
    display: none;
}

/* Команда: группы активных и неактивных участников */
.team-group {
    padding-top: clamp(48px, 6vw, 72px);
}

.team-group .section-heading {
    margin-bottom: 4px;
}

.team-group .team-grid {
    padding-top: 28px;
}

/* ==========================================================================
   Страница курса (arduino.html, course.html) — по образцу разделов Сириус Wiki
   ========================================================================== */

/* Пока course.js перестраивает страницу, старую разметку не показываем */
.course-pending main {
    visibility: hidden;
}

.course-page .back-link {
    margin-bottom: 28px;
}

.lesson-nav {
    gap: 2px;
}

.lesson-link {
    justify-content: flex-start;
    align-items: baseline;
    gap: 12px;
    border-radius: 12px;
}

.lesson-link-num {
    flex: 0 0 1.6em;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.lesson-link-title {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.35;
}

.lesson-link.active .lesson-link-num {
    color: inherit;
}

.lesson-area {
    min-width: 0;
    max-width: 820px;
}

.lesson-progress {
    height: 3px;
    margin-bottom: 28px;
    background: var(--line);
}

.lesson-progress span {
    display: block;
    height: 100%;
    background: var(--accent);
    transition: width 0.3s;
}

.lesson-head {
    padding-bottom: 22px;
    margin-bottom: 8px;
    border-bottom: 2px solid var(--rule);
}

.lesson-head h2 {
    margin: 10px 0 0;
    font-size: clamp(1.9rem, 4vw, 3rem);
    line-height: 1.06;
    letter-spacing: -0.045em;
    font-weight: 850;
    text-wrap: balance;
}

/* Содержимое урока */
.lesson .section {
    padding: 28px 0;
    border-bottom: 1px solid var(--line);
}

.lesson .section:last-child {
    border-bottom: 0;
}

.lesson .section > h2 {
    margin-top: 0;
    font-size: 1.45rem;
}

.lesson .section > br {
    display: none;
}

.lesson img,
.lesson video,
.lesson iframe {
    max-width: 100%;
    height: auto;
    border: 1px solid var(--line);
    border-radius: 11px;
}

.code-example {
    margin: 1.2em 0;
}

.code-example pre {
    margin: 0;
    padding: 18px 20px;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: var(--code-bg);
    font-family: var(--mono);
    font-size: 0.86rem;
    line-height: 1.65;
    white-space: pre;
    overflow-x: auto;
}

/* Тест: каждый вопрос — плитка, ответы — строки-пилюли */
.quiz-question {
    margin: 0 0 14px;
    padding: 20px 22px;
    border: 1px solid var(--outline);
    background: var(--bg);
}

.quiz-question > p {
    margin: 0 0 12px;
    font-weight: 700;
}

.quiz-question label {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 4px 0 0;
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: 999px;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.quiz-question label:hover {
    border-color: var(--line-strong);
    background: var(--surface);
}

.quiz-question input[type="radio"] {
    accent-color: var(--accent);
    width: 16px;
    height: 16px;
    margin: 0;
}

.quiz-question label.is-correct {
    border-color: var(--accent);
    background: var(--accent-tint);
}

.quiz-question label.is-wrong {
    border-color: #e5675d;
    background: color-mix(in srgb, #e5675d 12%, transparent);
}

.quiz-result {
    margin: 14px 0 0;
    font-weight: 700;
}

/* Кнопки внутри уроков — как вторичные кнопки сайта */
.lesson button {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    margin-top: 8px;
    padding: 0 18px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
    font-weight: 700;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, color 0.2s;
}

.lesson button:hover {
    border-color: var(--accent);
    background: var(--accent);
    color: var(--on-accent);
}

.practice-area {
    display: grid;
    gap: 10px;
    margin-top: 14px;
}

.lesson textarea {
    width: 100%;
    min-height: 160px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: var(--code-bg);
    color: var(--text);
    font-family: var(--mono);
    font-size: 0.86rem;
    line-height: 1.6;
    resize: vertical;
}

.lesson textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.practice-area button {
    justify-self: start;
}

.preview-section:not(:empty) {
    padding: 16px 18px;
    border: 1px dashed var(--line-strong);
    border-radius: 11px;
    background: var(--surface);
}

/* Предыдущий / следующий урок */
.lesson-pager {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 40px;
    padding-top: 28px;
    border-top: 2px solid var(--rule);
}

.pager-link {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    font-weight: 700;
    line-height: 1.3;
    transition: border-color 0.2s, background 0.2s;
}

.pager-link small {
    display: block;
    margin-bottom: 2px;
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 600;
}

.pager-link.next {
    justify-content: space-between;
    text-align: right;
}

.pager-link:hover {
    border-color: var(--accent);
    background: var(--surface);
}

@media (max-width: 820px) {
    .lesson-nav .lesson-link {
        max-width: 240px;
    }

    .lesson-link-title {
        -webkit-line-clamp: 1;
    }

    .lesson-pager {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================================
   Олимпиады и конкурсы — таблица по образцу PDF-подборки
   ========================================================================== */

.page-top:has(> h1:only-child) {
    grid-template-columns: 1fr;
}

.page-top > h1 {
    margin-top: 0;
}

.olymp-controls {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    padding-top: 28px;
}

.olymp-controls .search-bar {
    margin: 0;
}

/* Переключатель направлений — как «По дням / По предметам» в вики */
.segmented {
    display: inline-flex;
    gap: 2px;
    padding: 5px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
}

.segmented button {
    min-height: 42px;
    padding: 0 18px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--muted);
    font-weight: 650;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.18s, color 0.18s;
}

.segmented button:hover {
    color: var(--text);
}

.segmented button.active {
    background: var(--accent);
    color: var(--on-accent);
}

.olympiads-page .filter-tags {
    margin-top: 16px;
}

.filter-tag small {
    margin-left: 6px;
    color: var(--muted);
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
}

.filter-tag.active small {
    color: inherit;
}

.olymp-table {
    margin-top: 12px;
    border-top: 2px solid var(--rule);
}

.olymp-group-title {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin: 0;
    padding: 26px 0 12px;
    border-bottom: 1px solid var(--line);
    font-size: 1.15rem;
    letter-spacing: -0.02em;
    font-weight: 800;
}

.olymp-group-title small {
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 600;
}

.olymp-row {
    display: grid;
    grid-template-columns: 2.6rem minmax(0, 1fr) 7.5rem minmax(0, 15rem);
    gap: 4px 20px;
    align-items: center;
    padding: 13px 4px;
    border-bottom: 1px solid var(--line);
    transition: background 0.18s;
}

.olymp-row:hover {
    background: var(--surface);
}

.olymp-n {
    color: var(--muted);
    font-family: var(--mono);
    font-size: 0.8rem;
}

.olymp-name strong {
    font-weight: 700;
}

.olymp-name span {
    color: var(--muted);
}

.olymp-type {
    justify-self: start;
    padding: 2px 9px;
    border: 1px solid var(--line);
    border-radius: 7px;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
}

/* Тип различаем оттенком, а не заливкой: метки не должны спорить с названием */
.olymp-type.is-rsosh {
    border-color: color-mix(in srgb, var(--plus) 35%, transparent);
    background: color-mix(in srgb, var(--plus) 12%, transparent);
    color: color-mix(in srgb, var(--plus) 80%, var(--text));
}

.olymp-type.is-olymp {
    border-color: color-mix(in srgb, var(--accent) 35%, transparent);
    background: color-mix(in srgb, var(--accent) 8%, transparent);
    color: color-mix(in srgb, var(--accent) 80%, var(--text));
}

.olymp-site {
    min-width: 0;
    overflow: hidden;
    color: var(--accent);
    font-family: var(--mono);
    font-size: 0.8rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.olymp-path {
    opacity: 0.6;
}

.olymp-row:hover .olymp-name strong {
    color: var(--accent);
}

.olymp-legend {
    margin: 24px 0 0;
    color: var(--muted);
    font-size: 0.86rem;
}

/* Главная: два направления олимпиад */
.direction-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.direction-grid .section-card {
    min-height: 240px;
}

@media (max-width: 820px) {
    .olymp-controls {
        grid-template-columns: 1fr;
    }

    .segmented {
        display: grid;
        grid-template-columns: 1fr 1fr;
        border-radius: 18px;
    }

    .segmented button {
        min-height: 46px;
        padding: 6px 10px;
        border-radius: 14px;
        white-space: normal;
        line-height: 1.2;
    }

    .olymp-row {
        grid-template-columns: 2.2rem minmax(0, 1fr);
        gap: 6px 12px;
        align-items: start;
    }

    .olymp-type,
    .olymp-site {
        grid-column: 2;
    }

    .olymp-n {
        padding-top: 3px;
    }

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


/* ==========================================================================
   Мобильная версия: доводка
   ========================================================================== */

.brand-mark {
    display: none;
}

@media (max-width: 820px) {
    .search-close .on-desktop {
        display: none;
    }

    .search-close .on-touch {
        display: inline;
    }

    .search-dialog {
        margin-top: 12px;
        max-height: calc(100vh - 24px);
    }

    .search-results {
        max-height: calc(100vh - 24px - 68px);
    }

    .search-bar kbd,
    .vim-btn kbd {
        display: none;
    }

    .search-bar input {
        padding-right: 20px;
    }

    .markdown-body {
        font-size: 1rem;
    }

    .markdown-body h1 { font-size: 1.6rem; }
    .markdown-body h2 { font-size: 1.35rem; }
    .markdown-body h3 { font-size: 1.15rem; }
}

@media (max-width: 560px) {
    /* В шапке вместо надписи FrogeeSoft — только лягушка, чтобы влезло название платформы */
    header.site-header .brand-logo-switch {
        display: none;
    }

    header.site-header .brand-mark {
        display: block;
        width: auto;
        height: 30px;
    }

    .brand {
        gap: 10px;
    }

    .brand-sep {
        height: 22px;
    }

    .brand-edu {
        font-size: 0.95rem;
    }

    .header-actions {
        gap: 6px;
    }

    .site-header .icon-button {
        width: 40px;
        height: 40px;
    }

    .menu-toggle span {
        left: 11px;
    }

    .menu-toggle span:first-child { top: 15px; }
    .menu-toggle span:last-child { top: 23px; }
    .menu-toggle[aria-expanded="true"] span:first-child,
    .menu-toggle[aria-expanded="true"] span:last-child { top: 19px; }

    /* Hero: кольца перекрывали кнопку */
    .hero-deco-rings {
        display: none;
    }

    .hero-actions .button {
        width: 100%;
        max-width: 280px;
    }

    /* Плитки статей компактнее */
    .article-tile {
        gap: 10px;
        padding: 20px;
    }

    .article-tile h3 {
        font-size: 1.08rem;
    }

    .article-tile p {
        -webkit-line-clamp: 2;
    }

    .tile-foot {
        min-height: 0;
        align-items: center;
    }

    .tile-foot .round-arrow {
        width: 40px;
        height: 40px;
    }

    .tile-art {
        height: 64px;
        margin: 0 -20px -20px 0;
    }

    .article-list {
        gap: 22px;
    }

    /* Темы: первые десять, остальные — по ссылке «Все темы» */
    .topic-cloud .topic:nth-child(n + 11) {
        display: none;
    }

    .topic {
        padding: 9px 14px;
        font-size: 0.92rem;
    }

    .section-card h2 {
        font-size: 1.35rem;
    }

    /* Футер в одну колонку, ссылки в две */
    .footer-grid {
        grid-template-columns: 1fr;
        gap: 32px;
    }

    .footer-col ul {
        grid-template-columns: 1fr 1fr;
        gap: 10px 16px;
    }
}
