:root {
  --bg: #0d0f14;
  --panel: #151922;
  --panel-2: #1b2030;
  --border: #262c3d;
  --text: #eef1f7;
  --muted: #8b93a7;
  --accent: #ff4f8b;
  --accent-2: #8a5cff;
  --ok: #3ddc97;
  --warn: #ffb547;
  --danger: #ff5d5d;
  --radius: 14px;
  --grad: linear-gradient(135deg, #ff4f8b 0%, #ff7a59 45%, #8a5cff 100%);
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: Inter, system-ui, 'Segoe UI', sans-serif; font-size: 15px; }
a { color: inherit; }
code { background: var(--panel-2); padding: 1px 6px; border-radius: 6px; font-size: 0.9em; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.spacer { flex: 1; }

/* ---------- Topbar */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 24px; padding: 14px 28px; background: rgba(13, 15, 20, 0.85); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; text-decoration: none; letter-spacing: -0.02em; }
.brand-mark { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--grad); font-size: 13px; }
.topbar nav { display: flex; gap: 6px; flex: 1; }
.topbar nav a { text-decoration: none; color: var(--muted); padding: 8px 14px; border-radius: 10px; font-weight: 500; }
.topbar nav a.active, .topbar nav a:hover { color: var(--text); background: var(--panel-2); }
.icon-btn { background: var(--panel-2); border: 1px solid var(--border); color: var(--text); width: 38px; height: 38px; border-radius: 10px; cursor: pointer; font-size: 17px; }
.banner { background: linear-gradient(90deg, rgba(255, 79, 139, 0.18), rgba(138, 92, 255, 0.18)); border-bottom: 1px solid var(--border); padding: 12px 28px; display: flex; gap: 14px; align-items: center; }

main { max-width: 1320px; margin: 0 auto; padding: 28px; }

/* ---------- Botões e campos */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--border); background: var(--panel-2); color: var(--text); border-radius: 11px; padding: 10px 16px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; transition: transform 0.08s, filter 0.15s, background 0.15s; white-space: nowrap; }
.btn:hover { filter: brightness(1.15); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; filter: none; }
.btn-primary { background: var(--grad); border: none; color: #fff; box-shadow: 0 6px 24px -8px rgba(255, 79, 139, 0.6); }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--danger); background: transparent; }
.btn-small { padding: 6px 11px; font-size: 13px; border-radius: 9px; }
.btn-big { padding: 15px 26px; font-size: 16px; border-radius: 13px; }

.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; }
.field > span, .label { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
input, select, textarea { width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; font: inherit; outline: none; transition: border-color 0.15s; }
input:focus, select:focus, textarea:focus { border-color: var(--accent-2); }
textarea { resize: vertical; line-height: 1.5; }
select { cursor: pointer; }
.check { display: flex; align-items: center; gap: 9px; cursor: pointer; margin-bottom: 14px; color: var(--text); }
.check input { width: auto; accent-color: var(--accent); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }

.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; }
.panel h3 { margin: 0 0 16px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.panel + .panel { margin-top: 18px; }

/* ---------- Tela "Novo vídeo" */
.hero { text-align: center; margin: 10px 0 30px; }
.hero h1 { font-size: 38px; letter-spacing: -0.03em; margin: 0 0 10px; }
.hero h1 em { font-style: normal; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { color: var(--muted); margin: 0; font-size: 16px; }

.create-layout { display: grid; grid-template-columns: 1.35fr 1fr; gap: 22px; align-items: start; }
.prompt-box textarea { min-height: 170px; font-size: 16px; }
.examples { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip { border: 1px solid var(--border); background: var(--panel-2); color: var(--muted); border-radius: 999px; padding: 7px 13px; font: inherit; font-size: 13px; cursor: pointer; }
.chip:hover { color: var(--text); }
.chip.active { color: #fff; border-color: transparent; background: var(--grad); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }

.formats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.format-card { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 14px 8px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg); cursor: pointer; color: var(--muted); font: inherit; font-size: 12px; text-align: center; }
.format-card .shape { border: 2px solid currentColor; border-radius: 5px; }
.format-card strong { color: var(--text); font-size: 13px; }
.format-card.active { border-color: var(--accent); color: var(--accent); background: rgba(255, 79, 139, 0.07); }

.voice-row { display: flex; gap: 8px; }
.voice-row select { flex: 1; }

.create-actions { display: flex; flex-direction: column; gap: 12px; margin-top: 18px; }

/* ---------- Editor de projeto */
.project-head { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.project-head input.title { flex: 1; min-width: 240px; font-size: 22px; font-weight: 700; background: transparent; border-color: transparent; padding: 6px 8px; }
.project-head input.title:hover, .project-head input.title:focus { border-color: var(--border); }
.save-state { font-size: 12px; color: var(--muted); min-width: 70px; }

.progress-card { margin-bottom: 20px; }
.progress-top { display: flex; justify-content: space-between; margin-bottom: 10px; font-weight: 600; }
.progress { height: 10px; border-radius: 99px; background: var(--bg); overflow: hidden; border: 1px solid var(--border); }
.progress > div { height: 100%; width: 0; background: var(--grad); transition: width 0.4s ease; }
.error-box.info { background: rgba(138, 92, 255, 0.1); border-color: rgba(138, 92, 255, 0.35); color: var(--text); }
.login-box { max-width: 440px; margin: 60px auto; display: flex; flex-direction: column; gap: 12px; }
.login-box h2 { margin: 0; }
.login-box ol { padding-left: 20px; line-height: 1.7; }
.login-error { color: var(--danger); min-height: 1em; margin: 0; font-size: 14px; }
.error-box {background: rgba(255, 93, 93, 0.1); border: 1px solid rgba(255, 93, 93, 0.35); color: #ffc2c2; border-radius: 12px; padding: 14px 16px; margin-bottom: 20px; white-space: pre-wrap; font-size: 14px; }

.editor-layout { display: grid; grid-template-columns: 1fr 380px; gap: 22px; align-items: start; }
.side { position: sticky; top: 86px; max-height: calc(100vh - 100px); overflow: auto; padding-right: 2px; }

.scene { display: grid; grid-template-columns: 170px 1fr; gap: 18px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.scene-media { display: flex; flex-direction: column; gap: 8px; }
.thumb { position: relative; width: 100%; border-radius: 10px; overflow: hidden; background: var(--bg); border: 1px dashed var(--border); display: grid; place-items: center; color: var(--muted); font-size: 12px; text-align: center; }
.thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; }
.thumb .badge { position: absolute; top: 6px; left: 6px; z-index: 2; }
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 99px; background: rgba(0, 0, 0, 0.6); }
.badge.warn { background: var(--warn); color: #231400; }
.scene-body { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.scene-top { display: flex; align-items: center; gap: 8px; }
.scene-num { font-weight: 800; font-size: 13px; background: var(--panel-2); border-radius: 8px; padding: 4px 10px; }
.scene-body textarea.narration { min-height: 78px; font-size: 15px; }
.scene-body textarea.prompt { min-height: 70px; font-size: 13px; color: #c9cfdd; }
details summary { cursor: pointer; color: var(--muted); font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.scene-audio { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.scene-audio audio { height: 34px; flex: 1; min-width: 180px; }
.meta { font-size: 12px; color: var(--muted); }
.spinner { width: 22px; height: 22px; border: 3px solid rgba(255, 255, 255, 0.15); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
.thumb .spinner { position: absolute; }
@keyframes spin { to { transform: rotate(360deg); } }

.video-preview { width: 100%; border-radius: 12px; background: #000; display: block; max-height: 560px; }
.caption-box textarea { min-height: 150px; font-size: 14px; }

/* ---------- Meus vídeos */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; text-decoration: none; display: flex; flex-direction: column; transition: transform 0.12s, border-color 0.12s; }
.card:hover { transform: translateY(-2px); border-color: #3a4260; }
.card .cover { aspect-ratio: 4 / 5; background: var(--panel-2) center / cover no-repeat; position: relative; }
.card .cover .badge { position: absolute; top: 10px; left: 10px; }
.card .info { padding: 12px 14px; }
.card .info strong { display: block; margin-bottom: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { text-align: center; padding: 70px 20px; color: var(--muted); }

/* ---------- Diálogos, toasts, lightbox */
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 18px; padding: 0; width: min(620px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0, 0, 0, 0.65); backdrop-filter: blur(3px); }
.dialog-body { padding: 26px; }
.dialog-body h2 { margin-top: 0; }
.dialog-actions { display: flex; gap: 10px; margin-top: 20px; align-items: center; }

#toasts { position: fixed; bottom: 22px; right: 22px; display: flex; flex-direction: column; gap: 10px; z-index: 100; }
.toast { background: var(--panel-2); border: 1px solid var(--border); border-left: 4px solid var(--ok); padding: 12px 16px; border-radius: 10px; max-width: 420px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4); animation: pop 0.2s ease; white-space: pre-wrap; }
.toast.error { border-left-color: var(--danger); }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } }

.lightbox { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.88); display: grid; place-items: center; z-index: 50; cursor: zoom-out; }
.lightbox img { max-width: 92vw; max-height: 92vh; border-radius: 12px; }

.loading-screen { display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 90px 20px; text-align: center; }
.loading-screen .spinner { width: 48px; height: 48px; border-width: 4px; }

@media (max-width: 1000px) {
  .create-layout, .editor-layout { grid-template-columns: 1fr; }
  .side { position: static; max-height: none; }
}
@media (max-width: 640px) {
  main { padding: 16px; }
  .topbar { padding: 12px 16px; gap: 12px; }
  .formats { grid-template-columns: repeat(2, 1fr); }
  .scene { grid-template-columns: 1fr; }
  .scene-media { max-width: 220px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .hero h1 { font-size: 28px; }
}
