:root {
  color-scheme: light;
  --ink: #171717;
  --muted: #6e6e6e;
  --line: #dedbd5;
  --paper: #fbfaf7;
  --surface: #ffffff;
  --accent: #245449;
  --accent-2: #b74e35;
  --soft: #eef2ed;
  --shadow: 0 18px 44px rgba(30, 28, 24, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(251, 250, 247, 0.92);
  padding: 18px 28px;
  backdrop-filter: blur(16px);
}

.source {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
}

h1 {
  margin: 0;
  font-size: clamp(24px, 3vw, 42px);
  font-weight: 760;
  line-height: 1.05;
}

.actions {
  display: flex;
  gap: 8px;
}

button {
  border: 1px solid var(--ink);
  background: var(--ink);
  color: white;
  cursor: pointer;
  min-height: 38px;
  padding: 0 14px;
}

button:hover {
  background: var(--accent);
  border-color: var(--accent);
}

button:disabled,
input:disabled,
select:disabled {
  cursor: wait;
  opacity: 0.58;
}

main {
  padding: 20px 28px 48px;
}

.controls {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) repeat(4, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  min-height: 44px;
  padding: 0 12px;
}

input:focus,
select:focus {
  border-color: var(--accent);
  outline: 2px solid rgba(36, 84, 73, 0.16);
}

.summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border: 1px solid var(--line);
  background: var(--surface);
  margin-bottom: 20px;
}

.summary div {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 14px 16px;
}

.summary div + div {
  border-left: 1px solid var(--line);
}

.summary strong {
  font-size: 22px;
  line-height: 1;
}

.summary span {
  color: var(--muted);
  font-size: 12px;
}

.catalog-status {
  display: flex;
  align-items: center;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  margin-bottom: 14px;
  padding: 15px 16px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.03);
}

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

.catalog-status strong,
.catalog-status span {
  display: block;
}

.catalog-status strong {
  font-size: 15px;
}

.catalog-status span {
  color: var(--muted);
  font-size: 13px;
}

.loader,
.status-mark {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
}

.loader {
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.status-mark {
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-2);
  color: white;
  font-weight: 760;
}

.catalog-status.is-error {
  border-color: rgba(183, 78, 53, 0.35);
}

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

.catalog.is-loading {
  pointer-events: none;
}

.product-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.03);
}

.media {
  display: grid;
  grid-template-columns: 1.45fr 0.9fr;
  gap: 1px;
  aspect-ratio: 1.25;
  background: var(--line);
}

.media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #f5f5f2;
  cursor: zoom-in;
}

.media img:first-child {
  grid-row: span 2;
}

.card-body {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.card-kicker {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

h2 {
  min-height: 52px;
  margin: 0;
  font-size: 21px;
  line-height: 1.22;
}

.specs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0;
}

.specs div {
  display: grid;
  gap: 2px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

dt {
  color: var(--muted);
  font-size: 11px;
}

dd {
  overflow: hidden;
  margin: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 650;
}

.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 18px;
}

.swatch {
  width: 18px;
  height: 18px;
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 50%;
  background: var(--swatch, #ddd);
}

.card-footer {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.card-footer button {
  display: grid;
  place-items: center;
  min-width: 0;
  border-radius: 6px;
  font-size: 13px;
}

.secondary-action {
  background: white;
  color: var(--ink);
}

.secondary-action:hover {
  background: var(--soft);
  border-color: var(--accent);
  color: var(--ink);
}

.skeleton-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding-bottom: 16px;
}

.skeleton-media,
.skeleton-line,
.skeleton-grid {
  position: relative;
  overflow: hidden;
  background: #eeeae2;
}

.skeleton-media {
  aspect-ratio: 1.25;
}

.skeleton-line {
  height: 14px;
  width: 52%;
  margin: 14px 16px 0;
  border-radius: 999px;
}

.skeleton-line.wide {
  width: 72%;
  height: 22px;
  margin-top: 18px;
}

.skeleton-grid {
  height: 82px;
  margin: 16px 16px 0;
  border-radius: 6px;
}

.skeleton-media::after,
.skeleton-line::after,
.skeleton-grid::after {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.72), transparent);
  content: "";
  transform: translateX(-100%);
  animation: shimmer 1.25s ease-in-out infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes shimmer {
  to {
    transform: translateX(100%);
  }
}

dialog {
  width: min(980px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(15, 14, 12, 0.42);
}

.close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  min-height: 36px;
  border-radius: 50%;
  padding: 0;
}

.detail {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 22px;
  padding: 22px;
}

.detail-images {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.detail-images img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 6px;
  background: #f4f3ef;
  cursor: zoom-in;
}

.detail-copy {
  padding-right: 34px;
}

.detail-copy h2 {
  min-height: 0;
  margin-bottom: 10px;
  font-size: 30px;
}

.detail-copy p {
  color: var(--muted);
  line-height: 1.55;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 18px 0;
}

.detail-grid div {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
}

.color-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.color-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
}

#imageDialog {
  width: min(1180px, calc(100vw - 28px));
  background: #111;
  border-color: #111;
}

.image-viewer {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) 54px;
  align-items: center;
  min-height: min(78vh, 820px);
  padding: 18px;
}

#largeImage {
  display: block;
  width: 100%;
  max-height: min(78vh, 820px);
  object-fit: contain;
}

.nav-image {
  width: 42px;
  min-height: 60px;
  border-color: rgba(255, 255, 255, 0.22);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: white;
  font-size: 34px;
  line-height: 1;
  padding: 0;
}

.image-counter {
  color: rgba(255, 255, 255, 0.76);
  font-size: 13px;
  padding: 0 18px 18px;
  text-align: center;
}

@media (max-width: 900px) {
  .controls,
  .summary,
  .detail {
    grid-template-columns: 1fr;
  }

  .summary div + div {
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 640px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 16px;
  }

  main {
    padding: 16px;
  }

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

  .detail {
    padding: 14px;
  }

  .detail-copy {
    padding-right: 0;
  }

  .image-viewer {
    grid-template-columns: 38px minmax(0, 1fr) 38px;
    min-height: 68vh;
    padding: 10px;
  }

  .nav-image {
    width: 32px;
    min-height: 48px;
  }
}
