/* css/catalog.css — стили каталога. Путь: css/catalog.css */

/* ============================================================
   ЗАГОЛОВОК КАТАЛОГА
   ============================================================ */
.catalog-header{
    text-align:center;
    padding:30px 0 20px;
}
.catalog-header h1{margin-bottom:0}

/* ============================================================
   ПОИСК (обычный — для других страниц)
   ============================================================ */
.search-form{
    display:flex;
    gap:10px;
    max-width:520px;
    margin:0 auto 20px;
    align-items:center;
}
.search-form input{
    flex:1;
    height:48px;
    padding:0 18px;
    border:1px solid #eae6e1;
    border-radius:50px;
    font-size:15px;
    font-family:inherit;
    background:var(--card);
    outline:none;
    transition:.2s;
    box-sizing:border-box;
}
.search-form input:focus{border-color:var(--accent)}
.search-form button{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    height:48px;
    padding:0 26px;
    background:var(--accent);
    color:#fff;
    border:none;
    border-radius:50px;
    cursor:pointer;
    font-weight:600;
    font-family:inherit;
    font-size:15px;
    transition:.2s;
    white-space:nowrap;
    box-sizing:border-box;
}
.search-form button:hover{background:var(--accent-dark)}

/* ============================================================
   ССЫЛКИ КАТЕГОРИЙ
   ============================================================ */
.category-links{
    display:flex;
    flex-wrap:wrap;
    gap:10px;
    justify-content:center;
    margin:30px 0;
}
.category-links a{
    background:var(--card);
    color:var(--ink);
    padding:9px 18px;
    border-radius:50px;
    font-size:14px;
    border:1px solid #eae6e1;
    transition:.2s;
}
.category-links a:hover,
.category-links a.active{
    background:var(--accent);
    color:#fff;
    border-color:var(--accent);
}

/* ============================================================
   СЧЁТЧИК
   ============================================================ */
.catalog-count{
    color:var(--muted);
    text-align:center;
    margin:20px 0;
    font-size:14px;
}

/* ============================================================
   STICKY-ПОИСК + ПЕРЕКЛЮЧАТЕЛЬ
   Фон — как у страницы (var(--bg)), без тени и полосы.
   ============================================================ */
.catalog-sticky-search {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg, #f5f1eb);   /* фон страницы, а не прозрачный */
    padding: 12px 0;
    margin: 0 0 24px;
    border-bottom: none;
    box-shadow: none;
}
.catalog-sticky-inner {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    box-sizing: border-box;
}
.search-form--sticky {
    flex: 1 1 auto;
    display: flex;
    gap: 8px;
    margin: 0;
    min-width: 0;
    max-width: none;
}
.search-form--sticky input {
    flex: 1 1 auto;
    min-width: 0;
    height: 48px;
    padding: 0 20px;
    font-size: 15px;
    font-family: inherit;
    border: 1px solid #eae6e1;
    border-radius: 50px;
    background: #fff;
    color: var(--ink);
    outline: none;
    transition: border-color .2s, box-shadow .2s;
    box-sizing: border-box;
}
.search-form--sticky input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.search-form--sticky button {
    flex: 0 0 48px;
    width: 48px;
    height: 48px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: background .15s;
}
.search-form--sticky button:hover { background: var(--accent-dark); }
.search-form--sticky button svg { display: block; }

/* ============================================================
   ПЕРЕКЛЮЧАТЕЛЬ ВИДА
   ============================================================ */
.view-switch {
    display: inline-flex;
    flex: 0 0 auto;
    background: #f0f3f1;
    border-radius: 10px;
    padding: 3px;
    gap: 2px;
    border: 1px solid #eae6e1;
}
.view-switch__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border: none;
    background: transparent;
    color: #6b7a74;
    cursor: pointer;
    border-radius: 7px;
    transition: background .15s, color .15s;
    padding: 0;
}
.view-switch__btn:hover { color: #2e7d5b; }
.view-switch__btn.is-active {
    background: #fff;
    color: #2e7d5b;
    box-shadow: 0 1px 3px rgba(0,0,0,.08);
}

/* ============================================================
   ТЕЛО КАТАЛОГА + АЛФАВИТ
   ============================================================ */
.catalog-body {
    position: relative;
}
.catalog-main { min-width: 0; }

.book-card-wrap { display: contents; }

.catalog-alpha {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    position: fixed;
    top: 50%;
    right: 8px;
    transform: translateY(-50%);
    z-index: 40;
    padding: 8px 4px;
    background: rgba(255,255,255,.94);
    border: 1px solid #eae6e1;
    border-radius: 24px;
    box-shadow: 0 4px 12px rgba(0,0,0,.06);
    max-height: 80vh;
    overflow-y: auto;
}
.catalog-alpha a {
    display: block;
    width: 24px;
    height: 24px;
    line-height: 24px;
    text-align: center;
    font-size: 13px;
    color: #6b7a74;
    text-decoration: none;
    border-radius: 50%;
    transition: background .15s, color .15s;
    font-weight: 600;
}
.catalog-alpha a:hover,
.catalog-alpha a.is-active {
    background: var(--accent);
    color: #fff;
}
.catalog-alpha__disabled {
    display: block;
    width: 24px;
    height: 24px;
    line-height: 24px;
    text-align: center;
    font-size: 13px;
    color: #d5d9d6;
    font-weight: 600;
}

.catalog-body.is-list .catalog-alpha { display: flex; }

/* ============================================================
   РЕЖИМ СПИСКА (десктоп)
   ============================================================ */
.books-grid.is-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.books-grid.is-list .book-card-wrap { display: block; }

.books-grid.is-list .book-card {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 20px;
    padding: 14px;
    background: var(--card);
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    align-items: flex-start;
    text-decoration: none;
    color: inherit;
}
.books-grid.is-list .book-card__cover {
    width: 120px;
    height: 160px;
    flex-shrink: 0;
    margin: 0;
}
.books-grid.is-list .book-card__cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
}
.books-grid.is-list .book-card__info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}
.books-grid.is-list .book-card .author {
    font-size: 14px;
    color: var(--muted);
    margin: 0 0 2px;
    font-weight: 600;
}
.books-grid.is-list .book-card h3 {
    font-size: 17px;
    margin: 0 0 6px;
    line-height: 1.3;
}
.books-grid.is-list .book-card .book-annonce {
    font-size: 14px;
    margin: 0 0 10px;
    color: var(--muted);
}
.books-grid.is-list .book-card .book-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
    padding-top: 8px;
    border-top: 1px solid #eae6e1;
}
.books-grid.is-list .book-card .price { font-size: 20px; }

/* ============================================================
   МОБИЛЬНЫЙ (≤ 860px)
   ============================================================ */
@media (max-width: 860px){
    .catalog-header{padding:20px 0 12px}
    .catalog-header h1{font-size:26px}

    .catalog-sticky-search {
        padding: 8px 0;
    }
    .catalog-sticky-inner {
        gap: 6px;
    }
    .search-form--sticky {
        gap: 4px;
    }
    .search-form--sticky input {
        height: 42px;
        font-size: 14px;
        padding: 0 14px;
    }
    .search-form--sticky button {
        flex: 0 0 42px;
        width: 42px;
        height: 42px;
    }
    .view-switch {
        padding: 2px;
    }
    .view-switch__btn {
        width: 38px;
        height: 38px;
        border-radius: 8px;
    }

    .catalog-alpha {
        right: 4px;
        padding: 6px 3px;
        gap: 0;
    }
    .catalog-alpha a,
    .catalog-alpha__disabled {
        width: 20px;
        height: 20px;
        line-height: 20px;
        font-size: 11px;
    }

    .books-grid.is-list .book-card {
        grid-template-columns: 84px 1fr;
        gap: 12px;
        padding: 10px;
    }
    .books-grid.is-list .book-card__cover {
        width: 84px;
        height: 112px;
    }
    .books-grid.is-list .book-card__info { gap: 2px; }
    .books-grid.is-list .book-card .author {
        font-size: 12.5px;
        margin-bottom: 2px;
    }
    .books-grid.is-list .book-card h3 {
        font-size: 15px;
        margin-bottom: 6px;
    }
    .books-grid.is-list .book-card .book-annonce { display: none; }
    .books-grid.is-list .book-card .book-meta { padding-top: 6px; }
    .books-grid.is-list .book-card .price { font-size: 17px; }
}

/* ============================================================
   АВТОПОДБОР: сетка книг
   ============================================================ */
.auto-test-grid {
    margin-top: 16px;
}

/* Кнопки как в каталоге-таблице */
.auto-test-grid .book-card {
    background: var(--card);
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.auto-test-grid .book-card__cover {
    width: 100%;
    aspect-ratio: 3 / 4;
    overflow: hidden;
    border-radius: 10px;
    background: #f5f7f6;
}
.auto-test-grid .book-card__cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.auto-test-grid .book-card__info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}
.auto-test-grid .book-card .author {
    font-size: 13px;
    color: var(--muted);
    margin: 0;
}
.auto-test-grid .book-card h3 {
    font-size: 15px;
    margin: 0;
    line-height: 1.3;
}
.auto-test-grid .book-card h3 a:hover { color: var(--accent); }
.auto-test-grid .book-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
    padding-top: 6px;
}
.auto-test-grid .book-meta .price {
    font-size: 17px;
    font-weight: 700;
    color: var(--accent);
}

/* Кнопки */
.auto-test-grid .book-actions-row {
    display: flex;
    gap: 6px;
    margin-top: 6px;
}
.auto-test-grid .btn-cart,
.auto-test-grid .btn-selection,
.auto-test-grid .btn-preview {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 34px;
    padding: 0 12px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    text-decoration: none;
    transition: .15s;
    white-space: nowrap;
}
.auto-test-grid .btn-cart {
    flex: 1;
    background: var(--accent);
    color: #fff;
}
.auto-test-grid .btn-cart:hover { background: var(--accent-dark); }
.auto-test-grid .btn-cart:disabled { background: #c9d3cd; cursor: default; }

.auto-test-grid .btn-selection {
    flex: 0 0 40px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 16px;
}
.auto-test-grid .btn-selection:hover { background: var(--accent); color: #fff; }
.auto-test-grid .btn-selection:disabled { background: #e1e4e8; color: #a5b2ac; cursor: default; }

.auto-test-grid .btn-preview {
    flex: 0 0 40px;
    background: #f0f3f1;
    color: #6b7a74;
}
.auto-test-grid .btn-preview:hover { background: #e1e4e8; }


/* ============================================================
   АВТОПОДБОР: сетка книг
   ============================================================ */
.auto-test-grid {
    margin-top: 16px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}
@media (max-width: 640px) {
    .auto-test-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
}

.auto-test-grid .book-card {
    background: var(--card);
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.auto-test-grid .book-card__cover {
    width: 100%;
    aspect-ratio: 3 / 4;
    overflow: hidden;
    border-radius: 10px;
    background: #f5f7f6;
}
.auto-test-grid .book-card__cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.auto-test-grid .book-card__info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}
.auto-test-grid .book-card .author {
    font-size: 13px;
    color: var(--muted);
    margin: 0;
}
.auto-test-grid .book-card h3 {
    font-size: 15px;
    margin: 0;
    line-height: 1.3;
}
.auto-test-grid .book-card h3 a:hover { color: var(--accent); }
.auto-test-grid .book-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
    padding-top: 6px;
}
.auto-test-grid .book-meta .price {
    font-size: 17px;
    font-weight: 700;
    color: var(--accent);
}

.auto-test-grid .book-actions-row {
    display: flex;
    gap: 6px;
    margin-top: 6px;
}
.auto-test-grid .btn-cart,
.auto-test-grid .btn-selection,
.auto-test-grid .btn-preview {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 34px;
    padding: 0 12px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    text-decoration: none;
    transition: .15s;
    white-space: nowrap;
}
.auto-test-grid .btn-cart {
    flex: 1;
    background: var(--accent);
    color: #fff;
}
.auto-test-grid .btn-cart:hover { background: var(--accent-dark); }
.auto-test-grid .btn-cart:disabled { background: #c9d3cd; cursor: default; }

.auto-test-grid .btn-selection {
    flex: 0 0 40px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 16px;
}
.auto-test-grid .btn-selection:hover { background: var(--accent); color: #fff; }
.auto-test-grid .btn-selection:disabled { background: #e1e4e8; color: #a5b2ac; cursor: default; }

.auto-test-grid .btn-preview {
    flex: 0 0 40px;
    background: #f0f3f1;
    color: #6b7a74;
}
.auto-test-grid .btn-preview:hover { background: #e1e4e8; }

/* ============================================================
   АВТОПОДБОР: сетка книг
   ============================================================ */
.auto-test-grid {
    margin-top: 16px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}
@media (max-width: 640px) {
    .auto-test-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
}

.auto-test-grid .book-card {
    background: var(--card);
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.auto-test-grid .book-card__cover {
    width: 100%;
    aspect-ratio: 3 / 4;
    overflow: hidden;
    border-radius: 10px;
    background: #f5f7f6;
}
.auto-test-grid .book-card__cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.auto-test-grid .book-card__info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}
.auto-test-grid .book-card .author {
    font-size: 13px;
    color: var(--muted);
    margin: 0;
}
.auto-test-grid .book-card h3 {
    font-size: 15px;
    margin: 0;
    line-height: 1.3;
}
.auto-test-grid .book-card h3 a:hover { color: var(--accent); }
.auto-test-grid .book-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
    padding-top: 6px;
}
.auto-test-grid .book-meta .price {
    font-size: 17px;
    font-weight: 700;
    color: var(--accent);
}

.auto-test-grid .book-actions-row {
    display: flex;
    gap: 6px;
    margin-top: 6px;
}
.auto-test-grid .btn-cart,
.auto-test-grid .btn-selection,
.auto-test-grid .btn-preview {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 34px;
    padding: 0 12px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    text-decoration: none;
    transition: .15s;
    white-space: nowrap;
}

.auto-test-grid .btn-cart {
    flex: 1;
    background: var(--accent);
    color: #fff;
}
.auto-test-grid .btn-cart:hover { background: var(--accent-dark); }
.auto-test-grid .btn-cart:disabled { opacity: .6; cursor: wait; }
.auto-test-grid .btn-cart.is-active {
    background: #235e45;
}

.auto-test-grid .btn-selection {
    flex: 0 0 40px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 16px;
}
.auto-test-grid .btn-selection:hover { background: var(--accent); color: #fff; }
.auto-test-grid .btn-selection:disabled { opacity: .6; cursor: wait; }
.auto-test-grid .btn-selection.is-active {
    background: var(--accent);
    color: #fff;
}

.auto-test-grid .btn-preview {
    flex: 0 0 40px;
    background: #f0f3f1;
    color: #6b7a74;
}
.auto-test-grid .btn-preview:hover { background: #e1e4e8; }

/* ============================================================
   ФИНАЛЬНЫЕ КНОПКИ АВТОПОДБОРА
   ============================================================ */
.auto-test-finish {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid #eae6e1;
}
.auto-test-finish .btn-primary,
.auto-test-finish .btn-outline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 52px;
    padding: 0 28px;
    border-radius: 50px;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: .15s;
}
.auto-test-finish .btn-primary {
    background: var(--accent);
    color: #fff;
    border: none;
}
.auto-test-finish .btn-primary:hover { background: var(--accent-dark); }
.auto-test-finish .btn-primary:disabled { background: #c9d3cd; cursor: wait; }

.auto-test-finish .btn-outline {
    background: #fff;
    color: var(--accent);
    border: 1px solid var(--accent);
}
.auto-test-finish .btn-outline:hover { background: var(--accent-soft); }
.auto-test-finish .btn-outline:disabled { opacity: .5; cursor: wait; }

@media (max-width: 640px) {
    .auto-test-finish { flex-direction: column; }
    .auto-test-finish .btn-primary,
    .auto-test-finish .btn-outline { width: 100%; }
}

/* ============================================================
   УВЕДОМЛЕНИЕ АВТОПОДБОРА
   ============================================================ */
.auto-test-notice {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    z-index: 9999;
    padding: 12px 22px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    box-shadow: 0 8px 24px rgba(0,0,0,.15);
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s, transform .25s;
    max-width: 90vw;
    text-align: center;
}
.auto-test-notice.is-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
.auto-test-notice.is-success { background: #2e7d5b; }
.auto-test-notice.is-warning { background: #d97706; }
.auto-test-notice.is-error   { background: #c0392b; }
.auto-test-notice.is-info    { background: #4a5568; }

/* ============================================================
   АВТОПОДБОР
   ============================================================ */
.auto-test-grid {
    margin-top: 16px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}
@media (max-width: 640px) {
    .auto-test-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
}

.auto-test-grid .book-card {
    background: var(--card);
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.auto-test-grid .book-card__cover {
    width: 100%;
    aspect-ratio: 3 / 4;
    overflow: hidden;
    border-radius: 10px;
    background: #f5f7f6;
}
.auto-test-grid .book-card__cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.auto-test-grid .book-card__info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}
.auto-test-grid .book-card .author {
    font-size: 13px;
    color: var(--muted);
    margin: 0;
}
.auto-test-grid .book-card h3 {
    font-size: 15px;
    margin: 0;
    line-height: 1.3;
}
.auto-test-grid .book-card h3 a:hover { color: var(--accent); }
.auto-test-grid .book-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
    padding-top: 6px;
}
.auto-test-grid .book-meta .price {
    font-size: 17px;
    font-weight: 700;
    color: var(--accent);
}

/* Кнопки */
.auto-test-grid .book-actions-row {
    display: flex;
    gap: 6px;
    margin-top: 6px;
}
.auto-test-grid .btn-cart,
.auto-test-grid .btn-selection,
.auto-test-grid .btn-preview {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 34px;
    padding: 0 12px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    text-decoration: none;
    transition: .15s;
    white-space: nowrap;
}

.auto-test-grid .btn-cart {
    flex: 1;
    background: var(--accent);
    color: #fff;
}
.auto-test-grid .btn-cart:hover { background: var(--accent-dark); }
.auto-test-grid .btn-cart.is-active { background: #235e45; }

.auto-test-grid .btn-selection {
    flex: 0 0 40px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 16px;
}
.auto-test-grid .btn-selection:hover { background: var(--accent); color: #fff; }
.auto-test-grid .btn-selection.is-active {
    background: var(--accent);
    color: #fff;
}

/* Просмотр — ВСЕГДА активен */
.auto-test-grid .btn-preview {
    flex: 0 0 40px;
    background: #f0f3f1;
    color: #6b7a74;
    pointer-events: auto !important;
    opacity: 1 !important;
}
.auto-test-grid .btn-preview:hover { background: #e1e4e8; }

/* Финальные кнопки */
.auto-test-finish {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid #eae6e1;
}
.auto-test-finish .btn-primary,
.auto-test-finish .btn-outline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 52px;
    padding: 0 28px;
    border-radius: 50px;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: .15s;
}
.auto-test-finish .btn-primary {
    background: var(--accent);
    color: #fff;
    border: none;
}
.auto-test-finish .btn-primary:hover { background: var(--accent-dark); }
.auto-test-finish .btn-primary:disabled { background: #c9d3cd; cursor: wait; }

.auto-test-finish .btn-outline {
    background: #fff;
    color: var(--accent);
    border: 1px solid var(--accent);
}
.auto-test-finish .btn-outline:hover { background: var(--accent-soft); }
.auto-test-finish .btn-outline:disabled { opacity: .5; cursor: wait; }

@media (max-width: 640px) {
    .auto-test-finish { flex-direction: column; }
    .auto-test-finish .btn-primary,
    .auto-test-finish .btn-outline { width: 100%; }
}

/* Уведомление */
.auto-test-notice {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    z-index: 9999;
    padding: 12px 22px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    box-shadow: 0 8px 24px rgba(0,0,0,.15);
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s, transform .25s;
    max-width: 90vw;
    text-align: center;
}
.auto-test-notice.is-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
.auto-test-notice.is-success { background: #2e7d5b; }
.auto-test-notice.is-warning { background: #d97706; }
.

/* ============================================================
   АВТОПОДБОР
   ============================================================ */
.auto-test-grid {
    margin-top: 16px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}
@media (max-width: 640px) {
    .auto-test-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
}

.auto-test-grid .book-card {
    background: var(--card);
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.auto-test-grid .book-card__cover {
    width: 100%;
    aspect-ratio: 3 / 4;
    overflow: hidden;
    border-radius: 10px;
    background: #f5f7f6;
}
.auto-test-grid .book-card__cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.auto-test-grid .book-card__info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}
.auto-test-grid .book-card .author {
    font-size: 13px;
    color: var(--muted);
    margin: 0;
}
.auto-test-grid .book-card h3 {
    font-size: 15px;
    margin: 0;
    line-height: 1.3;
}
.auto-test-grid .book-card h3 a:hover { color: var(--accent); }
.auto-test-grid .book-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
    padding-top: 6px;
}
.auto-test-grid .book-meta .price {
    font-size: 17px;
    font-weight: 700;
    color: var(--accent);
}

/* Кнопки */
.auto-test-grid .book-actions-row {
    display: flex;
    gap: 6px;
    margin-top: 6px;
}
.auto-test-grid .btn-cart,
.auto-test-grid .btn-selection,
.auto-test-grid .btn-preview {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 34px;
    padding: 0 12px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    text-decoration: none;
    transition: .15s;
    white-space: nowrap;
}

.auto-test-grid .btn-cart {
    flex: 1;
    background: var(--accent);
    color: #fff;
}
.auto-test-grid .btn-cart:hover { background: var(--accent-dark); }
.auto-test-grid .btn-cart.is-active { background: #235e45; }

.auto-test-grid .btn-selection {
    flex: 0 0 40px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 16px;
}
.auto-test-grid .btn-selection:hover { background: var(--accent); color: #fff; }
.auto-test-grid .btn-selection.is-active {
    background: var(--accent);
    color: #fff;
}

/* Просмотр — ВСЕГДА активен */
.auto-test-grid .btn-preview {
    flex: 0 0 40px;
    background: #f0f3f1;
    color: #6b7a74;
    pointer-events: auto !important;
    opacity: 1 !important;
}
.auto-test-grid .btn-preview:hover { background: #e1e4e8; }

/* Финальные кнопки */
.auto-test-finish {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid #eae6e1;
}
.auto-test-finish .btn-primary,
.auto-test-finish .btn-outline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 52px;
    padding: 0 28px;
    border-radius: 50px;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: .15s;
}
.auto-test-finish .btn-primary {
    background: var(--accent);
    color: #fff;
    border: none;
}
.auto-test-finish .btn-primary:hover { background: var(--accent-dark); }
.auto-test-finish .btn-primary:disabled { background: #c9d3cd; cursor: wait; }

.auto-test-finish .btn-outline {
    background: #fff;
    color: var(--accent);
    border: 1px solid var(--accent);
}
.auto-test-finish .btn-outline:hover { background: var(--accent-soft); }
.auto-test-finish .btn-outline:disabled { opacity: .5; cursor: wait; }

@media (max-width: 640px) {
    .auto-test-finish { flex-direction: column; }
    .auto-test-finish .btn-primary,
    .auto-test-finish .btn-outline { width: 100%; }
}

/* Уведомление */
.auto-test-notice {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    z-index: 9999;
    padding: 12px 22px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    box-shadow: 0 8px 24px rgba(0,0,0,.15);
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s, transform .25s;
    max-width: 90vw;
    text-align: center;
}
.auto-test-notice.is-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
.auto-test-notice.is-success { background: #2e7d5b; }
.auto-test-notice.is-warning { background: #d97706; }
.auto-test-notice.is-error   { background: #c0392b; }
.auto-test-notice.is-info    { background: #4a5568; }