:root {
  color-scheme: light;
  --ink: #171b24;
  --muted: #7b8190;
  --soft: #fbf7f2;
  --paper: #ffffff;
  --line: rgba(23, 27, 36, 0.12);
  --rose: #c95662;
  --rose-soft: #f8e7e8;
  --cream: #f4eadf;
  --charcoal: #202532;
  --glass: rgba(22, 20, 18, 0.62);
  --shadow: 0 18px 42px rgba(30, 26, 22, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--soft);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(100%, 430px);
  margin: 0 auto;
  background: var(--soft);
}

.app-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 18px 18px 14px;
  background: rgba(251, 247, 242, 0.92);
  backdrop-filter: blur(18px);
}

.app-header strong {
  font-size: 28px;
  font-weight: 950;
}

.app-header span {
  justify-self: center;
  font-size: 17px;
  font-weight: 850;
}

.app-header small {
  justify-self: end;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.tryon-stage {
  position: relative;
  overflow: hidden;
  background: #dbcbbb;
}

.stage-badge {
  position: absolute;
  z-index: 4;
  top: 22px;
  left: 14px;
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  border-radius: 8px;
  padding: 0 14px;
  color: #fff;
  background: var(--glass);
  font-size: 14px;
  font-weight: 850;
  backdrop-filter: blur(12px);
}

.image-viewport {
  position: relative;
  min-height: 560px;
  background: linear-gradient(180deg, #d9c9ba 0%, #bda997 100%);
}

.image-panel {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.image-panel img,
.image-panel canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border: 0;
  background: #f3eee8;
}

.image-panel > span {
  position: absolute;
  left: 14px;
  bottom: 14px;
  z-index: 3;
  border-radius: 999px;
  padding: 7px 12px;
  color: #fff;
  background: rgba(0, 0, 0, 0.46);
  font-size: 12px;
  font-weight: 850;
  backdrop-filter: blur(12px);
}

.original-panel {
  opacity: 0;
  pointer-events: none;
}

.view-original .original-panel,
.view-generated .generated-panel {
  opacity: 1;
  pointer-events: auto;
}

.view-original .generated-panel {
  opacity: 0;
  pointer-events: none;
}

.view-compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: rgba(255, 255, 255, 0.32);
}

.view-compare .image-panel {
  position: relative;
  inset: auto;
  min-height: 560px;
  opacity: 1;
  pointer-events: auto;
}

.view-compare .image-panel img,
.view-compare .image-panel canvas {
  object-fit: contain;
  object-position: center;
  background: #1d2028;
}

.quality-stack {
  position: absolute;
  z-index: 4;
  left: 14px;
  bottom: 78px;
  display: grid;
  gap: 7px;
  width: min(220px, 58vw);
}

.quality-stack span {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 38px;
  border-radius: 8px;
  padding: 0 13px;
  color: #fff;
  background: rgba(20, 18, 17, 0.56);
  font-size: 13px;
  font-weight: 800;
  backdrop-filter: blur(12px);
}

.quality-stack b {
  font-size: 17px;
}

.view-switch {
  position: absolute;
  z-index: 5;
  left: 14px;
  right: 14px;
  bottom: 18px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.view-switch button,
.chip-row button {
  min-height: 42px;
  border: 0;
  border-radius: 999px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.82);
  font-weight: 850;
}

.view-switch button.active,
.chip-row button.active {
  color: #fff;
  background: var(--rose);
}

.look-summary {
  position: relative;
  display: grid;
  gap: 12px;
  padding: 24px 18px 18px;
  background: var(--paper);
}

.look-summary .eyebrow {
  margin: 0 0 4px;
  color: var(--rose);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.look-summary h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.08;
}

.confidence-pill {
  position: absolute;
  top: 26px;
  right: 18px;
  min-width: 78px;
  border-radius: 999px;
  padding: 8px 11px;
  color: var(--rose);
  background: var(--rose-soft);
  font-size: 12px;
  font-weight: 900;
  text-align: center;
}

.look-summary p {
  margin: 0;
  max-width: 300px;
  color: #4b5260;
  font-size: 15px;
  line-height: 1.65;
}

.axis-list,
.chips,
.wardrobe-strip,
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.axis-list span,
.chips span,
.wardrobe-strip span {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 850;
}

.axis-list span {
  color: #5a3340;
  background: #f8e7e8;
}

.controls-panel,
.result-details {
  display: grid;
  gap: 14px;
  padding: 14px 18px 18px;
}

.upload-card,
.control-group,
.advanced-panel,
.result-details article {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 10px 28px rgba(25, 22, 20, 0.05);
}

.upload-card {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 12px;
  cursor: pointer;
  text-align: left;
}

.upload-card input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.upload-card:focus-visible {
  outline: 3px solid rgba(207, 84, 98, 0.32);
  outline-offset: 2px;
}

.upload-action {
  display: grid;
  place-items: center;
  min-height: 44px;
  border-radius: 999px;
  padding: 0 16px;
  color: #fff;
  background: var(--charcoal);
  font-weight: 900;
}

.upload-card strong {
  min-width: 0;
  overflow: hidden;
  color: #4b5260;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.photo-preview {
  display: none;
}

.control-group,
.advanced-panel,
.result-details article {
  padding: 15px;
}

.control-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

h2,
h3,
h4,
p {
  margin-top: 0;
}

.control-heading h2,
.result-details h3 {
  margin: 0;
  font-size: 17px;
}

.control-heading span,
label,
.preview-empty {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.chip-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}

.background-row {
  grid-template-columns: repeat(4, 1fr);
}

.background-row button {
  font-size: 13px;
}

input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 13px;
  color: var(--ink);
  background: #fff;
}

.advanced-panel summary {
  cursor: pointer;
  font-size: 17px;
  font-weight: 900;
}

.tag-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 14px;
}

.tag-grid button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: #fff;
  font-weight: 800;
}

.tag-grid button.active {
  border-color: transparent;
  color: #fff;
  background: var(--rose);
}

.action-row {
  position: sticky;
  bottom: 0;
  z-index: 6;
  display: grid;
  grid-template-columns: 0.8fr 1.4fr;
  gap: 10px;
  padding: 12px 0 calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(251, 247, 242, 0), var(--soft) 28%);
}

.primary-btn,
.secondary-btn {
  min-height: 54px;
  border-radius: 8px;
  font-weight: 950;
}

.primary-btn {
  border: 0;
  color: #fff;
  background: var(--rose);
}

.primary-btn:disabled {
  cursor: wait;
  opacity: 0.7;
}

.secondary-btn {
  border: 1px solid var(--line);
  color: var(--ink);
  background: #fff;
}

.result-details {
  padding-bottom: 24px;
}

.result-details p,
.result-details li {
  color: #4b5260;
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-line;
}

.two-column {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

ul {
  margin: 0;
  padding-left: 18px;
}

.chips {
  margin: 10px 0 14px;
}

.chips span {
  color: #fff;
}

.wardrobe-strip span {
  color: #5a3340;
  background: var(--rose-soft);
}

@media (min-width: 760px) {
  body {
    background: #eee7de;
  }

  .app-shell {
    min-height: 100vh;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.06), 0 30px 80px rgba(0, 0, 0, 0.14);
  }
}
