:root{
  --ground: #F5F7F6;
  --surface: #FFFFFF;
  --surface-sunken: #EAEFEE;
  --ink: #0D1412;
  --ink-soft: #55625F;
  --ink-faint: #8B9895;
  --line: #DCE4E2;
  --accent: #0D9488;
  --accent-hover: #0F766E;
  --accent-soft: #E3F5F2;
  --accent-ink: #FFFFFF;
  --danger: #D53F52;
  --danger-soft: #FCEBEE;
  --shadow-btn: 0 10px 24px -10px rgba(13,148,136,0.45);
}

@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]){
    --ground: #0A0A0A;
    --surface: #111214;
    --surface-sunken: #191B1D;
    --ink: #FAFAFA;
    --ink-soft: #A1A1AA;
    --ink-faint: #6B6F72;
    --line: rgba(250,250,250,0.1);
    --accent: #2DD4BF;
    --accent-hover: #5EEAD4;
    --accent-soft: #0D2B28;
    --accent-ink: #052E2B;
    --danger: #F1808F;
    --danger-soft: #3A2028;
    --shadow-btn: 0 10px 26px -8px rgba(45,212,191,0.4);
  }
}
:root[data-theme="dark"]{
  --ground: #0A0A0A;
  --surface: #111214;
  --surface-sunken: #191B1D;
  --ink: #FAFAFA;
  --ink-soft: #A1A1AA;
  --ink-faint: #6B6F72;
  --line: rgba(250,250,250,0.1);
  --accent: #2DD4BF;
  --accent-hover: #5EEAD4;
  --accent-soft: #0D2B28;
  --accent-ink: #052E2B;
  --danger: #F1808F;
  --danger-soft: #3A2028;
  --shadow-btn: 0 10px 26px -8px rgba(45,212,191,0.4);
}

*{ box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden]{ display: none !important; }
html{ background: var(--ground); }
body{
  margin:0;
  background:
    radial-gradient(680px 420px at 12% -8%, var(--accent-soft), transparent 60%),
    var(--ground);
  color: var(--ink);
  font-family: "Inter", ui-sans-serif, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

@keyframes step-in{
  from{ opacity: 0; transform: translateY(10px); }
  to{ opacity: 1; transform: translateY(0); }
}
.step{ animation: step-in .35s cubic-bezier(.2,.8,.2,1) both; }
@media (prefers-reduced-motion: reduce){
  .step{ animation: none; }
}

/* ---------- app bar ---------- */
/* Sempre escura, independente do tema do sistema — é a faixa de marca
   (mesmo tratamento do header do site institucional da EvocoreAI). */
.appbar{
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(6,6,16,0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(250,250,250,0.1);
  padding: 14px clamp(16px, 4vw, 32px);
  display: flex;
  justify-content: center;
}
.appbar-logo{
  font-family: "Inter", sans-serif;
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  color: #FAFAFA;
}

/* ---------- main flow ---------- */
.app{
  flex: 1;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 18px clamp(16px, 4vw, 32px) 18px;
}

.step-head{
  margin-bottom: 16px;
}
.step-head h1{
  font-family: "Sora", sans-serif;
  font-weight: 800;
  font-size: clamp(1.55rem, 4.4vw, 1.9rem);
  letter-spacing: -0.02em;
  line-height: 1.18;
  margin: 0 0 8px;
  text-wrap: balance;
}
.step-head p{
  color: var(--ink-soft);
  font-size: 0.96rem;
  line-height: 1.5;
  margin: 0;
}

/* ---------- capture ---------- */
.capture-frame{
  display:flex;
  align-items:center;
  justify-content:center;
  text-align:center;
  min-height: 62vh;
  max-height: 74vh;
  border-radius: 24px;
  border: 1.5px solid var(--line);
  background:
    radial-gradient(220px 160px at 50% 38%, var(--accent-soft), transparent 70%),
    var(--surface);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  padding: 24px;
  box-shadow: 0 1px 2px rgba(20,18,26,0.04);
  transition: border-color .15s ease, box-shadow .15s ease, transform .1s ease;
}
.capture-frame:hover{
  border-color: var(--accent);
  box-shadow: 0 16px 32px -18px rgba(91,61,245,0.35);
}
.capture-frame:active{ transform: scale(0.995); }
.capture-frame img{
  position:absolute; inset:0;
  width:100%; height:100%;
  object-fit: cover;
}
.capture-empty{
  display:flex;
  flex-direction:column;
  align-items:center;
  gap: 6px;
  color: var(--ink-faint);
  position: relative;
  z-index: 1;
}
.capture-frame.has-image .capture-empty{ display: none; }
.capture-icon{
  width: 64px; height: 64px;
  border-radius: 50%;
  display:flex; align-items:center; justify-content:center;
  background: var(--surface);
  color: var(--accent);
  box-shadow: 0 6px 18px -8px rgba(91,61,245,0.35), 0 0 0 1px var(--line);
  margin-bottom: 6px;
}
.capture-empty b{
  color: var(--ink);
  font-size: 1.02rem;
  font-weight: 700;
  margin-top: 4px;
}
.capture-tips{
  display:flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content:center;
  margin-top: 10px;
}
.capture-tips span{
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--ink-soft);
  background: var(--surface-sunken);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
}
input[type=file]{ display:none; }

/* ---------- tabs / chips ---------- */
.tabs{
  display:flex;
  gap: 4px;
  background: var(--surface-sunken);
  border-radius: 10px;
  padding: 3px;
  margin-bottom: 16px;
}
.tab{
  flex:1;
  border:none;
  background: transparent;
  padding: 9px 10px;
  border-radius: 8px;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--ink-soft);
  cursor:pointer;
}
.tab.active{
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.search-row{
  display:flex;
  align-items:center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
  color: var(--ink-faint);
  transition: border-color .12s ease;
}
.search-row:focus-within{ border-color: var(--accent); color: var(--ink-soft); }
.search-row input{
  flex: 1;
  border: none;
  outline: none;
  background: none;
  font-family: inherit;
  font-size: 0.88rem;
  color: var(--ink);
}
.search-row input::placeholder{ color: var(--ink-faint); }
.current-pick{
  display:flex;
  align-items:center;
  gap: 10px;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: 10px;
  padding: 8px 10px;
  margin-bottom: 12px;
}
.current-pick img{
  width: 34px; height: 34px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}
.current-pick span{
  flex: 1;
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--accent);
}
.current-pick button{
  border: none;
  background: none;
  color: var(--accent);
  font-weight: 700;
  font-size: 0.78rem;
  text-decoration: underline;
  cursor: pointer;
}
.gallery-caption{
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 4px 0 10px;
}

.category-row{
  display:flex;
  gap:6px;
  margin-bottom: 12px;
}
.chip{
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  border-radius: 8px;
  padding: 7px 13px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}
.chip.active{
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

/* ---------- style gallery ---------- */
.gallery{
  display:grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.style-card{
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  border: 2px solid transparent;
  cursor: pointer;
  background: var(--surface-sunken);
  text-align:left;
  padding:0;
  aspect-ratio: 1 / 1;
  box-shadow: 0 1px 2px rgba(20,18,26,0.05);
  transition: transform .1s ease, box-shadow .15s ease;
}
.style-card:hover{ transform: translateY(-1px); box-shadow: 0 10px 22px -10px rgba(20,18,26,0.28); }
.style-card.selected{
  border-color: var(--accent);
  box-shadow: 0 10px 24px -10px rgba(91,61,245,0.5);
}
.swatch{
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center 25%;
}
.swatch::after{
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(10,8,14,0.35) 0%, rgba(10,8,14,0) 30%);
  pointer-events: none;
}
.swatch .check{
  position:absolute;
  top:10px; right:10px;
  z-index: 2;
  color: var(--accent);
  opacity: 0;
  transform: scale(0.6);
  transition: opacity .12s ease, transform .12s ease;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4));
}
.style-card.selected .swatch .check{ opacity: 1; transform: scale(1); }
.style-card .label{
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 1;
  padding: 8px 10px 10px;
  pointer-events: none;
}
.style-card .label b{
  display:block;
  font-size: 0.8rem;
  font-weight: 700;
  color: #FFFFFF;
  line-height: 1.25;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

.variant-back{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--ink-soft);
  font-family: inherit;
  font-weight: 600;
  font-size: 0.84rem;
  padding: 4px 0;
  margin-bottom: 10px;
  cursor: pointer;
}
.variant-back:hover{ color: var(--ink); }
.variant-title{
  font-family: "Sora", sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  margin: 0 0 12px;
}
.variant-grid{
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.variant-card{
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  border: 2px solid transparent;
  background-size: cover;
  background-position: center 25%;
  cursor: pointer;
  padding: 0;
  transition: transform .1s ease, border-color .12s ease;
}
.variant-card:hover{ transform: translateY(-1px); border-color: var(--line); }
.variant-loading{
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--ink-faint);
  font-size: 0.88rem;
  padding: 40px 0;
}
.mini-ring{
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

.upload-own{
  border: 1.5px dashed var(--line);
  border-radius: 16px;
  padding: 28px 16px;
  text-align:center;
  color: var(--ink-faint);
  cursor:pointer;
  display:flex;
  flex-direction:column;
  align-items:center;
  gap: 6px;
  position:relative;
  overflow:hidden;
  min-height: 260px;
  justify-content:center;
}
.upload-own:hover{ border-color: var(--accent); }
.upload-own b{ color: var(--ink); font-size: 0.96rem; margin-top: 4px; }
.upload-own small{ font-size: 0.8rem; }
.upload-own img{ position:absolute; inset:0; width:100%; height:100%; object-fit:cover; }
.upload-own.has-image #ownHint{ display:none; }
.upload-own .badge{
  position:absolute; top:10px; left:10px;
  background: rgba(20,18,26,0.72); color:#fff;
  font-size: 0.68rem; font-weight: 600;
  padding: 4px 9px; border-radius: 6px;
}

/* ---------- result ---------- */
.compare{
  position:relative;
  border-radius: 18px;
  overflow:hidden;
  min-height: 260px;
  max-height: 66vh;
  aspect-ratio: 4 / 5; /* trocado via JS pela proporção real assim que a foto carrega */
  background: var(--surface-sunken);
}
/* contain, não cover — a foto gerada pela IA às vezes vem numa proporção
   diferente da foto original, e cover cortava parte dela pra caber no
   quadro. Com contain, a imagem inteira sempre aparece (com uma tarja
   neutra na sobra, se a proporção não bater). */
.compare img{ position:absolute; inset:0; width:100%; height:100%; object-fit: contain; background: var(--surface-sunken); }
.compare .after-layer{ position:absolute; inset:0; clip-path: inset(0 50% 0 0); }
.compare .slider{
  position:absolute; top:0; bottom:0; left:50%;
  width: 3px; background: #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.15);
  cursor: ew-resize;
}
.compare .slider::after{
  content:""; position:absolute; top:50%; left:50%;
  transform: translate(-50%,-50%);
  width: 32px; height: 32px; border-radius: 50%;
  background:#fff; box-shadow: 0 4px 14px rgba(0,0,0,0.3);
}
.compare .tag{
  position:absolute; top:12px; z-index:2;
  font-size: 0.66rem; font-weight:700; letter-spacing:0.03em; text-transform: uppercase;
  padding: 4px 10px; border-radius: 999px;
  background: rgba(20,18,26,0.65); color:#fff;
}
.compare .tag.before{ left:12px; }
.compare .tag.after{ right:12px; }

.processing{
  display:flex; flex-direction:column; align-items:center; justify-content:center;
  gap: 16px; min-height: 380px; color: var(--ink-soft); font-size: 0.9rem;
}
.ring{
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@media (prefers-reduced-motion: reduce){ .ring{ animation: none; } }
@keyframes spin{ to{ transform: rotate(360deg); } }

.error-box{
  background: var(--danger-soft); color: var(--danger);
  border-radius: 12px; padding: 14px 16px; font-size: 0.86rem; line-height: 1.4;
}

.cost-note{
  font-size: 0.76rem; color: var(--ink-faint);
  text-align:center; margin: 12px 0 0;
  font-variant-numeric: tabular-nums;
}

/* ---------- sticky action bar ---------- */
.actionbar{
  position: sticky;
  bottom: 0;
  padding: 0 clamp(16px, 4vw, 32px) calc(16px + env(safe-area-inset-bottom));
  display:flex;
  gap: 10px;
  max-width: 640px;
  margin: 12px auto 0;
  width: 100%;
}
.btn{
  appearance:none; border:none; border-radius: 12px;
  padding: 15px 20px; font-family: "Inter", sans-serif;
  font-weight: 700; font-size: 0.94rem; cursor:pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  color: var(--accent-ink);
  box-shadow: var(--shadow-btn);
  transition: filter .12s ease, transform .08s ease;
  flex: 1;
}
.btn:hover{ filter: brightness(1.06); }
.btn:active{ transform: scale(0.98); }
.btn:disabled{
  background: var(--surface-sunken);
  color: var(--ink-faint);
  border: 1px solid var(--line);
  box-shadow: none;
  cursor: not-allowed;
}
.btn:focus-visible{ outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.ghost{
  background: transparent; color: var(--ink); box-shadow:none;
  border: 1.5px solid var(--line); flex: 0 0 auto; padding-left: 22px; padding-right: 22px;
}
.btn.ghost:hover{ background: var(--surface-sunken); }

/* ---------- footer docs ---------- */
.tech-footer{
  max-width: 640px;
  margin: 0 auto;
  padding: 20px clamp(16px, 4vw, 32px) 40px;
  width: 100%;
}
.tech-footer summary{
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-faint);
  list-style: none;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.tech-footer summary::-webkit-details-marker{ display:none; }
.tech-footer summary::before{ content: "⚙ "; }
.tech-grid{
  display: grid;
  gap: 16px;
  padding: 16px 0 4px;
}
.tech-grid .kicker{
  display:block;
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--accent); margin-bottom: 6px;
}
.tech-grid p{
  color: var(--ink-soft); font-size: 0.85rem; line-height: 1.55; margin: 0;
}
code.inline{
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  background: var(--surface-sunken); border: 1px solid var(--line);
  border-radius: 5px; padding: 1px 6px; font-size: 0.85em; color: var(--ink);
}

.crop-modal{
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(10,8,14,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.crop-modal-inner{
  background: var(--surface);
  border-radius: 18px;
  padding: 16px;
  width: 100%;
  max-width: 460px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.crop-title{
  font-family: "Sora", sans-serif;
  font-weight: 700;
  font-size: 1rem;
  margin: 0;
  text-align: center;
}
.crop-canvas-wrap{
  width: 100%;
  height: min(60vh, 420px);
  background: #000;
  border-radius: 12px;
  overflow: hidden;
}
.crop-canvas-wrap img{ display: block; max-width: 100%; }
.crop-actions{
  display: flex;
  gap: 10px;
}
.crop-actions .btn{ flex: 1; }

@media (min-width: 641px){
  .app{ padding-top: 40px; }
  .capture-frame{ min-height: 480px; max-height: 620px; }
}
