/* ==========================================================================
   Компоненты дизайн-системы.
   Живой каталог: /styleguide
   ========================================================================== */

/* --------------------------------------------------------------------------
   Карточка — основной способ разделить блоки. Границ нет: работает фон.
   -------------------------------------------------------------------------- */

.card {
    background: var(--surface);
    border-radius: var(--r-card);
    padding: var(--sp-5);
}

.card-tight { padding: var(--sp-4); }

/* Карточка без собственной плоскости: фон и тень снимаются, отступы
   остаются — контент ложится на холст, не прилипая к соседям.
   Для страничных шапок и служебных блоков, которым панель только мешает. */
.card.no-bg {
    background: none;
    box-shadow: none;
}

.card-title {
    display: flex;
    gap: var(--sp-3);
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: var(--sp-4);
}

.card-sub {
    color: var(--ink-3);
    font-size: 13px;
    margin-top: var(--sp-1);
}

/* --------------------------------------------------------------------------
   Раскладка с сайдбаром. Сайдбар справа: слева читается основной контент,
   и на узких экранах он честно уходит вниз, а не наверх.
   -------------------------------------------------------------------------- */

.layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: var(--sp-4);
    align-items: start;
}

.side {
    display: flex;
    flex-direction: column;
    gap: var(--sp-4);
    position: sticky;
    /* Ниже липкой шапки, иначе сайдбар уезжает под неё */
    top: calc(var(--header-h) + var(--sp-4));
}

@media (max-width: 980px) {
    .layout { grid-template-columns: minmax(0, 1fr); }
    .side { position: static; }
}

.side-card {
    background: var(--surface);
    border-radius: var(--r-card);
    padding: var(--sp-4);
}

.side-card > .label {
    display: block;
    margin-bottom: var(--sp-3);
}

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

.side-list a {
    display: flex;
    justify-content: space-between;
    gap: var(--sp-3);
    align-items: baseline;
    padding: 8px 10px;
    border-radius: 9px;
    font-size: 14px;
    line-height: 1.35;
    text-decoration: none;
    transition: background .15s ease;
}

.side-list a:hover { background: var(--surface-2); }

/* Карточка-ссылка в каталоге */
.tile {
    text-decoration: none;
    transition: background .15s ease;
}

.tile:hover { background: var(--surface-2); }

.tile-flat {
    background: var(--surface);
    border-radius: var(--r-inner);
    padding: 12px 16px;
    text-decoration: none;
    transition: background .15s ease;
}

.tile-flat:hover { background: var(--surface-2); }

/* --------------------------------------------------------------------------
   Шапка и подвал
   -------------------------------------------------------------------------- */

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--surface);
    /* Скругления только снизу: сверху блок упирается в край экрана */
    border-radius: 0 0 var(--r-card) var(--r-card);
    padding: var(--sp-3) var(--sp-4);
    display: flex;
    align-items: center;
    gap: var(--sp-4);
    /* Тень здесь оправдана: под шапку уезжает контент, а карточки такие же
       белые — без отделения шапка сливается с ними при прокрутке */
    box-shadow: var(--shadow-sticky);
}

.logo {
    display: flex;
    align-items: center;
    gap: 9px;
    font-weight: 700;
    font-size: 17px;
    letter-spacing: -.02em;
    white-space: nowrap;
    text-decoration: none;
}

/* Логомарка — svg-иконка сайта (frontend/web/images/logo.svg), скругление и цвет в ней самой */
.logo-mark {
    width: 26px;
    height: 26px;
    display: block;
}

.site-footer .logo {
    color: var(--ink-2);
    font-size: 15px;
}

.site-footer .logo .logo-mark {
    width: 22px;
    height: 22px;
}

.site-nav {
    display: flex;
    gap: 18px;
    font-size: 14.5px;
    color: var(--ink-2);
    margin-right: auto;
}

.site-nav a {
    text-decoration: none;
    white-space: nowrap;
}

.site-nav a:hover { color: var(--ink); }
.site-nav a[aria-current="page"] { color: var(--ink); font-weight: 600; }

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

/* Без белой плашки: подвал отделяется воздухом и тонкой линией */
.site-footer {
    padding: var(--sp-5) var(--sp-1) var(--sp-6);
    margin-top: var(--sp-2);
    border-top: 1px solid var(--hairline);
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-3);
    justify-content: space-between;
    align-items: center;
    color: var(--ink-3);
    font-size: 13.5px;
}

.site-footer a { text-decoration: none; }
.site-footer a:hover { color: var(--ink); }

/* --------------------------------------------------------------------------
   Кнопки. Жёлтый — только заливка основного действия.
   -------------------------------------------------------------------------- */

.btn {
    display: inline-block;
    font-size: 14.5px;
    font-weight: 650;
    border: 0;
    border-radius: var(--r-control);
    padding: 11px 18px;
    cursor: pointer;
    white-space: nowrap;
    text-align: center;
    text-decoration: none;
    transition: background .15s ease, color .15s ease;
}

.btn-brand { background: var(--brand); color: var(--on-brand); }
.btn-brand:hover { background: var(--brand-hover); }

.btn-quiet { background: var(--surface-2); color: var(--ink); }
.btn-quiet:hover { background: var(--surface-3); }

.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }

.btn-danger { background: var(--err-soft); color: var(--err); }

.btn-sm { padding: 8px 14px; font-size: 13.5px; }
.btn-wide { width: 100%; }

.btn:disabled,
.btn[aria-disabled="true"] {
    background: var(--surface-2);
    color: var(--ink-3);
    cursor: not-allowed;
}

/* --------------------------------------------------------------------------
   Метки, чипы, бейджи
   -------------------------------------------------------------------------- */

.chip {
    display: inline-block;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-2);
    background: var(--surface-2);
    border-radius: var(--r-pill);
    padding: 6px 13px;
}

.chip-ok { background: var(--ok-soft); color: var(--ok); }
.chip-brand { background: var(--brand-soft); color: var(--brand-soft-ink); }

.badge {
    display: inline-block;
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: .06em;
    border-radius: 6px;
    padding: 4px 8px;
}

.badge-pro { background: var(--invert-bg); color: var(--invert-ink); }
.badge-new { background: var(--brand-soft); color: var(--brand-soft-ink); }
.badge-ok { background: var(--ok-soft); color: var(--ok); }

/* --------------------------------------------------------------------------
   Формы
   -------------------------------------------------------------------------- */

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field > label {
    font-size: 12.5px;
    color: var(--ink-3);
    font-weight: 600;
}

.input {
    background: var(--surface-2);
    border: 0;
    border-radius: var(--r-control);
    padding: 12px 14px;
    font-size: 15px;
    color: var(--ink);
    width: 100%;
}

.input::placeholder { color: var(--ink-3); }
.input:focus { outline: 2px solid var(--ink); outline-offset: -2px; }

.search-input {
    flex: 1;
    min-width: 120px;
    background: var(--surface-2);
    border: 0;
    border-radius: var(--r-pill);
    padding: 9px 16px;
    font-size: 14.5px;
}

.segmented {
    display: inline-flex;
    background: var(--surface-2);
    border-radius: var(--r-control);
    padding: 4px;
    gap: 4px;
}

.segmented > * {
    font-size: 14px;
    font-weight: 600;
    color: var(--ink-2);
    padding: 8px 18px;
    border: 0;
    background: none;
    border-radius: 9px;
    cursor: pointer;
    text-decoration: none;
}

/* Переключатель на радиокнопках: сам input скрыт, но остаётся доступным
   с клавиатуры, а видимую роль играет подпись */
.segmented-option { padding: 0; }
.segmented-option input { position: absolute; opacity: 0; pointer-events: none; }

.segmented-option span {
    display: block;
    padding: 8px 18px;
    border-radius: 9px;
}

.segmented-option input:checked + span {
    background: var(--surface);
    color: var(--ink);
}

.segmented-option input:focus-visible + span {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}

:root[data-theme="dark"] .segmented-option input:checked + span { background: var(--surface-3); }

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .segmented-option input:checked + span { background: var(--surface-3); }
}

.segmented > [aria-selected="true"],
.segmented > [aria-current="true"] {
    background: var(--surface);
    color: var(--ink);
}

:root[data-theme="dark"] .segmented > [aria-selected="true"],
:root[data-theme="dark"] .segmented > [aria-current="true"] {
    background: var(--surface-3);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .segmented > [aria-selected="true"],
    :root:not([data-theme="light"]) .segmented > [aria-current="true"] {
        background: var(--surface-3);
    }
}

.field-error {
    font-size: 12.5px;
    color: var(--err);
}

/* --------------------------------------------------------------------------
   Калькулятор: форма слева, результат справа
   -------------------------------------------------------------------------- */

.calc {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: var(--sp-5);
    align-items: start;
}

.calc-fields {
    display: flex;
    flex-direction: column;
    gap: var(--sp-4);
}

.calc-fields .btn { width: fit-content; }

.calc-result {
    background: var(--brand);
    color: var(--on-brand);
    border-radius: var(--r-inner);
    padding: var(--sp-5);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.calc-result b {
    font-size: 38px;
    font-weight: 750;
    letter-spacing: -.035em;
    line-height: 1.05;
}

.calc-result span { font-size: 13.5px; font-weight: 600; opacity: .75; }
.calc-result i { font-style: normal; font-size: 13px; opacity: .7; margin-top: var(--sp-2); }

.calc-result-empty {
    background: var(--err-soft);
    color: var(--err);
}

@media (max-width: 860px) {
    .calc { grid-template-columns: minmax(0, 1fr); }
}

/* --------------------------------------------------------------------------
   Табы и пагинация
   -------------------------------------------------------------------------- */

.tabs {
    display: flex;
    gap: 6px;
    background: var(--surface-2);
    padding: 5px;
    border-radius: var(--r-control);
    width: fit-content;
    max-width: 100%;
    overflow-x: auto;
}

.tabs > * {
    padding: 8px 16px;
    border: 0;
    background: none;
    border-radius: 9px;
    font-size: 14px;
    font-weight: 600;
    color: var(--ink-2);
    white-space: nowrap;
    cursor: pointer;
    text-decoration: none;
}

.tabs > [aria-selected="true"] { background: var(--surface); color: var(--ink); }

:root[data-theme="dark"] .tabs > [aria-selected="true"] { background: var(--surface-3); }

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .tabs > [aria-selected="true"] { background: var(--surface-3); }
}

.pager {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.pager a,
.pager span {
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    font-size: 14px;
    font-weight: 600;
    color: var(--ink-2);
    background: var(--surface-2);
    text-decoration: none;
}

.pager [aria-current="page"] {
    background: var(--ink);
    color: var(--surface);
}

/* --------------------------------------------------------------------------
   Хлебные крошки
   -------------------------------------------------------------------------- */

.crumbs {
    display: flex;
    gap: var(--sp-2);
    font-size: 13px;
    color: var(--ink-3);
    flex-wrap: wrap;
}

.crumbs a {
    color: var(--ink-2);
    text-decoration: none;
}

.crumbs a:hover { color: var(--ink); }

/* --------------------------------------------------------------------------
   Таблицы: зебра вместо линий
   -------------------------------------------------------------------------- */

.table-wrap { overflow-x: auto; }

.table {
    border-collapse: collapse;
    width: 100%;
    font-size: 15px;
    min-width: 420px;
}

.table th {
    text-align: left;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--ink-3);
    font-weight: 650;
    padding: 0 12px 9px;
}

.table td { padding: 11px 12px; }

.table tbody tr:nth-child(odd) { background: var(--surface-2); }
.table tbody td:first-child { border-radius: 9px 0 0 9px; font-variant-numeric: normal; }
.table tbody td:last-child { border-radius: 0 9px 9px 0; text-align: right; font-weight: 650; }

/* --------------------------------------------------------------------------
   Сообщения
   -------------------------------------------------------------------------- */

.notice {
    display: flex;
    gap: var(--sp-3);
    padding: var(--sp-4);
    border-radius: var(--r-inner);
    background: var(--surface-2);
    font-size: 14.5px;
    line-height: 1.6;
}

.notice b { display: block; margin-bottom: 2px; }

.notice-mark {
    width: 5px;
    border-radius: var(--r-pill);
    background: var(--ink-3);
    flex: none;
}

.notice-warn { background: var(--warn-soft); }
.notice-warn .notice-mark { background: var(--warn); }

.notice-ok { background: var(--ok-soft); }
.notice-ok .notice-mark { background: var(--ok); }

.notice-err { background: var(--err-soft); }
.notice-err .notice-mark { background: var(--err); }

/* --------------------------------------------------------------------------
   Данные о продукте: шкала БЖУ, иконки, полосы, строки нутриентов
   -------------------------------------------------------------------------- */

.macro-icon {
    width: 22px;
    height: 22px;
    flex: none;
}

.icon-p { color: var(--macro-p); }
.icon-f { color: var(--macro-f); }
.icon-c { color: var(--macro-c); }

.gauge-modes {
    margin: 0 auto var(--sp-3);
    display: flex;
    width: fit-content;
    font-size: 13px;
}

.gauge-modes button { padding: 6px 14px; font-size: 13px; }

/* Полукруглая шкала: что именно она делит, выбирает читатель */
.gauge {
    width: 100%;
    max-width: 340px;
    height: auto;
    display: block;
    margin: 0 auto;
}

.gauge-track {
    fill: none;
    stroke: var(--surface-3);
    stroke-width: 13;
}

.gauge-seg {
    fill: none;
    stroke-width: 13;
}

.gauge-value {
    font-size: 36px;
    font-weight: 750;
    letter-spacing: -.03em;
    fill: var(--ink);
    font-variant-numeric: tabular-nums;
}

.gauge-unit {
    font-size: 12px;
    fill: var(--ink-3);
}

.macro-legend {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--sp-4);
}

.macro-legend-item {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    min-width: 0;
}

.macro-legend b {
    display: block;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -.02em;
    line-height: 1.2;
}

.macro-legend span {
    font-size: 13px;
    color: var(--ink-3);
}

.macro-kcal {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.macro-kcal b {
    font-size: 38px;
    font-weight: 750;
    letter-spacing: -.035em;
    line-height: 1;
}

/* Показатели, которых нет в шкале: часть жиров и углеводов плюс вода */
.macro-details {
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    border-top: 1px solid var(--hairline);
    padding-top: var(--sp-4);
    margin-top: var(--sp-4);
    font-size: 14px;
    color: var(--ink-2);
}

.macro-details > div {
    display: flex;
    justify-content: space-between;
    gap: var(--sp-3);
    align-items: baseline;
}

.macro-details b {
    font-weight: 600;
    color: var(--ink);
}

@media (max-width: 520px) {
    .macro-legend { grid-template-columns: minmax(0, 1fr); gap: var(--sp-3); }
}

.nutri {
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
}

.nutri-row {
    display: grid;
    grid-template-columns: 1fr 132px auto;
    gap: var(--sp-3);
    align-items: center;
    font-size: 14.5px;
}

.nutri-row b {
    text-align: right;
    font-weight: 650;
    min-width: 72px;
}

/* Шкала полосы — сравнение с другими продуктами категории, не с нормой */
.track {
    height: 8px;
    border-radius: var(--r-pill);
    background: var(--surface-3);
    overflow: hidden;
}

.track > i {
    display: block;
    height: 100%;
    border-radius: var(--r-pill);
    background: var(--accent);
}

.track > i.low { background: var(--ink-3); }

@media (max-width: 560px) {
    .nutri-row { grid-template-columns: 1fr auto; }
    .nutri-row .track { grid-column: 1 / -1; order: 3; }
}

/* --------------------------------------------------------------------------
   Инвертированная карточка и рекламные места
   -------------------------------------------------------------------------- */

.invert-card {
    background: var(--invert-bg);
    color: var(--invert-ink);
    border-radius: var(--r-card);
    padding: var(--sp-5);
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
    align-items: flex-start;
}

.invert-card p { color: var(--invert-muted); font-size: 13.5px; }
.invert-card .btn { background: var(--invert-btn-bg); color: var(--invert-btn-ink); }
.invert-card .badge-pro { background: var(--invert-btn-bg); color: var(--invert-btn-ink); }

/* Высота задаётся заранее, чтобы реклама не двигала контент (CLS) */
.adslot {
    background: var(--surface-2);
    border-radius: var(--r-inner);
    min-height: 120px;
    display: grid;
    place-items: center;
    color: var(--ink-3);
    font-size: 12.5px;
    letter-spacing: .06em;
    text-transform: uppercase;
    font-weight: 650;
}

.adslot-side { min-height: 250px; background: var(--surface); border-radius: var(--r-card); }

/* --------------------------------------------------------------------------
   Переключатель темы
   -------------------------------------------------------------------------- */

.theme-toggle {
    background: var(--surface-2);
    border: 0;
    border-radius: var(--r-pill);
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    cursor: pointer;
    color: var(--ink-2);
    flex: none;
}

.theme-toggle:hover { background: var(--surface-3); color: var(--ink); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-dark { display: none; }

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

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .theme-toggle .icon-dark { display: block; }
    :root:not([data-theme="light"]) .theme-toggle .icon-light { display: none; }
}

/* --------------------------------------------------------------------------
   Инфографика калькуляторов (cv-*): фигурка, шкала, пламя, тарелка, эквиваленты.
   Персонаж намеренно в фиксированных цветах бренда: жёлтый одинаков в обеих
   темах, контур тёмный на жёлтом читается везде.
   -------------------------------------------------------------------------- */

.calc-viz {
    display: flex;
    flex-direction: column;
    gap: var(--sp-4);
}

.cv-figure { width: min(190px, 52%); margin: 0 auto; display: block; }
.cv-walk { width: min(190px, 52%); margin: 0 auto; display: block; }

.cv-body { fill: #FFDD2D; stroke: #1B1C1E; stroke-width: 3.5; stroke-linejoin: round; }
.cv-limb { stroke: #F5CF1E; stroke-linecap: round; fill: none; }
.cv-limb-o { stroke: #1B1C1E; stroke-linecap: round; fill: none; }
.cv-face { fill: #1B1C1E; }
.cv-smile { fill: none; stroke: #1B1C1E; stroke-width: 2.6; stroke-linecap: round; }
.cv-blush { fill: #FF7A00; opacity: .22; }

.cv-breathe {
    animation: cv-breathe 3.4s ease-in-out infinite alternate;
    transform-box: view-box;
    transform-origin: 50% 100%;
}

@keyframes cv-breathe {
    from { transform: scaleY(1); }
    to { transform: scaleY(1.012); }
}

.cv-scale { position: relative; padding-top: 40px; max-width: 460px; margin: 0 auto; width: 100%; }

.cv-track { display: flex; height: 14px; border-radius: var(--r-pill); overflow: hidden; }
.cv-track i { height: 100%; }

.cv-ticks { position: relative; height: 18px; font-size: 11.5px; color: var(--ink-3); }
.cv-ticks span { position: absolute; transform: translateX(-50%); top: 2px; }

.cv-marker {
    position: absolute;
    top: 0;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: left .25s ease;
    z-index: 1;
}

.cv-marker output {
    background: var(--ink);
    color: var(--surface);
    font-size: 13.5px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: var(--r-pill);
}

.cv-marker::after {
    content: "";
    width: 2.5px;
    height: 24px;
    background: var(--ink);
    border-radius: 2px;
}

.cv-caption { text-align: center; display: flex; flex-direction: column; gap: 2px; }
.cv-caption > b { font-size: 16px; }
.cv-caption span { font-size: 13.5px; color: var(--ink-2); }

.cv-flame-stage { width: 116px; margin: 0 auto; display: block; }

.cv-flame-scale {
    transform-box: view-box;
    transform-origin: 50% 100%;
    transition: transform .35s ease;
}

.cv-flame-outer,
.cv-flame-inner { transform-box: view-box; transform-origin: 50% 92%; }
.cv-flame-outer { animation: cv-flick .62s ease-in-out infinite alternate; }
.cv-flame-inner { animation: cv-flick .45s ease-in-out infinite alternate-reverse; }

@keyframes cv-flick {
    from { transform: scaleY(1) scaleX(1); }
    to { transform: scaleY(1.05) scaleX(.97); }
}

.cv-split {
    display: flex;
    height: 16px;
    border-radius: var(--r-pill);
    overflow: hidden;
    gap: 2px;
    max-width: 460px;
    margin: 0 auto;
    width: 100%;
}

.cv-split i { height: 100%; transition: width .35s ease; }

.cv-split-legend {
    display: flex;
    justify-content: center;
    gap: var(--sp-3) var(--sp-5);
    font-size: 13.5px;
    color: var(--ink-2);
    flex-wrap: wrap;
}

.cv-split-legend b { color: var(--ink); }

.cv-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    margin-right: 5px;
}

.cv-proj {
    border-top: 1px solid var(--hairline);
    padding-top: var(--sp-4);
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
    align-items: center;
}

.cv-proj-head { font-size: 14px; font-weight: 650; }

.cv-proj-chart { width: 100%; max-width: 460px; height: auto; }

.cv-plate { width: min(300px, 84%); margin: 0 auto; display: block; }

.cv-plate-seg {
    fill: none;
    transition: stroke-dasharray .4s ease, stroke-dashoffset .4s ease;
}

.cv-cutlery { stroke: var(--ink-3); stroke-width: 3; stroke-linecap: round; fill: none; }

.cv-bob {
    animation: cv-bob var(--step, .8s) ease-in-out infinite alternate;
    transform-box: view-box;
    transform-origin: 50% 100%;
}

@keyframes cv-bob {
    from { transform: translateY(0); }
    to { transform: translateY(-4px); }
}

.cv-arm-f, .cv-arm-b, .cv-leg-f, .cv-leg-b { transform-box: view-box; }
.cv-arm-f { transform-origin: 136px 104px; }
.cv-arm-b { transform-origin: 84px 104px; }
.cv-leg-f { transform-origin: 118px 210px; }
.cv-leg-b { transform-origin: 102px 210px; }

.cv-arm-f, .cv-leg-b { animation: cv-swing-a var(--step, .8s) ease-in-out infinite alternate; }
.cv-arm-b, .cv-leg-f { animation: cv-swing-b var(--step, .8s) ease-in-out infinite alternate; }

@keyframes cv-swing-a {
    from { transform: rotate(14deg); }
    to { transform: rotate(-14deg); }
}

@keyframes cv-swing-b {
    from { transform: rotate(-14deg); }
    to { transform: rotate(14deg); }
}

.cv-ground {
    stroke: var(--ink-3);
    stroke-width: 3;
    stroke-linecap: round;
    stroke-dasharray: 16 14;
    animation: cv-roll var(--step, .8s) linear infinite;
}

@keyframes cv-roll {
    to { stroke-dashoffset: -30; }
}

.cv-foods {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--sp-2);
    max-width: 560px;
    margin: 0 auto;
    width: 100%;
}

.cv-food {
    background: var(--surface-2);
    border-radius: var(--r-inner);
    padding: var(--sp-3) var(--sp-2);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    text-align: center;
}

.cv-food svg { color: var(--ink-2); }

.cv-food b {
    font-size: 19px;
    font-weight: 750;
    letter-spacing: -.02em;
    color: var(--accent);
}

.cv-food span { font-size: 12px; color: var(--ink-3); line-height: 1.25; }

.cv-note { font-size: 12.5px; color: var(--ink-3); text-align: center; }

.cv-share { display: flex; justify-content: center; margin-top: var(--sp-2); }
.cv-share .btn { display: inline-flex; align-items: center; gap: 8px; }

@media (max-width: 440px) {
    .cv-foods { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
    .cv-breathe, .cv-flame-outer, .cv-flame-inner, .cv-bob,
    .cv-arm-f, .cv-arm-b, .cv-leg-f, .cv-leg-b, .cv-ground { animation: none; }
    .cv-marker, .cv-flame-scale, .cv-plate-seg, .cv-split i { transition: none; }
}

/* --------------------------------------------------------------------------
   Порция: вес задаётся здесь, цифры на карточке пересчитывает product.js
   -------------------------------------------------------------------------- */

.portion-controls {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: var(--sp-4);
    align-items: center;
}

.portion-stepper {
    display: flex;
    gap: 6px;
    align-items: center;
}

.portion-stepper .btn {
    width: 44px;
    height: 44px;
    padding: 0;
    font-size: 20px;
    line-height: 44px;
}

.portion-input {
    position: relative;
    width: 124px;
}

.portion-input .input {
    padding-right: 34px;
    text-align: right;
    font-weight: 650;
    -moz-appearance: textfield;
    appearance: textfield;
}

.portion-input .input::-webkit-outer-spin-button,
.portion-input .input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.portion-input > span {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--ink-3);
    font-size: 14px;
}

.portion-range {
    width: 100%;
    height: 28px;
    margin: 0;
    accent-color: var(--accent);
    cursor: pointer;
}

.portion-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: var(--sp-3);
}

.portion-chips .chip {
    border: 0;
    cursor: pointer;
    font-family: inherit;
}

.portion-chips .chip:hover { background: var(--surface-3); color: var(--ink); }

.portion-chips .chip[aria-pressed="true"] {
    background: var(--brand-soft);
    color: var(--brand-soft-ink);
}

.portion-equiv {
    margin-top: var(--sp-3);
    font-size: 14px;
}

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

/* --------------------------------------------------------------------------
   Сравнение: кнопка на карточке, плавающий список, таблица
   -------------------------------------------------------------------------- */

.title-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--sp-3);
    flex-wrap: wrap;
}

.cmp-toggle[aria-pressed="true"] {
    background: var(--brand-soft);
    color: var(--brand-soft-ink);
}

.cmp-panel {
    position: fixed;
    right: var(--sp-4);
    bottom: var(--sp-4);
    z-index: 40;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: var(--sp-2);
}

.cmp-pill {
    border: 0;
    cursor: pointer;
    background: var(--invert-bg);
    color: var(--invert-ink);
    border-radius: var(--r-pill);
    padding: 11px 18px;
    font-size: 14px;
    font-weight: 650;
    box-shadow: var(--shadow-sticky);
}

.cmp-drawer {
    width: 320px;
    max-width: calc(100vw - 2 * var(--sp-4));
    background: var(--surface);
    border-radius: var(--r-card);
    box-shadow: 0 8px 32px rgba(0, 0, 0, .18);
    padding: var(--sp-4);
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
}

.cmp-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cmp-x {
    border: 0;
    background: none;
    cursor: pointer;
    color: var(--ink-3);
    font-size: 22px;
    line-height: 1;
    padding: 0 4px;
}

.cmp-x:hover { color: var(--ink); }

.cmp-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.cmp-list li {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: 6px 8px;
    border-radius: 9px;
    background: var(--surface-2);
    font-size: 14px;
}

.cmp-list li a {
    flex: 1;
    min-width: 0;
    color: var(--ink);
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cmp-list li button {
    border: 0;
    background: none;
    cursor: pointer;
    color: var(--ink-3);
    font-size: 18px;
    line-height: 1;
    padding: 0 4px;
}

.cmp-list li button:hover { color: var(--err); }

.cmp-note { font-size: 13px; }

.cmp-actions {
    display: flex;
    gap: var(--sp-2);
}

@media (max-width: 520px) {
    .cmp-panel {
        left: var(--sp-3);
        right: var(--sp-3);
        bottom: var(--sp-3);
        align-items: stretch;
    }

    .cmp-drawer { width: auto; max-width: none; }
    .cmp-pill { align-self: flex-end; }
}

/* Таблица сравнения: первая колонка липкая, лидер строки — оранжевым */
.cmp-table { min-width: 560px; }

.cmp-table td,
.cmp-table th { text-align: right; }

.cmp-table td { font-weight: 500; }

.cmp-table th:first-child,
.cmp-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
    text-align: left;
    background: var(--surface);
}

.cmp-table tbody tr:nth-child(odd) th:first-child { background: var(--surface-2); }

.cmp-table tbody th[scope="row"] {
    font-weight: 500;
    color: var(--ink-2);
    padding: 11px 12px;
    border-radius: 9px 0 0 9px;
}

.cmp-table .cmp-group,
.cmp-table .cmp-group th {
    background: none;
    border-radius: 0;
}

.cmp-table .cmp-group th {
    padding: var(--sp-5) 12px var(--sp-2);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--ink-3);
}

.cmp-table thead th { vertical-align: top; }

.cmp-product a {
    color: var(--ink);
    font-weight: 700;
    text-decoration: none;
}

.cmp-product a:hover { text-decoration: underline; }

.cmp-product .dim {
    display: block;
    font-size: 12px;
    font-weight: 400;
    margin-top: 2px;
}

.cmp-remove {
    display: inline-block;
    margin-top: 4px;
    color: var(--ink-3);
    text-decoration: none;
    font-size: 18px;
    line-height: 1;
}

.cmp-remove:hover { color: var(--err); }

.cmp-table td.is-max {
    color: var(--accent);
    font-weight: 700;
}

.cmp-table .cmp-diff { color: var(--ink-3); }

.cmp-table.hide-same tr.is-same { display: none; }

/* Ссылка «сравнить» рядом с соседом по категории в сайдбаре */
.side-row {
    display: flex;
    align-items: center;
    gap: 2px;
}

.side-row > a:first-child { flex: 1; min-width: 0; }

.side-list .side-cmp {
    flex: none;
    padding: 6px 8px;
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: .04em;
    color: var(--ink-3);
    border-radius: var(--r-pill);
}

.side-list .side-cmp:hover { color: var(--ink); }

/* Названия продуктов в шапке сравнения — обычным шрифтом, а не капителью колонок */
.cmp-table thead .cmp-product a {
    display: block;
    font-size: 15px;
    letter-spacing: 0;
    text-transform: none;
}

.cmp-table thead .cmp-product .dim {
    text-transform: none;
    letter-spacing: 0;
}

.cmp-table tbody th[scope="row"] {
    font-size: 15px;
    letter-spacing: 0;
    text-transform: none;
}

/* Липкая шапка таблицы сравнения: при прокрутке видно, что с чем сравнивается.
   Обёртка без overflow, иначе sticky прилипал бы к ней, а не к странице */
.cmp-wrap { overflow: visible; }

.cmp-table thead th {
    position: sticky;
    top: var(--header-h);
    z-index: 3;
    background: var(--surface);
    padding-top: var(--sp-3);
    box-shadow: 0 1px 0 var(--hairline);
}

.cmp-table thead th:first-child { z-index: 4; }

@media (max-width: 700px) {
    .cmp-table {
        min-width: 0;
        table-layout: fixed;
        font-size: 12.5px;
    }

    .cmp-table th:first-child,
    .cmp-table td:first-child { width: 30%; }

    .cmp-table td,
    .cmp-table tbody th[scope="row"],
    .cmp-table thead th {
        padding-left: 6px;
        padding-right: 6px;
    }

    .cmp-table tbody th[scope="row"],
    .cmp-table td { font-size: 12.5px; }

    .cmp-table thead .cmp-product a {
        font-size: 13px;
        overflow-wrap: anywhere;
        hyphens: auto;
    }

    .cmp-table thead .cmp-product .dim { display: none; }
}

/* --------------------------------------------------------------------------
   Подборки-рейтинги: плитки раздела и список с полосами
   -------------------------------------------------------------------------- */

.coll-tile h3 { font-size: 17px; }

.coll-leaders {
    margin: 0;
    padding-left: 1.3em;
    font-size: 14px;
    line-height: 1.5;
}

.coll-leaders .num { color: var(--ink); font-weight: 600; }

.coll-more { font-size: 13px; }

.rank-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.rank-row {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr) 180px auto;
    gap: var(--sp-3);
    align-items: center;
    padding: 10px 12px;
    border-radius: 12px;
}

.rank-row:nth-child(odd) { background: var(--surface-2); }

.rank-num {
    font-size: 15px;
    font-weight: 700;
    color: var(--ink-3);
    text-align: center;
}

.rank-row:nth-child(-n+3) .rank-num { color: var(--accent); }

.rank-main {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.rank-name {
    color: var(--ink);
    font-weight: 600;
    text-decoration: none;
    font-size: 15.5px;
}

.rank-name:hover { text-decoration: underline; }

.rank-meta { font-size: 13px; }

.rank-value {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 5px;
}

.rank-value b {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -.01em;
    white-space: nowrap;
}

.rank-track {
    display: block;
    width: 100%;
    height: 6px;
    border-radius: 999px;
    background: var(--surface-3);
    overflow: hidden;
}

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

.rank-cmp {
    border: 0;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
}

.rank-cmp:hover { background: var(--surface-3); color: var(--ink); }

@media (max-width: 700px) {
    .rank-row {
        grid-template-columns: 28px minmax(0, 1fr) auto;
        grid-template-areas:
            "num main value"
            "num cmp cmp";
        row-gap: 6px;
    }

    .rank-num { grid-area: num; }
    .rank-main { grid-area: main; }
    .rank-value { grid-area: value; width: 120px; }
    .rank-cmp { grid-area: cmp; justify-self: start; }
}

/* Название нутриента на карточке ведёт в рейтинг «где больше всего» */
.nutri-link {
    color: inherit;
    text-decoration: none;
    border-bottom: 1px dashed var(--ink-3);
}

.nutri-link:hover { border-bottom-color: var(--ink); }

/* Таблица мер и весов */
.msr-table td { vertical-align: top; }

.msr-table td b { display: block; }

.msr-kcal,
.msr-note {
    display: block;
    font-size: 12px;
    font-weight: 400;
}

.msr-block h3 { font-size: 15px; margin-bottom: var(--sp-2); }

.msr-pieces { min-width: 0; font-size: 14px; }

.msr-pieces td { padding: 8px 10px; }

.msr-pieces td:first-child a {
    color: var(--ink);
    font-weight: 600;
    text-decoration: none;
}

.msr-pieces td:first-child a:hover { text-decoration: underline; }

.msr-pieces td:first-child .dim {
    display: block;
    font-size: 12.5px;
}

.msr-pieces td:last-child { font-weight: 400; }

.portion-chips a.chip { text-decoration: none; }
.portion-chips a.chip:hover { background: var(--surface-3); color: var(--ink); }

/* Ссылки на справочные разделы в подвале */
.footer-links {
    display: flex;
    gap: var(--sp-4);
    font-size: 13.5px;
}

.footer-links a {
    color: var(--ink-2);
    text-decoration: none;
}

.footer-links a:hover { color: var(--ink); text-decoration: underline; }

/* Приглашение в Telegram-канал в сайдбаре */
.side-tg-text {
    font-size: 13.5px;
    color: var(--ink-2);
    margin: 0 0 var(--sp-3);
    line-height: 1.5;
}
