/* Geometry and motion belong to the format. Shadows take their ink from the palette. */
[data-format] {
  --ink: color-mix(in srgb, var(--bg) 80%, black);
  --halo: color-mix(in srgb, var(--accent) 32%, transparent);
}
.format-preview[data-format="gallery"] {
  --corner: 16px; --control: 9px; --edge: 1px;
  --rest: 0 7px 20px #0002; --hover: 0 15px 30px #0005; --press: inset 0 1px 3px #0004;
  --lift: translateY(-3px); --push: translateY(1px); --speed: 180ms; --title: Georgia, serif;
}
[data-format="editorial"] {
  --corner: 0; --control: 2px; --edge: 1px;
  --rest: 0 1px var(--line); --hover: 0 3px var(--accent); --press: inset 0 -3px var(--accent);
  --lift: none; --push: translateY(1px); --speed: 160ms; --title: Georgia, 'Times New Roman', serif;
}
[data-format="cushion"] {
  --corner: 30px; --control: 999px; --edge: 1px;
  --rest: 0 10px 25px -8px var(--ink), inset 0 1px #fff2;
  --hover: 0 18px 36px -9px var(--ink), 0 0 16px var(--halo); --press: inset 0 3px 8px var(--ink);
  --lift: translateY(-4px); --push: scale(.97); --speed: 220ms; --title: ui-rounded, 'Trebuchet MS', sans-serif;
}
[data-format="poster"] {
  --corner: 3px; --control: 3px; --edge: 2px;
  --rest: 4px 4px var(--accent); --hover: 7px 7px var(--accent); --press: 0 0 var(--accent);
  --lift: translate(-2px, -2px); --push: translate(3px, 3px); --speed: 90ms; --title: Impact, 'Arial Black', sans-serif;
}
[data-format="index"] {
  --corner: 5px; --control: 4px; --edge: 1px;
  --rest: inset 2px 0 var(--line); --hover: inset 5px 0 var(--accent); --press: inset 8px 0 var(--accent);
  --lift: translateX(2px); --push: translateX(4px); --speed: 115ms; --title: ui-monospace, Consolas, monospace;
}
[data-format="marquee"] {
  --corner: 14px; --control: 7px; --edge: 1px;
  --rest: 0 12px 24px -8px var(--ink); --hover: 0 0 0 1px var(--accent), 0 0 24px var(--halo);
  --press: inset 0 0 18px var(--halo), 0 0 4px var(--accent);
  --lift: scale(1.012); --push: scale(.99); --speed: 300ms; --title: 'Arial Narrow', 'Segoe UI', sans-serif;
}

/* Print, frame, directory and feature finishes. */
[data-format="print-broadsheet"] {
  --corner: 0; --control: 0; --edge: 1px; --title: Georgia, 'Times New Roman', serif;
  --rest: 0 2px var(--line);
  --hover: 0 5px var(--accent);
  --press: inset 0 -3px var(--accent);
  --lift: none; --push: translateY(1px); --speed: 160ms;
}
[data-format="print-cover"] {
  --corner: 2px; --control: 1px; --edge: 1px; --title: Impact, 'Arial Black', sans-serif;
  --rest: 2px 3px 0 var(--ink);
  --hover: 3px 8px 0 var(--ink);
  --press: inset 0 0 0 2px var(--accent);
  --lift: translateY(-3px) rotate(-.4deg); --push: scale(.985); --speed: 210ms;
}
[data-format="print-journal"] {
  --corner: 3px; --control: 5px; --edge: 1px; --title: Georgia, 'Times New Roman', serif;
  --rest: inset 4px 0 var(--line), 0 2px 6px var(--ink);
  --hover: inset 6px 0 var(--accent), 0 3px 8px var(--ink);
  --press: inset 8px 0 var(--accent);
  --lift: translateX(2px); --push: translateX(1px); --speed: 170ms;
}
[data-format="print-proof"] {
  --corner: 0; --control: 0; --edge: 1px; --title: ui-monospace, Consolas, monospace;
  --rest: 0 0 0 1px var(--line);
  --hover: 0 0 0 3px var(--accent);
  --press: inset 0 0 0 3px var(--accent);
  --lift: scale(1.012); --push: scale(.98); --speed: 100ms;
}
[data-format="print-letter"] {
  --corner: 2px; --control: 2px; --edge: 3px; --title: Georgia, 'Times New Roman', serif;
  --rest: inset 0 0 0 1px var(--line), 0 2px 0 var(--line);
  --hover: 0 2px 0 var(--accent), 0 5px 9px var(--ink);
  --press: inset 0 2px 4px var(--ink);
  --lift: translateY(-1px); --push: translateY(2px); --speed: 140ms;
}
[data-format="print-zine"] {
  --corner: 0; --control: 0; --edge: 2px; --title: Impact, 'Arial Black', sans-serif;
  --rest: 3px 2px var(--line), 5px 4px var(--ink);
  --hover: 4px 3px var(--accent), 7px 6px var(--ink);
  --press: 1px 1px var(--accent);
  --lift: rotate(-.65deg); --push: rotate(.3deg) scale(.98); --speed: 95ms;
}
[data-format="frame-mat"] {
  --corner: 3px; --control: 4px; --edge: 1px; --title: Georgia, 'Times New Roman', serif;
  --rest: 0 6px 16px -6px var(--ink);
  --hover: 0 12px 24px -7px var(--ink);
  --press: inset 0 1px 5px var(--ink);
  --lift: translateY(-2px); --push: scale(.992); --speed: 240ms;
}
[data-format="frame-instant"] {
  --corner: 2px; --control: 3px; --edge: 1px; --title: 'Trebuchet MS', sans-serif;
  --rest: 0 3px 4px var(--ink);
  --hover: 2px 8px 8px var(--ink);
  --press: 0 1px 1px var(--ink);
  --lift: rotate(-1deg) translateY(-2px); --push: rotate(.5deg); --speed: 190ms;
}
[data-format="frame-arch"] {
  --corner: 24px; --control: 999px; --edge: 1px; --title: Georgia, 'Times New Roman', serif;
  --rest: 0 6px 18px -6px var(--halo);
  --hover: 0 12px 24px -5px var(--halo);
  --press: inset 0 2px 7px var(--halo);
  --lift: translateY(-4px); --push: scale(.965); --speed: 230ms;
}
[data-format="frame-record"] {
  --corner: 4px; --control: 999px; --edge: 1px; --title: ui-monospace, Consolas, monospace;
  --rest: inset 0 0 0 2px var(--line);
  --hover: inset 0 0 0 2px var(--accent), 0 6px 12px var(--ink);
  --press: inset 0 0 0 4px var(--accent);
  --lift: rotate(.75deg); --push: scale(.975); --speed: 180ms;
}
[data-format="frame-ticket"] {
  --corner: 10px; --control: 6px; --edge: 1px; --title: ui-monospace, Consolas, monospace;
  --rest: 2px 0 var(--line);
  --hover: 5px 0 var(--accent);
  --press: inset -3px 0 var(--accent);
  --lift: translateX(-2px); --push: translateX(1px); --speed: 120ms;
}
[data-format="frame-slide"] {
  --corner: 8px; --control: 4px; --edge: 2px; --title: ui-monospace, Consolas, monospace;
  --rest: inset 0 0 0 3px var(--line), 0 2px var(--ink);
  --hover: inset 0 0 0 3px var(--accent), 0 4px var(--ink);
  --press: inset 0 0 0 5px var(--line);
  --lift: translateY(-2px); --push: translateY(1px); --speed: 130ms;
}
[data-format="list-ledger"] {
  --corner: 0; --control: 2px; --edge: 1px; --title: ui-monospace, Consolas, monospace;
  --rest: 0 1px var(--line), 0 3px var(--line);
  --hover: 0 2px var(--accent), 0 4px var(--line);
  --press: inset 0 -2px var(--accent);
  --lift: none; --push: translateY(1px); --speed: 105ms;
}
[data-format="list-timeline"] {
  --corner: 10px; --control: 20px; --edge: 1px; --title: 'Segoe UI', sans-serif;
  --rest: -3px 0 var(--line);
  --hover: -6px 0 var(--accent);
  --press: inset 3px 0 var(--accent);
  --lift: translateX(3px); --push: translateX(1px); --speed: 180ms;
}
[data-format="list-spread"] {
  --corner: 0; --control: 3px; --edge: 1px; --title: Georgia, 'Times New Roman', serif;
  --rest: 0 3px 8px -4px var(--ink);
  --hover: 0 9px 16px -4px var(--ink);
  --press: inset 0 -2px 5px var(--ink);
  --lift: translateY(-2px); --push: scale(.99); --speed: 220ms;
}
[data-format="list-dossier"] {
  --corner: 6px; --control: 3px; --edge: 2px; --title: ui-monospace, Consolas, monospace;
  --rest: 3px 2px var(--line);
  --hover: 5px 4px var(--accent);
  --press: inset 2px 1px var(--line);
  --lift: translate(-2px, -1px); --push: translate(2px, 1px); --speed: 115ms;
}
[data-format="list-pill"] {
  --corner: 60px; --control: 999px; --edge: 1px; --title: 'Trebuchet MS', sans-serif;
  --rest: 0 3px 10px -3px var(--ink);
  --hover: 0 5px 14px var(--halo);
  --press: inset 1px 2px 6px var(--ink);
  --lift: translateX(2px) scale(1.005); --push: scale(.965); --speed: 200ms;
}
[data-format="list-ribbon"] {
  --corner: 2px; --control: 2px; --edge: 1px; --title: 'Segoe UI', sans-serif;
  --rest: inset 5px 0 var(--accent);
  --hover: inset 9px 0 var(--accent), 0 2px var(--line);
  --press: inset 12px 0 var(--accent);
  --lift: translateX(1px); --push: translateX(3px); --speed: 130ms;
}
[data-format="show-panorama"] {
  --corner: 8px; --control: 20px; --edge: 1px; --title: 'Segoe UI', sans-serif;
  --rest: 0 8px 18px -10px var(--ink);
  --hover: 0 14px 24px -9px var(--ink);
  --press: inset 0 -4px var(--halo);
  --lift: translateY(-2px); --push: scale(.994); --speed: 250ms;
}
[data-format="show-mosaic"] {
  --corner: 6px; --control: 6px; --edge: 1px; --title: 'Trebuchet MS', sans-serif;
  --rest: 0 0 0 1px var(--line), 0 4px 9px -5px var(--ink);
  --hover: 0 0 0 2px var(--accent), 0 6px 12px var(--ink);
  --press: inset 0 0 0 2px var(--accent);
  --lift: scale(1.009); --push: scale(.984); --speed: 175ms;
}
[data-format="show-diptych"] {
  --corner: 0; --control: 2px; --edge: 1px; --title: Georgia, 'Times New Roman', serif;
  --rest: 1px 0 var(--line), 0 1px var(--line);
  --hover: 1px 0 var(--accent), 0 4px var(--accent);
  --press: inset 0 -1px var(--accent);
  --lift: translateY(-1px); --push: translateY(1px); --speed: 165ms;
}
[data-format="show-spotlight"] {
  --corner: 16px; --control: 999px; --edge: 1px; --title: 'Segoe UI', sans-serif;
  --rest: 0 6px 22px -8px var(--ink);
  --hover: 0 8px 30px -6px var(--halo);
  --press: inset 0 0 12px var(--halo);
  --lift: translateY(-3px) scale(1.005); --push: scale(.98); --speed: 260ms;
}
[data-format="show-film"] {
  --corner: 1px; --control: 2px; --edge: 2px; --title: ui-monospace, Consolas, monospace;
  --rest: inset 0 2px var(--line), inset 0 -2px var(--line);
  --hover: inset 0 3px var(--accent), inset 0 -3px var(--accent);
  --press: inset 0 4px var(--line), inset 0 -4px var(--line);
  --lift: translateX(-1px); --push: scale(.987); --speed: 140ms;
}
[data-format="show-postcard"] {
  --corner: 3px; --control: 5px; --edge: 1px; --title: Georgia, 'Times New Roman', serif;
  --rest: 1px 4px 5px -2px var(--ink);
  --hover: 3px 9px 12px -3px var(--ink);
  --press: inset 0 0 0 1px var(--accent);
  --lift: rotate(.6deg) translateY(-2px); --push: rotate(-.4deg); --speed: 215ms;
}

/* Apply the same surfaces to the public pages, gallery dialogs and studio. */
html[data-format]:not([data-format="gallery"]) {
  & :is(.auth-card, .product-card, .featured-card, .contact-card, .review-card, .guidelines,
    .featured-deals, .availability-section, .admin-box, .admin-product, .admin-mini-card,
    .contact-settings-card, dialog) {
    border-radius: var(--corner); border-width: var(--edge); box-shadow: var(--rest);
  }
  & :is(.product-card .card-media, .admin-thumb) { border-radius: 0; }
  & :is(h1, h2, .card-copy h3, .brand > span:last-child) { font-family: var(--title); }
  & :is(.button, .icon-button, .table-button, .admin-tabs button, .availability-tab) {
    border-radius: var(--control);
  }
  & :is(.button, .icon-button) { box-shadow: var(--rest); }
  & :is(input:not([type=radio]):not([type=checkbox]), select, textarea) {
    border-radius: min(var(--corner), 16px);
  }
  & .product-card .card-media :is(img, video) { transform: none; }
}

/* Focus gets an explicit outline. A press also has feedback on touch screens. */
html[data-format="gallery"] :is(.button, .product-card, .featured-card, .contact-card-link, .icon-button, .availability-tab):not(:disabled):active {
  transform: translateY(1px); box-shadow: inset 0 2px 5px var(--ink), 0 0 0 1px var(--halo);
}
:is(html[data-format]:not([data-format="gallery"]), .format-preview) {
  & :is(.product-card, .featured-card, .contact-card-link, .button, .icon-button,
    .admin-tabs button, .availability-tab, .table-button, .preview-trigger) {
    transition: transform var(--speed) ease-out, box-shadow var(--speed) ease-out, border-color var(--speed);
  }
  @media (hover: hover) {
    & :is(.product-card, .featured-card, .contact-card-link, .button, .icon-button,
      .admin-tabs button, .availability-tab, .table-button, .preview-trigger):not(:disabled):hover {
      transform: var(--lift); box-shadow: var(--hover); border-color: var(--accent);
    }
  }
  & :is(button, a, summary):focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
  & :is(.product-card, .featured-card, .contact-card-link, .button, .icon-button,
    .admin-tabs button, .availability-tab, .table-button, .preview-trigger):not(:disabled):active {
    transform: var(--push); box-shadow: var(--press); border-color: var(--accent);
    transition-duration: 50ms;
  }
}

/* Each format changes the gallery composition as well as the control finish. */
html[data-format="editorial"] {
  & .gallery-grid { grid-template-columns: 1fr; gap: 32px; }
  & .gallery-grid .card-media { aspect-ratio: 16 / 9; }
  & .gallery-grid .card-copy { align-items: start; text-align: left; padding: 18px 22px; }
  & .gallery-grid .card-copy h3 { font-size: clamp(1.45rem, 3vw, 2rem); font-style: italic; }
  @media (min-width: 760px) { & .gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
}
html[data-format="cushion"] {
  & .gallery-grid { gap: clamp(18px, 3vw, 40px); }
  & .gallery-grid .card-media { width: calc(100% - 20px); margin: 10px 10px 0; aspect-ratio: 1; border-radius: 22px; }
  & .card-copy h3, & h1 { font-weight: 700; letter-spacing: -.04em; }
}
html[data-format="poster"] {
  & .gallery-grid { gap: 22px; }
  & .gallery-grid .card-media { aspect-ratio: 3 / 4; border-bottom: 2px solid var(--accent); }
  & :is(h1, h2, .card-copy h3) { text-transform: uppercase; letter-spacing: .025em; }
  & .gallery-grid .card-copy { align-items: start; text-align: left; }
  @media (min-width: 1050px) { & .gallery-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
}
html[data-format="index"] {
  & :is(.gallery-grid, .mini-grid) { grid-template-columns: 1fr; gap: 10px; }
  & :is(.gallery-grid, .mini-grid) .product-card {
    display: grid; grid-template-columns: clamp(88px, 20vw, 160px) minmax(0, 1fr); align-items: center;
    padding: 8px; gap: 14px;
  }
  & .product-card .card-media { aspect-ratio: 4 / 3; border-radius: 3px; }
  & .product-card .card-copy { align-items: start; text-align: left; padding: 6px 10px 6px 0; }
  & .product-card .card-copy p { margin: 0; }
  & .product-card .view-label { display: none; }
  @media (min-width: 1000px) { & .gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
}
html[data-format="marquee"] {
  & .gallery-grid { grid-template-columns: 1fr; gap: 20px; }
  & .gallery-grid .product-card { display: grid; isolation: isolate; }
  & .gallery-grid :is(.card-media, .card-copy) { grid-area: 1 / 1; }
  & .gallery-grid .card-media { height: 100%; min-height: 210px; aspect-ratio: 16 / 9; }
  & .gallery-grid .card-copy {
    position: relative; justify-content: end; align-items: start; text-align: left; padding: 24px;
    background: linear-gradient(0deg, #080911fc, #080911cf 42%, transparent 85%);
    color: #fff;
  }
  & .gallery-grid .card-copy p { margin: 0; color: #e1e3e7; }
  & .gallery-grid .card-copy h3 { font-size: clamp(1.4rem, 3vw, 2rem); font-weight: 650; }
  & .gallery-grid .view-label { display: none; }
  & .gallery-grid .new-badge { z-index: 3; }
  @media (min-width: 800px) { & .gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
  @media (hover: hover) and (prefers-reduced-motion: no-preference) {
    & .product-card:hover .card-media :is(img, video) { transform: scale(1.06); }
  }
}

/* Print layouts share left-hand captions. Each edition sets its own crop and grid. */
html[data-format^="print-"] {
  & .gallery-grid { gap: var(--gutter, 18px); }
  & .gallery-grid .card-media { aspect-ratio: var(--crop, 4/3); }
  & .gallery-grid .card-copy { align-items: start; text-align: left; padding: var(--caption, 16px); }
  @media (min-width: 900px) { & .gallery-grid { grid-template-columns: repeat(var(--columns, 3), minmax(0, 1fr)); } }
}
html[data-format="print-broadsheet"] {
  --gutter: 10px; --crop: 3/2;
  & .gallery-grid .card-copy { border-top: 3px double var(--line); }
  & .gallery-grid .product-card:first-child h3 { font-size: clamp(1.5rem, 4vw, 2.6rem); }
  @media (min-width: 650px) { & .gallery-grid .product-card:first-child { grid-column: span 2; } }
}
html[data-format="print-cover"] {
  --crop: 3/4; --columns: 4; --gutter: 14px; --caption: 14px;
  & .card-copy h3 { font-size: clamp(1.2rem, 3vw, 1.8rem); text-transform: uppercase; line-height: 1.02; }
}
html[data-format="print-journal"] {
  --crop: 5/3; --columns: 2; --gutter: 26px;
  & .gallery-grid .product-card { padding: 14px 12px 0 20px; }
  & .gallery-grid .card-copy { border-left: 1px solid var(--accent); margin-top: 12px; }
}
html[data-format="print-proof"] {
  --crop: 1; --gutter: 6px; --columns: 5; --caption: 8px;
  & .gallery-grid h3 { font-size: .96rem; }
}
html[data-format="print-letter"] {
  --columns: 2; --crop: 2/1; --gutter: 24px;
  & .gallery-grid .product-card { border-style: double; padding: 8px; }
  & .gallery-grid .card-copy { align-items: center; text-align: center; }
  & .gallery-grid h3 { font-style: italic; }
}
html[data-format="print-zine"] {
  --crop: 1; --columns: 3; --gutter: 20px;
  & .gallery-grid .card-media { clip-path: polygon(0 0, calc(100% - 20px) 0, 100% 20px, 100% 100%, 0 100%); }
  & .gallery-grid .product-card:nth-child(even) .card-media { clip-path: polygon(20px 0, 100% 0, 100% 100%, 0 100%, 0 20px); }
  & .gallery-grid h3 { text-transform: uppercase; letter-spacing: .045em; }
}

/* Framed images sit inside the card, leaving room for mounts and borders. */
html[data-format^="frame-"] {
  & .gallery-grid { gap: clamp(16px, 2.4vw, 32px); }
  & .gallery-grid .product-card { padding: var(--mount, 12px); }
  & .gallery-grid .card-media { aspect-ratio: var(--crop, 1); border-radius: var(--aperture, 0); }
  & .gallery-grid .card-copy { padding: var(--caption, 14px 4px 4px); }
}
html[data-format="frame-mat"] {
  --mount: clamp(14px, 2.5vw, 32px); --crop: 5/4;
  & .card-media { outline: 1px solid var(--line); outline-offset: 4px; }
  & .gallery-grid h3 { font-weight: 400; }
}
html[data-format="frame-instant"] {
  --mount: 9px; --caption: 22px 4px 20px;
  & .gallery-grid .product-card { border-bottom-width: 7px; }
  & .gallery-grid h3 { font-style: italic; }
}
html[data-format="frame-arch"] {
  --crop: 4/5; --mount: 10px; --aperture: 50% 50% 8px 8px;
  & .gallery-grid .product-card { border-radius: 48% 48% 14px 14px; }
  & .gallery-grid .card-media .item-index { top: auto; bottom: 5px; }
}
html[data-format="frame-record"] {
  --aperture: 50%; --mount: clamp(10px, 2vw, 24px);
  & .gallery-grid .card-media { border: 4px double var(--line); }
  & .gallery-grid .card-media .item-index { top: 45%; left: 43%; }
}
html[data-format="frame-ticket"] {
  --mount: 5px; --crop: 2/1;
  & .gallery-grid .card-copy { margin-top: 6px; border-top: 2px dashed var(--line); }
}
html[data-format="frame-slide"] {
  --mount: clamp(16px, 2vw, 26px); --crop: 3/2; --aperture: 5px;
  & .gallery-grid .card-media { border: 5px solid var(--bg); }
  & .gallery-grid .card-copy { align-items: flex-end; text-align: right; }
}

/* Directory formats keep one reading column on phones. */
html[data-format^="list-"] {
  & .gallery-grid { grid-template-columns: minmax(0, 1fr); gap: var(--row-gap, 12px); }
  & .gallery-grid .product-card {
    display: grid; grid-template-columns: var(--thumb, 28%) minmax(0, 1fr);
    align-items: center; text-align: left; padding: var(--row-pad, 8px);
  }
  & .gallery-grid .card-media { aspect-ratio: var(--crop, 4/3); }
  & .gallery-grid .card-copy { align-items: start; text-align: left; padding: 10px clamp(12px, 2vw, 24px); }
  & .gallery-grid .card-copy p { margin: 0; }
  & .gallery-grid .view-label { display: none; }
  @media (min-width: 1000px) { & .gallery-grid { grid-template-columns: repeat(var(--columns, 2), minmax(0, 1fr)); } }
}
html[data-format="list-ledger"] {
  --thumb: clamp(70px, 15vw, 118px); --row-gap: 5px; --row-pad: 4px;
  & .gallery-grid { font-variant-numeric: tabular-nums; }
  & .gallery-grid .card-copy h3 { margin: 2px 0; font-size: 1.05rem; }
}
html[data-format="list-timeline"] {
  --columns: 1; --thumb: clamp(92px, 18vw, 180px); --row-gap: 20px;
  & .gallery-grid { border-left: 2px solid var(--accent); padding-left: clamp(12px, 2vw, 26px); }
  & .gallery-grid .card-media { border-radius: 6px; }
}
html[data-format="list-spread"] {
  --columns: 1; --thumb: 46%; --crop: 16/9; --row-pad: 0;
  & .gallery-grid .product-card:nth-child(even) { grid-template-columns: minmax(0, 1fr) 46%; }
  & .gallery-grid .product-card:nth-child(even) .card-media { grid-column: 2; grid-row: 1; }
  & .gallery-grid .product-card:nth-child(even) .card-copy { grid-column: 1; grid-row: 1; }
}
html[data-format="list-dossier"] {
  --crop: 4/5;
  & .gallery-grid .product-card { grid-template-columns: minmax(0, 1fr) 30%; }
  & .gallery-grid .card-media { grid-column: 2; grid-row: 1; }
  & .gallery-grid .card-copy { grid-column: 1; grid-row: 1; border-top: 3px solid var(--accent); }
}
html[data-format="list-pill"] {
  --thumb: clamp(72px, 16vw, 114px); --row-pad: 8px 16px 8px 8px; --crop: 1;
  & .gallery-grid .card-media { border-radius: 50%; }
  & .gallery-grid .item-index { display: none; }
}
html[data-format="list-ribbon"] {
  --thumb: 23%; --row-pad: 7px 7px 7px 15px; --crop: 4/5;
  & .gallery-grid h3 { letter-spacing: .04em; text-transform: uppercase; }
}

/* Feature layouts use wide photos and deliberate spans without changing reading order. */
html[data-format^="show-"] {
  & .gallery-grid { grid-template-columns: 1fr; gap: var(--gutter, 18px); }
  & .gallery-grid .card-media { aspect-ratio: var(--crop, 16/9); }
  & .gallery-grid .card-copy { align-items: start; text-align: left; padding: var(--caption, 16px 18px); }
  @media (min-width: 760px) { & .gallery-grid { grid-template-columns: repeat(var(--columns, 2), minmax(0, 1fr)); } }
}
html[data-format="show-panorama"] {
  --crop: 3/1; --columns: 1; --gutter: 26px;
  & .gallery-grid .card-copy { border-top: 1px solid var(--accent); }
}
html[data-format="show-mosaic"] {
  --columns: 3; --gutter: 10px; --crop: 1;
  & .gallery-grid .product-card:nth-child(4n + 1) .card-media { aspect-ratio: 2/1; }
  @media (min-width: 760px) { & .gallery-grid .product-card:nth-child(4n + 1) { grid-column: span 2; } }
}
html[data-format="show-diptych"] {
  --gutter: 3px; --crop: 5/4;
  & .gallery-grid .card-copy { border-top: 1px solid var(--line); }
  @media (min-width: 520px) { & .gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
}
html[data-format="show-spotlight"] {
  --columns: 3;
  & .gallery-grid .product-card:first-child { grid-column: 1 / -1; }
  & .gallery-grid .product-card:first-child .card-media { aspect-ratio: 2.8; }
  & .gallery-grid .product-card:first-child h3 { font-size: clamp(1.5rem, 4vw, 2.4rem); }
}
html[data-format="show-film"] {
  --crop: 2.35; --caption: 10px 14px;
  & .gallery-grid .card-media { border-block: 8px dashed var(--line); background: var(--bg); }
}
html[data-format="show-postcard"] {
  --crop: 1.7; --gutter: 24px;
  & .gallery-grid .product-card { padding: 7px; }
  & .gallery-grid .product-card:nth-child(even) .card-copy { align-items: end; text-align: right; }
}

/* Page regions are rendered in their reading order. Two-column layouts collapse on phones. */
.member-home :is(.market-main, .market-rail, .market-pair > *, .collection, .item-shelf) { min-width: 0; }
.member-home :is(.market-columns, .market-directory, .market-pair) {
  display: grid; align-items: start; gap: clamp(18px, 3vw, 38px);
}
.member-home .market-pair > :only-child, .market-directory > :only-child { grid-column: 1 / -1; }
body:not([data-layout="classic"]) .member-home :is(.collection, .contact-section, .reviews-section) {
  padding-block: clamp(20px, 3vw, 42px);
}
body:not([data-layout="classic"]) .member-home .featured-deals { margin: 0 0 18px; max-width: none; }
.member-home .market-pair .featured-deals { width: 100%; margin: 0; }
.market-masthead .featured-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 135px), 1fr)); }
.market-rail .guidelines, .market-masthead .guidelines, .market-pair .guidelines { grid-template-columns: 1fr; }
.market-rail .guidelines-intro, .market-pair .guidelines-intro { border-right: 0; border-bottom: 1px solid var(--line); }
.market-rail .guidelines-intro, .market-rail .guidelines ul { padding: 20px; }
.market-rail .guidelines h1 { font-size: clamp(1.6rem, 2.6vw, 2.25rem); }
.market-rail .guidelines li { align-items: start; }
.market-rail .availability-section { padding: 14px 8px; }
.market-rail .availability-picker { gap: 1px; }
.market-rail .contact-methods { grid-template-columns: 1fr; gap: 10px; }
.market-rail .availability-tab { font-size: .72rem; }
.market-directory .category-index {
  display: flex; flex-wrap: wrap; gap: 6px; align-content: start;
  padding: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--corner, 12px);
}
.category-index a { padding: 8px 12px; font-size: .875rem; border: 1px solid var(--line); border-radius: var(--control, 6px); }
.category-index a:is(:hover, :focus-visible) { border-color: var(--accent); color: var(--accent); }
.item-shelf + .item-shelf { margin-top: clamp(24px, 4vw, 54px); }
.shelf-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.shelf-heading h2 { font-size: clamp(1.35rem, 3vw, 2rem); scroll-margin-block-start: 20px; overflow-wrap: anywhere; }
.shelf-heading .new-badge { position: static; vertical-align: middle; }
.member-home .collection, .category-view { container-type: inline-size; container-name: merchandise; }
@media (min-width: 850px) {
  .member-home .market-columns { grid-template-columns: minmax(0, 1fr) minmax(245px, 29%); grid-template-areas: "catalog info"; }
  [data-layout="left"] .market-columns { grid-template-columns: minmax(245px, 29%) minmax(0, 1fr); grid-template-areas: "info catalog"; }
  .market-main { grid-area: catalog; }
  .market-rail { grid-area: info; }
  .member-home .market-columns .market-main > .collection:first-child, .member-home .market-directory .collection { padding-top: 0; }
  .member-home .market-pair { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .member-home .market-directory { grid-template-columns: minmax(160px, 21%) minmax(0, 1fr); }
  .market-directory .category-index { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow: auto; flex-direction: column; flex-wrap: nowrap; }
}

/* The same placement rules work on category covers, items in dialogs and inline shelves. */
html[data-format] body[data-arrangement]:where(:not([data-arrangement="regular"])) :is(.gallery-grid, .mini-grid) {
  display: grid; grid-template-columns: repeat(var(--item-columns, 1), minmax(0, 1fr));
  gap: var(--item-gap, clamp(10px, 1.8vw, 22px)); align-items: stretch;
}
html[data-format] body[data-arrangement] :is(.gallery-grid, .mini-grid) > .product-card { min-width: 0; }
body:is([data-arrangement="pairs"], [data-arrangement="wall"], [data-arrangement="mosaic"], [data-arrangement="triptych"]) { --item-columns: 2; }
body[data-arrangement="wall"] { --item-gap: 8px; }
html[data-format] body[data-arrangement="rows"] .mini-grid > .product-card,
html[data-format] body[data-arrangement="solo"] .mini-grid > .product-card {
  display: grid; grid-template-columns: minmax(78px, 25%) minmax(0, 1fr); align-items: center; text-align: left;
}
html[data-format] body:is([data-arrangement="rows"],[data-arrangement="solo"]) .mini-grid .card-copy { text-align: left; }
html[data-format] body[data-arrangement="solo"] .mini-grid > .product-card { grid-template-columns: minmax(95px, 44%) minmax(0, 1fr); }
html[data-format] body[data-arrangement="rows"] .mini-grid .card-media { aspect-ratio: 1.5; }
html[data-format] body[data-arrangement="steps"] :is(.gallery-grid, .mini-grid) { grid-template-columns: repeat(5, minmax(0, 1fr)); }
html[data-format] body[data-arrangement="steps"] :is(.gallery-grid, .mini-grid) > .product-card { grid-column: 1 / 5; }
html[data-format] body[data-arrangement="steps"] :is(.gallery-grid, .mini-grid) > .product-card:nth-child(even) { grid-column: 2 / 6; }
html[data-format] body[data-arrangement="triptych"] :is(.gallery-grid, .mini-grid) > .product-card:first-child,
html[data-format] body[data-arrangement="mosaic"] :is(.gallery-grid, .mini-grid) > .product-card:nth-child(3n + 1) { grid-column: 1 / -1; }
html[data-format] body[data-arrangement="strip"] :is(.gallery-grid, .mini-grid) {
  display: flex; overflow-x: auto; scroll-snap-type: x proximity;
  padding: 7px 5px 16px; scrollbar-color: var(--accent) var(--panel);
}
html[data-format] body[data-arrangement="strip"] :is(.gallery-grid, .mini-grid) > .product-card {
  flex: 0 0 clamp(185px, 70%, 320px); scroll-snap-align: start;
}
body[data-arrangement="strip"] .mini-grid .card-media { aspect-ratio: 16/10; }
@container merchandise (min-width: 540px) {
  html[data-format] body[data-arrangement="wall"] :is(.gallery-grid, .mini-grid) { --item-columns: 4; }
  html[data-format] body[data-arrangement="triptych"] :is(.gallery-grid, .mini-grid) { --item-columns: 3; }
  html[data-format] body[data-arrangement="lead"] :is(.gallery-grid, .mini-grid) { grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); }
  html[data-format] body[data-arrangement="lead"] :is(.gallery-grid, .mini-grid) > .product-card:first-child {
    grid-column: 1; grid-row: span 2;
  }
  html[data-format] body[data-arrangement="lead"] :is(.gallery-grid, .mini-grid) > .product-card:first-child .card-media { flex: 1 0 auto; aspect-ratio: 1; }
  html[data-format] body[data-arrangement="lead"] :is(.gallery-grid, .mini-grid) > .product-card:not(:first-child) .card-media { aspect-ratio: 2.4; }
  html[data-format] body[data-arrangement="mosaic"] :is(.gallery-grid, .mini-grid) { --item-columns: 3; }
  html[data-format] body[data-arrangement="mosaic"] :is(.gallery-grid, .mini-grid) > .product-card:nth-child(n) { grid-column: auto; }
  html[data-format] body[data-arrangement="mosaic"] :is(.gallery-grid, .mini-grid) > .product-card:is(:nth-child(4n+1), :nth-child(4n)) { grid-column: span 2; }
}
@container merchandise (max-width: 539px) {
  html[data-format] body[data-arrangement="lead"] :is(.gallery-grid, .mini-grid) { --item-columns: 2; }
  html[data-format] body[data-arrangement="lead"] :is(.gallery-grid, .mini-grid) > .product-card:first-child { grid-column: 1 / -1; }
}
@media (min-width: 760px) {
  body:is([data-layout="left"],[data-layout="right"],[data-layout="directory"]) dialog.item-detail-dialog[open] {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start;
    width: min(950px, calc(100vw - 64px));
  }
  .item-detail-dialog .detail-toolbar { grid-column: 1 / -1; }
  body[data-layout="right"] .item-detail-dialog .detail-media { grid-column: 2; grid-row: 2; }
  body[data-layout="right"] .item-detail-dialog .detail-copy { grid-column: 1; grid-row: 2; }
}

/* An isolated example lets admins try unsaved interactions. */
.format-preview[data-theme="classic"] {
  --bg: #0e1218; --panel: #191f28; --panel-2: #242c37; --accent: #e4bd79;
  --line: #323b48; --text: #f6f3ed; --muted: #acb3bf;
}
#appearance-form label[for="site-format"] { margin-bottom: 8px; }
.format-preview { padding: 20px; margin: 16px 0 24px; border-radius: 12px; background: var(--bg); }
.preview-trigger {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 16px;
  padding: 18px; cursor: pointer; list-style: none; color: var(--text);
  background: linear-gradient(120deg, var(--panel-2), var(--panel), var(--panel-end));
  border: var(--edge) solid var(--line); border-radius: var(--corner); box-shadow: var(--rest);
}
.preview-trigger::-webkit-details-marker { display: none; }
.preview-title { font: 600 1.2rem/1.4 var(--title); }
.preview-hint { font-size: .8rem; color: var(--accent); }
.preview-detail { margin: 14px 0 0; color: var(--muted); font-size: .875rem; }
[data-theme="porcelain"][data-format] { --ink: #383a4040; }
html[data-format="marquee"][data-theme="porcelain"] .gallery-grid .card-copy .category { color: #efeff5; }
@media (prefers-reduced-motion: reduce) {
  [data-format], .format-preview[data-format] { --lift: none; --push: none; --speed: 0ms; }
  html[data-format="gallery"] :is(.button, .product-card, .featured-card, .contact-card-link, .icon-button, .availability-tab):not(:disabled):active {
    transform: none;
  }
}
