/* ── Cart Modal ── */
    #cartModal .modal-dialog { max-width: 440px; }
    #cartModal .modal-content {
        border-radius: 16px;
        border: none;
        box-shadow: 0 8px 32px rgba(0,0,0,0.16);
    }
    #cartModal.fade .modal-dialog {
        transform: scale(0.92) translateY(-6px);
        transition: transform 0.28s cubic-bezier(0.34, 1.15, 0.64, 1);
    }
    #cartModal.fade.show .modal-dialog {
        transform: scale(1) translateY(0);
    }

    /* Header：商品圖 */
    #cartModalImg {
        width: 80px;
        height: 80px;
        object-fit: cover;
        border-radius: 8px;
    }

    /* Header：商品名稱（2行截斷） */
    #cartModalTitle {
        font-size: 1.1rem;
        line-height: 1.4;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    /* Header：價格列 */
    .tk-cart-price { min-height: 32px; }
    #cartModalSalePrice { color: #f26522; }

    /* 組合商品：內容物清單 */
    .tk-group-list {
        display: flex;
        flex-direction: column;
        gap: 6px;
        max-height: calc(4 * (0.82rem * 1.6) + 3 * 6px + 2px);
        overflow-y: auto;
        overscroll-behavior: contain;
        border: 1px solid #e5e7eb;
        border-radius: 8px;
        padding: 4px 6px;
    }
    .tk-group-list::-webkit-scrollbar { width: 3px; }
    .tk-group-list::-webkit-scrollbar-track { background: transparent; }
    .tk-group-list::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 99px; }
    .tk-group-item {
        display: flex;
        align-items: baseline;
        gap: 4px;
        font-size: 0.82rem;
        line-height: 1.6;
        flex-shrink: 0;
    }
    .tk-group-dot {
        color: #f26522;
        flex-shrink: 0;
        font-size: 0.9em;
    }

    /* 規格列表：flex wrap */
    #cartModalSpecList {
        display: flex;
        flex-wrap: wrap;
        gap: 10px;
    }

    /* 規格按鈕：依內容自動排列，按鈕內不換行 */
    #cartModal .tk-spec-btn {
        flex: 0 0 auto;
        padding: 8px 14px;
        border: 1.5px solid #e5e7eb;
        border-radius: 10px;
        background: #fff;
        font-size: 14px;
        font-weight: 400;
        cursor: pointer;
        transition: all 0.15s;
        text-align: center;
        white-space: nowrap;
    }
    #cartModal .tk-spec-btn.active {
        border-color: #f9a87a;
        background: #fff4ee;
        color: #c85000;
    }
    /* 缺貨規格按鈕：灰色文字、禁止點擊 */
    #cartModal .tk-spec-btn--oos {
        opacity: 0.4;
        cursor: not-allowed;
        color: #808080;
    }

    /* 數量控件外框 */
    .tk-qty-wrap {
        border: 1.5px solid #e5e7eb;
        border-radius: 99px;
    }

    /* 數量輸入框 */
    #cartModalQtyDisplay {
        width: 38px;
        height: 32px;
        border: none;
        outline: none;
        background: transparent;
        color: #111827;
        font-size: 16px;
        font-weight: 700;
        text-align: center;
        padding: 0;
        appearance: textfield;
        -moz-appearance: textfield;
    }
    #cartModalQtyDisplay::-webkit-outer-spin-button,
    #cartModalQtyDisplay::-webkit-inner-spin-button {
        -webkit-appearance: none;
        margin: 0;
    }

    /* 數量 +/- 按鈕 */
    .tk-qty-btn {
        width: 32px;
        height: 32px;
        border: none;
        background: transparent;
        font-size: 18px;
        line-height: 1;
        cursor: pointer;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        color: #374151;
    }
    #cartModalQtyMinus { border-radius: 50% 0 0 50%; }
    #cartModalQtyPlus  { border-radius: 0 50% 50% 0; }
    .tk-qty-btn:disabled {
        color: #808080;
        cursor: default;
    }

    /* 確認按鈕 */
    .tk-confirm-btn {
        width: 100%;
        height: 44px;
        border: none;
        border-radius: 10px;
        background: #FF7F32;
        color: #fff;
        font-size: 15px;
        font-weight: 700;
        cursor: pointer;
        transition: background 0.15s, border-color 0.15s, color 0.15s;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
    }
    .tk-confirm-btn:disabled {
        background: #d1d5db;
        cursor: default;
    }
    .tk-confirm-btn:not(:disabled):hover {
        background: #d95a1a;
    }
    /* 貨到通知模式：灰藍邊框風格，與商品卡片 btn-restock 一致 */
    .tk-confirm-btn[data-mode="restock"] {
        background: #f8fafc;
        color: #334155;
        border: 2px solid #64748b;
    }
    .tk-confirm-btn[data-mode="restock"]:not(:disabled):hover {
        background: #e2e8f0;
        border-color: #475569;
    }

    /* 已達庫存上限提示 */
    .tk-qty-hint { font-size: 12px; color: #f26522; }

    /* 保存期限 / 注意事項 */
    .tk-info-content { font-size: 12px; }
    .tk-notice-divider { border-bottom: 1px solid #e5e7eb; }
    #cartModalNoticeContent p { margin-bottom: 0.25rem; }
    /* 組合商品：逐筆列出各子商品保存期限 */
    .tk-cart-expiry-title { font-weight: 600; margin-bottom: 2px; }
    .tk-cart-expiry-row { line-height: 1.5; padding-left: 14px; }

    /* 貨到通知 / 加入購物車 Loading 遮罩 */
    .tk-loading-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        align-items: center;
        justify-content: center;
        z-index: 10001;
    }
    .tk-loading-overlay.is-visible { display: flex; }
    .tk-loading-spinner {
        width: 50px;
        height: 50px;
        border: 4px solid #f3f3f3;
        border-top-color: #007bff;
        border-radius: 50%;
        animation: tkOverlaySpin 1s linear infinite;
    }
    @keyframes tkOverlaySpin {
        to { transform: rotate(360deg); }
    }

    /* 數量滾輪選擇器 */
    .tk-qty-picker {
        position: fixed;
        inset: 0;
        display: flex;
        align-items: flex-end;
        justify-content: center;
        z-index: 1065;
        visibility: hidden;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.22s ease, visibility 0.22s ease;
    }
    .tk-qty-picker.is-open {
        visibility: visible;
        opacity: 1;
        pointer-events: auto;
    }
    .tk-qty-picker__backdrop {
        position: absolute;
        inset: 0;
        background: rgba(17, 24, 39, 0.42);
    }
    .tk-qty-picker__sheet {
        position: relative;
        width: min(100%, 440px);
        background: #fff;
        border-radius: 18px 18px 0 0;
        transform: translateY(100%);
        transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
        box-shadow: 0 -10px 28px rgba(0, 0, 0, 0.18);
        overflow: hidden;
    }
    .tk-qty-picker.is-open .tk-qty-picker__sheet {
        transform: translateY(0);
    }
    .tk-qty-picker__header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        padding: 14px 16px 10px;
        border-bottom: 1px solid #f3f4f6;
    }
    .tk-qty-picker__title {
        font-size: 15px;
        font-weight: 700;
        color: #111827;
    }
    .tk-qty-picker__action {
        border: none;
        background: transparent;
        padding: 6px 4px;
        font-size: 14px;
        font-weight: 600;
    }
    .tk-qty-picker__action.is-cancel {
        color: #6b7280;
    }
    .tk-qty-picker__action.is-confirm {
        color: #f26522;
    }
    .tk-qty-picker__body {
        position: relative;
        height: 200px;
        overflow: hidden;
    }
    .tk-qty-picker__wheel {
        height: 100%;
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: y mandatory;
        scrollbar-width: none;
        overflow-x: hidden;
    }
    .tk-qty-picker__wheel::-webkit-scrollbar {
        display: none;
    }
    .tk-qty-picker__spacer {
        height: 80px;
        flex-shrink: 0;
        pointer-events: none;
    }
    .tk-qty-picker__item {
        display: block;
        width: 100%;
        height: 40px;
        border: none;
        background: transparent;
        color: #6b7280;
        font-size: 24px;
        font-weight: 500;
        text-align: center;
        scroll-snap-align: center;
        transition: color 0.16s ease, transform 0.16s ease, font-weight 0.16s ease;
    }
    .tk-qty-picker__item.is-active {
        color: #111827;
        font-weight: 700;
        transform: scale(1.04);
    }
    .tk-qty-picker__highlight {
        position: absolute;
        top: 50%;
        left: 16px;
        right: 16px;
        height: 40px;
        transform: translateY(-50%);
        border-top: 1px solid #e5e7eb;
        border-bottom: 1px solid #e5e7eb;
        border-radius: 10px;
        background: rgba(249, 250, 251, 0.85);
        pointer-events: none;
    }
    #cartModal.qty-wheel-open {
        padding-bottom: 35px !important;
    }

    /* 手機版：底部滑出 */
    @media (max-width: 767px) {
        #cartModal {
            align-items: flex-end;
            padding: 0 0 10px !important;
        }
        #cartModal .modal-dialog {
            margin: 0;
            width: 100%;
            max-width: 100%;
            transform: translateY(110%);
            transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1) !important;
        }
        #cartModal.fade.show .modal-dialog {
            transform: translateY(0) !important;
        }
        #cartModal .modal-content {
            border-radius: 16px;
            max-height: 90dvh;
            overflow-y: auto;
        }
        .tk-qty-picker__sheet {
            width: 100%;
        }
    }

    /* ── 觸控裝置：停用 :hover（桌機不受影響）── */
    @media (hover: none) {
        .tk-confirm-btn:not(:disabled):hover { background: #FF7F32; }
        .tk-confirm-btn[data-mode="restock"]:not(:disabled):hover {
            background: #f8fafc;
            border-color: #64748b;
            color: #334155;
        }
    }
