/* Полосы прокрутки не показываем нигде: что листается, и так понятно (решение владельца) */
* { scrollbar-width: none; }
*::-webkit-scrollbar { display: none; width: 0; height: 0; }

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

   Принцип: страница - это одна 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.025);
    --grid-line-major: rgba(226, 138, 43, 0.05);
    --shadow: 0 4px 18px rgba(0, 0, 0, 0.50);
    --radius: 0;
    --radius-round: 50%;
    --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.045);
    --grid-line-major: rgba(180, 83, 9, 0.08);
    --shadow: 0 2px 8px rgba(26, 25, 23, 0.10);
    /* Пустынный градиент сцены: теплый песчаный свет и выветренный койот */
    --scene-gradient: linear-gradient(to bottom, #f3f0e8 0%, #e2ded6 55%, #c8c2b7 100%);
}
/* До запуска скриптов: светлая системная тема сразу даёт светлые цвета, без мигания тёмным */
@media (prefers-color-scheme: light) {
html:not([data-theme]) {
    --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.045);
    --grid-line-major: rgba(180, 83, 9, 0.08);
    --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: var(--radius-round);
    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: var(--radius);
    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: var(--radius);
    }
    .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));
    }

    /* Плашка догрузки полной детализации (LOD/progressive) садится НАД нижним
       тулбаром, чтобы не перекрывать кнопки навигации в портретном режиме */
    body .detail-status,
    .detail-status {
        bottom: calc(80px + var(--safe-bottom, 0px));
    }
}

/* На десктопе в портрете (высокие вертикальные мониторы):
   тулбар справа начинается под кнопкой темы (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;
    /* штрих у острых углов значков (кончик щита и т.п.) выходит за рамку viewBox: без этого он срезается */
    overflow: visible;
}

.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: var(--radius);
    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 picture {
    display: block;
    width: 100%;
    height: 100%;
    min-width: 0;
}
.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: var(--radius);
    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[hidden] {
    display: none;
}
.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 42%;
    min-width: 0;
}
.specs-view-row dd {
    flex: 1 1 0;
    min-width: 0;
    overflow-wrap: anywhere;
    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,
.compare-modal-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 picture {
    display: block;
    width: 100%;
    height: 100%;
    min-width: 0;
}
.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: 0 1 42%;
    min-width: 0;
}
.drawer-spec-val {
    font-weight: 600;
    color: var(--text);
    text-align: right;
    font-variant-numeric: tabular-nums;
    flex: 1 1 0;
    min-width: 0;
    overflow-wrap: anywhere;
}

/* Детальная шторка и элементы в светлой теме (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, #drawer-privacy) */
.info-drawer-overlay {
    z-index: 130;
}
.info-drawer-overlay .details-drawer {
    width: 440px;
    max-width: 100vw;
    z-index: 131;
}

.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: var(--radius);
    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 самой ленты (.gallery-grid). */
        padding: 4px 0 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%;
        /* 92px: 38px под точки карусели и ещё 54px, чтобы кнопка чата в правом нижнем углу не налезала на кнопку «3D просмотр» */
        max-height: calc(100dvh - 50px - var(--safe-top) - var(--safe-bottom) - 122px);
        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: 254px;
    height: 254px;
    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: var(--radius-round);
    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: var(--radius);
    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: var(--radius);
    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 {
    /* --pr / --pb - отступы окна от правого и нижнего края экрана. Кнопка чата
       (52px, отступ 24px) имеет центр в 50px от обоих краёв, поэтому окно
       раскрывается и схлопывается именно в неё (transform-origin ниже). */
    --pr: 24px;
    --pb: 86px;
    position: fixed;
    bottom: var(--pb);
    right: var(--pr);
    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: var(--radius);
    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: calc(100% + var(--pr) - 50px) calc(100% + var(--pb) - 50px);
    /* закрытое состояние: крошечное и прозрачное, в точке кнопки чата */
    opacity: 0;
    transform: scale(0.06);
    pointer-events: none;
    transition: opacity 0.18s ease-out,
                transform 0.34s cubic-bezier(0.22, 1, 0.36, 1),
                right 0.34s cubic-bezier(0.22, 1, 0.36, 1),
                bottom 0.34s cubic-bezier(0.22, 1, 0.36, 1),
                width 0.34s cubic-bezier(0.22, 1, 0.36, 1),
                height 0.34s cubic-bezier(0.22, 1, 0.36, 1),
                border-radius 0.34s ease;
    box-sizing: border-box;
}

.chat-widget-panel[hidden] {
    display: none;
}

.chat-widget-panel.is-open {
    display: flex !important;
    opacity: 1;
    transform: none;
    pointer-events: auto;
}

@media (prefers-reduced-motion: reduce) {
    .chat-widget-panel { transition: opacity 0.12s linear; transform: none; }
}

/* Шапка чата */
.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: var(--radius);
    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: var(--radius);
    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: var(--radius);
    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: var(--radius);
}

.chat-msg {
    max-width: 82%;
    padding: 9px 13px;
    border-radius: var(--radius);
    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-error-toast {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(239, 68, 68, 0.15);
    border-top: 1px solid rgba(239, 68, 68, 0.35);
    color: #fca5a5;
    font-size: 12px;
    line-height: 1.35;
    box-sizing: border-box;
    flex-shrink: 0;
}

.chat-error-toast[hidden] {
    display: none;
}

.chat-error-text {
    flex: 1 1 auto;
    word-break: break-word;
}

.chat-error-retry-btn {
    padding: 4px 10px;
    min-height: 28px;
    background: var(--accent);
    color: var(--accent-contrast);
    border: none;
    border-radius: var(--radius);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: opacity 0.15s ease;
}

.chat-error-retry-btn:hover {
    opacity: 0.9;
}

.chat-error-close-btn {
    background: none;
    border: none;
    color: #fca5a5;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    padding: 2px 4px;
    opacity: 0.7;
    transition: opacity 0.15s ease;
}

.chat-error-close-btn:hover {
    opacity: 1;
}

/* Подвал чата / поле ввода */
.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: var(--radius);
    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: var(--radius);
    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: var(--radius);
    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;
}

body.chat-widget-open {
    overflow: hidden;
}

@media (max-width: 480px) {
    .chat-launcher-btn {
        bottom: 16px;
        right: 16px;
        width: 48px;
        height: 48px;
    }
    .chat-widget-panel {
        --pr: 12px;
        --pb: 74px;
        bottom: 74px;
        right: 12px;
        left: 12px;
        width: auto;
        max-width: none;
        height: calc(100vh - 140px);
    }
    .chat-text-input,
    .chat-name-input {
        font-size: 16px;
        min-height: 40px;
    }
    .chat-send-btn {
        width: 40px;
        height: 40px;
    }
}

/* Телефон в горизонтальной ориентации: ширина экрана обычно больше 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;
}


/* Скрытое поле-ловушка для ботов в чате (ТЗ_10): человек его не видит. */
.chat-hp {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}


/* Вложения оператора в чате посетителя: картинка в пузыре, карточка файла, просмотр поверх страницы. */
.chat-msg-img { display: block; max-width: 100%; max-height: 260px; margin-top: 6px; border-radius: var(--radius); cursor: zoom-in; object-fit: cover; }
.chat-msg-file { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; padding: 8px 10px; border-radius: var(--radius); background: rgba(0, 0, 0, 0.18); }
html[data-theme="light"] .chat-msg-file { background: rgba(0, 0, 0, 0.06); }
.chat-msg-file a { color: inherit; overflow-wrap: anywhere; }
.chat-msg-file-open { font-weight: 600; text-decoration: underline; }
.chat-msg-file-dl { font-size: 12.5px; opacity: 0.8; }
.chat-lightbox { position: fixed; inset: 0; z-index: 100000; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(0, 0, 0, 0.88); }
.chat-lightbox img { max-width: 100%; max-height: calc(100vh - 110px); border-radius: var(--radius); object-fit: contain; }
.chat-lightbox-close { position: absolute; top: 12px; right: 12px; width: 44px; height: 44px; border: 0; border-radius: var(--radius); background: rgba(255, 255, 255, 0.16); color: #fff; font-size: 28px; line-height: 1; cursor: pointer; }
.chat-lightbox-dl { position: absolute; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%); padding: 10px 18px; border-radius: var(--radius); background: rgba(255, 255, 255, 0.16); color: #fff; text-decoration: none; }


/* Чат посетителя на телефоне: окно занимает всю видимую область экрана
   (без режима «полный экран» браузера), поле ввода всегда над клавиатурой.
   Высота берётся из visualViewport (см. main.js, --chat-vvh). Так же в альбомной ориентации телефона. */
@media (max-width: 600px), (orientation: landscape) and (max-height: 500px), (max-height: 500px) and (max-width: 1023px), (max-height: 500px) and (pointer: coarse) {
    #chat-widget-panel.chat-widget-panel {
        top: 0;
        right: 0;
        bottom: auto;
        left: 0;
        width: 100%;
        max-width: none;
        height: var(--chat-vvh, 100dvh);
        max-height: none;
        border: 0;
        border-radius: var(--radius);
        z-index: 200;
        transform-origin: center bottom;
    }
    #chat-widget-panel.chat-widget-panel:not(.is-open) {
        transform: translateY(32px);
    }
    #chat-widget-panel .chat-widget-header {
        padding-top: calc(12px + env(safe-area-inset-top));
    }
    #chat-widget-panel .chat-widget-footer {
        padding-bottom: calc(10px + env(safe-area-inset-bottom));
    }
    body.chat-widget-open .chat-launcher-btn {
        display: none;
    }
    #chat-widget-panel .chat-widget-body {
        overscroll-behavior: contain;
    }
}

/* Чат в альбомной ориентации телефона: компактная шапка (без подзаголовка), отступы от выреза, кнопки по 44 px */
@media (orientation: landscape) and (max-height: 500px), (max-height: 500px) and (max-width: 1023px), (max-height: 500px) and (pointer: coarse) {
    #chat-widget-panel .chat-widget-header {
        padding: 6px calc(12px + var(--safe-right, 0px)) 6px calc(14px + var(--safe-left, 0px));
    }
    #chat-widget-panel .chat-panel-subtitle { display: none; }
    #chat-widget-panel .chat-panel-title { font-size: 14px; letter-spacing: 0.04em; }
    #chat-widget-panel .chat-widget-body {
        padding: 8px calc(14px + var(--safe-right, 0px)) 8px calc(14px + var(--safe-left, 0px));
    }
    #chat-widget-panel .chat-widget-footer {
        padding: 6px calc(12px + var(--safe-right, 0px)) calc(6px + env(safe-area-inset-bottom)) calc(14px + var(--safe-left, 0px));
        gap: 4px;
    }
    #chat-widget-panel .chat-name-input {
        padding: 4px 8px;
        font-size: 13px;
        min-height: 32px;
    }
    #chat-widget-panel .chat-header-buttons .drawer-close-btn {
        width: 44px !important;
        height: 44px !important;
        min-width: 44px !important;
        min-height: 44px !important;
    }
    #chat-widget-panel .chat-text-input { min-height: 44px; }
    #chat-widget-panel .chat-send-btn { width: 44px; height: 44px; }
}


/* --- Большое окно чата (только компьютер, ТЗ владельца) --------------------- */
.chat-expand-btn { display: none; }
.chat-backdrop { display: none; }
@media (min-width: 1024px) and (pointer: fine) {
    .chat-expand-btn { display: inline-flex; }
    .chat-expand-btn .ic-collapse { display: none; }
    .chat-widget-panel.is-expanded .chat-expand-btn .ic-expand { display: none; }
    .chat-widget-panel.is-expanded .chat-expand-btn .ic-collapse { display: block; }

    /* Матовая подложка: всё за окном размыто и приглушено, но видно */
    .chat-backdrop {
        position: fixed;
        inset: 0;
        z-index: 998;
        display: block;
        background: color-mix(in srgb, var(--bg) 48%, transparent);
        -webkit-backdrop-filter: blur(14px) saturate(1.1);
        backdrop-filter: blur(14px) saturate(1.1);
        animation: chatBackdropIn 0.2s ease-out;
    }
    .chat-backdrop[hidden] { display: none; }
    @keyframes chatBackdropIn { from { opacity: 0; } to { opacity: 1; } }

    #chat-widget-panel.chat-widget-panel.is-expanded {
        --pr: calc((100vw - min(980px, 86vw)) / 2);
        --pb: calc((100vh - min(780px, 86vh)) / 2);
        left: auto;
        top: auto;
        width: min(980px, 86vw);
        max-width: none;
        height: min(780px, 86vh);
        max-height: none;
        z-index: 999;
        border-radius: var(--radius);
        box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
    }
    .chat-widget-panel.is-expanded .chat-widget-header { padding: 16px 22px; }
    .chat-widget-panel.is-expanded .chat-widget-body { padding: 20px 28px; }
    .chat-widget-panel.is-expanded .chat-widget-footer { padding: 14px 22px 18px; }
    .chat-widget-panel.is-expanded .chat-msg { font-size: 15px; max-width: 72%; }
    body.chat-expanded .chat-launcher-btn { visibility: hidden; }
}


/* Шапка чата: кнопки компактные и не наезжают на заголовок; порядок - меню, развернуть, закрыть */
.chat-widget-header { gap: 8px; }
.chat-header-info > div { min-width: 0; }
.chat-panel-title, .chat-panel-subtitle { overflow-wrap: anywhere; }
.chat-header-buttons { gap: 4px; }
.chat-header-buttons .drawer-close-btn { width: 32px; height: 32px; min-width: 32px; padding: 0; }

/* Очень узкие телефоны (320-340px): кнопки шапки чуть меньше, чтобы шапка не вылезала за экран */
@media (max-width: 340px) {
    .topbar-nav-btn,
    .topbar-rfq-btn,
    .gallery-header-btn {
        width: 32px;
        height: 32px;
    }
    .topbar-actions { gap: 4px; }
    .gallery-header-btn:not(.gallery-lang-btn) svg { width: 17px; height: 17px; }
}


/* Кнопка отправки в чате посетителя: тот же знак и вид, что в мессенджере админки */
.chat-send-btn,
.chat-send-btn:hover,
.chat-send-btn:active {
    width: 48px;
    height: 48px;
    border: 0;
    border-radius: var(--radius);
}
.chat-send-btn { transition: background-color 0.15s ease, transform 0.12s ease; }
.chat-send-btn:hover { opacity: 1; filter: brightness(1.1); transform: none; }
.chat-send-btn:active { transform: translate(1px, -1px); }
.chat-send-btn:disabled { background: var(--bg-panel); color: var(--text-dim); border: 1px solid var(--border); filter: none; cursor: default; }
.chat-send-btn svg { width: 24px; height: 24px; }
.chat-text-input { min-height: 48px; }

.chat-header-buttons .drawer-close-btn { width: 32px !important; height: 32px !important; min-width: 32px !important; min-height: 32px !important; padding: 0; }

/* Шапка каталога на телефоне в портретной ориентации: все кнопки одного размера и с одинаковыми промежутками
   (группы кнопок раскрыты в один ряд, ширина делится поровну). В альбомной ориентации остаются прежние отступы. */
@media (max-width: 600px) and (orientation: portrait) {
    :is(body.in-gallery #site-topbar, #app.in-gallery-mode #site-topbar, #site-topbar:not(.mode-3d)) {
        gap: 6px;
        justify-content: space-between;
    }
    :is(body.in-gallery #site-topbar, #app.in-gallery-mode #site-topbar, #site-topbar:not(.mode-3d)) :is(.topbar-brand-group, .topbar-nav, .topbar-actions) {
        display: contents;
    }
    :is(body.in-gallery #site-topbar, #app.in-gallery-mode #site-topbar, #site-topbar:not(.mode-3d)) :is(.brand-link, .topbar-nav-btn, .topbar-rfq-btn, .gallery-header-btn) {
        flex: 1 1 0;
        min-width: 0;
        max-width: 44px;
        width: auto;
        height: auto;
        aspect-ratio: 1;
        padding: 0;
        justify-content: center;
    }
}

/* Две ступени загрузки 3D (ТЗ_15, этап 1): плашка догрузки полной детализации */
.detail-status {
    position: fixed;
    left: 50%;
    bottom: calc(16px + var(--safe-bottom, 0px));
    transform: translateX(-50%);
    z-index: 40;
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: calc(100vw - 24px);
    padding: 8px 14px;
    font-size: 13px;
    line-height: 1.3;
    color: var(--text);
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    pointer-events: auto;
    transition: border-color 0.2s;
}
.detail-status[hidden] { display: none; }
.detail-status.is-attn { border-color: var(--accent); }
.detail-status-btn {
    min-height: 36px;
    padding: 0 12px;
    font: inherit;
    font-weight: 600;
    color: var(--accent);
    background: transparent;
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    cursor: pointer;
}
.detail-status-btn:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); }
#btn-measure.is-pending { opacity: 0.45; }
body.in-gallery .detail-status { display: none; }
@media (max-width: 900px) and (orientation: portrait) {
    body .detail-status,
    .detail-status {
        bottom: calc(80px + var(--safe-bottom, 0px));
    }
}

/* Подсказка по управлению мышью и клавиатурой (только компьютер) */
.controls-hint {
    position: fixed;
    left: 16px;
    bottom: calc(16px + var(--safe-bottom, 0px));
    z-index: 45;
    width: min(380px, calc(100vw - 32px));
    padding: 12px 14px 10px;
    color: var(--text);
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.35s ease, transform 0.35s ease;
}
.controls-hint[hidden] { display: none; }
.controls-hint.is-in { opacity: 1; transform: none; }
.hint-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.hint-title { font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-dim); }
.hint-close {
    width: 28px; height: 28px; padding: 0; display: inline-flex; align-items: center; justify-content: center;
    color: var(--text-dim); background: transparent; border: 1px solid transparent; border-radius: var(--radius); cursor: pointer;
}
.hint-close:hover { color: var(--text); border-color: var(--border); }
.hint-close svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.hint-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; }
.hint-row { display: flex; align-items: center; gap: 12px; }
.hint-mouse { width: 22px; height: 31px; flex: 0 0 auto; overflow: visible; }
.hint-body { fill: none; stroke: var(--text-dim); stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.hint-hl { fill: var(--accent); stroke: none; transform-box: fill-box; transform-origin: center; }
.hint-wheel { animation: hint-scroll 1.5s ease-in-out infinite; }
.hint-press { animation: hint-press 1.5s ease-in-out infinite; }
@keyframes hint-scroll { 0%, 100% { transform: translateY(-1.2px); } 50% { transform: translateY(1.8px); } }
@keyframes hint-press { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
.hint-text { font-size: 13px; line-height: 1.35; color: var(--text-dim); }
.hint-text b { display: block; font-weight: 600; color: var(--text); }
.hint-key {
    display: inline-block; padding: 0 5px; margin-right: 2px; font: inherit; font-size: 11px; font-weight: 700;
    color: var(--text); background: color-mix(in srgb, var(--text) 8%, transparent); border: 1px solid var(--border);
    border-bottom-width: 2px; border-radius: var(--radius);
}
body.in-gallery .controls-hint { display: none; }
@media (hover: none), (pointer: coarse) {
    .controls-hint {
        left: 12px;
        right: 12px;
        width: auto;
        max-width: calc(100vw - 24px);
        bottom: calc(76px + var(--safe-bottom, 0px));
        padding: 8px 12px 14px;
    }
    .hint-head { margin-bottom: 4px; }
    .hint-title { font-size: 15px; letter-spacing: 0; text-transform: none; color: var(--text); }
    .hint-close { width: 44px; height: 44px; margin: 0 -10px 0 0; }
    .hint-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 12px; }
    .hint-row { align-items: flex-start; gap: 10px; }
    .hint-text { font-size: 13px; line-height: 1.3; overflow-wrap: anywhere; }
    .hint-text b { font-size: 14px; margin-bottom: 1px; }
}
@media (orientation: landscape) and (max-height: 500px) and (hover: none), (orientation: landscape) and (max-height: 500px) and (pointer: coarse) {
    .controls-hint { right: auto; width: min(520px, 60vw); bottom: calc(12px + var(--safe-bottom, 0px)); padding-bottom: 10px; }
    .hint-list { gap: 8px 12px; }
}
.hint-touch-icon { box-sizing: content-box; width: 30px; height: 30px; padding: 6px; flex: 0 0 auto; overflow: visible; background: color-mix(in srgb, var(--text) 7%, transparent); border-radius: var(--radius); }
.hint-touch-icon .hint-body { stroke-width: 1.7; }
.hint-ring { opacity: 0.55; }
.hint-row-keys { margin-top: 4px; padding-top: 6px; border-top: 1px dashed var(--border); }

/* --- Динамическая масштабная линейка ANSYS (Scale Bar) --- */
.scale-bar {
    position: absolute;
    bottom: calc(18px + var(--safe-bottom, 0px));
    left: 50%;
    transform: translateX(-50%);
    width: auto;
    box-sizing: border-box;
    z-index: 15;
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: none;
    user-select: none;
    transition: opacity 0.2s ease;
    padding: 0;
}
html[data-theme="light"] .scale-bar {
    background: transparent;
}
.scale-bar-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    box-sizing: content-box;
    padding: 6px 28px 7px;
    background: rgba(18, 19, 21, 0.82);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
    min-width: 120px;
    max-width: calc(100vw - 32px);
    pointer-events: none;
}
.scale-bar.is-dense .scale-bar-val-sub1,
.scale-bar.is-dense .scale-bar-val-sub2,
.scale-bar.is-dense .scale-bar-val-q1,
.scale-bar.is-dense .scale-bar-val-q3 {
    display: none;
}
html[data-theme="light"] .scale-bar-container {
    background: rgba(245, 245, 247, 0.90);
    border: 1px solid var(--border);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.10);
}
.scale-bar-values {
    position: relative;
    width: 100%;
    height: 14px;
    font-family: var(--font-mono, monospace);
    font-size: 11px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    line-height: 14px;
    color: var(--text);
    letter-spacing: 0.02em;
    pointer-events: none;
}
.scale-bar-val {
    position: absolute;
    top: 0;
    white-space: nowrap;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}
html[data-theme="light"] .scale-bar-val {
    text-shadow: none;
}
.scale-bar-val-start {
    left: 0;
    transform: translateX(-50%);
}
.scale-bar-val-sub1,
.scale-bar-val-q1 {
    left: 25%;
    transform: translateX(-50%);
}
.scale-bar-val-mid {
    left: 50%;
    transform: translateX(-50%);
}
.scale-bar-val-sub2,
.scale-bar-val-q3 {
    left: 75%;
    transform: translateX(-50%);
}
.scale-bar-val-end {
    left: 100%;
    transform: translateX(-50%);
}
.scale-bar-ruler {
    position: relative;
    width: 100%;
    height: 7px;
    margin-top: 3px;
}
.scale-bar-line {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: var(--text);
    opacity: 0.92;
    box-sizing: border-box;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.45));
}
.scale-bar-ticks {
    position: absolute;
    inset: 0;
}
.scale-bar-tick {
    position: absolute;
    bottom: 0;
    width: 2px;
    height: 6px;
    background-color: var(--text);
    opacity: 0.92;
    box-sizing: border-box;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.45));
}
.scale-bar-tick-start {
    left: 0;
}
.scale-bar-tick-sub1,
.scale-bar-tick-q1 {
    left: 25%;
    width: 1.5px;
    height: 4.5px;
    opacity: 0.8;
    transform: translateX(-50%);
}
.scale-bar-tick-mid {
    left: 50%;
    transform: translateX(-50%);
}
.scale-bar-tick-sub2,
.scale-bar-tick-q3 {
    left: 75%;
    width: 1.5px;
    height: 4.5px;
    opacity: 0.8;
    transform: translateX(-50%);
}
.scale-bar-tick-end {
    right: 0;
}
html[data-theme="light"] .scale-bar-line,
html[data-theme="light"] .scale-bar-tick {
    filter: none;
}
.scale-bar-text {
    display: none;
}
body.in-gallery .scale-bar,
.scale-bar[hidden] {
    display: none !important;
}
@media (max-width: 900px) and (orientation: portrait) {
    .scale-bar {
        bottom: calc(68px + var(--safe-bottom, 0px));
        left: 50%;
        transform: translateX(-50%);
        width: auto;
    }
    .scale-bar-container {
        padding: 5px 22px 6px;
    }
    .scale-bar-values {
        font-size: 10px;
    }
}
#viewer-container canvas:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}
@media (prefers-reduced-motion: reduce) {
    .controls-hint { transition: none; }
    .hint-wheel, .hint-press { animation: none; }
}

/* --- ТЗ_15, Этап 2: Кнопка техпаспорта в шторке и форма согласия --- */
.btn-drawer-passport {
    width: 100%;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    font-weight: 600;
    font-size: 13px;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: transform 0.12s, border-color 0.15s, background-color 0.15s;
    margin-top: 8px;
}
.btn-drawer-passport:hover {
    border-color: var(--accent);
    background: rgba(255, 255, 255, 0.08);
}
.btn-drawer-passport:active {
    transform: scale(0.98);
}
.passport-consent-field {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 6px;
    margin-bottom: 6px;
}
.passport-consent-label {
    display: flex;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 4px 8px;
    font-size: 12.5px;
    line-height: 1.4;
    color: var(--text-dim);
    cursor: pointer;
}
.passport-consent-label input[type="checkbox"] {
    margin-top: 2px;
    accent-color: var(--accent);
    cursor: pointer;
}
.passport-privacy-link {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 2px;
}
.passport-privacy-link:hover {
    opacity: 0.85;
}

/* --- ТЗ_15, Этап 4: Сравнение моделей (кнопка на карточке, нижняя панель, окно с таблицей) --- */
.gallery-card-compare-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 4;
    min-height: 36px;
    padding: 0 12px 0 10px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--bg-panel) 88%, transparent);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    color: var(--text);
    font: inherit;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.gallery-card-compare-btn:hover { border-color: var(--accent); }
.gallery-card-compare-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.gallery-thumb .gallery-card-compare-btn svg { width: 16px; height: 16px; flex: none; opacity: 1; color: inherit; }
.gallery-card-compare-btn span { white-space: nowrap; }
.gallery-card-compare-btn .compare-ic-on { display: none; }
.gallery-card-compare-btn.is-selected {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-contrast);
}
.gallery-card-compare-btn.is-selected .compare-ic-add { display: none; }
.gallery-card-compare-btn.is-selected .compare-ic-on { display: block; }
@media (pointer: coarse) {
    .gallery-card-compare-btn { min-height: 44px; padding: 0 14px 0 12px; font-size: 13.5px; }
}

.compare-bar {
    position: fixed;
    left: 50%;
    bottom: calc(20px + var(--safe-bottom));
    transform: translateX(-50%);
    z-index: 60;
    width: min(680px, calc(100vw - 32px));
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 14px;
    padding: 10px 12px 10px 14px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-top: 3px solid var(--accent);
    border-radius: var(--radius);
    box-shadow: 0 10px 34px rgba(0, 0, 0, 0.38);
    animation: compareSlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.compare-bar[hidden] { display: none !important; }
@keyframes compareSlideUp {
    from { transform: translate(-50%, 40px); opacity: 0; }
    to { transform: translate(-50%, 0); opacity: 1; }
}
.compare-bar-thumbs { display: flex; gap: 6px; }
.compare-bar-thumb {
    width: 52px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: rgba(127, 127, 127, 0.08);
    overflow: hidden;
}
.compare-bar-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.compare-bar-info { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.compare-bar-count { font-size: 13.5px; font-weight: 700; color: var(--text); }
.compare-bar-note { font-size: 12px; color: var(--text-dim); }
.compare-bar-actions { display: flex; align-items: center; gap: 8px; }
.btn-compare-action,
.btn-compare-clear {
    min-height: 40px;
    padding: 0 16px;
    border-radius: var(--radius);
    font: inherit;
    font-size: 13.5px;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.15s, border-color 0.15s;
}
.btn-compare-action { border: 1px solid var(--accent); background: var(--accent); color: var(--accent-contrast); }
.btn-compare-action:hover:not(:disabled) { opacity: 0.9; }
.btn-compare-action:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-compare-clear { border: 1px solid var(--border); background: transparent; color: var(--text-dim); }
.btn-compare-clear:hover { border-color: var(--text-dim); color: var(--text); }
.btn-compare-action:focus-visible,
.btn-compare-clear:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
body.has-compare-bar #gallery-grid { padding-bottom: 110px; }
@media (pointer: coarse) {
    .btn-compare-action,
    .btn-compare-clear { min-height: 44px; }
}

.compare-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    box-sizing: border-box;
}
.compare-modal-overlay[hidden] { display: none !important; }
body.compare-open { overflow: hidden; }
.compare-modal-dialog {
    position: relative;
    z-index: 81;
    display: flex;
    flex-direction: column;
    width: min(1120px, 100%);
    max-height: min(880px, 100%);
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 18px 54px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}
.compare-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px 12px 20px;
    border-bottom: 1px solid var(--border);
}
.compare-modal-title { margin: 0; font-size: 18px; font-weight: 800; color: var(--text); }
.compare-modal-tools {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px 20px;
    padding: 10px 20px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-dim);
}
.compare-diff-toggle { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; min-height: 32px; color: var(--text); user-select: none; }
.compare-diff-toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.compare-switch {
    position: relative;
    width: 38px;
    height: 22px;
    border-radius: var(--radius);
    clip-path: inset(0 round 11px);
    background: rgba(140, 140, 140, 0.35);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
    box-sizing: border-box;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
    flex: none;
}
.compare-switch::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    border-radius: var(--radius-round);
    background: #ffffff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
    transition: transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.compare-diff-toggle input:checked + .compare-switch {
    background: var(--accent);
    box-shadow: inset 0 0 0 1px var(--accent);
}
.compare-diff-toggle input:checked + .compare-switch::after {
    transform: translateX(16px);
}
.compare-diff-toggle input:focus-visible + .compare-switch {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
.compare-legend { display: inline-flex; align-items: center; gap: 8px; }
.compare-legend i {
    width: 14px;
    height: 14px;
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--accent) 16%, transparent);
    border-left: 3px solid var(--accent);
}
.compare-table-wrap { flex: 1; min-height: 0; overflow: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.compare-table { --cmp-first: 200px; --cmp-col: 230px; table-layout: fixed; width: 100%; min-width: calc(var(--cmp-first) + var(--cmp-n, 2) * var(--cmp-col)); overflow-wrap: anywhere; border-collapse: separate; border-spacing: 0; font-size: 14px; color: var(--text); }
.compare-table th,
.compare-table td { padding: 11px 16px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); background: var(--bg-panel); }
.compare-table thead th {
    position: sticky;
    top: 0;
    z-index: 3;
    vertical-align: top;
    padding-top: 14px;
    padding-bottom: 14px;
}
.compare-table thead th.compare-corner {
    min-width: 168px;
    z-index: 4;
    left: 0;
    width: var(--cmp-first);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-dim);
    vertical-align: bottom;
}
.compare-table tbody th {
    position: sticky;
    left: 0;
    z-index: 2;
    width: var(--cmp-first);
    font-weight: 600;
    color: var(--text-dim);
    border-right: 1px solid var(--border);
}
.compare-table tbody tr:hover th,
.compare-table tbody tr:hover td { background: color-mix(in srgb, var(--text) 4%, var(--bg-panel)); }
.compare-table tr.diff-row th,
.compare-table tr.diff-row td { background: color-mix(in srgb, var(--accent) 9%, var(--bg-panel)); }
.compare-table tr.diff-row th { color: var(--text); box-shadow: inset 3px 0 0 var(--accent); }
.compare-table tr.diff-row td { font-weight: 600; }
.compare-table-wrap.only-diff .same-row { display: none; }
.compare-model { display: flex; flex-direction: column; gap: 8px; align-items: center; text-align: center; width: 100%; height: 100%; }
.compare-model-thumb {
    width: 100%;
    max-width: 180px;
    aspect-ratio: 4 / 3;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: rgba(127, 127, 127, 0.08);
    overflow: hidden;
    margin: 0 auto;
    flex: none;
}
.compare-model-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.compare-model-title {
    font-size: 14.5px;
    font-weight: 700;
    line-height: 1.3;
    color: var(--text);
    text-align: center;
    min-height: 2.8em;
    display: flex;
    align-items: center;
    justify-content: center;
    word-break: break-word;
    width: 100%;
    margin: 0;
}
body.in-3d .compare-bar,
#app.in-3d-mode .compare-bar { display: none !important; }

@media (max-width: 720px) {
    .compare-bar {
        left: 12px;
        right: 76px;
        width: auto;
        transform: none;
        grid-template-columns: 1fr;
        gap: 8px;
        padding: 10px 12px;
        animation: none;
    }
    .compare-bar-thumbs { order: 1; }
    .compare-bar-info { order: 2; flex-direction: row; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; }
    .compare-bar-actions { order: 3; }
    .compare-bar-actions .btn-compare-action { flex: 1; }
    .btn-compare-action,
    .btn-compare-clear { min-height: 44px; }
    body.has-compare-bar #gallery-grid { padding-bottom: 168px; }
    .compare-modal-overlay { padding: 0; }
    .compare-modal-dialog { width: 100%; height: 100%; max-height: none; border: 0; }
    .compare-modal-head { padding: 10px 12px 10px 16px; }
    .compare-modal-title { font-size: 16px; }
    .compare-modal-tools { padding: 8px 16px; }
    .compare-table { font-size: 13.5px; }
    .compare-table th,
    .compare-table td { padding: 10px 12px; }
    .compare-table { --cmp-first: 112px; --cmp-col: 152px; }
    .compare-table th { overflow-wrap: break-word; }
    .compare-table thead th { padding-left: 10px; padding-right: 10px; }
    .compare-table thead th.compare-corner,
    .compare-table tbody th { font-size: 12.5px; padding-left: 10px; padding-right: 8px; }
    .compare-table thead th.compare-corner { font-size: 9.5px; letter-spacing: 0.02em; }
    .compare-table td { padding-left: 10px; padding-right: 10px; }
    .compare-model-thumb { max-width: 112px; }
    .compare-model-title { font-size: 12.5px; min-height: 2.5em; }
}
@media (max-height: 520px) and (orientation: landscape) {
    .compare-bar { grid-template-columns: auto 1fr auto; left: 12px; right: 76px; width: auto; transform: none; animation: none; bottom: calc(8px + var(--safe-bottom)); padding: 6px 10px; }
    .compare-bar-thumbs,
    .compare-bar-info,
    .compare-bar-actions { order: 0; }
    .compare-bar-thumb { width: 40px; height: 30px; }
    .compare-bar-actions .btn-compare-action { flex: none; }
    body.has-compare-bar #gallery-grid { padding-bottom: 80px; }
    .compare-modal-overlay { padding: 0; }
    .compare-modal-dialog { width: 100%; height: 100%; max-height: none; border: 0; }
    .compare-modal-head { padding: 6px 10px 6px 16px; }
    .compare-modal-tools { padding: 4px 16px; }
    .compare-table thead th { padding-top: 8px; padding-bottom: 8px; }
    .compare-model { flex-direction: row; align-items: center; gap: 10px; }
    .compare-table { --cmp-first: 150px; --cmp-col: 260px; }
    .compare-model-thumb { width: 64px; max-width: 64px; flex: none; margin: 0; }
    .compare-model-title { font-size: 13px; min-height: auto; text-align: left; justify-content: flex-start; }
}

/* --- Вводная заставка при первом заходе (один раз в 30 дней, пропускается сразу) --- */
.intro {
    position: fixed;
    inset: 0;
    z-index: 120;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: max(20px, env(safe-area-inset-top)) 20px max(20px, env(safe-area-inset-bottom));
    background:
        radial-gradient(ellipse 70% 55% at 50% 38%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 70%),
        linear-gradient(color-mix(in srgb, var(--border) 45%, transparent) 1px, transparent 1px) 0 0 / 100% 56px,
        linear-gradient(90deg, color-mix(in srgb, var(--border) 45%, transparent) 1px, transparent 1px) 0 0 / 56px 100%,
        var(--bg);
    overflow-y: auto;
    opacity: 0;
    transition: opacity 0.45s ease;
}
.intro[hidden] { display: none !important; }
.intro.is-visible { opacity: 1; }
.intro.is-leaving { opacity: 0; pointer-events: none; }
.intro-inner {
    width: min(640px, 100%);
    margin: auto;
    padding: 8px 0;
    transform: translateY(14px);
    transition: transform 0.6s cubic-bezier(.16, 1, .3, 1);
}
.intro.is-visible .intro-inner { transform: none; }
.intro-brand { display: flex; align-items: center; gap: 12px; color: var(--accent); font-weight: 800; letter-spacing: 0.18em; font-size: 15px; }
.intro-brand svg { width: 34px; height: 34px; }
.intro-langs { margin-left: auto; display: flex; gap: 6px; }
.intro-lang {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 48px;
    min-height: 36px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: transparent;
    color: var(--text-dim);
    font: inherit;
    font-size: 12.5px;
    font-weight: 700;
    letter-spacing: 0.06em;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.intro-lang svg {
    width: 18px;
    height: 12px;
    flex-shrink: 0;
}
.intro-lang:hover {
    border-color: var(--accent);
    color: var(--text);
}
.intro-lang.is-active {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(226, 138, 43, 0.08);
}
.intro-lang:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.intro-eyebrow { margin: 40px 0 10px; font-size: 12.5px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: var(--text-dim); }
.intro-title { margin: 0 0 16px; font-size: clamp(28px, 6.4vw, 46px); line-height: 1.08; letter-spacing: -0.01em; color: var(--text); text-wrap: balance; }
.intro-lead { margin: 0 0 26px; font-size: clamp(15px, 2.6vw, 18px); line-height: 1.5; color: var(--text-dim); max-width: 34em; }
.intro-points { list-style: none; margin: 0 0 30px; padding: 0; display: grid; gap: 12px; }
.intro-points li { display: flex; align-items: center; gap: 12px; font-size: 15px; color: var(--text); }
.intro-points svg { width: 22px; height: 22px; flex: none; color: var(--accent); }
.intro-cookie-consent {
    margin: 0 0 22px;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.03);
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-dim);
}
.intro-cookie-text { margin: 0; }
.intro-privacy-link {
    display: inline-block;
    margin-left: 6px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--accent);
    font: inherit;
    font-size: 13px;
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
}
.intro-privacy-link:hover { opacity: 0.85; }
.intro-privacy-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.intro-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 14px 22px; }
.intro-cta {
    min-height: 52px;
    padding: 0 28px;
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    background: var(--accent);
    color: var(--accent-contrast);
    font: inherit;
    font-size: 16px;
    font-weight: 800;
    cursor: pointer;
    transition: opacity 0.15s;
}
.intro-cta:hover { opacity: 0.92; }
.intro-skip { min-height: 44px; padding: 0 6px; border: 0; background: transparent; color: var(--text-dim); font: inherit; font-size: 14px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.intro-skip:hover { color: var(--text); }
.intro-cta:focus-visible,
.intro-skip:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.intro-note { margin: 30px 0 0; font-size: 12.5px; color: var(--text-dim); }
body.intro-open { overflow: hidden; }
@media (prefers-reduced-motion: reduce) {
    .intro, .intro-inner { transition: none; transform: none; }
}
@media (max-height: 520px) and (orientation: landscape) {
    .intro-eyebrow { margin-top: 16px; }
    .intro-points { grid-template-columns: repeat(3, 1fr); margin-bottom: 18px; }
    .intro-points li { flex-direction: column; align-items: flex-start; gap: 6px; font-size: 13px; }
    .intro-cookie-consent { margin-bottom: 12px; padding: 6px 10px; font-size: 12px; }
    .intro-lead { margin-bottom: 14px; }
    .intro-note { margin-top: 14px; }
}

/* --- Мобильная версия публичного вьювера (ТЗ_16) --- */

/* Атрибут hidden не должен проигрывать display: flex у кнопок (иначе скрытые замеры и поддержка оставались видны) */
.tool-btn[hidden],
.topbar-nav-btn[hidden],
.topbar-rfq-btn[hidden],
.topbar-menu-item[hidden] { display: none !important; }

/* Тонкая полоса прогресса догрузки полной детализации (кнопок загрузки нет) */
.detail-progress {
    position: fixed;
    top: var(--safe-top, 0px);
    left: 0;
    right: 0;
    height: 3px;
    z-index: 45;
    pointer-events: none;
}
.detail-progress[hidden] { display: none; }
.detail-progress i { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.25s ease; }
body.in-gallery .detail-progress { display: none; }

/* Бургер и его меню: только на телефоне */
.topbar-burger { display: none; }
.topbar-menu-backdrop { position: fixed; inset: 0; z-index: 88; background: transparent; }
.topbar-menu-backdrop[hidden] { display: none; }
.topbar-menu {
    position: fixed;
    top: calc(56px + var(--safe-top, 0px));
    right: calc(10px + var(--safe-right, 0px));
    z-index: 89;
    width: min(290px, calc(100vw - 20px));
    padding: 6px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}
.topbar-menu[hidden] { display: none; }
.topbar-menu-item {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    min-height: 48px;
    padding: 0 12px;
    background: transparent;
    border: 0;
    border-radius: var(--radius);
    color: var(--text);
    font: inherit;
    font-size: 15px;
    text-align: left;
    cursor: pointer;
}
.topbar-menu-item:active,
.topbar-menu-item:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.topbar-menu-item svg { width: 22px; height: 22px; flex: none; color: var(--accent); }
.topbar-menu-flag { display: inline-flex; width: 22px; flex: none; }
.topbar-menu-flag svg { width: 22px; height: 15px; color: inherit; }
.topbar-menu-sep { height: 1px; margin: 4px 6px; background: var(--border); }

@media (max-width: 600px), (max-height: 500px) and (pointer: coarse) {
    /* Каталог: слева логотип, справа «Запрос ТКП» и бургер; остальное в меню */
    body #app #site-topbar:not(.mode-3d) :is(#topbar-nav, #btn-gallery-theme, #btn-gallery-lang) { display: none !important; }
    body #app #site-topbar:not(.mode-3d) .topbar-burger { display: flex; }
    body #app #site-topbar:not(.mode-3d) {
        justify-content: flex-start;
        gap: 8px;
    }
    body #app #site-topbar:not(.mode-3d) :is(.brand-link, .topbar-rfq-btn, .topbar-burger) {
        flex: 0 0 44px;
        width: 44px;
        height: 44px;
        max-width: 44px;
        aspect-ratio: auto;
    }
    body #app #site-topbar:not(.mode-3d) .brand-link { margin-right: auto; }
    body #app #site-topbar:not(.mode-3d) .topbar-actions { margin-left: auto; }

    /* Области нажатия не меньше 44 px */
    #site-topbar.mode-3d .brand-link,
    #site-topbar.mode-3d #btn-gallery-theme,
    .gallery-header-btn { width: 44px; height: 44px; }
    .btn-copy { min-height: 44px; min-width: 64px; height: 44px; }
    .rfq-input,
    .rfq-select { height: 48px; }
    .gallery-dot { position: relative; }
    .gallery-dot::before { content: ''; position: absolute; inset: -20px -3px; }
}

/* Окно сравнения: миниатюры без рамки, на фоне окна */
.compare-model-thumb { border: 0; background: transparent; overflow: visible; }
.compare-model-thumb img { filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.22)); }
html[data-theme="light"] .compare-model-thumb img { filter: drop-shadow(0 6px 8px rgba(15, 23, 42, 0.16)); }
@media (max-width: 720px) {
    .compare-table { --cmp-first: 108px; --cmp-col: 152px; }
    .compare-table.compare-n2 { --cmp-col: calc((100vw - var(--cmp-first)) / 2); }
    .compare-table tbody th { font-size: 12px; padding-left: 8px; padding-right: 6px; hyphens: auto; -webkit-hyphens: auto; }
    .compare-table thead th.compare-corner { font-size: 11px; letter-spacing: 0; }
    .compare-model-thumb { max-width: 132px; }
    .compare-model-title { font-size: 13px; }
}

/* Колесо: убранный сектор (замеры выключены) не рисуется, остальные остаются на местах */
.radial-sector.is-removed,
.radial-sector-fo.is-removed { display: none; }

/* --- ТЗ_16, раздел 5: остальные доработки мобильной версии --- */

/* «+N» на карточке: сколько характеристик не поместилось (полный список в шторке по нажатию на карточку) */
.gallery-chip-more { font-weight: 700; color: var(--accent); border-color: var(--accent); }

/* Кнопка чата гаснет, пока листают карусель */
.chat-launcher-btn { transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease, border-color 0.2s ease; }
.chat-launcher-btn.is-scroll-faded { opacity: 0; pointer-events: none; }

/* Сравнение, три и четыре модели: правый край затухает, пока справа есть ещё колонки */
@media (max-width: 720px) {
    .compare-table-wrap.has-more {
        -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 36px), transparent);
        mask-image: linear-gradient(to right, #000 calc(100% - 36px), transparent);
    }
}

@media (max-width: 600px) {
    /* Окна ТКП и паспорта: нижний лист с «ручкой», закрывается смахиванием вниз */
    .rfq-modal-overlay { align-items: flex-end; padding: 0; }
    .rfq-modal-dialog {
        max-width: none;
        width: 100%;
        max-height: calc(100dvh - 24px - var(--safe-top, 0px));
        border-left: 0;
        border-right: 0;
        border-bottom: 0;
        transform: translateY(40px);
    }
    .rfq-modal-overlay.is-open .rfq-modal-dialog { transform: translateY(0); }
    .rfq-modal-dialog .drawer-header { position: relative; padding-top: 20px; touch-action: none; }
    .rfq-modal-dialog .drawer-header::before {
        content: '';
        position: absolute;
        top: 8px;
        left: 50%;
        width: 40px;
        height: 4px;
        margin-left: -20px;
        border-radius: var(--radius);
        background: var(--border);
    }
    .rfq-modal-body { padding-bottom: calc(16px + var(--safe-bottom, 0px)); }

    /* Подписи форм обычным регистром */
    .rfq-label,
    .rfq-modal-dialog .drawer-badge { text-transform: none; letter-spacing: 0.01em; font-size: 13px; }
    .rfq-modal-dialog .drawer-badge { font-size: 12px; }
    .rfq-submit-btn { text-transform: none; letter-spacing: 0.01em; font-size: 15px; height: 48px; }
}

/* Портрет на телефоне: кадр модели над нижней панелью, а не под ней */
@media (max-width: 600px) and (orientation: portrait) {
    body.in-3d #viewer-container,
    #app.in-3d-mode #viewer-container { bottom: calc(61px + var(--safe-bottom, 0px)); }
}

@media (hover: none), (pointer: coarse) {
    body:has(.controls-hint:not([hidden])) .scale-bar { visibility: hidden; }
}
