/* ===========================================================================
   Оформление публичного вьювера.

   Принцип: страница - это одна 3D-сцена на весь экран и минимум элементов
   поверх неё. Никаких панелей со списком деталей, никаких названий - см.
   требования в README (публичный показ не раскрывает состав изделия).

   Две темы - тёмная (по умолчанию) и светлая, переключатель - кнопка в
   тулбаре (main.js, applyTheme/toggleTheme), выбор запоминается в
   localStorage. Тема меняет и панели/кнопки, и фон 3D-сцены
   (--scene-gradient, см. оба блока ниже) - структура градиента (тёмный/
   светлый край против противоположного силуэта) одна и та же в обеих
   темах, меняется только полярность. */
:root {
    --bg: #121315;
    --bg-panel: rgba(22, 23, 27, 0.96);
    --border: rgba(226, 138, 43, 0.18);
    --text: #eae8e4;
    --text-dim: #9d9890;
    --accent: #e28a2b;
    --accent-contrast: #0d0e10;
    --danger: #ff6b6b;
    /* Тонкая декоративная CAD-сетка (см. #model-gallery ниже) - едва
       заметный акцентный оттенок поверх фона, не самостоятельный цвет. */
    --grid-line: rgba(226, 138, 43, 0.05);
    --grid-line-major: rgba(226, 138, 43, 0.10);
    --shadow: 0 4px 18px rgba(0, 0, 0, 0.50);
    --radius: 2px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --scene-gradient: linear-gradient(to bottom, #23262d 0%, #121315 55%, #0b0d0e 100%);
}

/* Светлая тема - тот же набор переменных, светлые значения. Ставится
   атрибутом на <html> (main.js, applyTheme) - вместо media-запроса на
   системную тему специально: выбор пользователя (кнопка) должен
   побеждать системную настройку, а не только дополнять её. */
/* Светлая тема (Концепция «Coyote Tan & Desert Field» / Mil-Spec Cerakote):
   Тактический койот, песочно-полевой пустынный оттенок, янтарно-бронзовый
   акцент и строгая броневая контрастная типографика. */
html[data-theme="light"] {
    --bg: #e2ded6;
    --bg-panel: #edeae3;
    --border: #c8c2b7;
    --text: #1a1917;
    --text-dim: #635f58;
    --accent: #b45309;
    --accent-contrast: #ffffff;
    --danger: #dc2626;
    /* Заметно выше, чем в тёмной теме - тёмный акцент на светлом фоне
       "тает" гораздо быстрее с ростом прозрачности, чем светлый на тёмном. */
    --grid-line: rgba(180, 83, 9, 0.14);
    --grid-line-major: rgba(180, 83, 9, 0.24);
    --shadow: 0 2px 8px rgba(26, 25, 23, 0.10);
    /* Пустынный градиент сцены: теплый песчаный свет и выветренный койот */
    --scene-gradient: linear-gradient(to bottom, #f3f0e8 0%, #e2ded6 55%, #c8c2b7 100%);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;              /* страница не скроллится - скроллится сцена */
    background: var(--bg);
    color: var(--text);
    font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

#app { position: relative; width: 100%; height: 100%; }

/* --- 3D-сцена ----------------------------------------------------------- */
#viewer-container {
    position: absolute;
    inset: 0;
    /* touch-action: none - иначе браузер на телефоне перехватывает жесты
       себе (скролл/зум страницы), и модель не вращается. */
    touch-action: none;
    /* Мягкий вертикальный градиент вместо плоской заливки (ТЗ, раздел 5.2) -
       canvas библиотеки рисуется ПРОЗРАЧНЫМ (viewer-core.js,
       renderer.setClearAlpha(0)), настоящий фон - этот CSS-градиент позади
       него. Значение - переменная --scene-gradient (см. :root/[data-theme]
       выше) - меняется вместе с темой интерфейса, структура (более тёмный/
       светлый край против противоположного силуэта) сохраняется в обеих. */
    background: var(--scene-gradient);
}
#viewer-container canvas {
    display: block;
    outline: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

/* --- Оверлеи (загрузка, ошибка) ----------------------------------------- */
.overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    background: var(--bg);
    z-index: 30;
}
.overlay[hidden] { display: none; }

.spinner {
    width: 38px; height: 38px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Уважаем системную настройку "меньше движения". */
@media (prefers-reduced-motion: reduce) {
    .spinner { animation-duration: 3s; }
}

.loading-text { color: var(--text-dim); }
.loading-progress { color: var(--text-dim); font-size: 12px; min-height: 16px; }

.error-box {
    max-width: 420px;
    padding: 20px 24px;
    text-align: center;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-panel);
}
.error-title { font-weight: 600; margin-bottom: 8px; color: var(--danger); }
.error-text { color: var(--text-dim); font-size: 13px; word-break: break-word; }

/* --- Панель инструментов ------------------------------------------------- */
#toolbar {
    position: absolute;
    top: calc(12px + var(--safe-top));
    right: 12px;
    right: calc(12px + var(--safe-right));
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 20;
}

body.in-3d #toolbar,
#app.in-3d-mode #toolbar {
    top: calc(12px + var(--safe-top));
    right: 12px;
    right: calc(12px + var(--safe-right));
}

/* ТЗ_Активно_06, §5.3 - диагностический оверлей (?debug=1 / Ctrl+Shift+F,
   см. web/js/main.js, toggleDebugOverlay) - не часть обычного UI, поэтому
   вне общей системы кнопок/панелей ниже, минимальный самостоятельный стиль. */
.debug-overlay {
    position: fixed;
    top: calc(70px + var(--safe-top));
    left: calc(12px + var(--safe-left));
    z-index: 999;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.75);
    color: #7CFC00;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    line-height: 1.5;
    white-space: pre;
    border-radius: 4px;
    pointer-events: none;
    user-select: none;
}

.tool-btn {
    width: 44px; height: 44px;        /* 44px - минимальная удобная цель для пальца */
    display: flex; align-items: center; justify-content: center;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-panel);
    color: var(--text);
    cursor: pointer;
    backdrop-filter: blur(6px);
    box-shadow: var(--shadow);
    transition: background 0.15s, color 0.15s;
}
.tool-btn:hover {
    background: rgba(60, 64, 72, 0.96);
    border-color: var(--accent);
    color: var(--accent);
}
html[data-theme="light"] .tool-btn:hover {
    background: #ded9cf;
    border-color: var(--accent);
    color: var(--accent);
}
.tool-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tool-btn.is-active { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); }
/* Контурный стиль (Tabler Icons). fill:none по умолчанию - кроме значка
   темы (солнце/луна), который остаётся залитым: он один залитый среди
   контурных не случайно - визуально отличает переключатель темы от
   остальных, "инструментов просмотра" (см. fill="currentColor"
   stroke="none" прямо на его <svg> в index.html, который иначе перебило
   бы это правило). */
.tool-btn svg {
    width: 22px; height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
#btn-theme svg,
#btn-gallery-theme svg {
    fill: currentColor;
    stroke: none;
}


/* --- Панель замеров ------------------------------------------------------ */
#measure-panel {
    position: absolute;
    top: calc(64px + var(--safe-top));
    left: calc(12px + var(--safe-left));
    width: 250px;
    max-width: calc(100vw - 80px);
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-panel);
    backdrop-filter: blur(6px);
    box-shadow: var(--shadow);
    z-index: 45;
}
#measure-panel[hidden] { display: none; }

.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.panel-title { font-weight: 600; font-size: 13px; }
.panel-close {
    border: none; background: none; color: var(--text-dim);
    font-size: 20px; line-height: 1; cursor: pointer; padding: 0 4px;
}
.panel-close:hover { color: var(--text); }

.measure-modes { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.mode-btn {
    flex: 1 1 auto;
    padding: 7px 9px;
    font-size: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: transparent;
    color: var(--text);
    cursor: pointer;
    white-space: nowrap;
}
.mode-btn:hover { border-color: var(--accent); }
.mode-btn.is-active { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); }

.measure-result {
    min-height: 46px;
    padding: 8px 10px;
    border-radius: var(--radius);
    background: rgba(0, 0, 0, 0.28);
    font-size: 13px;
    white-space: pre-line;
    color: var(--text);
    /* Цифры замеров должны быть моноширинными - иначе числа "прыгают"
       по ширине при каждом обновлении и их неудобно читать. */
    font-variant-numeric: tabular-nums;
}

.measure-clear {
    width: 100%;
    margin-top: 8px;
    padding: 7px;
    font-size: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
}
.measure-clear:hover { color: var(--text); border-color: var(--accent); }

/* Метка замера прямо в сцене (число рядом с измеренной точкой). */
.measure-label {
    position: absolute;
    transform: translate(-50%, -50%);
    padding: 3px 7px;
    border-radius: var(--radius);
    background: rgba(12, 14, 17, 0.88);
    color: #ffe08a;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    pointer-events: none;      /* метка не должна перехватывать клики по модели */
    white-space: nowrap;
    z-index: 15;
}

/* --- Узкий экран (признак по ширине - тот же результат на десктопе с
   узким окном браузера, здесь это уместно одинаково) - только размер
   панели замеров, положение тулбара решают правила ниже. -------------- */
@media (max-width: 600px) {
    #measure-panel {
        left: 8px; right: 8px;
        width: auto;
        max-width: none;
        top: auto;
        bottom: calc(8px + var(--safe-bottom));
        max-height: 60vh;
        overflow-y: auto;
    }
}

/* ===========================================================================
   ПОЛОЖЕНИЕ ТУЛБАРА НА ТЕЛЕФОНЕ - туда, куда реально дотягивается большой
   палец (низ экрана в портрете, правый край колонкой в альбоме), а не
   туда, где он удобен с мышью на десктопе.

   Признак "это телефон" - ширина/высота экрана + ориентация, БЕЗ
   (hover:none)/(pointer:coarse). Та пара media-фич формально честнее
   ("настоящий палец, а не мышь"), но ненадёжна на практике - часть
   реальных браузеров/режимов не отчитывается coarse-pointer/no-hover
   даже на настоящем сенсорном телефоне. Цена простого признака - очень
   узкое десктопное окно тоже получит "телефонный" тулбар (безобидно,
   просто непривычно для мыши), а не риск пропустить настоящий телефон. */

/* Портретная ориентация:
   Кнопка темы отделяется и переходит в правый верхний угол (#site-topbar #btn-gallery-theme),
   а из тулбара скрывается */
@media (orientation: portrait) {
    #btn-theme {
        display: none !important;
    }
}

/* Портрет - нижняя панель на всю ширину (родная нижняя навигация iOS/
   Android, не плавающая колонка кнопок) - собственный фон/тень уже здесь
   на #toolbar, у отдельных .tool-btn фон убран, чтобы не получилось
   "кнопки в кнопке". 900px с запасом покрывает любой телефон и большинство
   планшетов в портрете. */
@media (max-width: 900px) and (orientation: portrait) {
    body.in-3d #toolbar,
    #app.in-3d-mode #toolbar,
    #toolbar {
        flex-direction: row;
        justify-content: space-around;
        top: auto;
        left: 0;
        right: 0;
        bottom: 0;
        padding: 8px 10px calc(8px + var(--safe-bottom));
        gap: 4px;
        background: var(--bg-panel);
        backdrop-filter: blur(6px);
        border-top: 1px solid var(--border);
        box-shadow: var(--shadow);
        border-radius: 0;
    }
    .tool-btn {
        background: transparent;
        border: none;
        box-shadow: none;
        backdrop-filter: none;
    }
    .tool-btn.is-active { background: var(--accent); border-radius: var(--radius); }

    /* Панель замеров садится НАД нижним тулбаром, а не поверх него -
       72px с запасом покрывает высоту панели (44px кнопки + вертикальные
       отступы) на любом реальном телефоне. */
    #measure-panel {
        bottom: calc(72px + var(--safe-bottom));
    }
}

/* На десктопе в портрете (высокие вертикальные мониторы):
   тулбар справа начинается под кнопкой темы (top: 12px + 44px + 8px = 64px) */
@media (min-width: 901px) and (orientation: portrait) {
    body.in-3d #toolbar,
    #app.in-3d-mode #toolbar,
    #toolbar {
        top: calc(64px + var(--safe-top));
    }
}

/* Альбомная ориентация в 3D-режиме:
   Кнопка темы интегрирована прямо в тулбар (#btn-theme),
   поэтому отдельно в правом верхнем углу шапки (#btn-gallery-theme) она скрыта,
   образуя единый монолитный блок кнопок */
@media (orientation: landscape) {
    #btn-gallery-theme,
    body.in-3d #site-topbar #btn-gallery-theme,
    #app.in-3d-mode #site-topbar #btn-gallery-theme,
    #site-topbar.mode-3d #btn-gallery-theme {
        display: none !important;
    }
    body.in-gallery #site-topbar #btn-gallery-theme,
    #app.in-gallery-mode #site-topbar #btn-gallery-theme,
    #site-topbar:not(.mode-3d) #btn-gallery-theme {
        display: flex !important;
    }
}

/* Альбом - тулбар КОЛОНКОЙ, но не в углу - вертикально по центру правого
   края, где его находит большой палец руки, которой держат телефон
   лёжа. Включает в себя кнопку темы (#btn-theme), образуя единый блок.

   Живая находка (24.09.2026, широкий монитор): у (max-height:520px) ветки
   изначально не было верхней границы по ширине - "короткое landscape-окно"
   само по себе не значит "телефон", это ловил и обычный десктоп, если
   окно браузера становится невысоким (смена масштаба ОС/браузера, не
   максимизированное окно). На широком мониторе это ошибочно включало
   телефонную раскладку. Добавлена and (max-width:1024px) - тот же порог,
   что уже используют другие правила этого файла для "точно телефон", штатные
   десктопные окна с этим условием больше не пересекаются. */
@media (max-height: 520px) and (max-width: 1024px) and (orientation: landscape), (max-width: 900px) and (orientation: landscape) {
    body.in-3d #toolbar,
    #app.in-3d-mode #toolbar,
    #toolbar {
        flex-direction: column;
        top: 50%;
        bottom: auto;
        right: calc(10px + var(--safe-right));
        transform: translateY(-50%);
    }
    /* Левый верхний угол занят плашкой бренда [◇ ❯ ❯] OMNIDRIVE (top: 12px; left: 12px; height: 40px) -
       панель замеров садится под неё (top: 58px; left: 12px;), чтобы не перекрывать бренд.
       Тулбар в альбоме сидит справа колонкой, пересечения нет. */
    #measure-panel {
        left: calc(12px + var(--safe-left));
        right: auto;
        top: calc(58px + var(--safe-top));
        bottom: auto;
        width: 260px;
        max-width: calc(100vw - 90px);   /* не залезать под колонку тулбара справа */
        max-height: calc(100vh - 68px - var(--safe-top) - var(--safe-bottom));
        overflow-y: auto;
    }
}

/* Компактный режим для сверхнизких альбомных экранов (высота <= 340px) */
@media (max-height: 340px) and (max-width: 1024px) and (orientation: landscape) {
    .tool-btn {
        width: 38px;
        height: 38px;
    }
    .tool-btn svg {
        width: 20px;
        height: 20px;
    }
    body.in-3d #toolbar,
    #app.in-3d-mode #toolbar,
    #toolbar {
        gap: 5px;
    }
}

/* --- Галерея выбора изделия - полноэкранный экран ВМЕСТО 3D-сцены,
   показывается только когда моделей на сервере несколько (см. main.js,
   showGallery/openModel) - обычная публичная ссылка на одно изделие или
   прямая ссылка "?model=..." её вообще не видит.

   Число карточек в ряд НЕ вычисляется вручную под конкретные экраны -
   grid-auto-fill сам укладывает столько колонок, сколько влезает при
   минимальной ширине карточки: телефон в портрете даёт 2, планшет/десктоп -
   4-6, без отдельных медиа-запросов под каждый случай. */
#model-gallery {
    position: absolute;
    inset: 0;
    z-index: 40;   /* выше тулбара и панели замеров - полностью их закрывает, пока открыта */
    background-color: var(--bg);
    /* Живая находка (24.09.2026): .gallery-scroll и .gallery-footer -
       обычные block-сиблинги, поэтому при малом числе моделей (контент
       короче экрана) футер просто заканчивался там, где кончались
       карточки, а ниже до самого низа окна оставался пустой фон -
       выглядело как "футер потерялся"/съехал, особенно на широких
       мониторах или при уменьшении масштаба браузера (эффективная высота
       окна растёт быстрее, чем количество моделей). display:flex column
       здесь + flex:1 0 auto на .gallery-scroll ниже - классический приём
       "прижатого футера": если контента мало, .gallery-scroll растягивается
       и заполняет пустоту сама, подталкивая футер точно к нижнему краю
       окна; если контента много (не помещается) - ничего не меняется,
       #model-gallery как и раньше скроллит содержимое (overflow-y:auto
       ниже), футер идёт сразу после карточек. Мобильные брейкпоинты ниже
       по файлу (max-width:600px, альбомный телефон) переопределяют это
       собственным display/flex независимо - не пересекается. */
    display: flex;
    flex-direction: column;
    /* Декоративная CAD-чертёжная сетка (явный запрос владельца - "что-то
       декоративное в стиле" для пустых полей по бокам на широких экранах).
       Растянута на весь #model-gallery, а не только на поля - но карточки
       (.gallery-card) и футер (.gallery-footer) уже непрозрачны своим
       собственным фоном, так что сетка реально видна только в пустых полях
       и зазорах между карточками, ровно там, где нужно. Мелкая сетка 40px +
       крупная разметка каждые 200px - имитация масштабной сетки чертежа,
       не просто "клетка в клетку". */
    background-image:
        repeating-linear-gradient(0deg, transparent, transparent 199px, var(--grid-line-major) 199px, var(--grid-line-major) 200px),
        repeating-linear-gradient(90deg, transparent, transparent 199px, var(--grid-line-major) 199px, var(--grid-line-major) 200px),
        repeating-linear-gradient(0deg, transparent, transparent 39px, var(--grid-line) 39px, var(--grid-line) 40px),
        repeating-linear-gradient(90deg, transparent, transparent 39px, var(--grid-line) 39px, var(--grid-line) 40px);
    overflow-y: auto;
    animation: gallery-in 0.35s ease-out;
}
#model-gallery.is-hiding {
    animation: gallery-out 0.22s cubic-bezier(0.4, 0, 1, 1) forwards;
    pointer-events: none;
}
#model-gallery[hidden] { display: none; }
@keyframes gallery-in {
    from { opacity: 0; transform: scale(0.98); }
    to { opacity: 1; transform: scale(1); }
}
@keyframes gallery-out {
    from { opacity: 1; transform: scale(1); }
    to { opacity: 0; transform: scale(0.98); }
}
@media (prefers-reduced-motion: reduce) {
    #model-gallery { animation: none; }
    #model-gallery.is-hiding { animation: none; }
}

.gallery-scroll {
    /* Живая находка (24.09.2026, 2К/широкие мониторы): было 1240px -
       фиксированный px-потолок не может одновременно (а) оставить ровно
       3 колонки на 1920x1200@125% (эффективно ~1536px) и (б) дать 4-5+
       колонок на настоящем 2К (2560/2048@125%) - любое ОДНО фиксированное
       число либо режет оба случая одинаково, либо не режет никак (тогда
       auto-fill сам добирает 4-ю колонку уже на 1536px, живой фидбэк
       владельца - там ожидались именно 3, тем же размером карточки).
       min(94vw, 1900px) - потолок контейнера растёт ВМЕСТЕ с шириной
       экрана вместо фиксированного числа: на ~1536px даёт ~1445px (с
       запасом хватает только на 3 колонки по 340px+), на 2560/2048px
       упирается в абсолютный предел 1900px (там влезает уже 4-5 колонок).
       Сам минимальный размер карточки (.gallery-grid, minmax) не трогаем -
       по отдельному фидбэку владельца увеличенный до 400px минимум
       давал слишком крупную карточку и более редкие/резкие переходы
       между количеством колонок при смене масштаба браузера. */
    /* flex:1 0 auto - см. комментарий у #model-gallery (display:flex) выше:
       эта растяжка и прижимает .gallery-footer к нижнему краю окна, когда
       карточек мало. width:100% ОБЯЗАТЕЛЕН вместе с margin:0 auto ниже -
       живая находка: внутри flex-колонки margin:auto по горизонтали (кросс-
       ось) сам по себе отменяет растяжение на всю ширину (align-items:
       stretch по умолчанию не действует, когда на кросс-оси есть auto-
       отступ) - без width:100% .gallery-scroll сжимался под условный
       "предпочитаемый" размер сетки auto-fill вместо честной доступной
       ширины, и на широких экранах опять получалось меньше колонок, чем
       должно было влезать. */
    flex: 1 0 auto;
    width: 100%;
    max-width: min(94vw, 1900px);
    margin: 0 auto;
    /* padding-top очищает фиксированную полноширинную шапку витрины */
    padding: calc(72px + var(--safe-top)) 24px calc(28px + var(--safe-bottom));
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.gallery-scroll::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

/* --- Полноширинная шапка / Панель бренда (#site-topbar) ------------------ */
#site-topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-sizing: border-box;
    transition: background-color 0.2s, border-color 0.2s, height 0.2s;
}

/* В витрине/галерее: монолитная полноширинная CAD-шапка во всю ширину экрана */
body.in-gallery #site-topbar,
#app.in-gallery-mode #site-topbar,
#site-topbar:not(.mode-3d) {
    height: calc(56px + var(--safe-top));
    padding: var(--safe-top) calc(20px + var(--safe-right)) 0 calc(20px + var(--safe-left));
    background: rgba(11, 13, 17, 0.88);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    pointer-events: auto;
}
html[data-theme="light"] body.in-gallery #site-topbar,
html[data-theme="light"] #app.in-gallery-mode #site-topbar,
html[data-theme="light"] #site-topbar:not(.mode-3d) {
    background: rgba(226, 222, 214, 0.95);
    border-bottom: 1px solid var(--border);
}

/* В 3D-режиме: основа прозрачна, плашка бренда [◇ ❯ ❯] OMNIDRIVE строго в
   ЛЕВОМ ВЕРХНЕМ УГЛУ (top: 12px; left: 12px;), кнопки темы/языка - в правом верхнем */
body.in-3d #site-topbar,
#app.in-3d-mode #site-topbar,
#site-topbar.mode-3d {
    height: 0;
    align-items: flex-start;
    padding: calc(12px + var(--safe-top)) calc(12px + var(--safe-right)) 0 calc(12px + var(--safe-left));
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-bottom: none;
    pointer-events: none;
}
#site-topbar > * {
    pointer-events: auto;
}

.topbar-brand-group {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-nav {
    display: flex;
    align-items: center;
    gap: 6px;
}

.topbar-nav-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 40px;
    padding: 0 12px;
    font-size: 11.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-dim);
    cursor: pointer;
    backdrop-filter: blur(6px);
    transition: border-color 0.15s, color 0.15s, background-color 0.15s;
    user-select: none;
    white-space: nowrap;
}

.topbar-nav-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(226, 138, 43, 0.08);
}

.topbar-nav-btn:active {
    background: var(--accent);
    color: var(--accent-contrast);
}

.topbar-nav-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    display: block;
}

.topbar-nav-mark,
.rfq-mark {
    font-size: 14px;
    line-height: 1;
}

html[data-theme="light"] .topbar-nav-btn {
    background: #ded9cf;
    border-color: #cfc8be;
    color: #475569;
}
html[data-theme="light"] .topbar-nav-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: #d4cec4;
}

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

.topbar-rfq-btn {
    height: 40px;
    padding: 0 14px;
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    background: rgba(226, 138, 43, 0.12);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    color: var(--accent);
    cursor: pointer;
    box-shadow: 0 0 10px rgba(226, 138, 43, 0.15);
    transition: background-color 0.15s, color 0.15s, transform 0.12s;
    user-select: none;
    white-space: nowrap;
}

.topbar-rfq-btn:hover {
    background: var(--accent);
    color: var(--accent-contrast);
    transform: translateY(-1px);
}

.topbar-rfq-btn:active {
    transform: scale(0.98);
}

html[data-theme="light"] .topbar-rfq-btn {
    background: #b45309;
    border-color: #92400e;
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(180, 83, 9, 0.25);
}
html[data-theme="light"] .topbar-rfq-btn:hover {
    background: #92400e;
}

/* Скрытие корпоративной навигации, RFQ и оперативного чата в 3D-режиме
   (открытая модель - чистый вьювер, чат с менеджером относится только
   к публичной витрине/каталогу, где посетитель ещё выбирает технику). */
body.in-3d #topbar-nav,
body.in-3d #btn-open-rfq,
body.in-3d #btn-chat-toggle,
body.in-3d #chat-widget-panel,
#app.in-3d-mode #topbar-nav,
#app.in-3d-mode #btn-open-rfq,
#app.in-3d-mode #btn-chat-toggle,
#app.in-3d-mode #chat-widget-panel,
#site-topbar.mode-3d #topbar-nav,
#site-topbar.mode-3d #btn-open-rfq {
    display: none !important;
}



.brand-link {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 40px;
    padding: 0 14px 0 6px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-panel);
    color: var(--text);
    text-decoration: none;
    cursor: pointer;
    backdrop-filter: blur(6px);
    box-shadow: var(--shadow);
    transition: border-color 0.15s, color 0.15s, transform 0.12s;
    user-select: none;
}
.brand-link:hover {
    border-color: var(--accent);
    color: var(--accent);
}
.brand-link:active {
    transform: scale(0.97);
}
.brand-mark-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    flex-shrink: 0;
}
.brand-mark-icon svg {
    width: 34px;
    height: 34px;
    display: block;
}
.brand-text {
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.gallery-header-btn {
    width: 40px;
    height: 40px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-panel);
    color: var(--text);
    cursor: pointer;
    backdrop-filter: blur(6px);
    box-shadow: var(--shadow);
    transition: border-color 0.15s, color 0.15s, background-color 0.15s;
}
.gallery-header-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}
.gallery-header-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
.gallery-header-btn:not(.gallery-lang-btn) svg {
    width: 22px;
    height: 22px;
}
.gallery-header-btn[hidden] {
    display: none;
}
.gallery-lang-btn svg,
.lang-btn svg {
    width: 20px;
    height: 14px;
    aspect-ratio: 20 / 14;
    border-radius: 0;
    display: block;
    box-sizing: border-box;
    overflow: hidden;
    flex-shrink: 0;
    outline: none;
    box-shadow: none;
}

.gallery-lang-btn svg .flag-outline,
.gallery-lang-btn svg rect[stroke],
.lang-btn svg .flag-outline,
.lang-btn svg rect[stroke] {
    stroke: rgba(0, 0, 0, 0.22);
}

html[data-theme="light"] .gallery-lang-btn svg,
html[data-theme="light"] .lang-btn svg {
    outline: none;
    box-shadow: none;
}

html[data-theme="light"] .gallery-lang-btn svg .flag-outline,
html[data-theme="light"] .gallery-lang-btn svg rect[stroke],
html[data-theme="light"] .lang-btn svg .flag-outline,
html[data-theme="light"] .lang-btn svg rect[stroke] {
    stroke: rgba(0, 0, 0, 0.35);
}

/* --- Инженерные CAD/HUD-углы (Раздел 4.6 ТЗ) -------------------------------- */
.has-corners {
    position: relative;
}
.has-corners::before,
.has-corners::after {
    content: '';
    position: absolute;
    width: 8px;
    height: 8px;
    pointer-events: none;
    z-index: 3;
    opacity: 0.75;
    transition: border-color 0.2s, opacity 0.2s;
}
.has-corners::before {
    top: -1px;
    left: -1px;
    border-top: 1.5px solid var(--accent);
    border-left: 1.5px solid var(--accent);
}
.has-corners::after {
    bottom: -1px;
    right: -1px;
    border-bottom: 1.5px solid var(--accent);
    border-right: 1.5px solid var(--accent);
}
.gallery-card:hover.has-corners::before,
.gallery-card:hover.has-corners::after,
.gallery-card:focus-visible.has-corners::before,
.gallery-card:focus-visible.has-corners::after,
.gallery-card:has(.gallery-card-action-btn:focus-visible).has-corners::before,
.gallery-card:has(.gallery-card-action-btn:focus-visible).has-corners::after {
    opacity: 1;
    border-color: var(--accent);
}

.gallery-grid {
    display: grid;
    /* Живая находка (24.09.2026): пробовали поднять минимум карточки до
       400px, чтобы получить ровно 3 колонки на 1920x1200@125% - владельцу
       не понравился получившийся размер карточки (крупнее привычного) и
       то, что переход между 3 и 4 колонками при смене масштаба браузера
       стал более резким/редким (больше шаг - реже меняется количество
       колонок). Вернули исходные 340px - карточки остаются привычного
       размера, auto-fill сам добавляет колонку чаще (более гранулярный,
       "плавный" на вид отклик при смене масштаба), а место на широких
       экранах по-прежнему съедает увеличенный потолок .gallery-scroll
       (max-width) выше по файлу, а не размер самой карточки. */
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 20px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.gallery-grid::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}
@media (min-width: 601px) and (max-width: 1024px) {
    .gallery-grid { grid-template-columns: repeat(2, 1fr); gap: 16px; }
}

/* --- Закрывающий футер витрины -------------------------------------------
   Только десктоп/планшет (обычный вертикальный скролл .gallery-scroll) -
   на телефоне (max-width:600px) #model-gallery/.gallery-scroll превращены
   в несворачиваемую на один экран горизонтальную карусель (flex,
   justify-content:space-between, фиксированная высота), где футер как
   ещё один flex-элемент сломал бы уже подобранную высоту карточки -
   см. правило display:none в @media max-width:600px ниже по файлу. */
.gallery-footer {
    margin-top: 40px;
    width: 100%;
    /* #model-gallery - flex column (см. комментарий там) - без явного
       flex-shrink:0 футер по умолчанию (flex-shrink:1) мог бы сжаться,
       если контент когда-нибудь окажется впритык по высоте; ему всегда
       нужен его собственный полный размер. */
    flex-shrink: 0;
    border-top: 1px solid var(--border);
    /* Непрозрачный (var(--bg-panel), не полупрозрачный оттенок) - иначе
       декоративная CAD-сетка #model-gallery проступает сквозь футер и
       выглядит как продолжение сетки, а не отдельная закрывающая полоса. */
    background: var(--bg-panel);
}
.gallery-footer-inner {
    /* Без max-width - блоки прижимаются к самым краям окна (явный запрос
       владельца), а не выровнены по узкой колонке карточек: сюда позже
       добавится больше контента (донаты, чат и т.п.), нужен запас места. */
    padding: 20px calc(24px + var(--safe-right)) 20px calc(24px + var(--safe-left));
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
}
.gallery-footer-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-dim);
}
.footer-brand-mark {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    color: var(--accent);
}
.footer-brand-mark svg { width: 100%; height: 100%; }
.footer-brand-text-wrap {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.footer-brand-text {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--text);
}
.footer-copyright {
    font-size: 11.5px;
    color: var(--text-dim);
}
.gallery-footer-nav {
    display: flex;
    align-items: center;
    gap: 4px;
}
.footer-nav-link {
    height: 32px;
    padding: 0 12px;
    font-size: 11.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: none;
    border: 1px solid transparent;
    border-radius: var(--radius);
    color: var(--text-dim);
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background-color 0.15s;
}
.footer-nav-link:hover {
    border-color: var(--border);
    color: var(--accent);
    background: rgba(255, 255, 255, 0.03);
}

/* Основная навигация + юридические ссылки - ОДНА строка, без собственных
   верхних отступов/границы (тот вариант раздувал высоту футера на два
   яруса - явное замечание владельца). .footer-links-divider отделяет их
   друг от друга визуально, а не отступом сверху. */
.gallery-footer-links {
    display: flex;
    align-items: center;
    gap: 16px;
}
.footer-links-divider {
    width: 1px;
    height: 16px;
    background: var(--border);
    flex-shrink: 0;
}
.gallery-footer-legal {
    display: flex;
    align-items: center;
    gap: 16px;
}
.footer-legal-link {
    padding: 0;
    font-size: 10.5px;
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    text-decoration: underline;
    text-decoration-color: transparent;
    transition: color 0.15s, text-decoration-color 0.15s;
}
.footer-legal-link:hover {
    color: var(--accent);
    text-decoration-color: currentColor;
}

@keyframes card-in {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: translateY(0); }
}
.gallery-card {
    display: flex;
    flex-direction: column;
    width: 100%;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.18);
    transition: transform 0.22s cubic-bezier(.2,.8,.2,1), box-shadow 0.22s ease-out,
                border-color 0.22s, opacity 0.15s;
    animation: card-in 0.5s cubic-bezier(.2,.8,.2,1) both;
    animation-delay: calc(var(--i, 0) * 55ms);
}
@media (prefers-reduced-motion: reduce) {
    .gallery-card { animation: none; }
}
.gallery-card:hover,
.gallery-card:focus-visible,
.gallery-card:has(.gallery-card-action-btn:focus-visible) {
    transform: translateY(-5px);
    box-shadow: 0 0 0 1px var(--accent), 0 16px 28px -8px rgba(0,0,0,0.45);
    border-color: var(--accent);
    outline: none;
}
.gallery-card:hover .gallery-thumb img,
.gallery-card:focus-visible .gallery-thumb img,
.gallery-card:has(.gallery-card-action-btn:focus-visible) .gallery-thumb img {
    transform: scale(1.05);
}
.gallery-card:hover .gallery-card-title,
.gallery-card:focus-visible .gallery-card-title,
.gallery-card:has(.gallery-card-action-btn:focus-visible) .gallery-card-title {
    color: var(--accent);
}
.gallery-card:active { transform: translateY(-2px) scale(0.99); }

.gallery-card-open-btn {
    display: flex;
    flex-direction: column;
    width: 100%;
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    text-align: left;
    font: inherit;
    color: inherit;
    cursor: pointer;
}
.gallery-card-open-btn:focus-visible { outline: none; }
.gallery-card.is-opening { opacity: 0.45; transform: scale(0.97); }

/* Миниатюра изделия */
.gallery-thumb {
    position: relative;
    aspect-ratio: 4 / 3;
    background: radial-gradient(circle at 50% 35%, rgba(127,127,127,0.10), rgba(127,127,127,0.02) 70%);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}
.gallery-thumb::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 3;
    background: transparent;
    pointer-events: auto;
}
.gallery-thumb img {
    width: 100%; height: 100%; object-fit: contain;
    transition: transform 0.35s cubic-bezier(.2,.8,.2,1);
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-user-drag: none;
    -webkit-touch-callout: none;
}
.gallery-thumb svg {
    width: 38%; height: 38%;
    fill: none;
    stroke: var(--text-dim);
    stroke-width: 1.4;
    opacity: 0.55;
}

/* Мгновенная смена камуфляжа на миниатюрах (0 мс) */
.gallery-thumb[data-camo="woodland"] img,
.drawer-thumb[data-camo="woodland"] img {
    filter: none;
}
.gallery-thumb[data-camo="desert"] img,
.drawer-thumb[data-camo="desert"] img {
    filter: sepia(0.38) saturate(1.22) hue-rotate(-8deg) brightness(1.05);
}
.gallery-thumb[data-camo="arctic"] img,
.drawer-thumb[data-camo="arctic"] img {
    filter: grayscale(0.7) brightness(1.22) contrast(1.12);
}
.gallery-thumb[data-camo="urban"] img,
.drawer-thumb[data-camo="urban"] img {
    filter: grayscale(0.85) contrast(1.22) brightness(0.88);
}

/* Свотчи камуфляжей под миниатюрой (Раздел 4.4 ТЗ) */
.gallery-camo-swatches {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: rgba(0, 0, 0, 0.16);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}
html[data-theme="light"] .gallery-camo-swatches {
    background: #f1f5f9;
    border-top: 1px solid #cbd5e1;
    border-bottom: 1px solid #cbd5e1;
}
html[data-theme="light"] .camo-swatch {
    border-color: #94a3b8;
}
.camo-swatch {
    width: 20px;
    height: 20px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 3px;
    cursor: pointer;
    position: relative;
    transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.camo-swatch:hover {
    transform: scale(1.15);
    border-color: var(--accent);
}
.camo-swatch.is-active {
    transform: scale(1.18);
    border-color: var(--accent);
    box-shadow: 0 0 0 1.5px var(--accent);
}

.gallery-card-body {
    padding: 12px 14px 14px;
    display: flex;
    flex-direction: column;
    flex: 1;
}
.gallery-card-title {
    font-size: 14.5px;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    line-height: 1.3;
    color: var(--text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color 0.2s;
}
.gallery-card-desc {
    font-size: 12px;
    line-height: 1.4;
    color: var(--text-dim);
    margin-top: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Экспресс-чипы ключевых характеристик (Этап 3 ТЗ) */
.gallery-chips {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin: 9px 0 8px;
}
.gallery-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    padding: 2px 7px;
    border-radius: var(--radius);
    font-size: 11px;
    font-variant-numeric: tabular-nums;
}
html[data-theme="light"] .gallery-chip {
    background: #e2e8f0;
    border-color: #b8c4d2;
    color: #0f172a;
}
html[data-theme="light"] .gallery-chip-lbl {
    color: #475569;
}
html[data-theme="light"] .gallery-chip-val {
    color: #0f172a;
}

/* Ряд кнопок действия на карточке */
.gallery-card-actions {
    display: flex;
    align-items: center;
    margin-top: auto;
    padding-top: 10px;
    width: 100%;
}
.gallery-card-details-btn {
    display: none;
}

/* Строгая функциональная кнопка действия (3D Просмотр ↗) */
.gallery-card-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex: 1 1 100%;
    width: 100%;
    margin-top: 0;
    min-height: 38px;
    padding: 8px 12px;
    background: rgba(77, 159, 255, 0.10);
    border: 1px solid rgba(77, 159, 255, 0.35);
    border-radius: var(--radius);
    color: var(--accent);
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    cursor: pointer;
    transition: background-color 0.18s, border-color 0.18s, color 0.18s, transform 0.15s;
}
.gallery-card:hover .gallery-card-action-btn,
.gallery-card:focus-visible .gallery-card-action-btn,
.gallery-card:has(.gallery-card-action-btn:focus-visible) .gallery-card-action-btn {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-contrast);
    transform: translateY(-1px);
}
.gallery-card-open { display: none; }
html[data-theme="light"] .gallery-card-action-btn {
    background: #0f172a;
    border: 1px solid #1e293b;
    border-radius: var(--radius);
    color: #f8fafc;
    box-shadow: none;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
html[data-theme="light"] .gallery-card:hover .gallery-card-action-btn,
html[data-theme="light"] .gallery-card:focus-visible .gallery-card-action-btn,
html[data-theme="light"] .gallery-card-action-btn:hover {
    background: #1e293b;
    border-color: var(--accent);
    color: #ffffff;
    box-shadow: 0 0 0 1px var(--accent);
}

/* Раскрывающиеся технические характеристики карточки (specs из meta.json,
   см. /admin/orientation - редактор label/value пар). Модели без specs
   этот блок не получают вовсе (main.js создаёт его условно) - пустого
   "воздуха" под карточкой без характеристик нет. */
.gallery-card-specs-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: none;
    border: none;
    border-top: 1px solid var(--border);
    padding: 9px 13px;
    margin: 0;
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-dim);
    cursor: pointer;
    transition: color 0.2s;
}
.gallery-card-specs-toggle:hover,
.gallery-card-specs-toggle:focus-visible {
    color: var(--accent);
    outline: none;
}
.specs-chevron {
    width: 14px; height: 14px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform 0.25s ease;
    flex-shrink: 0;
}
.gallery-card-specs-toggle.is-open .specs-chevron {
    transform: rotate(180deg);
}

/* Техника "0fr/1fr" на grid-template-rows - раскрытие/сворачивание БЕЗ
   ручного замера высоты в JS (той высоты, что была бы у content: auto),
   современный CSS-приём, работает с любым числом строк характеристик. */
.gallery-card-specs-wrap {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.3s ease;
}
.gallery-card-specs-wrap.is-open {
    grid-template-rows: 1fr;
}
@media (prefers-reduced-motion: reduce) {
    .gallery-card-specs-wrap { transition: none; }
}
.gallery-card-specs-inner {
    overflow: hidden;
    min-height: 0;
}
.gallery-card-specs-list {
    margin: 0;
    padding: 2px 13px 12px;
}
.specs-view-row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 5px 0;
    border-top: 1px solid var(--border);
    font-size: 12px;
    line-height: 1.35;
}
.specs-view-row:first-child { border-top: none; }
.specs-view-row dt {
    color: var(--text-dim);
    flex: 0 1 auto;
}
.specs-view-row dd {
    margin: 0;
    color: var(--text);
    font-weight: 600;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* --- Боковая шторка / Паспорт изделия (#model-details-drawer) ------------- */
.details-drawer-overlay {
    position: fixed;
    inset: 0;
    z-index: 70;
    pointer-events: auto;
}
.details-drawer-overlay[hidden] {
    display: none;
}
.details-drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(7, 9, 12, 0.68);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    opacity: 0;
    transition: opacity 0.25s ease;
}
.details-drawer-overlay.is-open .details-drawer-backdrop {
    opacity: 1;
}
.details-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 460px;
    max-width: 100vw;
    background: var(--bg-panel);
    border-left: 1px solid var(--border);
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 71;
    overflow: hidden;
}
.details-drawer-overlay.is-open .details-drawer {
    transform: translateX(0);
}
.drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: calc(16px + var(--safe-top)) 20px 14px;
    border-bottom: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.15);
    flex-shrink: 0;
}
.drawer-title-wrap {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.drawer-badge {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--accent);
    text-transform: uppercase;
}
.drawer-title {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--text);
}
.drawer-close-btn {
    min-width: 44px;
    min-height: 44px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: transparent;
    color: var(--text-dim);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.15s, color 0.15s, background-color 0.15s;
}
.drawer-close-btn svg {
    width: 16px;
    height: 16px;
    display: block;
}
.drawer-close-btn:hover {
    border-color: var(--accent);
    color: var(--text);
    background: rgba(255, 255, 255, 0.05);
}
.drawer-close-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
.drawer-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 20px 20px calc(24px + var(--safe-bottom));
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.drawer-preview-wrap {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.drawer-thumb {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 10;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
    background: rgba(0, 0, 0, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}
.drawer-thumb::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 3;
    background: transparent;
    pointer-events: auto;
}
.drawer-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: filter 0.15s ease;
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-user-drag: none;
    -webkit-touch-callout: none;
}
.drawer-camo-bar {
    display: none;
}
.drawer-cta-wrap {
    width: 100%;
}
.btn-drawer-3d {
    width: 100%;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border-radius: var(--radius);
    border: 1px solid var(--accent);
    background: var(--accent);
    color: var(--accent-contrast);
    font-weight: 700;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    cursor: pointer;
    box-shadow: none;
    transition: transform 0.12s, opacity 0.15s, background-color 0.15s;
}
.btn-drawer-3d:hover {
    box-shadow: none;
    opacity: 0.92;
}
.btn-drawer-3d:active {
    transform: scale(0.98);
}
.btn-3d-mark {
    font-size: 16px;
}
.drawer-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.drawer-section-title {
    margin: 0;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dim);
}
.drawer-desc-text {
    margin: 0;
    font-size: 13.5px;
    line-height: 1.6;
    color: var(--text);
}
/* --- Донаты (РАЗДЕЛ Ж.9 ТЗ) - адрес TRC20 + кнопка копирования --------- */
.donate-address-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    padding: 10px 12px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.donate-address-value {
    flex: 1 1 auto;
    min-width: 0;
    font-family: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;
    font-size: 12.5px;
    color: var(--text);
    overflow-wrap: break-word;
    word-break: break-all;
    user-select: all;
}
.btn-copy {
    flex-shrink: 0;
    height: 30px;
    padding: 0 12px;
    font: inherit;
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: var(--accent);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    color: var(--accent-contrast);
    cursor: pointer;
    transition: opacity 0.15s;
}
.btn-copy:hover {
    opacity: 0.85;
}
.drawer-specs-list {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.drawer-spec-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 9px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    background: rgba(0, 0, 0, 0.08);
}
.drawer-spec-row:last-child {
    border-bottom: none;
}
.drawer-spec-lbl {
    color: var(--text-dim);
    flex: 1 1 auto;
}
.drawer-spec-val {
    font-weight: 600;
    color: var(--text);
    text-align: right;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}

/* Детальная шторка и элементы в светлой теме (Tactical Titanium) */
html[data-theme="light"] .details-drawer {
    background: #edf1f6;
    border-left: 1px solid #b8c4d2;
    box-shadow: -8px 0 32px rgba(15, 23, 42, 0.18);
}
html[data-theme="light"] .drawer-header {
    background: #e2e8f0;
    border-bottom: 1px solid #b8c4d2;
}
html[data-theme="light"] .drawer-close-btn {
    background: #edf1f6;
    border-color: #b8c4d2;
    color: #475569;
}
html[data-theme="light"] .drawer-close-btn:hover {
    border-color: #0f172a;
    color: #0f172a;
    background: #e2e8f0;
}
html[data-theme="light"] .drawer-thumb {
    background: #dce3ed;
    border-color: #b8c4d2;
}
html[data-theme="light"] .drawer-camo-bar {
    display: none;
}
html[data-theme="light"] .drawer-specs-list {
    border-color: #b8c4d2;
}
html[data-theme="light"] .drawer-spec-row {
    background: #f1f5f9;
    border-bottom: 1px solid #cbd5e1;
}
html[data-theme="light"] .drawer-spec-row:nth-child(even) {
    background: #e8ecf2;
}
html[data-theme="light"] .drawer-spec-lbl {
    color: #475569;
}
html[data-theme="light"] .drawer-spec-val {
    color: #0f172a;
}
html[data-theme="light"] .btn-drawer-3d {
    background: #0f172a;
    border: 1px solid #1e293b;
    color: #f8fafc;
    box-shadow: none;
}
html[data-theme="light"] .btn-drawer-3d:hover {
    background: #1e293b;
    border-color: var(--accent);
    color: #ffffff;
    box-shadow: 0 0 0 1px var(--accent);
}
html[data-theme="light"] .tool-btn {
    background: #edf1f6;
    border-color: #b8c4d2;
    color: #1e293b;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}
html[data-theme="light"] .tool-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}
html[data-theme="light"] .tool-btn.is-active {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-contrast);
}
html[data-theme="light"] #measure-panel {
    background: #edf1f6;
    border-color: #b8c4d2;
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.12);
}
html[data-theme="light"] .radial-center-disc {
    background: #edf1f6;
    border-color: #b8c4d2;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.12);
}

/* --- Инженерные боковые шторки (#drawer-tech, #drawer-about, #drawer-contacts) */
.info-drawer-overlay {
    z-index: 60;
}
.info-drawer-overlay .details-drawer {
    width: 440px;
    max-width: 100vw;
}

.contacts-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 4px;
}

.contact-row {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.contact-lbl {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-dim);
}

.contact-val {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--accent);
    text-decoration: none;
    word-break: break-all;
}

.contact-type-icon {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    display: inline-block;
}

.contact-val[href]:hover {
    text-decoration: underline;
}

html[data-theme="light"] .contact-row {
    background: #f1f5f9;
    border-color: #cbd5e1;
}
html[data-theme="light"] .contact-lbl {
    color: #475569;
}
html[data-theme="light"] .contact-val {
    color: var(--accent);
}

/* --- Модальное окно запроса ТКП (#modal-rfq) ------------------------------ */
.rfq-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 70;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    box-sizing: border-box;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease-out;
}

.rfq-modal-overlay.is-open {
    opacity: 1;
    pointer-events: auto;
}

.rfq-modal-overlay[hidden] {
    display: none;
}

.rfq-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(7, 9, 12, 0.82);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.rfq-modal-dialog {
    position: relative;
    width: 100%;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 32px);
    overflow: hidden;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6);
    z-index: 2;
    box-sizing: border-box;
    transform: scale(0.96) translateY(8px);
    transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.rfq-modal-overlay.is-open .rfq-modal-dialog {
    transform: scale(1) translateY(0);
}

.rfq-modal-dialog .drawer-header {
    flex-shrink: 0;
    padding: 12px 20px 10px;
}

.rfq-modal-body {
    padding: 14px 20px 16px;
    overflow-y: auto;
}

.rfq-lead-text {
    font-size: 12.5px;
    color: var(--text-dim);
    margin: 0 0 10px;
    line-height: 1.4;
}

.rfq-status-banner {
    padding: 10px 12px;
    margin-bottom: 12px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    line-height: 1.4;
    text-align: center;
    border: 1px solid #5fd68a;
    background: rgba(95, 214, 138, 0.12);
    color: #5fd68a;
}
.rfq-status-banner[hidden] {
    display: none;
}

.rfq-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.rfq-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 0;
    text-align: left;
}

.rfq-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text);
    margin-bottom: 0;
}

.rfq-input,
.rfq-select {
    width: 100%;
    height: 38px;
    box-sizing: border-box;
    padding: 0 12px;
    font-size: 13px;
    font-family: inherit;
    color: var(--text);
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
}

.rfq-textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 12px;
    font-size: 13px;
    font-family: inherit;
    color: var(--text);
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
    resize: vertical;
    min-height: 52px;
    max-height: 80px;
}

.rfq-input:focus,
.rfq-select:focus,
.rfq-textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
}

.rfq-input::placeholder,
.rfq-textarea::placeholder {
    color: var(--text-dim);
    opacity: 0.7;
}

.rfq-select option {
    background: var(--bg-panel);
    color: var(--text);
}

.rfq-actions {
    margin-top: 6px;
}

.rfq-submit-btn {
    width: 100%;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    cursor: pointer;
}

html[data-theme="light"] .rfq-modal-dialog {
    background: #e8e3d9;
    border-color: #cfc8be;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.25);
}

html[data-theme="light"] .rfq-input,
html[data-theme="light"] .rfq-select,
html[data-theme="light"] .rfq-textarea {
    background: #ffffff;
    border-color: #cbd5e1;
    color: #0f172a;
}

html[data-theme="light"] .rfq-input:focus,
html[data-theme="light"] .rfq-select:focus,
html[data-theme="light"] .rfq-textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
}

html[data-theme="light"] .rfq-status-banner {
    background: #e6f4ea;
    border-color: #34a853;
    color: #137333;
}


/* Точки-индикаторы карусели (РАЗДЕЛ Ж.2 ТЗ) - только на телефоне, где
   галерея - горизонтальная карусель (см. main.js, buildGalleryDots).
   На десктопе/планшете сетка и так показывает все карточки разом. */
.gallery-dots {
    display: none;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 14px;
}
.gallery-dot {
    width: 8px;
    height: 3px;
    padding: 0;
    border: none;
    border-radius: 1px;
    background: var(--border);
    cursor: pointer;
    transition: width 0.22s ease, background 0.22s ease;
}
.gallery-dot.is-active {
    width: 24px;
    background: var(--accent);
}
html[data-theme="light"] .gallery-dot {
    background: #94a3b8;
}
html[data-theme="light"] .gallery-dot.is-active {
    background: var(--accent);
}

/* ===========================================================================
   Карусель на телефоне (Раздел 4.5 ТЗ):
   1. Строгая посадка по высоте 100dvh (Zero vertical scroll)
   2. Дискретный TikTok/Tinder snap (scroll-snap-type: x mandatory, scroll-snap-stop: always)
   3. Анимация фокуса активной карточки (scale/opacity)
   4. Скрытие системного горизонтального скроллбара
   =========================================================================== */
@media (max-width: 600px) {
    /* Карусель на один экран без внутреннего вертикального скролла -
       футер как ещё один элемент сломал бы подобранную высоту карточки
       (см. комментарий у .gallery-footer выше по файлу). */
    .gallery-footer {
        display: none;
    }
    #model-gallery {
        position: fixed;
        inset: 0;
        width: 100vw;
        height: 100dvh;
        max-height: 100dvh;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }
    .gallery-scroll {
        position: relative;
        width: 100%;
        /* Живая находка (24.09.2026): базовое правило .gallery-scroll (для
           широких экранов) получило max-width:min(94vw,1900px) - здесь,
           в мобильной карусели, эта строка НЕ была явно сброшена, поэтому
           карточка ужималась до ~94% ширины экрана и центрировалась,
           обнажая декоративную CAD-сетку #model-gallery узкими полосками
           по бокам - особенно заметно при пролистывании карусели (живой
           баг-репорт владельца, реальный телефон). max-width:none - тот
           же смысл, что и раньше (100% без ограничения по ширине). */
        max-width: none;
        height: calc(100dvh - 50px - var(--safe-top));
        max-height: calc(100dvh - 50px - var(--safe-top));
        margin-top: calc(50px + var(--safe-top));
        margin-bottom: 0;
        margin-left: 0;
        margin-right: 0;
        padding: 4px 10px calc(8px + var(--safe-bottom));
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        box-sizing: border-box;
        overflow: hidden;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    .gallery-scroll::-webkit-scrollbar {
        display: none;
        width: 0;
        height: 0;
    }

    .gallery-grid {
        display: flex;
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
        gap: 14px;
        margin: 0;
        padding: 6px 14px;
        align-items: center;
        flex: 1 1 auto;
        min-height: 0;
        box-sizing: border-box;
    }
    .gallery-grid::-webkit-scrollbar {
        display: none;
        width: 0;
        height: 0;
    }

    .gallery-card {
        flex: 0 0 calc(100vw - 36px);
        max-width: calc(100vw - 36px);
        height: 100%;
        max-height: calc(100dvh - 50px - var(--safe-top) - var(--safe-bottom) - 38px);
        display: flex;
        flex-direction: column;
        scroll-snap-align: center;
        scroll-snap-stop: always;
        overflow: hidden;
        box-sizing: border-box;
        transform: scale(0.94);
        opacity: 0.72;
        transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.28s ease, border-color 0.2s, box-shadow 0.2s;
    }

    .gallery-card.is-active-card,
    .gallery-card:only-child {
        transform: scale(1);
        opacity: 1;
        box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
    }
    html[data-theme="light"] .gallery-card.is-active-card {
        box-shadow: 0 6px 20px rgba(15, 23, 42, 0.12);
        border-color: var(--accent);
    }

    .gallery-card-open-btn {
        flex: 1 1 auto;
        min-height: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .gallery-thumb {
        flex: 1 1 auto;
        min-height: 0;
        max-height: 48vh;
        width: 100%;
        aspect-ratio: auto;
        display: flex;
        align-items: center;
        justify-content: center;
        overflow: hidden;
    }

    .gallery-thumb img {
        width: 100%;
        height: 100%;
        object-fit: contain;
    }

    .gallery-camo-swatches {
        flex-shrink: 0;
        padding: 6px 12px;
        gap: 10px;
    }
    .camo-swatch {
        width: 26px;
        height: 26px;
        position: relative;
    }
    .camo-swatch::after {
        content: '';
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        min-width: 44px;
        min-height: 44px;
    }

    .gallery-card-body {
        flex-shrink: 0;
        padding: 8px 12px 10px;
    }

    .gallery-card-title {
        font-size: 14px;
        line-height: 1.25;
    }

    .gallery-card-desc {
        font-size: 11.5px;
        line-height: 1.35;
        margin-top: 3px;
        -webkit-line-clamp: 2;
    }

    .gallery-chips {
        margin: 5px 0 6px;
        gap: 5px;
    }

    .gallery-chip {
        font-size: 10.5px;
        padding: 2px 6px;
    }

    .gallery-card-actions {
        padding-top: 6px;
        width: 100%;
    }

    .gallery-card-action-btn {
        width: 100%;
        min-height: 44px;
        font-size: 11.5px;
        text-transform: uppercase;
        letter-spacing: 0.08em;
        padding: 8px 10px;
    }

    .gallery-dots {
        display: flex;
        flex-shrink: 0;
        margin-top: 6px;
        margin-bottom: 2px;
    }

    /* Панель замеров на телефоне - прижата снизу к тулбару */
    #measure-panel {
        top: auto;
        bottom: calc(76px + var(--safe-bottom));
        left: calc(12px + var(--safe-left));
        right: calc(12px + var(--safe-right));
        width: auto;
        max-width: calc(100vw - 24px);
    }

    /* Полноширинная шапка витрины на телефоне */
    body.in-gallery #site-topbar,
    #app.in-gallery-mode #site-topbar,
    #site-topbar:not(.mode-3d) {
        height: calc(50px + var(--safe-top));
        padding: var(--safe-top) calc(14px + var(--safe-right)) 0 calc(14px + var(--safe-left));
    }
    .brand-link {
        width: 38px;
        height: 38px;
        padding: 0;
        justify-content: center;
        gap: 0;
    }
    .brand-mark-icon svg {
        width: 32px;
        height: 32px;
    }
    .brand-text {
        display: none;
    }
    .rfq-input,
    .rfq-select,
    .rfq-textarea {
        font-size: 16px;
    }
    .topbar-brand-group {
        gap: 8px;
    }
    .topbar-nav {
        gap: 4px;
    }
    .topbar-nav-btn,
    .topbar-rfq-btn {
        width: 36px;
        height: 36px;
        padding: 0;
        justify-content: center;
    }
    .topbar-nav-label,
    .topbar-rfq-btn .topbar-nav-label {
        display: none;
    }
    .topbar-actions {
        gap: 6px;
    }
    .gallery-header-btn {
        width: 36px;
        height: 36px;
    }
    .gallery-header-btn:not(.gallery-lang-btn) svg {
        width: 19px;
        height: 19px;
    }
    .gallery-lang-btn svg,
    .lang-btn svg {
        width: 20px;
        height: 14px;
        aspect-ratio: 20 / 14;
    }

    /* Детальная шторка на телефоне - на весь экран с safe-area */
    .details-drawer {
        width: 100vw;
        max-width: 100vw;
        border-left: none;
    }
    .drawer-header {
        padding: calc(14px + var(--safe-top)) 16px 12px;
    }
    .drawer-body {
        padding: 16px 16px calc(24px + var(--safe-bottom));
    }
    .drawer-title {
        font-size: 16px;
    }
    .btn-drawer-3d {
        min-height: 52px;
        font-size: 16px;
    }
}

/* Отступы галереи под тулбар на планшетах (не на узких телефонах) */
@media (min-width: 601px) and (max-width: 900px) and (orientation: portrait) {
    .gallery-scroll {
        padding-bottom: calc(72px + var(--safe-bottom));
    }
}
@media (max-height: 520px) and (max-width: 1024px) and (orientation: landscape), (max-width: 1024px) and (orientation: landscape) {
    .gallery-scroll {
        /* 46px - реальная высота #site-topbar в этом же брейкпоинте (см.
           ниже по файлу) + запас - было 10px, посчитанные без учёта, что
           топбар вообще перекрывает контент здесь: верхний ряд карточек
           уезжал ПОД фиксированный топбар и визуально "срезался" -
           живая находка владельца на реальном телефоне. */
        padding-top: calc(58px + var(--safe-top));
        padding-bottom: calc(12px + var(--safe-bottom));
        /* padding-right НЕ увеличиваем (было 88px - задел под колонку
           тулбара 3D-ПРОСМОТРА справа, скопированный по ошибке; в режиме
           ГАЛЕРЕИ тулбара нет вообще) - иначе сетка карточек выглядит
           сдвинутой влево, живая находка владельца на реальном телефоне.
           Левый/правый отступы остаются равными (24px, из базового
           правила .gallery-scroll ниже по каскаду не переопределяются).

           max-width:none - тот же живой баг, что и в портретной карусели
           (max-width:600px) выше: базовое правило .gallery-scroll держит
           max-width:min(94vw,1900px) для десктопных широких экранов, а
           здесь это узкий телефон - без сброса появлялась узкая полоска
           декоративной CAD-сетки по бокам вместо честной полной ширины. */
        max-width: none;
    }
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    .gallery-thumb {
        aspect-ratio: 16 / 9;
    }
    .gallery-card-body {
        padding: 8px 12px 10px;
    }

    /* Живая находка владельца (реальный телефон, Samsung Galaxy S25,
       альбомная ориентация, открыт ПРЯМО В БРАУЗЕРЕ - не в полноэкранном
       режиме, со видимой панелью браузера) - вся компактная мобильная
       обработка шапки/футера была завязана ТОЛЬКО на @media
       max-width:600px (ширина). В альбомной ориентации у телефона ширина
       легко превышает 600px (у S25 - больше 900px), поэтому сайт
       откатывался к десктопной шапке с полными текстовыми подписями (не
       помещалась, "слипалось") и показывал футер, для которого просто
       нет места по высоте у телефона в альбомной ориентации.
       ПЕРВАЯ попытка чинить это одним условием max-height:520px не
       сработала на реальном устройстве - высота видимой области с
       открытой панелью браузера (адресная строка, вкладки) оказалась
       больше 520px. Условие расширено до (высота<=520px) ИЛИ
       (ширина<=1024px)+альбомная ориентация - та же двойная схема, что
       уже используется тулбаром 3D-вьювера чуть выше в этом файле
       (см. комментарий "Признак 'это телефон'" в начале файла), просто с
       более широким порогом ширины - здесь решение затрагивает всю
       шапку/футер целиком, а не только колонку кнопок тулбара. */
    body.in-gallery #site-topbar,
    #app.in-gallery-mode #site-topbar,
    #site-topbar:not(.mode-3d) {
        height: calc(46px + var(--safe-top));
        padding: var(--safe-top) calc(14px + var(--safe-right)) 0 calc(14px + var(--safe-left));
    }
    .brand-link {
        width: 34px;
        height: 34px;
        padding: 0;
        justify-content: center;
        gap: 0;
    }
    .brand-mark-icon svg {
        width: 28px;
        height: 28px;
    }
    .brand-text {
        display: none;
    }
    .topbar-brand-group {
        gap: 8px;
    }
    .topbar-nav {
        gap: 4px;
    }
    .topbar-nav-btn,
    .topbar-rfq-btn {
        width: 34px;
        height: 34px;
        padding: 0;
        justify-content: center;
    }
    .topbar-nav-label,
    .topbar-rfq-btn .topbar-nav-label {
        display: none;
    }
    .topbar-actions {
        gap: 6px;
    }
    .gallery-header-btn {
        width: 34px;
        height: 34px;
    }
    .gallery-header-btn:not(.gallery-lang-btn) svg {
        width: 18px;
        height: 18px;
    }
    .gallery-lang-btn svg,
    .lang-btn svg {
        width: 20px;
        height: 14px;
        aspect-ratio: 20 / 14;
    }

    /* Футеру просто некуда деться по высоте на телефоне в альбоме (та же
       причина, по которой он скрыт и в портретной карусели) - решает
       ту же задачу "закрывающей полосы", что и пустые поля на ПК, а на
       телефоне этой задачи нет ни в каком развороте. */
    .gallery-footer {
        display: none;
    }
}

/* --- Радиальное меню (CAD Radial / Marking Menu, ТЗ Раздел 3.3, 3.4) ------ */
.radial-menu-overlay {
    position: absolute;
    inset: 0;
    z-index: 100;
    pointer-events: auto;
    user-select: none;
    -webkit-user-select: none;
}
.radial-menu-overlay[hidden] {
    display: none;
}
.radial-menu-backdrop {
    position: absolute;
    inset: 0;
    background: transparent;
}
.radial-menu-overlay.is-pinned .radial-menu-backdrop {
    background: rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}
.radial-menu-disc {
    position: absolute;
    transform: translate(-50%, -50%);
    width: 320px;
    height: 320px;
    pointer-events: none;
}
.radial-menu-disc.is-opening {
    animation: radialMenuPopIn 120ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.radial-menu-disc.is-closing {
    animation: radialMenuPopOut 80ms ease-in forwards;
}
@keyframes radialMenuPopIn {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.88);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}
@keyframes radialMenuPopOut {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.92);
    }
}

.radial-menu-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
    pointer-events: auto;
    filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.45));
}
.radial-sector {
    fill: var(--bg-panel);
    stroke: var(--border);
    stroke-width: 1.5px;
    transition: fill 0.12s ease, stroke 0.12s ease;
    cursor: pointer;
}
.radial-sector:hover,
.radial-sector.is-active {
    fill: var(--accent);
    stroke: var(--accent);
}
.radial-sector.is-disabled {
    opacity: 0.22;
    pointer-events: none;
    cursor: not-allowed;
}

.radial-sector-fo {
    pointer-events: none;
}
.radial-sector-fo.is-disabled {
    opacity: 0.22;
    pointer-events: none;
}
.radial-sector-icon {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text);
    transition: color 0.12s ease, transform 0.12s ease;
}
.radial-sector-fo.is-active .radial-sector-icon {
    color: var(--accent-contrast);
    transform: scale(1.15);
}

/* Центральный диск (нейтральная зона) */
.radial-center-disc {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 84px;
    height: 84px;
    border-radius: 50%;
    background: var(--bg);
    border: 2px solid var(--border);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    cursor: pointer;
    box-sizing: border-box;
    padding: 4px;
    text-align: center;
    transition: border-color 0.12s ease, background-color 0.12s ease;
}
.radial-center-disc:hover {
    border-color: var(--accent);
}
.radial-center-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    margin-bottom: 2px;
}
.radial-center-label {
    font-size: 10px;
    font-weight: 600;
    line-height: 1.1;
    color: var(--text);
    max-width: 76px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* ==========================================================================
   Оперативный чат с менеджером (Live Chat Widget, ТЗ_04 §3, ТЗ_05 §4)
   ========================================================================== */

/* Плавающая кнопка вызова чата в правом нижнем углу */
.chat-launcher-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 65;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--bg-panel);
    border: 1.5px solid var(--border);
    color: var(--accent);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45), 0 0 12px rgba(226, 138, 43, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease, border-color 0.2s ease;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.chat-launcher-btn:hover {
    transform: scale(1.08);
    border-color: var(--accent);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55), 0 0 18px rgba(226, 138, 43, 0.35);
}

.chat-launcher-btn:active {
    transform: scale(0.96);
}

.chat-launcher-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

@keyframes chat-launcher-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); box-shadow: 0 0 16px var(--accent); }
}

.chat-launcher-btn.has-unread {
    animation: chat-launcher-pulse 2s infinite ease-in-out;
}

.chat-unread-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: var(--accent);
    color: var(--accent-contrast);
    font-size: 11px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
    box-sizing: border-box;
    z-index: 2;
    pointer-events: none;
}

.chat-unread-badge[hidden] {
    display: none;
}

/* Окно чата */
.chat-widget-panel {
    position: fixed;
    bottom: 86px;
    right: 24px;
    width: 360px;
    max-width: calc(100vw - 32px);
    height: 480px;
    max-height: calc(100vh - 120px);
    z-index: 66;
    background: var(--bg-panel);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55), 0 0 24px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    box-sizing: border-box;
}

.chat-widget-panel[hidden] {
    display: none;
    opacity: 0;
    transform: scale(0.92) translateY(12px);
    pointer-events: none;
}

.chat-widget-panel.is-open {
    display: flex !important;
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: auto;
}

/* Шапка чата */
.chat-widget-header {
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.chat-header-buttons {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    position: relative;
}

.chat-menu-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 5;
    display: flex;
    flex-direction: column;
    min-width: 168px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    overflow: hidden;
    padding: 4px;
}

.chat-menu-dropdown[hidden] {
    display: none;
}

.chat-menu-dropdown button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 10px;
    font-size: 12.5px;
    color: var(--text);
    background: transparent;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}

.chat-menu-dropdown button:hover,
.chat-menu-dropdown button:focus-visible {
    background: rgba(226, 138, 43, 0.14);
    outline: none;
}

html[data-theme="light"] .chat-menu-dropdown button:hover,
html[data-theme="light"] .chat-menu-dropdown button:focus-visible {
    background: rgba(180, 83, 9, 0.14);
}

.chat-status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #3fb950;
    box-shadow: 0 0 6px rgba(63, 185, 80, 0.6);
    flex-shrink: 0;
}

.chat-panel-title {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text);
    margin: 0;
    line-height: 1.2;
}

.chat-panel-subtitle {
    font-size: 11px;
    color: var(--text-dim);
    line-height: 1.2;
    margin-top: 2px;
}

/* Тело чата / список сообщений */
.chat-widget-body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-sizing: border-box;
    -webkit-overflow-scrolling: touch;
}

.chat-empty-state {
    margin: auto;
    padding: 18px;
    text-align: center;
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-dim);
    background: rgba(255, 255, 255, 0.02);
    border: 1px dashed var(--border);
    border-radius: 8px;
}

.chat-msg {
    max-width: 82%;
    padding: 9px 13px;
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.45;
    word-break: break-word;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-msg-in {
    /* Сообщение визитера (исходящее с точки зрения пользователя сайта) */
    align-self: flex-end;
    background: rgba(226, 138, 43, 0.18);
    border: 1px solid rgba(226, 138, 43, 0.4);
    color: var(--text);
    border-bottom-right-radius: 2px;
}

.chat-msg-out {
    /* Ответ менеджера (входящий с точки зрения пользователя сайта) */
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border);
    color: var(--text);
    border-bottom-left-radius: 2px;
}

.chat-msg-time {
    font-size: 10px;
    color: var(--text-dim);
    align-self: flex-end;
    opacity: 0.8;
}

/* Подвал чата / поле ввода */
.chat-widget-footer {
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.02);
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
}

.chat-name-row {
    width: 100%;
}

.chat-name-input {
    width: 100%;
    box-sizing: border-box;
    padding: 5px 8px;
    font-size: 11px;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    outline: none;
}

.chat-name-input:focus {
    border-color: var(--accent);
}

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

.chat-text-input {
    flex: 1 1 auto;
    min-height: 36px;
    padding: 8px 12px;
    font-size: 13px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.15s ease;
}

.chat-text-input:focus {
    border-color: var(--accent);
}

.chat-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--accent);
    color: var(--accent-contrast);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: opacity 0.15s ease, transform 0.1s ease;
    outline: none;
}

.chat-send-btn:hover {
    opacity: 0.9;
    transform: scale(1.04);
}

.chat-send-btn:active {
    transform: scale(0.96);
}

.chat-send-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

@media (max-width: 480px) {
    .chat-launcher-btn {
        bottom: 16px;
        right: 16px;
        width: 48px;
        height: 48px;
    }
    .chat-widget-panel {
        bottom: 74px;
        right: 12px;
        left: 12px;
        width: auto;
        max-width: none;
        height: calc(100vh - 140px);
    }
}

/* Телефон в горизонтальной ориентации: ширина экрана обычно больше 480px
   (предыдущий брейкпоинт не сработает), поэтому панель без этого блока
   получала desktop-размер (480px), урезанный до max-height: calc(100vh -
   120px) - на экране высотой ~360-420px под сообщения оставалось всего
   ~90px. Брейкпоинт по высоте, а не по ширине - top/bottom без height
   растягивают панель на весь доступный вертикальный зазор. */
@media (max-height: 420px) {
    .chat-launcher-btn {
        bottom: 8px;
        right: 8px;
        width: 40px;
        height: 40px;
    }
    .chat-widget-panel {
        top: 8px;
        bottom: 56px;
        right: 8px;
        left: auto;
        width: 320px;
        max-width: calc(100vw - 16px);
        height: auto;
        max-height: none;
    }
}

/* Оперативный чат в светлой теме (Tactical Titanium) - подложка сообщения
   визитёра завязана на акцентный цвет (#e28a2b в тёмной теме), у которого
   в светлой теме свой собственный акцент (#b45309, см. :root/[data-theme]
   выше) - тот же приём конвертации hex->rgba(), что и у .topbar-rfq-btn. */
html[data-theme="light"] .chat-msg-in {
    background: rgba(180, 83, 9, 0.14);
    border: 1px solid rgba(180, 83, 9, 0.4);
}
html[data-theme="light"] .chat-msg-out {
    background: rgba(0, 0, 0, 0.05);
}
html[data-theme="light"] .chat-name-input,
html[data-theme="light"] .chat-text-input {
    background: #ffffff;
    border-color: #cbd5e1;
    color: #0f172a;
}
