/*
 * Shade Explorer (page-shade-explorer.php): colour wall on the indigo stage, sticky filter bar,
 * shade panel (side panel on desktop, bottom sheet on phones) and the "Match my colour" dialog.
 * Port of prototypes/css/shades.css. Loads after site.css.
 */

/* ---------- Hero ---------- */
.sx-hero { position: relative; padding-block: clamp(20px, 3vw, 32px) 0; overflow: hidden; }
.sx-hero::before {
  content: ""; position: absolute; inset: -20% -10% auto auto; width: 70vw; height: 70vw; border-radius: 50%; pointer-events: none;
  background: radial-gradient(closest-side, rgb(90 71 184 / 0.45), transparent 70%);
}
.sx-crumbs { position: relative; }
.sx-crumbs a { color: rgb(255 255 255 / 0.72); }
.sx-crumbs [aria-current] { color: var(--white); font-weight: 600; text-decoration: none; }
.sx-hero__inner {
  position: relative; display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.8fr); gap: var(--space-8);
  align-items: end; padding-block: clamp(28px, 4vw, 56px) clamp(36px, 4vw, 56px);
}
.sx-hero__copy .display { font-size: var(--step-5); margin: var(--space-4) 0; }
.sx-hero__copy .display em { color: var(--accent); }
.sx-hero__copy .lead { color: rgb(255 255 255 / 0.74); max-width: 52ch; font-size: var(--step-0); margin: 0; }
.sx-hero__aside { display: grid; gap: var(--space-6); justify-items: start; }
.sx-stats { display: grid; grid-template-columns: repeat(3, auto); gap: var(--space-6); margin: 0; }
.sx-stats div { display: grid; gap: 6px; }
.sx-stats dt { order: 2; font: 700 var(--step--2)/1.2 var(--font-body); letter-spacing: 0.12em; text-transform: uppercase; color: rgb(255 255 255 / 0.66); }
.sx-stats dd { margin: 0; min-width: 2ch; font: 300 var(--step-4)/0.9 var(--font-display); letter-spacing: -0.03em; font-variant-numeric: lining-nums tabular-nums; }
.sx-match-btn { min-height: 56px; padding-inline: var(--space-6); font-size: var(--step-0); }
.sx-match-btn__wheel {
  width: 22px; height: 22px; border-radius: 50%;
  background: conic-gradient(#E8457A, #FE7122, #D4A23A, #9DAE8E, #1F7A4D, #9CC3E4, #3C2A98, #B9A6DC, #E8457A);
  box-shadow: 0 0 0 2px rgb(17 11 48 / 0.25);
}
.sx-hero__strip { height: 10px; background: rgb(255 255 255 / 0.06); }
.sx-hero__strip canvas { display: block; width: 100%; height: 100%; }

/* ---------- Sticky bar ---------- */
.sx-bar {
  position: sticky; top: calc(var(--header-h) + env(safe-area-inset-top)); z-index: 40;
  background: rgb(247 244 239 / 0.94); backdrop-filter: saturate(1.3) blur(14px); border-bottom: 1px solid var(--line);
  transition: box-shadow var(--dur-2);
}
.sx-bar.is-stuck { box-shadow: 0 8px 24px rgb(17 11 48 / 0.08); }
.sx-bar__inner { display: flex; align-items: center; gap: var(--space-5); min-height: 72px; }
.sx-chips {
  display: flex; gap: var(--space-2); overflow-x: auto; flex: 1; min-width: 0; padding-block: var(--space-3);
  scrollbar-width: none; mask-image: linear-gradient(90deg, #000 92%, transparent); overscroll-behavior-x: contain;
}
.sx-chips::-webkit-scrollbar { display: none; }
.sx-chips .chip { flex: none; white-space: nowrap; min-height: 40px; }
/* Reserve one chip row until shades.js fills the chips, so the bar and wall don't shift down. */
.sx-chips:empty::before { content: ""; flex: none; min-height: 40px; }
.sx-chip__n { font: 600 11px/1 var(--font-mono); opacity: 0.7; }
.chip.is-product { background: var(--indigo-600); border-color: var(--indigo-600); color: var(--white); }
.sx-tools { display: flex; gap: var(--space-3); align-items: center; flex: none; }
.sx-search { position: relative; }
.sx-search .icon { position: absolute; left: 12px; top: 50%; translate: 0 -50%; width: 16px; height: 16px; opacity: 0.55; pointer-events: none; }
.sx-search input {
  width: 200px; height: 44px; padding: 0 var(--space-4) 0 36px; border-radius: var(--r-pill); border: 1px solid var(--line-strong);
  background: var(--white); font-size: 16px;
}
.sx-search input:focus { outline: none; border-color: var(--indigo-600); box-shadow: 0 0 0 3px var(--indigo-100); }
.sx-sort { display: flex; align-items: center; gap: var(--space-2); font-size: var(--step--1); font-weight: 700; }
.sx-sort label { color: var(--text-muted); font-weight: 600; }
.sx-sort select {
  appearance: none; height: 44px; padding: 0 36px 0 var(--space-4); border-radius: var(--r-pill); border: 1px solid var(--line-strong); font-weight: 700; font-size: 16px;
  background: var(--white) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2317131F' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center / 14px;
}
.sx-sort select:focus { outline: none; border-color: var(--indigo-600); box-shadow: 0 0 0 3px var(--indigo-100); }

/* ---------- Wall ---------- */
.sx-wall { background: var(--indigo-950); color: var(--white); min-height: 100svh; padding: clamp(24px, 3vw, 48px) var(--gutter) var(--space-9); }
.sx-wall__inner { --tile: 76px; --zoom: 1.6; max-width: 1680px; margin-inline: auto; display: grid; gap: clamp(20px, 2.4vw, 36px); }
.sx-wall__inner[data-size="m"] { --tile: 96px; --zoom: 1.42; }
.sx-wall__inner[data-size="l"] { --tile: 128px; --zoom: 1.3; }
.sx-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--tile), 1fr)); gap: 3px; }
.sx-fam {
  position: relative; grid-column: span 2; display: flex; flex-direction: column; justify-content: space-between; gap: 4px; padding: 12px 12px 10px 16px;
  border-radius: 3px; background: rgb(255 255 255 / 0.04); box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.08);
}
.sx-fam::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 0 2px 2px 0; background: var(--fc); }
.sx-fam__label { font: italic 300 clamp(15px, 1.25vw, 21px)/1.05 var(--font-display); letter-spacing: -0.01em; }
.sx-fam small { font: 600 10px/1 var(--font-mono); letter-spacing: 0.06em; color: rgb(255 255 255 / 0.66); }
.tile {
  position: relative; aspect-ratio: 4 / 5; padding: 0; border: 0; border-radius: 3px; cursor: pointer; overflow: hidden;
  background:
    linear-gradient(168deg, rgb(255 255 255 / 0.20) 0%, rgb(255 255 255 / 0) 34%, rgb(0 0 0 / 0) 62%, rgb(0 0 0 / 0.16) 100%),
    var(--c);
  color: var(--on); transform-origin: center; z-index: 0;
  transition: transform var(--dur-2) var(--ease-out), border-radius var(--dur-2) var(--ease-out), box-shadow var(--dur-2) var(--ease-out);
}
.tile__label {
  position: absolute; inset: auto 0 0 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 1px; padding: 6px 7px; text-align: left;
  opacity: 0; transition: opacity var(--dur-1) var(--ease-out);
}
.tile__code { font: 700 clamp(9px, calc(var(--tile) / 10), 12px)/1.15 var(--font-mono); letter-spacing: 0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile__name { font: 700 clamp(9px, calc(var(--tile) / 10), 12px)/1.15 var(--font-body); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile__prod { font: 500 8px/1.2 var(--font-body); opacity: 0.8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (hover: hover) {
  .tile:hover { transform: scale(var(--zoom)); z-index: 5; border-radius: 8px; box-shadow: 0 18px 40px rgb(0 0 0 / 0.45), 0 0 0 1px rgb(255 255 255 / 0.18); transition-delay: 30ms; }
  .tile:hover .tile__label { opacity: 1; transition-delay: 90ms; }
}
.tile:focus-visible { outline: none; transform: scale(var(--zoom)); z-index: 5; border-radius: 8px; box-shadow: 0 0 0 2px var(--indigo-950), 0 0 0 4px var(--accent), 0 18px 40px rgb(0 0 0 / 0.45); }
.tile:focus-visible .tile__label { opacity: 1; }
.tile.is-open { box-shadow: 0 0 0 2px var(--indigo-950), 0 0 0 4px var(--white); z-index: 4; border-radius: 6px; }
.tile.is-open .tile__label { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .tile:hover, .tile:focus-visible { transform: none; } }

/* Gentle entrance when the wall re-renders */
.sx-wall__inner.is-in .tile { animation: sx-tile-in var(--dur-3) var(--ease-out) both; }
@keyframes sx-tile-in { from { opacity: 0; } }
.sx-empty { text-align: center; color: rgb(255 255 255 / 0.76); padding: var(--space-9) 0; }
.sx-empty[hidden] { display: none; }
.link-btn { padding: 0; min-height: 44px; border: 0; background: none; color: var(--accent); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Panel ---------- */
.sx-scrim { display: none; }
.sx-panel {
  position: fixed; z-index: 70; top: calc(var(--header-h) + env(safe-area-inset-top)); right: 0; bottom: 0; width: min(440px, 100%);
  background: var(--paper); color: var(--ink); box-shadow: var(--shadow-3); border-left: 1px solid var(--line);
  translate: 100% 0; transition: translate var(--dur-3) var(--ease-out);
}
.sx-panel.is-open { translate: 0 0; }
.sx-panel[hidden] { display: none; }
.sx-panel__grab { display: none; }
.sx-panel__scroll { height: 100%; overflow-y: auto; padding: var(--space-4) var(--space-6) calc(var(--space-7) + env(safe-area-inset-bottom)); overscroll-behavior: contain; }
.sx-panel__top { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--space-3); }
.sx-panel__top .eyebrow { margin: 0; }
.sx-panel__chip {
  position: relative; height: 168px; border-radius: var(--r-md); display: flex; justify-content: space-between; align-items: end; padding: var(--space-4);
  background: linear-gradient(168deg, rgb(255 255 255 / 0.2), transparent 40%, rgb(0 0 0 / 0.14)), var(--c); color: var(--on);
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.08); transition: background-color var(--dur-3);
}
.sx-panel__chip .code { font-size: var(--step--1); }
.sx-panel__head { margin: var(--space-5) 0; }
.sx-panel__name { font: 350 var(--step-4)/1 var(--font-display); letter-spacing: -0.03em; overflow-wrap: anywhere; }
.sx-panel__code { margin: var(--space-3) 0 0; font-size: var(--step--1); color: var(--text-muted); }
.sx-panel__code .code { color: var(--accent-ink); }
.sx-panel__code a { font-weight: 700; color: var(--ink); }
.sx-panel__swatch {
  position: relative; height: 260px; border-radius: var(--r-md); overflow: hidden; isolation: isolate;
  background: radial-gradient(90% 90% at 50% 30%, var(--indigo-800), var(--indigo-950) 75%);
}
.sx-panel__3d { position: absolute; inset: 0; opacity: 0; transition: opacity var(--dur-3) var(--ease-out); touch-action: none; }
.sx-panel__3d canvas { width: 100% !important; height: 100% !important; display: block; outline: none; }
.sx-panel__swatch.has-3d .sx-panel__3d { opacity: 1; }
.sx-panel__swatch.has-3d .sx-ribbon { opacity: 0; }
.sx-ribbon { position: absolute; inset: 0; transition: opacity var(--dur-3); }
.sx-ribbon span {
  position: absolute; left: -10%; width: 120%; height: 24%; top: 40%; rotate: -12deg;
  background: linear-gradient(180deg, color-mix(in oklab, var(--c) 86%, black), var(--c) 14%, color-mix(in oklab, var(--c) 72%, white) 36%, var(--c) 58%, color-mix(in oklab, var(--c) 78%, black));
  box-shadow: 0 24px 40px -16px rgb(0 0 0 / 0.6);
}
.sx-ribbon span + span { top: 34%; height: 17%; rotate: 20deg; left: 20%; background: linear-gradient(180deg, color-mix(in oklab, var(--c) 78%, black), color-mix(in oklab, var(--c) 88%, black) 60%, color-mix(in oklab, var(--c) 66%, black)); z-index: -1; }
/* Buttons, snaps, eyelets: a lit disc instead of a ribbon. */
.sx-ribbon--disc span { left: 50%; top: 50%; width: 46%; height: auto; aspect-ratio: 1; rotate: none; translate: -50% -50%; border-radius: 50%; background: radial-gradient(circle at 34% 28%, color-mix(in oklab, var(--c) 50%, white), var(--c) 42%, color-mix(in oklab, var(--c) 72%, black)); box-shadow: 0 30px 50px -20px rgb(0 0 0 / 0.7), inset 0 -6px 16px rgb(0 0 0 / 0.2); }
.sx-ribbon--disc span + span { display: none; }
.sx-panel__badge { position: absolute; left: var(--space-3); bottom: var(--space-3); padding: 5px 10px; border-radius: var(--r-pill); background: rgb(255 255 255 / 0.14); backdrop-filter: blur(6px); color: var(--white); font-size: 11px; font-weight: 700; letter-spacing: 0.04em; pointer-events: none; }
.sx-panel__badge[hidden] { display: none; }
.sx-panel__facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3) var(--space-5); margin: var(--space-5) 0; }
.sx-panel__facts div { display: grid; gap: 4px; padding-top: var(--space-3); border-top: 1px solid var(--line); }
.sx-panel__facts dt { font: 700 var(--step--2)/1 var(--font-body); letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-muted); }
.sx-panel__facts dd { margin: 0; font-weight: 600; font-size: var(--step--1); }
.sx-panel__actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
.sx-panel__actions .btn { min-height: 48px; padding-inline: var(--space-4); }
.sx-add { margin-top: var(--space-4); padding: var(--space-4); border-radius: var(--r-md); background: var(--white); border: 1px solid var(--line); display: grid; gap: var(--space-4); }
.sx-add[hidden] { display: none; }
.sx-add__row { display: grid; grid-template-columns: 1.2fr 0.8fr 1fr; gap: var(--space-3); }
.sx-field { display: grid; gap: 6px; min-width: 0; font-size: var(--step--2); font-weight: 700; color: var(--text-muted); }
.sx-field select, .sx-field input {
  width: 100%; height: 44px; padding: 0 var(--space-3); border-radius: var(--r-sm); border: 1px solid var(--line-strong); background: var(--white);
  font-size: 16px; font-weight: 700; color: var(--ink);
}
.sx-field select:focus, .sx-field input:focus { outline: none; border-color: var(--indigo-600); box-shadow: 0 0 0 3px var(--indigo-100); }
.btn--block { width: 100%; }
.sx-panel__view { margin-top: var(--space-5); min-height: 44px; }
.sx-panel__similar { margin-top: var(--space-6); }
.sx-panel__h { font: 800 var(--step--2)/1 var(--font-body); letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-muted); margin-bottom: var(--space-4); }
.sx-similar { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-3); }
.sx-sim { display: grid; gap: 4px; padding: 0; border: 0; background: none; text-align: left; min-width: 0; }
.sx-sim__sw { aspect-ratio: 1; border-radius: var(--r-sm); background: linear-gradient(168deg, rgb(255 255 255 / 0.2), transparent 40%, rgb(0 0 0 / 0.14)), var(--c); box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.08); transition: transform var(--dur-2) var(--ease-out); }
.sx-sim:hover .sx-sim__sw { transform: translateY(-2px); }
.sx-sim__code { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sx-sim__name { font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Segmented control (same as the product page) ---------- */
.mx .seg { display: inline-flex; padding: 3px; border-radius: var(--r-pill); background: var(--paper-2); box-shadow: inset 0 0 0 1px var(--line); }
.mx .seg__btn {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 var(--space-4); border: 0; border-radius: var(--r-pill);
  background: transparent; color: var(--text-muted); font-size: var(--step--1); font-weight: 700;
  transition: background-color var(--dur-2) var(--ease-out), color var(--dur-2) var(--ease-out), box-shadow var(--dur-2);
}
.mx .seg__btn:hover { color: var(--text); }
.mx .seg__btn[aria-selected="true"] { background: var(--white); color: var(--ink); box-shadow: var(--shadow-1); }

/* ---------- Match dialog ---------- */
.mx {
  width: min(1120px, calc(100% - 32px)); max-height: min(860px, calc(100dvh - 32px)); padding: 0; border: 0; border-radius: var(--r-xl);
  background: var(--paper); color: var(--ink); box-shadow: var(--shadow-3); overflow: hidden;
}
.mx[open] { display: block; animation: mx-in var(--dur-3) var(--ease-out); }
@keyframes mx-in { from { opacity: 0; translate: 0 16px; } }
.mx::backdrop { background: rgb(17 11 48 / 0.62); backdrop-filter: blur(6px); }
.mx__close { position: absolute; top: var(--space-4); right: var(--space-4); z-index: 2; margin: 0; }
.mx__close .icon-btn { width: 44px; height: 44px; color: var(--white); }
.mx__close .icon-btn svg { width: 20px; height: 20px; }
.mx__close .icon-btn:hover { background: rgb(255 255 255 / 0.12); }
.mx__grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); max-height: inherit; }
.mx__input { padding: clamp(24px, 4vw, 48px); overflow-y: auto; display: grid; gap: var(--space-5); align-content: start; }
.mx__input .eyebrow { margin: 0; }
.mx__input .h3 { font-size: var(--step-4); font-weight: 350; letter-spacing: -0.03em; margin-top: calc(-1 * var(--space-2)); }
.mx__lead { margin: 0; color: var(--text-muted); font-size: var(--step--1); max-width: 46ch; }
.mx__tabs { justify-self: start; }
.mx__pane[hidden] { display: none; }
.mx__pick { display: flex; gap: var(--space-5); align-items: end; }
.mx__picker input { width: 104px; height: 104px; padding: 0; border: 0; border-radius: var(--r-lg); background: none; cursor: pointer; box-shadow: var(--shadow-1); }
.mx__picker input::-webkit-color-swatch-wrapper { padding: 0; }
.mx__picker input::-webkit-color-swatch { border: 0; border-radius: var(--r-lg); }
.mx__picker input::-moz-color-swatch { border: 0; border-radius: var(--r-lg); }
.mx__hex { display: grid; gap: 6px; flex: 1; min-width: 0; }
.mx__hex label { font-size: var(--step--2); font-weight: 700; color: var(--text-muted); }
.mx__hex input { width: 100%; height: 52px; padding: 0 var(--space-4); border-radius: var(--r-md); border: 1px solid var(--line-strong); background: var(--white); font: 600 max(16px, var(--step-1))/1 var(--font-mono); text-transform: uppercase; letter-spacing: 0.04em; }
.mx__hex input:focus { outline: none; border-color: var(--indigo-600); box-shadow: 0 0 0 3px var(--indigo-100); }
.mx__hex input[aria-invalid="true"] { border-color: #B42318; }
.mx__err { margin: 0; color: #B42318; font-size: var(--step--2); font-weight: 600; }
.mx__err[hidden] { display: none; }
.mx__presets { display: flex; flex-wrap: wrap; gap: 8px; margin-top: var(--space-4); }
.mx__preset { width: 32px; height: 32px; border-radius: 50%; border: 0; padding: 0; background: var(--c); box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.12); transition: transform var(--dur-1) var(--ease-out); }
.mx__preset:hover { transform: scale(1.15); }
.mx__drop {
  display: grid; justify-items: center; gap: var(--space-2); padding: var(--space-7) var(--space-5); border-radius: var(--r-lg); cursor: pointer; text-align: center;
  border: 1.5px dashed var(--line-strong); background: var(--white); transition: border-color var(--dur-2), background-color var(--dur-2);
}
.mx__drop svg { width: 36px; height: 36px; color: var(--indigo-600); }
.mx__drop span { font-size: var(--step--2); color: var(--text-muted); }
.mx__drop:hover, .mx__drop.is-over, .mx__drop:focus-within { border-color: var(--indigo-600); background: var(--indigo-50); }
.mx__drop:focus-within { outline: 2px solid var(--focus); outline-offset: 3px; }
.mx__drop[hidden], .mx__photo[hidden] { display: none; }
.mx__photo { display: grid; gap: var(--space-3); }
.mx__canvaswrap { position: relative; justify-self: start; max-width: 100%; border-radius: var(--r-md); overflow: hidden; box-shadow: var(--shadow-1); }
.mx__canvaswrap canvas { display: block; max-width: 100%; max-height: 300px; width: auto; height: auto; cursor: crosshair; }
.mx__dot { position: absolute; width: 26px; height: 26px; translate: -50% -50%; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 3px var(--white), 0 4px 12px rgb(0 0 0 / 0.4); pointer-events: none; }
.mx__dot[hidden] { display: none; }
.mx__hint { margin: 0; font-size: var(--step--2); color: var(--text-muted); }
.mx__sub { width: 100%; margin: 0 0 4px; font: 800 var(--step--2)/1 var(--font-body); letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-muted); }
.mx__suggest { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.mx__chip { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 4px 14px 4px 4px; border-radius: var(--r-pill); border: 1px solid var(--line-strong); background: var(--white); font-size: var(--step--2); font-weight: 700; }
.mx__chip small { margin-left: 6px; font-weight: 600; color: var(--text-muted); font-family: var(--font-mono); }
.mx__chip-sw { width: 32px; height: 32px; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.12); }
.mx__chip[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.mx .link-btn { color: var(--accent-ink); font-size: var(--step--1); justify-self: start; }
.mx__current { display: flex; align-items: center; gap: var(--space-4); padding-top: var(--space-5); border-top: 1px solid var(--line); font-size: var(--step--1); line-height: 1.4; }
.mx__cur-sw { width: 52px; height: 52px; flex: none; border-radius: var(--r-md); background: var(--c); box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.1); }
.mx__cur-name { color: var(--text-muted); }

.mx__results { background: var(--indigo-950); color: var(--white); padding: clamp(24px, 4vw, 48px) clamp(20px, 3vw, 40px); overflow-y: auto; }
.mx__results-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-5); padding-right: 48px; }
.mx__h { font: italic 300 var(--step-2)/1 var(--font-display); }
.mx__scope { font-size: var(--step--2); color: rgb(255 255 255 / 0.66); }
.mx__list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-2); }
.mx__res {
  position: relative; width: 100%; display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; gap: var(--space-4); align-items: center;
  padding: var(--space-3); border: 0; border-radius: var(--r-md); background: rgb(255 255 255 / 0.04); color: inherit; text-align: left;
  transition: background-color var(--dur-2);
}
.mx__res:hover { background: rgb(255 255 255 / 0.1); }
.mx__cmp { position: relative; width: 56px; height: 56px; border-radius: var(--r-sm); overflow: hidden; }
.mx__cmp span { position: absolute; inset: 0; background: var(--c); }
.mx__cmp span:first-child { background: var(--you); clip-path: polygon(0 0, 100% 0, 0 100%); z-index: 1; }
.mx__info { display: grid; gap: 4px; min-width: 0; }
.mx__name { font-weight: 700; font-size: var(--step--1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mx__name .code { margin-left: 6px; color: var(--accent); font-size: var(--step--2); }
.mx__prod { font-size: var(--step--2); color: rgb(255 255 255 / 0.66); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mx__bar { height: 3px; border-radius: 2px; background: rgb(255 255 255 / 0.12); overflow: hidden; margin-top: 2px; }
.mx__bar span { display: block; height: 100%; width: var(--pct); background: linear-gradient(90deg, var(--indigo-400), var(--accent)); }
.mx__pct { display: grid; justify-items: end; gap: 2px; min-width: 112px; }
.mx__pct strong { font: 400 var(--step-2)/1 var(--font-display); }
.mx__pct span { font-size: 11px; color: rgb(255 255 255 / 0.7); white-space: nowrap; }
.mx__best { position: absolute; top: -6px; left: 8px; padding: 3px 8px; border-radius: var(--r-pill); background: var(--accent); color: var(--indigo-950); font-size: 10px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.mx__list li:first-child .mx__res { margin-top: 6px; background: rgb(255 255 255 / 0.08); }

body.sx-lock { overflow: hidden; }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .sx-hero__inner { grid-template-columns: 1fr; gap: var(--space-6); }
  .sx-bar__inner { flex-wrap: wrap; gap: 0 var(--space-3); padding-block: var(--space-2); }
  .sx-chips { flex-basis: 100%; }
  .sx-tools { flex: 1; padding-bottom: var(--space-3); }
  .sx-search { flex: 1; }
  .sx-search input { width: 100%; }
}
@media (max-width: 760px) {
  .sx-hero__inner { padding-block: var(--space-5) var(--space-6); gap: var(--space-5); }
  .sx-hero__aside { gap: var(--space-5); width: 100%; }
  .sx-match-btn { width: 100%; }
  .sx-stats { grid-template-columns: repeat(3, minmax(0, auto)); gap: var(--space-5); }
  .sx-stats dt { font-size: 10px; letter-spacing: 0.08em; }
  .sx-stats dd { font-size: var(--step-3); }
  .sx-chips { padding-block: var(--space-2); }
  .sx-tools { padding-bottom: var(--space-2); }
  .sx-sort label { display: none; }
  .sx-sort select { padding-right: 32px; }

  /* Dense but tappable: tiles never narrower than ~44px. */
  .sx-wall { padding-inline: 12px; }
  .sx-wall__inner { --zoom: 1; }
  .sx-wall__inner, .sx-wall__inner[data-size] { --tile: 44px; }
  .sx-wall__inner[data-size="l"] { --tile: 72px; }
  .sx-grid { gap: 2px; }
  .sx-fam { grid-column: span 3; min-height: 56px; padding: 6px 6px 6px 10px; }
  .sx-fam__label { font-size: 14px; }
  .tile { min-height: 44px; }
  .tile__prod { display: none; }

  /* Bottom sheet */
  .sx-scrim { display: block; position: fixed; inset: 0; z-index: 65; background: rgb(17 11 48 / 0.5); opacity: 0; transition: opacity var(--dur-3) var(--ease-out); }
  .sx-scrim.is-on { opacity: 1; }
  .sx-scrim[hidden] { display: none; }
  .sx-panel {
    top: auto; height: min(88dvh, 760px); width: 100%; border-left: 0; border-radius: var(--r-xl) var(--r-xl) 0 0;
    translate: 0 100%; overflow: hidden; display: flex; flex-direction: column;
  }
  .sx-panel[hidden] { display: none; }
  .sx-panel.is-open { translate: 0 0; }
  .sx-panel__grab { display: block; position: relative; flex: none; height: 20px; touch-action: none; cursor: grab; }
  .sx-panel__grab::before { content: ""; position: absolute; top: 8px; left: 50%; width: 40px; height: 4px; translate: -50% 0; border-radius: 2px; background: var(--line-strong); }
  .sx-panel__top { touch-action: none; }
  .sx-panel__scroll { flex: 1; min-height: 0; height: auto; padding: var(--space-1) var(--space-5) calc(var(--space-7) + env(safe-area-inset-bottom)); }
  .sx-panel__chip { height: 104px; }
  .sx-panel__name { font-size: var(--step-3); }
  .sx-panel__swatch { height: 200px; }
  .sx-add__row { grid-template-columns: 1fr 1fr; }
  .sx-add__row .sx-field:first-child { grid-column: 1 / -1; }

  .mx { width: 100%; max-width: none; max-height: 100dvh; height: 100dvh; margin: 0; border-radius: 0; }
  .mx__grid { grid-template-columns: 1fr; overflow-y: auto; height: 100%; overscroll-behavior: contain; }
  .mx__input, .mx__results { overflow: visible; }
  .mx__input { padding-bottom: var(--space-6); }
  .mx__results { padding-bottom: calc(var(--space-7) + env(safe-area-inset-bottom)); }
  .mx__results-head { padding-right: 0; }
  .mx__close .icon-btn { color: var(--ink); background: rgb(247 244 239 / 0.9); }
  .mx__close .icon-btn:hover { background: rgb(0 0 0 / 0.06); }
  .mx__pick { gap: var(--space-4); }
  .mx__picker input { width: 80px; height: 80px; }
  .mx__pct { min-width: 0; }
  .mx__res { grid-template-columns: 48px minmax(0, 1fr) auto; gap: var(--space-3); }
  .mx__cmp { width: 48px; height: 48px; }
}
@media (pointer: coarse) {
  .mx__preset { width: 40px; height: 40px; }
  .sx-chips .chip { min-height: 44px; }
  .sx-chips:empty::before { min-height: 44px; }
}

/* Placeholder tiles while the wall is built (replaced by shades.js render()). */
.sx-skel { --sk1: rgb(255 255 255 / 0.07); --sk2: rgb(255 255 255 / 0.15); grid-template-columns: repeat(auto-fill, minmax(var(--tile), 1fr)); }
html:not(.js) .sx-skel { display: none; }
