:root {
  --bg-top: #050505;
  --bg-bottom: #020202;
  --panel: #050505;
  --panel-strong: #0d0d0d;
  --text-main: #f7f7f5;
  --text-soft: #7d7d79;
  --border: rgba(255, 255, 255, 0.12);
  --shadow: 0 20px 44px rgba(0, 0, 0, 0.42);
  --accent: #9a9a95;
  --accent-strong: #f1f1ed;
  --accent-deep: #a8a8a2;
  --cream: #0a0a0a;
}

* {
  box-sizing: border-box;
}

html,
body {
  overflow-x: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: sans-serif;
  color: var(--text-main);
  background: linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
}

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: stretch;
  margin-bottom: 24px;
}

.hero-copy,
.panel {
  border-radius: 26px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.hero-copy {
  flex: 1;
  padding: 28px 28px 24px;
}

h1,
h2,
h3 {
  margin: 0;
}

h1 {
  font-family: "Montserrat", sans-serif;
  font-size: clamp(2.2rem, 5vw, 3.5rem);
  line-height: 1;
  letter-spacing: -0.02em;
  font-weight: 700;
  color: #f7f8fa;
}

.lead {
  max-width: 38rem;
  margin: 14px 0 0;
  line-height: 1.6;
  color: var(--text-soft);
  font-size: 0.96rem;
  font-family: "Montserrat", sans-serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.app-grid {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  grid-template-areas:
    "upload preview"
    "controls preview"
    "actions preview";
  gap: 24px;
}

.panel {
  padding: 22px;
}

.upload-panel {
  grid-area: upload;
}

.is-hidden {
  display: none !important;
}

.controls-panel {
  grid-area: controls;
}

.controls-panel,
.actions-panel {
  opacity: 1;
  transform: translateY(0);
}

.controls-panel.is-revealing-panel,
.actions-panel.is-revealing-panel {
  animation: panelReveal 360ms ease both;
}

.actions-panel {
  grid-area: actions;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.controls-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.upload-box {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 180px;
  padding: 24px;
  border: 1px dashed rgba(255, 255, 255, 0.14);
  border-radius: 0;
  background: #0c0c0c;
  text-align: center;
  cursor: pointer;
  transition: border-color 180ms ease, background 180ms ease;
}

.upload-box:hover {
  border-color: rgba(255, 255, 255, 0.32);
  background: #101010;
}

.upload-box.is-dragover {
  border-color: rgba(255, 255, 255, 0.42);
  background: #141414;
}

.upload-box input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.upload-title {
  display: block;
  font-family: "Montserrat", sans-serif;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.5;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.upload-sub {
  display: block;
  margin-top: 8px;
  color: var(--text-soft);
  font-size: 0.84rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.control-group {
  display: grid;
  gap: 10px;
}

.control-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.control-group label {
  font-family: "Montserrat", sans-serif;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-soft);
}

.control-value {
  font-family: "Montserrat", sans-serif;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-soft);
}

select,
input[type="color"],
input[type="range"] {
  width: 100%;
}

select,
input[type="color"] {
  height: 48px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 0;
  font: inherit;
  color: var(--text-main);
  background: var(--panel-strong);
}

input[type="color"] {
  padding: 6px;
}

.range-row {
  display: grid;
  grid-template-columns: 42px 1fr 42px;
  align-items: center;
  gap: 12px;
}

.step-btn {
  height: 40px;
  border-radius: 999px;
  background: #101010;
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  font-size: 1.15rem;
  font-weight: 700;
  box-shadow: none;
}

input[type="range"] {
  height: 4px;
  appearance: none;
  background: rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  border: 0;
}

input[type="range"]::-moz-range-track {
  height: 4px;
  background: rgba(255, 255, 255, 0.28);
  border-radius: 999px;
}

input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  border: 0;
}

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

.color-swatch {
  height: 48px;
  border-radius: 0;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: transparent;
  box-shadow: none;
  position: relative;
  overflow: hidden;
}

.color-swatch[data-color="#ffffff"] {
  background: #ffffff;
}

.color-swatch[data-color="#d9d9d9"] {
  background: #d9d9d9;
}

.color-swatch[data-color="#7a7a7a"] {
  background: #7a7a7a;
}

.color-swatch[data-color="#000000"] {
  background: #000000;
}

.color-swatch.is-active {
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.4), 0 0 18px rgba(255, 255, 255, 0.12);
}

.custom-swatch {
  display: grid;
  grid-template-rows: auto 1fr;
  background: #101010;
  cursor: pointer;
  padding: 6px;
  align-items: stretch;
}

.custom-swatch-label {
  font-family: "Montserrat", sans-serif;
  font-size: 0.54rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-soft);
  position: static;
  display: block;
  margin-bottom: 4px;
  line-height: 1;
  text-align: left;
}

.custom-swatch-preview {
  display: block;
  width: 100%;
  min-height: 0;
  flex: 1;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #ffffff;
}

.custom-swatch input[type="color"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  padding: 0;
  border: 0;
}

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

.action-row button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.button-icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.button-icon svg {
  width: 18px;
  height: 18px;
  display: block;
}

button {
  border: 1px solid transparent;
  border-radius: 0;
  height: 48px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease,
    background 180ms ease;
  font-family: "Montserrat", sans-serif;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

button:hover {
  transform: translateY(-2px);
}

.secondary-btn {
  background: #f5f5f0;
  color: #0a0a0a;
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: none;
}

.ghost-btn {
  background: #0c0c0c;
  color: var(--text-main);
  border-color: rgba(255, 255, 255, 0.16);
  box-shadow: none;
}


.preview-panel {
  grid-area: preview;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.preview-note {
  margin: 0;
  padding-left: 4px;
  font-family: "Montserrat", sans-serif;
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  color: var(--text-soft);
  text-align: left;
  opacity: 0;
  transform: translateY(8px);
}

.preview-panel.has-image .preview-note {
  opacity: 1;
  transform: translateY(0);
}

.preview-panel.is-revealing-note .preview-note {
  animation: panelReveal 360ms ease both;
}

.canvas-wrap {
  position: relative;
  border-radius: 0;
  padding: 0;
  background: #0c0c0c;
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: grid;
  place-items: center;
  overflow: hidden;
}

canvas {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: 70vh;
  margin: 0 auto;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  cursor: crosshair;
  opacity: 1;
  transition: opacity 320ms ease;
}

.canvas-wrap.is-revealing canvas {
  opacity: 0;
}

.canvas-wrap.is-loading canvas {
  opacity: 0;
}

.loading-overlay {
  position: absolute;
  inset: 0;
  display: block;
  background: transparent;
  z-index: 2;
  pointer-events: none;
}

.loading-surface {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #0f0f0f;
}

.loading-stage {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.01));
}

.shimmer-block {
  position: relative;
  overflow: hidden;
}

.shimmer-block::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.04) 35%,
    rgba(255, 255, 255, 0.18) 50%,
    rgba(255, 255, 255, 0.04) 65%,
    transparent 100%
  );
  animation: shimmer 1.6s ease-in-out infinite;
}

.canvas-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  pointer-events: none;
  color: var(--text-soft);
}

.canvas-placeholder p {
  margin: 0;
  font-family: "Montserrat", sans-serif;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.canvas-placeholder span {
  display: block;
  margin-top: 8px;
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.canvas-placeholder[hidden] {
  display: none !important;
}

@keyframes shimmer {
  to {
    transform: translateX(100%);
  }
}

@keyframes panelReveal {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

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

@media (max-width: 960px) {
  .hero,
  .app-grid {
    display: grid;
    grid-template-columns: 1fr;
  }

  .page-shell {
    width: min(100% - 24px, 375px);
    padding: 20px 0 32px;
  }

  .hero {
    gap: 16px;
    margin-bottom: 16px;
  }

  .hero-copy,
  .panel {
    border-radius: 22px;
  }

  .hero-copy {
    padding: 22px 20px;
  }

  h1 {
    font-size: clamp(2.2rem, 11vw, 3.2rem);
  }

  .lead {
    font-size: 0.95rem;
    line-height: 1.7;
  }

  .app-grid {
    grid-template-areas:
      "upload"
      "preview"
      "controls"
      "actions";
    gap: 16px;
  }

  .panel {
    padding: 16px;
  }

  .controls-panel {
    gap: 12px;
  }

  .upload-box {
    min-height: 144px;
    padding: 18px;
    border-radius: 0;
  }

  .upload-title {
    font-size: 1rem;
  }

  .upload-sub {
    font-size: 0.88rem;
  }

  .range-row {
    grid-template-columns: 44px 1fr 44px;
    gap: 10px;
  }

  .step-btn {
    height: 44px;
  }

  button,
  select,
  input[type="color"] {
    height: 52px;
  }

  .tips-card {
    padding: 16px;
    border-radius: 18px;
  }

  .status-pill {
    white-space: normal;
    line-height: 1.45;
  }

  .canvas-wrap {
    min-height: 272px;
    padding: 0;
    border-radius: 0;
  }

  canvas {
    width: auto;
    max-width: min(100%, 320px);
    height: auto;
    max-height: 40vh;
    border-radius: 0;
  }

  .loading-surface {
    width: 100%;
    height: 100%;
  }

  .loading-stage {
    width: 100%;
    height: 100%;
    aspect-ratio: auto;
  }

}

@media (max-width: 640px) {
  .page-shell {
    width: min(100% - 16px, 375px);
    padding-top: 12px;
  }

  .hero-copy,
  .hero-card,
  .panel {
    border-radius: 20px;
  }

  .hero-copy,
  .panel {
    padding: 16px;
  }

  .action-row {
    grid-template-columns: 1fr 1fr;
  }


  .canvas-wrap {
    min-height: 248px;
    padding: 0;
  }

  canvas {
    width: auto;
    max-width: min(100%, 300px);
    height: auto;
    max-height: 36vh;
  }

  .loading-surface {
    width: 100%;
    height: 100%;
  }

  .loading-stage {
    width: 100%;
    height: 100%;
    aspect-ratio: auto;
  }

  .control-group {
    gap: 6px;
  }

  .range-row {
    grid-template-columns: 40px 1fr 40px;
    gap: 8px;
  }

  .step-btn {
    height: 40px;
  }

  .color-presets {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
  }

  .color-swatch {
    height: 42px;
  }

  .tips-card ul {
    padding-left: 16px;
    line-height: 1.65;
  }
}
