:root {
  --bg: #09131a;
  --bg-soft: #122330;
  --panel: rgba(10, 20, 28, 0.86);
  --panel-border: rgba(255, 255, 255, 0.08);
  --text: #f4efe6;
  --text-muted: rgba(244, 239, 230, 0.72);
  --line: rgba(255, 255, 255, 0.08);
  --accent: #ff7a59;
  --accent-strong: #ff613a;
  --accent-soft: rgba(255, 122, 89, 0.14);
  --surface: rgba(255, 255, 255, 0.04);
  --surface-strong: rgba(255, 255, 255, 0.07);
  --good: #7ad4a2;
  --shadow: 0 32px 90px rgba(0, 0, 0, 0.34);
  --radius-xl: 30px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Manrope", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(255, 122, 89, 0.16), transparent 32%),
    radial-gradient(circle at bottom right, rgba(83, 166, 255, 0.16), transparent 28%),
    linear-gradient(160deg, #081219 0%, #0d1c26 58%, #061017 100%);
  color: var(--text);
  overflow-x: hidden;
}

html.is-embedded,
html.is-embedded body {
  min-height: 0;
  overflow-x: hidden;
  scrollbar-width: none;
}

html.is-embedded body {
  background: transparent;
}

html.is-embedded::-webkit-scrollbar,
html.is-embedded body::-webkit-scrollbar {
  display: none;
}

html.is-embedded .ambient {
  display: none;
}

html.is-embedded .app-shell {
  width: 100%;
  margin: 0 auto;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.ambient {
  position: fixed;
  width: 42rem;
  height: 42rem;
  border-radius: 999px;
  filter: blur(110px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.35;
}

.ambient-left {
  top: -10rem;
  left: -8rem;
  background: rgba(255, 132, 94, 0.28);
}

.ambient-right {
  right: -10rem;
  bottom: -12rem;
  background: rgba(81, 162, 255, 0.22);
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1600px, calc(100vw - 32px));
  margin: 20px auto;
  padding: 22px;
  border: 1px solid var(--panel-border);
  border-radius: 34px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 24%),
    rgba(5, 13, 18, 0.7);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.topbar,
.workspace,
.panel-section,
.section-heading,
.topbar-actions,
.product-toggle,
.color-swatches,
.quick-actions,
.stage-header,
.stage-footer,
.chip-row,
.range-meta {
  display: flex;
}

.topbar,
.workspace,
.stage-header,
.stage-footer {
  justify-content: space-between;
}

.topbar,
.stage-header,
.range-meta {
  align-items: center;
}

.topbar {
  gap: 20px;
  padding: 8px 6px 26px;
}

.brand-banner {
  padding: 6px 6px 22px;
}

.brand-banner h1 {
  max-width: none;
  font-size: clamp(1.65rem, 3vw, 2.6rem);
  line-height: 1;
}

.brand-logo {
  width: clamp(96px, 12vw, 170px);
  height: auto;
  display: block;
  border-radius: 12px;
  object-fit: contain;
}

.topbar h1,
.stage-header h2,
.panel-section h2 {
  margin: 0;
  font-family: "Archivo", sans-serif;
  letter-spacing: -0.04em;
}

.topbar h1 {
  max-width: 12ch;
  font-size: clamp(2rem, 4.5vw, 3.6rem);
  line-height: 0.98;
}

.brand-banner h1 {
  max-width: none;
  font-size: clamp(1.65rem, 3vw, 2.6rem);
  line-height: 1;
}

.eyebrow {
  margin: 0 0 10px;
  font-size: 0.74rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(244, 239, 230, 0.64);
}

.topbar-actions {
  gap: 12px;
  flex-wrap: wrap;
}

.workspace {
  gap: 18px;
  align-items: stretch;
}

.panel,
.stage-panel {
  min-height: 760px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 40%),
    var(--panel);
  backdrop-filter: blur(20px);
}

.panel {
  width: min(330px, 100%);
  padding: 18px;
}

.panel-left,
.panel-right {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel-section {
  flex-direction: column;
  gap: 18px;
  padding: 18px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--line);
}

.panel-section.compact {
  margin-top: auto;
}

.section-heading {
  gap: 14px;
  align-items: flex-start;
}

.section-heading p {
  margin: 6px 0 0;
  color: var(--text-muted);
  font-size: 0.94rem;
  line-height: 1.5;
}

.section-kicker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 800;
  flex: 0 0 auto;
}

.ghost-button,
.accent-button,
.secondary-button,
.upload-button,
.product-chip,
.swatch-button {
  border: 1px solid transparent;
  transition:
    transform 160ms ease,
    background-color 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease,
    color 160ms ease;
}

.ghost-button,
.secondary-button {
  padding: 0.9rem 1.05rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--line);
  color: var(--text);
}

.accent-button {
  padding: 0.95rem 1.2rem;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  color: #fff8f0;
  font-weight: 800;
  box-shadow: 0 14px 34px rgba(255, 97, 58, 0.26);
}

.ghost-button:hover,
.secondary-button:hover,
.upload-button:hover,
.product-chip:hover,
.swatch-button:hover,
.accent-button:hover {
  transform: translateY(-1px);
}

.product-toggle,
.color-swatches,
.quick-actions,
.chip-row {
  flex-wrap: wrap;
  gap: 10px;
}

.product-toggle,
.color-swatches {
  width: 100%;
  flex-direction: column;
}

.dropdown-control {
  width: 100%;
  min-height: 52px;
  padding: 0 42px 0 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.02)),
    #15232e;
  outline: none;
  cursor: pointer;
}

.dropdown-control:focus-visible {
  border-color: rgba(255, 122, 89, 0.64);
  outline: 2px solid rgba(255, 122, 89, 0.28);
  outline-offset: 2px;
}

.dropdown-control option {
  background: #15232e;
  color: var(--text);
}

.color-dropdown {
  position: relative;
  width: 100%;
}

.color-dropdown-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
}

.color-dropdown-trigger::after {
  content: "";
  width: 8px;
  height: 8px;
  margin-left: auto;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
  opacity: 0.72;
}

.color-dropdown-menu {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  display: grid;
  gap: 2px;
  max-height: 280px;
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #15232e;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.34);
}

.color-dropdown-menu[hidden] {
  display: none;
}

.color-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 0;
  border-radius: 10px;
  color: var(--text);
  background: transparent;
  text-align: left;
}

.color-option:hover {
  background: rgba(255, 255, 255, 0.07);
}

.color-swatch {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--swatch);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.22),
    0 0 0 1px rgba(0, 0, 0, 0.24);
}

.product-chip {
  min-width: 120px;
  padding: 0.95rem 1rem;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.045);
  border-color: var(--line);
  color: var(--text);
  text-align: left;
}

.product-chip strong,
.product-chip span {
  display: block;
}

.product-chip strong {
  font-size: 1rem;
}

.product-chip span {
  margin-top: 0.2rem;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.product-chip.is-active {
  background: linear-gradient(180deg, rgba(255, 122, 89, 0.18), rgba(255, 255, 255, 0.06));
  border-color: rgba(255, 122, 89, 0.5);
  box-shadow: inset 0 0 0 1px rgba(255, 122, 89, 0.08);
}

.swatch-button {
  position: relative;
  width: calc(33.333% - 7px);
  min-width: 88px;
  padding: 12px 10px 10px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--line);
  color: var(--text);
}

.swatch-button::before {
  content: "";
  display: block;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 12px;
  background: var(--swatch);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
  margin-bottom: 10px;
}

.swatch-button span {
  display: block;
  font-size: 0.8rem;
  line-height: 1.2;
}

.swatch-button.is-active {
  border-color: rgba(255, 122, 89, 0.48);
  box-shadow: 0 0 0 1px rgba(255, 122, 89, 0.18);
}

.upload-button {
  display: grid;
  gap: 6px;
  justify-items: start;
  padding: 1.2rem 1.1rem;
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03)),
    rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.1);
  color: var(--text);
}

.upload-button span {
  font-weight: 800;
  font-size: 1rem;
}

.upload-button small {
  color: var(--text-muted);
}

.artwork-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.025);
}

.artwork-panel h3 {
  margin: 0;
  font-size: 0.9rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.artwork-panel .upload-button {
  padding: 0.95rem 1rem;
}

.quick-actions .secondary-button {
  flex: 1 1 74px;
  padding-inline: 0.65rem;
}

.info-card {
  display: grid;
  gap: 6px;
  padding: 18px;
  border-radius: 18px;
  background:
    linear-gradient(140deg, rgba(255, 122, 89, 0.14), rgba(255, 255, 255, 0.03) 62%),
    rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 122, 89, 0.14);
}

.info-card strong {
  font-size: 1.08rem;
}

.info-card span,
.info-card p {
  color: var(--text-muted);
}

.info-card p {
  margin: 4px 0 0;
  line-height: 1.45;
}

.export-actions {
  display: flex;
  gap: 10px;
}

.export-panel-button {
  flex: 1 1 0;
  width: 100%;
}

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

.stage-panel {
  flex: 1;
  min-width: 0;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.stage-header h2 {
  font-size: 1.8rem;
}

.stage-note,
.footnote {
  margin: 0;
  color: var(--text-muted);
}

.canvas-shell {
  position: relative;
  flex: 0 0 auto;
  min-height: 0;
  display: grid;
  place-items: center;
  aspect-ratio: var(--stage-aspect-ratio, 900 / 840);
  padding: clamp(8px, 1.2vw, 16px);
  border-radius: 28px;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.08), transparent 54%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 28%),
    #172935;
  border: 1px solid rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.preview-grid {
  flex: 0 0 auto;
  min-height: 0;
  gap: 14px;
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
}

.canvas-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.86), transparent);
  pointer-events: none;
}

.canvas-shell .canvas-container {
  position: relative;
  z-index: 1;
  width: 100% !important;
  height: auto !important;
  aspect-ratio: var(--stage-aspect-ratio, 900 / 840);
  max-width: 100%;
  max-height: 100%;
  overflow: hidden;
  border-radius: 28px;
  box-shadow: 0 34px 80px rgba(0, 0, 0, 0.28);
  animation: canvasIn 520ms ease;
}

.canvas-shell .canvas-container canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
  border-radius: 28px;
}

.canvas-shell .upper-canvas {
  touch-action: none !important;
}

.preview-badge {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 3;
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  background: rgba(8, 17, 24, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-muted);
  font-size: 0.76rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.canvas-shell.is-dragging {
  border-color: rgba(255, 122, 89, 0.52);
  box-shadow: inset 0 0 0 2px rgba(255, 122, 89, 0.15);
}

.drop-indicator {
  position: absolute;
  inset: auto auto 20px 20px;
  z-index: 2;
  padding: 0.7rem 0.9rem;
  border-radius: 999px;
  background: rgba(8, 17, 24, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-muted);
  font-size: 0.84rem;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.canvas-shell.is-dragging .drop-indicator {
  opacity: 1;
  transform: translateY(0);
}

.chip {
  padding: 0.55rem 0.8rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  color: var(--text-muted);
  font-size: 0.82rem;
}

.panel-right .inspector-grid {
  display: grid;
  gap: 12px;
}

.range-card {
  display: grid;
  gap: 10px;
  padding: 14px 14px 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
}

.range-card input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.range-meta output,
.range-meta span {
  font-size: 0.92rem;
}

.range-meta output {
  color: var(--text-muted);
}

button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid rgba(255, 122, 89, 0.72);
  outline-offset: 2px;
}

@keyframes canvasIn {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.985);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 1260px) {
  .workspace {
    flex-direction: column;
  }

  .panel {
    width: 100%;
    min-height: auto;
  }

  .stage-panel {
    min-height: auto;
  }

  .panel-left,
  .panel-right {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }

  .preview-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .panel-left .compact,
  .panel-right .panel-section {
    margin-top: 0;
  }
}

@media (max-width: 860px) {
  html.is-embedded,
  html.is-embedded body {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  * {
    transition-duration: 0ms !important;
    animation-duration: 0ms !important;
  }

  .workspace {
    display: contents;
  }

  .app-shell {
    display: flex;
    flex-direction: column;
  }

  .panel-left {
    display: contents;
  }

  .garment-section {
    order: 1;
  }

  .stage-panel {
    order: 2;
  }

  .artwork-section {
    order: 3;
  }

  .export-section {
    order: 4;
  }

  .app-shell {
    width: 100%;
    margin: 0;
    padding: 10px;
    border-radius: 18px;
    box-shadow: none;
    backdrop-filter: none;
  }

  .topbar,
  .stage-header,
  .stage-footer {
    flex-direction: column;
    align-items: flex-start;
  }

  .brand-banner {
    flex-direction: row;
    align-items: center;
    gap: 10px;
    padding-bottom: 14px;
  }

  .brand-banner h1 {
    font-size: clamp(1.3rem, 7vw, 2rem);
  }

  .brand-logo {
    width: clamp(72px, 23vw, 108px);
  }

  .topbar-actions,
  .product-toggle,
  .color-swatches,
  .quick-actions,
  .chip-row {
    width: 100%;
  }

  .topbar-actions button,
  .quick-actions button {
    flex: 1 1 0;
  }

  .panel-left,
  .panel-right {
    grid-template-columns: minmax(0, 1fr);
  }

  .panel,
  .stage-panel,
  .panel-section {
    padding: 12px;
    backdrop-filter: none;
  }

  .workspace,
  .stage-panel,
  .panel-left,
  .panel-right {
    gap: 12px;
  }

  .canvas-shell,
  .canvas-shell .canvas-container,
  .canvas-shell .canvas-container canvas {
    border-radius: 18px;
  }

  .canvas-shell .canvas-container {
    box-shadow: none;
    animation: none;
  }

  .preview-badge {
    top: 8px;
    left: 8px;
    padding: 0.35rem 0.55rem;
    font-size: 0.68rem;
  }

  .swatch-button {
    width: calc(50% - 5px);
  }

  .drop-indicator {
    inset: auto 14px 14px 14px;
    text-align: center;
  }
}

@media (max-width: 560px) {
  .topbar h1 {
    font-size: 2rem;
  }

  .stage-panel,
  .panel,
  .panel-section {
    border-radius: 20px;
  }

  .swatch-button,
  .product-chip {
    width: 100%;
  }
}
