:root {
  color-scheme: light;
  --paper: #f8f5ec;
  --paper-deep: #efe9dc;
  --ink: #233c31;
  --muted: #5a665d;
  --accent: #ac6849;
  --line: rgba(35, 60, 49, 0.14);
  --serif: "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: "Avenir Next", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  --ease: cubic-bezier(0.23, 1, 0.32, 1);
}

* { box-sizing: border-box; }
::selection { background: var(--ink); color: var(--paper); }

html {
  background: var(--paper);
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  font: 15px/1.45 var(--sans);
  overflow-x: clip;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
h1, h2, h3, p, figure { margin: 0; }
button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.wrap {
  width: min(1320px, calc(100% - 40px));
  margin-inline: auto;
}

.mast {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(248, 245, 236, 0.93);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.mast-inner {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 8px 0;
}

.wordmark {
  font: 700 clamp(20px, 2.3vw, 27px)/1 var(--serif);
  letter-spacing: -0.03em;
  white-space: nowrap;
}

.wordmark span { color: var(--accent); }

.controls-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.tab-switch, .view-switch {
  display: inline-flex;
  border: 1px solid var(--line);
  background: var(--paper-deep);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}

.tab-switch button, .view-switch button {
  border: 0;
  background: transparent;
  padding: 7px 14px;
  min-height: 36px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  transition: background-color 160ms var(--ease), color 160ms var(--ease);
}

.tab-switch button[aria-selected="true"],
.view-switch button[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
}

.catalog-wrap {
  padding: clamp(22px, 3vw, 40px) 0 clamp(60px, 7vw, 96px);
}

.catalog-panel[hidden] { display: none; }

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(22px, 2.5vw, 36px) clamp(14px, 2vw, 26px);
}

.card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.card-frame {
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: #f3efe4;
  border: 1px solid rgba(35, 60, 49, 0.08);
}

.card-frame img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 180ms var(--ease), transform 360ms var(--ease);
}

.img-hat { opacity: 1; }
.img-art { opacity: 0; background: var(--paper); }

body[data-view="art"] .img-hat { opacity: 0; }
body[data-view="art"] .img-art { opacity: 1; }

@media (hover: hover) and (pointer: fine) {
  body[data-view="hat"] .card:hover .img-hat { opacity: 0; }
  body[data-view="hat"] .card:hover .img-art { opacity: 1; transform: scale(1.02); }
  body[data-view="art"] .card:hover .img-art { opacity: 0; }
  body[data-view="art"] .card:hover .img-hat { opacity: 1; transform: scale(1.02); }
  .card:hover .card-name { color: var(--accent); }
}

.card-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.card-name {
  font: 600 clamp(15px, 1.3vw, 18px)/1.2 var(--serif);
  letter-spacing: -0.015em;
  transition: color 160ms var(--ease);
}

.card-color {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--cap);
  border: 1px solid rgba(35, 60, 49, 0.28);
  flex-shrink: 0;
}

.detail-wrap {
  padding: clamp(18px, 2.5vw, 34px) 0 clamp(60px, 7vw, 96px);
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 16px;
}

.back-link:hover { color: var(--ink); }

.product-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: clamp(24px, 4vw, 60px);
  align-items: start;
}

.gallery {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.stage-btn {
  display: block;
  width: 100%;
  padding: 0;
  border: 1px solid rgba(35, 60, 49, 0.1);
  background: #f3efe4;
  height: min(64svh, 600px);
  overflow: hidden;
  cursor: zoom-in;
}

.stage-btn img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.thumbs {
  display: grid;
  grid-template-columns: repeat(2, 112px);
  gap: 10px;
}

.thumb {
  padding: 0;
  border: 1px solid var(--line);
  background: #f3efe4;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  opacity: 0.72;
  transition: opacity 160ms ease, border-color 160ms ease;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumb[aria-pressed="true"] {
  opacity: 1;
  border-color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--ink);
}

.product-info {
  position: sticky;
  top: 96px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-top: 8px;
}

.product-info h1 {
  font: 700 clamp(28px, 3.2vw, 42px)/1.08 var(--serif);
  letter-spacing: -0.025em;
}

.product-color {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 500;
}

.product-color .dot { width: 13px; height: 13px; }

.product-spec {
  font-size: 14px;
  color: var(--muted);
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.more-section {
  margin-top: clamp(50px, 6vw, 84px);
  padding-top: 26px;
  border-top: 1px solid var(--line);
}

.more-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 18px;
}

.more-head h2 { font: 600 20px/1.2 var(--serif); }
.more-head a { font-size: 14px; color: var(--muted); }
.more-head a:hover { color: var(--ink); }

.more-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
}

dialog.lightbox {
  width: min(94vw, 960px);
  max-height: 92svh;
  padding: 0;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
}

dialog.lightbox::backdrop {
  background: rgba(20, 30, 26, 0.72);
  backdrop-filter: blur(4px);
}

.lightbox-bar {
  display: flex;
  justify-content: flex-end;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}

.lightbox-close {
  border: 1px solid var(--line);
  background: var(--paper);
  min-height: 36px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
}

.lightbox-body {
  display: grid;
  place-items: center;
  padding: 16px;
  max-height: calc(92svh - 60px);
  overflow: auto;
}

.lightbox-body img {
  max-height: calc(92svh - 96px);
  width: auto;
  height: auto;
  object-fit: contain;
}

.foot {
  border-top: 1px solid var(--line);
  padding: 24px 0;
  font-size: 13.5px;
  color: var(--muted);
}

.not-found {
  padding: 96px 0;
  text-align: center;
  display: grid;
  gap: 14px;
  justify-items: center;
}

.not-found h1 { font: 700 32px/1.1 var(--serif); }

@media (max-width: 960px) {
  .catalog-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .product-grid { grid-template-columns: minmax(0, 1fr); }
  .stage-btn { height: auto; aspect-ratio: 1 / 1; }
  .product-info { position: static; padding-top: 0; }
  .more-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .wrap { width: calc(100% - 24px); }
  .mast-inner { min-height: 56px; gap: 10px; padding: 10px 0; }
  .wordmark { font-size: 20px; }
  .controls-bar { width: 100%; justify-content: space-between; gap: 8px; }
  .tab-switch button, .view-switch button { padding: 6px 11px; font-size: 12px; min-height: 34px; }
  .catalog-grid { gap: 18px 10px; }
  .card-meta { flex-direction: column; gap: 2px; }
  .card-name { font-size: 15px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.01ms !important; }
}
