:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f7f5f0;
  color: #201d19;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
}

.shell {
  width: min(1280px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0;
  display: grid;
  grid-template-columns: minmax(360px, 420px) 1fr;
  gap: 24px;
  align-items: start;
}

.panel,
.preview {
  background: #fffdf9;
  border: 1px solid #dfd8cf;
  border-radius: 8px;
  box-shadow: 0 18px 45px rgba(40, 30, 20, 0.08);
}

.panel {
  padding: 24px;
  position: sticky;
  top: 24px;
}

.masthead {
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: #87662d;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 2rem;
  line-height: 1.08;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 14px;
  font-size: 1rem;
}

.form {
  display: grid;
  gap: 16px;
}

.field {
  display: grid;
  gap: 8px;
}

.field span {
  color: #655b51;
  font-size: 0.86rem;
  font-weight: 700;
}

input,
select,
button {
  width: 100%;
  min-height: 44px;
  border-radius: 8px;
  font: inherit;
}

input,
select {
  padding: 0 12px;
  border: 1px solid #cfc4b7;
  background: #ffffff;
  color: #211d1a;
}

input:focus,
select:focus,
button:focus-visible {
  outline: 2px solid #9a752b;
  outline-offset: 2px;
}

select[multiple] {
  min-height: 180px;
  padding: 8px 12px;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  max-height: 350px;
  overflow: auto;
  padding-right: 2px;
}

.product-card {
  min-height: 0;
  position: relative;
  display: grid;
  gap: 6px;
  padding: 7px;
  border: 1px solid #e0d5c8;
  border-radius: 8px;
  background: #ffffff;
  color: #211d1a;
  text-align: left;
  box-shadow: none;
}

.product-card img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  border-radius: 6px;
  background: #f4eadc;
}

.product-card span {
  color: #4e453d;
  font-size: 0.76rem;
  font-weight: 800;
  text-align: center;
  overflow-wrap: anywhere;
}

.product-card.selected {
  border-color: #8c681f;
  box-shadow: 0 0 0 2px rgba(140, 104, 31, 0.32);
}

.product-card.selected::after {
  content: "Selected";
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 3px 6px;
  border-radius: 999px;
  background: #201d19;
  color: #ffffff;
  font-size: 0.65rem;
  font-weight: 800;
}

.product-grid.locked .product-card {
  cursor: wait;
  opacity: 0.74;
}

.product-loading {
  margin-bottom: 0;
  color: #80746b;
  font-size: 0.92rem;
}

.details {
  display: grid;
  gap: 8px;
  padding: 14px;
  min-height: 84px;
  border: 1px solid #ece3d8;
  border-radius: 8px;
  background: #fbf7ef;
  color: #4e453d;
  font-size: 0.92rem;
}

.selected-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid #eadfce;
  border-radius: 8px;
  background: #fbf7ef;
  color: #4e453d;
  font-size: 0.9rem;
  font-weight: 800;
}

.ghost-button {
  width: auto;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid #d8ccbc;
  background: #ffffff;
  color: #332b24;
  font-size: 0.86rem;
}

.details strong {
  color: #211d1a;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.meta span {
  padding: 5px 8px;
  border-radius: 999px;
  background: #ffffff;
  border: 1px solid #eadfce;
}

.selected-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.selected-list span {
  padding: 4px 7px;
  border-radius: 6px;
  background: #211d1a;
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 800;
}

.upload {
  display: grid;
  gap: 6px;
  padding: 18px;
  border: 1px dashed #b99b61;
  border-radius: 8px;
  background: #fffaf1;
  cursor: pointer;
}

.upload input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.upload-title {
  font-weight: 800;
}

.upload-subtitle {
  color: #6f655c;
  font-size: 0.92rem;
  overflow-wrap: anywhere;
}

button {
  border: 0;
  background: #1f1a16;
  color: #ffffff;
  font-weight: 800;
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.status {
  min-height: 22px;
  margin-bottom: 0;
  color: #6f655c;
  font-size: 0.92rem;
}

.status.error {
  color: #a32920;
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
}

.preview {
  padding: 18px;
}

.image-frame {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 520px;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  border-radius: 8px;
  background: #efe6da;
}

.image-frame img {
  display: none;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.image-frame.has-image img {
  display: block;
}

.image-frame.has-image span {
  display: none;
}

.image-frame span {
  color: #80746b;
  font-weight: 700;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  min-height: 520px;
}

.empty-result {
  display: grid;
  place-items: center;
  min-height: 180px;
  border-radius: 8px;
  background: #efe6da;
  color: #80746b;
  font-weight: 700;
}

.result-card {
  margin: 0;
  display: grid;
  gap: 8px;
}

.result-card img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: contain;
  border-radius: 8px;
  background: #efe6da;
}

.result-card figcaption {
  color: #4e453d;
  font-size: 0.92rem;
  font-weight: 800;
}

@media (max-width: 900px) {
  .shell {
    grid-template-columns: 1fr;
    padding: 20px 0;
  }

  .panel {
    position: static;
  }

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

  .product-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: none;
  }

  .image-frame {
    min-height: 360px;
  }
}
