:root {
  --bg: #17141c;
  --bg-soft: #201b28;
  --card: #262030;
  --card-border: #3a3147;
  --text: #f4f0f8;
  --text-dim: #b9b0c7;
  --accent: #e8b4b8;
  --accent-strong: #d98b92;
  --accent-dark: #8a4b54;
  --ok: #9fd8b4;
  --radius: 16px;
  font-size: 16px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  min-height: 100vh;
  line-height: 1.5;
}
.hidden { display: none !important; }

/* Header */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  padding: 16px clamp(16px, 4vw, 40px);
  border-bottom: 1px solid var(--card-border);
  background: linear-gradient(180deg, #1d1826, var(--bg));
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  font-size: 1.6rem;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  width: 48px; height: 48px;
  display: grid; place-items: center;
}
.topbar h1 { font-size: 1.25rem; font-weight: 650; letter-spacing: .2px; }
.tagline { color: var(--text-dim); font-size: .85rem; }
.privacy-badge {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: .8rem; color: var(--ok);
  background: rgba(159, 216, 180, .08);
  border: 1px solid rgba(159, 216, 180, .35);
  padding: 7px 12px; border-radius: 999px;
  white-space: nowrap;
}

main {
  max-width: 760px;
  margin: 0 auto;
  padding: 20px clamp(14px, 4vw, 28px) 40px;
  display: flex; flex-direction: column; gap: 18px;
}
.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
}

/* Upload */
.upload-card { border-style: dashed; border-width: 2px; }
.upload-inner {
  padding: 46px 22px;
  text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.upload-inner.dragging { background: var(--bg-soft); border-radius: var(--radius); }
.upload-icon { font-size: 2.6rem; }
.upload-inner h2 { font-size: 1.35rem; }
.upload-inner p { color: var(--text-dim); max-width: 42ch; }
.upload-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 8px; }
.fine-print { font-size: .78rem; color: var(--text-dim); max-width: 52ch; margin-top: 10px; }

/* Buttons */
.btn {
  appearance: none; border: 0; cursor: pointer;
  font: inherit; font-weight: 600; font-size: .95rem;
  padding: 12px 20px; border-radius: 12px;
  display: inline-flex; align-items: center; gap: 8px;
  transition: transform .06s ease, background .15s ease, opacity .15s;
  text-decoration: none; color: var(--text);
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: default; }
.btn-primary { background: var(--accent-strong); color: #241016; }
.btn-primary:hover:not(:disabled) { background: var(--accent); }
.btn-outline { background: transparent; border: 1.5px solid var(--card-border); }
.btn-outline:hover { border-color: var(--accent); }
.btn-ghost { background: transparent; color: var(--text-dim); }
.btn-ghost:hover { color: var(--text); }
.btn-sm { padding: 9px 14px; font-size: .88rem; }

/* Stage */
.stage { overflow: hidden; }
.stage-viewport {
  position: relative;
  background: #100d15;
  display: grid; place-items: center;
  min-height: 280px;
  touch-action: none;
}
.stage-viewport canvas {
  max-width: 100%; max-height: 58vh;
  width: auto; height: auto;
  display: block;
  grid-area: 1/1;
}
.controls-col { display: flex; flex-direction: column; gap: 18px; }
.notice-orientative {
  background: rgba(238, 194, 127, .1);
  border: 1px solid rgba(238, 194, 127, .45);
  color: #f0d9ae;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: .84rem;
}
@media (min-width: 900px) {
  main { max-width: 1180px; }
  #editor-section {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
    gap: 18px;
    align-items: start;
  }
  #editor-section.hidden { display: none; }
  .controls-col { position: sticky; top: 12px; }
  .stage-viewport canvas { max-height: 74vh; }
}
#canvas-original { pointer-events: none; }
.compare-handle {
  position: absolute; top: 0; bottom: 0; width: 2px;
  background: #fff; box-shadow: 0 0 8px rgba(0,0,0,.7);
  pointer-events: none;
}
.compare-handle span {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 34px; height: 34px; border-radius: 50%;
  background: #fff;
  display: grid; place-items: center;
}
.compare-handle span::before { content: "\21C4"; color: #333; font-size: 16px; }
.stage-loading {
  position: absolute; inset: 0;
  background: rgba(16, 13, 21, .88);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  z-index: 5;
}
.spinner {
  width: 42px; height: 42px;
  border: 4px solid var(--card-border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.stage-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding: 12px 14px;
  border-top: 1px solid var(--card-border);
}
.compare-toggle { display: inline-flex; align-items: center; gap: 8px; font-size: .88rem; color: var(--text-dim); cursor: pointer; }
.compare-toggle input { accent-color: var(--accent-strong); width: 17px; height: 17px; }
.stage-note { padding: 0 14px 12px; font-size: .82rem; color: var(--text-dim); }
.stage-note.warn { color: #eec27f; }

/* Tabs */
.tabs {
  display: flex; gap: 8px;
  background: var(--bg-soft);
  border: 1px solid var(--card-border);
  padding: 6px; border-radius: 14px;
}
.tab {
  flex: 1; padding: 11px; border-radius: 10px;
  background: transparent; border: 0; color: var(--text-dim);
  font: inherit; font-weight: 600; cursor: pointer;
}
.tab.active { background: var(--card); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,.4); }

/* Panels */
.panel { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.panel h3 { font-size: 1.05rem; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.badge-real {
  font-size: .68rem; font-weight: 700; letter-spacing: .3px;
  color: #10321c; background: var(--ok);
  padding: 3px 9px; border-radius: 999px; text-transform: uppercase;
}
.badge-orientative {
  font-size: .68rem; font-weight: 700; letter-spacing: .3px;
  color: #3a2a08; background: #eec27f;
  padding: 3px 9px; border-radius: 999px; text-transform: uppercase;
}
.panel-help { font-size: .86rem; color: var(--text-dim); }
.adjust-hint { font-size: .82rem; color: var(--text-dim); margin: 0 0 8px; }
.swatch-group h4 { font-size: .8rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: .6px; margin-bottom: 8px; }
.swatches {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
  row-gap: 36px; column-gap: 4px;
  justify-items: center;
}
.swatch {
  width: 46px; height: 46px; border-radius: 50%;
  border: 3px solid transparent; cursor: pointer;
  box-shadow: inset 0 -4px 8px rgba(0,0,0,.35), 0 2px 5px rgba(0,0,0,.4);
  transition: transform .08s ease;
  position: relative;
}
.swatch:hover { transform: scale(1.1); }
.swatch.active { border-color: #fff; }
.swatch span {
  position: absolute; top: 108%; left: 50%; transform: translateX(-50%);
  width: 76px; text-align: center;
  font-size: .68rem; line-height: 1.15;
  color: var(--text-dim); white-space: normal;
}

.slider-row { display: flex; align-items: center; gap: 12px; }
.slider-row label { font-size: .86rem; color: var(--text-dim); min-width: 120px; }
.slider-row input[type="range"] { flex: 1; accent-color: var(--accent-strong); height: 26px; }
.slider-row span { font-size: .85rem; min-width: 42px; text-align: right; }

/* Styles grid */
.styles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 10px;
}
.style-thumb {
  background: var(--bg-soft);
  border: 2px solid var(--card-border);
  border-radius: 12px;
  padding: 8px 6px 6px;
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  font: inherit; color: var(--text-dim); font-size: .76rem;
  transition: border-color .12s ease;
}
.style-thumb img { width: 64px; height: 64px; }
.style-thumb:hover { border-color: var(--accent-dark); }
.style-thumb.active { border-color: var(--accent); color: var(--text); }
#style-adjust { display: flex; flex-direction: column; gap: 10px; border-top: 1px solid var(--card-border); padding-top: 14px; }

/* About */
.about { padding: 14px 18px; font-size: .88rem; color: var(--text-dim); }
.about summary { cursor: pointer; font-weight: 600; color: var(--text); }
.about ul { margin: 12px 0 4px 18px; display: flex; flex-direction: column; gap: 8px; }
.about strong { color: var(--text); }

footer {
  text-align: center; padding: 18px;
  color: var(--text-dim); font-size: .78rem;
  border-top: 1px solid var(--card-border);
}

@media (max-width: 480px) {
  .stage-viewport canvas { max-height: 48vh; }
  .topbar h1 { font-size: 1.05rem; }
  .privacy-badge { font-size: .72rem; padding: 6px 10px; }
  .upload-inner { padding: 34px 14px; }
  .swatch { width: 42px; height: 42px; }
  .slider-row label { min-width: 88px; }
}
