:root {
  --bg: #fdf6f1;
  --card: #ffffff;
  --ink: #2b1740;
  --muted: #7d6f8c;
  --line: #eadff0;
  --pink: #e0397a;
  --violet: #7a3cf0;
  --gold: #f7a928;
  --teal: #12a594;
  --grad: linear-gradient(135deg, #e0397a 0%, #a23bd6 55%, #7a3cf0 100%);
  --grad-gold: linear-gradient(135deg, #ffd36b 0%, #f7a928 55%, #f08a1c 100%);
  --accent: #b23bc4;
  --accent-ink: #ffffff;
  --accent-soft: #f6e9fb;
  --ok: #12a594;
  --err: #c0283f;
  --radius: 20px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg);
  background-image:
    radial-gradient(900px 500px at 8% -10%, rgba(224, 57, 122, 0.20), transparent 60%),
    radial-gradient(800px 480px at 105% 0%, rgba(122, 60, 240, 0.20), transparent 60%),
    radial-gradient(700px 500px at 50% 110%, rgba(247, 169, 40, 0.18), transparent 60%);
  background-attachment: fixed;
  min-height: 100vh;
}
.wrap { max-width: 780px; margin: 0 auto; padding: 22px 16px 56px; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Marca */
.brand { text-align: center; padding: 18px 0 10px; }
.logo {
  width: 68px; height: 68px; margin: 0 auto 10px; border-radius: 22px; display: grid; place-items: center;
  font-size: 32px; line-height: 1; background: var(--grad);
  box-shadow: 0 10px 28px rgba(162, 59, 214, 0.38), inset 0 0 0 2px rgba(255, 255, 255, 0.35);
  transform: rotate(-6deg);
}
.brand h1 {
  margin: 8px 0 4px; font-family: var(--serif); font-weight: 700; font-size: clamp(28px, 6vw, 38px);
  letter-spacing: -0.5px; line-height: 1.15;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.sub { margin: 0; color: var(--muted); font-size: 17px; }

/* Cartões */
.card {
  position: relative; overflow: hidden;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 20px 20px;
  margin: 18px 0;
  box-shadow: 0 12px 34px rgba(122, 60, 240, 0.10), 0 2px 6px rgba(43, 23, 64, 0.04);
}
.card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 5px; background: var(--grad); }
#loading.card::before { background: var(--grad-gold); }
#result.card::before { background: linear-gradient(90deg, var(--teal), var(--violet), var(--pink)); }
.card h2 { margin: 4px 0 14px; font-family: var(--serif); font-size: 22px; line-height: 1.25; }
.card h3 { margin: 0 0 8px; font-family: var(--serif); font-size: 17px; }
.center { text-align: center; }

.banner {
  background: linear-gradient(135deg, #fff4d6, #ffe9b8); border: 1px solid #f3cf7e; color: #6b4a00;
  border-radius: 14px; padding: 12px 16px; margin: 14px 0; font-size: 15px;
}
.banner.info { background: linear-gradient(135deg, #fde7f1, #efe5ff); border-color: #dcc3f3; color: #54207f; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hint { color: var(--muted); font-size: 13px; font-weight: 400; margin: 4px 0 0; }
#aiInfo {
  display: inline-flex; align-items: center; gap: 8px; background: #fff; border: 1px solid var(--line);
  padding: 6px 12px; border-radius: 999px; box-shadow: 0 2px 8px rgba(122, 60, 240, 0.08);
}
#aiInfo::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 0 3px rgba(18, 165, 148, 0.2); }

/* Campos */
.field { margin-bottom: 16px; }
.field > label, .picker > label { display: block; font-weight: 650; margin-bottom: 6px; font-size: 15px; color: #3a1f58; }
.grid2 { display: grid; grid-template-columns: 1fr; gap: 0 16px; }
@media (min-width: 640px) { .grid2 { grid-template-columns: 1fr 1fr; } }

input, select, textarea {
  width: 100%; font: inherit; color: inherit; background: #fdfbff;
  border: 1.5px solid var(--line); border-radius: 14px; padding: 12px 14px; min-height: 48px;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
input::placeholder, textarea::placeholder { color: #b3a7c0; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--violet); background: #fff; box-shadow: 0 0 0 4px rgba(122, 60, 240, 0.14);
}
input.invalid, select.invalid, textarea.invalid { border-color: var(--err); box-shadow: 0 0 0 4px rgba(192, 40, 63, 0.10); }

/* Botões */
.btn {
  font: inherit; font-weight: 650; border: 0; border-radius: 14px; padding: 13px 20px; min-height: 50px;
  cursor: pointer; transition: transform 0.08s, box-shadow 0.2s, filter 0.2s, opacity 0.2s;
}
.btn:hover:not(:disabled) { filter: brightness(1.05); }
.btn:active { transform: scale(0.98); }
.btn:focus-visible, .chip:focus-visible, .hl:focus-visible, .copy-mini:focus-visible { outline: 3px solid rgba(122, 60, 240, 0.45); outline-offset: 2px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.primary { background: var(--grad); color: var(--accent-ink); box-shadow: 0 8px 20px rgba(162, 59, 214, 0.34); }
.btn.secondary { background: var(--grad-gold); color: #4a2a00; box-shadow: 0 8px 20px rgba(247, 169, 40, 0.34); }
.btn.ghost { background: #fff; color: #4a2a6e; border: 1.5px solid var(--line); }
.btn.ghost:hover:not(:disabled) { border-color: var(--violet); }
.btn.small { min-height: 38px; padding: 6px 14px; font-size: 14px; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 10px; }
.actions .btn { flex: 1 1 220px; }
#loginForm .btn { width: 100%; margin-top: 12px; }

.error { color: var(--err); font-weight: 600; margin: 10px 0 0; }

/* Upload */
.drop {
  display: block; text-align: center; padding: 22px 16px; border: 2px dashed #cdb3f0; border-radius: 16px;
  background: linear-gradient(135deg, #fff5fa, #f4eeff); font-weight: 650; cursor: pointer; color: #6a2fb8;
  transition: border-color 0.15s, background 0.15s;
}
.drop:hover { border-color: var(--pink); background: linear-gradient(135deg, #ffeaf3, #efe6ff); }
.thumbs { list-style: none; margin: 12px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; }
.thumbs li { position: relative; border-radius: 14px; overflow: hidden; border: 2px solid #fff; background: #fff; box-shadow: 0 4px 12px rgba(43, 23, 64, 0.14); }
.thumbs img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.thumbs .tag { position: absolute; left: 6px; top: 6px; background: var(--grad); color: #fff; font-size: 12px; font-weight: 700; padding: 1px 8px; border-radius: 999px; }
.thumbs button { position: absolute; right: 4px; top: 4px; border: 0; background: rgba(255, 255, 255, 0.94); border-radius: 999px; width: 28px; height: 28px; font-size: 16px; cursor: pointer; }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip {
  font: inherit; font-size: 14px; font-weight: 600; border: 1.5px solid var(--line); background: #fff; color: #4a2a6e;
  border-radius: 999px; padding: 6px 14px; cursor: pointer; transition: background 0.15s, border-color 0.15s, transform 0.08s;
}
.chip:hover { transform: translateY(-1px); }
.chip:nth-child(5n+1):hover, .chip:nth-child(5n+1).on { background: #fde7f1; border-color: var(--pink); }
.chip:nth-child(5n+2):hover, .chip:nth-child(5n+2).on { background: #efe6ff; border-color: var(--violet); }
.chip:nth-child(5n+3):hover, .chip:nth-child(5n+3).on { background: #fff1d6; border-color: var(--gold); }
.chip:nth-child(5n+4):hover, .chip:nth-child(5n+4).on { background: #dff6f2; border-color: var(--teal); }
.chip:nth-child(5n+5):hover, .chip:nth-child(5n+5).on { background: #fde7f1; border-color: var(--pink); }

/* Carregando */
.spinner {
  width: 46px; height: 46px; margin: 8px auto 14px; border-radius: 50%;
  background: conic-gradient(from 0deg, rgba(224, 57, 122, 0), var(--pink), var(--violet), var(--gold));
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 6px), #000 calc(100% - 5px));
          mask: radial-gradient(farthest-side, transparent calc(100% - 6px), #000 calc(100% - 5px));
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

/* Resultado */
.result-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
#resultMeta { background: #efe6ff; color: #54207f; padding: 3px 10px; border-radius: 999px; font-weight: 600; }
.picker {
  background: linear-gradient(135deg, #fff7fb, #f6f0ff); border: 1.5px solid #e3d0f5;
  border-radius: 18px; padding: 16px; margin: 8px 0 18px;
}
.headline-list { display: grid; gap: 10px; margin-bottom: 14px; }
.hl {
  text-align: left; font: inherit; border: 1.5px solid var(--line); background: #fff; border-radius: 14px;
  padding: 12px 14px; cursor: pointer; display: flex; gap: 12px; align-items: flex-start;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.08s;
}
.hl:hover { transform: translateY(-1px); border-color: #cdb3f0; }
.hl .n {
  flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  background: var(--grad); color: #fff; font-weight: 700; font-size: 13px;
}
.hl.on { border-color: var(--violet); background: #f5eeff; box-shadow: 0 0 0 4px rgba(122, 60, 240, 0.12); }
.hl .best { margin-left: auto; font-size: 12px; font-weight: 700; background: var(--grad-gold); color: #4a2a00; border-radius: 999px; padding: 2px 10px; white-space: nowrap; }
.picker .btn { width: 100%; margin-top: 12px; }

.output h2, .output h3, .output h4 { margin: 22px 0 8px; line-height: 1.3; font-family: var(--serif); }
.output h2 {
  font-size: 19px; padding: 8px 12px; border-radius: 12px; color: #3a1f58;
  background: linear-gradient(90deg, #fde7f1, #efe6ff); border-left: 5px solid var(--pink);
}
.output h3 { font-size: 17px; color: #7a2aa8; }
.output p { margin: 6px 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.output ul { margin: 6px 0 6px 20px; padding: 0; }
.output li { margin: 4px 0; overflow-wrap: anywhere; }
.output li::marker { color: var(--pink); }
.output strong { color: #3a1f58; }
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.copy-mini {
  font: inherit; font-size: 13px; font-weight: 650; border: 1.5px solid #dcc3f3; background: #fff; color: #6a2fb8;
  border-radius: 10px; padding: 5px 12px; cursor: pointer; white-space: nowrap; transition: background 0.15s;
}
.copy-mini:hover { background: #f4eeff; }

.foot { text-align: center; margin-top: 30px; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff;
  padding: 11px 18px; border-radius: 999px; font-size: 14px; font-weight: 600; z-index: 10; max-width: 90vw;
  box-shadow: 0 10px 28px rgba(43, 23, 64, 0.35);
}
