:root {
  color-scheme: light;
  --ink: #25231f;
  --muted: #716d65;
  --paper: #fffdf8;
  --canvas: #f4efe5;
  --accent: #7b3f54;
  --accent-dark: #572638;
  --line: #ded5c6;
  --danger: #9f2f2f;
  --shadow: 0 18px 45px rgba(63, 48, 37, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at top right, #ead8de 0, transparent 32rem),
    var(--canvas);
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
}

button,
select,
input {
  font: inherit;
}

.page-shell {
  width: min(1100px, calc(100% - 32px));
  margin: 0 auto;
  padding: 48px 0 72px;
}

.page-header {
  max-width: 720px;
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 12px;
  font-size: clamp(2rem, 5vw, 3.7rem);
  line-height: 1.12;
}

.page-header > p:last-child,
.section-heading p,
.helper-text {
  color: var(--muted);
}

.panel {
  margin-bottom: 24px;
  padding: clamp(20px, 4vw, 38px);
  border: 1px solid rgba(123, 63, 84, 0.12);
  border-radius: 24px;
  background: rgba(255, 253, 248, 0.94);
  box-shadow: var(--shadow);
}

.form-section + .form-section {
  margin-top: 36px;
  padding-top: 34px;
  border-top: 1px solid var(--line);
}

.section-heading {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 22px;
}

.section-heading h2 {
  margin-bottom: 5px;
}

.section-heading p {
  margin-bottom: 0;
}

.step {
  display: grid;
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--accent);
  font-weight: 800;
}

.upload-button,
.primary-button {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  padding: 0 24px;
  border: 0;
  border-radius: 14px;
  color: #fff;
  background: var(--accent);
  cursor: pointer;
  font-weight: 800;
  transition: transform 160ms ease, background 160ms ease;
}

.upload-button:hover,
.primary-button:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
}

.primary-button {
  width: 100%;
  margin-top: 30px;
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.65;
  transform: none;
}

.helper-text {
  margin: 12px 0;
  font-size: 0.9rem;
}

.image-preview,
.outfit-items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(135px, 1fr));
  gap: 14px;
}

.preview-card,
.result-item {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
}

.preview-card img,
.result-item img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: #eee;
}

.preview-body,
.result-item-body {
  padding: 10px;
}

.preview-name {
  overflow: hidden;
  margin-bottom: 8px;
  font-size: 0.8rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.remove-image {
  width: 100%;
  padding: 7px;
  border: 1px solid #d9a5a5;
  border-radius: 9px;
  color: var(--danger);
  background: #fff7f7;
  cursor: pointer;
}

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

.form-grid label > span {
  display: block;
  margin-bottom: 7px;
  font-weight: 700;
}

select {
  width: 100%;
  min-height: 45px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--ink);
  background: #fff;
}

.input-mode {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 22px;
}

.input-mode label {
  cursor: pointer;
}

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

.input-mode span {
  display: inline-block;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
}

.input-mode input:checked + span {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
}

.text-input-label > span {
  display: block;
  margin-bottom: 8px;
  font-weight: 800;
}

textarea {
  width: 100%;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  background: #fff;
  resize: vertical;
}

.color-grid {
  margin-top: 22px;
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
}

legend {
  padding: 0 8px;
  font-weight: 800;
}

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

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

.color-choice span {
  display: inline-block;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  cursor: pointer;
  font-size: 0.85rem;
}

.color-choice input:checked + span {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
}

.request-status {
  margin: 12px 0 0;
  color: var(--muted);
  text-align: center;
}

.outfit-results {
  display: grid;
  gap: 18px;
}

.outfit-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
}

.outfit-card h3 {
  margin: 0 0 14px;
}

.result-item-body p {
  margin: 2px 0;
  font-size: 0.85rem;
}

.external-label {
  color: var(--accent);
  font-weight: 800;
}

.missing-slots {
  margin: 14px 0 0;
  color: var(--danger);
  font-weight: 700;
}

.json-details {
  margin-top: 24px;
}

.json-details summary {
  cursor: pointer;
  font-weight: 800;
}

pre {
  overflow: auto;
  max-height: 520px;
  padding: 16px;
  direction: ltr;
  border-radius: 12px;
  color: #f7f2ea;
  background: #25231f;
  text-align: left;
  white-space: pre-wrap;
  word-break: break-word;
}

.error-box {
  padding: 18px 22px;
  border: 1px solid #e1aaaa;
  border-radius: 15px;
  color: #6e2020;
  background: #fff1f1;
}

.error-box p {
  margin: 7px 0 0;
}

@media (max-width: 700px) {
  .page-shell {
    width: min(100% - 20px, 1100px);
    padding-top: 26px;
  }

  .form-grid,
  .color-grid {
    grid-template-columns: 1fr;
  }

  .panel {
    border-radius: 18px;
  }
}
