:root {
  color-scheme: dark;
  --bg: #080706;
  --panel: #11100f;
  --panel-2: #171412;
  --line: #302925;
  --text: #f4eee8;
  --muted: #afa49a;
  --gold: #c7a15b;
  --red: #8e1d2d;
  --red-bright: #b52b3f;
  --shadow: 0 24px 80px rgba(0, 0, 0, .42);
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 18% 0%, rgba(142, 29, 45, .16), transparent 34rem),
    radial-gradient(circle at 90% 18%, rgba(199, 161, 91, .08), transparent 28rem),
    var(--bg);
  font: 16px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input { font: inherit; }
button, a, label { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }

.app-header {
  min-height: 76px;
  padding: 10px clamp(16px, 4vw, 56px);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  border-bottom: 1px solid rgba(199, 161, 91, .22);
  background: rgba(8, 7, 6, .9);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand img {
  display: block;
  width: 132px;
  height: auto;
}

.back-link {
  color: var(--muted);
  text-decoration: none;
  font-weight: 700;
  justify-self: start;
}

.back-link:hover { color: var(--text); }

.language-switch {
  display: flex;
  justify-self: end;
  gap: 4px;
}

.language-switch button {
  min-width: 42px;
  min-height: 42px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: .875rem;
  font-weight: 800;
  cursor: pointer;
}

.language-switch button.active {
  color: var(--gold);
  border-color: rgba(199, 161, 91, .35);
  background: rgba(199, 161, 91, .08);
}

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: clamp(22px, 4vw, 54px) clamp(14px, 4vw, 54px) 64px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(330px, 440px);
  gap: 28px 34px;
  align-items: start;
}

.workspace-heading {
  grid-column: 1 / -1;
  max-width: 760px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: .18em;
  font-size: .78rem;
  font-weight: 850;
}

h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 5vw, 4.4rem);
  line-height: .98;
  letter-spacing: -.035em;
}

.workspace-heading > p:last-child {
  max-width: 640px;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 1rem;
}

.preview-column { min-width: 0; }

.canvas-frame {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(199, 161, 91, .3);
  border-radius: 22px;
  background: #0c0b0a;
  box-shadow: var(--shadow);
}

#previewCanvas {
  display: block;
  width: 100%;
  height: auto;
  max-height: 68vh;
  object-fit: contain;
  touch-action: none;
  cursor: grab;
}

#previewCanvas:active { cursor: grabbing; }

.canvas-tip {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 28px);
  padding: 9px 13px;
  border: 1px solid rgba(255, 255, 255, .13);
  border-radius: 999px;
  background: rgba(8, 7, 6, .76);
  color: #e8e0d8;
  text-align: center;
  font-size: .82rem;
  backdrop-filter: blur(10px);
  pointer-events: none;
  transition: opacity .25s ease;
}

.canvas-tip.hidden { opacity: 0; }

.quick-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.button,
.upload-button,
.whatsapp-link {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 11px 16px;
  border-radius: 12px;
  border: 1px solid transparent;
  font-weight: 800;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.button-primary,
.whatsapp-link {
  background: linear-gradient(135deg, var(--red-bright), #72121f);
  color: white;
  box-shadow: 0 10px 28px rgba(142, 29, 45, .28);
}

.button-outline,
.upload-button {
  background: rgba(199, 161, 91, .08);
  border-color: rgba(199, 161, 91, .36);
  color: #e7c98e;
}

.button-ghost {
  background: var(--panel-2);
  border-color: var(--line);
  color: var(--muted);
}

.controls {
  display: grid;
  gap: 14px;
}

.mode-switch,
.effect-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #0d0c0b;
}

.mode-switch button,
.effect-row button {
  min-height: 44px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  cursor: pointer;
}

.mode-switch button.active,
.effect-row button.active {
  background: #28221e;
  color: var(--text);
  box-shadow: inset 0 0 0 1px rgba(199, 161, 91, .18);
}

.control-card {
  position: relative;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 14px 12px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(145deg, rgba(25, 22, 20, .96), rgba(14, 13, 12, .96));
}

.step {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(199, 161, 91, .4);
  border-radius: 50%;
  color: var(--gold);
  font-size: .78rem;
  font-weight: 900;
}

.control-card h2 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.25;
}

.control-card p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: .875rem;
}

.control-card > .upload-button,
.control-card > .model-gallery,
.control-card > .button-stack,
.control-card > .check-row,
.adjust-card > .range-row,
.adjust-card > .effect-row,
.adjust-card > .mirror-button {
  grid-column: 2;
}

.model-gallery {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.model-gallery.hidden { display: none; }

.model-card {
  min-width: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #0c0b0a;
  color: var(--muted);
  cursor: pointer;
  transition: border-color .18s ease, transform .18s ease, color .18s ease;
}

.model-card:hover { transform: translateY(-1px); color: var(--text); }

.model-card.active {
  border-color: var(--gold);
  color: #f1d7a4;
  box-shadow: 0 0 0 2px rgba(199, 161, 91, .13);
}

.model-card img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: #0a0908;
}

.model-card span {
  min-height: 38px;
  display: grid;
  place-items: center;
  padding: 6px 4px;
  font-size: .74rem;
  font-weight: 800;
  line-height: 1.15;
}

.upload-button input { display: none; }

.button-stack {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.text-button {
  min-height: 44px;
  padding: 8px 4px;
  border: 0;
  background: transparent;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 4px;
  cursor: pointer;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: .9rem;
}

.check-row input {
  width: 20px;
  height: 20px;
  accent-color: var(--red-bright);
}

.mirror-button {
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid rgba(199, 161, 91, .36);
  border-radius: 10px;
  background: rgba(199, 161, 91, .06);
  color: #e7c98e;
  font-weight: 800;
  cursor: pointer;
}

.mirror-button.active {
  border-color: var(--gold);
  background: rgba(199, 161, 91, .18);
  color: #fff1cf;
}

.range-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 7px 12px;
  color: #ddd3ca;
  font-size: .9rem;
}

.range-row output { color: var(--gold); font-variant-numeric: tabular-nums; }
.range-row input { grid-column: 1 / -1; width: 100%; accent-color: var(--red-bright); }

.privacy-note {
  margin: 0;
  padding: 0 8px;
  color: #91877e;
  font-size: .82rem;
}

.whatsapp-link { width: 100%; }

.whatsapp-hint {
  margin: -7px 8px 0;
  color: #91877e;
  text-align: center;
  font-size: .78rem;
  line-height: 1.4;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 20;
  transform: translate(-50%, 24px);
  padding: 12px 18px;
  border: 1px solid rgba(199, 161, 91, .3);
  border-radius: 12px;
  background: #191512;
  color: var(--text);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: .25s ease;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 900px) {
  .app-header { grid-template-columns: 1fr auto; }
  .brand { display: none; }
  .workspace { grid-template-columns: 1fr; }
  .workspace-heading { grid-column: 1; }
  .controls { grid-row: 3; }
  #previewCanvas { max-height: none; }
}

@media (max-width: 560px) {
  .app-header { min-height: 62px; padding: 8px 12px; }
  .language-switch button { min-width: 38px; min-height: 40px; padding: 0 7px; }
  .app-shell { padding: 22px 10px 48px; }
  .workspace { gap: 20px; }
  .workspace-heading { padding: 0 6px; }
  h1 { font-size: 2.25rem; }
  .canvas-frame { border-radius: 16px; }
  .quick-actions { grid-template-columns: 1fr 1fr; }
  .quick-actions .button-primary { grid-column: 1 / -1; grid-row: 1; }
  .control-card { grid-template-columns: 36px minmax(0, 1fr); padding: 15px 13px; }
  .step { width: 34px; height: 34px; }
  .button-stack { grid-template-columns: 1fr; }
  .control-card > .upload-button,
  .control-card > .model-gallery,
  .control-card > .button-stack,
  .control-card > .check-row,
  .adjust-card > .range-row,
  .adjust-card > .effect-row,
  .adjust-card > .mirror-button { grid-column: 1 / -1; }
  .model-gallery { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
