/* h3-studio — tema custom.
   Inspirado no visual do Linear (linear.app): fundo quase preto levemente
   azulado, bordas de baixíssimo contraste, um único acento frio, tipografia
   Inter com tracking negativo nos títulos, e cantos generosos.
   Sem framework: o site tem três páginas e roda numa e2-micro de 0,25 vCPU —
   um CSS de 6 KB entrega o mesmo e não custa um build. */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  color-scheme: dark;
  --bg: #08090c;
  --bg-elev: #0e1015;
  --card: #131620;
  --card-hover: #171b27;
  --linha: #21252f;
  --linha-forte: #2c313d;
  --texto: #eef0f5;
  --texto-2: #a7adbd;
  --texto-3: #6e7583;
  --acento: #7c86ff;
  --acento-forte: #9aa2ff;
  --acento-fraco: rgba(124, 134, 255, .14);
  --ok: #40cf9a;
  --alerta: #f0b866;
  --alerta-bg: rgba(240, 184, 102, .09);
  --erro: #ff7a7a;
  --sombra: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.28);
  --r: 12px;
  --r-sm: 8px;
}

:root[data-tema="light"] {
  color-scheme: light;
  --bg: #fbfbfd;
  --bg-elev: #ffffff;
  --card: #ffffff;
  --card-hover: #f6f7fb;
  --linha: #e6e8ef;
  --linha-forte: #d5d9e4;
  --texto: #12141a;
  --texto-2: #545b6b;
  --texto-3: #858c9c;
  --acento: #5b63e8;
  --acento-forte: #4a52d8;
  --acento-fraco: rgba(91, 99, 232, .10);
  --ok: #12915f;
  --alerta: #8a5d13;
  --alerta-bg: rgba(240, 184, 102, .16);
  --erro: #c93b3b;
  --sombra: 0 1px 2px rgba(16,20,40,.05), 0 8px 24px rgba(16,20,40,.06);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--texto);
  font: 15px/1.6 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.005em;
}

/* fundo com um brilho sutil no topo, como o Linear faz */
body::before {
  content: "";
  position: fixed; inset: 0 0 auto 0; height: 420px; pointer-events: none;
  background: radial-gradient(70% 100% at 50% 0%, var(--acento-fraco), transparent 70%);
  z-index: 0;
}
main, header { position: relative; z-index: 1; }

header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 24px; border-bottom: 1px solid var(--linha);
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: blur(12px);
  position: sticky; top: 0; z-index: 20;
}
h1 { font-size: 15px; margin: 0; font-weight: 600; letter-spacing: -0.02em; }
h2 { font-size: 15px; font-weight: 600; letter-spacing: -0.02em; margin: 0 0 10px; }
main { max-width: 880px; margin: 0 auto; padding: 28px 20px 96px; }
section { margin-bottom: 26px; }

label { display: block; font-size: 12px; font-weight: 500; color: var(--texto-2);
  margin-bottom: 7px; letter-spacing: 0; }

textarea, select, input[type=file], input[type=number] {
  width: 100%; background: var(--card); color: var(--texto);
  border: 1px solid var(--linha); border-radius: var(--r-sm);
  padding: 11px 13px; font: inherit; transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; font: 13px/1.65 ui-monospace, SFMono-Regular, Menlo, monospace; }
textarea:focus, select:focus, input:focus {
  outline: none; border-color: var(--acento);
  box-shadow: 0 0 0 3px var(--acento-fraco);
}

.linha-contador { display: flex; justify-content: space-between; font-size: 12px;
  color: var(--texto-3); margin: 7px 0 16px; }
.linha-controles { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.linha-controles select { width: auto; min-width: 190px; }
.linha-controles label { display: flex; align-items: center; gap: 8px; margin: 0; }
.checkbox { font-size: 13px; color: var(--texto-2); }
.checkbox input { width: auto; }

fieldset { border: 1px solid var(--linha); border-radius: var(--r); padding: 15px; margin: 0 0 18px;
  background: var(--bg-elev); }
legend { font-size: 12px; font-weight: 500; color: var(--texto-2); padding: 0 7px; }

button, .primario {
  font: inherit; font-weight: 500; border-radius: var(--r-sm);
  padding: 10px 17px; cursor: pointer; border: 0; transition: all .15s;
}
.primario { background: var(--acento); color: #fff; font-weight: 600;
  display: inline-block; text-decoration: none; text-align: center; box-shadow: var(--sombra); }
.primario:hover:not(:disabled) { background: var(--acento-forte); transform: translateY(-1px); }
.primario:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.secundario { background: var(--card); color: var(--texto); border: 1px solid var(--linha); }
.secundario:hover:not(:disabled) { background: var(--card-hover); border-color: var(--linha-forte); }
.secundario:disabled { opacity: .4; cursor: not-allowed; }
.secundario.ativo { border-color: var(--acento); color: var(--acento-forte); background: var(--acento-fraco); }

.erro { color: var(--erro); font-size: 13px; }
.nota { color: var(--texto-3); font-size: 12px; margin: 8px 0 0; line-height: 1.55; }
.fraco { color: var(--texto-3); font-weight: 400; }

.barra { height: 6px; background: var(--card); border: 1px solid var(--linha);
  border-radius: 99px; overflow: hidden; }
#barra-preenchida { height: 100%; width: 0; border-radius: 99px;
  background: linear-gradient(90deg, var(--acento), var(--acento-forte));
  transition: width .35s ease; }
#texto-progresso { font-size: 13px; color: var(--texto-2); margin-top: 10px; }

video { width: 100%; border-radius: var(--r); background: #000; display: block; }
#conta { font-size: 13px; color: var(--texto-2); display: flex; gap: 10px; align-items: center; }
#conta a { color: var(--texto-2); text-decoration: none; padding: 6px 10px;
  border-radius: var(--r-sm); border: 1px solid var(--linha); }
#conta a:hover { background: var(--card-hover); }

#banner-offline { background: var(--alerta-bg); border-bottom: 1px solid var(--linha);
  color: var(--alerta); padding: 11px 24px; font-size: 13px;
  display: flex; gap: 8px; flex-wrap: wrap; position: relative; z-index: 10; }

/* ---------------------------------------------------------------- sessão -- */
#sessao { display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
  font-size: 12px; color: var(--texto-2); margin-bottom: 18px; }
#sessao .chip { background: var(--card); border: 1px solid var(--linha);
  border-radius: 99px; padding: 5px 12px; display: inline-flex; gap: 6px; align-items: center; }
#sessao .chip b { color: var(--texto); font-weight: 600; font-variant-numeric: tabular-nums; }
#btn-janela { padding: 5px 12px; font-size: 12px; border-radius: 99px; }

/* -------------------------------------------------------------- galeria --- */
#galeria ul { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 8px; }
#galeria li { background: var(--card); border: 1px solid var(--linha); border-radius: var(--r-sm);
  padding: 11px 13px; cursor: pointer; display: flex; gap: 11px; align-items: flex-start;
  transition: all .15s; }
#galeria li:hover { border-color: var(--acento); background: var(--card-hover); }
#galeria .texto { flex: 1; font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--texto-2); max-height: 3.1em; overflow: hidden; }
#galeria .meta { font-size: 11px; color: var(--texto-3); white-space: nowrap; }
.lupa { opacity: .8; }

/* -------------------------------------------------------------- exemplos -- */
#exemplos { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 11px; }
.cartao-ex { border: 1px solid var(--linha); border-radius: var(--r); overflow: hidden;
  cursor: pointer; background: var(--card); transition: all .18s; text-align: left; padding: 0; }
.cartao-ex:hover { border-color: var(--acento); transform: translateY(-2px); box-shadow: var(--sombra); }
.cartao-ex .capa { height: 84px; position: relative; }
.cartao-ex .capa::after { content: ""; position: absolute; inset: 0;
  background: radial-gradient(120% 90% at 20% 10%, rgba(255,255,255,.22), transparent 60%); }
.cartao-ex .corpo { padding: 10px 12px 12px; }
.cartao-ex .titulo { font-size: 13px; font-weight: 600; letter-spacing: -0.01em; }
.cartao-ex .legenda { font-size: 11px; color: var(--texto-3); margin-top: 2px; }

/* --------------------------------------------------------------- gaveta --- */
.gaveta { border: 1px solid var(--linha); border-radius: var(--r); background: var(--bg-elev);
  overflow: hidden; margin-bottom: 14px; }
.gaveta > summary { cursor: pointer; padding: 12px 15px; font-size: 13px; font-weight: 500;
  list-style: none; display: flex; justify-content: space-between; align-items: center; }
.gaveta > summary::-webkit-details-marker { display: none; }
.gaveta > summary::after { content: "▾"; color: var(--texto-3); transition: transform .2s; }
.gaveta[open] > summary::after { transform: rotate(180deg); }
.gaveta > summary:hover { background: var(--card-hover); }
.gaveta-corpo { border-top: 1px solid var(--linha); max-height: 340px; overflow-y: auto; padding: 6px; }
.gaveta-corpo::-webkit-scrollbar { width: 10px; }
.gaveta-corpo::-webkit-scrollbar-thumb { background: var(--linha-forte); border-radius: 99px;
  border: 3px solid var(--bg-elev); }
.cat-titulo { font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--texto-3); padding: 12px 10px 6px; font-weight: 600; }
.item-tpl { display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--r-sm); cursor: pointer; transition: background .12s; }
.item-tpl:hover { background: var(--card-hover); }
.item-tpl .n { font-size: 13px; font-weight: 500; }
.item-tpl .r { font-size: 11px; color: var(--texto-3); text-align: right; }

/* --------------------------------------------------------------- vídeos --- */
.card-video { background: var(--card); border: 1px solid var(--linha); border-radius: var(--r);
  padding: 11px; margin-bottom: 12px; }
.card-video video { margin-bottom: 10px; }
.linha-video { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.linha-video .meta { flex: 1; font-size: 12px; color: var(--texto-3); }
.linha-video .primario, .linha-video button { padding: 7px 14px; font-size: 13px; }

/* ---------------------------------------------------------------- admin --- */
table { width: 100%; border-collapse: collapse; margin: 10px 0 26px; font-size: 13px; }
th, td { text-align: left; padding: 9px 11px; border-bottom: 1px solid var(--linha); vertical-align: middle; }
th { color: var(--texto-3); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
td .acoes { display: flex; gap: 6px; flex-wrap: wrap; }
td button { padding: 5px 11px; font-size: 12px; }
input[type=number] { width: 110px; }
.pill { font-size: 11px; padding: 3px 9px; border-radius: 99px; border: 1px solid var(--linha); font-weight: 500; }
.pill.aprovado { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.pill.pendente { color: var(--alerta); border-color: color-mix(in srgb, var(--alerta) 40%, transparent); }
.pill.bloqueado { color: var(--erro); border-color: color-mix(in srgb, var(--erro) 40%, transparent); }

#pendente-aviso, #aviso-email { background: var(--alerta-bg);
  border: 1px solid color-mix(in srgb, var(--alerta) 30%, transparent);
  color: var(--alerta); border-radius: var(--r); padding: 15px 17px; margin-bottom: 20px;
  font-size: 13px; line-height: 1.6; }
#pendente-aviso h2 { margin: 0 0 6px; font-size: 14px; color: inherit; }
#aviso-email code { background: rgba(0,0,0,.25); padding: 1px 6px; border-radius: 4px;
  font: 12px ui-monospace, Menlo, monospace; }

@media (max-width: 560px) {
  main { padding: 20px 14px 80px; }
  .linha-controles select { min-width: 0; flex: 1; }
}

/* --------------------------------------------------------------- slots ---- */
.slot { display: grid; grid-template-columns: 96px 1fr auto; gap: 10px; align-items: center;
  padding: 8px 0; border-bottom: 1px dashed var(--linha); }
.slot:last-child { border-bottom: 0; }
.slot-rotulo { font: 12px ui-monospace, Menlo, monospace; color: var(--acento-forte); }
.slot input[type=file] { padding: 7px 10px; font-size: 12px; }
.slot-papel { width: auto; padding: 7px 10px; font-size: 12px; }
.slot-status { grid-column: 1 / -1; margin: 0; }
.cartao-ex video.capa { width: 100%; height: 84px; object-fit: cover; display: block;
  border-radius: 0; background: #000; }
.capa-imgs { display: grid; grid-auto-flow: column; gap: 2px; background: var(--linha); }
.capa-imgs img { width: 100%; height: 84px; object-fit: cover; display: block; }

.cartao-ex .credito { font-size: 10px; color: var(--texto-3); margin-top: 6px; line-height: 1.4;
  opacity: .8; }

/* =================================================================== v3 ==== */
/* compositor: campo compacto com Gerar ao lado (item 7) */
.compositor { margin-bottom: 20px; }
.prompt-linha { display: grid; grid-template-columns: 1fr 150px; gap: 12px; align-items: stretch; }
.prompt-caixa { display: flex; flex-direction: column; }
.prompt-caixa textarea { flex: 1; min-height: 150px; border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.prompt-rodape { display: flex; align-items: center; gap: 12px; font-size: 12px; color: var(--texto-3);
  background: var(--card); border: 1px solid var(--linha); border-top: 0;
  border-radius: 0 0 var(--r-sm) var(--r-sm); padding: 7px 12px; }
.prompt-rodape .erro { flex: 1; }
.gerar-coluna { display: flex; flex-direction: column; gap: 8px; }
.primario.grande { flex: 1; font-size: 16px; line-height: 1.2; padding: 14px 10px; }
.primario.grande small { display: block; font-size: 11px; opacity: .7; font-weight: 500; margin-top: 4px; }
.gerar-coluna .nota { margin: 0; font-size: 11px; line-height: 1.4; }
.link { background: none; border: 0; color: var(--acento-forte); padding: 0; font-size: 12px; cursor: pointer; }
.link:hover { text-decoration: underline; }
.link:disabled { opacity: .5; cursor: wait; }
.linha-controles.compacta { margin: 12px 0 10px; }
.linha-controles.compacta select { min-width: 0; }
.mini { padding: 5px 10px; font-size: 12px; }
.icone { padding: 8px 11px; }

/* tags (item 6) */
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; align-items: center; }
.tags .grupo { font-size: 11px; color: var(--texto-3); margin-right: 2px; text-transform: uppercase;
  letter-spacing: .06em; font-weight: 600; }
.tags .grupo:not(:first-child) { margin-left: 8px; }
.tag { border: 1px solid var(--linha); background: var(--card); color: var(--texto-2); border-radius: 99px;
  padding: 4px 11px; font-size: 12px; cursor: pointer; transition: all .12s; }
.tag:hover { border-color: var(--acento); color: var(--acento-forte); background: var(--acento-fraco); }
.tag.usada { border-color: var(--ok); color: var(--ok); }

/* modelos como formulário (item 5) */
.gaveta > summary { gap: 10px; }
.gaveta > summary > span:first-child { font-weight: 600; }
#resumo-gaveta { flex: 1; font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.form-template { border: 1px solid var(--acento); background: var(--bg-elev); border-radius: var(--r);
  padding: 16px; margin-bottom: 14px; box-shadow: var(--sombra); }
.form-template h3 { margin: 0 0 4px; font-size: 14px; }
.form-template .desc { font-size: 12px; color: var(--texto-3); margin: 0 0 12px; }
.form-template .campos { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.form-template .campo label { margin-bottom: 4px; }
.form-template .campo input, .form-template .campo textarea { width: 100%; padding: 8px 10px; font-size: 13px; }
.form-template .acoes { display: flex; gap: 8px; margin-top: 12px; align-items: center; }
.form-template .preview { font: 11px/1.5 ui-monospace, Menlo, monospace; color: var(--texto-3);
  max-height: 96px; overflow: auto; margin-top: 10px; white-space: pre-wrap; border-top: 1px dashed var(--linha); padding-top: 8px; }
#sugestoes-llm { padding: 6px; border-bottom: 1px solid var(--linha); }
#sugestoes-llm .cat-titulo { color: var(--acento-forte); }

/* progresso com etapa nomeada */
.progresso-topo { display: flex; justify-content: space-between; font-size: 12px; color: var(--texto-2); margin-bottom: 6px; }
#pct { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--texto); }
#painel-progresso { margin-top: 14px; }

/* toasts no lugar de alert() */
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast { background: var(--card); color: var(--texto); border: 1px solid var(--linha); border-radius: var(--r-sm);
  padding: 10px 14px; font-size: 13px; box-shadow: var(--sombra); max-width: 360px; animation: sobe .18s ease; }
.toast.erro { border-color: color-mix(in srgb, var(--erro) 50%, transparent); }
.toast.ok { border-color: color-mix(in srgb, var(--ok) 50%, transparent); }
@keyframes sobe { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* modal no lugar de confirm() */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center;
  justify-content: center; z-index: 60; padding: 20px; }
.modal-caixa { background: var(--bg-elev); border: 1px solid var(--linha-forte); border-radius: var(--r);
  padding: 20px; max-width: 460px; width: 100%; box-shadow: var(--sombra); }
.modal-caixa h3 { margin: 0 0 8px; font-size: 15px; }
#modal-corpo { font-size: 13px; color: var(--texto-2); line-height: 1.6; }
.modal-acoes { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* login */
.hero { max-width: 460px; margin: 60px auto; text-align: center; }
.hero h2 { font-size: 24px; letter-spacing: -0.03em; margin-bottom: 8px; }
.hero p { color: var(--texto-2); margin: 0 0 20px; }
#botao-google { display: flex; justify-content: center; }

/* vídeos guardados */
.card-video .meta small { display: block; color: var(--texto-3); margin-top: 2px; }
.aviso-fila { font-size: 12px; color: var(--alerta); }

@media (max-width: 640px) {
  .prompt-linha { grid-template-columns: 1fr; }
  .primario.grande { padding: 12px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* avançado / loras */
#avancado { margin: 10px 0 14px; }
.avancado-corpo { max-height: none; padding: 12px 14px; }
#avancado select { max-width: 360px; }
#avancado input[type=range] { width: 140px; accent-color: var(--acento); }
#lora-info .gatilho { display: inline-block; font: 12px ui-monospace, Menlo, monospace; background: var(--acento-fraco);
  color: var(--acento-forte); border-radius: 6px; padding: 1px 7px; margin: 2px 4px 2px 0; cursor: pointer; }
#lora-info .gatilho:hover { outline: 1px solid var(--acento); }
