:root {
  --bg: #fbfaf7;
  --paper: #f7efe0;
  --paper-strong: #efe2cc;
  --ink: #11100d;
  --muted: #686157;
  --line: #ded3c2;
  --gold: #b98a34;
  --gold-strong: #94661d;
  --sage: #657063;
  --white: #ffffff;
  --shadow: 0 22px 64px rgba(18, 16, 12, 0.14);
  --soft-shadow: 0 14px 38px rgba(18, 16, 12, 0.1);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  background:
    linear-gradient(90deg, rgba(101, 112, 99, 0.08), transparent 25%, transparent 75%, rgba(185, 138, 52, 0.08)),
    var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.is-modal-open {
  overflow: hidden;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

img {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
}

[hidden] {
  display: none !important;
}

h1,
h2,
p {
  margin: 0;
}

.tryon-shell {
  width: min(100%, 1180px);
  min-height: 100svh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  --brand-tracking: 0.34em;

  display: inline-flex;
  align-items: baseline;
  gap: 0;
  color: var(--ink);
  font-family: "Poppins", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 1.35rem;
  font-weight: 400;
  letter-spacing: var(--brand-tracking);
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
}

.brand strong {
  font-size: 1em;
  font-weight: 800;
}

.brand span:last-child {
  border-bottom: 0;
}

.icon-link {
  display: inline-grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid rgba(17, 16, 13, 0.15);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.7);
  box-shadow: 0 12px 28px rgba(17, 16, 13, 0.07);
  text-decoration: none;
}

.icon-link svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2;
}

.welcome-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
}

.welcome-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 16, 13, 0.36);
  backdrop-filter: blur(8px);
}

.welcome-card {
  position: relative;
  z-index: 1;
  display: grid;
  width: min(100%, 680px);
  gap: 18px;
  justify-items: center;
  padding: 42px 34px 34px;
  border: 1px solid rgba(17, 16, 13, 0.12);
  border-radius: 14px;
  background: rgba(251, 250, 247, 0.97);
  box-shadow: 0 30px 90px rgba(17, 16, 13, 0.26);
  text-align: center;
}

.welcome-close {
  position: absolute;
  top: 12px;
  right: 12px;
  display: inline-grid;
  width: 38px;
  height: 38px;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(17, 16, 13, 0.14);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  cursor: pointer;
}

.welcome-close svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2;
}

.welcome-mark {
  display: grid;
  width: 78px;
  height: 78px;
  place-items: center;
  border-radius: 50%;
  background: #11100d;
  color: #f4d48b;
  box-shadow: var(--soft-shadow);
}

.welcome-mark svg {
  width: 34px;
  height: 34px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2;
}

.welcome-card h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 3rem;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0;
}

.welcome-card p {
  max-width: 560px;
  color: #312d26;
  font-size: 1rem;
  line-height: 1.58;
}

.welcome-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.tryon-app {
  display: grid;
  gap: 18px;
  padding-top: 28px;
}

.hero-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: end;
  border-bottom: 1px solid var(--line);
  padding-bottom: 18px;
}

.hero-panel h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 3.2rem;
  font-weight: 500;
  line-height: 0.98;
  letter-spacing: 0;
}

.hero-panel p {
  max-width: 720px;
  margin-top: 12px;
  color: #312d26;
  font-size: 1rem;
  line-height: 1.58;
}

.credit-meter {
  display: grid;
  min-width: 132px;
  gap: 2px;
  justify-items: center;
  padding: 14px 16px;
  border: 1px solid rgba(185, 138, 52, 0.35);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.75);
  box-shadow: var(--soft-shadow);
}

.credit-meter span {
  color: var(--gold-strong);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2.2rem;
  line-height: 1;
}

.credit-meter small {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.locked-panel {
  display: grid;
  max-width: 620px;
  gap: 14px;
  justify-self: center;
  justify-items: center;
  padding: 34px 20px;
  text-align: center;
}

.access-loading {
  display: grid;
  min-height: 220px;
  place-items: center;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 1rem;
  font-weight: 750;
  text-align: center;
}

.locked-panel h2,
.shirt-panel h2,
.result-panel h2 {
  color: #26221c;
  font-size: 0.84rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  line-height: 1.3;
  text-transform: uppercase;
}

.locked-panel p {
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.55;
}

.tryon-grid {
  display: grid;
  gap: 18px;
  align-items: start;
}

.shirt-panel,
.result-panel {
  display: grid;
  min-width: 0;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.photo-source input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.upload-icon {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border-radius: 50%;
  background: #11100d;
  color: #f4d48b;
}

.upload-icon svg,
.result-empty svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.result-upload strong {
  color: var(--ink);
  font-size: 1rem;
}

.shirt-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.empty-state {
  grid-column: 1 / -1;
  display: grid;
  min-height: 110px;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
  text-align: center;
}

.shirt-choice {
  position: relative;
  display: grid;
  gap: 8px;
  padding: 8px;
  border: 1px solid rgba(17, 16, 13, 0.13);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.7);
  box-shadow: 0 10px 26px rgba(17, 16, 13, 0.06);
  cursor: grab;
  text-align: left;
}

.shirt-choice:active,
.shirt-choice.is-dragging {
  cursor: grabbing;
}

.shirt-choice.is-selected {
  border-color: var(--gold);
  box-shadow:
    0 10px 26px rgba(17, 16, 13, 0.06),
    0 0 0 3px rgba(185, 138, 52, 0.16);
}

.shirt-check {
  position: absolute;
  top: 14px;
  right: 14px;
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 2px solid rgba(17, 16, 13, 0.45);
  border-radius: 6px;
  background: rgba(251, 250, 247, 0.9);
  color: transparent;
  box-shadow: 0 8px 20px rgba(17, 16, 13, 0.12);
  transition:
    border-color 160ms ease,
    background 160ms ease,
    color 160ms ease,
    transform 160ms ease;
}

.shirt-check svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.6;
}

.shirt-choice.is-selected .shirt-check {
  border-color: #11100d;
  background: #11100d;
  color: #f4d48b;
  transform: scale(1.04);
}

.shirt-choice img {
  width: 100%;
  height: auto;
  border-radius: 6px;
  object-fit: contain;
  object-position: center center;
  background: var(--paper);
}

.shirt-choice strong {
  min-height: 32px;
  color: #26221c;
  font-size: 0.86rem;
  line-height: 1.2;
}

.shirt-badges {
  display: flex;
  min-height: 24px;
  flex-wrap: wrap;
  gap: 5px;
}

.shirt-badges span {
  display: inline-flex;
  min-height: 22px;
  align-items: center;
  padding: 0 7px;
  border: 1px solid rgba(101, 112, 99, 0.22);
  border-radius: 999px;
  color: var(--sage);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.result-panel {
  gap: 12px;
}

.result-head {
  display: grid;
  min-width: 0;
  gap: 7px;
}

.selected-shirt-line {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.4;
}

.selected-shirt-line strong {
  color: var(--ink);
}

.status-line {
  min-height: 0;
  color: var(--sage);
  font-size: 0.86rem;
  font-weight: 750;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.result-frame {
  position: relative;
  display: grid;
  width: 100%;
  min-height: 520px;
  overflow: hidden;
  place-items: center;
  border: 1px solid rgba(17, 16, 13, 0.13);
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 50% 20%, rgba(255, 255, 255, 0.95), rgba(247, 239, 224, 0.55) 72%),
    var(--paper);
  box-shadow: var(--shadow);
  transition:
    border-color 180ms ease,
    box-shadow 180ms ease,
    transform 180ms ease;
}

.result-frame.has-upload {
  border-style: dashed;
}

.result-frame.has-photo,
.result-frame.has-result {
  width: min(100%, var(--frame-natural-width, 430px));
  height: auto;
  min-height: 0;
  aspect-ratio: var(--frame-aspect, 4 / 5);
  justify-self: center;
}

#result-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center center;
}

.result-frame.is-drop-target {
  border-color: var(--gold);
  box-shadow:
    var(--shadow),
    0 0 0 4px rgba(185, 138, 52, 0.18);
  transform: translateY(-1px);
}

.result-empty {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 10px;
  justify-items: center;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.result-upload {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  place-content: center;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.photo-source {
  display: grid;
  min-width: 150px;
  gap: 10px;
  justify-items: center;
  padding: 18px;
  border: 1px solid rgba(17, 16, 13, 0.13);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 12px 28px rgba(17, 16, 13, 0.08);
  cursor: pointer;
}

.photo-source:focus-within {
  outline: 3px solid rgba(185, 138, 52, 0.3);
  outline-offset: 3px;
}

.result-upload.is-compact {
  inset: 12px auto auto 12px;
  display: flex;
  max-width: calc(100% - 24px);
  min-height: 44px;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border: 1px solid rgba(17, 16, 13, 0.13);
  border-radius: 999px;
  background: rgba(251, 250, 247, 0.9);
  box-shadow: 0 12px 28px rgba(17, 16, 13, 0.14);
  color: var(--ink);
}

.result-upload.is-compact .photo-source {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.result-upload.is-compact .photo-source + .photo-source {
  padding-left: 10px;
  border-left: 1px solid rgba(17, 16, 13, 0.13);
}

.result-upload.is-compact .upload-icon {
  width: 30px;
  height: 30px;
}

.result-upload.is-compact .upload-icon svg {
  width: 17px;
  height: 17px;
}

.result-upload.is-compact strong {
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  line-height: 1;
  text-transform: uppercase;
}

@media (max-width: 480px) {
  .result-upload:not(.is-compact) {
    align-content: center;
    flex-direction: column;
  }

  .result-upload:not(.is-compact) .photo-source {
    width: min(100%, 260px);
    grid-template-columns: auto 1fr;
    align-items: center;
    justify-items: start;
    text-align: left;
  }

  .result-upload.is-compact {
    align-items: flex-start;
    flex-direction: column;
    border-radius: var(--radius);
  }

  .result-upload.is-compact .photo-source + .photo-source {
    padding-top: 7px;
    padding-left: 0;
    border-top: 1px solid rgba(17, 16, 13, 0.13);
    border-left: 0;
  }
}

.result-empty svg {
  width: 42px;
  height: 42px;
  color: var(--gold-strong);
}

.result-stage {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

.result-frame .stage-person {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center center;
}

.stage-shirt {
  position: absolute;
  right: 12px;
  top: 12px;
  display: grid;
  width: min(30%, 142px);
  gap: 6px;
  padding: 8px;
  border: 1px solid rgba(185, 138, 52, 0.36);
  border-radius: var(--radius);
  background: rgba(251, 250, 247, 0.9);
  box-shadow: 0 18px 40px rgba(17, 16, 13, 0.18);
  text-align: left;
}

.stage-shirt img {
  width: 100%;
  height: auto;
  border-radius: 6px;
  object-fit: contain;
  object-position: center center;
  background: var(--paper);
}

.stage-shirt strong {
  color: #26221c;
  font-size: 0.72rem;
  font-weight: 900;
  line-height: 1.15;
}

.drop-hint {
  position: absolute;
  left: 50%;
  bottom: 18px;
  translate: -50% 0;
  display: none;
  min-height: 34px;
  align-items: center;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(17, 16, 13, 0.88);
  color: #f4d48b;
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.result-frame.is-drop-target .drop-hint {
  display: inline-flex;
}

.action-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 9px;
}

.primary-action,
.secondary-action {
  display: inline-flex;
  min-height: 52px;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
  border: 1px solid #25221d;
  border-radius: var(--radius);
  background: #11100d;
  color: #f4d48b;
  box-shadow: inset 0 -10px 18px rgba(185, 138, 52, 0.14);
  font-size: 0.82rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-decoration: none;
  text-transform: uppercase;
  cursor: pointer;
}

.secondary-action {
  background: rgba(255, 255, 255, 0.75);
  color: var(--ink);
  box-shadow: none;
}

.primary-action:disabled,
.secondary-action:disabled {
  cursor: not-allowed;
  opacity: 0.46;
}

.social-note {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

body.has-buy-bar .tryon-shell {
  padding-bottom: calc(92px + max(20px, env(safe-area-inset-bottom)));
}

.buy-bar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px max(16px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
  border-top: 1px solid var(--line);
  background: rgba(251, 250, 247, 0.93);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.buy-link {
  width: min(100%, 520px);
  min-height: 56px;
}

.buy-note {
  max-width: 520px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.4;
  text-align: center;
}

@media (max-width: 920px) {
  .result-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 640px) {
  .tryon-shell {
    padding-left: 14px;
    padding-right: 14px;
  }

  .hero-panel {
    grid-template-columns: 1fr;
  }

  .hero-panel h1 {
    font-size: 2.45rem;
  }

  .welcome-card {
    align-content: center;
    min-height: min(620px, calc(100svh - 36px));
    padding: 38px 20px 24px;
  }

  .welcome-card h2 {
    font-size: 2.35rem;
  }

  .welcome-actions {
    width: 100%;
  }

  .welcome-actions .primary-action,
  .welcome-actions .secondary-action {
    width: 100%;
  }

  .credit-meter {
    justify-self: start;
  }

  .tryon-grid,
  .shirt-list,
  .action-row {
    grid-template-columns: 1fr;
  }

  .result-frame {
    min-height: 430px;
  }

  .result-frame.has-photo,
  .result-frame.has-result {
    width: 100%;
    min-height: 0;
  }

  .stage-shirt {
    width: min(34%, 128px);
  }
}

@media (max-width: 380px) {
  .brand {
    --brand-tracking: 0.24em;

    font-size: 1.15rem;
  }

  .icon-link {
    width: 40px;
    height: 40px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
