/* Доступность: текст только для скринридеров */
.sr-only{
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

/* =========================
   БАЗОВАЯ ВЁРСТКА
   ========================= */
body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    background: #f5f5f7;
}

*, *::before, *::after { box-sizing: border-box; }

.no-scroll { overflow: hidden; }

.logo-link {
    text-decoration: none;
    color: inherit;
}

.logo-link h1 {
    margin: 0;
}

/* Навигация (объединено, без дублей) */
nav a,
.nav-link {
    color: #fff;
    margin-left: 15px;
    text-decoration: none;
    position: relative;
    padding-bottom: 2px;
}

nav a:hover {
    text-decoration: none;
}

.nav-link-active::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: -4px;
    width: 100%;
    height: 2px;
    background: #ff8a00;
    border-radius: 999px;
}

main{
  width: 100%;
  padding: 20px 24px;
  max-width: none;
  margin: 0;
}
@media (min-width: 1200px){
  main{ padding: 24px 40px; }
}

/* =========================
   КНОПКИ
   ========================= */

/* База для всех кнопок */
button,
input[type="submit"],
.btn-primary,
.btn-primary:link,
.btn-primary:visited {
    display: inline-block;
    border: none;
    padding: 8px 18px;
    border-radius: 999px;
    background: linear-gradient(135deg, #ff8a00, #e52e71);
    color: #fff;
    font-weight: 500;
    cursor: pointer;
    transition: transform 0.1s ease, box-shadow 0.1s ease, opacity 0.2s;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
    text-decoration: none;
    font-size: 14px;
}

button:not(.search-inset-btn):hover,
input[type="submit"]:hover,
.btn-primary:hover {
    transform: none;                 /* ключевой фикс от "мыла" */
    box-shadow: 0 8px 18px rgba(0,0,0,0.22);
    filter: brightness(1.02);
    opacity: 1;
}

.btn-secondary,
.btn-secondary:link,
.btn-secondary:visited {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 999px;
    background: #fff;
    color: #333;
    border: 1px solid #ccc;
    box-shadow: none;
    text-decoration: none;
    font-size: 14px;
}

.btn-secondary:hover {
    background: #f0f0f0;
    border-color: #bbb;
    text-decoration: none;
}

.btn-small {
    padding: 4px 10px;
    font-size: 12px;
}

/* Кнопка выхода в шапке — как ссылка, без градиента */
.logout-link {
    background: none !important;
    border: none !important;
    padding: 0;
    margin-left: 15px;
    font: inherit;
    cursor: pointer;
    color: #fff;
    text-decoration: none;
    box-shadow: none !important;
}

.logout-link:hover {
    text-decoration: underline;
}

/* =========================
   ИНПУТЫ И ФОРМЫ
   ========================= */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="number"],
textarea {
    width: 100%;
    max-width: 400px;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid #ccc;
    background: #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.04);
    font-size: 14px;
    box-sizing: border-box;
}

textarea {
    min-height: 120px;
    resize: vertical;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="tel"]:focus,
input[type="number"]:focus,
textarea:focus {
    outline: none;
    border-color: #ff8a00;
    box-shadow: 0 0 0 2px rgba(255, 138, 0, 0.2);
}

/* Карточки форм */
.form-card {
    background: #fff;
    padding: 20px 24px;
    border-radius: 16px;
    box-shadow: 0 6px 18px rgba(0,0,0,0.08);
    max-width: 600px;
}

.form-card p {
    margin-bottom: 12px;
}

.form-card label {
    display: block;
    margin-bottom: 4px;
    font-size: 14px;
    font-weight: 500;
}

form fieldset {
    border: 1px solid #eee;
    border-radius: 12px;
    padding: 10px 14px 14px;
    margin-bottom: 14px;
}

form legend {
    font-size: 14px;
    font-weight: 600;
    padding: 0 4px;
}

/* =========================
   КАТАЛОГ + ФИЛЬТРЫ
   ========================= */
/*
   Каталог/Акции: фильтры открываются как fixed-панель.
   Сам layout не должен быть grid, иначе при автоплейсменте
   элементы могли «уезжать» в узкую колонку и стягивать сетку карточек.
*/
.catalog-layout{
    position: relative;
    width: 100%;
}

.filter-toggle {
    border: none;
    padding: 8px 16px;
    border-radius: 999px;
    background: linear-gradient(135deg, #ff8a00, #e52e71);
    color: #fff;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
    cursor: pointer;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.filter-toggle:hover {
    background: linear-gradient(135deg, #ffa733, #ff4f88);
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(0,0,0,0.2);
    opacity: 0.98;
}

.filter-panel {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    background: #ffffff;
    box-shadow: 4px 0 16px rgba(0,0,0,0.15);
    padding: 20px;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.filter-panel.open {
    transform: translateX(0);
}

.filter-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.filter-panel-header h3 {
    margin: 0;
    font-size: 18px;
}

.filter-close {
    background: transparent !important;
    color: #555 !important;
    border: none !important;
    box-shadow: none !important;
    padding: 4px;
    border-radius: 999px;
    cursor: pointer;
    font-size: 18px;
    transition: background 0.15s ease, color 0.15s ease, opacity 0.15s ease;
}

.filter-close:hover {
    background: #f0f0f0;
    color: #222 !important;
    transform: none !important;
    box-shadow: none !important;
    opacity: 0.9;
}

.filter-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.25);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease;
    z-index: 900;
}

.filter-overlay.open {
    opacity: 1;
    visibility: visible;
}

.filter-form {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.filter-block label,
.filter-block-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 6px;
    display: block;
}

.filter-block input[type="text"] {
    width: 100%;
    padding: 8px;
    border-radius: 8px;
    border: 1px solid #ccc;
}

.filter-checkbox-list {
    max-height: 260px;
    overflow-y: auto;
    padding-right: 4px;
}

.filter-checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    margin-bottom: 4px;
}

.filter-checkbox-item input[type="checkbox"] {
    transform: scale(1.1);
}

.filter-actions {
    margin-top: auto;
    display: flex;
    gap: 10px;
}

.catalog-content {
    width: 100%;
    max-width: none;
}

.search-bar form {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.search-bar input[type="text"] {
    flex: 1;
    padding: 8px 10px;
    border-radius: 999px;
    border: 1px solid #ccc;
    background: #fff;
}

/* =========================
   КОМПАКТНЫЙ ТУЛБАР КАТАЛОГА (ФИЛЬТР + ПОИСК)
   ========================= */

.catalog-toolbar{
    display: flex;
    /* stretch даёт одинаковую "линию верха" у кнопки фильтра и поля */
    align-items: stretch;
    gap: 12px;
    width: 100%;
    margin-bottom: 14px;
}

.filter-toggle--toolbar{
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 14px;
    background: #fff;
    color: #ff8a00;
    border: 1px solid rgba(0,0,0,0.10);
    box-shadow: 0 6px 16px rgba(0,0,0,0.08);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.filter-toggle--toolbar:hover{
    transform: none;
    box-shadow: 0 8px 20px rgba(0,0,0,0.10);
    background: #fff;
    opacity: 1;
}

.search-form-compact{
    flex: 1 1 auto;
    margin: 0;
    min-width: 0;
}

.search-form-compact .search-inline{
    display: flex;
    align-items: center;
    width: 100%;
}

.search-wrapper--with-btn{
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
}

/* переопределяем общий max-width:400px для инпутов */
.search-wrapper--with-btn input[name="q"]{
    width: 100%;
    max-width: none;
    height: 44px;
    padding: 10px 52px 10px 14px;
    border-radius: 14px;
}

/* лупа внутри поля */
.search-inset-btn{
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 38px;
    height: 38px;
    border-radius: 12px;
    border: 1px solid rgba(255,138,0,0.28);
    background: rgba(255,138,0,0.14);
    color: #ff6a00;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    box-shadow: 0 6px 14px rgba(0,0,0,0.08);
}

.search-inset-btn:hover{
    background: rgba(255,138,0,0.18);
    box-shadow: 0 8px 18px rgba(0,0,0,0.10);
}

.search-inset-btn:active{
    background: rgba(255,138,0,0.22);
}

/* Иконка поиска внутри кнопки (лупа). Не прячем SVG — просто форсим цвет. */
.search-inset-btn svg{ display: block; }
.search-inset-btn svg *{
    stroke: currentColor !important;
    fill: none !important;
}

/* =========================
   КАРТОЧКИ КНИГ
   ========================= */
.products{
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 20px;
}

@media (max-width: 1400px){
    .products{ grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 1100px){
    .products{ grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

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


.product-card {
    background: #fff;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 6px 16px rgba(0,0,0,0.08);
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.product-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 22px rgba(0,0,0,0.15);
}

.product-link {
    display: block;
    color: inherit;
    text-decoration: none;
}

/* Единая версия (без дублей): вертикальная обложка целиком, без обрезки */
.product-image {
    width: 100%;
    aspect-ratio: 3 / 4;
    overflow: hidden;
    border-radius: 16px 16px 0 0;
    background: #f3f3f7;
    display: flex;
    align-items: center;
    justify-content: center;
}

.product-image img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
}

.no-image {
    width: 100%;
    aspect-ratio: 3 / 4;
    background: linear-gradient(135deg, #e0e0e0, #f5f5f5);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 14px;
}

.product-info {
    padding: 12px 14px 14px;
}

.product-title {
    font-size: 16px;
    margin: 0 0 4px;
}

.author {
    color: #666;
    font-size: 14px;
    margin: 0 0 8px;
}

.price {
    margin: 0;
    font-size: 15px;
}

.old-price {
    text-decoration: line-through;
    color: #999;
    margin-right: 6px;
}

.new-price {
    color: #e53935;
    font-weight: 600;
}

/* =========================
   КОРЗИНА / ТАБЛИЦЫ
   ========================= */
.cart-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

.cart-table th,
.cart-table td {
    border: 1px solid #ddd;
    padding: 8px;
}

/* =========================
   ЛИЧНЫЙ КАБИНЕТ / ИСТОРИЯ ЗАКАЗОВ
   ========================= */
.account-layout {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px;
    align-items: flex-start;
}

.account-left,
.account-right {
    min-width: 0;
}

.account-title {
    margin: 0 0 12px;
    font-size: 22px;
    font-weight: 700;
}

.orders-card {
    background: #fff;
    padding: 16px 18px 18px;
    border-radius: 16px;
    box-shadow: 0 6px 18px rgba(0,0,0,0.08);
}

.orders-card h3 {
    margin-top: 0;
    margin-bottom: 10px;
}

.orders-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.order-item {
    border-radius: 12px;
    border: 1px solid #eee;
    overflow: hidden;
    background: #fafafa;
}

.order-summary {
    width: 100%;
    text-align: left;
    background: transparent;
    box-shadow: none;
    border-radius: 0;
    padding: 10px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.order-summary-left {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.order-id {
    font-weight: 600;
    font-size: 14px;
}

.order-date {
    font-size: 12px;
    color: #777;
}

.order-summary-right {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

@media (max-width: 520px){
    .order-summary{
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    .order-summary-right{
        width: 100%;
        flex-wrap: wrap;
        justify-content: flex-start;
        gap: 6px;
    }
}

.order-meta {
    color: #555;
}

.order-status {
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
}

.order-status-new { background: #fff3cd; color: #856404; }
.order-status-processing { background: #d1ecf1; color: #0c5460; }
.order-status-done { background: #d4edda; color: #155724; }
.order-status-canceled { background: #f8d7da; color: #721c24; }

.order-arrow {
    font-size: 12px;
    color: #555;
}

.order-details {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease;
    padding: 0 12px;
}

.order-details.open {
    max-height: 400px;
    padding-bottom: 10px;
}

@media (max-width: 820px){
    .order-details.open{ max-height: 900px; }
}

.orders-empty {
    font-size: 14px;
    color: #777;
}

/* =========================
   УВЕДОМЛЕНИЯ / ПОИСК ПОДСКАЗКИ
   ========================= */
.search-wrapper {
    position: relative;
}

.search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #ffffff;
    border-radius: 0 0 12px 12px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.08);
    z-index: 50;
    max-height: 260px;
    overflow-y: auto;
    display: none;
}

.search-suggestion-item {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 14px;
}

.search-suggestion-item:hover {
    background: #fff3e0;
}

.search-suggestion-title {
    font-weight: 500;
}

.search-suggestion-author {
    font-size: 12px;
    color: #777;
}

.messages-wrapper {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.alert {
    min-width: 260px;
    max-width: 360px;
    padding: 10px 14px;
    border-radius: 12px;
    box-shadow: 0 4px 14px rgba(0,0,0,0.12);
    font-size: 14px;
    line-height: 1.4;
}

.alert-success { background: #e8f5e9; border-left: 4px solid #4caf50; color: #1b5e20; }
.alert-info { background: #e3f2fd; border-left: 4px solid #2196f3; color: #0d47a1; }
.alert-warning { background: #fff8e1; border-left: 4px solid #ffb300; color: #e65100; }
.alert-error, .alert-danger { background: #ffebee; border-left: 4px solid #f44336; color: #b71c1c; }

@media (max-width: 600px){
    .messages-wrapper{
        right: 12px;
        left: 12px;
        top: 72px;
    }
    .alert{
        min-width: 0;
        max-width: none;
    }
}

/* =========================
   ДЕТАЛЬНАЯ СТРАНИЦА КНИГИ (ПОЧИЩЕНО)
   ========================= */

:root{
    --price-card-bg: linear-gradient(135deg, #ffffff, #f7f7ff);
    --price-card-shadow: 0 6px 18px rgba(15, 35, 95, 0.08);
}

/* Общая карточка */
.book-detail-card {
    display: flex;
    gap: 40px;
    align-items: stretch;
    background: #fff;
    border-radius: 16px;
    padding: 20px 24px;
    box-shadow: 0 6px 18px rgba(0,0,0,0.08);
}

/* Левая колонка */
.book-detail-left {
    flex: 0 0 420px;
    max-width: 420px;
    display: flex;
    justify-content: flex-start;
    align-items: flex-start;
}

.book-detail-image {
    width: 100%;
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
}

.book-detail-image img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 12px 30px rgba(0,0,0,0.18);
}

.no-image-book {
    width: 100%;
    height: auto;
    max-height: 85vh;
    border-radius: 12px;
    box-shadow: 0 12px 30px rgba(0,0,0,0.18);
    background: linear-gradient(135deg, #e0e0e0, #f5f5f5);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 14px;
    aspect-ratio: 3 / 4;
}

/* Правая колонка */
.book-detail-right {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.book-detail-title {
    margin: 0;
    font-size: 28px;
    font-weight: 700;
    max-width: 620px; /* как у тебя было */
}

.book-detail-author {
    margin: 0;
    font-size: 16px;
    color: #777;
    max-width: 620px;
}

/* Две колонки справа: панели слева, "О книге" справа */
.book-detail-right-grid{
    display: grid;
    grid-template-columns: 360px minmax(0, 1fr);
    gap: 24px;
    align-items: start;
    margin-top: 10px;
    width: 100%;
    min-width: 0;
}

.book-side-panels{
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 0;
}

/* Карточка цены */
.book-price-block {
    flex: 0 0 auto;
    min-width: 220px;
    max-width: 320px;

    padding: 10px 14px;
    border-radius: 14px;
    background: var(--price-card-bg);
    box-shadow: var(--price-card-shadow);

    display: flex;
    flex-direction: column;
    gap: 6px;
}

.price-row {
    display: block;
    margin-bottom: 6px;
}

.price-label {
    font-size: 14px;
    font-weight: 600;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.price-current,
.price-new {
    font-size: 24px;
    font-weight: 700;
    color: #ff6a3d;
}

.price-old {
    font-size: 16px;
    text-decoration: line-through;
    color: #b5b5b5;
}

.price-note {
    font-size: 13px;
    color: #888;
}

.stock-row {
    display: block;
    margin-top: 4px;
}

.stock-pill {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 13px;
}

.stock-ok { background: rgba(76, 175, 80, 0.08); color: #2e7d32; }
.stock-bad { background: rgba(244, 67, 54, 0.08); color: #c62828; }

/* Карточка количества/кнопки */
.book-actions-panel {
    flex: 0 0 auto;
    min-width: 240px;
    max-width: 320px;

    padding: 10px 14px;
    border-radius: 14px;
    background: var(--price-card-bg);
    box-shadow: var(--price-card-shadow);

    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
}

.book-detail-qty {
    font-size: 14px;
    color: #555;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.qty-control {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    background: #f0f1f7;
    padding: 3px;
}

.qty-btn {
    border: none;
    background: #ffffff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;

    display: flex;
    align-items: center;
    justify-content: center;

    color: #555;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
}

.qty-btn:hover {
    background: #f7f7fb;
}

.qty-input {
    width: 56px;
    border: none;
    text-align: center;
    font-size: 16px;
    background: transparent;
    outline: none;
}

.book-buy-btn {
    align-self: flex-start;
    margin-top: 4px;
}

/* Блок "О книге" */
.book-description-card {
    padding: 18px 20px;
    border-radius: 18px;
    background: var(--price-card-bg);
    box-shadow: var(--price-card-shadow);
    box-sizing: border-box;
    max-width: 100%;
}

.book-description-card--wide{
    margin-top: 0;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    justify-self: stretch;
}

.section-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 10px;
}

.book-description {
    white-space: pre-wrap;
    font-size: 14px;
    line-height: 1.6;
    color: #444;
    margin: 0;
}

/* =========================
   АДАПТИВ
   ========================= */
@media (max-width: 900px) {
    .account-layout {
        grid-template-columns: 1fr;
    }

    .book-detail-right-grid{
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    main {
        padding: 15px;
    }

    /* .catalog-layout теперь block — ничего переопределять не нужно */

    .filter-toggle {
        margin-bottom: 10px;
    }

    .book-detail-card {
        flex-direction: column;
        padding: 16px 18px;
        gap: 20px;
    }

    .book-detail-left{
        flex: 0 0 auto;
        max-width: none;
    }
}

@media (max-width: 600px) {
    /* .catalog-layout теперь block — без gap */

    .catalog-toolbar{
        gap: 8px;
        margin-bottom: 10px;
    }

    /* Тулбар на мобильном: одна строка, равная высота элементов */
    .catalog-toolbar{ align-items: stretch; }

    .catalog-toolbar .filter-toggle--toolbar{
        width: 44px;
        height: 44px;
        padding: 0;
        border-radius: 14px;
        background: #fff;
        color: #ff8a00;
        border: 1px solid rgba(255,138,0,0.28);
        box-shadow: 0 6px 16px rgba(0,0,0,0.08);
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 0;
        line-height: 1;
        flex: 0 0 44px;
        /* визуально выравниваем по top-edge с инпутом */
        transform: translateY(1px);
    }

    .catalog-toolbar .filter-toggle--toolbar:hover{ transform: translateY(1px); }

    /* гарантируем, что svg не смещается и берёт currentColor */
    .catalog-toolbar .filter-toggle--toolbar svg{ display:block; }
.catalog-toolbar .filter-toggle--toolbar .filter-text{
        font-size: 13px;
        white-space: nowrap;
    }

    .search-wrapper--with-btn input[name="q"]{
        height: 44px;
        padding: 10px 44px 10px 12px;
    }

    .search-inset-btn{ width: 34px; height: 34px; }
    .search-inset-btn svg{ width: 16px; height: 16px; }

    /* Поиск в одну строку: инпут занимает всё */
    .search-form-inline .search-inline{
        flex-direction: row;
        align-items: center;
        gap: 8px;
    }

    .search-form-compact input[name="q"]{
        border-radius: 14px;
    }

    /* search bar: stack input + button */
    .search-bar .search-wrapper{
        width: 100%;
        flex: 1 1 auto;
    }
    .products{
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
    }
    .product-info{ padding: 10px 12px 12px; }
    .product-title{ font-size: 14px; }
    .product-info .author{ font-size: 13px; }
}

@media (max-width: 420px){
    .products{ grid-template-columns: 1fr; }
}

.book-extra-card{
    margin-top: 18px;
    background: #fff;
    border-radius: 16px;
    padding: 18px 24px;
    box-shadow: 0 6px 18px rgba(0,0,0,0.08);
}

.book-extra-grid{
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    align-items: start;
}

.book-extra-block{
    border-radius: 14px;
    background: linear-gradient(135deg, #ffffff, #f7f7ff);
    box-shadow: 0 6px 18px rgba(15, 35, 95, 0.08);
    padding: 14px 16px;
    min-width: 0;
}

.book-pretext{
    white-space: pre-wrap;   /* сохраняет переносы строк и пробелы */
    font-size: 14px;
    line-height: 1.6;
    color: #444;
}

.muted{
    color: #777;
    margin: 0;
}

.book-specs{
    margin: 0;
    display: grid;
    gap: 10px;
}

.book-specs div{
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 10px;
}

.book-specs dt{
    color: #777;
    font-weight: 600;
}

.book-specs dd{
    margin: 0;
    color: #222;
}

.author-box{
    display: grid;
    grid-template-columns: 72px 1fr;
    gap: 12px;
    align-items: start;
}

.author-photo{
    width: 72px;
    height: 72px;
    border-radius: 14px;
    object-fit: cover;
    box-shadow: 0 6px 14px rgba(0,0,0,0.12);
}

.author-name{
    font-weight: 700;
    margin-bottom: 6px;
}

@media (max-width: 1100px){
    .book-extra-grid{ grid-template-columns: 1fr; }
}

/* ========== Карточки: текст, бейджи, цена ========== */
.product-info .author{
  margin: 6px 0 10px;
  color: rgba(255,255,255,0.72);
  font-size: 14px;
  line-height: 1.35;
}

.card-meta{
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.pill{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1;
  font-weight: 600;
  user-select: none;
}

.pill-ok{
  background: rgba(76,175,80,0.14);
  color: #d7ffd9;
  border: 1px solid rgba(76,175,80,0.22);
}

.pill-bad{
  background: rgba(244,67,54,0.14);
  color: #ffe2df;
  border: 1px solid rgba(244,67,54,0.22);
}

.pill-sale{
  background: rgba(255,106,61,0.16);
  color: #ffe7de;
  border: 1px solid rgba(255,106,61,0.24);
}

.pill-muted{
  background: rgba(255,255,255,0.10);
  color: rgba(255,255,255,0.80);
  border: 1px solid rgba(255,255,255,0.16);
}

.card-price{
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-top: 2px;
}

.price-current,
.price-new{
  font-size: 18px;
  font-weight: 800;
  color: #ff6a3d;
}

.price-old{
  font-size: 13px;
  color: rgba(255,255,255,0.55);
  text-decoration: line-through;
}

.card-subtext{
  margin-top: 6px;
  font-size: 12px;
  color: rgba(255,255,255,0.60);
}

/* ========== Поиск: обёртка + выпадающие подсказки ========== */
.search-wrapper{
  position: relative;
  flex: 1;
  min-width: 220px;
}

.search-bar form{
  display: flex;
  gap: 10px;
  align-items: center;
}

.search-bar input[type="text"]{
  width: 100%;
}

.search-suggestions.open{
  display: block;
}

.search-suggestions a{
  display: block;
  padding: 10px 12px;
  color: rgba(255,255,255,0.88);
  text-decoration: none;
  font-size: 14px;
  line-height: 1.25;
}

.search-suggestions a:hover{
  background: rgba(255,255,255,0.06);
}

/* ========== Фильтр: select/checkbox под стиль ========== */
.filter-form select{
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.92);
  outline: none;
}

.filter-form select:focus{
  border-color: rgba(255,106,61,0.55);
}

.filter-form option{
  color: #111; /* чтобы в выпадающем списке был читаемый текст */
}

.filter-checkbox-item{
  display: flex;
  align-items: center;
  gap: 10px;
}

.filter-checkbox-item input[type="checkbox"]{
  width: 18px;
  height: 18px;
  accent-color: #ff6a3d; /* современно и просто */
}

/* ===== FIX: читаемость на светлых карточках ===== */
.product-card,
.product-card *{
  color: inherit;
}

.product-info{
  color: #111827; /* базовый текст тёмный */
}

.product-title{
  color: #111827;
}

.product-info .author{
  margin: 6px 0 10px;
  color: #6b7280;  /* серый, читаемый на белом */
  font-size: 14px;
  line-height: 1.35;
}

/* ===== FIX: pills (зелёный/красный/акция) ===== */
.pill{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1;
  font-weight: 700;
  user-select: none;
}

.pill-ok{
  background: #E8F5E9;
  border: 1px solid #C8E6C9;
  color: #1B5E20; /* тёмно-зелёный текст, видно всегда */
}

.pill-bad{
  background: #FFEBEE;
  border: 1px solid #FFCDD2;
  color: #B71C1C;
}

.pill-sale{
  background: #FFF3E0;
  border: 1px solid #FFE0B2;
  color: #E65100;
}

.pill-muted{
  background: #F3F4F6;
  border: 1px solid #E5E7EB;
  color: #374151;
}

/* ===== Cart ===== */
.cart-page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 18px 16px 40px;
}

.cart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.page-title {
  margin: 0;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.cart-card {
  background: rgba(255, 255, 255, 0.86);
  border-radius: 22px;
  box-shadow: 0 14px 34px rgba(0,0,0,0.08);
  overflow: hidden;
}

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

.cart-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 920px;
}

.cart-table thead th {
  text-align: left;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(0,0,0,0.55);
  padding: 14px 16px;
  background: rgba(0,0,0,0.03);
}

.cart-table tbody td {
  padding: 14px 16px;
  border-top: 1px solid rgba(0,0,0,0.06);
  vertical-align: middle;
}

.cart-muted {
  color: rgba(0,0,0,0.55);
}

.cart-book {
  display: flex;
  align-items: center;
  gap: 12px;
}

.cart-book-thumb {
  width: 56px;
  height: 76px;
  border-radius: 14px;
  overflow: hidden;
  display: block;
  flex: 0 0 auto;
  background: rgba(0,0,0,0.04);
  box-shadow: 0 10px 22px rgba(0,0,0,0.10);
}

.cart-book-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cart-book-thumb-placeholder {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  font-size: 12px;
  color: rgba(0,0,0,0.45);
}

.cart-book-title {
  display: inline-block;
  font-weight: 800;
  color: rgba(0,0,0,0.88);
  text-decoration: none;
}

.cart-book-title:hover {
  text-decoration: underline;
}

.cart-book-sub {
  margin-top: 3px;
  font-size: 13px;
  color: rgba(0,0,0,0.55);
}

.cart-price, .cart-sum {
  font-weight: 800;
}

.cart-qty {
  display: inline-flex;
  min-width: 44px;
  height: 34px;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,0.10);
  background: rgba(255,255,255,0.75);
  font-weight: 800;
}

.cart-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px;
  border-top: 1px solid rgba(0,0,0,0.06);
  background: rgba(255,255,255,0.65);
}

.cart-total {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.cart-total-label {
  font-size: 13px;
  color: rgba(0,0,0,0.55);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.cart-total-value {
  font-size: 22px;
  font-weight: 900;
}

.cart-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cart-auth-hint {
  color: rgba(0,0,0,0.68);
  font-size: 14px;
}

.cart-auth-hint a {
  color: rgba(0,0,0,0.88);
  font-weight: 800;
  text-decoration: none;
}

.cart-auth-hint a:hover {
  text-decoration: underline;
}

/* кнопка удаления (в стиле сайта) */
.btn-danger {
  border: none;
  border-radius: 999px;
  padding: 10px 14px;
  font-weight: 800;
  cursor: pointer;
  background: linear-gradient(135deg, #ff4d4d, #ff8a00);
  color: #fff;
  box-shadow: 0 10px 22px rgba(255, 77, 77, 0.22);
  transition: transform .15s ease, box-shadow .15s ease, filter .15s ease;
}

.btn-danger:hover {
  transform: translateY(-1px);
  filter: brightness(1.02);
  box-shadow: 0 14px 28px rgba(255, 77, 77, 0.28);
}

.btn-small {
  padding: 8px 12px;
  font-size: 13px;
}

/* пустая корзина */
.cart-empty {
  display: grid;
  place-items: center;
  padding: 28px 0;
}

.cart-empty-card {
  width: min(640px, 100%);
  background: rgba(255,255,255,0.86);
  border-radius: 22px;
  box-shadow: 0 14px 34px rgba(0,0,0,0.08);
  padding: 22px;
  text-align: center;
}

.cart-empty-title {
  font-size: 20px;
  font-weight: 900;
  margin-bottom: 8px;
}

.cart-empty-sub {
  color: rgba(0,0,0,0.62);
  margin-bottom: 14px;
}

/* адаптив */
@media (max-width: 820px) {
  .cart-footer {
    flex-direction: column;
    align-items: stretch;
  }
  .cart-actions {
    justify-content: flex-end;
  }

  /* tables -> stacked cards */
  .cart-table-wrap{ overflow: visible; }
  .cart-table{ min-width: 0; }
  .cart-table thead{ display: none; }
  .cart-table, .cart-table tbody, .cart-table tr, .cart-table td{ display: block; width: 100%; }
  .cart-table tr{
    padding: 12px 14px;
    border-top: 1px solid rgba(0,0,0,0.06);
  }
  .cart-table tbody td{
    border: none;
    padding: 8px 0;
    display: flex;
    justify-content: space-between;
    gap: 12px;
  }
  .cart-table tbody td::before{
    content: attr(data-label);
    font-weight: 800;
    color: rgba(0,0,0,0.55);
    min-width: 92px;
  }

  /* first column in cart has its own layout */
  .cart-table td.col-book{ padding-top: 4px; }
  .cart-table td.col-book::before{ display: none; }
  .cart-table td.col-author{ display: none; }

  .cart-table td.col-actions{
    display: flex;
    justify-content: flex-end;
  }
  .cart-table td.col-actions::before{ display: none; }
}

.search-wrapper{
  position: relative;
}

.search-suggestions{
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: rgba(255,255,255,0.96);
  border: 1px solid rgba(0,0,0,0.10);
  border-radius: 16px;
  box-shadow: 0 18px 40px rgba(0,0,0,0.12);
  overflow: hidden;
  z-index: 50;
  display: none;
}

.search-suggestions.open{
  display: block;
}

.search-suggestion-item{
  padding: 10px 12px;
  cursor: pointer;
  color: rgba(0,0,0,0.88);
  background: transparent;
}

.search-suggestion-item:hover{
  background: rgba(0,0,0,0.05);
}

.search-suggestion-title{
  font-weight: 800;
  font-size: 14px;
  line-height: 1.2;
}

.search-suggestion-sub{
  font-size: 12px;
  color: rgba(0,0,0,0.55);
  margin-top: 2px;
}

/* Кнопка рядом с поиском (стиль btn-primary не трогаем) */
.search-form-inline .search-inline{
  display: flex;
  align-items: center;
  gap: 12px;
}

.search-form-inline .search-wrapper{
  flex: 1;
  position: relative;
}


/* Кнопка рядом с поиском (стиль btn-primary не трогаем) */
.search-form-inline .search-inline{
  display: flex;
  align-items: center;
  gap: 12px;
}

.search-form-inline .search-wrapper{
  flex: 1;
  position: relative;
}

/* ВАЖНО: если раньше кнопке задавали position/float — сбрасываем, чтобы не улетала вправо */
.search-form-inline .btn-primary{
  flex: 0 0 auto;
  position: static;
  float: none;
  margin: 0;
}

/* Только длина поиска (x1.5), без изменения высоты */
.search-bar form{
  display: flex;
  align-items: center;
  gap: 12px;
}

.search-bar .search-wrapper{
  width: clamp(260px, 60vw, 600px);
  flex: 0 1 clamp(260px, 60vw, 600px);
}

/* снять общий лимит max-width:400px именно для поиска */
.search-bar input[name="q"]{
  width: 100%;
  max-width: none;
}

/* ===== Compact Header epBook ===== */
.site-header{
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255,255,255,0.86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(0,0,0,0.06);
  justify-content: space-between;
}

.header-inner{
  max-width: none;
  width: 100%;
  margin: 0;
  padding: 8px 14px;            /* ВАЖНО: высота шапки */
  display: flex;
  align-items: center;
  justify-content: space-between; /* слева/справа */
  gap: 12px;
}

/* Левая группа: лого + ссылки */
.header-left{
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.brand{
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  font-weight: 900;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.brand-mark{
  width: 32px;                  /* меньше */
  height: 32px;                 /* меньше */
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #ff8a00, #ff4d4d);
  color: #fff;
  font-size: 16px;
  box-shadow: 0 10px 18px rgba(255,77,77,0.16);
}

.brand-name{
  font-size: 20px;              /* базовое значение, десктоп увеличим ниже */
  color: rgba(0,0,0,0.88);
}

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

.nav-toggle{
  display: none;
  border: 0;
  background: rgba(0,0,0,0.05);
  border: 1px solid rgba(0,0,0,0.08);
  color: rgba(0,0,0,0.86);
  width: 38px;
  height: 38px;
  border-radius: 14px;
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
}

.nav-toggle:hover{ background: rgba(0,0,0,0.07); }

.nav-link{
  text-decoration: none;
  font-weight: 800;
  font-size: 13px;              /* базовое значение, десктоп увеличим ниже */
  color: rgba(0,0,0,0.70);
  padding: 6px 10px;            /* меньше */
  border-radius: 12px;
  transition: background .15s ease, color .15s ease;
}

/* Десктоп: делаем бренд и пункты меню заметнее */
@media (min-width: 821px){
  .brand-mark{ width: 36px; height: 36px; font-size: 18px; }
  .brand-name{ font-size: 24px; }
  .nav-link{ font-size: 15px; padding: 8px 12px; }
}

.nav-link:hover{
  background: rgba(0,0,0,0.05);
  color: rgba(0,0,0,0.88);
}

.nav-link.is-active{
  background: rgba(255,106,61,0.14);
  border: 1px solid rgba(255,106,61,0.22);
  color: rgba(0,0,0,0.90);
}

/* Правая группа: корзина + кабинет */
.header-actions{
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.header-btn{
  text-decoration: none;
  font-weight: 900;
  font-size: 13px;
  padding: 7px 12px;            /* меньше */
  border-radius: 999px;
  transition: transform .15s ease, box-shadow .15s ease, filter .15s ease, background .15s ease;
}

.header-btn-ghost{
  background: rgba(0,0,0,0.05);
  color: rgba(0,0,0,0.86);
}

.header-btn-ghost:hover{
  background: rgba(0,0,0,0.07);
}

.header-btn-solid{
  background: linear-gradient(135deg, #ff8a00, #ff4d4d);
  color: #fff;
  box-shadow: 0 10px 18px rgba(255,77,77,0.16);
}

.header-btn-solid:hover{
  filter: brightness(1.03);
}

/* Мобилка: прячем ссылки, оставляем логотип и кнопки */
@media (max-width: 820px){
  .nav-links{ display:none; }
  .nav-toggle{ display:inline-flex; align-items:center; justify-content:center; }
}

@media (max-width: 420px){
  .brand-name{ font-size: 18px; }
  .header-inner{ padding: 8px 10px; }
  .header-btn{ padding: 7px 10px; font-size: 12px; }
  .cart-badge{ min-width: 18px; height: 18px; font-size: 11px; }
  .nav-toggle{ width: 36px; height: 36px; }
  .mobile-nav{ top: 66px; }
}

/* Мобильное меню */
.mobile-nav-overlay{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.25);
  opacity: 0;
  visibility: hidden;
  transition: opacity .2s ease;
  z-index: 95;
}

.mobile-nav{
  position: fixed;
  left: 12px;
  right: 12px;
  top: 72px;
  background: rgba(255,255,255,0.96);
  border: 1px solid rgba(0,0,0,0.10);
  border-radius: 18px;
  box-shadow: 0 18px 40px rgba(0,0,0,0.12);
  padding: 10px;
  display: none;
  z-index: 100;
}

.mobile-nav.open{ display: block; }
.mobile-nav-overlay.open{ opacity: 1; visibility: visible; }

.mobile-nav-link{
  display: block;
  padding: 12px 12px;
  border-radius: 14px;
  text-decoration: none;
  font-weight: 900;
  color: rgba(0,0,0,0.86);
}

.mobile-nav-link:hover{ background: rgba(0,0,0,0.05); }
.mobile-nav-link.is-active{
  background: rgba(255,106,61,0.14);
  border: 1px solid rgba(255,106,61,0.22);
}

@media (min-width: 821px){
  .mobile-nav, .mobile-nav-overlay{ display: none !important; }
}

body{
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: geometricPrecision;
}

.header-cart{
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.cart-badge{
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  color: #fff;
  background: linear-gradient(135deg, #ff8a00, #ff4d4d);
  box-shadow: 0 8px 16px rgba(255,77,77,0.18);
}

.header-btn-ghost{
  background: rgba(0,0,0,0.05);
  border: 1px solid rgba(0,0,0,0.08);
  color: rgba(0,0,0,0.86);
}

/* (удалён устаревший блок стилей для .header/.logo, который ломал CSS) */
.header-btn-icon{width:40px;height:36px;padding:0;border-radius:14px;display:inline-flex;align-items:center;justify-content:center;}
.header-btn-icon svg{display:block;}

/* Было: на <=420px делали 1 колонку — из-за этого на телефоне по одной книге */
@media (max-width: 420px){
  .products{
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  .product-title{ font-size: 13px; }
  .product-info .author{ font-size: 12px; }
}

/* Если совсем узкие экраны — тогда уже 1 колонка */
@media (max-width: 340px){
  .products{ grid-template-columns: 1fr; }
}