:root {
    --vp-surface: #ffffff;
    --vp-surface-2: #f3ede2;
    --vp-border: #e6ddd0;
    --vp-ink-muted: var(--bs-secondary-color, #8c8071);
}

.vp {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 24px;
}

.vp--full {
    display: grid;
    grid-template-columns: 1fr 320px;
    grid-template-areas:
        "toolbar toolbar"
        "families families"
        "body selection";
    column-gap: 28px;
    row-gap: 16px;
    align-items: start;
}

.vp--full .vp-toolbar { grid-area: toolbar; }
.vp--full .vp-colour-strip { grid-area: families; }
.vp--full .vp-body { grid-area: body; }
.vp--full .vp-selection { grid-area: selection; position: sticky; top: 16px; }

@media (max-width: 991px) {
    .vp--full {
        grid-template-columns: 1fr;
        grid-template-areas: "toolbar" "families" "body" "selection";
    }
    .vp--full .vp-selection { position: static; }
}

.vp-heading {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.vp-title {
    font-weight: 700;
    font-size: 19px;
}

.vp-count {
    font-size: 13px;
    color: var(--vp-ink-muted);
}

.vp-toolbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.vp-search {
    max-width: 260px;
    margin-left: auto;
    border-radius: 999px;
    padding: 9px 16px 9px 36px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23999' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001q.044.06.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1 1 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 12px center;
}

/* Colours component — a filter strip of family swatches (not the tag grid itself) */
.vp-colour-strip {
    display: flex;
    gap: 14px;
    overflow-x: auto;
    padding: 2px 2px 6px;
    scrollbar-width: thin;
}

.vp-colour-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px;
    flex-shrink: 0;
    width: 50px;
}

.vp-colour-dot {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid transparent;
    box-shadow: 0 0 0 1px var(--vp-border) inset;
}

.vp-colour-item[aria-pressed="true"] .vp-colour-dot {
    border-color: var(--bs-primary, #8b5e34);
    box-shadow: 0 0 0 2px var(--vp-surface), 0 0 0 3px var(--bs-primary, #8b5e34);
}

.vp-colour-item span:last-child {
    font-size: 10px;
    color: var(--vp-ink-muted);
    text-align: center;
    line-height: 1.2;
}

.vp-colour-item[aria-pressed="true"] span:last-child {
    color: inherit;
    font-weight: 600;
}

.vp-colour-dot--all {
    background: conic-gradient(from 90deg, #d94f4f, #d99522, #d3cc3c, #6fae3e, #2fa79a, #3b7fd1, #8a5fc9, #cd5fa8, #d94f4f);
}

.vp-body {
    max-height: 420px;
    overflow-y: auto;
    border: 1px solid var(--vp-border);
    border-radius: 12px;
    padding: 16px;
}

.vp--compact .vp-body {
    max-height: none;
    overflow-y: visible;
    border: none;
    padding: 0;
}

.vp-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
    gap: 10px;
}

/* Tag component — the app's own pattern: colour IS the chip background, code is the
   text on top of it (not a separate swatch + label pair). */
.vp-chip {
    position: relative;
    height: 44px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 12.5px;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08) inset;
    background: var(--vp-surface-2);
    color: inherit;
}

.vp-chip[aria-pressed="true"] {
    outline: 3px solid var(--bs-body-color, #241d16);
    outline-offset: 2px;
}

.vp-chip--none {
    background: var(--vp-surface-2);
    color: var(--vp-ink-muted);
    box-shadow: 0 0 0 1px var(--vp-border) inset;
}

.vp-empty,
.vp-empty-selection {
    color: var(--vp-ink-muted);
    font-size: 13px;
    padding: 8px 0;
    text-align: center;
}

.vp-empty-selection {
    border: 1.5px dashed var(--vp-border);
    border-radius: 10px;
    padding: 22px 16px;
    line-height: 1.5;
}

/* Inline per-shade stepper on a selected chip (mobile) — pick, adjust and see the
   running total without leaving the grid. */
.vp-chip--stepper {
    height: auto;
    min-height: 44px;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    padding: 6px 4px;
    cursor: default;
}

.vp-chip-code { line-height: 1.15; }

.vp-chip-stepper-row {
    display: flex;
    align-items: center;
    gap: 5px;
    background: rgba(255, 255, 255, 0.28);
    border-radius: 999px;
    padding: 1px;
}

.vp-chip-stepper-row button {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.9);
    color: #241d16;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    font-weight: 700;
}

.vp-chip-stepper-row button:disabled { opacity: 0.4; cursor: not-allowed; }

.vp-chip-stepper-row span {
    min-width: 14px;
    text-align: center;
    font-size: 11px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* Desktop "Your selection" side panel */
.vp-selection {
    border: 1px solid var(--vp-border);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.vp-selection-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 700;
    font-size: 17px;
}

.vp-clear {
    background: none;
    border: none;
    color: var(--bs-primary, #8b5e34);
    font-size: 13px;
    cursor: pointer;
}

.vp-selection-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 260px;
    overflow-y: auto;
}

.vp-selection-row {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    align-items: center;
    gap: 10px;
}

.vp-swatch {
    display: inline-block;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    border: 1px solid var(--vp-border);
    flex-shrink: 0;
}

.vp-swatch--sm { width: 24px; height: 24px; }

.vp-swatch--none {
    background: repeating-linear-gradient(45deg, var(--vp-surface-2), var(--vp-surface-2) 3px, var(--vp-surface) 3px, var(--vp-surface) 6px);
}

.vp-selection-code {
    font-size: 13px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* QA-13: selected shade at/below the admin low-stock threshold */
.vp-selection-label {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.vp-low-stock {
    font-size: 11px;
    font-weight: 600;
    color: #b45309;
}

.vp-stepper {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--vp-border);
    border-radius: 7px;
    overflow: hidden;
}

.vp-stepper-btn {
    width: 22px;
    height: 22px;
    border: none;
    background: var(--vp-surface-2);
    color: inherit;
    cursor: pointer;
    font-size: 13px;
    line-height: 1;
}

.vp-stepper-qty {
    display: inline-block;
    min-width: 22px;
    text-align: center;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.vp-remove {
    background: none;
    border: none;
    color: var(--bs-danger, #b3261e);
    font-size: 17px;
    line-height: 1;
    cursor: pointer;
    padding: 0 2px;
}

.vp-summary {
    border-top: 1px solid var(--vp-border);
    padding-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.vp-summary-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: var(--vp-ink-muted);
}

.vp-summary-row--total {
    font-size: 19px;
    font-weight: 700;
    color: inherit;
    margin-top: 2px;
}

.vp-add-btn {
    width: 100%;
    border-radius: 10px;
    padding: 12px;
    font-weight: 600;
    font-size: 15px;
}

.vp-add-btn:disabled { opacity: 0.45; cursor: not-allowed; }

.vp-save-btn {
    width: 100%;
    border-radius: 10px;
    padding: 11px;
    font-weight: 500;
    font-size: 14px;
    background: var(--vp-surface);
    border: 1px solid var(--vp-border);
    color: inherit;
}

/* ============ Mobile-only chrome: bottom bar + review overlay ============ */

[data-vp-bottom-bar] {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.vp-stack-preview {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    background: var(--vp-surface-2);
    border: 1px solid var(--vp-border);
    border-radius: 12px;
    padding: 6px 10px 6px 6px;
    cursor: pointer;
    text-align: left;
}

.vp-stack-preview:disabled { cursor: default; opacity: 0.7; }

.vp-stack-swatches {
    position: relative;
    width: 40px;
    height: 30px;
    flex-shrink: 0;
}

.vp-stack-swatch {
    position: absolute;
    top: 0;
    width: 30px;
    height: 30px;
    border-radius: 7px;
    border: 2px solid var(--vp-surface-2);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.vp-stack-swatch:nth-child(1) { left: 10px; z-index: 2; }
.vp-stack-swatch:nth-child(2) { left: 0; z-index: 1; filter: brightness(0.94); }

.vp-stack-text {
    min-width: 0;
    flex: 1;
}

.vp-stack-price {
    font-weight: 700;
    font-size: 14.5px;
    font-variant-numeric: tabular-nums;
    display: block;
}

.vp-stack-sub {
    font-size: 10.5px;
    color: var(--vp-ink-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
}

.vp-stack-chevron {
    color: var(--vp-ink-muted);
    font-size: 11px;
    flex-shrink: 0;
    font-weight: 600;
}

.vp-bottom-actions {
    display: flex;
    gap: 8px;
}

.vp-buy-btn,
.vp-add-btn-bottom {
    flex: 1;
    border: none;
    border-radius: 10px;
    padding: 11px 8px;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
}

.vp-buy-btn { background: #e8963c; color: #fff; }
.vp-add-btn-bottom { background: var(--bs-primary, #8b5e34); color: #fff; }

.vp-buy-btn:disabled,
.vp-add-btn-bottom:disabled {
    background: var(--vp-surface-2);
    color: var(--vp-ink-muted);
    cursor: not-allowed;
}

/* Review overlay — appended to <body> (see wireCompactChrome in variant-picker.js), so it
   sits outside the sticky bar's transformed ancestor and position:fixed genuinely fixes to
   the viewport. Stops above the bottom bar (its `bottom` is set from JS to the bar's real
   height) rather than covering it, so Buy now / Add to cart stay usable while reviewing. */
.vp-review-overlay {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    top: 0;
    background: var(--vp-surface);
    z-index: 100000;
    padding: 18px 16px;
    overflow-y: auto;
    box-shadow: 0 -12px 24px rgba(0, 0, 0, 0.12);
}

.vp-review-overlay--open { display: block; }

.vp-review-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 700;
    font-size: 17px;
    margin-bottom: 14px;
}

.vp-review-close {
    background: var(--vp-surface-2);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 18px;
    color: var(--vp-ink-muted);
    cursor: pointer;
}

.vp-review-overlay .vp-selection { border: none; padding: 0; }

:focus-visible { outline: 2px solid var(--bs-body-color, #241d16); outline-offset: 2px; }

@media (prefers-reduced-motion: no-preference) {
    .vp-chip { transition: transform 0.08s ease; }
    .vp-chip:active { transform: scale(0.96); }
}

/* "You May Also Like" sidebar: compact horizontal strip on mobile/tablet instead of
   full-width stacked cards dominating the page — matches its role as a secondary,
   not primary, section relative to the product picker. */
@media (max-width: 991px) {
    .you-may-also-like-row {
        flex-wrap: nowrap !important;
        scrollbar-width: thin;
    }

    .you-may-also-like-card {
        flex: 0 0 220px !important;
        max-width: 220px;
    }
}

/* Count badge on a picked chip (full mode) */
.vp-chip-qty {
    position: absolute;
    top: -8px;
    right: -8px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 10px;
    background: var(--bs-body-color, #241d16);
    color: #fff;
    border: 1.5px solid var(--vp-surface);
    font-size: 11px;
    font-weight: 700;
    line-height: 17px;
    text-align: center;
    pointer-events: none;
}

/* ============ Phones, full mode: bottom bar + selection sheet (wireMobileTray) ============ */

.vp-mbar,
.vp-sheet,
.vp-sheet-backdrop { display: none; }

@media (max-width: 767px) {
    /* The page scrolls through the whole grid: an inner scroll box traps the swipe. */
    .vp--full .vp-body { max-height: none; overflow-y: visible; padding: 12px; }
    .vp--full .vp-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px 10px; padding: 6px 6px 0 0; }
    /* Only once wireMobileTray() has put the bar on the page (html.vp-has-mbar), so a
       stale cached script can never leave a phone without an Add to cart button. */
    html.vp-has-mbar .vp--full .vp-selection .vp-add-btn,
    html.vp-has-mbar .vp--full .vp-selection .vp-save-btn { display: none; }
    .vp--full .vp-selection-list { max-height: none; }

    .vp-mbar {
        display: flex;
        flex-direction: column;
        gap: 8px;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1040;
        background: var(--vp-surface);
        border-radius: 18px 18px 0 0;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.12);
        padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    }

    .vp-mbar-tray {
        display: flex;
        align-items: center;
        gap: 10px;
        width: 100%;
        background: var(--vp-surface-2);
        border: 1px solid var(--vp-border);
        border-radius: 12px;
        padding: 8px 12px;
        text-align: left;
        color: inherit;
    }
    .vp-mbar-tray[hidden], .vp-mbar-hint[hidden] { display: none; }

    .vp-mbar-swatches { display: flex; flex-shrink: 0; }
    .vp-mbar-swatches .vp-swatch { width: 26px; height: 26px; border: 2px solid var(--vp-surface-2); }
    .vp-mbar-swatches .vp-swatch + .vp-swatch { margin-left: -10px; }

    .vp-mbar-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
    .vp-mbar-count { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .vp-mbar-total { font-size: 14px; color: var(--bs-primary, #8b5e34); font-variant-numeric: tabular-nums; }
    .vp-mbar-view { font-weight: 700; font-size: 14px; color: var(--bs-primary, #8b5e34); flex-shrink: 0; }

    .vp-mbar-hint { font-size: 13px; color: var(--vp-ink-muted); padding: 2px 4px; }

    .vp-mbar .vp-buy-btn,
    .vp-mbar .vp-add-btn-bottom,
    .vp-sheet .vp-add-btn-bottom,
    .vp-keep-btn { padding: 12px 8px; font-size: 15px; }

    .vp-sheet-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 1050;
        background: rgba(0, 0, 0, 0.45);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.2s ease;
    }
    .vp-sheet-backdrop.vp-open { opacity: 1; pointer-events: auto; }

    .vp-sheet {
        display: flex;
        flex-direction: column;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1060;
        max-height: 80vh;
        max-height: 80dvh;
        background: var(--vp-surface);
        border-radius: 18px 18px 0 0;
        padding-bottom: env(safe-area-inset-bottom);
        transform: translateY(100%);
        transition: transform 0.25s ease;
        visibility: hidden;
    }
    .vp-sheet.vp-open { transform: translateY(0); visibility: visible; }

    .vp-sheet-grip { width: 40px; height: 4px; border-radius: 2px; background: var(--vp-border); margin: 8px auto 4px; }
    .vp-sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 16px 10px; border-bottom: 1px solid var(--vp-border); }
    .vp-sheet-title { font-weight: 700; font-size: 17px; }
    .vp-sheet-count { font-size: 13px; color: var(--vp-ink-muted); }
    .vp-sheet-list { overflow-y: auto; overscroll-behavior: contain; padding: 8px 16px; display: flex; flex-direction: column; gap: 4px; }
    .vp-sheet-foot { border-top: 1px solid var(--vp-border); padding: 10px 16px 12px; display: flex; flex-direction: column; gap: 10px; }

    /* Bigger touch targets in the list on phones (inline panel and sheet) */
    .vp-selection-row { padding: 4px 0; }
    .vp-selection-code { font-size: 15px; }
    .vp-stepper-btn { width: 36px; height: 34px; font-size: 18px; }
    .vp-stepper-btn:disabled { opacity: 0.35; }
    .vp-stepper-qty { min-width: 30px; font-size: 15px; }
    .vp-remove { font-size: 24px; padding: 0 6px; }

    .vp-keep-btn {
        flex: 1;
        border-radius: 10px;
        font-weight: 700;
        background: var(--vp-surface);
        border: 1px solid var(--bs-primary, #8b5e34);
        color: var(--bs-primary, #8b5e34);
    }

    html.vp-sheet-lock, html.vp-sheet-lock body { overflow: hidden; }
}
