:root {
  color-scheme: light;
  --ink: #172026;
  --muted: #5d6972;
  --paper: #f7f5f0;
  --panel: #ffffff;
  --line: #d8ddd8;
  --sage: #637c68;
  --teal: #236c78;
  --rose: #c86b72;
  --gold: #c49a47;
  --shadow: 0 24px 70px rgba(23, 32, 38, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(135deg, rgba(35, 108, 120, 0.12), transparent 36%),
    linear-gradient(315deg, rgba(200, 107, 114, 0.16), transparent 34%),
    var(--paper);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  width: 100%;
  padding: 28px;
  display: grid;
  place-items: center;
}

.workbench {
  width: min(1180px, 100%);
  max-width: 100%;
  min-width: 0;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(216, 221, 216, 0.9);
  box-shadow: var(--shadow);
  border-radius: 8px;
  overflow: hidden;
}

.topbar {
  min-height: 106px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 26px 30px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.75);
  min-width: 0;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(34px, 6vw, 58px);
  line-height: 0.95;
}

h2 {
  font-size: 26px;
}

.api-pill {
  min-width: 150px;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 14px;
  color: var(--sage);
  font-size: 13px;
  font-weight: 800;
  background: #f4f8f2;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(380px, 1.1fr);
  min-height: 650px;
  min-width: 0;
}

.scan-panel,
.results-panel {
  padding: 28px;
  min-width: 0;
}

.scan-panel {
  border-right: 1px solid var(--line);
  background: #f1eee6;
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 22px;
}

.portrait-stage {
  position: relative;
  min-height: 420px;
  border-radius: 8px;
  overflow: hidden;
  background: linear-gradient(180deg, #f9d6c5 0%, #e7ac9b 55%, #907b69 100%);
  max-width: 100%;
}

#sampleCanvas {
  display: block;
  width: 100%;
  max-width: 100%;
  height: 100%;
  min-height: 420px;
}

.scan-line {
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, transparent 0%, transparent 48%, rgba(35, 108, 120, 0.35) 50%, transparent 52%, transparent 100%);
  animation: scan 3.7s ease-in-out infinite;
}

.heatmap-tag {
  position: absolute;
  left: 18px;
  bottom: 18px;
  padding: 9px 12px;
  border-radius: 999px;
  background: rgba(23, 32, 38, 0.72);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
}

.controls {
  display: grid;
  gap: 13px;
  min-width: 0;
}

.file-drop,
.url-input {
  display: grid;
  gap: 8px;
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.file-drop {
  border: 1px dashed #a8afa7;
  background: rgba(255, 255, 255, 0.58);
  border-radius: 8px;
  padding: 14px;
}

.file-drop input,
.url-input input {
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

.url-input input {
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
}

.mode-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
}

.mode-row label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

button {
  height: 46px;
  width: 100%;
  border: 0;
  border-radius: 6px;
  background: var(--teal);
  color: #fff;
  font-weight: 900;
  cursor: pointer;
}

button:disabled {
  cursor: progress;
  opacity: 0.65;
}

.microcopy {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.results-panel {
  display: grid;
  align-content: start;
  gap: 20px;
  background: var(--panel);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  min-height: 98px;
  background: #fbfcf8;
}

.metric strong {
  display: block;
  font-size: 25px;
}

.metric span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.decision-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  background: linear-gradient(120deg, #fff 0%, #eef5f2 100%);
  min-width: 0;
}

.decision-card p:last-child {
  margin: 14px 0 0;
  max-width: 58ch;
  color: var(--muted);
  line-height: 1.55;
}

.recommendations {
  display: grid;
  gap: 10px;
}

.recommendation {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 12px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  min-width: 0;
}

.recommendation b {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #f6eadc;
  color: #865d18;
}

.recommendation p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.retail-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.product {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  min-height: 150px;
  display: grid;
  grid-template-rows: 1fr auto auto;
  gap: 9px;
  background: #fff;
  min-width: 0;
}

.product span {
  display: block;
  min-height: 64px;
  border-radius: 6px;
}

.product strong {
  font-size: 14px;
}

.product small {
  color: var(--muted);
}

.swatch-sky span {
  background: linear-gradient(135deg, #d8e8ec, #f7d7c8);
}

.swatch-blue span {
  background: linear-gradient(135deg, #1f5e76, #9fbac3);
}

.swatch-pearl span {
  background: linear-gradient(135deg, #f5eee1, #d8b56f);
}

@keyframes scan {
  0%,
  100% {
    transform: translateY(-36%);
  }
  50% {
    transform: translateY(36%);
  }
}

@media (max-width: 840px) {
  .app-shell {
    padding: 0;
    display: block;
  }

  .topbar,
  .workspace {
    display: block;
  }

  .topbar {
    min-height: 0;
  }

  .api-pill {
    margin-top: 14px;
    width: 100%;
  }

  .workbench,
  .scan-panel,
  .results-panel,
  .topbar {
    width: 100%;
  }

  .workbench {
    border-left: 0;
    border-right: 0;
    border-radius: 0;
  }

  .topbar,
  .scan-panel,
  .results-panel {
    padding-left: 16px;
    padding-right: 16px;
  }

  .portrait-stage {
    width: 100%;
  }

  #sampleCanvas {
    height: 480px;
  }

  .microcopy {
    overflow-wrap: anywhere;
  }

  .scan-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .metric-grid,
  .retail-strip {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 30px;
    line-height: 1.08;
    overflow-wrap: anywhere;
  }
}

@media (prefers-reduced-motion: reduce) {
  .scan-line {
    animation: none;
  }
}
