/* ================= 紫万生点单页 · 响应式样式 ================= */
:root {
    --dd-primary: #5C3D2E;
    --dd-primary-hover: #7A5543;
    --dd-gold: #C49A6C;
    --dd-bg: #f7f3ee;
    --dd-card: #ffffff;
    --dd-text: #1C1816;
    --dd-muted: #8A7A6E;
    --dd-border: #E8E0D5;
    --dd-radius: 12px;
    --dd-cartbar-h: 64px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
    margin: 0; padding: 0;
    background: var(--dd-bg);
    color: var(--dd-text);
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
    font-size: 15px;
    line-height: 1.6;
}
body { padding-bottom: calc(var(--dd-cartbar-h) + env(safe-area-inset-bottom)); }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

/* ================= 顶部固定栏 ================= */
.dd-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--dd-primary);
    color: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,.08);
}
.dd-header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    height: 48px;
}
.dd-logo { color: #fff; font-weight: 700; font-size: 16px; letter-spacing: 1px; }
.dd-header-title { font-weight: 600; font-size: 16px; }
.dd-back { color: #fff; font-size: 15px; padding: 4px 8px; }
.dd-cart-icon {
    position: relative;
    font-size: 22px;
    padding: 4px 8px;
    line-height: 1;
}
.dd-badge {
    position: absolute;
    top: -2px; right: -2px;
    min-width: 18px; height: 18px;
    padding: 0 5px;
    background: #E63946;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* 分类 Tab */
.dd-tabs {
    display: flex;
    gap: 4px;
    padding: 0 10px 8px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.dd-tabs::-webkit-scrollbar { display: none; }
.dd-tab {
    flex: 0 0 auto;
    padding: 8px 16px;
    background: rgba(255,255,255,.15);
    color: #fff;
    border-radius: 18px;
    font-size: 14px;
    white-space: nowrap;
    transition: background .2s;
}
.dd-tab.is-active { background: var(--dd-gold); color: #fff; font-weight: 600; }

/* ================= 商品网格 ================= */
.dd-main { padding: 12px 12px 24px; }
.dd-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
}
.dd-card {
    background: var(--dd-card);
    border-radius: var(--dd-radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 2px 8px rgba(0,0,0,.04);
    transition: transform .2s, box-shadow .2s;
}
.dd-card:active { transform: scale(.98); }
.dd-card-img {
    width: 100%;
    aspect-ratio: 1 / 1;
    background: #f0ebe3;
    overflow: hidden;
}
.dd-card-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.dd-card-body {
    padding: 10px 12px 12px;
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 4px;
}
.dd-card-title {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--dd-text);
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.dd-card-desc {
    margin: 0;
    font-size: 12px;
    color: var(--dd-muted);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.dd-card-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: auto;
    padding-top: 6px;
    gap: 8px;
}
.dd-card-price { color: var(--dd-gold); font-weight: 700; font-size: 16px; }
.dd-add-btn {
    width: 30px; height: 30px;
    border: none;
    border-radius: 50%;
    background: var(--dd-primary);
    color: #fff;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
    transition: transform .15s;
}
.dd-add-btn:active { transform: scale(.85); }

.dd-empty { text-align: center; padding: 60px 20px; color: var(--dd-muted); }

/* ================= 底部购物车浮条 ================= */
.dd-cartbar {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
    background: #2d221c;
    color: #fff;
    box-shadow: 0 -4px 16px rgba(0,0,0,.15);
}
.dd-cartbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    cursor: pointer;
    min-width: 0;
}
.dd-cartbar-icon { position: relative; font-size: 28px; line-height: 1; }
.dd-cartbar-count {
    position: absolute;
    top: -4px; right: -6px;
    min-width: 18px; height: 18px;
    padding: 0 5px;
    background: #E63946;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.dd-cartbar-info { min-width: 0; }
.dd-cartbar-price { color: var(--dd-gold); font-size: 18px; font-weight: 700; line-height: 1.2; }
.dd-cartbar-tip { font-size: 12px; opacity: .7; }
.dd-cartbar-btn, .dd-primary-btn {
    border: none;
    border-radius: 24px;
    padding: 10px 22px;
    background: var(--dd-gold);
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background .2s;
    white-space: nowrap;
}
.dd-cartbar-btn:active, .dd-primary-btn:active { opacity: .85; }
.dd-primary-btn { width: 100%; }
.dd-primary-btn--flex { flex: 1; }
.dd-primary-btn--gold { background: var(--dd-gold); }

/* ================= 购物车抽屉 ================= */
.dd-drawer-mask {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 300;
    animation: ddFadeIn .2s;
}
@keyframes ddFadeIn { from { opacity: 0 } to { opacity: 1 } }
.dd-drawer {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 301;
    background: #fff;
    border-radius: 16px 16px 0 0;
    display: flex;
    flex-direction: column;
    max-height: 80vh;
    animation: ddSlideUp .25s;
}
@keyframes ddSlideUp { from { transform: translateY(100%) } to { transform: translateY(0) } }
.dd-drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--dd-border);
}
.dd-drawer-head h3 { margin: 0; font-size: 16px; color: var(--dd-primary); }
.dd-drawer-close {
    background: transparent;
    border: none;
    font-size: 20px;
    color: var(--dd-muted);
    cursor: pointer;
    padding: 0 4px;
}
.dd-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 8px 16px;
}
.dd-drawer-foot {
    border-top: 1px solid var(--dd-border);
    padding: 12px 16px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
    background: #faf6f0;
}
.dd-cart-summary { margin-bottom: 10px; }
.dd-row {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    color: var(--dd-muted);
    padding: 3px 0;
}
.dd-row-total {
    border-top: 1px dashed var(--dd-border);
    margin-top: 6px;
    padding-top: 8px;
    font-size: 15px;
    color: var(--dd-text);
    font-weight: 600;
}
.dd-total { color: var(--dd-gold); font-size: 18px; font-weight: 700; }

/* 购物车商品项 */
.dd-ci {
    display: grid;
    grid-template-columns: 64px 1fr auto;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--dd-border);
    align-items: center;
}
.dd-ci:last-child { border-bottom: none; }
.dd-ci-img {
    width: 64px; height: 64px;
    border-radius: 8px;
    background: #f0ebe3;
    overflow: hidden;
    flex-shrink: 0;
}
.dd-ci-img img { width: 100%; height: 100%; object-fit: cover; }
.dd-ci-info { min-width: 0; }
.dd-ci-name {
    font-size: 14px;
    font-weight: 600;
    margin: 0 0 2px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.dd-ci-price { font-size: 13px; color: var(--dd-gold); font-weight: 600; }
.dd-ci-ops {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
}
.dd-qty {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--dd-border);
    border-radius: 14px;
    overflow: hidden;
}
.dd-qty button {
    width: 26px; height: 26px;
    border: none;
    background: transparent;
    color: var(--dd-primary);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
}
.dd-qty span {
    min-width: 24px;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
}
.dd-ci-del {
    background: transparent;
    border: none;
    color: var(--dd-muted);
    font-size: 12px;
    cursor: pointer;
    padding: 0;
}

/* ================= 商品详情页 ================= */
.dd-header--simple { background: var(--dd-primary); }
.dd-detail { padding-bottom: calc(var(--dd-cartbar-h) + 24px); }
.dd-detail-img {
    width: 100%;
    background: #f0ebe3;
    aspect-ratio: 4 / 3;
    overflow: hidden;
}
.dd-detail-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.dd-detail-info {
    background: #fff;
    padding: 16px;
    border-radius: var(--dd-radius);
    margin: -16px 12px 12px;
    position: relative;
    box-shadow: 0 4px 16px rgba(0,0,0,.05);
}
.dd-detail-title {
    margin: 0 0 8px;
    font-size: 20px;
    color: var(--dd-primary);
    line-height: 1.35;
}
.dd-detail-price {
    color: var(--dd-gold);
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 12px;
}
.dd-detail-desc {
    margin: 0;
    color: var(--dd-muted);
    font-size: 14px;
    line-height: 1.7;
}
.dd-detail-content {
    background: #fff;
    border-radius: var(--dd-radius);
    padding: 16px;
    margin: 0 12px 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,.04);
}
.dd-detail-content h2 {
    margin: 0 0 12px;
    font-size: 16px;
    color: var(--dd-primary);
    padding-left: 10px;
    border-left: 3px solid var(--dd-gold);
}
.dd-rich { font-size: 15px; line-height: 1.8; color: #333; overflow-wrap: anywhere; }
.dd-rich img { max-width: 100%; height: auto; border-radius: 8px; }
.dd-rich table { max-width: 100%; border-collapse: collapse; }
.dd-rich table td, .dd-rich table th { padding: 6px 10px; border: 1px solid var(--dd-border); }

.dd-detail-bar {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
    background: #fff;
    box-shadow: 0 -4px 16px rgba(0,0,0,.08);
}
.dd-detail-bar-price {
    color: var(--dd-gold);
    font-size: 18px;
    font-weight: 700;
    flex-shrink: 0;
    min-width: 70px;
}

/* ================= 结算页 ================= */
.dd-checkout {
    padding: 12px 12px calc(var(--dd-cartbar-h) + 24px);
}
.dd-checkout-block {
    background: #fff;
    border-radius: var(--dd-radius);
    padding: 14px 16px;
    margin-bottom: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,.04);
}
.dd-checkout-block h3 {
    margin: 0 0 12px;
    font-size: 15px;
    color: var(--dd-primary);
    padding-left: 10px;
    border-left: 3px solid var(--dd-gold);
}
.dd-field {
    display: flex;
    align-items: flex-start;
    padding: 10px 0;
    border-bottom: 1px solid var(--dd-border);
    gap: 10px;
}
.dd-field:last-child { border-bottom: none; }
.dd-field > span {
    flex: 0 0 68px;
    color: var(--dd-muted);
    font-size: 14px;
    padding-top: 4px;
}
.dd-field input, .dd-field textarea {
    flex: 1;
    border: none;
    outline: none;
    font-size: 15px;
    color: var(--dd-text);
    background: transparent;
    font-family: inherit;
    padding: 4px 0;
    resize: none;
}
.dd-checkout-bar {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
    background: #2d221c;
    color: #fff;
    box-shadow: 0 -4px 16px rgba(0,0,0,.15);
}
.dd-checkout-bar .dd-cartbar-info { flex: 1; }

/* ================= 响应式适配 ================= */
@media (max-width: 380px) {
    .dd-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .dd-card-title { font-size: 14px; }
    .dd-card-price { font-size: 15px; }
    .dd-tab { padding: 6px 14px; font-size: 13px; }
}
@media (min-width: 720px) {
    .dd-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
    .dd-main, .dd-checkout { max-width: 1100px; margin: 0 auto; padding-left: 20px; padding-right: 20px; }
    .dd-detail { max-width: 800px; margin: 0 auto; }
    .dd-cartbar, .dd-checkout-bar, .dd-detail-bar {
        max-width: 1100px;
        margin: 0 auto;
        border-radius: 16px 16px 0 0;
    }
}
@media (min-width: 1200px) {
    .dd-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
}
/* ================= 购物车勾选 / 批量操作 ================= */
.dd-drawer-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-bottom: 1px solid var(--dd-border);
    background: #faf6f0;
}
.dd-all-check {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: var(--dd-text);
    cursor: pointer;
    user-select: none;
}
.dd-all-check input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--dd-gold);
    cursor: pointer;
    margin: 0;
}
.dd-batch-del {
    background: transparent;
    border: 1px solid var(--dd-border);
    border-radius: 16px;
    padding: 4px 12px;
    font-size: 13px;
    color: var(--dd-muted);
    cursor: pointer;
    transition: color .2s, border-color .2s;
}
.dd-batch-del:not(:disabled):hover {
    color: #c0392b;
    border-color: #c0392b;
}
.dd-batch-del:disabled {
    opacity: .4;
    cursor: not-allowed;
}

/* 购物车项：加一列复选框 */
.dd-ci {
    grid-template-columns: 24px 64px 1fr auto;
}
.dd-ci-check {
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.dd-ci-check input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--dd-gold);
    cursor: pointer;
    margin: 0;
}

/* 结算按钮禁用态 */
.dd-primary-btn:disabled,
.dd-cartbar-btn:disabled {
    opacity: .5;
    cursor: not-allowed !important;
}

/* 小屏微调 */
@media (max-width: 380px) {
    .dd-ci { grid-template-columns: 22px 56px 1fr auto; gap: 8px; }
    .dd-ci-img { width: 56px; height: 56px; }
    .dd-drawer-actions { padding: 8px 12px; }
    .dd-all-check { font-size: 13px; }
    .dd-batch-del { font-size: 12px; padding: 3px 10px; }
}