/* Lunai — sistema de temas (decisão de Leonardo, 23/10/2026, sobre a fase 1
   em files/lunai-polish/): DUAS direções aprovadas com alternador, no mesmo
   padrão do Orai — os componentes são únicos e só as VARIÁVEIS mudam.

   Tema PADRÃO = Direção A "Noite Lunar" (dark premium): noite profunda,
   prata luar e o acento Violeta Aurora — ponto médio do degradê neon do
   brand kit dele (files/brand-kit-lunai: azul #38B6FF → rosa #FF4FD8).
   Tema ALTERNATIVO = Direção B "Estúdio Claro", via [data-theme="estudio"]
   no <html>: branco luar, prata escovado, tinta noite, o MESMO violeta
   (textos de acento no tom profundo, por contraste).

   O dourado do kit saiu de primária (colidia com o Orai, da mesma conta) e
   fica como legado da marca em capas/animações. O wordmark do cabeçalho é a
   ARTE REAL do brand kit recolorida por tema (logo-lunai-noite.png /
   logo-lunai-estudio.png) + a lua crescente violeta — o gancho do nome. */
:root {
  --bg: #060714;
  --panel: #0d0e1f;
  --panel-2: #141631;
  --line: #272b4d;
  --text: #f2f3fa;
  --muted: #9ba1be;
  --silver: #c9cee6;
  --silver-hi: #f4f5ff;
  --silver-lo: #7c83a8;
  --accent: #8e7cff;
  --accent-core: #c4b5fd;
  --accent-deep: #5a3ee0;
  --accent-text: #c4b5fd;
  --accent-grad: linear-gradient(180deg, #8e7cff, #5a3ee0);
  --on-accent: #ffffff;
  --field: #0a0b1e;
  --card-shadow: 0 18px 50px rgba(3, 2, 16, .55);
  --focus-ring: rgba(142, 124, 255, .30);
  --glow-a: rgba(142, 124, 255, .15);
  --glow-b: rgba(196, 181, 253, .10);
  --btn-glow: rgba(142, 124, 255, .45);
  --neon-shadow: 0 0 12px rgba(142, 124, 255, .65), 0 0 30px rgba(90, 62, 224, .50);
  --logo-filter: drop-shadow(0 0 16px rgba(142, 124, 255, .30));
  --moon-filter: drop-shadow(0 0 10px rgba(142, 124, 255, .45));
  --media-bg: #000000;
  --danger: #ff6b81;
  --ok: #3ddc97;
  --chevron: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8'><path d='M1 1l5 5 5-5' fill='none' stroke='%239ba1be' stroke-width='2' stroke-linecap='round'/></svg>");
}

[data-theme="estudio"] {
  --bg: #f4f5f9;
  --panel: #ffffff;
  --panel-2: #ffffff;
  --line: #d9dbe8;
  --text: #17182b;
  --muted: #5e627a;
  --silver: #5d6178;
  --silver-hi: #eceef6;
  --silver-lo: #b7bbd0;
  --accent-text: #5a3ee0;
  --field: #eceef6;
  --card-shadow: 0 18px 44px rgba(93, 97, 120, .16);
  --focus-ring: rgba(90, 62, 224, .22);
  --glow-a: rgba(142, 124, 255, .10);
  --glow-b: rgba(183, 187, 208, .18);
  --btn-glow: rgba(90, 62, 224, .28);
  --neon-shadow: none;
  --logo-filter: drop-shadow(0 2px 10px rgba(93, 97, 120, .20));
  --moon-filter: drop-shadow(0 1px 4px rgba(93, 97, 120, .30));
  --media-bg: #060714;
  --danger: #d92d20;
  --ok: #0e9f6e;
  --chevron: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8'><path d='M1 1l5 5 5-5' fill='none' stroke='%235e627a' stroke-width='2' stroke-linecap='round'/></svg>");
}

* { box-sizing: border-box; }

::selection { background: var(--accent); color: var(--on-accent); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Poppins", system-ui, -apple-system, "Segoe UI", sans-serif;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

/* halos de fundo no violeta aurora (a assinatura neon do kit, sem ruído) */
.glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  pointer-events: none;
  z-index: 0;
}
.glow-a { width: 560px; height: 560px; background: var(--glow-a); top: -180px; left: -120px; }
.glow-b { width: 480px; height: 480px; background: var(--glow-b); bottom: -200px; right: -100px; }

.topbar, main, footer { position: relative; z-index: 1; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 28px;
  max-width: 980px;
  margin: 0 auto;
}

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

/* lua crescente violeta — o gancho do nome, ao lado do wordmark real */
.brand-moon { width: 34px; height: 34px; flex: none; filter: var(--moon-filter); }

/* wordmark REAL do brand kit (arte recolorida por tema); uma imagem por tema */
.brand-logo { height: 52px; width: auto; display: block; filter: var(--logo-filter); }
.brand-logo-sm { height: 27px; width: auto; display: block; filter: var(--logo-filter); }
.logo-estudio { display: none; }
[data-theme="estudio"] .logo-noite { display: none; }
[data-theme="estudio"] .logo-estudio { display: block; }

/* alternador de temas (padrão do Orai: ícone do tema ATIVO + aria) */
.theme-btn {
  margin-left: auto;
  flex: none;
  width: 42px; height: 42px;
  display: flex; align-items: center; justify-content: center;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--silver);
  cursor: pointer;
  padding: 0;
}
.theme-btn:hover { border-color: var(--accent); color: var(--accent-text); }
.theme-btn svg { width: 20px; height: 20px; display: block; }
.theme-btn .icon-sun { display: none; }
[data-theme="estudio"] .theme-btn .icon-sun { display: block; }
[data-theme="estudio"] .theme-btn .icon-moon { display: none; }

.session { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.balance {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 14px;
}
.balance b { color: var(--accent-text); }
.user-email { color: var(--muted); font-size: 14px; }

main { max-width: 980px; margin: 0 auto; padding: 8px 20px 40px; }

.card {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 26px;
  margin-bottom: 22px;
  box-shadow: var(--card-shadow);
}
.auth-card { max-width: 520px; margin: 5vh auto 22px; }
.auth-card h1 { font-size: 30px; line-height: 1.2; margin: 0 0 8px; }
.card h2 { margin: 0 0 16px; font-size: 21px; }
.neon { color: var(--accent-text); text-shadow: var(--neon-shadow); }
.muted { color: var(--muted); }
.fineprint { color: var(--muted); font-size: 12.5px; line-height: 1.5; margin-top: 16px; }
.hint { color: var(--muted); font-size: 12px; font-weight: 400; }

.tabs { display: flex; gap: 8px; margin: 18px 0; }
.tab {
  flex: 1;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.tab.active { color: var(--text); border-color: var(--accent); box-shadow: 0 0 14px var(--focus-ring) inset; }

label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 14px; }
input, textarea, select {
  width: 100%;
  margin-top: 6px;
  background-color: var(--field);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  font: inherit;
  font-weight: 400;
  padding: 11px 12px;
}
select {
  appearance: none;
  -webkit-appearance: none;
  background-image: var(--chevron);
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}
textarea { resize: vertical; }

.row { display: flex; gap: 16px; }
.row > label { flex: 1; }
.row-end { align-items: flex-end; }
.switch-line { display: flex; align-items: center; gap: 10px; font-weight: 600; padding-bottom: 10px; }
.switch-line input { width: auto; margin: 0; accent-color: var(--accent); transform: scale(1.25); }

.segmented { display: inline-flex; background: var(--field); border: 1px solid var(--line); border-radius: 999px; padding: 4px; margin-bottom: 18px; flex-wrap: wrap; }
.seg {
  border: 0; background: transparent; color: var(--muted);
  font: inherit; font-weight: 600; font-size: 14px;
  padding: 8px 20px; border-radius: 999px; cursor: pointer;
}
.seg.active { background: var(--accent-grad); color: var(--on-accent); box-shadow: 0 0 16px var(--btn-glow); }
.seg.active::before {
  content: "";
  display: inline-block;
  width: 10px; height: 10px;
  margin-right: 7px;
  vertical-align: -1px;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z' fill='%23ffffff'/></svg>") center / contain no-repeat;
}

.btn {
  font: inherit; font-weight: 700; cursor: pointer;
  border-radius: 10px; padding: 11px 20px; border: 1px solid transparent;
}
.btn-primary {
  background: var(--accent-grad);
  color: var(--on-accent);
  box-shadow: 0 0 18px var(--btn-glow);
}
.btn-primary:hover { filter: brightness(1.12); }
.btn-primary:disabled { opacity: .55; cursor: wait; }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--line); padding: 8px 14px; }
.btn-ghost:hover { color: var(--text); border-color: var(--accent); }
.btn-block { width: 100%; }

.form-msg { min-height: 20px; font-size: 14px; margin: 10px 0 0; }
.form-msg.error { color: var(--danger); }
.form-msg.ok { color: var(--ok); }

/* referências (v2; estados por arquivo na v2.1): campo de anexos +
   thumbnails com estado (enviando / anexada ✓ / erro) + remover/retry */
.refs-block { margin-bottom: 14px; }
.refs-label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
input[type="file"] { padding: 9px 12px; border-style: dashed; }
.refs-thumbs { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 10px; align-items: flex-start; }
.refs-thumbs:empty { margin-top: 0; }
.ref-thumb { width: 72px; display: flex; flex-direction: column; gap: 4px; }
.ref-media { position: relative; width: 72px; height: 72px; }
.ref-media img {
  width: 72px; height: 72px; object-fit: cover; display: block;
  border-radius: 10px; border: 1px solid var(--line);
}
.ref-thumb.is-uploading .ref-media img { opacity: .55; }
.ref-thumb.is-error .ref-media img { opacity: .75; border-color: var(--danger); }
.ref-badge {
  position: absolute; left: -6px; bottom: -6px;
  min-width: 20px; height: 20px; border-radius: 999px; padding: 0 5px;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
}
.ref-thumb.is-ok .ref-badge { color: var(--ok); border-color: var(--ok); }
.ref-thumb.is-uploading .ref-badge { color: var(--accent-text); border-color: var(--accent); }
.ref-thumb.is-error .ref-badge { color: #fff; background: var(--danger); border-color: var(--danger); }
.ref-remove {
  position: absolute; top: -8px; right: -8px;
  width: 22px; height: 22px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--panel-2);
  color: var(--text); font-size: 14px; line-height: 1; padding: 0; cursor: pointer;
}
.ref-remove:hover { border-color: var(--danger); color: var(--danger); }
.ref-cap { font-size: 10.5px; line-height: 1.3; color: var(--muted); word-break: break-word; }
.ref-cap.error { color: var(--danger); }
.ref-retry {
  background: none; border: 0; padding: 0; cursor: pointer;
  color: var(--accent-text); font: inherit; font-size: 11px;
  text-align: left; text-decoration: underline;
}
.refs-status { font-size: 13.5px; color: var(--muted); margin: 10px 0 0; }
.refs-warning { font-size: 13.5px; font-weight: 600; color: var(--danger); margin: 6px 0 0; }

.create-footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-top: 4px; }
.cost { color: var(--muted); font-size: 14px; }
.cost b { color: var(--accent-text); }

.lib-head { display: flex; align-items: center; justify-content: space-between; }
.lib-head h2 { margin: 0; }
.library { margin-top: 16px; display: flex; flex-direction: column; gap: 14px; }

.track-item {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  background: var(--field);
}
.track-item h3 { margin: 0 0 4px; font-size: 16px; }
.track-meta { color: var(--muted); font-size: 12.5px; display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.badge {
  border: 1px solid var(--line); border-radius: 999px; padding: 1px 9px; font-size: 11.5px;
}
.badge.status-success { color: var(--ok); border-color: var(--ok); }
.badge.status-fail { color: var(--danger); border-color: var(--danger); }
.badge.status-generating, .badge.status-waiting, .badge.status-queuing, .badge.status-queued { color: var(--accent-text); border-color: var(--accent); }
.version { border-top: 1px dashed var(--line); padding-top: 12px; margin-top: 12px; }
.version:first-of-type { border-top: 0; padding-top: 2px; margin-top: 4px; }
.version-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 13.5px; }
audio { width: 100%; height: 40px; }
video { width: 100%; max-height: 480px; border-radius: 10px; background: var(--media-bg); }
.version img { width: 100%; border-radius: 10px; display: block; }
.spin { display: inline-block; animation: spin 1.1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

footer {
  max-width: 980px; margin: 0 auto; padding: 10px 28px 34px;
  display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px;
}

@media (max-width: 640px) {
  .brand-logo { height: 40px; }
  .brand-moon { width: 27px; height: 27px; }
  .brand-logo-sm { height: 22px; }
  .row { flex-direction: column; gap: 0; }
  .topbar { padding: 16px; flex-wrap: wrap; }
  .card { padding: 20px; }
}

/* Paywall — grade de pacotes de créditos (fundo amarrado aos tokens do tema;
   o #05090F herdado do Sonai saiu — auditoria 23/10/2026) */
.packs { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 14px 0; }
.pack { position: relative; border: 1px solid var(--line); border-radius: 14px; padding: 14px; background: var(--field); }
.pack h3 { margin: 0 0 4px; font-size: 15px; }
.pack-credits { margin: 0 0 4px; font-weight: 700; font-size: 17px; color: var(--accent-text); }
.pack .muted { margin: 0 0 10px; font-size: 12.5px; }
.pack-popular { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), 0 10px 30px var(--btn-glow); }
.pack-badge {
  position: absolute; top: -10px; right: 12px;
  background: var(--accent-grad); color: var(--on-accent);
  font-size: 10.5px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase;
  border-radius: 999px; padding: 2px 9px;
}
.pack-sub { grid-column: 1 / -1; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.pack-sub h3, .pack-sub .pack-credits { margin: 0; }
.pack-sub .muted { margin: 0; flex: 1; }
.pack-sub .btn-block { width: auto; }
