/**
 * responsive.css — умная вёрстка панели под телефоны, планшеты и настольные экраны.
 *
 * Правила игры (чтобы ничего не сломать):
 *   • здесь только ДОПОЛНЕНИЯ и переопределения внутри медиа-запросов; базовые стили разделов
 *     остаются в style.css / shell.css / <раздел>/lib/*.css и не трогаются;
 *   • вёрстка не «плавает»: высота каркаса берётся из dvh (динамический вьюпорт), внутренние
 *     области прокручиваются сами, transform/opacity — единственные анимируемые свойства;
 *   • выворачивание экрана (orientation) не требует перезагрузки: раскладка зависит только от
 *     ширины и высоты вьюпорта, а ящик меню на широком экране закрывается сам (boot.js);
 *   • safe-area (вырез камеры, домашняя полоса) учитывается через env().
 *
 * Подключается последней в core/shell.php, после стилей раздела.
 */

/* мобильная подсказка мастерской — только на телефоне */
.studio-note--mobile { display: none; }

/* ------------------------------------------------------------------ */
/* 1. Основа: динамическая высота, вырез экрана, «как приложение»       */
/* ------------------------------------------------------------------ */

html {
    -webkit-text-size-adjust: 100%;      /* поворот экрана не увеличивает шрифт */
    text-size-adjust: 100%;
    /* запрет бокового сдвига страницы: hidden поддерживают все браузеры,
       clip — современные (там, где есть, он не создаёт лишнего скролл-контейнера) */
    overflow-x: hidden;
    overscroll-behavior-x: none;
}
@supports (overflow: clip) {
    html { overflow-x: clip; }
}

body.triz-section-page {
    /* динамический вьюпорт: адресная строка мобильного браузера больше не «дёргает» каркас */
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;   /* нет серой вспышки при касании */
    overscroll-behavior: none;                  /* нет оттягивания страницы за пределы */
    /* запрет горизонтальных жестов на уровне страницы: карточки и таблицы листаются
       внутри своих блоков, а сама страница стоит на месте */
    touch-action: pan-y pinch-zoom;
    max-width: 100vw;
    overflow-x: hidden;
}

body.triz-section-page .admin-layout {
    height: 100vh;
    height: 100dvh;
    width: 100%;
    min-height: 0;
}

body.triz-section-page .main-content {
    min-width: 0;                        /* иначе flex-элемент не даёт себя сжать */
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding-left: max(2rem, env(safe-area-inset-left));
    padding-right: max(2rem, env(safe-area-inset-right));
    padding-bottom: max(2rem, env(safe-area-inset-bottom));
}

body.triz-section-page img,
body.triz-section-page video,
body.triz-section-page iframe {
    max-width: 100%;
}

/* касания: без задержки 300 мс и без случайного выделения текста на кнопках */
body.triz-section-page button,
body.triz-section-page .btn,
body.triz-section-page .sidebar-link,
body.triz-section-page .tab-btn,
body.triz-section-page .qr-tab,
body.triz-section-page .studio-tool,
body.triz-section-page .nls-action {
    touch-action: manipulation;
}

/* мобильная шапка и затемнение — по умолчанию их нет (настольный экран) */
.triz-topbar { display: none; }
.triz-backdrop { display: none; }

/* ------------------------------------------------------------------ */
/* 2. Планшеты: чуть уже меню, меньше отступы                          */
/* ------------------------------------------------------------------ */

@media (max-width: 1199px) {
    body.triz-section-page .sidebar { width: 240px; padding: 1.15rem; }
    body.triz-section-page .main-content { padding: 1.5rem; }
    body.triz-section-page .tab-title { font-size: 1.4rem; }
}

/* ------------------------------------------------------------------ */
/* 3. Телефоны и планшеты в портрете: меню уезжает в ящик              */
/* ------------------------------------------------------------------ */

@media (max-width: 900px) {
    body.triz-section-page {
        --triz-topbar-h: calc(52px + env(safe-area-inset-top));
    }

    /* шапка: гамбургер, название раздела, быстрый переход на портал */
    body.triz-section-page .triz-topbar {
        position: fixed;
        top: 0; left: 0; right: 0;
        height: var(--triz-topbar-h);
        padding: env(safe-area-inset-top) max(10px, env(safe-area-inset-right)) 0 max(10px, env(safe-area-inset-left));
        display: flex;
        align-items: center;
        gap: 10px;
        box-sizing: border-box;
        background: rgba(28, 21, 17, 0.96);
        border-bottom: 1px solid var(--border);
        backdrop-filter: blur(8px);
        z-index: 60;
    }

    .triz-burger {
        flex: 0 0 auto;
        width: 44px; height: 44px;
        display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
        background: var(--surface-2);
        border: 1px solid var(--border);
        border-radius: 12px;
        cursor: pointer;
        padding: 0;
    }
    .triz-burger span {
        display: block; width: 20px; height: 2px; border-radius: 2px;
        background: #f3ece1; transition: transform .18s ease, opacity .18s ease;
    }
    body.triz-nav-open .triz-burger span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
    body.triz-nav-open .triz-burger span:nth-child(2) { opacity: 0; }
    body.triz-nav-open .triz-burger span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

    .triz-topbar-title {
        flex: 1 1 auto;
        min-width: 0;
        font-size: 15px;
        font-weight: 800;
        letter-spacing: .2px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .triz-topbar-home {
        flex: 0 0 auto;
        width: 44px; height: 44px;
        display: inline-flex; align-items: center; justify-content: center;
        border-radius: 12px; border: 1px solid var(--border);
        background: var(--surface-2);
        font-size: 19px; text-decoration: none;
    }

    /* каркас освобождает место под фиксированную шапку */
    body.triz-section-page .admin-layout {
        margin-top: var(--triz-topbar-h);
        height: calc(100vh - var(--triz-topbar-h));
        height: calc(100dvh - var(--triz-topbar-h));
    }

    /* меню — выдвижной ящик. В закрытом состоянии его вообще нет в раскладке
       (display: none): так страницу нельзя утащить вбок ни в Safari, ни в Chrome —
       «уехавшее» за край фиксированное меню как раз и было причиной «плавания». */
    body.triz-section-page .sidebar {
        position: fixed;
        top: var(--triz-topbar-h);
        bottom: 0;
        left: 0;
        width: min(312px, 86vw);
        max-width: 86vw;
        padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom));
        border-right: 1px solid var(--border);
        border-bottom: 0;
        background: var(--surface);
        display: none;
        overflow-y: auto;
        overscroll-behavior: contain;
        z-index: 70;
        box-shadow: 18px 0 40px rgba(0, 0, 0, .45);
    }
    body.triz-nav-open .sidebar { display: flex; }

    body.triz-section-page .triz-backdrop {
        display: block;
        position: fixed;
        inset: var(--triz-topbar-h) 0 0 0;
        background: rgba(0, 0, 0, .55);
        opacity: 0;
        pointer-events: none;
        transition: opacity .2s ease;
        z-index: 65;
    }
    body.triz-nav-open .triz-backdrop { opacity: 1; pointer-events: auto; }

    /* пока ящик открыт, содержимое не прокручивается под ним */
    body.triz-nav-open .main-content { overflow: hidden; }

    /* пункты меню — крупные, палец не промахивается */
    body.triz-section-page .sidebar-link {
        min-height: 44px;
        display: flex;
        align-items: center;
        font-size: 0.95rem;
        padding: 11px 14px;
    }
    body.triz-section-page .sidebar-footer { margin-top: 12px; }
    body.triz-section-page .sidebar-footer .btn { width: 100%; min-height: 44px; }

    body.triz-section-page .main-content { padding: 1rem; }

    /* заголовок раздела и кнопки — друг под другом, без обрезков */
    body.triz-section-page .triz-section .tab-header-row { flex-direction: column; align-items: stretch; gap: 10px; }
    body.triz-section-page .triz-section-actions { width: 100%; }
    body.triz-section-page .triz-section-actions > * { flex: 1 1 auto; min-height: 40px; }
    body.triz-section-page .tab-title { font-size: 1.25rem; }
    body.triz-section-page .tab-desc { font-size: 0.8rem; }

    /* поля не «зумят» в iOS: меньше 16px он увеличивает страницу при фокусе.
       Только текстовые поля — размер галочек и радиокнопок не трогаем. */
    body.triz-section-page input:not([type="checkbox"]):not([type="radio"]),
    body.triz-section-page select,
    body.triz-section-page textarea,
    body.triz-section-page .input,
    body.triz-section-page .field input:not([type="checkbox"]):not([type="radio"]),
    body.triz-section-page .field select,
    body.triz-section-page .field textarea { font-size: 16px; }

    /* двух- и трёхколоночные сетки, заданные в разметке инлайн, — в одну колонку */
    body.triz-section-page .qr-pane [style*="grid-template-columns"],
    body.triz-section-page .triz-section [style*="grid-template-columns: 1fr 1fr"],
    body.triz-section-page .triz-section [style*="grid-template-columns: 1fr 1fr 1fr"],
    body.triz-section-page .triz-section [style*="grid-template-columns:180px 1fr"] {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    /* Любая сетка, заданная в разметке инлайном, на телефоне — в одну колонку:
       иначе .adm-grid (minmax(280px,360px) 1fr), конструктор страниц и дизайн
       вылезают за экран, и весь раздел «уезжает» вбок.
       minmax(0, 1fr) вместо 1fr — чтобы колонка могла сжаться уже содержимого
       (иначе длинная строка распирает её и раздел снова шире экрана). */
    body.triz-section-page .triz-section [style*="grid-template-columns"] {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    /* Раздел никогда не должен прокручиваться вбок целиком: широкое содержимое
       (таблицы, шахматка, превью) прокручивается внутри своего блока. */
    body.triz-section-page .main-content { overflow-x: hidden; }

    /* широкие таблицы не должны двигать раздел: каждая лежит в своей прокрутке */
    body.triz-section-page .tbl-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
    body.triz-section-page .tbl-scroll > table { min-width: 720px; }
    body.triz-section-page .triz-section .info-table { display: block; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    body.triz-section-page .triz-section #ctlTable { min-width: 900px; }

    /* любой блок, в котором лежит таблица (например #ctlDevices), прокручивается сам */
    body.triz-section-page .triz-section div:has(> table) { overflow-x: auto; -webkit-overflow-scrolling: touch; }

    /* дети сеток и карточек могут сжиматься: иначе длинная подпись распирает колонку */
    body.triz-section-page .triz-section .card,
    body.triz-section-page .triz-section .adm-grid > *,
    body.triz-section-page .triz-section [class*="-grid"] > * { min-width: 0; }

    /* переключатель режимов «Страниц» переносится, а не режет экран */
    body.triz-section-page .cnt-mode-switch {
        display: flex !important;
        flex-wrap: wrap;
        gap: 6px;
        max-width: 100%;
    }
    body.triz-section-page .cnt-mode { flex: 1 1 auto; min-height: 38px; }

    /* «Дизайн»: строки цвета — обычный перенос, а не жёсткие колонки 1fr 46px 96px */
    body.triz-section-page .ds-color-row,
    body.triz-section-page .ds-color-row--alpha {
        display: flex !important;
        flex-wrap: wrap;
        align-items: center;
        gap: 8px;
    }
    body.triz-section-page .ds-color-label { flex: 1 1 100%; }
    body.triz-section-page .ds-color-row input[type="text"],
    body.triz-section-page .ds-color-row .input { flex: 1 1 96px; min-width: 0; }
    body.triz-section-page .ds-color-picker { flex: 0 0 44px; }
    body.triz-section-page .ds-preview-wrap,
    body.triz-section-page .ds-preview { width: 100% !important; max-width: 100% !important; }
    body.triz-section-page iframe.ds-preview { height: clamp(320px, 42dvh, 520px) !important; }

    /* кнопки в строке инструментов — не «в обрез» */
    body.triz-section-page .toolbar-row { gap: 0.6rem; }
    body.triz-section-page .btn { min-height: 40px; }

    /* редактор контента: на телефоне панели друг под другом, без фиксированной высоты */
    body.triz-section-page .visual-editor-container {
        height: auto;
        min-height: 0;
        gap: 1rem;
    }
    body.triz-section-page .editor-forms-panel { flex: 0 0 auto; }
    body.triz-section-page .content-list-scroll { overflow: visible; }

    /* мастерская: окно инструмента во всю ширину и разумной высоты */
    body.triz-section-page .studio-frame {
        height: clamp(380px, 62dvh, 720px);
        min-height: 380px;
    }
    body.triz-section-page .studio-brand { gap: 10px; }
    body.triz-section-page .studio-brand .studio-actions { margin-left: 0; width: 100%; }
    body.triz-section-page .studio-brand .studio-actions > * { flex: 1 1 auto; }
    body.triz-section-page .studio-tool { min-width: calc(50% - 4px); flex: 1 1 calc(50% - 4px); }

    /* подсказка про полноэкранный режим — только на телефоне */
    body.triz-section-page .studio-note--mobile { display: block; }
}

/* Мастерская на весь экран: окно инструмента занимает экран ПОД шапкой панели, поэтому
   собственное меню движка не уходит под вырез камеры и всегда видно. Кнопка «свернуть»
   стоит в шапке справа. */
body.studio-full .studio-body {
    position: fixed;
    top: var(--triz-topbar-h, 52px);
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 55;
    margin: 0;
    padding: 0;
    background: #171310;
}
body.studio-full .studio-frame {
    height: calc(100dvh - var(--triz-topbar-h, 52px));
    min-height: calc(100dvh - var(--triz-topbar-h, 52px));
    border-radius: 0;
    border: 0;
}
body.studio-full .triz-topbar { z-index: 80; }
body.studio-full .triz-topbar-home { visibility: hidden; }
body.studio-full .studio-brand { display: none; }
body.studio-full .studio-actions { margin: 0; }
body.studio-full .studio-rail,
body.studio-full .studio-grid,
body.studio-full .studio-note { display: none; }

/* кнопка «свернуть» в полноэкранном режиме мастерской — прямо в body, поверх всего */
.studio-fs-exit { display: none; }
body.studio-full .studio-fs-exit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    top: calc(env(safe-area-inset-top) + 7px);
    right: 12px;
    z-index: 230;
    min-height: 38px;
    padding: 0 12px;
    font: 700 12px/1 system-ui, "Segoe UI", Arial, sans-serif;
    color: #f6efe2;
    background: rgba(212, 175, 55, .18);
    border: 1px solid rgba(212, 175, 55, .6);
    border-radius: 10px;
    cursor: pointer;
}

/* Шахматка на весь экран — та же логика: развернуть/свернуть, кнопка остаётся на виду */
body.triz-section-page.board-full .board-scroll {
    position: fixed;
    inset: 0;
    z-index: 200;
    height: 100dvh !important;
    max-height: 100dvh !important;
    min-height: 0 !important;
    width: 100% !important;
    margin: 0;
    padding: 8px 8px max(8px, env(safe-area-inset-bottom));
    border-radius: 0;
    border: 0;
    background: #1b1511;
    touch-action: pan-x pan-y;
}
/* в полноэкранном режиме шапка дней прилипает к верху — иначе она «прячется» */
body.triz-section-page.board-full .board-days { top: 0 !important; }
body.triz-section-page.board-full .board-hrow.board-months { position: sticky; top: 0; z-index: 7; background: #1a1310; }
body.board-full .board-hint,
body.board-full .board-legend { display: none; }
body.board-full #boardFull {
    position: fixed;
    top: max(8px, env(safe-area-inset-top));
    right: 10px;
    z-index: 210;
    background: rgba(28, 21, 17, .95);
    border: 1px solid rgba(212, 175, 55, .5);
    box-shadow: 0 8px 24px rgba(0, 0, 0, .5);
    min-height: 40px;
}

@media (max-width: 900px) {

    /* модальные окна и оверлеи не вылезают за экран */
    body.triz-section-page .info-overlay > *,
    body.triz-section-page .modal,
    body.triz-section-page [role="dialog"] {
        max-width: calc(100vw - 20px);
        max-height: calc(100dvh - 24px);
        overflow: auto;
    }

    /* горизонтальные простыни таблиц прокручиваются пальцем */
    body.triz-section-page .bookings-grid-container,
    body.triz-section-page .board-scroll { -webkit-overflow-scrolling: touch; }

    /* Шахматка на телефоне: ниже, с подсказкой, что её листают вбок */
    body.triz-section-page .board-scroll {
        min-height: 380px;
        max-height: 64dvh;
        padding-bottom: 10px;
    }
    body.triz-section-page .board-row { min-height: 54px; }
    body.triz-section-page .board-bar { font-size: 11px; }
    body.triz-section-page .board-bar-meta { font-size: 9px; }
    body.triz-section-page .board-hint {
        display: block;
        margin: 8px 0 0;
        font-size: 11.5px;
        color: var(--text-muted);
        line-height: 1.5;
    }
}

/* ------------------------------------------------------------------ */
/* 4a. Бронирования на телефоне: компактная панель над шахматкой       */
/* ------------------------------------------------------------------ */

@media (max-width: 560px) {
    body.triz-section-page .board-toolbar {
        display: grid !important;      /* перебиваем инлайновый display:flex из разметки */
        grid-template-columns: 1fr 1fr;
        gap: 6px;
        width: 100%;
    }
    body.triz-section-page .board-toolbar > * { min-width: 0; width: 100%; }
    body.triz-section-page .board-toolbar #boardMonth {
        grid-column: 1 / -1;
        min-width: 0;
        text-align: center;
        font-size: 13px;
    }
    body.triz-section-page .board-toolbar #boardPrev,
    body.triz-section-page .board-toolbar #boardNext { padding: 8px 0; }
    body.triz-section-page .board-toolbar select,
    body.triz-section-page .board-toolbar .input { max-width: none !important; }
    body.triz-section-page .board-toolbar .btn--sm { min-height: 36px; font-size: 12px; }
    /* карточки сводки — по две в ряд */
    body.triz-section-page #boardCards,
    body.triz-section-page #ctlCards { grid-template-columns: 1fr 1fr !important; }
}

/* ------------------------------------------------------------------ */
/* 4. Телефоны в портрете: ещё компактнее                              */
/* ------------------------------------------------------------------ */

@media (max-width: 560px) {
    body.triz-section-page .main-content { padding: 0.85rem; }
    body.triz-section-page .card { border-radius: 14px; }
    body.triz-section-page .qr-tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    body.triz-section-page .qr-tab { flex: 0 0 auto; padding: 9px 12px; }
    body.triz-section-page .studio-tool { min-width: 100%; flex-basis: 100%; }
    body.triz-section-page .triz-topbar-title { font-size: 14px; }

    /* в таблице SEO на узком экране оставляем главное (страница, заголовок, состояние):
       описание и ключевые слова всё равно правятся ниже, в форме */
    body.triz-section-page .seo-table th:nth-child(3),
    body.triz-section-page .seo-table th:nth-child(4),
    body.triz-section-page .seo-table td:nth-child(3),
    body.triz-section-page .seo-table td:nth-child(4) { display: none; }
    body.triz-section-page .tbl-scroll > table,
    body.triz-section-page .seo-table { min-width: 0; }
}

/* ------------------------------------------------------------------ */
/* 5. Выворачивание экрана: широкий, но низкий                        */
/* ------------------------------------------------------------------ */

@media (max-width: 900px) and (orientation: landscape) and (max-height: 560px) {
    body.triz-section-page { --triz-topbar-h: calc(44px + env(safe-area-inset-top)); }
    body.triz-section-page .triz-burger,
    body.triz-section-page .triz-topbar-home { width: 40px; height: 40px; border-radius: 10px; }
    body.triz-section-page .main-content { padding: 0.7rem 1rem; }
    body.triz-section-page .triz-section .tab-header-row { flex-direction: row; align-items: center; }
    body.triz-section-page .tab-desc { display: none; }
    body.triz-section-page .studio-frame { height: calc(100dvh - 190px); min-height: 260px; }
    body.triz-section-page .sidebar-brand { margin-bottom: 0.9rem; }
    body.triz-section-page .sidebar-user { padding: 0.6rem; margin-bottom: 0.9rem; }
}

/* ------------------------------------------------------------------ */
/* 6. Большие экраны и тач-ноутбуки: воздух, но контент на всю ширину  */
/* ------------------------------------------------------------------ */

@media (min-width: 1600px) {
    body.triz-section-page .main-content { padding: 2.5rem max(3rem, env(safe-area-inset-left)); }
}

/* Широкоформатные мониторы: панель занимает экран целиком, без «островка» посередине.
   Поля и сетки тянутся сами (раздел 10), поэтому центрировать и ужимать нечего. */
@media (min-width: 1900px) {
    body.triz-section-page .main-content { padding: 2.5rem max(2.5rem, env(safe-area-inset-left)); }
    body.triz-section-page .main-content > .triz-section { max-width: none; width: 100%; margin: 0; }
}

/* ------------------------------------------------------------------ */
/* 7. Плотность интерфейса при грубом указателе (палец)                */
/* ------------------------------------------------------------------ */

@media (pointer: coarse) {
    body.triz-section-page .sidebar-link { min-height: 44px; }
    body.triz-section-page .btn { min-height: 40px; }
    body.triz-section-page .btn--sm { min-height: 36px; }
    body.triz-section-page .qr-tab { min-height: 40px; }
}

/* ------------------------------------------------------------------ */
/* 8. Печать: без меню и шапки                                         */
/* ------------------------------------------------------------------ */

@media print {
    body.triz-section-page .sidebar,
    body.triz-section-page .triz-topbar,
    body.triz-section-page .triz-backdrop,
    body.triz-section-page .triz-section-actions { display: none !important; }
    body.triz-section-page .admin-layout { height: auto; margin: 0; }
    body.triz-section-page .main-content { overflow: visible; height: auto; padding: 0; }
}

/* ------------------------------------------------------------------ */
/* 9. Портал разделов и форма входа (та же адаптация)                  */
/* ------------------------------------------------------------------ */

body.triz-portal-page {
    min-height: 100vh;
    min-height: 100dvh;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior-y: none;
}

body.triz-portal-page .portal-wrap {
    padding-left: max(22px, env(safe-area-inset-left));
    padding-right: max(22px, env(safe-area-inset-right));
}

body.triz-portal-page .portal-login {
    min-height: 100vh;
    min-height: 100dvh;
    padding: max(24px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}

@media (max-width: 700px) {
    body.triz-portal-page .portal-grid { grid-template-columns: 1fr; }
    body.triz-portal-page .portal-head { gap: 10px; }
    body.triz-portal-page .portal-me { width: 100%; justify-content: space-between; }
    body.triz-portal-page .portal-card { padding: 15px 14px 14px 17px; }
}

@media (max-width: 480px) {
    body.triz-portal-page .portal-wrap { padding-left: 14px; padding-right: 14px; }
    body.triz-portal-page .portal-card { grid-template-columns: 38px 1fr; }
    body.triz-portal-page .portal-card-icon { width: 38px; height: 38px; }
}

/* поля входа: 16px, иначе iOS увеличивает страницу при фокусе */
@media (max-width: 900px) and (pointer: coarse) {
    body.triz-portal-page input,
    body.triz-portal-page select,
    body.triz-portal-page textarea { font-size: 16px; }
    body.triz-portal-page .portal-login-btn { min-height: 46px; }
}

/* ------------------------------------------------------------------ */
/* 10. Поля тянутся на любую ширину: от телефона до широкоформатного   */
/* ------------------------------------------------------------------ */

/* Поля не «выпирают» из своей колонки. Важно: ширину задаём только текстовым полям —
   чекбоксы, радиокнопки и файлы обязаны оставаться своего размера, иначе в матрице прав
   галочка растягивается на всю ячейку и подписи наезжают друг на друга.
   max-width у разделов (.adm-toolbar .input и т. п.) не перебиваем: он и так ограничивает. */
body.triz-section-page input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]):not([type="color"]):not([type="submit"]):not([type="button"]),
body.triz-section-page select,
body.triz-section-page textarea,
body.triz-section-page .field,
body.triz-section-page .field input:not([type="checkbox"]):not([type="radio"]),
body.triz-section-page .field textarea,
body.triz-section-page .field select {
    min-width: 0;
}

body.triz-section-page .field { box-sizing: border-box; }
body.triz-section-page textarea,
body.triz-section-page .field textarea { resize: vertical; }

/* колонки сеток подстраиваются сами: минимум 240px на поле, дальше — сколько помещается.
   Так на телефоне одна колонка, на планшете две, на широком мониторе форма заполняет экран. */
body.triz-section-page .triz-section .grid--2 {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, max(240px, calc((100% - 3rem) / 4))), 1fr));
}
body.triz-section-page .triz-section .grid--3 {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, max(200px, calc((100% - 3rem) / 5))), 1fr));
}

/* на очень широком экране поля получают воздух, но не растягиваются в километр */
@media (min-width: 1800px) {
    body.triz-section-page .triz-section .field { padding-right: 0; }
}

@media (max-width: 760px) {
    body.triz-section-page .triz-section .grid--2,
    body.triz-section-page .triz-section .grid--3 { grid-template-columns: 1fr; }
}
