:root {
    /* 炮竹封面风格：深红→朱红→金 */
    --primary: #c41e3a;
    --primary-dark: #8b0000;
    --gold: #d4af37;
    --gold-dark: #b8860b;
    --dark: #2d0a0a;
    --bg-paper: rgba(255,248,240,0.98);
    --border: rgba(184,134,11,0.22);
    --shadow-sm: 0 2px 10px rgba(0,0,0,0.08);
    --shadow-md: 0 10px 30px rgba(0,0,0,0.16);
    --radius-sm: 10px;
    --radius-md: 14px;
    --focus: 0 0 0 3px rgba(212,175,55,0.25);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
    background: linear-gradient(145deg, #2d0a0a 0%, #5c1a1a 35%, #8b2500 70%, #1a0a0a 100%);
    color: #333;
    min-height: 100vh;
    line-height: 1.6;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

.container { max-width: 1200px; margin: 0 auto; padding: 1.75rem; }

main h1, main h2, main h3 { color: var(--dark); letter-spacing: 0.2px; }
main h2 { font-size: 1.4rem; margin-bottom: 1rem; }

a { color: inherit; }

.btn {
    padding: 0.65rem 1.25rem;
    border: 1px solid rgba(0,0,0,0.06);
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.98rem;
    font-weight: 600;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    background: rgba(255,255,255,0.8);
    color: #222;
    box-shadow: 0 1px 0 rgba(0,0,0,0.03);
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, border-color 0.15s ease;
    user-select: none;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(0); box-shadow: 0 1px 0 rgba(0,0,0,0.03); }
.btn:focus { outline: none; }
.btn:focus-visible { box-shadow: var(--focus), var(--shadow-sm); }
.btn:disabled, .btn[disabled] { opacity: 0.6; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-primary {
    background: linear-gradient(180deg, #c41e3a 0%, #8b0000 100%);
    color: #fff;
    border-color: rgba(0,0,0,0.08);
}
.btn-primary:hover { background: linear-gradient(180deg, #d42a48 0%, #a52a2a 100%); }

button { font-family: inherit; }
input, textarea, select {
    font-family: inherit;
}
input:focus, textarea:focus, select:focus { outline: none; box-shadow: var(--focus); border-color: rgba(212,175,55,0.65) !important; }

.site-header {
    background: linear-gradient(90deg, #8b0000 0%, #a52a2a 25%, #c41e3a 50%, #b8860b 100%);
    border-bottom: 2px solid var(--gold);
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(139, 0, 0, 0.35);
    min-height: 44px; /* keep header visually consistent */
}

.site-header .container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0; /* avoid global .container padding inflating header */
    padding: 0.32rem 0.9rem;
    min-height: 44px;
}

.site-logo {
    font-size: 0.95rem;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
    text-decoration: none;
    line-height: 1.2;
}

.site-nav {
    display: flex;
    align-items: center;
    gap: 0.55rem;
}

.site-nav a {
    color: #fff;
    text-decoration: none;
    margin-left: 0;
    line-height: 1.1;
    font-weight: 600;
    opacity: 0.95;
    font-size: 0.84rem;
    padding: 0.28rem 0.4rem; /* uniform clickable area */
    border-radius: 8px;
}
.site-nav a:hover { color: var(--gold); background: rgba(0,0,0,0.10); }

.site-nav .nav-user {
    margin-left: 0.2rem;
    color: rgba(255,255,255,0.92);
    font-weight: 600;
    opacity: 0.95;
    font-size: 0.84rem;
    padding: 0.28rem 0.4rem;
}

.site-nav .nav-badge {
    margin-left: 0.2rem;
    display: inline-flex;
    align-items: center;
    padding: 0.12rem 0.42rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.2px;
    color: #1a0a0a;
    background: linear-gradient(180deg, var(--gold) 0%, var(--gold-dark) 100%);
    box-shadow: 0 6px 16px rgba(0,0,0,0.18);
}

.cart-link {
    background: linear-gradient(180deg, var(--gold) 0%, var(--gold-dark) 100%);
    color: #1a0a0a !important;
    padding: 0.12rem 0.5rem;
    border-radius: 6px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
}
.cart-link:hover { background: linear-gradient(180deg, #e6c04a 0%, var(--gold) 100%); color: #1a0a0a !important; }

main {
    min-height: 60vh;
    background: linear-gradient(180deg, var(--bg-paper) 0%, rgba(255,245,230,0.98) 100%);
    border-radius: var(--radius-md);
    padding: 2rem;
    margin-top: 1rem;
    box-shadow: 0 8px 28px rgba(0,0,0,0.22), inset 0 1px 0 rgba(212,175,55,0.12);
    border: 1px solid var(--border);
}

.hero {
    text-align: center;
    padding: 2rem 0 2.5rem;
    background: linear-gradient(180deg, rgba(196,30,58,0.12) 0%, rgba(212,175,55,0.08) 50%, transparent 100%);
    border-radius: var(--radius-md);
    margin-bottom: 2rem;
    border: 1px solid var(--border);
}
.hero.hero-has-banner {
    padding: 0;
    background: transparent;
    border: 0;
    margin-bottom: 1.25rem;
}
.hero h1 { color: var(--dark); font-size: 2rem; margin-bottom: 0.5rem; }
.hero p { color: #666; }

/* 固定尺寸横幅容器（类似 div.banner）：200×200，图片在容器内裁剪 */
.banner {
    width: 200px;
    height: 200px;
    max-width: 100%;
    margin: 0 auto;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(0,0,0,0.18);
}

/* 首页有横幅时：只展示图片，不要卡片边角 */
.hero.hero-has-banner .banner {
    width: 100%;
    aspect-ratio: 16 / 9;
    height: auto;
    border-radius: 0;
    box-shadow: none;
}
.hero.hero-has-banner .hero-banner {
    object-fit: contain;
    object-position: center center;
    background: rgba(255,255,255,0.0);
}
.hero-banner {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

/* 轮播容器：多张图叠在同一格，只显示当前一张，避免出现多个格子 */
.hero-slider {
    position: relative;
    max-width: 100%;
    margin: 0 auto;
    min-height: 0;
}

.hero-slide {
    display: none;
}
.hero-slide.active {
    display: block;
}

.hero-dots {
    display: flex;
    justify-content: center;
    gap: 0.4rem;
    margin-top: 0.8rem;
}

.hero-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.6);
    box-shadow: 0 0 0 1px rgba(0,0,0,0.1);
    cursor: pointer;
}
.hero-dot.active {
    background: #ffca28;
}

.categories {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 2rem;
}
.categories a {
    padding: 0.5rem 1rem;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    text-decoration: none;
    color: #333;
}
.categories a:hover,
.categories a.active {
    background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #fff;
    border-color: var(--primary);
}

/* 图1 风格：分类卡片（图标 + 两行文字） */
.category-cards-wrap {
    margin-bottom: 2rem;
    overflow: hidden;
}
.category-cards {
    display: flex;
    gap: 1rem;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 0.5rem 0 1rem;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}
.category-card {
    flex: 0 0 auto;
    width: 100px;
    text-align: center;
    text-decoration: none;
    color: #333;
    border-radius: 14px;
    padding: 0.6rem;
    background: #fff;
    border: 2px solid transparent;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.2s, background 0.2s;
    box-shadow: 0 1px 0 rgba(0,0,0,0.03);
}
.category-card:hover {
    border-color: rgba(212,175,55,0.6);
    background: #fffef8;
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}
.category-card.active {
    border-color: var(--primary);
    background: linear-gradient(180deg, rgba(196,30,58,0.12) 0%, rgba(212,175,55,0.08) 100%);
}
.category-icon {
    display: block;
    width: 72px;
    height: 72px;
    margin: 0 auto 0.4rem;
    border-radius: 12px;
    overflow: hidden;
    background: #f5f5f5;
    font-size: 1.5rem;
    line-height: 72px;
    font-weight: bold;
    color: var(--primary);
}
.category-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.category-icon-fallback {
    display: none;
}
.category-icon-fallback.show {
    display: block;
}
.category-icon-all {
    font-size: 1rem;
    line-height: 72px;
}
.category-name-en {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: #555;
    margin-bottom: 0.15rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.category-card.active .category-name-en {
    color: var(--primary-dark);
}
.category-name {
    display: block;
    font-size: 0.8rem;
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.category-card.active .category-name {
    color: #333;
    font-weight: 500;
}

.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.5rem;
}

@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }
    main {
        padding: 1.2rem;
        margin-top: 0.5rem;
    }
    .hero {
        padding: 1.2rem 0 1.4rem;
    }
    /* 手机端固定格子：宽 100%，高 200px */
    .banner {
        width: 100%;
        height: 200px;
    }
    .hero-slider {
        min-height: 200px;
    }
    .products-grid {
        grid-template-columns: 1fr 1fr;
        gap: 1rem;
    }
}

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

.product-card {
    background: #fff;
    border-radius: var(--radius-sm);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
    border: 1px solid rgba(0,0,0,0.04);
}
.product-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.product-card img {
    width: 100%;
    height: 200px;
    object-fit: contain; /* never crop product images */
    object-position: center center;
    background: #f0f0f0;
}
.product-card .info { padding: 1rem; }
.product-card .name { font-weight: bold; margin-bottom: 0.3rem; color: var(--dark); }
.product-card .price { color: var(--primary); font-size: 1.2rem; font-weight: bold; }
.product-card .stock { font-size: 0.85rem; color: #888; margin-top: 0.3rem; }
.product-card .btn-add {
    display: block;
    width: 100%;
    margin-top: 0.8rem;
    padding: 0.6rem;
    background: linear-gradient(180deg, #c41e3a 0%, #8b0000 100%);
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 700;
    letter-spacing: 0.2px;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.product-card .btn-add:hover { background: linear-gradient(180deg, #d42a48 0%, #a52a2a 100%); transform: translateY(-1px); box-shadow: 0 8px 18px rgba(0,0,0,0.16); }
.product-card .btn-add:disabled { background: #999; cursor: not-allowed; }

.product-detail {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    align-items: start;
}
@media (max-width: 768px) { .product-detail { grid-template-columns: 1fr; } }
.product-detail img {
    width: 100%;
    max-height: 400px;
    object-fit: contain; /* never crop product images */
    object-position: center center;
    border-radius: 10px;
}
.product-detail .meta h1 { margin-bottom: 1rem; color: var(--dark); }
.product-detail .meta .price { font-size: 1.8rem; color: var(--primary); margin-bottom: 1rem; }
.product-detail .meta .description { color: #555; margin-bottom: 1.5rem; }
.product-detail .price-row { display: flex; flex-direction: column; gap: 0.25rem; margin-bottom: 1rem; }
.product-detail .unit-hint { color: #666; font-size: 0.9em; margin-left: 0.25rem; }
.cart-unit { color: #666; font-size: 0.9em; }
.quantity-wrap { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.5rem; }
.quantity-wrap input {
    width: 80px;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 6px;
}
.btn-buy {
    padding: 0.8rem 2rem;
    background: linear-gradient(180deg, #c41e3a 0%, #8b0000 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
}
.btn-buy:hover { background: linear-gradient(180deg, #d42a48 0%, #a52a2a 100%); }

.cart-table { width: 100%; border-collapse: collapse; }
.cart-table th, .cart-table td { padding: 0.9rem 1rem; border-bottom: 1px solid rgba(0,0,0,0.06); text-align: left; }
.cart-table th { background: rgba(0,0,0,0.03); font-weight: 700; color: #222; }
.cart-table tr:hover td { background: rgba(212,175,55,0.06); }
.cart-total { text-align: right; margin-top: 1.5rem; font-size: 1.2rem; }
.cart-total strong { color: var(--primary); }
.cart-empty { text-align: center; padding: 3rem; color: #888; }
.cart-table button {
    padding: 0.45rem 0.75rem;
    border-radius: 10px;
    border: 1px solid rgba(0,0,0,0.08);
    background: rgba(255,255,255,0.85);
    cursor: pointer;
    font-weight: 600;
}
.cart-table button:hover { box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.cart-table button:focus-visible { box-shadow: var(--focus), var(--shadow-sm); }

.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 0.3rem; font-weight: 500; }
.form-group input,
.form-group textarea {
    width: 100%;
    padding: 0.6rem;
    border: 1px solid #ddd;
    border-radius: 10px;
    font-size: 1rem;
    background: rgba(255,255,255,0.9);
}
.form-group textarea { min-height: 100px; resize: vertical; }

.btn {
    /* 前面已统一定义，这里保留兼容旧结构 */
}
.btn-primary { background: linear-gradient(180deg, #c41e3a 0%, #8b0000 100%); color: #fff; }
.btn-primary:hover { background: linear-gradient(180deg, #d42a48 0%, #a52a2a 100%); }

/* 配送方式：与首页分类按钮同款 - 白底灰边 / 选中红底白字 */
.delivery-method-wrap .form-label { display: block; margin-bottom: 0.5rem; font-weight: 500; }
.delivery-options-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    position: relative;
}
.delivery-option-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    font-size: 1rem;
    font-weight: 500;
    color: #333;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.delivery-option-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}
/* 选中态：红底白字，与分类选中一致 */
.delivery-option-btn.delivery-selected {
    background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #fff !important;
    border-color: var(--primary);
}
/* 单选完全隐藏 */
.delivery-radio-hidden {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    clip-path: inset(50%);
}
.delivery-option { display: inline-block; margin-right: 1rem; margin-bottom: 0.3rem; font-weight: 500; }
.delivery-option input { margin-right: 0.35rem; }

.site-footer {
    text-align: center;
    padding: 2rem;
    color: rgba(255,248,240,0.85);
    font-size: 0.9rem;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.alert { padding: 1rem; border-radius: 6px; margin-bottom: 1rem; }
.alert-success { background: #d4edda; color: #155724; }
.alert-error { background: #f8d7da; color: #721c24; }
