:root {
  --bg: #f6f7ed;
  --bg-dots: rgba(31, 31, 31, 0.05);
  --card: #ffffff;
  --ink: #1d1f1c;
  --muted: #6b6f66;
  --line: #e6e8dc;
  --soft: #f1f3e7;
  --accent: #16a34a;
  --accent-ink: #ffffff;
  --accent-soft: #dcfce7;
  --danger: #dc2626;
  --shadow: 0 1px 2px rgba(20, 24, 16, 0.04), 0 12px 32px -12px rgba(20, 24, 16, 0.12);
  --radius: 22px;
  --checker-a: #f3f4ee;
  --checker-b: #e9ebe1;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111312;
    --bg-dots: rgba(255, 255, 255, 0.04);
    --card: #1a1d1b;
    --ink: #f2f4ef;
    --muted: #9aa198;
    --line: #2a2f2c;
    --soft: #222624;
    --accent: #22c55e;
    --accent-ink: #062b14;
    --accent-soft: rgba(34, 197, 94, 0.14);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 16px 40px -16px rgba(0, 0, 0, 0.6);
    --checker-a: #202422;
    --checker-b: #262b28;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  font-family: "Plus Jakarta Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background-color: var(--bg);
  background-image: radial-gradient(var(--bg-dots) 1.2px, transparent 1.2px);
  background-size: 22px 22px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; color: inherit; }

svg { width: 1em; height: 1em; fill: currentColor; flex: none; }

/* Icones Lucide (lucide.dev): traco 2px, cantos arredondados, sem preenchimento */
svg.lucide {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px clamp(16px, 4vw, 40px);
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand strong { display: block; font-size: 15px; letter-spacing: -0.01em; }
.brand small { color: var(--muted); font-size: 12px; }

.brand-mark {
  width: 40px; height: 40px;
  border-radius: 13px;
  background: var(--accent);
  display: grid; place-items: center;
  box-shadow: 0 6px 18px -6px var(--accent);
}
.brand-mark svg { width: 26px; height: 26px; fill: #fff; }
.brand-mark .fold { fill: none; stroke: var(--accent); stroke-width: 3; }

.top-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.dev-link {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 14px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 13px; font-weight: 600;
  text-decoration: none;
  transition: transform .15s ease, border-color .15s ease;
}
.dev-link:hover { transform: translateY(-1px); border-color: var(--accent); }
.dev-link svg { width: 16px; height: 16px; }
.dev-link svg.lucide { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Page */
.page {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 8px clamp(16px, 4vw, 40px) 48px;
  flex: 1;
}

.intro { max-width: 640px; margin: 18px 0 28px; }
.intro h1 {
  font-size: clamp(30px, 5vw, 46px);
  line-height: 1.05;
  letter-spacing: -0.035em;
  margin: 0 0 14px;
  font-weight: 800;
}
.intro h1 span { color: var(--accent); }
.intro p { color: var(--muted); margin: 0; font-size: 15px; line-height: 1.6; }

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}
@media (max-width: 860px) { .grid { grid-template-columns: 1fr; } }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Segmented */
.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--soft);
  padding: 4px;
  border-radius: 14px;
  gap: 4px;
}
.seg {
  border: 0;
  background: transparent;
  padding: 10px 12px;
  border-radius: 11px;
  font-size: 14px; font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  transition: background .2s ease, color .2s ease, box-shadow .2s ease;
}
.seg.active {
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 12px -6px rgba(0,0,0,.15);
}
.seg svg { width: 16px; height: 16px; }
.seg.active svg { color: var(--accent); }

/* Dropzone */
.dropzone {
  display: block;
  border: 1.5px dashed var(--line);
  border-radius: 18px;
  background: var(--soft);
  cursor: pointer;
  transition: border-color .2s ease, background .2s ease, transform .2s ease;
}
.dropzone:hover, .dropzone.dragging { border-color: var(--accent); background: var(--accent-soft); }
.dropzone.dragging { transform: scale(1.01); }

.drop-empty {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: 6px;
  padding: 36px 16px;
}
.drop-empty strong { font-size: 15px; }
.drop-empty small { color: var(--muted); font-size: 12.5px; }
.drop-icon {
  width: 46px; height: 46px;
  border-radius: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  display: grid; place-items: center;
  margin-bottom: 6px;
}
.drop-icon svg { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; width: 22px; height: 22px; }

.drop-filled { display: flex; align-items: center; gap: 14px; padding: 12px; }
.thumb {
  width: 64px; height: 64px;
  border-radius: 12px;
  overflow: hidden;
  background: var(--card);
  border: 1px solid var(--line);
  flex: none;
}
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.file-meta { flex: 1; min-width: 0; }
.file-meta strong { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-meta small { color: var(--muted); font-size: 12.5px; }

/* Sound panel */
.sound-panel {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  display: flex; flex-direction: column; gap: 12px;
  animation: rise .25s ease;
}
.sound-head { display: flex; flex-direction: column; gap: 2px; }
.sound-head small { color: var(--muted); font-size: 12.5px; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent);
}
.eyebrow svg.lucide { width: 14px; height: 14px; }

.file-pill {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px;
  border-radius: 12px;
  background: var(--soft);
  font-size: 13.5px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: border-color .2s ease;
}
.file-pill:hover { border-color: var(--accent); }
.file-pill svg { color: var(--accent); width: 18px; height: 18px; }
.file-pill span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.range-row { display: flex; align-items: center; gap: 12px; font-size: 13.5px; }
.range-row label {
  width: 148px; color: var(--muted); flex: none;
  display: inline-flex; align-items: center; gap: 6px;
}
.range-row label svg.lucide { width: 14px; height: 14px; flex: none; }
.range-row output { width: 36px; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.range-row .unit { color: var(--muted); font-size: 12.5px; }
.range-row input[type="number"] {
  width: 84px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
}

input[type="range"] { flex: 1; accent-color: var(--accent); height: 4px; }

/* Options */
.options { display: flex; flex-direction: column; gap: 12px; }

.switch { display: flex; align-items: center; gap: 12px; font-size: 14px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track {
  width: 40px; height: 24px;
  border-radius: 999px;
  background: var(--line);
  position: relative;
  transition: background .2s ease;
  flex: none;
}
.switch .knob {
  position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
  transition: transform .2s ease;
}
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track .knob { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

.credits {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--soft);
  transition: border-color .2s ease, background .2s ease;
}
.credits:hover, .credits[open] { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }
.credits summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  cursor: pointer;
  list-style: none;
  user-select: none;
  border-radius: 14px;
}
.credits summary::-webkit-details-marker { display: none; }
.credits summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.credits-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.credits-text strong {
  font-size: 14px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 7px;
}
.credits-text strong svg.lucide { width: 15px; height: 15px; color: var(--accent); }
.credits-text small {
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.credits-text small.filled { color: var(--accent); }
.credits .chevron {
  width: 18px; height: 18px;
  color: var(--muted);
  transition: transform .25s ease, color .2s ease;
}
.credits:hover .chevron { color: var(--ink); }
.credits[open] .chevron { transform: rotate(180deg); color: var(--accent); }
.credits-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 0 14px 14px;
  animation: rise .2s ease;
}
.credits-fields label { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--muted); }
.credits-fields input, .phone-row input {
  padding: 11px 13px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card);
  font-size: 14px;
  color: var(--ink);
  outline: none;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.credits-fields input:focus, .phone-row input:focus, .range-row input[type="number"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: none;
}

/* Buttons */
.primary, .secondary, .dark, .ghost {
  border: 0;
  border-radius: 14px;
  padding: 13px 18px;
  font-size: 14.5px; font-weight: 700;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  text-decoration: none;
  transition: transform .15s ease, filter .15s ease, opacity .15s ease;
}
.primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 8px 20px -10px var(--accent); }
.primary:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.05); }
.primary:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.primary .btn-label, .dark { display: inline-flex; align-items: center; gap: 8px; }
.primary svg.lucide, .secondary svg.lucide, .dark svg.lucide { width: 16px; height: 16px; }
.secondary { background: var(--soft); color: var(--ink); border: 1px solid var(--line); flex: 1; font-size: 13.5px; }
.secondary:hover { border-color: var(--accent); }
.dark { background: var(--ink); color: var(--card); }
.dark:disabled { opacity: .5; cursor: not-allowed; }
.ghost { background: transparent; border: 1px solid var(--line); }
.ghost.small { padding: 7px 12px; font-size: 12.5px; border-radius: 10px; }
.link {
  background: none; border: 0; padding: 0;
  color: var(--muted);
  font-size: 12.5px; font-weight: 600;
  text-decoration: underline; text-underline-offset: 3px;
  cursor: pointer;
  align-self: center;
}
.link:hover { color: var(--ink); }

.spinner {
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  display: none;
  animation: spin .7s linear infinite;
}
.loading .spinner { display: inline-block; }
.loading { pointer-events: none; }

.form-error {
  margin: 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--danger) 10%, transparent);
  color: var(--danger);
  font-size: 13px;
}

/* Result */
.stage {
  position: relative;
  aspect-ratio: 1;
  border-radius: 18px;
  background-color: var(--checker-a);
  background-image:
    linear-gradient(45deg, var(--checker-b) 25%, transparent 25%),
    linear-gradient(-45deg, var(--checker-b) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--checker-b) 75%),
    linear-gradient(-45deg, transparent 75%, var(--checker-b) 75%);
  background-size: 24px 24px;
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
  display: grid; place-items: center;
  overflow: hidden;
}
.stage img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: contain;
  animation: pop .45s cubic-bezier(.2, 1.4, .4, 1);
}
.stage-empty { display: flex; flex-direction: column; align-items: center; gap: 14px; color: var(--muted); font-size: 13.5px; }
.stage-empty p { margin: 0; }
.ghost-sticker {
  width: 110px; height: 110px;
  border-radius: 28px 28px 54px 28px;
  border: 2px dashed color-mix(in srgb, var(--muted) 45%, transparent);
  animation: float 3.2s ease-in-out infinite;
}

.sound-badge {
  position: absolute; top: 14px; right: 14px;
  z-index: 1;
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 0;
  background: rgba(17, 19, 18, .72);
  color: #fff;
  display: grid; place-items: center;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: transform .15s ease, background .15s ease;
}
.sound-badge:hover { transform: scale(1.06); }
.sound-badge svg { width: 22px; height: 22px; }
.sound-badge.playing { background: var(--accent); animation: pulse 1s ease-in-out infinite; }

.result-meta { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  font-size: 12px; font-weight: 600;
  padding: 6px 11px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--muted);
}
.chip.sound { background: var(--accent-soft); color: var(--accent); }

.downloads { display: flex; gap: 10px; flex-wrap: wrap; }
.note {
  margin: -4px 0 0;
  font-size: 12.5px; color: var(--muted); line-height: 1.5;
  display: flex; gap: 8px; align-items: flex-start;
}
.note svg.lucide { width: 15px; height: 15px; margin-top: 2px; flex: none; color: var(--accent); }

/* Send box */
.send-box {
  border-top: 1px solid var(--line);
  padding-top: 16px;
  display: flex; flex-direction: column; gap: 12px;
}
.send-head { display: flex; align-items: center; gap: 12px; }
.send-head strong {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 14.5px;
}
.send-head strong svg.lucide { width: 16px; height: 16px; color: var(--accent); }
.send-head small { display: block; color: var(--muted); font-size: 12.5px; }
.code-lead {
  margin: 0;
  font-size: 13.5px;
  font-weight: 600;
  text-align: center;
}
.wa-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--line);
  box-shadow: 0 0 0 4px var(--soft);
  flex: none;
}
.wa-dot.waiting { background: #f59e0b; animation: pulse 1.2s ease-in-out infinite; }
.wa-dot.online { background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }

.send-step { display: flex; flex-direction: column; gap: 10px; animation: rise .25s ease; }
.phone-row { display: flex; gap: 8px; }
.phone-row input { flex: 1; min-width: 0; }
.muted { color: var(--muted); font-size: 12.5px; line-height: 1.5; }
.phone-row input { font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.phone-hint { margin-top: -4px; font-size: 12.5px; color: var(--muted); }
.phone-hint.adjusted { color: var(--accent); }
.phone-hint.invalid { color: var(--danger); }

.pair-code {
  font-size: clamp(26px, 5vw, 34px);
  font-weight: 800;
  letter-spacing: .14em;
  text-align: center;
  padding: 16px;
  border-radius: 16px;
  background: var(--soft);
  font-variant-numeric: tabular-nums;
  user-select: all;
}
.steps { margin: 0; padding-left: 20px; font-size: 13px; color: var(--muted); line-height: 1.7; }
.steps b { color: var(--ink); font-weight: 600; }

.send-msg { margin: 0; font-size: 13px; padding: 10px 12px; border-radius: 12px; background: var(--soft); }
.send-msg.ok { background: var(--accent-soft); color: var(--accent); }
.send-msg.err { background: color-mix(in srgb, var(--danger) 10%, transparent); color: var(--danger); }

/* Footer */
.footer {
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px;
  padding: 18px clamp(16px, 4vw, 40px) 26px;
  color: var(--muted);
  font-size: 12px;
  border-top: 1px solid var(--line);
}
.footer a { color: var(--ink); }

[hidden] { display: none !important; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: scale(.7) rotate(-6deg); } to { opacity: 1; transform: none; } }
@keyframes float { 0%, 100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-8px) rotate(3deg); } }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 45%, transparent); } 50% { box-shadow: 0 0 0 8px transparent; } }

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