/* Identidade Rainmaker. Tema escuro = variante GRAFITE da marca; tema claro = AREIA.
   Paleta: Laranja #F97316 (primaria), Brasa #C2410C (hover), Pessego #FFEDD5,
   Grafite #1C1917, Pedra #57534E, Areia #F5F3F0, Bordas #E7E5E4. */
:root, :root[data-theme="dark"] {
  --bg: #1C1917;         /* grafite */
  --bg-2: #16120F;       /* sidebar: um degrau mais escuro */
  --panel: #23201D;
  --panel-2: #2A2623;
  --border: #37322D;
  --border-2: #46403A;   /* bordas de elementos interativos, steppers, chips */
  --text: #F5F3F0;       /* areia (quase branco) sobre grafite */
  --muted: #A8A29E;
  --dim: #78716C;        /* pedra: micro-labels e texto terciario */
  --accent: #F97316;
  --accent-2: #FB923C;   /* hover no escuro: laranja mais claro pra manter visivel */
  --accent-dim: rgba(249,115,22,.16);
  --peach: #FFEDD5;
  --danger: #ff5468;
  --ok: #34d399;
  --warn: #f5b04a;
  --shadow: rgba(0,0,0,.45);
  --radius: 16px;        /* cards */
  --radius-lg: 24px;     /* paineis grandes */
  --radius-btn: 10px;    /* campos (botoes usam pilula) */
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}

/* Tema claro = AREIA (a face principal da marca). */
:root[data-theme="light"] {
  --bg: #F5F3F0;         /* areia */
  --bg-2: #FFFFFF;       /* sidebar branca */
  --panel: #FFFFFF;
  --panel-2: #F5F3F0;
  --border: #E7E5E4;
  --border-2: #DAD5CF;
  --text: #1C1917;       /* grafite */
  --muted: #57534E;      /* pedra */
  --dim: #8A857E;
  --accent: #F97316;
  --accent-2: #C2410C;   /* brasa: hover/pressed no claro */
  --accent-dim: rgba(249,115,22,.12);
  --peach: #FFEDD5;
  --danger: #e0384b;
  --ok: #12a56f;
  --warn: #c77c14;
  --shadow: rgba(28,25,23,.10);
  color-scheme: light;
}

/* Archivo (SIL OFL) — fonte da identidade Rainmaker. Pesos 400/500/600/800/900. */
@font-face { font-family: 'Archivo'; font-weight: 400; font-style: normal; font-display: swap; src: url('/fonts/Archivo-400.woff2') format('woff2'); }
@font-face { font-family: 'Archivo'; font-weight: 500; font-style: normal; font-display: swap; src: url('/fonts/Archivo-500.woff2') format('woff2'); }
@font-face { font-family: 'Archivo'; font-weight: 600; font-style: normal; font-display: swap; src: url('/fonts/Archivo-600.woff2') format('woff2'); }
@font-face { font-family: 'Archivo'; font-weight: 800; font-style: normal; font-display: swap; src: url('/fonts/Archivo-800.woff2') format('woff2'); }
@font-face { font-family: 'Archivo'; font-weight: 900; font-style: normal; font-display: swap; src: url('/fonts/Archivo-900.woff2') format('woff2'); }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Archivo', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  font-size: 15px;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.err { color: var(--danger); font-size: 13px; min-height: 18px; }

/* --- Escala tipografica: micro-labels, titulos de tela, secoes numeradas ----- */
/* .lbl e o rotulo pequeno em monospace (campos e cabecalhos de bloco).
   .eyebrow e a mesma ideia, mais espacada, usada acima do titulo da tela. */
.lbl { font: 600 10px/1 var(--mono); letter-spacing: .18em; text-transform: uppercase; color: var(--dim); }
.eyebrow { font: 600 10.5px/1 var(--mono); letter-spacing: .22em; text-transform: uppercase; color: var(--dim); margin-bottom: 14px; }
.page-head { min-width: 0; }
/* O tamanho vem daqui; ".row h2" (o titulo pequeno de bloco) se exclui via :not(). */
.page-title { margin: 0 0 12px; font-size: 47px; line-height: 1.03; letter-spacing: -.035em; font-weight: 800; }
.page-title em { font-style: normal; color: var(--accent); }
.page-lede { color: var(--muted); font-size: 15.5px; max-width: 640px; margin: 0 0 34px; }

.secnum { display: flex; align-items: baseline; gap: 13px; margin: 44px 0 18px; }
.secnum span { font: 700 11px/1 var(--mono); color: var(--accent); letter-spacing: .1em; }
.secnum h2 { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: -.015em; }

/* --- Chips de status --------------------------------------------------------- */
.chip { display: inline-block; font: 700 9px/1 var(--mono); letter-spacing: .13em; padding: 5px 8px; border-radius: 5px; text-transform: uppercase; vertical-align: middle; }
.chip-pub { background: rgba(52,211,153,.14); color: var(--ok); }
.chip-draft { background: rgba(245,176,74,.14); color: var(--warn); }
.chip-fail { background: rgba(255,84,104,.14); color: var(--danger); }
.chip-sched { background: var(--accent-dim); color: var(--accent-2); }
/* Estados sem cor propria (publicando, na fila, linha pausada): cinza neutro. */
.chip-neutral { background: rgba(140,140,163,.16); color: var(--muted); }

/* Brand — wordmark "rainmaker" (Archivo 900) com a gota no lugar do pingo do "i". */
.brand { display: flex; align-items: center; }
.wordmark {
  font-family: 'Archivo', sans-serif; font-weight: 900; letter-spacing: -0.04em;
  line-height: 1; color: var(--text); display: inline-flex; align-items: flex-end;
  font-size: 24px; user-select: none;
}
.wordmark .wm-i { position: relative; display: inline-block; }
.wordmark .wm-i svg { position: absolute; width: 0.22em; height: auto; left: 50%; top: -0.06em; transform: translateX(-50%); }
.wordmark .wm-i svg path { fill: var(--accent); }
.login-card .wordmark { font-size: 34px; }

/* Login */
.login { position: fixed; inset: 0; display: grid; place-items: center; }
.login-card {
  width: 340px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 16px; padding: 28px; display: flex; flex-direction: column; gap: 12px;
}
.login-card input {
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  padding: 12px 14px; border-radius: 10px; font-size: 15px;
}

/* App shell: sidebar + content */
.app { display: flex; min-height: 100vh; align-items: stretch; }
.sidebar {
  width: 246px; flex-shrink: 0; background: var(--bg-2); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 22px 16px 16px; gap: 16px;
  position: sticky; top: 0; height: 100vh;
}
.side-header { display: flex; flex-direction: column; gap: 12px; padding: 0 8px; }
.side-header .brand { padding: 0; }
.side-actions { display: flex; align-items: center; gap: 8px; }
.side-actions .btn { flex: 1; }
/* Seletor de canal. Com tres canais os nomes nao cabem lado a lado na sidebar de
   246px ("Instagram" sozinho pede ~62px e sobram ~53px), entao aqui ele empilha:
   cada canal ocupa uma linha inteira e nenhum nome fica cortado. Como e grid de
   uma coluna, entra um quarto canal sem mexer no CSS. */
.channel-switch { display: grid; gap: 3px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; margin: 0 8px; }
.channel-switch .chan { width: 100%; min-width: 0; text-align: left; background: transparent; border: none; color: var(--muted); font-size: 13px; font-weight: 700; padding: 9px 12px; border-radius: 7px; cursor: pointer; white-space: nowrap; transition: background .12s, color .12s; }
.channel-switch .chan:hover { color: var(--text); background: var(--bg-2); }
.channel-switch .chan.active { background: var(--accent); color: #1C1917; }
/* Atalho primario da sidebar: leva ao Estudio em post novo (nao cria nada sozinho). */
.side-cta { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 13px 15px; font-size: 14.5px; }
.side-cta span { font-size: 15px; line-height: 1; }
.nav { display: flex; flex-direction: column; gap: 3px; flex: 1; overflow-y: auto; }
/* Rotulo de grupo do menu (Principal / Conta), no mesmo padrao de .lbl. */
.nav-label { font: 600 10px/1 var(--mono); letter-spacing: .2em; text-transform: uppercase; color: var(--dim); padding: 0 8px; margin: 14px 0 8px; }
.nav-label:first-child { margin-top: 0; }
.nav-item {
  display: flex; align-items: center; gap: 13px; width: 100%; text-align: left;
  background: transparent; border: none; color: var(--muted);
  padding: 11px 14px; border-radius: 10px; cursor: pointer; font-size: 14.5px; font-weight: 600;
  transition: background .12s, color .12s;
}
.nav-item:hover { color: var(--text); background: var(--panel-2); }
.nav-item.active { color: #1C1917; background: var(--accent); }
.nav-item svg { width: 19px; height: 19px; flex-shrink: 0; }
.sidebar-foot { border-top: 1px solid var(--border); padding-top: 14px; display: flex; flex-direction: column; gap: 10px; }
/* Rodape de identidade: iniciais em gradiente + nome + resumo das contas em .lbl.
   Substitui o pill solto de status do Instagram (a informacao continua a mesma). */
.ident { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ident-avatar {
  width: 34px; height: 34px; border-radius: 9px; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(140deg, var(--accent), #c2410c);
  color: #12060a; font: 800 12px/1 var(--mono);
}
.ident-txt { min-width: 0; }
.ident-name { font-size: 13px; font-weight: 700; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ident .lbl { display: block; line-height: 1.4; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ident.no .ident-avatar { background: linear-gradient(140deg, var(--border-2), var(--panel-2)); color: var(--muted); }
.content { flex: 1; min-width: 0; }
.pill {
  font-size: 12px; color: var(--muted); background: var(--panel-2);
  border: 1px solid var(--border); padding: 7px 12px; border-radius: 20px; text-align: center;
}
.pill.ok { color: var(--ok); border-color: rgba(52,211,153,.3); }
.pill.no { color: var(--warn); border-color: rgba(245,176,74,.3); }

/* Abas / filtros (pills) usadas em Publicacoes e no Calendario */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab {
  background: var(--panel-2); border: 1px solid var(--border); color: var(--muted);
  padding: 8px 16px; border-radius: 9px; cursor: pointer; font-size: 13.5px; font-weight: 600;
}
.tab:hover { color: var(--text); }
.tab.active { color: #1C1917; background: var(--accent); border-color: var(--accent); }

/* Layout */
main { padding: 38px 44px 70px; max-width: 1240px; margin: 0 auto; }
/* O Estudio e a unica tela com tres colunas de conteudo; 1240px espremia tudo e
   deixava meia tela vazia em monitor grande. */
main.tela-larga { max-width: 1720px; }

@media (max-width: 820px) {
  .app { display: block; }
  /* sidebar vira "contents" -> header no topo, nav embaixo (estilo app) */
  .sidebar { display: contents; }
  .side-header {
    position: fixed; top: 0; left: 0; right: 0; z-index: 20;
    flex-direction: row; align-items: center; justify-content: space-between;
    height: 56px; padding: 0 14px; padding-top: env(safe-area-inset-top);
    background: var(--bg-2); border-bottom: 1px solid var(--border);
  }
  .side-header .brand { font-size: 17px; }
  /* No celular sobra largura, entao o seletor volta a ser uma linha so. Ele fica
     FORA do .side-header no HTML, e com a sidebar em `display: contents` cairia no
     topo da pagina, debaixo do cabecalho fixo de 56px: por isso a margem. E como o
     seletor ja empurra o conteudo para baixo do cabecalho, o .content nao precisa
     mais repetir esse recuo. */
  .channel-switch {
    grid-auto-flow: column; grid-auto-columns: 1fr;
    margin: calc(56px + env(safe-area-inset-top) + 10px) 14px 0;
  }
  .channel-switch .chan { text-align: center; padding: 8px 6px; font-size: 12.5px; }
  /* No celular o topo tem 56px: o atalho e os rotulos de grupo saem de cena. */
  .side-cta, .nav-label { display: none; }
  .side-actions { gap: 6px; }
  .side-actions .btn { flex: none; padding: 8px 12px; }
  .sidebar-foot { display: none; }
  .nav {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
    flex-direction: row; gap: 0; overflow: visible;
    background: var(--bg-2); border-top: 1px solid var(--border);
    padding: 6px 4px; padding-bottom: calc(6px + env(safe-area-inset-bottom));
  }
  .nav-item {
    flex: 1; flex-direction: column; align-items: center; gap: 3px; justify-content: center;
    padding: 7px 2px; border-radius: 10px; font-size: 10px; font-weight: 600; text-align: center; min-width: 0;
  }
  .nav-item span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .nav-item svg { width: 22px; height: 22px; }
  .nav-item.active { background: transparent; color: var(--accent); }
  .content { padding-top: 4px; padding-bottom: calc(66px + env(safe-area-inset-bottom)); }
  main { padding: 18px 14px; }
  .row { flex-wrap: wrap; }
  .toast { bottom: calc(84px + env(safe-area-inset-bottom)); }
}
/* Titulo de tela grande encolhe junto com a largura. */
@media (max-width: 900px) {
  .page-title { font-size: 32px; }
  .page-lede { font-size: 14.5px; margin-bottom: 24px; }
  .secnum { margin: 32px 0 14px; }
}
.row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; gap: 12px; }
.row h2:not(.page-title) { margin: 0; font-size: 20px; }
/* Cabecalho de tela: titulo a esquerda, acoes a direita, alinhado pelo topo. */
.row.page-row { align-items: flex-start; margin-bottom: 10px; }

/* Buttons */
.btn {
  border: 1px solid var(--border-2); background: var(--panel-2); color: var(--text);
  padding: 10px 18px; border-radius: 999px; cursor: pointer; font-size: 14px; font-weight: 600;
  white-space: nowrap; transition: background .12s, color .12s, border-color .12s;
}
.btn:hover { border-color: var(--accent); }
/* Botao primario da marca: laranja com texto GRAFITE (contraste 6.4:1), peso 800,
   pilula. Hover vira brasa com texto branco. */
.btn.primary { background: var(--accent); border-color: var(--accent); color: #1C1917; font-weight: 800; }
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn.sm { padding: 7px 14px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { background: transparent; border: none; color: var(--muted); cursor: pointer; font-size: 13px; }
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 9px; cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text); padding: 0;
}
.theme-toggle:hover { border-color: var(--accent); }
.theme-toggle svg { width: 18px; height: 18px; }

/* Fields */
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 6px; }
input[type=text], input[type=datetime-local], input[type=time], input[type=number], input:not([type]), textarea, select {
  width: 100%; background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  padding: 11px 13px; border-radius: 10px; font-size: 14px; font-family: inherit;
}
textarea { resize: vertical; min-height: 120px; line-height: 1.5; }
.check { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.check label { cursor: pointer; }
/* Checkbox -> interruptor (toggle) */
.check input[type="checkbox"], .daychk input[type="checkbox"] {
  appearance: none; -webkit-appearance: none; margin: 0; flex: none; cursor: pointer;
  width: 42px; height: 24px; border-radius: 24px; background: var(--border);
  position: relative; transition: background .15s;
}
.check input[type="checkbox"]::after, .daychk input[type="checkbox"]::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; transition: left .15s;
}
.check input[type="checkbox"]:checked, .daychk input[type="checkbox"]:checked { background: var(--accent); }
.check input[type="checkbox"]:checked::after, .daychk input[type="checkbox"]:checked::after { left: 21px; }
.daychk { display: inline-flex; align-items: center; gap: 8px; }

/* Cards list (full width) */
.list { display: flex; flex-direction: column; gap: 9px; }
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px; display: flex; align-items: center; gap: 16px;
}
.card:hover { border-color: var(--border-2); }
.card.selected { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.card .selwrap { display: flex; align-items: center; flex: none; }
.selbox { width: 20px; height: 20px; cursor: pointer; accent-color: var(--accent); }
.bulkbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 14px; margin-bottom: 12px;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  position: sticky; top: 8px; z-index: 5;
}
.bulkbar .selall { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.bulkbar .selall input { width: 18px; height: 18px; cursor: pointer; accent-color: var(--accent); }
.card .thumb { width: 72px; height: 90px; border-radius: 8px; object-fit: cover; background: var(--panel-2); border: 1px solid var(--border); }
.card .thumb-li { display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 26px; color: #fff; background: #0a66c2; border-color: #0a66c2; }
.card .thumb-th { display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 26px; color: #fff; background: #101010; border-color: #101010; }
.card .grow { flex: 1; min-width: 0; }
/* Chave liga/desliga da linha de planejamento. Fica antes do titulo porque o
   estado "esta rodando ou nao" e a primeira coisa que a pessoa precisa saber ao
   bater o olho na lista. */
.switch { display: inline-flex; align-items: center; cursor: pointer; flex: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-trilho {
  width: 40px; height: 23px; border-radius: 999px; background: var(--border);
  position: relative; flex: none; transition: background .15s;
}
.switch-bola {
  position: absolute; top: 3px; left: 3px; width: 17px; height: 17px; border-radius: 50%;
  background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.35);
}
.switch input:checked + .switch-trilho { background: var(--ok); }
.switch input:checked + .switch-trilho .switch-bola { transform: translateX(17px); }
.switch input:focus-visible + .switch-trilho { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch input:disabled + .switch-trilho { opacity: .5; cursor: progress; }
/* Linha pausada fica esmaecida: da para varrer a lista e ver o que esta parado. */
.card.pausada .grow { opacity: .55; }
.card .title { font-weight: 600; margin-bottom: 4px; }
.card .sub { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.empty { color: var(--muted); text-align: center; padding: 48px; border: 1px dashed var(--border); border-radius: var(--radius); }

/* Status badges */
.badge { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 20px; text-transform: uppercase; letter-spacing: .04em; }
.badge.draft { background: rgba(139,148,167,.15); color: var(--muted); }
.badge.approved { background: rgba(249,115,22,.15); color: var(--accent-2); }
.badge.scheduled { background: rgba(245,176,74,.15); color: var(--warn); }
.badge.published { background: rgba(52,211,153,.15); color: var(--ok); }
.badge.failed { background: rgba(255,84,104,.15); color: var(--danger); }
.badge.queued { background: rgba(139,148,167,.18); color: var(--muted); }

/* Calendario */
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal-dow { font-size: 12px; color: var(--muted); text-align: center; font-weight: 700; padding-bottom: 4px; }
.cal-cell { min-width: 0; min-height: 96px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 7px; display: flex; flex-direction: column; gap: 4px; }
.cal-cell.empty { background: transparent; border-color: transparent; }
.cal-cell.today { border-color: var(--accent); }
.cal-daynum { font-size: 12px; color: var(--muted); font-weight: 700; }
.cal-item { display: flex; align-items: center; gap: 5px; min-width: 0; font-size: 11px; padding: 3px 5px; border-radius: 6px; background: var(--panel-2); border: 1px solid var(--border); border-left: 3px solid var(--muted); cursor: pointer; }
.cal-item .cal-when { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-thumb { width: 22px; height: 22px; border-radius: 4px; object-fit: cover; background: #000; flex: none; }
.cal-thumb-empty { display: flex; align-items: center; justify-content: center; text-align: center; line-height: 1; font-size: 8px; font-weight: 700; color: var(--muted); background: var(--panel); border: 1px dashed var(--border); text-transform: uppercase; }
.cal-thumb-li { display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 800; color: #fff; background: #0a66c2; }
.cal-thumb-th { display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 800; color: #fff; background: #101010; }
.cal-day-list .cal-thumb-li, .cal-day-list .cal-thumb-th { font-size: 15px; }
.cal-day-list .cal-thumb-empty { font-size: 11px; }
.cal-item .cal-id { color: var(--muted); font-weight: 600; }
.cal-item.cal-nomedia { border-left-color: var(--danger); }
.cal-item.cal-nomedia .cal-thumb-empty { color: var(--danger); border-color: var(--danger); }
.cal-item.st-scheduled { border-left-color: var(--accent); }
.cal-item.st-published { border-left-color: var(--ok); background: rgba(52,211,153,.14); }
.cal-item.st-published .cal-when { color: var(--ok); }
.cal-item.st-failed { border-left-color: var(--danger); }
.cal-item.st-draft, .cal-item.st-queued { border-left-color: var(--muted); }
.cal-item.cal-more { justify-content: center; color: var(--muted); border-left-color: transparent; background: transparent; font-weight: 600; }
.cal-nav { display: flex; align-items: center; gap: 10px; }
.cal-nav h3 { margin: 0; min-width: 150px; text-align: center; text-transform: capitalize; font-size: 16px; }
.cal-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal-week .cal-cell { min-height: 220px; }
.cal-day-list { display: flex; flex-direction: column; gap: 8px; max-width: 680px; }
.cal-day-list .cal-item { padding: 8px 10px; font-size: 13px; }
.cal-day-list .cal-thumb { width: 40px; height: 40px; }
.cal-cap { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Videos */
.vid-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.vid-card { position: relative; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.vid-card video { width: 100%; height: 150px; object-fit: cover; background: #000; display: block; }
.vid-card .vid-noprev { position: absolute; top: 0; left: 0; right: 0; height: 150px; display: flex; align-items: center; justify-content: center; text-align: center; font-size: 11px; font-weight: 600; color: var(--warn); background: rgba(0,0,0,.55); text-transform: uppercase; letter-spacing: .5px; pointer-events: none; }
.vid-card .vid-foot { padding: 8px; display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.vid-card .vid-name { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vid-sched { padding: 0 8px 8px; font-size: 11px; color: var(--accent); display: flex; flex-direction: column; gap: 2px; }
.vid-sched.muted { color: var(--muted); }
.slide-edit { border: 1px solid var(--border); border-radius: 10px; padding: 12px; margin-bottom: 10px; background: var(--panel); }
/* Cabecalho do slide: numero, funcao narrativa e as operacoes de ordem. */
.slide-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.slide-head .lbl { flex: none; }
.slide-head select { padding: 6px 8px; font-size: 12.5px; }
.slide-ops { display: flex; gap: 4px; margin-left: auto; }
.icon-op {
  background: var(--panel-2); border: 1px solid var(--border-2); color: var(--muted);
  width: 28px; height: 28px; border-radius: 8px; cursor: pointer; font-size: 13px; line-height: 1; padding: 0;
}
.icon-op:hover:not(:disabled) { color: var(--text); border-color: var(--dim); }
.icon-op:disabled { opacity: .35; cursor: default; }
.icon-op.danger { color: var(--danger); }
.mini-check { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); cursor: pointer; }
.mini-check input { width: 14px; height: 14px; }
.folder-tab { display: inline-flex; align-items: center; }
.folder-tab .fdel { border: none; background: transparent; color: var(--muted); cursor: pointer; font-size: 12px; padding: 2px 6px; margin-left: -2px; border-radius: 6px; }
.folder-tab .fdel:hover { color: var(--danger); background: rgba(255,84,104,.12); }
.drop { border: 2px dashed var(--border); border-radius: 12px; padding: 28px; text-align: center; color: var(--muted); cursor: pointer; }
.drop:hover { border-color: var(--accent); }

/* Studio split: coluna do formulario (3 secoes numeradas) + preview ao vivo fixo */
/* Estudio em tres colunas: 01 Pauta | 02 Formato + 03 Publicacao | preview.
   Antes as tres etapas ficavam empilhadas numa coluna so, entao o Formato caia
   abaixo da dobra enquanto sobrava meia tela vazia a direita. */
.studio { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(320px, 400px); gap: 22px; align-items: start; }
.studio .panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.studio-col { min-width: 0; }
.studio-col .secnum:first-child, .preview-wrap .secnum:first-child { margin-top: 0; }

/* Seletor de template: card com miniatura desenhada em CSS + nome + quando usar */
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); gap: 10px; }
.tpl-opt {
  display: flex; gap: 13px; align-items: flex-start; text-align: left; width: 100%;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 13px;
  padding: 13px; cursor: pointer; color: var(--text); font-family: inherit;
}
.tpl-opt:hover { border-color: var(--border-2); }
.tpl-opt.active { border-color: var(--accent); background: var(--accent-dim); }
.tpl-thumb { width: 66px; height: 80px; border-radius: 8px; flex: none; position: relative; overflow: hidden; background: #f4f4f6; }
.tpl-thumb.dark { background: #16161f; border: 1px solid var(--border-2); }
.tpl-thumb i { position: absolute; left: 9px; right: 9px; height: 5px; border-radius: 3px; background: #c9c9d4; }
.tpl-thumb.dark i { background: #3a3a4d; }
.tpl-txt { min-width: 0; }
.tpl-nm { font-weight: 700; font-size: 14px; letter-spacing: -.01em; }
.tpl-ds { color: var(--muted); font-size: 12.5px; line-height: 1.45; margin-top: 6px; }

/* Publicacoes: linha em grid (marcar | miniatura | conteudo | acoes) */
.card.post-row { display: grid; grid-template-columns: 30px 64px minmax(0, 1fr) auto; gap: 16px; align-items: center; padding: 16px 18px; }
/* No celular nao cabem 4 colunas: as acoes descem para uma linha propria. */
@media (max-width: 820px) {
  .card.post-row { grid-template-columns: 26px 56px minmax(0, 1fr); gap: 12px; padding: 14px; }
  .card.post-row .actions { grid-column: 1 / -1; justify-content: flex-start; }
  .post-mini { width: 56px; height: 68px; }
}
.post-mini { width: 64px; height: 78px; border-radius: 8px; object-fit: cover; background: var(--panel-2); border: 1px solid var(--border); }
.post-mini.thumb-li { display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 22px; color: #fff; background: #0a66c2; border-color: #0a66c2; }
.post-mini.thumb-th { display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 22px; color: #fff; background: #101010; border-color: #101010; }
.post-mini.thumb-reel { display: flex; align-items: center; justify-content: center; font: 600 10px/1 var(--mono); letter-spacing: .18em; text-transform: uppercase; color: var(--dim); }
video.post-mini { object-fit: cover; background: #000; }
.tabs-mono .tab { font: 600 10.5px/1 var(--mono); letter-spacing: .13em; text-transform: uppercase; padding: 11px 15px; }

/* Detalhe do post: slides a esquerda, trilho de acoes fixo a direita */
.detail { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 26px; align-items: start; }
.detail-slides { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.detail-slide { position: relative; border: 1px solid var(--border); border-radius: 11px; overflow: hidden; background: var(--panel-2); }
.detail-slide img, .detail-slide video { width: 100%; display: block; }
.slide-no { position: absolute; top: 8px; left: 9px; font: 700 8.5px/1 var(--mono); letter-spacing: .12em; color: #fff; background: rgba(0,0,0,.5); padding: 4px 6px; border-radius: 4px; }
.slide-role { position: absolute; top: 8px; right: 9px; font: 700 8.5px/1 var(--mono); letter-spacing: .12em; color: var(--accent-2); background: rgba(0,0,0,.5); padding: 4px 6px; border-radius: 4px; }
.rail { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; position: sticky; top: 24px; }
.rail .lbl { display: block; margin-bottom: 12px; }
.rail .btn { width: 100%; display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.rail hr { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }
.rail .meta { color: var(--muted); font-size: 12.8px; line-height: 1.5; }
@media (max-width: 900px) {
  .detail { grid-template-columns: 1fr; }
  .rail { position: static; }
}
.preview-wrap { position: sticky; top: 90px; }
/* O preview nao tem cabecalho "01 Pauta", entao ganharia um deslocamento para cima
   em relacao as outras colunas. Este espacador copia a caixa do .secnum de verdade
   (mesma fonte, mesmas margens) e some da leitura de tela: alinha sozinho, mesmo
   se o cabecalho mudar de tamanho depois. */
.secnum.espacador { visibility: hidden; }
.preview-stage {
  background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.preview-stage img { width: 100%; max-width: 360px; border-radius: 10px; box-shadow: 0 8px 30px var(--shadow); }
.slides-nav { display: flex; gap: 8px; align-items: center; }
.dot { width: 8px; height: 8px; border-radius: 8px; background: var(--border); }
.dot.active { background: var(--accent); }

/* Voz e identidade */
.voice-liner {
  width: 100%; background: transparent; border: none; color: var(--text);
  font-family: inherit; font-size: 30px; font-weight: 800; letter-spacing: -.025em; line-height: 1.2;
  padding: 0; resize: vertical; min-height: 44px;
}
.voice-liner::placeholder { color: var(--dim); }
.voice-liner:focus { outline: none; }
.voice-liner-wrap { border-bottom: 1px solid var(--border-2); padding-bottom: 14px; margin-bottom: 8px; }
.voice-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(232px, 1fr)); gap: 14px; }
.voice-col { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.voice-col .lbl { display: block; margin-bottom: 12px; }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.tag {
  display: inline-flex; align-items: center; gap: 7px;
  font: 600 11px/1 var(--mono); letter-spacing: .06em; text-transform: uppercase;
  border: 1px solid var(--border-2); color: var(--muted); background: var(--panel-2);
  padding: 7px 9px; border-radius: 6px;
}
.tag.avoid { border-color: rgba(255,84,104,.34); color: var(--danger); background: rgba(255,84,104,.10); }
.tag button { background: none; border: none; color: inherit; cursor: pointer; font-size: 13px; line-height: 1; padding: 0; opacity: .65; }
.tag button:hover { opacity: 1; }
.tag-add { display: flex; gap: 6px; }
.tag-add input { flex: 1; min-width: 0; padding: 8px 10px; font-size: 13px; }
.tag-add .btn { padding: 8px 12px; }
.voice-empty { color: var(--dim); font-size: 12.5px; margin-bottom: 10px; }

/* Estudio guiado: ficha do que vai ser gerado, lista de pautas e stepper. */
.ficha { border: 1px solid var(--border); border-radius: 11px; overflow: hidden; }
.ficha-l { display: flex; align-items: baseline; gap: 14px; padding: 11px 14px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.ficha-l:last-child { border-bottom: 0; }
.ficha-l .lbl { flex: none; width: 92px; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--border-2); border-radius: 9px; overflow: hidden; }
.stepper button { background: transparent; border: 0; color: var(--muted); padding: 6px 13px; cursor: pointer; font-size: 15px; }
.stepper button:hover { color: var(--text); }
.stepper span { padding: 6px 14px; font-weight: 700; border-left: 1px solid var(--border-2); border-right: 1px solid var(--border-2); }
.pauta-opt {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; margin-bottom: 6px; color: var(--text); font-family: inherit;
}
.pauta-opt:hover { border-color: var(--border-2); }
.pauta-opt.ativa { border-color: var(--accent); background: var(--accent-dim); }
.pauta-opt-txt { flex: 1; min-width: 0; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pauta-opt .lbl { flex: none; }

/* Roteiro de Reel: gancho em destaque e cenas numeradas (o que aparece / o que fala). */
.roteiro-hook { background: var(--accent-dim); border-radius: 11px; padding: 12px 14px; margin-bottom: 14px; }
.roteiro-hook p { margin: 6px 0 0; font-size: 15.5px; font-weight: 600; letter-spacing: -.01em; }
.roteiro-cenas { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 10px; }
.roteiro-cenas li { padding-left: 4px; }
.roteiro-cenas b { display: block; font-size: 13px; font-weight: 700; }
.roteiro-cenas span { display: block; color: var(--muted); font-size: 13.5px; margin-top: 3px; }

/* Banco de imagens: grade de reuso, sem gerar nada de novo. */
.banco-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.banco-item {
  position: relative; padding: 0; border: 1px solid var(--border); border-radius: 10px;
  overflow: hidden; cursor: pointer; background: var(--panel-2); aspect-ratio: 4 / 5;
}
.banco-item:hover { border-color: var(--accent); }
.banco-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.banco-tag {
  position: absolute; left: 5px; bottom: 5px; font: 700 8.5px/1 var(--mono); letter-spacing: .1em;
  text-transform: uppercase; color: #fff; background: rgba(0,0,0,.55); padding: 3px 5px; border-radius: 4px;
}

/* Pauta no calendario: o que esta PLANEJADO (ainda texto), acima dos posts.
   Discreta de proposito: o post e o fato, a pauta e a intencao. */
.cal-pauta {
  display: flex; align-items: center; gap: 6px; min-width: 0; cursor: pointer;
  font-size: 11px; padding: 4px 6px; margin-bottom: 3px; border-radius: 6px;
  background: transparent; border: 1px dashed var(--border-2); color: var(--muted);
}
.cal-pauta:hover { border-color: var(--accent); color: var(--text); }
.cal-pauta.aprovada { border-style: solid; border-color: rgba(249,115,22,.45); color: var(--accent-2); }
.cal-pauta.gerada { border-style: solid; border-color: rgba(52,211,153,.35); color: var(--ok); }
.cal-pauta-hora { font: 600 9px/1 var(--mono); letter-spacing: .06em; flex: none; opacity: .8; }
.cal-pauta-txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-day-list + .cal-pauta, .cal-pauta + .cal-day-list { margin-top: 8px; }

/* Faixa da semana na tela Hoje: 7 dias, barra de publicados + agendados. */
.semana { display: grid; grid-template-columns: repeat(7, 1fr); gap: 9px; }
.dia {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 10px 12px; cursor: pointer; color: var(--text); font-family: inherit;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.dia:hover { border-color: var(--border-2); }
.dia.hoje { border-color: var(--accent); background: var(--accent-dim); }
.dia .lbl { color: var(--dim); }
.dia.hoje .lbl { color: var(--accent-2); }
.dia-num { font-size: 19px; font-weight: 800; letter-spacing: -.02em; }
.barras { display: flex; align-items: flex-end; gap: 3px; height: 48px; }
.barras i { width: 9px; border-radius: 3px 3px 0 0; background: var(--ok); min-height: 2px; }
.barras i.age { background: var(--accent); }
.dia-total { font: 600 11px/1 var(--mono); color: var(--muted); }
@media (max-width: 820px) {
  .semana { grid-template-columns: repeat(4, 1fr); }
}

/* Feedback da peca (trilho do detalhe): estrelas + tags que alternam ao clicar. */
.stars { display: flex; gap: 6px; }
.star { background: none; border: none; cursor: pointer; padding: 0; font-size: 22px; line-height: 1; color: var(--border-2); }
.star:hover { color: var(--accent-2); }
.star.on { color: var(--accent); }
.tag-list .tag { cursor: pointer; }
.tag.sel { border-color: var(--accent); color: var(--accent-2); background: var(--accent-dim); }
.tag.avoid.sel { border-color: var(--danger); color: var(--danger); background: rgba(255,84,104,.16); }
.rail .tag-list { margin-bottom: 0; }
.rail textarea { font-size: 13px; }

/* Modal */
.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.6); }
.modal-card {
  position: relative; width: 560px; max-width: 92vw; max-height: 88vh; overflow: auto;
  background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 22px;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.modal-head h3 { margin: 0; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* Toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  padding: 12px 20px; border-radius: 10px; z-index: 120; font-size: 14px; max-width: 90vw; text-align: center;
}
.toast.ok { border-color: rgba(52,211,153,.4); }
.toast.err { border-color: rgba(255,84,104,.4); }

.avatar-sm { width: 44px; height: 44px; border-radius: 44px; object-fit: cover; background: var(--panel-2); border: 1px solid var(--border); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; color: var(--muted); }
.spinner { color: var(--muted); font-size: 13px; }
/* Abaixo de 1400px nao cabem tres colunas: as etapas voltam a empilhar de um lado
   e o preview fica do outro. Abaixo de 860px, tudo em coluna unica. */
@media (max-width: 1600px) {
  .studio { grid-template-columns: minmax(0, 1fr) minmax(280px, 340px); }
  .studio-col:nth-of-type(2) { grid-column: 1; }
  .preview-wrap { grid-column: 2; grid-row: 1 / span 2; }
}
@media (max-width: 1080px) {
  .studio { grid-template-columns: 1fr; }
  .studio-col:nth-of-type(2), .preview-wrap { grid-column: 1; grid-row: auto; }
  /* Em coluna unica o preview vem depois do conteudo: nao ha o que alinhar. */
  .preview-wrap { position: static; }
  .secnum.espacador { display: none; }
}


/* Faixa de saude das contas (Seu dia). Vermelha = conta desconectada e os posts
   nao estao saindo; ambar = token perto de vencer. */
.aviso-conta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 13px 16px; border-radius: 12px; margin: 0 0 20px; font-size: 14px; }
.aviso-conta b { font-weight: 700; }
.aviso-conta span { color: var(--muted); }
.aviso-conta .btn { margin-left: auto; }
.aviso-conta.erro { background: rgba(255,84,104,.12); border: 1px solid rgba(255,84,104,.32); color: var(--danger); }
.aviso-conta.alerta { background: rgba(245,176,74,.12); border: 1px solid rgba(245,176,74,.32); color: var(--warn); }

/* Pontos extraídos de um link lido (origem "A partir de um link"). */
.link-pontos { margin: 12px 0 0; padding-left: 18px; }
.link-pontos li { font-size: 13.5px; color: var(--muted); margin-bottom: 6px; line-height: 1.45; }

/* Controles do texto gravado no Reel (escurecimento, posicao, alinhamento, audio). */
.reel-ctrl { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-top: 12px; }
.reel-ctrl > div { min-width: 0; }
.reel-ctrl .lbl { display: block; margin-bottom: 5px; }
.reel-ctrl input[type=range] { width: 100%; accent-color: var(--accent); }
.reel-ctrl select { width: 100%; }
