*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue: #0A4DB2;
  --blue-light: #B6DEFF;
  --white: #FFFFFF;
  --yellow: #ffd027;
  --bg: #062a6b;
  --bg-card: #0a3a8a;
  --bg-surface: #0d3f94;
  --text: #FFFFFF;
  --text-dim: #B6DEFF;
  --radius: 16px;
  --radius-sm: 10px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100dvh;
  overflow-x: hidden;
  background: linear-gradient(180deg, #0A4DB2 0%, #062a6b 40%, #041c4a 100%);
}

button, input { font: inherit; border: 0; background: none; color: inherit; }
input[type="file"] { display: none; }

/* ── LAYOUT ── */
.app {
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  padding: 12px 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── HEADER ── */
.header {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.header-figurinha {
  width: min(90vw, 380px);
  height: auto;
  display: block;
}

/* ── CTA HERO ── */
.cta-hero {
  text-align: center;
}

.cta-hero h1 {
  font-size: 22px;
  font-weight: 900;
  letter-spacing: -.03em;
  line-height: 1.2;
  color: var(--white);
}

.cta-hero .highlight {
  color: var(--yellow);
}

.cta-hero p {
  margin-top: 8px;
  font-size: 14px;
  color: var(--blue-light);
  line-height: 1.5;
  max-width: 340px;
  margin-left: auto;
  margin-right: auto;
}

/* ── PREVIEW AREA ── */
.preview-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

/* ── Instagram circle mock ── */
.ig-mock {
  position: relative;
  width: min(72vw, 300px);
  aspect-ratio: 1;
}

.ig-circle {
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  overflow: hidden;
  background: rgba(255,255,255,.06);
  cursor: pointer;
  z-index: 2;
  touch-action: none;
}

.ig-circle canvas {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.ig-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid transparent;
  background: linear-gradient(var(--bg), var(--bg)) padding-box,
              linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888) border-box;
  z-index: 1;
}

.ig-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--blue-light);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  padding: 20px;
  pointer-events: none;
}

.ig-placeholder.hidden { display: none; }

.ig-caption {
  font-size: 11px;
  color: var(--blue-light);
  text-align: center;
  letter-spacing: .02em;
  opacity: .7;
}

/* ── Square preview (small) ── */
.square-preview {
  position: relative;
  width: min(40vw, 160px);
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.1);
  background: rgba(255,255,255,.06);
  transition: opacity .3s ease;
  touch-action: none;
}

.square-preview.hidden {
  opacity: 0.15;
  pointer-events: none;
}

.square-preview canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.square-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 4px;
  font-size: 9px;
  text-align: center;
  color: rgba(255,255,255,.6);
  background: rgba(0,0,0,.45);
  font-weight: 600;
  letter-spacing: .02em;
}

/* ── CONTROLS ── */
.controls {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--blue-light);
}

/* ── Upload ── */
.upload-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 50px;
  border-radius: var(--radius);
  border: 2px dashed rgba(182,222,255,.3);
  background: rgba(255,255,255,.06);
  color: var(--white);
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}

.upload-btn:active { background: rgba(255,255,255,.1); }
.upload-btn.has-photo {
  border-style: solid;
  border-color: rgba(0,200,83,.5);
  background: rgba(0,200,83,.08);
}
.upload-btn.has-photo svg { stroke: #4caf50; }

/* ── Frames strip ── */
.frames-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.frames-strip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
  scrollbar-width: none;
}

.frames-strip::-webkit-scrollbar { display: none; }

.frame-card {
  flex: 0 0 auto;
  width: 80px;
  cursor: pointer;
  scroll-snap-align: start;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 2px solid transparent;
  background: rgba(255,255,255,.06);
  transition: border-color .15s, transform .1s;
  padding: 0;
}

.frame-card:active { transform: scale(.96); }

.frame-card.selected {
  border-color: var(--yellow);
}

.frame-thumb {
  aspect-ratio: 1;
  width: 100%;
  overflow: hidden;
  background: rgba(0,0,0,.2);
}

.frame-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.frame-name {
  display: block;
  padding: 5px 6px;
  font-size: 10px;
  font-weight: 700;
  color: var(--blue-light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}

.frame-card.selected .frame-name { color: var(--yellow); }

/* ── Adjust ── */
.adjust-section { display: flex; flex-direction: column; gap: 6px; }

.zoom-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.zoom-row input[type="range"] {
  flex: 1;
  height: 6px;
  appearance: none;
  -webkit-appearance: none;
  background: rgba(182,222,255,.15);
  border-radius: 99px;
  outline: none;
}

.zoom-row input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--yellow);
  border: 0;
  cursor: pointer;
}

.zoom-row input[type="range"]::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--yellow);
  border: 0;
  cursor: pointer;
}

.reset-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(255,255,255,.08);
  display: grid;
  place-items: center;
  cursor: pointer;
  color: var(--blue-light);
  flex-shrink: 0;
  transition: background .15s;
}

.reset-btn:active { background: rgba(255,255,255,.15); }

.tip {
  font-size: 11px;
  color: var(--blue-light);
  line-height: 1.4;
  opacity: .7;
}

/* ── Download ── */
.download-btn {
  width: 100%;
  height: 54px;
  border-radius: var(--radius);
  background: var(--yellow);
  color: #062a6b;
  font-weight: 900;
  font-size: 16px;
  cursor: pointer;
  transition: transform .1s, opacity .15s;
  letter-spacing: -.01em;
}

.download-btn:active { transform: scale(.98); }
.download-btn:disabled { opacity: .3; cursor: not-allowed; }

/* ── Share CTA ── */
.share-cta {
  text-align: center;
  padding: 16px;
  border-radius: var(--radius);
  background: rgba(182,222,255,.08);
  border: 1px solid rgba(182,222,255,.12);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.share-text {
  font-size: 15px;
  color: var(--white);
  line-height: 1.5;
  font-weight: 700;
}

.share-text strong {
  color: var(--yellow);
}

.share-sub {
  font-size: 13px;
  color: var(--blue-light);
  line-height: 1.4;
}

.share-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ig-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 12px;
  background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  text-decoration: none;
  transition: transform .1s, opacity .15s;
}

.ig-btn:active { transform: scale(.97); }

.whatsapp-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 12px;
  background: #25D366;
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
  transition: transform .1s, opacity .15s;
}

.whatsapp-btn:active { transform: scale(.97); }

.privacy {
  font-size: 11px;
  color: var(--blue-light);
  text-align: center;
  padding-bottom: 4px;
  opacity: .6;
}

/* ── FOOTER ── */
.site-footer {
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  padding: 16px 16px calc(16px + var(--safe-bottom));
  border-top: 1px solid rgba(182,222,255,.1);
}

.site-footer p {
  font-size: 10px;
  color: var(--blue-light);
  text-align: center;
  opacity: .5;
  line-height: 1.5;
}

/* ── DESKTOP ── */
@media (min-width: 768px) {
  .app {
    max-width: 960px;
    padding: 32px 24px 48px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto 1fr;
    gap: 24px;
    min-height: auto;
  }

  .header {
    grid-column: 1 / -1;
  }

  .header-figurinha { width: min(45vw, 420px); }

  .cta-hero {
    grid-column: 1 / -1;
    text-align: center;
  }

  .cta-hero h1 { font-size: 32px; }

  .preview-area {
    grid-column: 1;
    grid-row: 3;
    position: sticky;
    top: 24px;
  }

  .controls {
    grid-column: 2;
    grid-row: 3;
  }

  .ig-mock { width: min(50vw, 340px); }
  .square-preview { width: min(30vw, 180px); }

  .site-footer {
    max-width: 960px;
  }
}
