* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--tg-theme-bg-color, #f6f2ec);
    color: var(--tg-theme-text-color, #2d2d2d);
}

.container {
    max-width: 500px;
    margin: 0 auto;
    padding: 20px 16px;
}

/* Прелоадер */
#preloader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #f6f2ec;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    transition: opacity 0.5s;
}

.loader-logo img {
    width: 140px;
    margin-bottom: 30px;
}

.loader-bar {
    width: 200px;
    height: 6px;
    background: #ddd;
    border-radius: 10px;
    overflow: hidden;
}

.loader-progress {
    width: 0%;
    height: 100%;
    background: #4b2e2a;
    transition: width 1.5s;
}

/* Шапка */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.back-button {
    background: none;
    border: none;
    font-size: 18px;
    color: #4b2e2a;
    cursor: pointer;
    padding: 8px 0;
    min-width: 70px;
    text-align: left;
}

.page-title {
    font-size: 24px;
    font-weight: 600;
    color: #4b2e2a;
    text-align: center;
    flex: 1;
}

.cart-icon {
    position: relative;
    font-size: 24px;
    cursor: pointer;
    min-width: 70px;
    text-align: right;
}

.cart-count {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #4b2e2a;
    color: white;
    font-size: 12px;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Главная */
.main-logo {
    text-align: center;
    margin-bottom: 24px;
}

.main-logo img {
    width: 140px;
}

.hero img {
    width: 100%;
    border-radius: 20px;
    margin-bottom: 24px;
}

.menu-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.menu-item {
    cursor: pointer;
    text-align: center;
}

.menu-item img {
    width: 100%;
    aspect-ratio: 1/1;        /* Квадратное соотношение */
    object-fit: cover;         /* Изображение заполняет квадрат */
    border-radius: 20px;
    margin-bottom: 8px;
}

.menu-item p {
    font-size: 15px;
    font-weight: 500;
    color: #4b2e2a;
}

/* ======== СТРАНИЦА ВИДЕОРЕЦЕПТОВ ======== */

.video-description {
    background: var(--tg-theme-secondary-bg-color, #ffffff);
    border-radius: 20px;
    padding: 20px;
    margin-bottom: 24px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.03);
}

.description-text {
    font-size: 14px;
    line-height: 1.5;
    color: var(--tg-theme-text-color, #2d2d2d);
    font-weight: 300;
    letter-spacing: 0.3px;
    margin: 0;
}

.video-recipes-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 30px;
}

.video-recipe-card-full {
    position: relative;
    width: 100%;
    border-radius: 20px;
    overflow: hidden;
    aspect-ratio: 3/2;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    transition: transform 0.2s;
}

.video-recipe-card-full:hover {
    transform: translateY(-2px);
}

.recipe-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 1;
}

.recipe-content {
    position: relative;
    z-index: 2;
    width: 100%;
    height: 100%;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: linear-gradient(180deg, rgba(0,0,0,0.2) 0%, rgba(0,0,0,0.5) 100%);
    color: white;
}

.recipe-text-top {
    text-align: left;
}

.recipe-title-caps {
    font-size: 24px;
    font-weight: 300;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: #e0c0a0;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    margin-bottom: 6px;
    line-height: 1.2;
}

.recipe-desc {
    font-size: 13px;
    line-height: 1.4;
    font-weight: 300;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    max-width: 85%;
    opacity: 0.9;
}

.recipe-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

.recipe-price {
    font-size: 22px;
    font-weight: 300;
    color: #e0c0a0;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    background: rgba(0, 0, 0, 0.15);
    padding: 4px 10px;
    border-radius: 30px;
    backdrop-filter: blur(4px);
    letter-spacing: 0.5px;
}

.buy-now-btn {
    background: rgba(139, 90, 75, 0.95);
    border: none;
    color: white;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 1px;
    padding: 12px 24px;
    border-radius: 40px;
    text-transform: uppercase;
    cursor: pointer;
    backdrop-filter: blur(4px);
    transition: all 0.2s;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.buy-now-btn:hover {
    background: #4b2e2a;
    transform: scale(1.03);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

.buy-now-btn:active {
    transform: scale(0.98);
}

/* ======== СТРАНИЦА КНИГ - КВАДРАТНАЯ СЕТКА ======== */

.books-description {
    background: var(--tg-theme-secondary-bg-color, #ffffff);
    border-radius: 20px;
    padding: 20px;
    margin-bottom: 24px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.03);
}

.books-grid-square {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 16px;
    margin-bottom: 30px;
}

.book-square-card {
    background: white;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
}

.book-square-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
}

.book-square-card.coming-soon {
    opacity: 0.7;
    filter: grayscale(0.5);
}

.book-cover-image {
    width: 100%;
    aspect-ratio: 1/1;
    object-fit: contain;
    background-color: #f0e9e0;
    padding: 8px;
}

.book-square-info {
    padding: 12px;
    text-align: left;
}

.book-square-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
    color: #2d2d2d;
}

.book-square-price {
    font-size: 18px;
    font-weight: 700;
    color: #8b5a4b;
    margin-bottom: 2px;
}

.book-square-type {
    font-size: 12px;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ======== ДЕТАЛЬНАЯ СТРАНИЦА КНИГИ ======== */

.book-detail-page {
    padding-bottom: 30px;
}

.book-detail-cover {
    width: 100%;
    margin-bottom: 24px;
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
    background-color: #f0e9e0;
}

.book-detail-cover img {
    width: 100%;
    aspect-ratio: 1/1;
    object-fit: contain;
    display: block;
    padding: 20px;
}

.book-detail-title {
    font-size: 28px;
    font-weight: 300;
    line-height: 1.3;
    margin-bottom: 12px;
    color: #2d2d2d;
    letter-spacing: -0.5px;
}

.book-detail-price {
    font-size: 32px;
    font-weight: 300;
    color: #8b5a4b;
    margin-bottom: 24px;
    border-bottom: 1px solid #eee;
    padding-bottom: 16px;
}

.book-detail-description {
    font-size: 16px;
    line-height: 1.6;
    color: #444;
    margin-bottom: 30px;
}

.book-detail-description p {
    margin-bottom: 16px;
}

.book-quote {
    font-size: 18px;
    font-style: italic;
    color: #8b5a4b;
    border-left: 3px solid #8b5a4b;
    padding-left: 16px;
    margin: 20px 0;
}

.book-section-title {
    font-size: 18px;
    font-weight: 500;
    margin: 20px 0 12px 0;
    color: #8b5a4b;
}

.book-features {
    list-style: none;
    margin: 20px 0;
}

.book-features li {
    padding: 8px 0 8px 24px;
    position: relative;
}

.book-features li:before {
    content: "•";
    color: #8b5a4b;
    font-size: 20px;
    position: absolute;
    left: 4px;
    top: 4px;
}

.book-format {
    font-size: 14px;
    color: #8b5a4b;
    font-weight: 500;
    margin-top: 20px;
    padding: 8px 12px;
    background: rgba(139, 90, 75, 0.1);
    border-radius: 30px;
    display: inline-block;
}

.book-purchase-section {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

.buy-book-detail-btn {
    width: 100%;
    background: #8b5a4b;
    color: white;
    border: none;
    padding: 18px;
    border-radius: 40px;
    font-size: 18px;
    font-weight: 500;
    letter-spacing: 1px;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(139, 90, 75, 0.3);
}

.buy-book-detail-btn.ebook {
    background: #4b2e2a;
}

.buy-book-detail-btn:hover {
    transform: scale(1.02);
    box-shadow: 0 6px 16px rgba(139, 90, 75, 0.4);
}

.buy-book-detail-btn:active {
    transform: scale(0.98);
}

.delivery-note {
    text-align: center;
    color: #999;
    font-size: 13px;
    margin-top: 12px;
}

/* Книги (старые стили, оставляем для совместимости) */
.books-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.book-card {
    display: flex;
    background: white;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.book-cover {
    width: 100px;
    height: 140px;
    object-fit: cover;
}

.book-info {
    flex: 1;
    padding: 16px;
}

.book-info h3 {
    margin-bottom: 8px;
    font-size: 16px;
}

.book-desc {
    color: #666;
    font-size: 14px;
    margin-bottom: 8px;
}

.price {
    color: #4b2e2a;
    font-weight: 600;
    margin-bottom: 8px;
}

.add-btn {
    background: #4b2e2a;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
}

/* Кофейня */
.cafe-info {
    margin-bottom: 24px;
}

.cafe-image {
    width: 100%;
    height: 180px;
    object-fit: cover;
    border-radius: 16px;
    margin-bottom: 16px;
}

.address {
    color: #666;
    font-size: 14px;
    margin: 8px 0;
}

.map-link {
    color: #4b2e2a;
    text-decoration: none;
    font-weight: 500;
    display: inline-block;
    margin: 8px 0;
}

.hours {
    color: #333;
    font-size: 14px;
}

.menu-section h3 {
    margin-bottom: 16px;
}

.menu-item-card {
    display: flex;
    align-items: center;
    background: white;
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 8px;
}

.menu-item-card img {
    width: 50px;
    height: 50px;
    border-radius: 10px;
    margin-right: 12px;
    object-fit: cover;
}

.item-info {
    flex: 1;
}

.item-name {
    font-weight: 500;
    display: block;
    margin-bottom: 4px;
}

.item-price {
    color: #4b2e2a;
    font-weight: 600;
    font-size: 14px;
}

.small-btn {
    width: 36px;
    height: 36px;
    background: #4b2e2a;
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
}

/* Корзина */
.contact-block {
    background: white;
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 24px;
}

.contact-info {
    background: #f5f5f5;
    border-radius: 12px;
    padding: 12px;
    margin: 12px 0;
}

.share-btn {
    width: 100%;
    background: #4b2e2a;
    color: white;
    border: none;
    padding: 12px;
    border-radius: 24px;
    font-size: 16px;
    cursor: pointer;
}

.cart-item {
    display: flex;
    background: white;
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 8px;
}

.item-details {
    flex: 1;
}

.quantity-control {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
}

.quantity-control button {
    width: 30px;
    height: 30px;
    background: #4b2e2a;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
}

.remove-btn {
    background: none;
    border: none;
    color: #999;
    font-size: 18px;
    cursor: pointer;
}

.time-slots {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 16px 0;
}

.time-slot {
    flex: 1 1 calc(50% - 4px);
    background: #f5f5f5;
    padding: 12px;
    border-radius: 12px;
    text-align: center;
    cursor: pointer;
}

.time-slot.selected {
    background: #4b2e2a;
    color: white;
}

.total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 20px;
    font-weight: 700;
    margin: 20px 0;
    padding: 20px 0;
    border-top: 2px solid #ddd;
}

.pay-btn {
    width: 100%;
    background: #4b2e2a;
    color: white;
    border: none;
    padding: 16px;
    border-radius: 30px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
}

.note {
    text-align: center;
    color: #999;
    font-size: 12px;
    margin-top: 8px;
}

.empty-cart {
    text-align: center;
    color: #999;
    padding: 40px 0;
}

/* Для темной темы */
@media (prefers-color-scheme: dark) {
    .video-description,
    .books-description {
        background: var(--tg-theme-secondary-bg-color, #2a2a2a);
    }
    
    .video-recipe-card-full,
    .book-card-full {
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    }
    
    .book-square-card {
        background: #2a2a2a;
    }
    
    .book-square-title {
        color: white;
    }
    
    .book-detail-title {
        color: white;
    }
    
    .book-detail-description {
        color: #ccc;
    }
    
    .book-section-title {
        color: #e0c0a0;
    }
    
    .book-format {
        background: rgba(224, 192, 160, 0.15);
        color: #e0c0a0;
    }
    
    .book-cover-image,
    .book-detail-cover {
        background-color: #1a1a1a;
    }
    
    .menu-item p {
        color: #e0c0a0;
    }
}

/* Для маленьких экранов */
@media (max-width: 400px) {
    .recipe-title-caps,
    .book-title-caps,
    .book-square-title {
        font-size: 14px;
    }
    
    .recipe-price,
    .book-price,
    .book-square-price {
        font-size: 16px;
    }
    
    .buy-now-btn,
    .buy-book-btn,
    .buy-book-detail-btn {
        padding: 10px 16px;
        font-size: 13px;
    }
    
    .recipe-bottom,
    .book-bottom {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .book-detail-title {
        font-size: 22px;
    }
    
    .book-detail-price {
        font-size: 24px;
    }
    
    .book-detail-cover img {
        padding: 10px;
    }
    
    .menu-item p {
        font-size: 13px;
    }
}