body { margin: 0; font-family: "Manrope", sans-serif; color: var(--ink); }
.page { padding: 0 7% 80px; }

.back-link {
    display: inline-block;
    margin: 24px 0 16px;
    color: var(--ink-muted);
    text-decoration: none;
    font-size: 14px;
}
.back-link:hover { color: var(--ink); }

/* ---------- Десктоп: галерея + вкладки слева, липкая колонка справа ---------- */
.product-page {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
    grid-template-areas: "gallery aside" "details aside";
    grid-template-rows: auto 1fr;
    gap: 32px 40px;
    align-items: start;
    margin: 8px 0 48px;
}
.gallery { grid-area: gallery; min-width: 0; }
.product-details { grid-area: details; min-width: 0; }
.product-aside {
    grid-area: aside;
    position: sticky;
    top: 110px;               /* ниже липкой шапки; подгони под высоту своей */
    max-height: calc(100vh - 130px);
    overflow-y: auto;
    padding: 28px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: #fff;
}

/* Галерея */
.gallery-main {
    aspect-ratio: 4 / 3;
    border: 1px solid var(--border);
    border-radius: 20px;
    overflow: hidden;
    background: white;
}
.gallery-main img { width: 100%; height: 100%; object-fit: contain; display: block; }
.gallery-thumbs { display: flex; gap: 8px; margin-top: 12px; overflow-x: auto; }
.thumb {
    flex: 0 0 72px;
    height: 72px;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 12px;
    overflow: hidden;
    background: white;
    cursor: pointer;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.active { border-color: var(--accent); }

/* Название, цена, кнопка */
.product-summary { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; min-width: 0; margin-bottom: 24px; }
.product-category { font-size: 13px; color: var(--ink-muted); }
.product-summary h1 { font-size: 30px; line-height: 1.15; letter-spacing: -0.02em; margin: 0; overflow-wrap: anywhere; }
.product-price { font-size: 32px; font-weight: 800; font-variant-numeric: tabular-nums; }
.add-to-cart { margin-bottom: 24px; }
.buy-price { display: none; }   /* цена в нижней панели нужна только на телефоне */

/* Форма заявки: на десктопе всегда раскрыта, заголовок не кликается */
.request-box { padding-top: 24px; border-top: 1px solid var(--border); }
.request-box > summary { list-style: none; cursor: default; pointer-events: none; }
.request-box > summary::-webkit-details-marker { display: none; }
.request-box h2 { margin: 0 0 16px; font-size: 20px; }
.request-call { margin: 16px 0 0; font-size: 14px; color: var(--ink-muted); }
.request-call a { color: var(--ink); font-weight: 700; text-decoration: none; white-space: nowrap; }

/* Выбор вида сделки: пилюли, как фильтр категорий в каталоге */
.deal-type { margin: 0; padding: 0; border: 0; min-width: 0; }
.deal-type legend { padding: 0; margin-bottom: 8px; font-size: 13px; color: var(--ink-muted); }
.deal-options { display: flex; flex-wrap: wrap; gap: 8px; }
.request-form .deal-option { position: relative; flex-direction: row; gap: 0; font-size: 14px; color: var(--ink); }
.deal-option input { position: absolute; opacity: 0; pointer-events: none; }
.deal-option span {
    display: inline-block;
    padding: 10px 18px;
    border-radius: 999px;
    background: #EEF1F0;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}
.deal-option input:checked + span { background: var(--accent); color: white; }
.deal-option input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Вкладки без JS: радио-кнопки + соседние блоки */
.tabs-input { position: absolute; opacity: 0; pointer-events: none; }
.tabs-nav { display: flex; gap: 24px; margin-bottom: 20px; border-bottom: 1px solid var(--border); }
.tabs-nav label {
    padding: 12px 0; margin-bottom: -1px; cursor: pointer;
    font-weight: 600; color: var(--ink-muted);
    border-bottom: 2px solid transparent;
}
.tab-panel { display: none; line-height: 1.6; color: var(--ink); }
.tab-panel p { margin: 0 0 12px; }
#tab-desc:checked ~ .tabs-nav label[for="tab-desc"],
#tab-specs:checked ~ .tabs-nav label[for="tab-specs"] { color: var(--ink); border-bottom-color: var(--ink); }
#tab-desc:checked ~ .tab-panel--desc,
#tab-specs:checked ~ .tab-panel--specs { display: block; }
#tab-desc:focus-visible ~ .tabs-nav label[for="tab-desc"],
#tab-specs:focus-visible ~ .tabs-nav label[for="tab-specs"] { outline: 2px solid var(--accent); outline-offset: 4px; }

.specs { width: 100%; border-collapse: collapse; }
.specs th, .specs td { padding: 12px 0; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.specs th { width: 40%; padding-right: 16px; font-weight: 500; color: var(--ink-muted); }

/* «С этим товаром часто берут» */
.related h2 { font-size: 24px; margin: 0 0 16px; }
.related-track {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    padding-bottom: 8px;
}
.related-track .product-tile { flex: 0 0 220px; scroll-snap-align: start; }
.product-info { display: flex; flex-direction: column; gap: 6px; padding: 16px; }
.product-info h3 { margin: 0; font-size: 16px; }
.product-info .product-category { font-size: 12px; }
.product-tile-price { margin-top: 4px; font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- Телефон и планшет (ВСЕГДА в конце файла) ---------- */
@media (max-width: 900px) {
    .page { padding-bottom: 104px; }   /* место под нижнюю панель */

    /* Порядок: галерея, название и цена, описание, форма */
    .product-page {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
        grid-template-areas: "gallery" "summary" "details" "request";
        gap: 20px;
    }
    /* Правая колонка «распаковывается»: её блоки становятся элементами общей сетки */
    .product-aside { display: contents; }
    .product-summary { grid-area: summary; margin-bottom: 0; }
    .product-summary h1 { font-size: 24px; }
    .product-price { font-size: 28px; }
    .product-details { grid-area: details; }

    /* Галерея не больше ~40% высоты экрана */
    .gallery-main { max-height: 40vh; }
    .thumb { flex-basis: 56px; height: 56px; }

    /* Нижняя липкая панель: цена + «В корзину» */
    .add-to-cart {
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
        display: flex; align-items: center; gap: 16px;
        margin: 0;
        padding: 12px 16px max(12px, env(safe-area-inset-bottom));
        background: #fff;
        border-top: 1px solid var(--border);
        box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.06);
    }
    .buy-price { display: block; font-size: 20px; font-weight: 800; white-space: nowrap; font-variant-numeric: tabular-nums; }
    .add-to-cart .btn-block { flex: 1; }

    /* Форма заявки: свёрнутая карточка */
    .request-box {
        grid-area: request;
        padding: 0;
        border: 1px solid var(--border);
        border-radius: 16px;
        background: #fff;
    }
    .request-box > summary {
        display: flex; align-items: center; justify-content: space-between; gap: 12px;
        padding: 16px; cursor: pointer; pointer-events: auto;
    }
    .request-box > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 16px; }
    .request-box > summary h2 { margin: 0; font-size: 16px; }
    .request-box > summary::after {
        content: ""; flex: none; width: 9px; height: 9px;
        border-right: 2px solid var(--ink); border-bottom: 2px solid var(--ink);
        transform: rotate(45deg); transition: transform 0.2s ease;
    }
    .request-box[open] > summary::after { transform: rotate(-135deg); }
    .request-body { padding: 0 16px 16px; }

    /* Плашка «добавлено» не должна прятаться за нижней панелью */
    .toast { bottom: 88px; }
}