/* ====== 全局 ====== */
*{box-sizing:border-box;margin:0;padding:0;-webkit-tap-highlight-color:transparent}
html,body{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","PingFang SC","Hiragino Sans GB","Microsoft YaHei",sans-serif;color:#1a1a1a;background:#f5f6f8;font-size:15px;line-height:1.5;-webkit-font-smoothing:antialiased}
button{font-family:inherit;cursor:pointer;border:none;background:none}
input,textarea,select{font-family:inherit}
img{max-width:100%;display:block}

/* ====== 顶栏 ====== */
.topbar{position:sticky;top:0;z-index:50;display:flex;align-items:center;gap:10px;padding:10px 14px;background:#fff;border-bottom:1px solid #eee}
.brand{display:flex;align-items:center;gap:8px;flex-shrink:0;font-size:17px;font-weight:700;color:#6366f1}
.logo{font-size:22px}
.search-box{flex:1;display:flex;align-items:center;background:#f1f2f6;border-radius:22px;padding:0 6px}
.search-box input{flex:1;border:none;background:none;padding:8px 10px;font-size:14px;outline:none}
.search-btn{padding:8px 12px;border-radius:50%;font-size:15px}
.cart-btn{position:relative;width:40px;height:40px;border-radius:50%;background:#f1f2f6;font-size:18px;flex-shrink:0}
.badge{position:absolute;top:2px;right:2px;min-width:18px;height:18px;background:#ef4444;color:#fff;font-size:11px;border-radius:9px;display:flex;align-items:center;justify-content:center;padding:0 4px;font-weight:700}

/* ====== 分类 ====== */
.cat-bar{display:flex;gap:8px;padding:10px 14px;overflow-x:auto;white-space:nowrap;background:#fff;border-bottom:1px solid #eee;position:sticky;top:59px;z-index:40;scrollbar-width:none}
.cat-bar::-webkit-scrollbar{display:none}
.cat-chip{flex-shrink:0;padding:7px 14px;border-radius:18px;background:#f1f2f6;color:#555;font-size:13px}
.cat-chip.active{background:#6366f1;color:#fff;font-weight:600}

/* ====== 商品网格 ====== */
main{padding:12px 10px 80px}
.grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:10px}
@media (min-width:420px){.grid{grid-template-columns:repeat(2,1fr)}}
@media (min-width:640px){.grid{grid-template-columns:repeat(3,1fr);gap:14px}}
@media (min-width:900px){.grid{grid-template-columns:repeat(4,1fr)}}

.card{background:#fff;border-radius:12px;overflow:hidden;box-shadow:0 1px 4px rgba(0,0,0,.06);display:flex;flex-direction:column;cursor:pointer;transition:transform .15s}
.card:active{transform:scale(.98)}
.cover{width:100%;aspect-ratio:4/3;display:flex;align-items:center;justify-content:center;font-size:48px;font-weight:700;color:rgba(255,255,255,.9);letter-spacing:2px;text-shadow:0 2px 8px rgba(0,0,0,.15)}
.card-body{padding:10px 12px 12px;display:flex;flex-direction:column;gap:4px;flex:1}
.card-title{font-size:14px;font-weight:600;line-height:1.3;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;color:#111}
.card-sub{font-size:12px;color:#888;display:-webkit-box;-webkit-line-clamp:1;-webkit-box-orient:vertical;overflow:hidden}
.card-price{display:flex;align-items:baseline;gap:6px;margin-top:auto}
.price{font-size:17px;font-weight:700;color:#ef4444}
.price::before{content:'¥';font-size:12px;margin-right:1px}
.price-old{font-size:12px;color:#bbb;text-decoration:line-through}
.tag-row{display:flex;gap:4px;flex-wrap:wrap}
.tag{font-size:10px;padding:1px 6px;background:#eef2ff;color:#6366f1;border-radius:8px}

/* ====== 弹窗 ====== */
.modal{position:fixed;inset:0;background:rgba(0,0,0,.5);display:flex;align-items:flex-end;justify-content:center;z-index:100;padding:0}
.modal-card{background:#fff;border-radius:16px 16px 0 0;width:100%;max-width:640px;max-height:90vh;overflow-y:auto;padding:18px 20px}
@media (min-width:560px){.modal{align-items:center;padding:20px}.modal-card{border-radius:16px;max-height:85vh}}
.modal-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:14px}
.modal-header h3{font-size:17px}
.close{width:32px;height:32px;border-radius:50%;background:#f1f2f6;font-size:16px;flex-shrink:0}

/* ====== 详情 ====== */
.detail-cover{width:100%;aspect-ratio:16/10;border-radius:12px;display:flex;align-items:center;justify-content:center;font-size:80px;font-weight:800;color:rgba(255,255,255,.9);margin-bottom:14px}
.detail-title{font-size:20px;font-weight:700;margin-bottom:4px}
.detail-sub{font-size:14px;color:#666;margin-bottom:10px}
.detail-price-row{display:flex;align-items:baseline;gap:10px;margin-bottom:10px}
.detail-price-row .price{font-size:26px}
.detail-desc{font-size:14px;color:#444;background:#f8f9fb;padding:12px;border-radius:10px;line-height:1.7;margin-bottom:14px;white-space:pre-wrap}
.detail-meta{display:flex;gap:16px;font-size:12px;color:#888;margin-bottom:14px}
.qty-picker{display:flex;align-items:center;gap:10px}
.qty-btn{width:36px;height:36px;border-radius:8px;background:#f1f2f6;font-size:18px;font-weight:600}
.qty-num{font-size:18px;font-weight:700;min-width:32px;text-align:center}

/* ====== 购物车 / 结算 ====== */
.cart-list{display:flex;flex-direction:column;gap:10px;margin-bottom:12px}
.cart-item{display:flex;gap:10px;padding:10px;background:#f8f9fb;border-radius:10px;align-items:center}
.cart-item .cover{width:60px;height:60px;border-radius:8px;font-size:22px;aspect-ratio:auto;flex-shrink:0}
.cart-item-info{flex:1;min-width:0}
.cart-item-title{font-size:14px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.cart-item-price{font-size:13px;color:#ef4444;font-weight:600;margin-top:2px}
.cart-qty{display:flex;align-items:center;gap:6px;flex-shrink:0}
.cart-qty .qty-btn{width:28px;height:28px;font-size:14px}
.cart-qty .qty-num{font-size:15px;min-width:24px}
.cart-remove{color:#ef4444;font-size:18px;margin-left:6px;flex-shrink:0}
.cart-footer{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-top:14px;padding-top:12px;border-top:1px solid #eee}
.price-big{font-size:22px;font-weight:700;color:#ef4444}
.price-big::before{content:'¥';font-size:14px}

/* ====== 表单 ====== */
.form{display:flex;flex-direction:column;gap:12px}
.form label{display:flex;flex-direction:column;gap:4px;font-size:13px;color:#555}
.form input,.form textarea{padding:10px 12px;border:1px solid #e5e7eb;border-radius:10px;font-size:15px;outline:none}
.form input:focus,.form textarea:focus{border-color:#6366f1}
.tip{font-size:12px;color:#888;background:#fff8e1;padding:8px 10px;border-radius:8px}

/* ====== 按钮 ====== */
.btn-primary{background:#6366f1;color:#fff;padding:12px 20px;border-radius:12px;font-size:15px;font-weight:600;min-height:44px}
.btn-primary:active{background:#4f46e5}
.btn-secondary{background:#f1f2f6;color:#333;padding:12px 20px;border-radius:12px;font-size:14px;font-weight:500;min-height:44px}
.btn-danger{background:#fee2e2;color:#dc2626;padding:8px 14px;border-radius:10px;font-size:13px}
.btn-sm{padding:6px 10px;border-radius:8px;font-size:12px}
.load-more{width:100%;padding:12px;margin-top:10px;background:#fff;border:1px solid #eee;border-radius:10px;color:#666}
.row-gap{display:flex;gap:10px;flex-wrap:wrap}

/* ====== 其他 ====== */
.loading,.empty{text-align:center;padding:40px;color:#888;font-size:14px}
.success-icon{font-size:64px;margin-bottom:10px}
.center{text-align:center}
.fab{position:fixed;right:18px;bottom:20px;width:52px;height:52px;border-radius:50%;background:#6366f1;color:#fff;font-size:22px;box-shadow:0 4px 14px rgba(99,102,241,.4);z-index:30}
.fab:active{transform:scale(.95)}
.toast{position:fixed;left:50%;top:40%;transform:translateX(-50%);background:rgba(0,0,0,.8);color:#fff;padding:10px 20px;border-radius:10px;z-index:200;font-size:14px}
.order-status{font-size:13px;padding:4px 12px;border-radius:14px;display:inline-block;margin-top:6px}
.status-pending{background:#fef3c7;color:#b45309}
.status-paid{background:#dbeafe;color:#1d4ed8}
.status-shipped{background:#c7d2fe;color:#4338ca}
.status-done{background:#d1fae5;color:#065f46}
.status-cancelled{background:#fee2e2;color:#b91c1c}
