/* Локальные шрифты. Раньше грузились с fonts.googleapis.com: 600 мс
   только на список начертаний, потом ещё десяток файлов с чужого
   домена — а до Google из России ходит через раз. Отсюда «сайт
   стал медленнее» при том, что страницы отдаются за 80 мс.

   Взято ровно то, что используется в CSS: Cormorant 400/500/600
   плюс курсивы 400/500, Plex Sans 400/500/600, Plex Mono 400.
   Лишние веса не качаем — каждый из них браузер тянул бы при
   первом заходе независимо от того, применяется он или нет.

   Кириллица и латиница разнесены через unicode-range: браузер
   берёт только нужное подмножество, файлы грузятся параллельно.
   Вьетнамский и греческий, которые отдавал Google, выброшены. */


@font-face {
    font-family: 'Cormorant Garamond';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/CormorantGaramond-400-cyrillic.7baf6d32c023.woff2") format('woff2');
    unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
    font-family: 'Cormorant Garamond';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/CormorantGaramond-400-latin.3007c5acec83.woff2") format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, 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: 'Cormorant Garamond';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url("../fonts/CormorantGaramond-500-cyrillic.4690c74113a7.woff2") format('woff2');
    unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
    font-family: 'Cormorant Garamond';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url("../fonts/CormorantGaramond-500-latin.d62e7df62dd3.woff2") format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, 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: 'Cormorant Garamond';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url("../fonts/CormorantGaramond-600-cyrillic.4af3d2101dbf.woff2") format('woff2');
    unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
    font-family: 'Cormorant Garamond';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url("../fonts/CormorantGaramond-600-latin.e15c62ae5a22.woff2") format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, 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: 'Cormorant Garamond';
    font-style: italic;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/CormorantGaramond-400i-cyrillic.0c5ae8dcc051.woff2") format('woff2');
    unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
    font-family: 'Cormorant Garamond';
    font-style: italic;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/CormorantGaramond-400i-latin.95f875e7d230.woff2") format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, 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: 'Cormorant Garamond';
    font-style: italic;
    font-weight: 500;
    font-display: swap;
    src: url("../fonts/CormorantGaramond-500i-cyrillic.93fa214c036f.woff2") format('woff2');
    unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
    font-family: 'Cormorant Garamond';
    font-style: italic;
    font-weight: 500;
    font-display: swap;
    src: url("../fonts/CormorantGaramond-500i-latin.cbd4c2248690.woff2") format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, 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: 'IBM Plex Sans';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/IBMPlexSans-400-cyrillic.6e0805c960c3.woff2") format('woff2');
    unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
    font-family: 'IBM Plex Sans';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/IBMPlexSans-400-latin.fd614a0cd4db.woff2") format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, 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: 'IBM Plex Sans';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url("../fonts/IBMPlexSans-500-cyrillic.6917011cb2c3.woff2") format('woff2');
    unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
    font-family: 'IBM Plex Sans';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url("../fonts/IBMPlexSans-500-latin.d8fb67ccd0a6.woff2") format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, 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: 'IBM Plex Sans';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url("../fonts/IBMPlexSans-600-cyrillic.12a1cae04317.woff2") format('woff2');
    unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
    font-family: 'IBM Plex Sans';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url("../fonts/IBMPlexSans-600-latin.36dda28b4dde.woff2") format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, 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: 'IBM Plex Mono';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/IBMPlexMono-400-cyrillic.cd34c7793d97.woff2") format('woff2');
    unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
    font-family: 'IBM Plex Mono';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/IBMPlexMono-400-latin.814fe1615d4d.woff2") format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* medlib — «Античный манускрипт»: базовая палитра и фундамент вёрстки */

:root {
    --bg: #F5F0E6;
    --text: #1A1A1A;
    --accent-1: #8B2E1F;
    --accent-2: #8B6F1F;
    --divider: #D4CCB8;
    --card-light: #EDE3CE;
    --card-dark: #D8C9A8;

    --serif: 'Cormorant Garamond', 'Georgia', serif;
    --sans: 'IBM Plex Sans', -apple-system, sans-serif;
    --mono: 'IBM Plex Mono', 'Courier New', monospace;

    --plate: #F5F0E6;
    --nav-bg: rgba(245, 240, 230, 0.85);
}

[data-theme="dark"] {
    --bg: #16120D;
    --text: #E8E0D2;
    --accent-1: #C0562F;
    --accent-2: #CF8C63;
    --divider: #3A3025;
    --card-light: #241D15;
    --card-dark: #1F1913;
    --plate: #EFE7D7;
    --nav-bg: rgba(22, 18, 13, 0.85);
}

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

html,
body,
h1, h2, h3, h4, h5, h6,
p,
figure {
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--sans);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.25s ease, color 0.25s ease;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--serif);
    font-weight: 600;
    letter-spacing: 0.01em;
}

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

img {
    max-width: 100%;
    display: block;
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
}

/* Верхняя навигация */

.nav {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg); /* fallback для браузеров без backdrop-filter */
    border-bottom: 1px solid var(--divider);
}

/* Переход по якорю (#subjects с главной) браузер отсчитывает от верха окна,
   не зная про sticky-шапку, — цель уезжает под неё и заголовок обрезается.
   Высоту шапки в число не зашить: на мобильном меню переносится на вторую
   строку и она вдвое выше. Реальное значение измеряет скрипт и кладёт
   в --nav-height; 80px — запасное значение, если скрипт не отработал. */
:root {
    --nav-height: 80px;
}

[id] {
    scroll-margin-top: calc(var(--nav-height) + 16px);
}

@supports (backdrop-filter: blur(10px)) or (-webkit-backdrop-filter: blur(10px)) {
    .nav {
        background: var(--nav-bg);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
    }
}

.nav__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
    padding: 1rem 2rem;
}

.nav__logo {
    font-family: var(--serif);
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
}

.nav__logo em {
    font-style: italic;
    color: var(--accent-1);
}

.nav__brand {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav__tagline {
    font-family: var(--sans);
    font-size: 10px;
    font-weight: 400;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--accent-2);
    opacity: 0.7;
    line-height: 1;
}

.nav__links {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    list-style: none;
    flex: 1;
}

.nav__links a {
    font-size: 0.95rem;
    letter-spacing: 0.02em;
    white-space: nowrap;
    transition: color 0.2s ease;
}

.nav__links a:hover {
    color: var(--accent-1);
}

.nav-link--primary {
    font-weight: 500;
    position: relative;
}

.nav-link--primary::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: -4px;
    height: 1.5px;
    background: var(--accent-1);
    opacity: 0.7;
}

.nav-link--primary:hover::after {
    opacity: 1;
}

.nav__search {
    display: flex;
    align-items: center;
    position: relative;
}

.nav__search input {
    font-family: var(--sans);
    font-size: 0.9rem;
    background: var(--card-light);
    border: 1px solid var(--divider);
    border-radius: 999px;
    padding: 0.5rem 1rem 0.5rem 40px;
    color: var(--text);
    min-width: 360px;
    width: clamp(360px, 30vw, 420px);
    outline: none;
    transition: border-color 0.2s ease;
}

.nav__search-icon {
    position: absolute;
    left: 14px;
    display: flex;
    color: var(--accent-2);
    pointer-events: none;
}

.nav__search input:focus {
    border-color: var(--accent-2);
}

.nav__search input::-webkit-search-cancel-button,
.nav__search input::-webkit-search-decoration {
    -webkit-appearance: none;
    appearance: none;
    display: none;
}

.nav__search input::-ms-clear {
    display: none;
}

.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: 1px solid var(--divider);
    border-radius: 50%;
    background: transparent;
    color: var(--accent-2);
    cursor: pointer;
    transition: border-color 0.2s ease, color 0.2s ease;
}

.theme-toggle:hover {
    border-color: var(--accent-1);
    color: var(--accent-1);
}

.theme-toggle .theme-icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .theme-icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .theme-icon-moon { display: block; }

/* Кнопка «наверх» — интерфейс, не содержание: гротеск нигде не звучит
   (иконка без текста), только токены поверхности/рамки/приглушённого
   текста, общие для обеих тем. */
.scroll-top-btn {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--card-light);
    border: 1px solid var(--divider);
    color: var(--accent-2);
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px);
    transition: opacity 0.2s ease, transform 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.scroll-top-btn:hover {
    border-color: var(--accent-1);
    color: var(--accent-1);
}

.scroll-top-btn.is-visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
    .scroll-top-btn {
        transition: none;
    }
}

/* Футер */

.footer {
    border-top: 1px solid var(--divider);
    margin-top: 4rem;
    padding: 2.5rem 0;
}

.footer__quote {
    font-family: var(--serif);
    font-style: italic;
    font-size: 1.25rem;
    color: var(--accent-1);
    text-align: center;
    margin-bottom: 1rem;
}

.footer__meta {
    font-family: var(--mono);
    font-size: 0.8rem;
    color: var(--text);
    opacity: 0.6;
    text-align: center;
    letter-spacing: 0.02em;
}

.footer__links {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-top: 1rem;
    list-style: none;
}

.footer__links a {
    font-size: 0.85rem;
    color: var(--text);
    opacity: 0.7;
    transition: opacity 0.2s ease, color 0.2s ease;
}

.footer__links a:hover {
    opacity: 1;
    color: var(--accent-1);
}

/* Hero */

.hero {
    position: relative;
    min-height: 85vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.hero-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 0.9fr);
    align-items: center;
    gap: clamp(2.5rem, 6vw, 6rem);
}

.hero-text {
    align-self: stretch;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.hero-engraving {
    display: flex;
    justify-content: center;
    margin: 0;
    flex-direction: column;
    align-items: center;
}

.hero-engraving img {
    width: 100%;
    max-width: 560px;
    height: auto;
    max-height: min(64vh, 660px);
    object-fit: contain;
}

.engraving-dark { display: none; }

[data-theme="light"] .engraving-light { mix-blend-mode: multiply; }

[data-theme="dark"] .engraving-light { display: none; }
[data-theme="dark"] .engraving-dark {
    display: block;
    mix-blend-mode: screen;
}

.engraving-credit {
    max-width: 560px;
    margin-top: 12px;
    font-family: var(--sans);
    font-size: 12px;
    line-height: 1.4;
    text-align: center;
    color: color-mix(in srgb, var(--text) 52%, transparent);
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 480ms cubic-bezier(0.4, 0, 0.2, 1),
                transform 480ms cubic-bezier(0.4, 0, 0.2, 1);
}

.hero-engraving:hover .engraving-credit,
.hero-engraving:focus-within .engraving-credit {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 820ms cubic-bezier(0.4, 0, 0.2, 1),
                transform 820ms cubic-bezier(0.4, 0, 0.2, 1);
}

.engraving-credit a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: color 200ms ease;
}

.engraving-credit a:hover,
.engraving-credit a:focus-visible {
    color: color-mix(in srgb, var(--accent-1) 85%, transparent);
}

@media (prefers-reduced-motion: reduce) {
    .engraving-credit,
    .hero-engraving:hover .engraving-credit,
    .hero-engraving:focus-within .engraving-credit {
        transition: none;
        transform: none;
    }
}

.hero-eyebrow {
    position: relative;
    display: inline-flex;
    align-items: center;
    font-family: var(--sans);
    font-size: 0.85rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent-2);
    padding-left: 3rem;
    margin-bottom: 2rem;
}

.hero-eyebrow::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    width: 2.25rem;
    height: 1px;
    background: var(--accent-2);
    transform: translateY(-50%);
}

.hero-quote {
    font-family: var(--serif);
    font-style: italic;
    font-weight: 500;
    font-size: clamp(2.625rem, 6vw, 5.25rem);
    line-height: 1.05;
    color: var(--text);
    margin-bottom: 1.5rem;
}

.hero-attribution {
    font-family: var(--sans);
    font-size: 0.85rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text);
    opacity: 0.6;
    margin-bottom: 2.5rem;
}

.hero-lead {
    font-family: var(--serif);
    font-size: clamp(1.375rem, 2vw, 1.625rem);
    line-height: 1.5;
    max-width: 640px;
    color: var(--text);
    opacity: 0.85;
    margin-bottom: 2.5rem;
}

.hero-cta-group {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.hero-cta {
    display: inline-block;
    font-family: var(--sans);
    font-size: 0.95rem;
    letter-spacing: 0.02em;
    padding: 0.9rem 1.75rem;
    border-radius: 2px;
    transition: background 0.25s ease, color 0.25s ease, border-color 0.25s ease, transform 0.2s ease;
}

.hero-cta.primary,
.hero-cta.primary:visited,
.hero-cta.primary:link,
.hero-cta.primary:active,
.hero-cta.primary:focus {
    background: var(--accent-1);
    color: var(--bg);
    border: 1px solid var(--accent-1);
}

.hero-cta.primary:hover {
    background: transparent;
    color: var(--accent-1);
    transform: translateY(-2px);
}

.hero-cta.secondary,
.hero-cta.secondary:visited,
.hero-cta.secondary:link {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--divider);
}

.hero-cta.secondary:hover {
    border-color: var(--accent-1);
    color: var(--accent-1);
    transform: translateY(-2px);
}

/* Section */

.section {
    padding: 120px 0;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 2rem;
    margin-bottom: 4rem;
}

.section-eyebrow {
    position: relative;
    display: inline-flex;
    align-items: center;
    font-family: var(--sans);
    font-size: 0.8rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent-2);
    padding-left: 2.5rem;
    margin-bottom: 0.75rem;
}

.section-eyebrow::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    width: 1.75rem;
    height: 1px;
    background: var(--accent-2);
    transform: translateY(-50%);
}

.section-title {
    font-family: var(--serif);
    font-size: 3.5rem;
    font-weight: 500;
}

.section-title em {
    font-style: italic;
    color: var(--accent-1);
}

.section-descr {
    font-family: var(--serif);
    font-style: italic;
    font-size: 1.15rem;
    opacity: 0.7;
    max-width: 340px;
    text-align: right;
}

/* Subjects grid */

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

.subject-card--morphological {
    --card-bg-light: #A8563A;
    --card-bg-dark: #8B4327;
    --card-text: #F5F0E6;
    --card-accent: #D4CCB8;
}

.subject-card--functional {
    --card-bg-light: #7A2E2E;
    --card-bg-dark: #5C1E1E;
    --card-text: #F5F0E6;
    --card-accent: #D4CCB8;
}

.subject-card--clinical {
    --card-bg-light: #4A6741;
    --card-bg-dark: #3A5033;
    --card-text: #F5F0E6;
    --card-accent: #D4CCB8;
}

.subject-card--micro {
    --card-bg-light: #3D5A80;
    --card-bg-dark: #2E4560;
    --card-text: #F5F0E6;
    --card-accent: #D4CCB8;
}

.subject-card--general {
    --card-bg-light: #4A4A4A;
    --card-bg-dark: #333333;
    --card-text: #F5F0E6;
    --card-accent: #D4CCB8;
}

.subject-card--surgical {
    --card-bg-light: #96662A;
    --card-bg-dark: #7A5220;
    --card-text: #F5F0E6;
    --card-accent: #D4CCB8;
}

.subject-card--diagnostic {
    --card-bg-light: #6B5580;
    --card-bg-dark: #4A3860;
    --card-text: #F5F0E6;
    --card-accent: #D4CCB8;
}

.subject-card--humanities {
    --card-bg-light: #6B5A45;
    --card-bg-dark: #52442F;
    --card-text: #F5F0E6;
    --card-accent: #D4CCB8;
}

[data-theme="dark"] .subject-card--morphological {
    --card-bg-light: #8E4326;
    --card-bg-dark: #6E321B;
}
[data-theme="dark"] .subject-card--functional {
    --card-bg-light: #6E2C2C;
    --card-bg-dark: #532020;
}
[data-theme="dark"] .subject-card--micro {
    --card-bg-light: #2F4770;
    --card-bg-dark: #223555;
}
[data-theme="dark"] .subject-card--clinical {
    --card-bg-light: #3E5636;
    --card-bg-dark: #2E4028;
}
[data-theme="dark"] .subject-card--surgical {
    --card-bg-light: #806029;
    --card-bg-dark: #61481E;
}
[data-theme="dark"] .subject-card--diagnostic {
    --card-bg-light: #573F62;
    --card-bg-dark: #412F49;
}
[data-theme="dark"] .subject-card--general {
    --card-bg-light: #383029;
    --card-bg-dark: #29231D;
}
[data-theme="dark"] .subject-card--humanities {
    --card-bg-light: #5A4630;
    --card-bg-dark: #443524;
}

[data-theme="dark"] .subject-card--morphological,
[data-theme="dark"] .subject-card--functional,
[data-theme="dark"] .subject-card--micro,
[data-theme="dark"] .subject-card--clinical,
[data-theme="dark"] .subject-card--surgical,
[data-theme="dark"] .subject-card--diagnostic,
[data-theme="dark"] .subject-card--general,
[data-theme="dark"] .subject-card--humanities {
    --card-text: #F0E8DA;
    --card-accent: #C0AE92;
}

.subject-card {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 320px;
    margin: 0 auto;
    aspect-ratio: 3 / 4;
    padding: 1.75rem;
    overflow: hidden;
    background: linear-gradient(160deg, var(--card-bg-light) 0%, var(--card-bg-dark) 100%);
    color: var(--card-text);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08), 0 8px 24px rgba(0, 0, 0, 0.12);
    transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1),
                box-shadow 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.subject-card::before,
.subject-card::after {
    content: '';
    position: absolute;
    pointer-events: none;
}

.subject-card::before {
    inset: 10px;
    border: 1px solid var(--card-text);
    opacity: 0.55;
}

.subject-card::after {
    inset: 14px;
    border: 1px solid var(--card-text);
    opacity: 0.35;
}

.subject-spine {
    position: absolute;
    top: 0;
    bottom: 0;
    right: 0;
    left: auto;
    width: 3px;
    background: linear-gradient(
        to left,
        rgba(0, 0, 0, 0.15) 0%,
        rgba(0, 0, 0, 0) 100%
    );
    border-right: none;
    pointer-events: none;
    z-index: 1;
}

.subject-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1), 0 16px 32px rgba(0, 0, 0, 0.18);
}

.subject-card--coming-soon {
    opacity: 0.45;
    filter: saturate(0.6);
    pointer-events: none;
    cursor: default;
}

.subject-coming-soon-badge {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    font-family: var(--sans);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: var(--card-text);
    background: rgba(0, 0, 0, 0.4);
    padding: 8px 18px;
    border-radius: 999px;
    z-index: 5;
    white-space: nowrap;
}

.subject-top {
    position: relative;
    z-index: 1;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.subject-number {
    font-family: var(--serif);
    font-style: italic;
    font-size: 1.75rem;
    color: var(--card-text);
    opacity: 0.7;
}

.subject-ornament {
    font-size: 1.1rem;
    color: var(--card-text);
    opacity: 0.5;
}

.subject-bottom {
    position: relative;
    z-index: 1;
    padding-top: 10%;
    min-height: 200px;
    text-align: center;
}

.subject-name {
    font-family: var(--serif);
    font-size: 2.5rem;
    font-weight: 500;
    line-height: 1.05;
    color: var(--card-text);
    margin-bottom: 0;
    overflow-wrap: break-word;
    hyphens: manual;
    -webkit-hyphens: manual;
}

.subject-name--long {
    font-size: 2.3rem;
    letter-spacing: -0.01em;
}
.subject-name--xlong { font-size: 1.75rem; }
.subject-name--narrow  { font-size: 2.25rem; }
.subject-name--narrower { font-size: 2.05rem; }

.subject-divider {
    width: 40px;
    height: 1px;
    margin: 48px auto 1rem;
    background: var(--card-accent);
    opacity: 0.6;
}

.subject-latin {
    font-family: var(--serif);
    font-style: italic;
    font-weight: 400;
    font-size: 20px;
    letter-spacing: 0.02em;
    color: var(--card-text);
    opacity: 0.8;
    margin-top: 8px;
    line-height: 1.3;
}

.subject-meta {
    font-family: var(--serif);
    font-style: italic;
    font-size: 1rem;
    color: var(--card-text);
    opacity: 0.7;
}

/* Subject detail page */

.subject-page--morphological {
    --page-accent: #A8563A;
}

.subject-page--functional {
    --page-accent: #7A2E2E;
}

.subject-page--clinical {
    --page-accent: #4A6741;
}

.subject-page--micro {
    --page-accent: #3D5A80;
}

.subject-page--general {
    --page-accent: #4A4A4A;
}

.subject-page--surgical {
    --page-accent: #96662A;
}

.subject-page--diagnostic {
    --page-accent: #6B5580;
}

.subject-page--humanities {
    --page-accent: #6B5A45;
}

[data-theme="dark"] .subject-page--morphological,
[data-theme="dark"] .subject-page--functional,
[data-theme="dark"] .subject-page--micro,
[data-theme="dark"] .subject-page--clinical,
[data-theme="dark"] .subject-page--surgical,
[data-theme="dark"] .subject-page--diagnostic,
[data-theme="dark"] .subject-page--general,
[data-theme="dark"] .subject-page--humanities {
    --page-accent: #C0562F;
}

.subject-page-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 60px;
    padding-top: 80px;
    padding-bottom: 80px;
}

.sidebar {
    min-width: 0;
    border-right: 1px solid var(--divider);
    padding-right: 32px;
    position: sticky;
    top: 96px;
    align-self: start;
}

.sidebar-eyebrow {
    font-family: var(--sans);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent-2);
    margin-bottom: 8px;
}

.sidebar-title {
    font-family: var(--serif);
    font-weight: 600;
    font-size: 32px;
    letter-spacing: -0.01em;
    color: var(--page-accent);
    margin-bottom: 32px;
    overflow-wrap: break-word;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
}

.sidebar-nav-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    margin-bottom: 2px;
    border-radius: 4px;
    font-family: var(--sans);
    font-size: 14px;
    color: var(--text);
    text-decoration: none;
    transition: background 0.15s ease;
}

.sidebar-nav-item:hover {
    background: rgba(139, 111, 31, 0.08);
}

.sidebar-nav-item.active {
    background: var(--page-accent);
    color: var(--bg);
    font-weight: 500;
}

.sidebar-nav-item .count {
    font-family: var(--mono);
    font-size: 12px;
    color: var(--page-accent);
    opacity: 0.7;
}

.sidebar-nav-item.active .count {
    color: var(--divider);
}

.sidebar-nav-group {
    display: flex;
    flex-direction: column;
    margin-left: 17px;
}

.sidebar-nav-group--sub {
    margin-left: 16px;
    border-left: 1px solid transparent;
}

.sidebar-nav-group--sub.active {
    border-left-color: color-mix(in srgb, var(--page-accent) 55%, transparent);
}

.sidebar-nav-group--sub .sidebar-nav-item.active {
    margin-left: 4px;
}

.sidebar-nav-item.child {
    font-size: 13px;
    opacity: 0.75;
}

.sidebar-nav-item.child.active {
    opacity: 1;
    background: var(--page-accent);
}

.sidebar-nav-item.grandchild {
    font-size: 12px;
    opacity: 0.65;
}

.sidebar-nav-item.grandchild.active {
    opacity: 1;
}

/* Выбранная подтема — контуром: заливка уже у темы над ней, вторая — перебор */
.sidebar-nav-group--sub .sidebar-nav-item.grandchild.active {
    background: transparent;
    color: var(--page-accent);
    box-shadow: inset 0 0 0 1px var(--page-accent);
}

.sidebar-nav-group--sub .sidebar-nav-item.grandchild.active .count {
    color: var(--page-accent);
}

.sidebar-group-title {
    font-family: var(--sans);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: var(--accent-2);
    padding: 8px 12px;
    margin-top: 16px;
}

.file-list-area {
    min-width: 0;
    padding-left: 20px;
}

.topics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
    margin-bottom: 40px;
}

.topic-tile {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 100px;
    padding: 20px;
    border: 1px solid var(--divider);
    border-radius: 4px;
    background: var(--card-light);
    text-decoration: none;
    color: inherit;
    transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.topic-tile:hover {
    border-color: var(--page-accent);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(26, 26, 26, 0.08);
}

/* В поиске карточки тем не привязаны к предмету странице — --page-accent
   там не задан, а цвет в этой системе означает предмет: разные предметы
   в одной выдаче не должны красить карточки в разные цвета. */
.search-topics .topic-tile:hover {
    border-color: var(--accent-2);
}

.topic-tile-name {
    font-family: var(--serif);
    font-weight: 500;
    font-size: 20px;
    line-height: 1.2;
    margin-bottom: 8px;
}

.topic-tile-path {
    font-family: var(--sans);
    font-size: 11px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--accent-2);
    margin-bottom: 8px;
}

.topic-tile-count {
    font-family: var(--sans);
    font-size: 13px;
    color: var(--accent-2);
}

.subtopics-section {
    margin-bottom: 48px;
}

.subtopics-section h2 {
    font-family: var(--serif);
    font-size: 24px;
    font-weight: 500;
    margin-bottom: 16px;
}

.breadcrumb {
    font-size: 13px;
    color: var(--accent-2);
    letter-spacing: 0.03em;
    margin-bottom: 16px;
}

.breadcrumb--mobile {
    display: none;
}

.breadcrumb a {
    color: var(--accent-2);
    text-decoration: none;
    transition: color 0.2s ease;
}

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

.breadcrumb .sep {
    margin: 0 8px;
    color: var(--page-accent);
    opacity: 0.5;
}

.file-list-header {
    font-family: var(--serif);
    font-weight: 500;
    font-size: 48px;
    letter-spacing: -0.01em;
    color: var(--page-accent);
    margin-bottom: 8px;
}

.file-list-subtitle {
    font-family: var(--serif);
    font-style: italic;
    font-size: 18px;
    color: var(--accent-2);
    margin-bottom: 40px;
}

.file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 12px;
    margin: 0 -12px;
    border-bottom: 1px solid var(--divider);
    border-radius: 4px;
    transition: background 0.2s ease, padding 0.2s ease;
    content-visibility: auto;
    contain-intrinsic-size: auto 99px;
}

@media (hover: hover) {
    .file-item:hover {
        background: rgba(139, 111, 31, 0.05);
        /* Сдвиг вправо на 8px, ширина под текст та же — длинное название не перескакивает на новую строку */
        padding-left: 20px;
        padding-right: 4px;
    }
}

.file-info {
    min-width: 0;
}

.file-title {
    font-family: var(--serif);
    font-weight: 500;
    font-size: 20px;
    color: var(--text);
    margin-bottom: 6px;
    overflow-wrap: break-word;
}

.file-meta {
    font-family: var(--sans);
    font-size: 13px;
    color: var(--accent-2);
}

/* Поиск, группа «По содержанию»: какие пункты оглавления совпали с запросом,
   каждый с новой строки. Пункт со страницей — ссылка: PDF откроется сразу
   на ней (#page=N). */
.file-hits {
    font-family: var(--sans);
    font-size: 13px;
    line-height: 1.45;
    margin-top: 8px;
    max-width: 640px;
    overflow-wrap: break-word;
}

.file-hits__label {
    color: var(--accent-2);
    margin: 0 0 2px;
}

.file-hits__list {
    list-style: none;
    margin: 0;
    padding: 0 0 0 14px;
    border-left: 1px solid var(--divider);
}

.file-hits__list li {
    padding: 2px 0;
}

.file-hits__item {
    color: var(--text);
}

a.file-hits__item {
    color: var(--page-accent, var(--accent-1));
    text-decoration: none;
}

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

.file-hits__page {
    color: var(--accent-2);
    margin-left: 8px;
    white-space: nowrap;
}

/* «Подробнее» — оглавление файла из закладок PDF (только у файлов, где оно есть) */
.file-more {
    font: inherit;
    color: var(--page-accent, var(--accent-1));
    background: none;
    border: none;
    padding: 6px 0;
    margin: -6px 0;
    cursor: pointer;
}

.file-more:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.file-more__arrow {
    display: inline-block;
    margin-left: 5px;
    vertical-align: 1px;
    transition: transform 0.2s ease;
}

.file-more[aria-expanded="true"] .file-more__arrow,
.file-more__arrow--up {
    transform: rotate(180deg);
}

.file-item.is-outline-open {
    align-items: flex-start;
}

.file-item.is-outline-open .file-info {
    flex: 1 1 auto;
}

.file-outline {
    margin-top: 14px;
    padding-left: 14px;
    border-left: 1px solid var(--divider);
    max-width: 640px;
    transition: height 0.3s ease, opacity 0.3s ease, margin-top 0.3s ease;
}

/* Плавное раскрытие: высоту меняет file-outline.js, здесь — что прячем на время */
.file-outline.is-animating {
    overflow: hidden;
}

.file-outline.is-collapsed {
    opacity: 0;
    margin-top: 0;
}

@media (prefers-reduced-motion: reduce) {
    .file-outline {
        transition: none;
    }
}

.file-outline__pages {
    font-family: var(--sans);
    font-size: 13px;
    color: var(--accent-2);
    margin: 0 0 8px;
}

.file-outline__list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.file-outline__item {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    font-family: var(--sans);
    font-size: 14px;
    line-height: 1.45;
    color: var(--text);
    padding: 3px 0;
}

.file-outline__item--l0 {
    font-weight: 500;
}

.file-outline__item--l0 + .file-outline__item--l0,
.file-outline__item--l1 + .file-outline__item--l0 {
    margin-top: 4px;
}

.file-outline__item--l1 {
    padding-left: 16px;
    font-size: 13px;
    font-weight: 400;
}

.file-outline__title {
    min-width: 0;
    overflow-wrap: break-word;
}

.file-outline__page {
    flex-shrink: 0;
    font-family: var(--mono);
    font-size: 12px;
    color: var(--accent-2);
}

.file-outline:not(.is-full) .file-outline__item--extra {
    display: none;
}

.file-outline__all {
    font-family: var(--sans);
    font-size: 13px;
    color: var(--page-accent, var(--accent-1));
    background: none;
    border: none;
    padding: 10px 0 2px;
    cursor: pointer;
}

.file-outline__all:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
}

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

.file-action {
    font-family: var(--sans);
    font-size: 13px;
    padding: 6px 14px;
    border-radius: 3px;
    border: 1px solid transparent;
    text-decoration: none;
    /* Мягкое наведение: заливка «Скачать» и рамка «Просмотр» проявляются плавно */
    transition: color 0.35s ease, background-color 0.35s ease, border-color 0.35s ease;
    cursor: pointer;
    white-space: nowrap;
}

.file-action--view {
    color: var(--accent-2);
    border-color: var(--divider);
}

.file-action--view:hover {
    color: var(--accent-2);
    border-color: var(--accent-2);
}

.file-action--download {
    color: var(--page-accent, var(--accent-1));
    border-color: var(--page-accent, var(--accent-1));
}

/* Контурная, как «Просмотр»; заливка цветом предмета — только при наведении */
.file-action--download:hover {
    background: var(--page-accent, var(--accent-1));
    color: var(--bg);
}

.file-favorite {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 6px;
    color: var(--accent-2);
    opacity: 0.6;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.file-favorite:hover {
    opacity: 1;
    color: var(--accent-1);
}

.file-favorite.is-active {
    opacity: 1;
    color: var(--accent-1);
}

/* Тип файла (PDF, DOCX…) — первым словом строки под названием, тем же цветом */
.file-type {
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.1em;
}

/* Favorites page */

.favorites-page {
    padding: 60px 0 100px;
    min-height: 60vh;
}

.favorites-list {
    display: flex;
    flex-direction: column;
}

.favorites-empty {
    font-family: var(--serif);
    font-style: italic;
    font-size: 20px;
    color: var(--accent-2);
    padding: 40px 0;
    text-align: center;
}

/* Search page */

.search-page {
    padding: 60px 0 100px;
    min-height: 60vh;
}

.search-summary {
    font-family: var(--serif);
    font-style: italic;
    font-size: 18px;
    color: var(--accent-2);
    margin-bottom: 40px;
}


.search-results-list {
    display: flex;
    flex-direction: column;
}

/* Плавное сворачивание: grid-template-rows 1fr → 0fr анимируется,
   display:none — нет. overflow:hidden у ребёнка обязателен, иначе
   содержимое вылезет за пределы схлопнутой строки грида; min-width:0 —
   та же защита от grid blowout на длинных именах файлов, что уже
   применялась у .sidebar/.file-list-area. */
.search-collapsible {
    display: grid;
    grid-template-rows: 1fr;
    transition: grid-template-rows 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.search-collapsible.is-collapsed {
    grid-template-rows: 0fr;
}

/* Длинные группы (51 учебник и т.п.) переключают высоту мгновенно —
   браузер иначе считает конечную высоту в первом кадре, и раскрытие
   читается как рывок. У коротких групп и «Предметы»/«Темы» этой
   проблемы нет — там transition остаётся. */
.search-collapsible--instant {
    transition: none;
}

.search-collapsible > * {
    overflow: hidden;
    min-width: 0;
    /* Резерв сверху под подъём карточки при hover (.subject-card:hover
       translateY(-6px), .topic-tile:hover translateY(-2px)) — без него
       overflow:hidden обрезает обложку по верхнему краю. Отрицательный
       margin компенсирует отступ снаружи, чтобы вертикальный ритм
       страницы не сдвинулся. Так же по бокам — под .file-item (margin
       0 -12px и сдвиг вправо при hover): иначе подсветка строки срезана
       по краям, а значок формата справа обрезается. */
    padding: 8px 12px 0;
    margin: -8px -12px 0;
    opacity: 1;
    transition: opacity 0.2s ease-out;
}

.search-collapsible.is-collapsed > * {
    opacity: 0;
    transition: opacity 0.15s ease-out;
}

@media (prefers-reduced-motion: reduce) {
    .search-collapsible {
        transition: none;
    }

    .search-collapsible > * {
        transition: none;
    }
}

.search-section-title {
    font-family: var(--serif);
    font-style: italic;
    font-weight: 500;
    font-size: 26px;
    letter-spacing: 0.02em;
    color: var(--accent-2);
    margin: 32px 0 24px;
    opacity: 0.8;
}

/* Заголовок группы материалов — тот же .search-section-title снаружи
   (h2), но кликабельный: текст наследует шрифт/цвет через
   font/color/letter-spacing: inherit, кнопка сама — только сброс. */
.search-group-toggle {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    width: 100%;
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    font: inherit;
    color: inherit;
    letter-spacing: inherit;
    text-align: left;
    cursor: pointer;
}

.search-group-chevron {
    flex: 0 0 auto;
    color: var(--accent-2);
    transition: transform 0.2s ease;
}

.search-group-toggle[aria-expanded="true"] .search-group-chevron {
    transform: rotate(180deg);
}

.search-subjects {
    margin-bottom: 48px;
}

.search-subjects + .search-section-title,
.search-subjects + .search-topics {
    margin-top: 48px;
}

.search-subjects .subjects-grid {
    gap: 24px;
    /* Наследует template-columns из основного правила .subjects-grid */
}

.search-topics {
    margin-bottom: 48px;
}

.search-topics + .search-section-title {
    margin-top: 48px;
}

.search-empty {
    padding: 0 0 96px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.search-empty-quote {
    font-family: var(--serif);
    font-style: italic;
    font-weight: 400;
    font-size: clamp(40px, 4.5vw, 60px);
    line-height: 1.05;
    letter-spacing: -0.01em;
    color: var(--accent-1);
}

.search-empty-attribution {
    margin-top: -6px;
    font-family: var(--sans);
    font-size: 12px;
    font-weight: 400;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--accent-2);
}

.search-empty-hint {
    font-family: var(--serif);
    font-size: 19px;
    line-height: 1.5;
    color: var(--accent-2);
    max-width: 520px;
    margin-top: 24px;
    /* Строки ровные по длине — без одинокого слова в конце */
    text-wrap: balance;
}

/* Страница «не найдено» (templates/404.html): вся область страницы в двойной
   тонкой рамке, как у выпусков MedLib; цвета сайта — днём и ночью свои. */
.not-found {
    padding: 40px 0 64px;
}

.not-found__card {
    position: relative;
    min-height: 62vh;
    padding: 64px 32px;
    justify-content: center;
    border: 1px solid var(--accent-1);
    color: var(--text);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.not-found__card::before {
    content: "";
    position: absolute;
    inset: 6px;
    border: 1px solid var(--accent-1);
    pointer-events: none;
}

.not-found__code {
    font-family: var(--mono);
    font-size: 12px;
    letter-spacing: 0.3em;
    color: var(--accent-2);
}

.not-found__text {
    font-family: var(--serif);
    font-size: 19px;
    line-height: 1.5;
    color: var(--accent-2);
    max-width: 400px;
    margin-top: 8px;
    text-wrap: balance;
}

.not-found__home {
    margin-top: 8px;
    font-family: var(--sans);
    font-size: 14px;
    padding: 10px 22px;
    border: 1px solid var(--accent-1);
    border-radius: 3px;
    color: var(--accent-1);
    text-decoration: none;
    transition: color 0.35s ease, background-color 0.35s ease;
}

.not-found__home:hover {
    background: var(--accent-1);
    color: var(--bg);
}

@media (max-width: 640px) {
    .not-found {
        padding: 20px 0 40px;
    }

    .not-found__card {
        min-height: 70vh;
        padding: 44px 20px;
    }
}

/* На телефоне две фразы не помещаются по строке — пусть текст течёт сам */
@media (max-width: 560px) {
    .search-empty-hint__br {
        display: none;
    }
}

.search-empty-hint em {
    color: var(--accent-1);
}

/* «Не нашли? Напишите» — под подсказкой пустой выдачи */
.search-feedback {
    width: 100%;
    max-width: 440px;
    margin-top: 4px;
}

.search-feedback__row {
    display: flex;
    gap: 8px;
    transition: opacity 0.35s ease;
}

.search-feedback__row input {
    flex: 1;
    min-width: 0;
    font-family: var(--sans);
    font-size: 0.9rem;
    background: transparent;
    border: 1px solid var(--divider);
    border-radius: 999px;
    padding: 0.55rem 1.1rem;
    color: var(--text);
    outline: none;
    transition: border-color 0.2s ease;
}

.search-feedback__row input:focus {
    border-color: var(--accent-2);
}

.search-feedback__row .file-action {
    font-size: 14px;
    border-radius: 999px;
    padding: 0.55rem 1.2rem;
}

/* Кнопка — рамкой, как поле; при наведении рамка мягко краснеет */
.search-feedback__send {
    background: transparent;
    color: var(--accent-1);
    border-color: var(--divider);
    transition: border-color 0.4s ease, opacity 0.3s ease;
}

.search-feedback__send:hover,
.search-feedback__send:focus-visible {
    border-color: var(--accent-1);
}

.search-feedback__send:disabled {
    cursor: default;
    opacity: 0.6;
}

/* Отправка: поле с кнопкой тихо гаснут, «Спасибо» проявляется снизу */
.search-feedback--leaving .search-feedback__row {
    opacity: 0;
}

.search-feedback--sent .search-feedback__note {
    animation: search-feedback-in 0.6s ease both;
}

.search-feedback__note a {
    color: var(--accent-1);
    text-decoration: underline;
    text-decoration-color: currentColor;
    text-underline-offset: 3px;
}

/* Та же форма в разделе «Чего не хватает?» страницы «О библиотеке» */
.about-feedback {
    max-width: 520px;
    margin: 8px 0 24px;
}

/* Фокус на ответе нужен только экранной читалке — рамку не рисуем */
.search-feedback__note:focus {
    outline: none;
}

@keyframes search-feedback-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .search-feedback__row,
    .search-feedback__send { transition: none; }
    .search-feedback--sent .search-feedback__note { animation: none; }
}

/* iPhone увеличивает страницу при фокусе на поле мельче 16px */
@media (max-width: 640px) {
    .search-feedback__row input {
        font-size: 16px;
    }
}

.search-feedback__note:empty {
    display: none;
}

/* Две ступени селектора — чтобы перебить .about-section p на странице «О библиотеке» */
.search-feedback .search-feedback__note {
    font-family: var(--sans);
    font-size: 12px;
    letter-spacing: 0.08em;
    color: var(--accent-2);
    opacity: 0.8;
    margin-top: 10px;
}

.search-feedback--sent .search-feedback__note {
    font-family: var(--serif);
    font-size: 19px;
    letter-spacing: 0;
    color: var(--accent-1);
    opacity: 1;
}

.search-feedback__trap {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.search-page--empty .section-header {
    justify-content: center;
    text-align: center;
    margin-bottom: 2rem;
}

.search-page--empty .section-header > div {
    text-align: center;
}

.search-page--empty .section-title {
    text-align: center;
}

/* Планшет горизонтально и небольшие ноутбуки: шапка в одну строку
   не помещалась, кнопка темы уходила за правый край. */
@media (min-width: 901px) and (max-width: 1100px) {
    .nav__tagline {
        display: none;
    }

    .nav__inner {
        gap: 1.25rem;
    }

    .nav__links {
        gap: 1.5rem;
    }

    .nav__search input {
        min-width: 0;
        width: 260px;
    }
}

@media (max-width: 900px) {
    .container {
        padding: 0 1.25rem;
    }

    .nav__tagline {
        display: none;
    }

    .subject-page-layout {
        grid-template-columns: 1fr;
        padding-top: 40px;
        padding-bottom: 40px;
    }

    .sidebar {
        border-right: none;
        border-bottom: 1px solid var(--divider);
        padding-right: 0;
        padding-bottom: 24px;
        position: static;
    }

    .file-list-area {
        padding-left: 0;
    }

    .nav__inner {
        flex-wrap: wrap;
        align-items: flex-start;
        padding: 1rem 1.25rem;
        row-gap: 1rem;
    }

    .nav__brand {
        align-items: flex-start;
    }

    .nav__links {
        order: 3;
        width: 100%;
        justify-content: flex-start;
        padding-left: 0;
        margin-left: 0;
        gap: 20px;
        /* flex: 1 обнуляет width — без этого на планшете меню
           вставало в первую строку рядом с поиском. */
        flex-basis: 100%;
    }

    .nav__search {
        order: 2;
        margin-left: auto;
    }

    .nav__search input {
        min-width: 0;
        width: 160px;
    }

    .theme-toggle {
        order: 2;
    }

    .footer__links {
        flex-wrap: wrap;
        gap: 1rem 1.5rem;
    }

    .hero {
        min-height: auto;
        padding: 4rem 0;
    }

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

    .hero-engraving {
        display: none;
    }

    .hero-cta-group {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .section {
        padding: 64px 0;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .section-descr {
        max-width: none;
        text-align: left;
    }

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

@media (max-width: 640px) {
    /* Зона нажатия «Подробнее» на телефоне — ~44px по высоте, строка при этом не растёт */
    .file-more {
        padding: 12px 0;
        margin: -12px 0;
    }

    /* Четыре пункта меню в одну строку от края до края. */
    .nav__links {
        justify-content: space-between;
        gap: 8px;
    }

    /* На узких экранах (320–360px) кегль чуть уменьшается, чтобы
       «Канал» не упирался в край. */
    .nav__links a {
        font-size: clamp(0.8rem, 4.1vw, 0.95rem);
    }

    .hero {
        padding: 40px 0 60px;
    }

    .hero-quote {
        font-size: clamp(56px, 14vw, 88px);
    }

    .hero-attribution {
        font-size: 11px;
        margin-top: 8px;
    }

    .hero-lead {
        font-size: 1.25rem;
        margin: 24px 0 32px;
        line-height: 1.55;
    }

    .section-title {
        font-size: clamp(34px, 9vw, 64px);
        line-height: 1.05;
        letter-spacing: -0.02em;
        /* Длинные термины («Офтальмология») не влезают в строку на узких
           экранах, а Cormorant не переносит внутри слова — разрешаем явно,
           иначе слово выходит за край экрана. */
        overflow-wrap: break-word;
        hyphens: auto;
    }

    .subjects-grid {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    .search-subjects .subject-card {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        aspect-ratio: 3 / 4;
    }

    /* Только названия в 12-13 букв («Офтальмология», «Микробиология»,
       «Эпидемиология», «Нутрициология») — на узкой мобильной обложке
       они не помещались в строку и рвались посреди слова. Переносить
       нельзя: одна буква «я» на второй строке хуже, чем есть.
       Остальные обложки сохраняют исходный кегль 2.5rem.
       Базовые правила для --narrow/--narrower объявлены вне медиазапроса
       (рядом с --long): класс проставляется фильтром всегда, и на десктопе
       кегль тоже должен уменьшаться. Здесь значения продублированы явно —
       если мобильные понадобится развести с десктопными, менять тут. */
    .subject-name--narrow {
        font-size: 2.25rem;
    }

    .subject-name--narrower {
        font-size: 2.05rem;
    }


    .subject-page-layout {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    .breadcrumb--mobile {
        display: block;
        grid-column: 1 / -1;
    }

    .file-list-area .breadcrumb {
        display: none;
    }

    .sidebar {
        width: 100%;
    }

    .sidebar-eyebrow {
        display: none;
    }

    .sidebar-title {
        font-size: 28px;
    }

    .sidebar-group-title,
    .sidebar-nav-group {
        display: none;
    }

    .file-list-header {
        display: none;
    }

    .file-list-header.page-title--topic {
        display: block;
        font-size: 26px;
    }

    .file-list-subtitle {
        margin-bottom: 16px;
    }

    .file-item {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .file-info {
        width: 100%;
    }

    .file-actions {
        display: grid;
        grid-template-columns: 1fr 1fr 44px;
        width: 100%;
        gap: 8px;
    }

    .file-action--view {
        grid-column: 1;
    }

    .file-action--download {
        grid-column: 2;
    }

    /* Нет «Просмотр» (не PDF и не видео) — «Скачать» на обе колонки, без пустого места слева */
    .file-action--download:first-child {
        grid-column: 1 / 3;
    }

    .file-action--view,
    .file-action--download {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .file-favorite {
        grid-column: 3;
        min-width: 44px;
        min-height: 44px;
    }

    .scroll-top-btn {
        right: 16px;
        bottom: calc(16px + env(safe-area-inset-bottom));
    }
}

/* About page */

.about-page {
  max-width: 720px;
  margin: 0 auto;
  padding: 80px 0 120px;
}

.about-header {
  margin-bottom: 72px;
}

.about-eyebrow {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: var(--accent-1);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.about-eyebrow::before {
  content: '';
  width: 24px;
  height: 1px;
  background: var(--accent-1);
}

.about-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(48px, 6vw, 72px);
  line-height: 1;
  letter-spacing: -0.015em;
  color: var(--text);
}

.about-title em {
  font-style: italic;
  font-weight: 400;
  color: var(--accent-1);
}

.about-section {
  margin-bottom: 56px;
}

.about-section-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 28px;
  letter-spacing: -0.01em;
  color: var(--text);
  margin-bottom: 20px;
}

.about-section p {
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.6;
  /* Без одинокого слова в последней строке абзаца */
  text-wrap: pretty;
  color: var(--text);
  margin-bottom: 16px;
}

.about-section p:last-child {
  margin-bottom: 0;
}

.about-lead {
  font-family: var(--serif) !important;
  font-style: italic;
  font-size: 24px !important;
  color: var(--accent-1) !important;
  margin-bottom: 24px !important;
  line-height: 1.4 !important;
}

.about-link {
  color: var(--accent-1);
  /* Как ссылка «канале» на пустом поиске: тонкое подчёркивание цветом текста */
  text-decoration: underline;
  text-decoration-color: currentColor;
  text-underline-offset: 3px;
  transition: opacity 0.15s;
}

.about-link:hover {
  opacity: 0.7;
}

/* Телефон: первый экран не пустой — отступы страницы «О библиотеке» на треть меньше */
@media (max-width: 640px) {
  .about-page {
    padding: 48px 0 80px;
  }

  .about-header {
    margin-bottom: 44px;
  }

  .about-section {
    margin-bottom: 40px;
  }
}

.about-disclaimer {
  margin-top: 80px;
  padding-top: 32px;
  border-top: 1px solid var(--divider);
}

.about-disclaimer p {
  font-family: var(--serif);
  font-size: 15px;
  line-height: 1.6;
  color: var(--accent-2);
  font-style: italic;
}

@media (prefers-reduced-motion: no-preference) {
    ::view-transition-old(root) {
        animation: none;
    }
    ::view-transition-new(root) {
        animation: reveal-circle 1.15s cubic-bezier(0.25, 0.6, 0.3, 1);
        z-index: 2;
    }
    @keyframes reveal-circle {
        from {
            clip-path: circle(0 at var(--reveal-x) var(--reveal-y));
        }
        to {
            clip-path: circle(var(--reveal-r) at var(--reveal-x) var(--reveal-y));
        }
    }
}

.theme-switching body {
    transition: none;
}

/* «Результаты по за-просу»: в заголовке поиска слова не рвём дефисом.
   Специфичность (0,2,0) перебивает hyphens: auto у .section-title на телефоне. */
.section-title.search-title {
    hyphens: manual;
    -webkit-hyphens: manual;
}

/* Узкие телефоны (≤420px): логотип, поиск и кнопка темы в одном ряду.
   Стоит в конце файла, чтобы перебивать правила блока 640px. */
@media (max-width: 420px) {
    .nav__inner {
        column-gap: 12px;
    }

    .nav__search input {
        width: 140px;
    }

    .file-actions {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 36px;
        gap: 6px;
    }

    .file-action--view,
    .file-action--download {
        padding: 6px;
        font-size: 12px;
    }

    .file-favorite {
        grid-column: 3;
        grid-row: 1;
        min-width: 36px;
    }
}

/* Планшет вертикально (iPad 768–820): меню в одной строке с логотипом,
   поиском и кнопкой темы — как на компьютере. Уже 720px не помещается. */
@media (min-width: 720px) and (max-width: 900px) {
    .nav__inner {
        align-items: center;
        column-gap: 16px;
    }

    .nav__links {
        order: 2;
        flex: 1;
        flex-basis: auto;
        width: auto;
        justify-content: center;
    }

    .nav__search {
        order: 3;
        margin-left: 0;
    }

    .nav__search input {
        width: 180px;
    }

    .theme-toggle {
        order: 4;
    }
}

/* Телефон: файлы ближе к верху экрана (дизайн-аудит 01.11, п. 2).
   Разделы предмета — чипами в несколько строк вместо столбика,
   меньше пустоты над заголовками страницы предмета и поиска. */
@media (max-width: 640px) {
    .subject-page-layout {
        padding-top: 20px;
        gap: 16px;
    }

    .sidebar {
        padding-bottom: 16px;
    }

    .sidebar-title {
        margin-bottom: 14px;
    }

    .sidebar-nav {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
    }

    .sidebar-nav > .sidebar-nav-item {
        gap: 8px;
        margin: 0;
        padding: 8px 12px;
        border: 1px solid var(--divider);
        border-radius: 999px;
        font-size: 13px;
    }

    .sidebar-nav > .sidebar-nav-item.active {
        border-color: var(--page-accent);
    }

    .search-page {
        padding-top: 28px;
    }

    /* Пустой поиск не трогаем — там свой отступ под формой «Не нашли?» */
    .search-page:not(.search-page--empty) .section-header {
        margin-bottom: 20px;
    }

    .search-summary {
        margin-bottom: 20px;
    }

    .search-section-title {
        margin-top: 16px;
        margin-bottom: 8px;
        line-height: 1.2;
    }

    /* Первый файл группы — ближе к её заголовку; черта над ним остаётся разделителем */
    .search-results-list > .file-item:first-child {
        padding-top: 10px;
    }

    /* Плитки тем и серий — ниже: название и счётчик без пустого поля */
    .topics-grid {
        gap: 10px;
        margin-bottom: 24px;
    }

    .topic-tile {
        min-height: 0;
        padding: 12px 16px;
    }

    .topic-tile-name {
        font-size: 18px;
        margin-bottom: 4px;
    }

    /* Шапка закреплена и видна всегда — меньше воздуха вокруг строки меню */
    .nav__inner {
        padding-top: 14px;
        padding-bottom: 14px;
        row-gap: 14px;
    }

    .nav__links {
        margin: 0;
    }

    .breadcrumb--mobile {
        margin-bottom: 0;
    }

    /* Страница темы: «12 материалов» справа от названия, если влезает в строку.
       Длинное название занимает всю ширину, число тогда — под ним слева,
       как раньше (space-between ставит одиночный элемент строки к левому краю). */
    .file-list-area:has(> .page-title--topic) {
        display: flex;
        flex-wrap: wrap;
        align-items: baseline;
        justify-content: space-between;
        column-gap: 24px;
    }

    .file-list-area:has(> .page-title--topic) > * {
        flex: 0 0 100%;
        min-width: 0;
    }

    .file-list-area > .page-title--topic {
        flex: 0 1 auto;
        margin-bottom: 8px;
    }

    .file-list-area > .page-title--topic + .file-list-subtitle {
        flex: 0 0 auto;
        margin-bottom: 16px;
        white-space: nowrap;
    }

    /* Без подтем: от «N материалов» до первого файла — ближе */
    .file-list-subtitle + .file-list > .file-item:first-child {
        padding-top: 8px;
    }

    /* «Подтемы» — подписью к плиткам, как «ТЕМЫ» в боковом меню на компьютере,
       чтобы не спорить с названием темы */
    .subtopics-section h2 {
        font-family: var(--sans);
        font-size: 13px;
        font-weight: 500;
        text-transform: uppercase;
        letter-spacing: 0.2em;
        color: var(--accent-2);
        margin-bottom: 10px;
    }

    /* От плиток подтем до первого файла — без лишней пустоты */
    .subtopics-section {
        margin-bottom: 8px;
    }

    .subtopics-section .topics-grid {
        margin-bottom: 0;
    }
}

/* ===== Вход и кабинет (accounts, бета 07.11) =====
   Кнопка кабинета — в стиле переключателя темы, сразу после него;
   «Войти» — тихая текстовая кнопка. Страницы входа — на каркасе .not-found. */
.account-entry {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    margin-left: 8px;
    border: 1px solid var(--divider);
    border-radius: 50%;
    color: var(--accent-1);
    flex-shrink: 0;
    transition: border-color 0.35s ease, background-color 0.35s ease;
}

.account-entry:hover {
    border-color: var(--accent-1);
}

.account-login {
    margin-left: 12px;
    font-family: var(--sans);
    font-size: 14px;
    color: var(--accent-1);
    text-decoration: none;
    padding: 7px 14px;
    border: 1px solid var(--accent-1);
    border-radius: 999px;
    white-space: nowrap;
    flex-shrink: 0;
    transition: color 0.35s ease, background-color 0.35s ease;
}

.account-login:hover {
    background: var(--accent-1);
    color: var(--bg);
}

/* Клавиатура: тонкая обводка цветом сайта вместо синей системной.
   После закрытия окна мышью фокус возвращается без обводки (account-modal.js). */
.account-login:focus,
.account-entry:focus { outline: none; }
.account-login:focus-visible,
.account-entry:focus-visible {
    outline: 1px solid var(--accent-1);
    outline-offset: 2px;
}
.account-login.acc-quiet-focus,
.account-entry.acc-quiet-focus { outline: none; }

/* Компьютер: кнопка темы ровно посередине между поиском и «Войти»/кабинетом —
   слева и справа один и тот же gap шапки, без добавочного отступа. */
@media (min-width: 901px) {
    .account-login,
    .account-entry { margin-left: 0; }
}

/* Телефон и планшет: «Войти» / кабинет — сразу после кнопки темы, в её ряду;
   поиск сжимается под оставшееся место, и ряд не переносится. Правила
   с :has() срабатывают только когда кнопка есть (бета или вошедший) —
   без беты шапка прежняя. */
@media (max-width: 900px) {
    .account-login,
    .account-entry { order: 2; margin-left: 0; }
    .account-login { display: inline-flex; align-items: center; height: 38px; padding: 0 14px; }
    .account-entry { width: 38px; height: 38px; }
    /* Основа 0: ряд не переносится, поиск растёт до своей обычной ширины. */
    .nav__inner:has(.account-login, .account-entry) .nav__search { flex: 1 1 0; min-width: 0; max-width: 160px; }
    .nav__inner:has(.account-login, .account-entry) .nav__search input { width: 100%; }
}
@media (max-width: 640px) {
    .nav__inner:has(.account-login, .account-entry) { column-gap: 12px; }
}
@media (max-width: 420px) {
    .nav__inner:has(.account-login, .account-entry) { column-gap: 10px; }
    .nav__inner:has(.account-login, .account-entry) .nav__search { max-width: 140px; }
    .account-login { padding: 0 12px; }
}
@media (min-width: 720px) and (max-width: 900px) {
    .account-login,
    .account-entry { order: 5; }
    /* Меню растёт вместе с поиском — поиску большая доля, иначе он схлопывается. */
    .nav__inner:has(.account-login, .account-entry) .nav__search { flex-grow: 4; max-width: 180px; }
}

.account-welcome__form {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    max-width: 460px;
    margin-top: 8px;
    text-align: left;
}

.account-welcome__check {
    align-self: stretch;
    display: flex;
    gap: 10px;
    align-items: flex-start;
    font-family: var(--sans);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    cursor: pointer;
}

.account-welcome__check input {
    margin-top: 3px;
    accent-color: var(--accent-1);
}

.account-welcome__check a {
    color: var(--accent-1);
}

.account-welcome__error {
    font-family: var(--sans);
    font-size: 14px;
    color: var(--accent-1);
}

.account-link-button {
    background: none;
    border: none;
    font-family: var(--sans);
    font-size: 13px;
    color: var(--text);
    text-decoration: underline;
    cursor: pointer;
}

/* ===== Окна входа и кабинета (accounts, макет A — mock/cabinet/) =====
   Окно поверх затемнённого сайта: тёплая вуаль чуть светлее макета, лёгкий
   blur, появление fade+scale. Только токены :root — ночная тема пересчитывается
   сама. Мелкий текст не меньше 13px и на основе --text (не бледное золото). */
.acc-modal {
    --acc-radius: 18px;
    --acc-radius-sm: 12px;
    --acc-ease: cubic-bezier(.22, .8, .24, 1);
    --acc-veil: color-mix(in srgb, color-mix(in srgb, var(--text) 78%, var(--accent-2)) 40%, transparent);
    --acc-line: color-mix(in srgb, var(--divider) 70%, var(--bg));
    --acc-side: color-mix(in srgb, var(--card-light) 55%, var(--bg));
    --acc-hover: color-mix(in srgb, var(--accent-2) 7%, transparent);
    --acc-muted: color-mix(in srgb, var(--text) 74%, var(--bg));
    --acc-shadow:
        0 0 0 1px var(--acc-line),
        0 2px 6px color-mix(in srgb, var(--text) 8%, transparent),
        0 24px 64px -12px color-mix(in srgb, var(--text) 38%, transparent);
    position: fixed;
    inset: 0;
    z-index: 200;
    display: grid;
    /* Дорожка сетки = свободное место: max-width/max-height: 100% у окна
       считаются от экрана, и кабинет 1000px не вылезает на планшете. */
    grid-template: minmax(0, 1fr) / minmax(0, 1fr);
    place-items: center;
    padding: 40px;
    visibility: hidden;
    pointer-events: none;
    transition: visibility 0s .22s;
}
.acc-modal.is-open {
    visibility: visible;
    pointer-events: auto;
    transition: none;
}
html.acc-locked { overflow: hidden; }
/* Ночью --text светлый: вуаль и тень от него засветились бы — берём тёмные. */
[data-theme="dark"] .acc-modal {
    color-scheme: dark;   /* галочки и поля браузера — тёмные, без белых квадратов */
    --acc-veil: color-mix(in srgb, var(--bg) 72%, transparent);
    --acc-shadow:
        0 0 0 1px var(--acc-line),
        0 24px 64px -12px rgba(0, 0, 0, .7);
}

.acc-modal__veil {
    position: absolute;
    inset: 0;
    background: var(--acc-veil);
    backdrop-filter: blur(4px) saturate(.92);
    -webkit-backdrop-filter: blur(4px) saturate(.92);
    opacity: 0;
    transition: opacity .3s var(--acc-ease);
}
.acc-modal.is-open .acc-modal__veil { opacity: 1; }

.acc-modal__win {
    position: relative;
    max-width: 100%;
    max-height: 100%;
    background: var(--bg);
    color: var(--text);
    border-radius: var(--acc-radius);
    box-shadow: var(--acc-shadow);
    overflow: hidden;
    opacity: 0;
    transform: scale(.98) translateY(6px);
    transition: opacity .2s ease, transform .2s ease;
}
.acc-modal.is-open .acc-modal__win {
    opacity: 1;
    transform: none;
    transition: opacity .3s var(--acc-ease), transform .36s var(--acc-ease);
}
/* Само окно получает фокус программно — без обводки (иначе рамка «в воздухе»
   на 2px от края). Специфичнее, чем .acc-modal :focus-visible ниже. */
.acc-modal .acc-modal__win:focus,
.acc-modal .acc-modal__win:focus-visible { outline: none; }

.acc-modal__close {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 9;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--text);
    opacity: .6;
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: background .2s ease, opacity .2s ease;
}
.acc-modal__close:hover { background: var(--acc-hover); opacity: 1; }

.acc-modal :focus { outline: none; }
.acc-modal :focus-visible {
    outline: 1px solid var(--accent-1);
    outline-offset: 2px;
}

/* Общие элементы окон */
.acc-h {
    font: 500 40px/1.05 var(--serif);
    color: var(--text);
    margin: 0 0 10px;
}
.acc-h em { font-style: italic; color: var(--accent-1); }
.acc-lead {
    font: 15px/1.55 var(--sans);
    color: var(--acc-muted);
    margin: 0;
    max-width: 520px;
}
.acc-error { color: var(--accent-1); }
p.acc-error { font: 14px/1.5 var(--sans); margin: 0; }

.acc-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 38px;
    padding: 0 18px;
    border-radius: 999px;
    border: 1px solid transparent;
    font: 500 14px/1 var(--sans);
    cursor: pointer;
    white-space: nowrap;
    text-decoration: none;
    /* Закрашивание при наведении — плавно (контурная «Войти по почте» —
       от прозрачной к цвету); бледность до галочек тоже уходит плавно. */
    transition: background-color .3s ease, color .3s ease, border-color .3s ease,
                opacity .25s ease, transform .15s ease;
}
.acc-btn:active { transform: scale(.98); }
.acc-btn[hidden] { display: none; }
.acc-btn--primary { background: var(--accent-1); color: var(--bg); }
.acc-btn--primary:hover { background: color-mix(in srgb, var(--accent-1) 88%, var(--text)); }
.acc-btn--outline { border-color: var(--accent-1); color: var(--accent-1); background: transparent; }
.acc-btn--outline:hover { background: var(--accent-1); color: var(--bg); }
.acc-btn--ghost { color: var(--text); background: transparent; border-color: var(--acc-line); }
.acc-btn--ghost:hover { border-color: var(--accent-2); color: var(--accent-2); }
.acc-btn--danger {
    --acc-danger: color-mix(in srgb, var(--accent-1) 80%, var(--bg));
    color: var(--acc-danger);
    border-color: color-mix(in srgb, var(--acc-danger) 55%, var(--bg));
    background: transparent;
}
/* Ночью смесь с тёмным фоном слишком тусклая — приглушаем к светлому тексту. */
[data-theme="dark"] .acc-btn--danger { --acc-danger: color-mix(in srgb, var(--accent-1) 80%, var(--text)); }
.acc-btn--danger:hover { color: var(--accent-1); border-color: var(--accent-1); background: color-mix(in srgb, var(--accent-1) 6%, transparent); }
.acc-btn--danger-solid { background: var(--accent-1); color: var(--bg); }
.acc-btn--danger-solid:hover { background: color-mix(in srgb, var(--accent-1) 85%, var(--text)); }
.acc-btn--sm { height: 32px; padding: 0 14px; font-size: 13px; }
.acc-btn--wide { width: 100%; height: 46px; font-size: 15px; }

.acc-legal {
    margin: 22px 0 0;
    font: 13px/1.5 var(--sans);
    color: var(--acc-muted);
}
.acc-legal a { color: var(--acc-muted); text-decoration: none; }
.acc-legal a:hover { color: var(--accent-1); text-decoration: underline; }
.acc-legal span { margin: 0 6px; color: var(--divider); }

/* ---------- Окно входа ---------- */
.acc-login {
    width: 460px;
    padding: 44px 40px 28px;
    text-align: center;
    overflow-y: auto;
}
.acc-login .acc-lead { margin: 0 auto 28px; }
.acc-login .acc-h + .acc-choose { margin-top: 28px; }
.acc-later {
    margin: 14px 0 0;
    font: 14px/1.4 var(--sans);
    color: var(--acc-muted);
    cursor: default;
}
.acc-login .acc-legal { padding-top: 18px; border-top: 1px solid var(--acc-line); margin-top: 28px; }
.acc-consent {
    display: flex;
    flex-direction: column;
    gap: 14px;
    text-align: left;
}
.acc-check {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    font: 14px/1.5 var(--sans);
    color: var(--text);
    cursor: pointer;
}
/* Свои галочки: системные на телефоне квадратные, на компьютере скруглённые —
   рисуем одинаково везде. Отмечено — заливка акцентом и светлая «птичка». */
.acc-check input {
    flex: none;
    -webkit-appearance: none;
    appearance: none;
    position: relative;
    width: 18px;
    height: 18px;
    margin: 2px 0 0;
    border: 1.5px solid color-mix(in srgb, var(--text) 42%, var(--bg));
    border-radius: 5px;
    background: var(--bg);
    cursor: pointer;
    transition: background-color .15s ease, border-color .15s ease;
}
.acc-check input::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 45%;
    width: 4.5px;
    height: 9px;
    border: solid var(--bg);
    border-width: 0 2px 2px 0;
    transform: translate(-50%, -50%) rotate(45deg) scale(0);
    transition: transform .15s ease;
}
.acc-check input:hover { border-color: var(--accent-1); }
.acc-check input:checked { background: var(--accent-1); border-color: var(--accent-1); }
.acc-check input:checked::after { transform: translate(-50%, -50%) rotate(45deg) scale(1); }
.acc-modal .acc-check input:focus-visible { outline: 2px solid var(--accent-1); outline-offset: 2px; }
.acc-check a { color: var(--accent-1); }
.acc-consent .acc-btn--wide { margin-top: 8px; }

/* Способы входа и галочки под ними (одна форма). Пока галочки не отмечены,
   кнопки бледные и не нажимаются (aria-disabled, account-modal.js). */
.acc-choose { display: flex; flex-direction: column; gap: 10px; }
.acc-consent--login {
    gap: 12px;
    margin-top: 14px;
    padding-top: 18px;
    border-top: 1px solid var(--acc-line);
}
.acc-consent--login .acc-check { font-size: 13.5px; }
.acc-choose .acc-error { text-align: left; }
.acc-btn[aria-disabled="true"] { opacity: .42; cursor: not-allowed; }
[data-theme="dark"] .acc-btn[aria-disabled="true"] { opacity: .55; }
.acc-btn[aria-disabled="true"]:active { transform: none; }
.acc-btn--primary[aria-disabled="true"]:hover { background: var(--accent-1); }
.acc-btn--outline[aria-disabled="true"]:hover { background: transparent; color: var(--accent-1); }
.acc-btn:disabled { opacity: .6; cursor: progress; }

/* Вход по почте: адрес → код. Поле — как у имени в кабинете: обводка
   только у обёртки (.acc-field), у самого input её нет. */
.acc-step[hidden], [data-acc-flow-step][hidden] { display: none; }
.acc-email { display: flex; flex-direction: column; gap: 12px; text-align: left; }
.acc-login .acc-field { height: 50px; }
.acc-login .acc-lead strong { color: var(--text); font-weight: 500; overflow-wrap: anywhere; }
.acc-login .acc-lead:has(+ .acc-step__sub) { margin-bottom: 6px; }
.acc-step__sub { margin: 0 0 22px; font: 14px/1.5 var(--sans); }
.acc-step__foot { margin: 16px 0 0; font: 14px/1.5 var(--sans); color: var(--acc-muted); }
.acc-field--code input {
    font: 500 26px/1 var(--mono);
    letter-spacing: .32em;
    font-variant-numeric: tabular-nums;
}
.acc-login .acc-field--code { height: 62px; padding: 0 16px; }
.acc-login .acc-field--code input { text-align: center; padding-left: .32em; }
.acc-field--code input::placeholder { letter-spacing: .32em; color: color-mix(in srgb, var(--text) 30%, transparent); }

/* Вход через нашего бота (accounts/_bot_wait.html): QR на компьютере, подсказка
   на телефоне. Код всегда на кремовой карточке (и ночью): тёмные модули на
   светлом фоне считываются надёжнее; логотип — поверх центра, ≤22% ширины. */
.acc-bot { display: flex; flex-direction: column; align-items: stretch; gap: 14px; }
.acc-bot__view { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.acc-bot__view[hidden], .acc-bot [hidden] { display: none; }
.acc-bot__hint { margin: 0; font: 15px/1.55 var(--sans); color: var(--acc-muted); max-width: 340px; }
.acc-qr {
    --acc-qr-cream: #F5F0E6;   /* фон кода (accounts.bot.QR_LIGHT) — одинаковый в обеих темах */
    position: relative;
    width: 232px;
    max-width: 100%;
    aspect-ratio: 1;
    padding: 6px;
    background: var(--acc-qr-cream);
    border-radius: 16px;
    box-shadow: 0 0 0 1px var(--acc-line), 0 6px 20px -10px color-mix(in srgb, var(--text) 30%, transparent);
}
[data-theme="dark"] .acc-qr { box-shadow: 0 0 0 1px rgba(0, 0, 0, .4); }
.acc-qr__code, .acc-qr__code svg { display: block; width: 100%; height: 100%; }
.acc-bot__wait {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 0;
    font: 14px/1.4 var(--sans);
    color: var(--acc-muted);
}
.acc-bot__dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent-1);
    animation: acc-bot-pulse 1.4s ease-in-out infinite;
}
@keyframes acc-bot-pulse { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }
.acc-bot .acc-error { text-align: center; }
.acc-bot__dev { margin: 0; font: 13px/1.4 var(--sans); }
.acc-bot__foot { margin-top: 18px; }
.acc-bot__alt { margin: 6px 0 0; font: 13px/1.5 var(--sans); }
.acc-bot__alt .acc-textbtn { color: var(--acc-muted); text-decoration-color: color-mix(in srgb, var(--acc-muted) 45%, transparent); }
.acc-bot__alt .acc-textbtn:hover { color: var(--accent-1); }
/* В кабинете — та же начинка в панели под плашкой Telegram, код чуть меньше. */
.acc-link--bot { text-align: center; }
.acc-link--bot .acc-link__label { text-align: left; }
.acc-link--bot .acc-qr { width: 208px; }
.acc-link--bot .acc-btn--wide { width: auto; height: 40px; font-size: 14px; padding: 0 20px; }
.acc-link--bot .acc-link__foot span { margin: 0 6px; color: var(--divider); }
.acc-method__form[hidden] { display: none; }

/* Кнопка-ссылка: «Изменить адрес», «Отправить код ещё раз», «Отмена». */
.acc-textbtn {
    display: inline;
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    color: var(--accent-1);
    text-decoration: underline;
    text-decoration-color: color-mix(in srgb, var(--accent-1) 40%, transparent);
    text-underline-offset: 3px;
    cursor: pointer;
}
.acc-textbtn:hover { text-decoration-color: currentColor; }
.acc-textbtn:disabled { color: var(--acc-muted); text-decoration: none; cursor: default; opacity: 1; }

/* ---------- Окно кабинета ---------- */
.acc-cab {
    width: 1000px;
    height: 672px;
    display: grid;
    grid-template-columns: 236px minmax(0, 1fr);
}

.acc-side {
    background: var(--acc-side);
    border-right: 1px solid var(--acc-line);
    display: flex;
    flex-direction: column;
    padding: 22px 14px 18px;
    min-height: 0;
}
.acc-side__who {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 10px 22px;
}
.acc-side__seal {
    width: 40px;
    height: 40px;
    flex: none;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font: italic 500 22px/1 var(--serif);
    color: var(--accent-1);
    background: var(--bg);
    box-shadow: 0 0 0 1px var(--acc-line);
}
.acc-side__text { min-width: 0; }
.acc-side__name {
    font: 500 15px/1.25 var(--sans);
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.acc-side__name.is-empty { color: var(--acc-muted); font-weight: 400; }
.acc-side__sub { font: 13px/1.4 var(--sans); color: var(--acc-muted); }
.acc-side__nav { display: flex; flex-direction: column; gap: 2px; }
.acc-side__item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 12px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    font: 400 14.5px/1.2 var(--sans);
    color: color-mix(in srgb, var(--text) 85%, var(--bg));
    text-align: left;
    cursor: pointer;
    transition: background .18s ease, color .18s ease;
}
.acc-side__item svg { flex: none; opacity: .7; }
.acc-side__item:hover { background: var(--acc-hover); color: var(--text); }
.acc-side__item[aria-current="page"] {
    background: var(--bg);
    color: var(--accent-1);
    font-weight: 500;
    box-shadow: 0 1px 2px color-mix(in srgb, var(--text) 7%, transparent), 0 0 0 1px var(--acc-line);
}
.acc-side__item[aria-current="page"] svg { opacity: 1; }
.acc-side__soon {
    margin-left: auto;
    font: 13px/1 var(--sans);
    color: var(--acc-muted);
    font-weight: 400;
}
.acc-side__sep { height: 1px; background: var(--acc-line); margin: 10px 12px; }

.acc-main { position: relative; min-width: 0; overflow: hidden; }
.acc-screen {
    position: absolute;
    inset: 0;
    overflow-y: auto;
    padding: 48px 56px 40px;
    scrollbar-width: thin;
    scrollbar-color: var(--divider) transparent;
    transition: opacity .2s ease, transform .24s var(--acc-ease);
}
.acc-screen[hidden] { display: block; visibility: hidden; opacity: 0; pointer-events: none; }
.acc-screen.is-entering { opacity: 0; transform: translateY(6px); }

.acc-block { margin-top: 34px; max-width: 520px; }
.acc-block__title {
    display: block;
    font: 500 14px/1.3 var(--sans);
    color: var(--text);
    margin: 0 0 12px;
}
.acc-field {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 6px 0 16px;
    height: 48px;
    background: color-mix(in srgb, var(--card-light) 45%, var(--bg));
    border: 1px solid var(--acc-line);
    border-radius: var(--acc-radius-sm);
    transition: border-color .2s ease, background .2s ease, box-shadow .2s ease;
}
.acc-field:focus-within {
    background: var(--bg);
    border-color: var(--accent-1);
}
.acc-field input {
    flex: 1;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    font: 16px/1 var(--sans);
    color: var(--text);
}
.acc-field input:focus,
.acc-field input:focus-visible { outline: none; border: none; box-shadow: none; }
.acc-field input::placeholder { color: color-mix(in srgb, var(--text) 45%, transparent); }
.acc-field__saved { font: 13px/1 var(--sans); color: var(--acc-muted); white-space: nowrap; }
.acc-hint { font: 13px/1.5 var(--sans); color: var(--acc-muted); margin: 8px 0 0; }

.acc-methods { display: grid; gap: 10px; }
.acc-method {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 14px 12px 14px;
    border: 1px solid var(--acc-line);
    border-radius: var(--acc-radius-sm);
    background: var(--bg);
}
.acc-method__icon {
    width: 38px;
    height: 38px;
    flex: none;
    border-radius: 10px;
    display: grid;
    place-items: center;
    background: color-mix(in srgb, var(--card-light) 70%, var(--bg));
    color: var(--accent-2);
}
.acc-method__icon--vk { font: 600 12px/1 var(--sans); }
.acc-method__name { flex: 1; min-width: 0; font: 500 15px/1.3 var(--sans); color: var(--text); }
.acc-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font: 500 13px/1 var(--sans);
    color: var(--accent-2);
    padding: 8px 12px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--accent-2) 10%, transparent);
    white-space: nowrap;
}
.acc-status--quiet { background: transparent; font-weight: 400; color: var(--acc-muted); }
.acc-method__text { flex: 1; min-width: 0; }
.acc-method__sub {
    font: 13px/1.4 var(--sans);
    color: var(--acc-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.acc-method__sub[hidden] { display: none; }
.acc-method:focus { outline: none; }
.acc-method--soon { border-style: dashed; }

/* Итог подключения Telegram после возврата в кабинет: отказ — в тонах
   подтверждения удаления, успех — в тонах плашки «Подключён». */
.acc-notice {
    margin: 0 0 12px;
    padding: 12px 14px;
    border: 1px solid color-mix(in srgb, var(--accent-1) 35%, var(--bg));
    border-radius: var(--acc-radius-sm);
    background: color-mix(in srgb, var(--accent-1) 5%, var(--bg));
    font: 14px/1.5 var(--sans);
    color: var(--text);
}
.acc-notice--ok {
    border-color: color-mix(in srgb, var(--accent-2) 30%, var(--bg));
    background: color-mix(in srgb, var(--accent-2) 8%, var(--bg));
}

/* Ночью смесь с тёмным фоном почти не видна — цвета чуть сильнее. */
[data-theme="dark"] .acc-notice {
    border-color: color-mix(in srgb, var(--accent-1) 50%, var(--bg));
    background: color-mix(in srgb, var(--accent-1) 12%, var(--bg));
}
[data-theme="dark"] .acc-notice--ok {
    border-color: color-mix(in srgb, var(--accent-2) 40%, var(--bg));
    background: color-mix(in srgb, var(--accent-2) 12%, var(--bg));
}

/* Подключение почты в кабинете: панель сразу под плашкой «Почта». */
.acc-link {
    padding: 16px 18px 14px;
    border: 1px solid var(--acc-line);
    border-radius: var(--acc-radius-sm);
    background: var(--bg);
}
.acc-link[hidden] { display: none; }
.acc-link form { margin: 0; }
.acc-link__label {
    display: block;
    margin: 0 0 10px;
    font: 14px/1.5 var(--sans);
    color: var(--acc-muted);
}
.acc-link__label strong { color: var(--text); font-weight: 500; overflow-wrap: anywhere; }
.acc-link .acc-error { margin-top: 8px; }
.acc-link .acc-field--code input { font-size: 22px; }
.acc-link__foot { margin: 10px 0 0; font: 13px/1.5 var(--sans); }
.acc-method--soon .acc-method__icon, .acc-method--soon .acc-method__name { opacity: .6; }

/* Избранное */
.acc-fav-group { margin-top: 30px; }
.acc-fav-group__head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--acc-line);
}
.acc-fav-group__mark {
    width: 12px;
    height: 16px;
    flex: none;
    border-radius: 2px;
    background: linear-gradient(160deg, var(--card-bg-light, var(--accent-2)) 0%, var(--card-bg-dark, var(--accent-2)) 100%);
}
.acc-fav-group__name { font: 500 24px/1.2 var(--serif); color: var(--text); margin: 0; }
.acc-fav-group__latin { font: italic 16px/1 var(--serif); color: var(--accent-2); }
.acc-fav {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 12px;
    margin: 0 -12px;
    border-radius: 10px;
    transition: background .2s ease, opacity .26s ease, transform .26s var(--acc-ease);
}
.acc-fav + .acc-fav { box-shadow: 0 -1px 0 var(--acc-line); }
.acc-fav:hover { background: var(--acc-hover); box-shadow: none; }
.acc-fav:hover + .acc-fav { box-shadow: none; }
.acc-fav.is-removing { opacity: 0; transform: translateX(8px); }
.acc-fav__info { flex: 1; min-width: 0; }
.acc-fav__title {
    display: block;
    font: 500 18px/1.25 var(--serif);
    color: var(--text);
    text-decoration: none;
    margin-bottom: 4px;
}
a.acc-fav__title:hover { color: var(--accent-1); }
.acc-fav__meta {
    font: 13px/1.45 var(--sans);
    color: var(--acc-muted);
    display: flex;
    gap: 4px 12px;
    flex-wrap: wrap;
}
.acc-fav__type { color: var(--acc-muted); white-space: nowrap; }
.acc-fav__actions { display: flex; align-items: center; gap: 6px; flex: none; }
.acc-fav__remove {
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--accent-1);
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: background .2s ease;
}
.acc-fav__remove:hover { background: color-mix(in srgb, var(--accent-1) 9%, transparent); }

.acc-toast {
    position: absolute;
    left: 50%;
    bottom: 22px;
    z-index: 6;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 10px 10px 18px;
    border-radius: 999px;
    background: var(--text);
    color: var(--bg);
    font: 14px/1 var(--sans);
    box-shadow: var(--acc-shadow);
    white-space: nowrap;
    transform: translate(-50%, 16px);
    opacity: 0;
    visibility: hidden;
    transition: opacity .25s ease, transform .3s var(--acc-ease), visibility 0s .3s;
}
.acc-toast.is-on { opacity: 1; visibility: visible; transform: translate(-50%, 0); transition: opacity .25s ease, transform .3s var(--acc-ease); }
.acc-toast button {
    border: 0;
    background: color-mix(in srgb, var(--bg) 16%, transparent);
    color: var(--bg);
    font: 500 13px/1 var(--sans);
    padding: 8px 12px;
    border-radius: 999px;
    cursor: pointer;
}

/* Настройки */
.acc-rows { margin-top: 26px; max-width: 600px; }
.acc-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 18px 0;
    border-bottom: 1px solid var(--acc-line);
}
.acc-row[hidden] { display: none; }
.acc-row form { margin: 0; flex: none; }
.acc-row__name { font: 500 15px/1.3 var(--sans); color: var(--text); }
.acc-row__desc { font: 13px/1.45 var(--sans); color: var(--acc-muted); margin-top: 3px; max-width: 380px; }
.acc-row--danger { border-bottom: 0; }
.acc-row--danger .acc-row__name { color: var(--acc-muted); }
.acc-confirm {
    margin: 10px 0 0;
    padding: 18px 20px;
    border: 1px solid color-mix(in srgb, var(--accent-1) 35%, var(--bg));
    border-radius: var(--acc-radius-sm);
    background: color-mix(in srgb, var(--accent-1) 5%, var(--bg));
}
.acc-confirm[hidden] { display: none; }
.acc-confirm__text { font: 14px/1.5 var(--sans); color: var(--text); margin: 0 0 14px; }
.acc-confirm__actions { display: flex; gap: 10px; flex-wrap: wrap; }
/* Ссылки на документы — прижаты к низу правой колонки «Настроек». */
.acc-screen--settings:not([hidden]) { display: flex; flex-direction: column; }
.acc-legal--bottom { margin-top: auto; padding-top: 30px; }

/* Планшет и узкий ноутбук (≤900px, брейкпоинт шапки): кабинет 1000×672 не
   помещается — окно по ширине экрана, колонка разделов и поля уже. */
@media (max-width: 900px) {
    .acc-modal { padding: 24px; }
    .acc-cab { grid-template-columns: 208px minmax(0, 1fr); }
    .acc-screen { padding: 44px 36px 36px; }
}

/* Телефон (≤640px, как у остального сайта). Окно входа — почти во всю
   ширину с полями 16px; кабинет — на весь экран: сверху имя и разделы
   лентой (листается вбок), ниже раздел со своей прокруткой, крестик всегда
   на месте. Кнопки и поля — от 44px по высоте, текст — от 14px. */
@media (max-width: 640px) {
    .acc-modal { padding: 16px; }
    .acc-modal--cab { padding: 0; }
    .acc-modal__close { top: 8px; right: 8px; width: 44px; height: 44px; }

    .acc-h { font-size: 32px; }
    .acc-btn { min-height: 44px; }
    .acc-btn--sm { height: 44px; padding: 0 16px; font-size: 14px; }
    .acc-legal { font-size: 14px; }
    /* Ссылки и текстовые кнопки: зона нажатия ~44px, строка не растёт. */
    .acc-legal a, .acc-textbtn { display: inline-block; padding: 12px 0; margin: -12px 0; }
    .acc-link__foot { font-size: 14px; }

    /* Окно входа (а с ним /auth/login/, welcome и возврат из Telegram) */
    .acc-login { width: 100%; padding: 44px 20px 20px; }
    .acc-login .acc-lead { margin-bottom: 24px; }
    .acc-login .acc-h + .acc-choose { margin-top: 24px; }
    .acc-consent--login .acc-check { font-size: 14px; }
    .acc-login .acc-legal { margin-top: 22px; }

    /* Кабинет: окно во весь экран */
    .acc-cab {
        width: 100%;
        height: 100%;
        border-radius: 0;
        box-shadow: none;
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto minmax(0, 1fr);
    }
    .acc-side { border-right: 0; border-bottom: 1px solid var(--acc-line); padding: 12px 0 10px; }
    .acc-side__who { padding: 2px 60px 12px 16px; }
    .acc-side__seal { width: 36px; height: 36px; font-size: 20px; }
    .acc-side__sub { font-size: 14px; }
    /* Разделы — плашками в несколько строк, как разделы на странице предмета
       (решение Семёна 08.11: без прокрутки вбок). */
    .acc-side__nav {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
        padding: 2px 16px;
    }
    .acc-side__item {
        width: auto;
        flex: none;
        min-height: 40px;
        padding: 0 14px;
        gap: 8px;
        white-space: nowrap;
        font-size: 14px;
        border: 1px solid var(--divider);
        border-radius: 999px;
    }
    .acc-side__item[aria-current="page"] { border-color: var(--accent-1); }
    .acc-side__soon { margin-left: 2px; font-size: 13px; }
    .acc-side__sep { display: none; }

    .acc-screen { padding: 24px 16px 32px; }
    .acc-block { margin-top: 28px; }
    .acc-hint, .acc-field__saved { font-size: 14px; }
    .acc-cab .acc-field { height: 56px; }

    .acc-method { gap: 12px; padding: 10px 12px; flex-wrap: wrap; }
    .acc-method__icon { width: 34px; height: 34px; }
    .acc-method__sub { font-size: 14px; white-space: normal; overflow-wrap: anywhere; }
    .acc-method__form { margin-left: auto; }
    .acc-status { font-size: 14px; }
    .acc-link { padding: 14px 14px 12px; }

    /* Файл: название и подпись во всю ширину, кнопки строкой под ними,
       закладка — справа. Латинское название предмета переносится. */
    .acc-fav { flex-wrap: wrap; gap: 10px; }
    .acc-fav__info { flex: 1 1 100%; }
    .acc-fav__meta { font-size: 14px; }
    .acc-fav__actions { flex: 1 1 100%; gap: 8px; }
    .acc-fav__remove { width: 44px; height: 44px; margin-left: auto; }
    .acc-fav-group__head { flex-wrap: wrap; row-gap: 2px; }
    .acc-fav-group__name { font-size: 22px; }
    .acc-fav-group__latin { line-height: 1.3; }

    /* Кнопки настроек — под описанием, одинаково во всех строках. */
    .acc-row { flex-direction: column; align-items: flex-start; gap: 12px; }
    .acc-row__desc { font-size: 14px; }
    .acc-toast { max-width: calc(100% - 32px); bottom: 16px; }
    .acc-toast button { min-height: 36px; }
}

/* Узкие телефоны (≤420px): поле и кнопка внутри него не помещаются в строку —
   поле на всю ширину, кнопка под ним (имя, почта и код в кабинете). */
@media (max-width: 420px) {
    .acc-cab .acc-field {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        height: auto;
        padding: 0;
        border: 0;
        background: none;
    }
    .acc-cab .acc-field input {
        flex: none;
        height: 48px;
        padding: 0 16px;
        background: color-mix(in srgb, var(--card-light) 45%, var(--bg));
        border: 1px solid var(--acc-line);
        border-radius: var(--acc-radius-sm);
        transition: border-color .2s ease, background .2s ease;
    }
    .acc-cab .acc-field input:focus,
    .acc-cab .acc-field input:focus-visible { background: var(--bg); border: 1px solid var(--accent-1); }
    .acc-cab .acc-field--code input { height: 56px; text-align: center; padding-left: .32em; }
    .acc-cab .acc-field__saved:empty { display: none; }
    .acc-cab .acc-field .acc-btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
    .acc-modal, .acc-modal__veil, .acc-modal__win, .acc-screen, .acc-fav, .acc-toast, .acc-btn {
        transition-duration: .01ms !important;
        transition-delay: 0s !important;
    }
    .acc-modal__win, .acc-modal.is-open .acc-modal__win { transform: none; }
    .acc-btn:active { transform: none; }
    .acc-bot__dot { animation: none; opacity: .8; }
}

/* ===== Документы: политика, согласие, правила (accounts, бета 07.11) =====
   Каркас как у «О библиотеке»; строгий текст — гротеском 17px, строка ~70 знаков.
   «Коротко» — вклейка курсивом Cormorant на тонком фоне. Только токены :root. */
.legal-page {
    max-width: 680px;
    margin: 0 auto;
    padding: 72px 0 112px;
}
.legal-header { margin-bottom: 40px; }
.legal-title {
    font-family: var(--serif);
    font-weight: 500;
    font-size: clamp(40px, 5vw, 60px);
    line-height: 1.05;
    letter-spacing: -0.015em;
    color: var(--text);
    margin-bottom: 18px;
}
.legal-title em { font-style: italic; font-weight: 400; color: var(--accent-1); }
.legal-date {
    font: 14px/1.5 var(--sans);
    color: color-mix(in srgb, var(--text) 70%, var(--bg));
    margin: 0;
}
/* Текст документа: один шрифт (как в статьях сайта), заголовки разделов —
   тем же шрифтом, полужирные. Без плашек, оглавления и таблиц (решение Семёна 07.11). */
.legal-body h2 {
    font: 600 21px/1.3 var(--sans);
    color: var(--text);
    margin: 44px 0 14px;
}
.legal-body h3 {
    font: 600 17px/1.4 var(--sans);
    color: var(--text);
    margin: 24px 0 10px;
}
.legal-body p,
.legal-body ul {
    font: 17px/1.65 var(--sans);
    color: var(--text);
    margin: 0 0 12px;
    text-wrap: pretty;
}
.legal-body ul { padding-left: 1.3em; }
.legal-body li { margin-bottom: 8px; }
.legal-body strong { font-weight: 600; }
.legal-body a {
    color: var(--accent-1);
    text-decoration: underline;
    text-underline-offset: 3px;
    overflow-wrap: anywhere;
}

@media (max-width: 640px) {
    .legal-page { padding: 44px 0 72px; }
    .legal-body h2 { font-size: 19px; margin-top: 36px; }
    .legal-body p, .legal-body ul { font-size: 16px; }
}

/* ===== Тренажёр (trainer/, пилот по личной ссылке) =====
   Плашка-«том» в цвете предмета (переменные .subject-card--<группа>) → окно выбора
   системы, как кабинет, поверх затемнённого сайта → тест на весь экран, раскрытие
   clip-path из карточки темы (static/js/trainer.js). Только цвета палитры сайта:
   алый --accent-1 (кнопки, ошибка), зелёный клинических предметов #4A6741 (верно). */
.trn-plate {
    --pb1: var(--card-bg-light, #A8563A);
    --pb2: var(--card-bg-dark, #8B4327);
    --pt: var(--card-text, #F5F0E6);
    --pa: var(--card-accent, #D4CCB8);
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    margin-top: 28px;
    padding: 18px 16px 18px 22px;
    border: 0;
    border-radius: 12px;
    background: linear-gradient(160deg, var(--pb1), var(--pb2));
    color: var(--pt);
    font: inherit;
    text-align: left;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .08), 0 8px 24px rgba(0, 0, 0, .12);
    transition: transform .3s cubic-bezier(.2, .8, .2, 1), box-shadow .3s ease;
}
.trn-plate::before {          /* рамка обложки, как у карточки предмета */
    content: "";
    position: absolute;
    inset: 6px;
    border: 1px solid var(--pt);
    opacity: .4;
    border-radius: 7px;
    pointer-events: none;
}
.trn-plate::after {           /* корешок */
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 6px;
    border-radius: 12px 0 0 12px;
    background: linear-gradient(to right, rgba(0, 0, 0, .22), transparent);
}
.trn-plate:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, .1), 0 14px 30px rgba(0, 0, 0, .16);
}
.trn-plate:hover .trn-plate__arrow { transform: translateX(3px); }
.trn-plate:focus-visible { outline: 2px solid var(--accent-1); outline-offset: 3px; }
.trn-plate__icon {
    flex: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    border: 1px solid color-mix(in srgb, var(--pt) 55%, transparent);
    background: color-mix(in srgb, var(--pt) 10%, transparent);
}
.trn-plate__text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.trn-plate__title { font: 600 22px/1.1 var(--serif); }
.trn-plate__sub { font: 13px/1.4 var(--sans); color: color-mix(in srgb, var(--pt) 78%, transparent); }
.trn-plate__arrow { flex: none; color: var(--pa); transition: transform .2s ease; }

.trn {
    --trn-ok: #4A6741;            /* зелёный «Акушерства и гинекологии» */
    --trn-bad: var(--accent-1);   /* алый кнопок сайта */
    --trn-line: color-mix(in srgb, var(--divider) 70%, var(--bg));
    --trn-muted: color-mix(in srgb, var(--text) 74%, var(--bg));
    --trn-ease: cubic-bezier(.32, .72, 0, 1);
    --trn-veil: color-mix(in srgb, color-mix(in srgb, var(--text) 78%, var(--accent-2)) 40%, transparent);
    position: fixed;
    inset: 0;
    z-index: 150;                 /* ниже окна входа (200): «войти» открывается поверх */
    display: grid;
    grid-template: minmax(0, 1fr) / minmax(0, 1fr);
    place-items: center;
    padding: 40px;
}
.trn[hidden] { display: none; }
.trn.trn--top { z-index: 210; }   /* открыт из кабинета (z 200) — поверх него */
[data-theme="dark"] .trn {
    --trn-ok: color-mix(in srgb, #4A6741 55%, var(--text));
    --trn-veil: color-mix(in srgb, var(--bg) 72%, transparent);
    color-scheme: dark;
}
html.trn-locked { overflow: hidden; }
.trn :focus { outline: none; }
/* Окна получают фокус программно — без обводки (иначе рамка «в воздухе» вокруг окна). */
.trn .trn__win:focus, .trn .trn__win:focus-visible,
.trn .trn__full:focus, .trn .trn__full:focus-visible { outline: none; }
.trn :focus-visible { outline: 1px solid var(--accent-1); outline-offset: 2px; }

.trn__veil {
    position: absolute;
    inset: 0;
    background: var(--trn-veil);
    backdrop-filter: blur(4px) saturate(.92);
    -webkit-backdrop-filter: blur(4px) saturate(.92);
    opacity: 0;
    transition: opacity .35s ease;
}
.trn.is-open .trn__veil { opacity: 1; }
/* Под тестом на весь экран размытие не видно — выключаем, чтобы раскрытие не тормозило. */
.trn.is-full .trn__veil { backdrop-filter: none; -webkit-backdrop-filter: none; }

/* Окно выбора системы */
.trn__win {
    position: relative;
    width: 860px;
    max-width: 100%;
    max-height: 100%;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 40px 40px 36px;
    border-radius: 18px;
    background: var(--bg);
    color: var(--text);
    box-shadow:
        0 0 0 1px var(--trn-line),
        0 2px 6px color-mix(in srgb, var(--text) 8%, transparent),
        0 24px 64px -12px color-mix(in srgb, var(--text) 38%, transparent);
    opacity: 0;
    transform: scale(.97) translateY(10px);
    transition: opacity .3s ease, transform .45s var(--trn-ease);
    outline: none;
}
[data-theme="dark"] .trn__win { box-shadow: 0 0 0 1px var(--trn-line), 0 24px 64px -12px rgba(0, 0, 0, .7); }
.trn.is-open .trn__win { opacity: 1; transform: none; }
.trn.is-full .trn__win { opacity: 0; transform: scale(.985); transition-duration: .25s; }
.trn__x { position: absolute; top: 14px; right: 14px; }

.trn__icon {
    flex: none;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--text);
    display: grid;
    place-items: center;
    cursor: pointer;
    opacity: .7;
    transition: background .2s ease, opacity .2s ease;
}
.trn__icon:hover { opacity: 1; background: color-mix(in srgb, var(--accent-2) 8%, transparent); }
.trn__eyebrow {
    margin: 0;
    font: 500 12px/1 var(--sans);
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--accent-2);
    text-align: center;
}
.trn__h { margin: 0; font: 500 40px/1.05 var(--serif); text-align: center; }

.trn-intro { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.trn-intro .trn__eyebrow { margin-bottom: 2px; }
.trn-intro__lead { margin: 0; font: 15px/1.55 var(--sans); color: var(--trn-muted); text-wrap: balance; }
.trn-note {
    margin: 4px auto 0;
    max-width: 520px;
    font: 14px/1.55 var(--sans);
    color: var(--trn-muted);
    text-align: center;
    text-wrap: balance;
}
.trn-note a { color: var(--accent-1); text-decoration: underline; text-underline-offset: 2px; white-space: nowrap; }

.trn-topics {
    list-style: none;
    margin: 30px 0 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}
.trn-topic {
    display: grid;
    grid-template-columns: 72px 1fr;
    gap: 14px 16px;
    align-items: center;
    padding: 18px;
    border: 1px solid var(--divider);
    border-radius: 14px;
    background: var(--card-light);
}
.trn-topic__thumb {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    object-fit: cover;
    padding: 3px;
    border: 1px solid var(--divider);
    background: var(--bg);
}
.trn-topic__head { min-width: 0; }
.trn-topic__name { margin: 0; font: 600 22px/1.15 var(--serif); }
.trn-topic__meta { margin: 4px 0 0; font: 13px/1.5 var(--sans); color: var(--trn-muted); }
.trn-topic__bar { display: block; height: 3px; margin-top: 8px; border-radius: 3px; background: var(--trn-line); overflow: hidden; }
.trn-topic__bar[hidden] { display: none; }
.trn-topic__bar i { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--accent-1); }
.trn-topic__actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; }
.trn-topic--soon { background: transparent; border-style: dashed; opacity: .62; }
.trn-topic--soon .trn-topic__thumb { background: var(--card-light); }
.trn-topic--soon .trn-topic__name { font-size: 20px; }

.trn-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 42px;
    padding: 0 20px;
    border-radius: 999px;
    border: 1px solid var(--trn-line);
    background: transparent;
    color: var(--text);
    font: 500 14px/1 var(--sans);
    cursor: pointer;
    white-space: nowrap;
    transition: background .2s ease, border-color .2s ease, color .2s ease, transform .1s ease;
}
.trn-btn:hover { border-color: var(--accent-2); color: var(--accent-2); }
.trn-btn:active { transform: scale(.98); }
.trn-btn[hidden] { display: none; }
.trn-btn--primary { background: var(--accent-1); border-color: var(--accent-1); color: var(--bg); }
.trn-btn--primary:hover { background: color-mix(in srgb, var(--accent-1) 88%, var(--text)); color: var(--bg); border-color: transparent; }
.trn-btn:disabled { opacity: .55; cursor: default; }

/* Тест на весь экран */
.trn__full {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--text);
    clip-path: inset(0 0 0 0 round 0px);
    transition: clip-path .5s cubic-bezier(.2, .8, .2, 1);
    will-change: clip-path;
    outline: none;
}
.trn__full[hidden] { display: none; }
/* Обратно — без сжатия в карточку: тест мягко гаснет, окно выбора проявляется. */
.trn__full.is-closing { opacity: 0; transform: scale(.985); transition: opacity .24s ease, transform .24s ease; }
.trn__bar {
    flex: none;
    display: flex;
    align-items: center;
    gap: 8px;
    height: 60px;
    padding: 0 16px;
    border-bottom: 1px solid var(--trn-line);
}
.trn__bar .trn__eyebrow { flex: 1; }
.trn__body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity .28s ease .2s, transform .36s var(--trn-ease) .2s;
}
.trn__full.is-shown .trn__body { opacity: 1; transform: none; }
.trn-screen { width: 100%; max-width: 640px; margin: 0 auto; padding: 20px 24px 56px; }
.trn-screen[hidden] { display: none; }
.trn-screen[data-trn-screen="result"] { padding-top: 64px; text-align: center; }

.trn-progress { height: 3px; border-radius: 3px; background: var(--trn-line); overflow: hidden; }
.trn-progress span { display: block; height: 100%; width: 0; background: var(--accent-1); transition: width .35s var(--trn-ease); }
.trn-count { margin: 10px 0 18px; font: 13px/1.4 var(--sans); color: var(--trn-muted); text-align: center; }

.trn-photo {
    margin: 0 auto;
    width: min(100%, 440px, calc(100vh - 360px));
    min-width: 220px;
    padding: 6px;
    border: 1px solid var(--divider);
    background: var(--card-light);
    box-shadow: 0 10px 30px -18px color-mix(in srgb, var(--text) 55%, transparent);
}
.trn-photo img { width: 100%; height: auto; transition: opacity .18s ease; }
.trn-photo { position: relative; }
.trn-photo.is-loading img { opacity: 0; }
.trn-photo img:not([src]) { visibility: hidden; }
/* Индикатор загрузки фото — тонкое кольцо по центру рамки. */
.trn-photo.is-loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 34px;
    height: 34px;
    margin: -17px 0 0 -17px;
    border-radius: 50%;
    border: 2px solid color-mix(in srgb, var(--accent-1) 18%, transparent);
    border-top-color: var(--accent-1);
    animation: trn-spin .8s linear infinite;
}
.trn-photo--rect { min-height: 240px; }
@keyframes trn-spin { to { transform: rotate(360deg); } }
.trn-photo--round { aspect-ratio: 1; border-radius: 50%; }
.trn-photo--round img { height: 100%; object-fit: cover; border-radius: 50%; }
.trn-photo--rect { border-radius: 14px; width: min(100%, 560px); }
.trn-photo--rect img { border-radius: 9px; max-height: calc(100vh - 380px); min-height: 180px; object-fit: contain; }

.trn-form { margin: 22px auto 0; max-width: 480px; }
.trn-prompt { display: block; margin: 0 0 10px; font: 600 24px/1.2 var(--serif); text-align: center; }
.trn-field {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 5px 5px 18px;
    border: 1px solid var(--divider);
    border-radius: 999px;
    background: var(--bg);
    transition: border-color .25s ease, box-shadow .25s ease, background-color .3s ease;
}
.trn-field:focus-within { border-color: var(--accent-2); }
.trn-field input {
    flex: 1;
    min-width: 0;
    height: 40px;
    border: 0;
    background: transparent;
    color: var(--text);
    font: 16px/1 var(--sans);   /* 16px: iPhone не увеличивает страницу при вводе */
}
.trn-field input::placeholder { color: color-mix(in srgb, var(--text) 40%, transparent); }
.trn-field input:focus { outline: none; }
.trn-field input:read-only { cursor: default; }
/* Подсветка ответа — рамка и заливка поля цветом, вспышка наружу. */
.trn-field.is-ok {
    border-color: var(--trn-ok);
    background-color: color-mix(in srgb, var(--trn-ok) 14%, var(--bg));
    animation: trn-glow-ok .9s ease;
}
.trn-field.is-wrong {
    border-color: var(--trn-bad);
    background-color: color-mix(in srgb, var(--trn-bad) 12%, var(--bg));
    animation: trn-glow-bad .9s ease, trn-shake .38s ease;
}
[data-theme="dark"] .trn-field.is-ok { background-color: color-mix(in srgb, var(--trn-ok) 22%, var(--bg)); }
[data-theme="dark"] .trn-field.is-wrong { background-color: color-mix(in srgb, var(--trn-bad) 22%, var(--bg)); }
@keyframes trn-glow-ok {
    0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--trn-ok) 45%, transparent); }
    100% { box-shadow: 0 0 0 10px transparent; }
}
@keyframes trn-glow-bad {
    0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--trn-bad) 45%, transparent); }
    100% { box-shadow: 0 0 0 10px transparent; }
}
@keyframes trn-shake {
    0%, 100% { transform: none; }
    25% { transform: translateX(-5px); }
    50% { transform: translateX(4px); }
    75% { transform: translateX(-2px); }
}
.trn-feedback { min-height: 24px; margin: 12px 0 0; font: 500 15px/1.5 var(--sans); text-align: center; }
.trn-feedback.is-ok { color: var(--trn-ok); }
.trn-feedback.is-wrong { color: var(--trn-bad); }
[data-theme="dark"] .trn-feedback.is-wrong { color: color-mix(in srgb, var(--accent-1) 70%, var(--text)); }
.trn-form__foot { display: flex; justify-content: center; gap: 20px; margin-top: 6px; }
.trn-link {
    border: 0;
    background: transparent;
    padding: 6px 4px;
    font: 14px/1.4 var(--sans);
    color: var(--trn-muted);
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-color: var(--trn-line);
}
.trn-link:hover { color: var(--accent-1); }
.trn-link[hidden] { display: none; }

.trn-result { margin: 14px 0 0; font: 17px/1.55 var(--sans); }
.trn-result__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 28px; }
.trn-screen[data-trn-screen="result"] .trn-note { margin-top: 22px; }

/* Конструктор сборников: кнопка в окне выбора, круглые галочки на темах (как при
   пересылке в мессенджере), полоска «Собрать сборник» внизу окна. */
.trn-ctor-toggle {
    position: absolute;
    top: 18px;
    right: 62px;
    height: 32px;
    padding: 0 14px;
    border: 1px solid var(--trn-line);
    border-radius: 999px;
    background: transparent;
    color: var(--text);
    font: 500 13px/30px var(--sans);
    text-decoration: none;
    cursor: pointer;
    transition: border-color .2s ease, color .2s ease, background .2s ease;
}
.trn-ctor-toggle:hover { border-color: var(--accent-2); color: var(--accent-2); }
.trn-ctor-toggle[aria-pressed="true"] { background: var(--accent-1); border-color: var(--accent-1); color: var(--bg); }
.trn-ctor-hint { margin: 18px 0 0; font: 14px/1.5 var(--sans); color: var(--trn-muted); text-align: center; }
.trn-ctor-hint[hidden] { display: none; }

.trn-group[hidden] { display: none; }
.trn-group__title {
    margin: 28px 0 0;
    font: 500 12px/1 var(--sans);
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--accent-2);
}
.trn-group .trn-topics { margin-top: 14px; }
.trn-group + .trn-topics { margin-top: 14px; }
.trn-topic { position: relative; }
.trn-topic--col { background: color-mix(in srgb, var(--card-light) 60%, var(--bg)); }
.trn-topic__del {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--trn-muted);
    display: grid;
    place-items: center;
    cursor: pointer;
}
.trn-topic__del:hover { color: var(--accent-1); background: color-mix(in srgb, var(--accent-1) 8%, transparent); }

.trn-check {
    position: absolute;
    inset: 0;
    z-index: 1;
    border-radius: 14px;
    cursor: pointer;
}
.trn-check[hidden] { display: none; }
.trn-check input { position: absolute; opacity: 0; pointer-events: none; }
.trn-check > span[aria-hidden] {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 1.5px solid color-mix(in srgb, var(--text) 35%, transparent);
    background: var(--bg);
    transition: background .15s ease, border-color .15s ease, transform .15s ease;
}
.trn-check input:checked + span[aria-hidden] {
    background: var(--accent-1) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23F5F0E6' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 12.5l4 4 8-9'/%3E%3C/svg%3E") center / 16px no-repeat;
    border-color: var(--accent-1);
    transform: scale(1.06);
}
.trn-check input:focus-visible + span[aria-hidden] { outline: 1px solid var(--accent-1); outline-offset: 2px; }
.trn-check__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.trn-topic:has(.trn-check input:checked) { border-color: var(--accent-1); box-shadow: 0 0 0 1px var(--accent-1) inset; }
.trn.is-ctor [data-ctor-able] .trn-topic__actions { display: none; }
.trn.is-ctor [data-ctor-able] .trn-topic__head,
.trn-topic--col .trn-topic__head { padding-right: 30px; }
.trn.is-ctor .trn-group,
.trn.is-ctor .trn-topic--soon { opacity: .35; pointer-events: none; }

.trn-ctor-bar {
    position: sticky;
    bottom: -36px;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 22px -40px -36px;
    padding: 14px 40px 18px;
    border-top: 1px solid var(--trn-line);
    background: color-mix(in srgb, var(--bg) 94%, transparent);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}
.trn-ctor-bar[hidden] { display: none; }
.trn-ctor-bar__count { flex: 1; font: 500 14px/1.4 var(--sans); color: var(--trn-muted); }

/* Сборник — значок песочных часов (логотип сайта) вместо фото. */
.trn-topic__thumb--icon { display: grid; place-items: center; color: var(--accent-1); padding: 0; }
/* «Экзамен» — все системы: плашка на всю ширину в цвете предмета. */
.trn-topic--exam {
    --pb1: var(--card-bg-light, #A8563A);
    --pb2: var(--card-bg-dark, #8B4327);
    --pt: var(--card-text, #F5F0E6);
    grid-column: 1 / -1;
    border: 0;
    background: linear-gradient(160deg, var(--pb1), var(--pb2));
    color: var(--pt);
    box-shadow: 0 2px 8px rgba(0, 0, 0, .08), 0 8px 24px rgba(0, 0, 0, .12);
}
.trn-topic--exam::before {
    content: "";
    position: absolute;
    inset: 6px;
    border: 1px solid var(--pt);
    opacity: .4;
    border-radius: 9px;
    pointer-events: none;
}
.trn-topic--exam .trn-topic__thumb--icon { color: var(--pt); background: color-mix(in srgb, var(--pt) 10%, transparent); border-color: color-mix(in srgb, var(--pt) 55%, transparent); }
.trn-topic--exam .trn-topic__meta { color: color-mix(in srgb, var(--pt) 80%, transparent); }
.trn-topic--exam .trn-topic__bar { background: color-mix(in srgb, var(--pt) 22%, transparent); }
.trn-topic--exam .trn-topic__bar i { background: var(--pt); }
.trn-topic--exam .trn-btn { position: relative; border-color: color-mix(in srgb, var(--pt) 50%, transparent); color: var(--pt); }
.trn-topic--exam .trn-btn--primary { background: var(--pt); border-color: var(--pt); color: var(--pb2); }
.trn-topic--exam .trn-btn:hover { border-color: var(--pt); color: var(--pt); }
.trn-topic--exam .trn-btn--primary:hover { background: color-mix(in srgb, var(--pt) 88%, var(--pb2)); color: var(--pb2); }
.trn.is-ctor .trn-topic--exam { opacity: .35; pointer-events: none; }

/* Своё окно подтверждения — в тоне сайта, поверх окна выбора. */
.trn-confirm {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: grid;
    place-items: center;
    padding: 20px;
    background: color-mix(in srgb, var(--text) 25%, transparent);
}
.trn-confirm[hidden] { display: none; }
.trn-confirm__box {
    width: 380px;
    max-width: 100%;
    padding: 26px 24px 20px;
    border-radius: 16px;
    background: var(--bg);
    box-shadow: 0 0 0 1px var(--trn-line), 0 24px 64px -12px rgba(0, 0, 0, .45);
    animation: trn-pop .22s cubic-bezier(.2, .8, .2, 1);
}
.trn-confirm__text { margin: 0; font: 16px/1.5 var(--sans); color: var(--text); text-align: center; }
.trn-confirm__actions { display: flex; justify-content: center; gap: 8px; margin-top: 20px; }
@keyframes trn-pop { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }

/* Карусель фото препарата: стрелки по бокам, точки снизу. */
.trn-gallery { position: relative; display: flex; align-items: center; justify-content: center; gap: 10px; }
.trn-gallery__nav {
    flex: none;
    width: 40px;
    height: 40px;
    border: 1px solid var(--trn-line);
    border-radius: 50%;
    background: var(--bg);
    color: var(--text);
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: border-color .2s ease, color .2s ease;
}
.trn-gallery__nav:hover { border-color: var(--accent-1); color: var(--accent-1); }
.trn-gallery__nav[hidden] { display: none; }
.trn-dots { display: flex; justify-content: center; gap: 8px; margin-top: 12px; }
.trn-dots[hidden] { display: none; }
.trn-dots__dot {
    width: 8px;
    height: 8px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: color-mix(in srgb, var(--text) 22%, transparent);
    cursor: pointer;
    transition: background .2s ease, transform .2s ease;
}
.trn-dots__dot.is-on { background: var(--accent-1); transform: scale(1.25); }

.trn-cab { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; margin-top: 18px; }
/* Плашка темы в кабинете «Мои тесты» — в цвете предмета, как плашка «Тренажёр». */
.trn-cab__card {
    --pb1: var(--card-bg-light, #A8563A);
    --pb2: var(--card-bg-dark, #8B4327);
    --pt: var(--card-text, #F5F0E6);
    --pa: var(--card-accent, #D4CCB8);
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 20px 20px 18px;
    border-radius: 12px;
    background: linear-gradient(160deg, var(--pb1), var(--pb2));
    color: var(--pt);
    text-decoration: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .08), 0 8px 24px rgba(0, 0, 0, .12);
    transition: transform .3s cubic-bezier(.2, .8, .2, 1), box-shadow .3s ease;
}
.trn-cab__card::before {
    content: "";
    position: absolute;
    inset: 6px;
    border: 1px solid var(--pt);
    opacity: .4;
    border-radius: 7px;
    pointer-events: none;
}
.trn-cab__card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0, 0, 0, .1), 0 14px 30px rgba(0, 0, 0, .16); }
.trn-cab__card:hover .trn-cab__go svg { transform: translateX(3px); }
.trn-cab__card:focus-visible { outline: 2px solid var(--accent-1); outline-offset: 3px; }
.trn-cab__subject { font: 500 11px/1 var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--pa); }
.trn-cab__title { font: 600 24px/1.15 var(--serif); }
.trn-cab__bar { display: block; height: 4px; margin: 8px 0 4px; border-radius: 4px; background: color-mix(in srgb, var(--pt) 22%, transparent); overflow: hidden; }
.trn-cab__bar i { display: block; height: 100%; border-radius: inherit; background: var(--pt); }
.trn-cab__foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.trn-cab__desc { font: 13px/1.4 var(--sans); color: color-mix(in srgb, var(--pt) 82%, transparent); }
.trn-cab__go { flex: none; display: inline-flex; align-items: center; gap: 2px; font: 500 13px/1 var(--sans); }
.trn-cab__go svg { transition: transform .2s ease; }
/* Ещё не начатый предмет: бледная плашка — видно, что тест есть. */
.trn-cab__card--idle { filter: grayscale(.85); opacity: .55; }
.trn-cab__card--idle:hover { filter: grayscale(.4); opacity: .8; }
.trn-cab__card--idle .trn-cab__bar { display: none; }
/* «Карточки» в меню кабинета — пока не нажимаются. */
.acc-side__item--soon, .acc-side__item--soon:hover { opacity: .5; cursor: default; background: transparent; }

@media (prefers-reduced-motion: reduce) {
    .trn__veil, .trn__win, .trn__full, .trn__body { transition: none; transform: none; }
    .trn-field.is-ok, .trn-field.is-wrong { animation: none; }
}

@media (max-width: 768px) {
    .trn-plate { margin-top: 20px; }
    .trn { padding: 12px; }
    .trn__win { padding: 44px 16px 20px; border-radius: 16px; }
    .trn__h { font-size: 32px; }
    .trn-topics { grid-template-columns: 1fr; gap: 10px; margin-top: 22px; }
    .trn-topic { grid-template-columns: 56px 1fr; padding: 14px; }
    .trn-topic__thumb { width: 56px; height: 56px; }
    .trn-topic__actions .trn-btn { flex: 1 1 auto; }
    .trn-ctor-toggle { top: 14px; right: 58px; }
    .trn__win { padding-top: 62px; }
    .trn-ctor-bar { bottom: -20px; margin: 18px -16px -20px; padding: 12px 16px 16px; }
    .trn-ctor-bar__count { font-size: 13px; }
    /* Телефон: стрелки поверх краёв фото, фото на всю ширину. */
    .trn-gallery { gap: 0; }
    .trn-gallery__nav { position: absolute; top: 50%; z-index: 1; width: 36px; height: 36px; margin-top: -18px;
        background: color-mix(in srgb, var(--bg) 85%, transparent); }
    .trn-gallery__nav--prev { left: 0; }
    .trn-gallery__nav--next { right: 0; }
    .trn-screen { padding: 14px 16px 40px; }
    .trn-photo { width: min(100%, 360px, calc(100svh - 330px)); min-width: 200px; }
    .trn-prompt { font-size: 21px; }
    .trn-btn { height: 40px; padding: 0 16px; }
}
