.pdp-body {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--wa-space-l);
}

.pdp-stage {
    --gap: var(--wa-space-s);
}

/* Stage frame. Aspect and top/bottom padding come from .pdp-stage inline
   vars that _pdp_stage.html computes from the actual rendered content —
   no space is reserved for a chip or an action row that isn't there. */
.pdp-stage-frame {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    display: grid;
    place-items: center;
    padding: var(--stage-pad-top, var(--wa-space-s))
             var(--wa-space-l)
             var(--stage-pad-bottom, var(--wa-space-s));
    background: var(--wa-color-surface-default);
    border: 1px solid var(--wa-color-surface-border);
    aspect-ratio: var(--tag-aspect, 1.333);
    max-height: 60vh;
}
.pdp-stage:not([data-scene="studio"]) .pdp-stage-frame {
    aspect-ratio: 4 / 3;
}
.pdp-deck {
    position: relative;
    width: 100%;
    max-width: 520px;
}
.pdp-deck-front,
.pdp-deck-back {
    width: 100%;
}
.pdp-deck svg {
    display: block;
    width: 100%;
    max-width: 780px;
    height: auto;
}
/* Portrait labels (taller than wide) render in a square frame (per
   _pdp_stage.html's --tag-aspect clamp), which leaves the SVG too tall to
   fit at full deck width. Cap the deck width for portraits so the SVG
   shrinks proportionally — keeps deck-front/deck-back overlap intact since
   we don't touch deck/front/back heights. */
.pdp-stage[data-orientation="portrait"] .pdp-deck {
    max-width: 320px;
}
.pdp-deck-front {
    position: relative;
    z-index: 3;
    filter: drop-shadow(0 12px 40px rgba(0, 0, 0, 0.22));
}
.pdp-deck-back {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
    opacity: 0.5;
    pointer-events: none;
}
.pdp-deck-back-a { transform: rotate(-9deg) translate(-36px, 8px); }
.pdp-deck-back-b { transform: rotate(7deg)  translate(36px, 10px); }

/* In-flight feedback for picker commits whose responses re-render the stage.
   Triggered by hx-indicator=".preview-area" on font tile clicks + emoji slot
   commits. transition-delay on the dip-in side means fast responses (under
   the threshold) show no visible change at all — the .htmx-request class is
   added and removed before the transition starts. Slower responses fade to a
   subtle dim. The transition lives only on the .htmx-request rule, so when
   the class is removed (response landed) the opacity snaps back instantly. */
.preview-area.htmx-request {
    opacity: 0.6;
    transition: opacity 200ms ease 200ms;
}

/* Fanned-preview chain. WebKit grid auto-track sizing collapses to 0 when the
   only in-flow child has no intrinsic width — which the height-100% +
   aspect-ratio chain didn't provide. Force the column to 1fr, give the deck
   an explicit square aspect, and propagate width: 100% / height: 100% down
   instead of relying on percentage + aspect-ratio at the leaf. */
.pdp-stage-frame:has(.fanned-preview) {
    grid-template-columns: 1fr;
}
.pdp-deck:has(.fanned-preview) {
    place-self: stretch;
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
}
.pdp-deck-front:has(.fanned-preview),
#preview-area:has(.fanned-preview) {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.fanned-preview {
    position: relative;
    width: 100%;
    height: 100%;
}
.fanned-preview-tile {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 72%;
    aspect-ratio: 1 / 1;
    transform-origin: 50% 180%;
    transform: translate(-50%, -50%)
               rotate(calc((var(--i) - (var(--n) - 1) / 2) * 2.6deg));
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.10));
}
.fanned-preview-tile svg {
    display: block;
    width: 100%;
    height: 100%;
}
.fanned-preview-tile:last-child {
    transform: translate(-50%, -50%);
    z-index: 100;
    filter: drop-shadow(0 10px 22px rgba(0, 0, 0, 0.24));
}

.pdp-product-name {
    font-family: var(--wa-font-family-longform);
    font-size: var(--wa-font-size-2xl);
    margin: 0;
    line-height: 1.1;
}
.pdp-brand-sub {
    margin: var(--wa-space-2xs) 0 0;
    color: var(--wa-color-text-quiet);
    font-size: var(--wa-font-size-s);
}
.pdp-brand-sub a,
.pdp-brand-sub-link {
    color: var(--wa-color-text-link);
    text-decoration: underline;
}
.pdp-brand-sub-link {
    background: none;
    border: 0;
    padding: 0;
    font: inherit;
    cursor: pointer;
}

.pdp-story p {
    margin: 0 0 var(--wa-space-s);
    line-height: 1.55;
    color: var(--wa-color-text-normal);
    font-size: var(--wa-font-size-s);
}
.pdp-story p:last-child { margin-bottom: 0; }

.pdp-label {
    display: block;
    font-size: var(--wa-font-size-xs);
    font-weight: 600;
    color: var(--wa-color-text-quiet);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin-bottom: var(--wa-space-2xs);
}

.pdp-buy-footnote {
    font-size: var(--wa-font-size-xs);
    text-align: center;
    display: block;
    margin-top: var(--wa-space-2xs);
}

/* wa-badge sized down to feel like pills. */
.pdp-spec-tags wa-badge {
    font-size: var(--wa-font-size-xs);
}

/* Tweak only documented props; let WA handle bg/color. */
wa-popover {
    --arrow-size: 0.75rem;
    --max-width: 22rem;
}

wa-card.customize-dialog-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 160px;
    margin-bottom: var(--wa-space-m);
}
.customize-dialog-preview svg {
    width: 100%;
    max-width: 400px;
    height: auto;
    filter: drop-shadow(0 4px 14px rgba(0, 0, 0, 0.18));
}
wa-dialog#customize-dialog wa-tab-panel,
wa-drawer#customize-drawer wa-tab-panel {
    --padding: var(--wa-space-m) 0;
}

/* Sticky preview keeps the tag visible while the user types under the iOS
   keyboard — the centered wa-dialog version got clipped off the top edge. */
wa-drawer#customize-drawer {
    /* dvh tracks iOS's visual viewport (keyboard-adjusted); vh would leave
       the drawer taller than the visible area when the keyboard is up,
       pushing the sticky preview off-screen. */
    --size: 85dvh;
    --spacing: var(--wa-space-s);
}
wa-drawer#customize-drawer::part(dialog) {
    border-radius: var(--wa-border-radius-l) var(--wa-border-radius-l) 0 0;
}
wa-drawer#customize-drawer::part(body) {
    padding-top: 0;
}
wa-drawer#customize-drawer .customize-dialog-preview {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--wa-color-surface-raised);
    /* Bleed past --spacing so the sticky surface covers edge-to-edge. */
    margin-inline: calc(-1 * var(--wa-space-s));
    padding: var(--wa-space-2xs) var(--wa-space-s);
    margin-bottom: var(--wa-space-s);
    min-height: 110px;
    border: none;
    border-bottom: 1px solid var(--wa-color-surface-border);
    border-radius: 0;
}
wa-drawer#customize-drawer .customize-dialog-preview svg {
    max-width: 280px;
}

.qty-preview-card {
    display: grid;
    place-items: center;
    padding: var(--wa-space-m);
    margin-bottom: var(--wa-space-xl);
}
.qty-preview-card svg {
    /* Explicit width keeps Safari from collapsing the inline SVG to 0 when
       the source markup omits width/height attributes — Safari falls back
       to the SVG's intrinsic 0×0 viewport otherwise. */
    width: 100%;
    max-width: 18rem;
    height: auto;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.12));
}

.qty-row {
    display: flex;
    align-items: center;
    width: 100%;
    gap: var(--wa-space-s);
}
.qty-row-label {
    flex: 1;
    font-weight: 600;
}
.qty-row-price {
    font-weight: 700;
    min-width: 4.5rem;
    text-align: right;
}

.qty-roll-count {
    margin-top: var(--wa-space-l);
    padding-top: var(--wa-space-m);
    border-top: 1px solid var(--wa-color-surface-border);
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--wa-space-m);
    flex-wrap: wrap;
}
.qty-roll-count wa-number-input {
    /* Width below ~10rem clips the value: ~70px goes to the steppers, then
       ~28px to the input's own padding, leaving 0 for two-digit content.
       12rem keeps the field compact without clipping. */
    width: 12rem;
    flex: none;
}
.qty-total-row {
    text-align: right;
}
.qty-total-row strong {
    display: block;
    font-size: var(--wa-font-size-m);
}
.qty-total-row .qty-total-meta {
    color: var(--wa-color-text-quiet);
    font-size: var(--wa-font-size-s);
}

.pdp-scene-carousel {
    --aspect-ratio: 4 / 3;
    --slide-gap: 0px;
    position: absolute;
    inset: 0;
    z-index: 0;
}
.pdp-scene-carousel::part(base),
.pdp-scene-carousel::part(scroll-container) {
    height: 100%;
}
.pdp-scene-carousel wa-carousel-item {
    position: relative;
    overflow: hidden;
}
.pdp-scene-carousel wa-carousel-item img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Per-scene crop — dynamic zoom anchored at the label position. */
wa-carousel-item[data-scene="workbench"] img {
    transform-origin: var(--left-workbench) var(--top-workbench);
    transform: scale(var(--zoom-workbench));
}
wa-carousel-item[data-scene="macbook"] img {
    transform-origin: var(--left-macbook) var(--top-macbook);
    transform: scale(var(--zoom-macbook));
}

/* Per-scene CSS vars are set on the stage. Scene swaps snap rather than
 * animate — width transitions caused a distracting zoom-down. */
.pdp-stage[data-scene="workbench"] .pdp-deck,
.pdp-stage[data-scene="macbook"] .pdp-deck {
    position: absolute;
    z-index: 1;
    max-width: none;
}
.pdp-stage[data-scene="workbench"] .pdp-deck {
    top: var(--top-workbench);
    left: var(--left-workbench);
    width: var(--w-workbench);
    transform: var(--xf-workbench);
}
.pdp-stage[data-scene="macbook"] .pdp-deck {
    top: var(--top-macbook);
    left: var(--left-macbook);
    width: var(--w-macbook);
    transform: var(--xf-macbook);
}
.pdp-stage:not([data-scene="studio"]) .pdp-deck-back {
    display: none;
}

.pdp-scene-chip {
    width: 96px;
    height: 72px;
    border-radius: var(--wa-border-radius-m);
    border: 2px solid var(--wa-color-surface-border);
    background: var(--chip-bg, var(--wa-color-surface-raised)) center / cover no-repeat;
    cursor: pointer;
    padding: 0;
    display: grid;
    place-items: center;
    color: var(--wa-color-text-quiet);
    font-size: 1.25rem;
    line-height: 1;
}
.pdp-scene-chip:hover {
    border-color: var(--wa-color-brand-border-normal);
}
.pdp-scene-chip[aria-pressed="true"] {
    border-color: var(--wa-color-brand-border-normal);
    outline: 2px solid var(--wa-color-brand-border-normal);
    outline-offset: 1px;
}
.pdp-scene-chip:focus-visible {
    outline: 3px solid var(--wa-color-brand-border-normal);
    outline-offset: 2px;
}

.scheme-swatches {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: var(--wa-space-s) var(--wa-space-l);
}
.scheme-swatches__group {
    display: flex;
    flex-direction: column;
    gap: var(--wa-space-3xs);
}
.scheme-swatches__label {
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--wa-color-text-quiet);
}
.scheme-swatches__row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.crayon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--crayon-bg);
    border: 1.5px solid color-mix(in oklab, var(--crayon-border) 40%, transparent);
    cursor: pointer;
    transition: transform var(--wa-transition-normal) ease, box-shadow var(--wa-transition-normal) ease;
    padding: 0;
}
.crayon:hover {
    transform: scale(1.2);
    box-shadow: var(--wa-shadow-m);
    z-index: 1;
}
.scheme-swatches .crayon.selected {
    box-shadow: inset 0 0 0 3px var(--crayon-border);
    transform: scale(1.15);
    z-index: 1;
}
.scheme-swatches .crayon.selected:hover {
    transform: scale(1.25);
}
.scheme-swatches .crayon:focus-visible {
    outline: 3px solid var(--wa-color-brand-fill-loud);
    outline-offset: 3px;
    z-index: 1;
}

.text-color-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: var(--wa-space-s);
    background: var(--text-swatch-bg, var(--wa-color-surface-lowered));
    border-radius: var(--wa-border-radius-m);
}

.text-crayon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--crayon-bg);
    border: 2px solid color-mix(in oklab, var(--crayon-bg) 70%, transparent);
    cursor: pointer;
    transition: transform var(--wa-transition-normal) ease, box-shadow var(--wa-transition-normal) ease;
    padding: 0;
}
.text-crayon:hover {
    transform: scale(1.2);
    box-shadow: var(--wa-shadow-m);
    z-index: 1;
}
.text-crayon.selected {
    outline: 3px solid var(--wa-color-brand-fill-loud);
    outline-offset: 2px;
    transform: scale(1.15);
}

/* wa-frame is position:relative, so absolute resolves against it. */
.pdp-starter-chip {
    position: absolute;
    top: var(--wa-space-s);
    left: var(--wa-space-s);
    z-index: 3;
    pointer-events: none;
}

/* Stage frame + action pills share this positioning context. Pills are
   absolute-bottom-left of the wrap on desktop (overlaying the frame), and
   static — flowing below the frame — on mobile. */
.pdp-stage-frame-wrap {
    position: relative;
}

.pdp-stage-actions {
    position: absolute;
    bottom: var(--wa-space-s);
    left: var(--wa-space-s);
    z-index: 200;
}
/* Suppress :focus on click; keep :focus-visible for keyboard. */
.pdp-stage-actions wa-button::part(base):focus {
    outline: none;
    box-shadow: none;
}
.pdp-stage-actions wa-button::part(base):focus-visible {
    outline: 2px solid var(--wa-color-brand-border-loud);
    outline-offset: 2px;
}

/* Hide the entire tab nav (triggers + separator track) when scoped. */
#customize-dialog[data-scope]:not([data-scope="all"]) wa-tab-group::part(nav),
#customize-drawer[data-scope]:not([data-scope="all"]) wa-tab-group::part(nav) {
    display: none;
}
#customize-dialog[data-scope]:not([data-scope="all"]) wa-tab-group,
#customize-drawer[data-scope]:not([data-scope="all"]) wa-tab-group {
    --track-width: 0;
}

.pdp-mobile-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    padding: var(--wa-space-s);
    padding-bottom: calc(var(--wa-space-s) + env(safe-area-inset-bottom, 0px));
    background: var(--wa-color-surface-raised);
    border-top: 1px solid var(--wa-color-surface-border);
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.06);
}
.pdp-mobile-bar-cta,
.pdp-mobile-bar-cta::part(base) {
    width: 100%;
}

wa-page[view='mobile'] .pdp-body {
    padding-bottom: calc(var(--wa-space-3xl) + var(--wa-space-l) + env(safe-area-inset-bottom, 0px));
}

wa-page[view='mobile'] .pdp-swatch-row,
wa-page[view='mobile'] #pdp-actions {
    display: none;
}

wa-page[view='mobile'] .pdp-stage-actions {
    position: static;
    justify-content: center;
    margin-top: var(--wa-space-xs);
}

wa-page[view='mobile'] .pdp-stage-frame {
    padding: var(--stage-pad-top, var(--wa-space-s))
             var(--wa-space-s)
             var(--wa-space-s);
    max-height: 38vh;
    min-height: 180px;
}

wa-page[view='mobile'] .pdp-stage {
    --gap: var(--wa-space-3xs);
}
wa-page[view='mobile'] .pdp-scene-chips {
    --gap: var(--wa-space-2xs);
}
wa-page[view='mobile'] .pdp-scene-chip {
    width: 56px;
    height: 42px;
}
