/* Atelier 151 — storefront, "catalogue raisonné" direction.
   Light theme. Palette moved from the dark system; all pairings measured:
   #1E1A15 on #F6F3ED 15.6:1 · #625B50 on #F6F3ED 6.1:1 · #8A5A18 on #F6F3ED 5.5:1
   #FFF on #1A7F5E 4.9:1 (fill, never text) · #1E1A15 on #D8B25C 8.6:1 (JP badge)
   #D8B25C on #171411 ~9:1 (footer only). Gold is dark-surface text ONLY — it
   measures ~2:1 on paper, which is why it is banned from the light surfaces. */

:root {
  --paper: #f6f3ed;
  --surface: #fdfcf9;
  --surface-hi: #ffffff;
  --ink: #1e1a15;
  --muted: #625b50;
  --accent: #8a5a18;
  --accent-hi: #6f4710;
  --gold: #d8b25c;            /* dark surfaces only (footer) */
  --green: #1a7f5e;            /* fill only, never text */
  --green-hi: #167052;
  --green-lo: #136043;
  --inkbg: #171411;            /* footer */
  --muted-d: #a39c90;          /* footer secondary, 6.7:1 on --inkbg */
  --line: rgba(30, 26, 21, 0.12);
  --line-hi: rgba(30, 26, 21, 0.22);
  --page: 1200px;
  --radius: 8px;
  --shadow-card: 0 1px 2px rgba(30, 26, 21, 0.07), 0 12px 28px rgba(30, 26, 21, 0.12);
  --shadow-panel: 0 18px 40px rgba(30, 26, 21, 0.22);
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-body: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: -0.015em;
  font-optical-sizing: auto;
  margin: 0;
}

h1 { font-size: clamp(1.9rem, 4vw, 2.7rem); }
h2 { font-size: clamp(1.4rem, 2.8vw, 1.9rem); }
h3 { font-size: 1.2rem; }

a { color: var(--accent); }
a:hover { color: var(--accent-hi); }

img { max-width: 100%; display: block; }

::selection { background: var(--accent); color: var(--paper); }

[hidden] { display: none !important; }

.wrap {
  max-width: var(--page);
  margin: 0 auto;
  padding: 0 24px;
}

.mono {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
}

/* ---------- header ---------- */

.site-header {
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: rgba(246, 243, 237, 0.92);
  backdrop-filter: blur(10px);
  z-index: 20;
}

.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 66px;
  flex-wrap: wrap;
}

.brand {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.3rem;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
}

.brand span {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--accent);
}

.brand:hover span { color: var(--accent-hi); }

.header-end {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}

.site-nav { display: flex; gap: 22px; flex-wrap: wrap; }

.site-nav a {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
  padding: 4px 0;
  border-bottom: 2px solid transparent;
}

.site-nav a:hover { color: var(--ink); }

.site-nav a[aria-current="page"] {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

/* ---------- hero / masthead ----------

   Flat paper masthead. The old banner image, scrim stack and sheen animation
   are deleted: their only job was to manage white photography on a dark page,
   which the light theme no longer has. If home_page() sets an inline
   background-image on .hero today, that must be removed — see the markup
   change list. */

.hero {
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}

.hero .wrap { padding-block: 64px 48px; }

.hero .mono { color: var(--accent); }

.hero h1 {
  font-size: clamp(2.5rem, 5.6vw, 4.2rem);
  line-height: 1.04;
  letter-spacing: -0.02em;
  max-width: 14ch;
  margin-top: 14px;
}

.hero p.lede {
  color: var(--muted);
  max-width: 58ch;
  margin: 18px 0 0;
  font-size: 1.06rem;
  line-height: 1.6;
}

/* ---------- catalogue tiles (homepage index) ---------- */

.cats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
  margin-top: 30px;
  padding: 0 24px 46px;
  max-width: var(--page);
  margin-inline: auto;
}

.cat {
  display: block;
  padding: 22px 22px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  transition: transform 160ms ease-out, border-color 160ms ease-out,
    background 160ms ease-out, box-shadow 160ms ease-out;
}

.cat:hover, .cat:focus-visible {
  transform: translateY(-2px);
  border-color: var(--line-hi);
  background: var(--surface-hi);
  box-shadow: var(--shadow-card);
}

.cat:active { transform: translateY(0); box-shadow: none; }

.cat h3 { margin: 10px 0 8px; }
.cat p { margin: 0 0 14px; color: var(--muted); font-size: 0.92rem; }
.cat > .mono:first-child { color: var(--accent); }
.cat .mono:last-child { color: var(--accent); }

.cat h3 { transition: color 140ms ease-out; }
@media (hover: hover) {
  .cat:hover h3 { color: var(--accent-hi); }
}

/* ---------- catalogue grid ---------- */

.section { padding-block: 56px; }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 26px;
  flex-wrap: wrap;
}

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

/* ---------- product card ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  transition: transform 160ms ease-out, border-color 160ms ease-out,
    background 160ms ease-out, box-shadow 160ms ease-out;
}

.card:hover, .card:focus-visible {
  transform: translateY(-2px);
  border-color: var(--line-hi);
  background: var(--surface-hi);
  box-shadow: var(--shadow-card);
}

.card:active { transform: translateY(0); box-shadow: none; }

.card-media {
  position: relative;
  aspect-ratio: 1 / 1;
  background: var(--surface);
}

/* Photographs are shot on white: the photo well must be pure white so the
   image and its mount are the same surface, not a box in a box. */
.card-media--photo { background: #fff; }

.card-media img { width: 100%; height: 100%; object-fit: contain; }

/* Sold out: the photograph recedes, the stamp takes over. Entirely
   decorative — the text alternatives carry the state. */
.card--out .card-media img {
  filter: grayscale(0.55);
  opacity: 0.6;
  transition: filter 160ms ease-out, opacity 160ms ease-out;
}

.card--out:hover .card-media img { filter: grayscale(0.3); opacity: 0.75; }

/* Placeholder for products with no photograph yet (dormant: everything is
   photographed now, but build.py can still emit it). Typographic, on paper. */
.ph {
  width: 100%; height: 100%;
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  gap: 12px; padding: 22px; text-align: center;
  background:
    linear-gradient(180deg, rgba(138, 90, 24, 0.05), transparent 60%), var(--paper);
  border-bottom: 1px solid var(--line);
}

.ph-fmt {
  font-family: var(--font-mono);
  font-size: 0.62rem; letter-spacing: 0.14em; text-transform: uppercase;
  font-weight: 500;
  color: var(--accent);
}

.ph-title {
  font-family: var(--font-display); font-weight: 600;
  font-size: 1.02rem; line-height: 1.3; color: rgba(30, 26, 21, 0.82);
  max-width: 16ch;
}

.badge {
  position: absolute;
  top: 10px;
  left: 10px;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 5px 9px;
  border-radius: 4px;
}

/* EN: emerald fill, white 4.9:1. JP: gold fill, ink 8.6:1. Gold as a FILL is
   fine on paper; it is banned as text there. */
.badge--en { background: var(--green); color: #fff; }
.badge--jp { background: var(--gold); color: var(--ink); }

.card-body { padding: 16px 16px 18px; display: flex; flex-direction: column; gap: 8px; flex: 1; }

.card-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.02rem;
  line-height: 1.3;
}

.card-spec {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}

.card-foot { margin-top: auto; display: flex; flex-direction: column; gap: 3px; }

.price {
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--accent);          /* 5.5:1 on paper — the priced accent */
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.card:hover .price, .card:focus-visible .price { color: var(--accent-hi); }

.stock {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

/* In-Stock marker: a small emerald square. The square is a graphic fill,
   which is the one thing --green is allowed to be. Colour is never the only
   signal — the word beside it carries the state. */
.stock::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: var(--green);
  flex: 0 0 auto;
}

/* Sold out: the marker becomes a bordered stamp, text unchanged. */
.stock--out {
  color: var(--muted);
  padding: 3px 8px;
  border: 1px solid var(--line-hi);
  border-radius: 3px;
  align-self: flex-start;
}

.stock--out::before { display: none; }

/* Legacy quantity tint from the old build; kept harmlessly in case the
   helper still emits it. Bronze on paper, 5.5:1. */
.stock--low { color: var(--accent); }

/* ---------- product detail ---------- */

.detail {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 44px;
  padding-block: 48px;
  align-items: start;
}

.gallery { display: block; }

.detail-media {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  aspect-ratio: 1 / 1;
  overflow: hidden;
}

.detail-media--photo { background: #fff; }
.detail-media img { width: 100%; height: 100%; object-fit: contain; }
.detail-media .ph-title { font-size: 1.4rem; max-width: 20ch; }

/* ---------- gallery ----------

   No-JS fallback is unchanged: thumbnails are plain links that open the
   photograph; gallery.js upgrades them to in-place swapping. */
.thumbs {
  display: flex; gap: 10px; flex-wrap: wrap;
  margin-top: 10px;
}

.thumb {
  width: 72px; height: 72px;
  border-radius: 6px; overflow: hidden;
  border: 1px solid var(--line);
  background: #fff;
  flex: 0 0 auto;
  opacity: 0.55;
  transition: opacity 140ms, border-color 140ms;
}

.thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }

.thumb.is-on { opacity: 1; border-color: var(--accent); }

@media (hover: hover) {
  .thumb:hover { opacity: 1; }
}

.thumb:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Spec list rendered as a ledger: one hairline per row across both columns,
   from borders on the dt and dd of the same row. */
.detail dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0 22px;
  margin: 24px 0;
}

.detail dl dt, .detail dl dd {
  padding: 9px 0;
  border-top: 1px solid var(--line);
}

.detail dl dt:first-of-type, .detail dl dd:first-of-type { border-top: 0; }

.detail dt {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}

.detail dd { margin: 0; }

.detail ul { padding-left: 18px; color: var(--ink); }
.detail ul li { margin-bottom: 5px; }

.price-row { display: flex; align-items: baseline; gap: 14px; margin: 6px 0 0; flex-wrap: wrap; }

.price-lg {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 2.5rem;
  line-height: 1.1;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

/* Case and box priced at once: both figures named, with a hairline between
   rows so the two prices never blur into one number. */
.price-stack { display: flex; flex-direction: column; gap: 8px; }
.price-stack .price-unit + .price-unit {
  border-top: 1px solid var(--line);
  padding-top: 8px;
}
.price-unit { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.price-stack .price-unit .price-lg { font-size: 1.6rem; }

.per, .price-from {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.price-from { margin-right: 2px; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 18px 0 0; }
.chip {
  border: 1px solid var(--line-hi);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 0.78rem;
  color: var(--muted);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  background: var(--green);
  color: #fff;                       /* 4.9:1 on the fill */
  text-decoration: none;
  font-weight: 600;
  padding: 13px 24px;
  border: 1px solid transparent;
  vertical-align: middle;
  border-radius: 6px;
  min-height: 48px;
  line-height: 22px;
  margin-top: 22px;
  transition: background 140ms ease-out, border-color 140ms ease-out;
}

.ico {
  flex: 0 0 auto;
  display: block;
  overflow: visible;
}

.btn:hover { background: var(--green-hi); }     /* 6.0:1 */
.btn:active { background: var(--green-lo); }    /* 7.5:1 */

.btn--ghost {
  background: transparent;
  border-color: var(--line-hi);
  color: var(--ink);
}

.btn--ghost:hover { background: var(--surface); border-color: var(--ink); }
.btn--ghost:active { background: var(--paper); }

.ctas { display: flex; flex-wrap: wrap; gap: 10px; }
.ctas .btn { flex: 0 1 auto; }

.footer-contact { display: flex; flex-wrap: wrap; gap: 8px 18px; }

.notice {
  border-left: 2px solid var(--accent);
  padding: 10px 0 10px 14px;
  color: var(--muted);
  font-size: 0.9rem;
  margin: 20px 0 0;
}

.price-note {
  font-style: italic;
  color: var(--muted);
  font-size: 0.9rem;
  margin: 18px 0 0;
  max-width: 46ch;
}

/* ---------- footer — the only dark surface ---------- */

.site-footer {
  border-top: 1px solid var(--line);
  background: var(--inkbg);
  color: #f3efe8;                    /* ~16:1 on --inkbg */
  padding-block: 38px 44px;
  font-size: 0.85rem;
}

.site-footer .wrap { display: flex; gap: 22px; justify-content: space-between; flex-wrap: wrap; }

.site-footer .brand { color: #f3efe8; }

/* Gold survives here, where it measures ~9:1. It is the deliberate bridge to
   the old storefront — and it is banned on the paper surfaces above. */
.site-footer .brand span { color: var(--gold); }
.site-footer .brand span:hover { color: var(--gold); }

.site-footer a { color: var(--muted-d); }       /* 6.7:1 on --inkbg */
.site-footer a:hover { color: #f3efe8; }

.contact-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.contact-link .ico { color: var(--gold); }
.contact-link:hover .ico { color: #f3efe8; }

.footer-contact .contact-link:hover { color: #f3efe8; }

.disclaimer { max-width: 62ch; margin-top: 18px; font-size: 0.78rem; line-height: 1.5; color: var(--muted-d); }

/* Focus ring on the dark footer must switch accent: bronze is only ~3.2:1
   on --inkbg, gold is ~9:1. */
.site-footer :focus-visible { outline-color: var(--gold); }

/* ---------- homepage rails ----------

   Mechanics unchanged: the row scrolls with CSS scroll-snap alone; the
   script only adds arrows and auto-advance on top. */
.rail-section + .rail-section { margin-top: 46px; }

.rail-section .section-head { margin-bottom: 18px; }

.rail-more {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
}

.rail-more:hover { text-decoration: underline; }

.rail { position: relative; }

.rail-track {
  display: flex;
  gap: 26px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scroll-padding-left: 2px;
  padding: 4px 2px 10px;
  margin: -4px -2px -10px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-hi) transparent;
  overscroll-behavior-x: contain;
}

.rail-track::-webkit-scrollbar { height: 8px; }
.rail-track::-webkit-scrollbar-track { background: transparent; }
.rail-track::-webkit-scrollbar-thumb {
  background: var(--line-hi);
  border-radius: 4px;
}

/* Edge fade — pure decoration; if mask-image is unsupported the rail simply
   renders without it, which is today's behaviour anyway. */
@supports (mask-image: linear-gradient(to right, black, black)) {
  .rail-track {
    mask-image: linear-gradient(to right, transparent 0, #000 28px, #000 calc(100% - 28px), transparent 100%);
    -webkit-mask-image: linear-gradient(to right, transparent 0, #000 28px, #000 calc(100% - 28px), transparent 100%);
  }
}

.rail-track > .card {
  flex: 0 0 clamp(160px, 40vw, 280px);
  scroll-snap-align: start;
}

.rail-nav {
  position: absolute;
  top: calc(50% - 40px);
  transform: translateY(-50%);
  z-index: 2;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--line-hi);
  background: var(--surface);
  color: var(--ink);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  box-shadow: var(--shadow-card);
  transition: opacity 220ms ease-out, background 140ms ease-out, border-color 140ms ease-out;
}

.rail:hover .rail-nav,
.rail-nav:focus-visible { opacity: 1; }

.rail-nav:hover { background: var(--surface-hi); }
.rail-nav:active { background: var(--paper); }
.rail-nav:disabled { opacity: 0 !important; pointer-events: none; }
.rail-nav--prev { left: -6px; }
.rail-nav--next { right: -6px; }

@media (hover: none) {
  .rail-nav { display: none; }
}

@media (max-width: 560px) {
  .rail-track { gap: 12px; }
  .rail-section + .rail-section { margin-top: 34px; }
}

/* ---------- set blocks ---------- */

.setblock { margin: 0; padding-top: 48px; scroll-margin-top: 80px; }
.setblock:first-of-type { padding-top: 8px; }

.setblock > summary {
  display: flex;
  align-items: baseline;
  gap: 16px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
  margin-bottom: 22px;
  cursor: pointer;
  list-style: none;
  transition: border-color 140ms ease-out;
}

.setblock > summary::-webkit-details-marker { display: none; }

@media (hover: hover) {
  .setblock > summary:hover { border-bottom-color: var(--line-hi); }
  .setblock > summary:hover h3 { color: var(--accent-hi); }
}

.setblock > summary h3 { transition: color 140ms ease-out; }
.setblock > summary > .mono { margin-left: auto; color: var(--accent); }

.setblock > summary::after {
  content: "";
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  transform: rotate(45deg);
  transition: transform 180ms ease-out;
  position: relative;
  top: -2px;
}

.setblock[open] > summary::after { transform: rotate(-135deg); top: 1px; }

.setblock:not([open]) > summary { margin-bottom: 0; }
.setblock:not([open]) { padding-top: 26px; }

.setblock h3 .mono { margin-left: 10px; margin-right: 0; color: var(--accent); }

@media (prefers-reduced-motion: reduce) {
  .setblock > summary,
  .setblock > summary h3,
  .setblock > summary::after { transition: none; }
}

.setblock .grid { row-gap: 20px; }

/* ---------- FAQ (native <details>, no JS) ---------- */

.faq { margin-top: 64px; }
.faq h2 { margin-bottom: 22px; }

.faq-list {
  border-top: 1px solid var(--line);
  max-width: 78ch;
}

.faq-item { border-bottom: 1px solid var(--line); }

.faq-item summary {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 18px 0;
  cursor: pointer;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.08rem;
  line-height: 1.4;
  list-style: none;
  transition: color 140ms ease-out;
}

.faq-item summary::-webkit-details-marker { display: none; }

@media (hover: hover) {
  .faq-item summary:hover { color: var(--accent-hi); }
}

.faq-item summary::after {
  content: "";
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  margin-left: auto;
  margin-top: 6px;
  border-right: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  transform: rotate(45deg);
  transform-origin: center;
  transition: transform 180ms ease-out;
}

.faq-item[open] summary::after { transform: rotate(-135deg); margin-top: 10px; }

.faq-answer {
  padding: 0 34px 20px 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.6;
}

.faq-answer p { margin: 0; }

@media (prefers-reduced-motion: reduce) {
  .faq-item summary::after { transition: none; }
}

/* ---------- game bands ---------- */

.gameband { padding-top: 18px; scroll-margin-top: 80px; }
.gameband + .gameband { padding-top: 56px; }

.gameband-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line-hi);
}

.gameband-head h2 { font-size: clamp(1.5rem, 3vw, 2rem); }

.gameband-head .mono { color: var(--accent); }

.gameband .setblock:first-of-type { padding-top: 30px; }
.gameband .setblock h3 { font-family: var(--font-display); font-size: 1.2rem; margin: 0; }

/* ---------- search ---------- */

.search { position: relative; margin: 0; }

.search input {
  width: 210px;
  max-width: 100%;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--line-hi);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 0.88rem;
  -webkit-appearance: none;
  appearance: none;
}

.search input::placeholder { color: var(--muted); }
.search input:focus { border-color: var(--accent); outline: none; }

/* The panel ships with the `hidden` attribute set in markup (see the markup
   list); the script removes it once there is something to show. With no
   script, the empty chrome never appears at all. */
.search-panel[hidden] { display: none; }

.search-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: min(380px, calc(100vw - 48px));
  background: var(--surface);
  border: 1px solid var(--line-hi);
  border-radius: var(--radius);
  box-shadow: var(--shadow-panel);
  max-height: min(420px, 70vh);
  overflow-y: auto;
  z-index: 30;
}

.search-results { list-style: none; margin: 0; padding: 6px; }

.search-results a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border-radius: 6px;
  text-decoration: none;
  color: var(--ink);
}

.search-results a:hover,
.search-results [aria-selected="true"] a { background: var(--paper); color: var(--ink); }

.search-thumb {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border-radius: 4px;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--line);
}

.search-thumb img { width: 100%; height: 100%; object-fit: contain; }
.search-thumb-blank { display: block; width: 100%; height: 100%; background: var(--paper); }

.search-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }

.search-title {
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-meta {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-price {
  font-size: 0.82rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--accent);
}

.search-empty { padding: 14px 12px; color: var(--muted); font-size: 0.88rem; }

/* ---------- responsive ---------- */

@media (max-width: 760px) {
  .detail { grid-template-columns: 1fr; gap: 28px; padding-block: 32px; }
  .section { padding-block: 40px; }
  .site-header .wrap { min-height: 58px; padding-block: 10px; }
  .hero .wrap { padding-block: 46px 40px; }

  .header-end { width: 100%; gap: 12px; }
  .search { width: 100%; order: -1; }
  .search input { width: 100%; }
  .search-panel { right: auto; left: 0; width: 100%; }

  .price-lg { font-size: 2.1rem; }
}

@media (max-width: 560px) {
  /* Chevron pinned right across two rows; title above, count below. Same
     fix as before, retinted. */
  .setblock > summary {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "title chevron"
      "meta  chevron";
    align-items: center;
    column-gap: 14px;
    row-gap: 4px;
  }

  .setblock > summary h3 { grid-area: title; }
  .setblock > summary > .mono { grid-area: meta; margin-left: 0; }

  .setblock > summary::after {
    grid-area: chevron;
    align-self: center;
    top: 0;
  }

  .setblock[open] > summary::after { top: 0; }

  .grid {
    grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
    gap: 12px;
  }

  .setblock .grid { row-gap: 12px; }

  .card-body { padding: 10px 10px 12px; gap: 5px; }
  .card-title { font-size: 0.85rem; line-height: 1.25; }
  .card-spec { font-size: 0.6rem; letter-spacing: 0.05em; }
  .card-foot { gap: 2px; }
  .price { font-size: 0.95rem; }
  .stock { font-size: 0.6rem; gap: 5px; }
  .stock--out { padding: 2px 6px; }

  .badge { font-size: 0.55rem; padding: 3px 6px; top: 6px; left: 6px; }

  .ph { padding: 12px; gap: 8px; }
  .ph-fmt { font-size: 0.55rem; letter-spacing: 0.1em; }
  .ph-title { font-size: 0.8rem; max-width: 14ch; }

  .thumb { width: 58px; height: 58px; }
  .thumbs { gap: 8px; }

  .cats { grid-template-columns: 1fr; }
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  .card, .cat, .rail-nav, .thumb, .stock::before, .btn { transition: none; }
}
