:root {
  color-scheme: dark;
  --bg: #0d1117;
  --bg-raised: #151b23;
  --bg-input: #0b0f14;
  --line: #262d36;
  --line-soft: #1c222a;
  --text: #e6edf3;
  --text-dim: #8b949e;
  --text-faint: #6e7681;
  --accent: #1877f2;
  --accent-ink: #ffffff;
  --ok: #3fb950;
  --warn: #d29922;
  --bad: #f85149;
  --radius: 8px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
}

h1, h2 { margin: 0; font-weight: 600; }
h1 { font-size: 15px; letter-spacing: -0.01em; }
h2 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-dim); }

/* ---------------------------------------------------------------- topbar */

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-raised);
  flex: 0 0 auto;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 26px; height: 26px;
  border-radius: 6px;
  background: #1877f2;
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.03em;
}

.topbar-status { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-input);
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
}
.chip:hover { border-color: #384049; color: var(--text); }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-faint); flex: 0 0 auto; }
.chip.is-ok .dot { background: var(--ok); }
.chip.is-warn .dot { background: var(--warn); }
.chip.is-bad .dot { background: var(--bad); }

/* ---------------------------------------------------------------- layout */

.layout {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 290px;
  min-height: 0;
}

.sidebar, .queue {
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.sidebar { border-right: 1px solid var(--line); }
.queue { border-left: 1px solid var(--line); }

.panel {
  background: var(--bg-raised);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.hint { margin: 0; font-size: 11.5px; line-height: 1.45; color: var(--text-faint); }
.hint strong, .hint em { color: var(--text-dim); font-style: normal; }
.hint code {
  font-family: var(--mono); font-size: 10.5px;
  background: var(--bg-input); padding: 1px 4px; border-radius: 3px;
}

/* ---------------------------------------------------------------- fields */

.field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--text-dim); }
.field > span { font-weight: 500; }
.field small { font-size: 11px; color: var(--text-faint); line-height: 1.4; }

input[type="text"], input[type="number"], textarea {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg-input);
  color: var(--text);
  font: inherit;
  font-size: 13px;
}
input:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { resize: vertical; font-size: 12.5px; }

.checkline { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12.5px; color: var(--text-dim); }
.checkline label, .switch { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.switch { font-size: 12.5px; color: var(--text-dim); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); margin: 0; }

.actions { display: flex; gap: 8px; }
.actions .btn { flex: 1; }

/* ---------------------------------------------------------------- buttons */

.btn {
  padding: 7px 13px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--bg-input);
  color: var(--text);
  font: inherit;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { border-color: #3d4650; background: #171d25; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover:not(:disabled) { background: #3b8cf5; border-color: #3b8cf5; }
.btn-ghost { background: transparent; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.chips .tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 6px 4px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-input);
  font-size: 12px;
}
.chips .tag code { font-family: var(--mono); font-size: 10.5px; color: var(--text-faint); }
.chips .tag button {
  border: 0; background: transparent; color: var(--text-faint);
  cursor: pointer; font-size: 14px; line-height: 1; padding: 0 2px;
}
.chips .tag button:hover { color: var(--bad); }

details summary { cursor: pointer; font-size: 12px; color: var(--text-faint); padding: 2px 0; }
details summary:hover { color: var(--text-dim); }
details[open] summary { margin-bottom: 8px; }

/* ------------------------------------------------------------------ abas */

.tabs {
  display: flex; gap: 2px;
  padding: 8px 14px 0;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}

.tab {
  padding: 7px 14px;
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: 6px 6px 0 0;
  background: transparent;
  color: var(--text-faint);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
}
.tab:hover { color: var(--text-dim); }
.tab.is-active { background: var(--bg); border-color: var(--line); color: var(--text); margin-bottom: -1px; }

select.mini, input.mini {
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg-input);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  max-width: 190px;
}
select.mini:disabled, input.mini:disabled { opacity: 0.4; }
input.mini { width: 160px; }

/* ---------------------------------------------------------------- results */

.results { display: flex; flex-direction: column; min-width: 0; min-height: 0; }

.results-toolbar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-raised);
  flex: 0 0 auto;
  /* Em telas estreitas os seletores e botões não caberiam numa linha só; sem o
     wrap eles comprimem até ficar ilegíveis. */
  flex-wrap: wrap;
}
.results-toolbar .spacer { flex: 1 1 0; min-width: 0; }
.results-toolbar .btn { flex: 0 0 auto; }
.select-all { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-dim); cursor: pointer; }

.results-meta {
  padding: 7px 14px;
  font-size: 11.5px;
  color: var(--text-faint);
  border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: center; gap: 12px;
  flex: 0 0 auto;
}
.results-meta .sep { color: var(--line); }

.table-wrap { flex: 1 1 auto; overflow: auto; position: relative; }

table.pubs { width: 100%; border-collapse: collapse; font-size: 13px; }

table.pubs thead th {
  position: sticky; top: 0; z-index: 2;
  background: #12181f;
  border-bottom: 1px solid var(--line);
  padding: 8px 10px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
}

table.pubs td { padding: 9px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
table.pubs tbody tr:hover { background: #121820; }
table.pubs tbody tr.is-selected { background: #101c2c; }
table.pubs tbody tr.is-off { opacity: 0.5; }

.col-check { width: 34px; }
.col-estado { width: 104px; }
.col-quando, .col-proximo { width: 128px; }
.col-erros { width: 62px; }

/* Célula da publicação: apelido em cima, grupo e link embaixo. O link cru é
   longo e sem valor de leitura — fica em fonte mono, esmaecido, e só serve
   para conferir que é o post certo. */
.pub-cell { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pub-cell .apelido { color: var(--text); font-weight: 500; }
.pub-cell a { color: var(--text-dim); text-decoration: none; }
.pub-cell a:hover { color: var(--accent); text-decoration: underline; }
.pub-cell .sub {
  font-size: 11px; color: var(--text-faint); font-family: var(--mono);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pub-cell .grupo { font-size: 11.5px; color: var(--text-dim); }

.badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11px;
  border: 1px solid var(--line);
  color: var(--text-dim);
}
.badge.ok { color: var(--ok); border-color: rgba(63, 185, 80, 0.35); }
.badge.warn { color: var(--warn); border-color: rgba(210, 153, 34, 0.35); }
.badge.bad { color: var(--bad); border-color: rgba(248, 81, 73, 0.35); }

.quando { font-size: 12px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.quando .faint { color: var(--text-faint); font-size: 11px; display: block; }

.empty { padding: 40px 20px; text-align: center; color: var(--text-faint); font-size: 13px; }
.empty[hidden] { display: none; }

/* ---------------------------------------------------------------- agenda */

.queue-counts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; text-align: center; }
.queue-counts div { background: var(--bg-input); border: 1px solid var(--line-soft); border-radius: 6px; padding: 7px 4px; }
.queue-counts strong { display: block; font-size: 17px; font-variant-numeric: tabular-nums; }
.queue-counts span { font-size: 10.5px; color: var(--text-faint); }

.queue-next {
  font-size: 12px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  padding: 7px 9px;
  background: var(--bg-input);
  border: 1px solid var(--line-soft);
  border-radius: 6px;
}
.queue-next.is-paused { color: var(--warn); }

.meter { display: grid; grid-template-columns: 52px 1fr 46px; align-items: center; gap: 8px; font-size: 11.5px; color: var(--text-dim); }
.meter .bar { height: 5px; border-radius: 3px; background: var(--bg-input); border: 1px solid var(--line-soft); overflow: hidden; }
.meter .bar i { display: block; height: 100%; background: var(--accent); transition: width 0.3s; }
.meter.is-high .bar i { background: var(--warn); }
.meter.is-full .bar i { background: var(--bad); }
.meter span { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-faint); }

.log { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; max-height: 300px; overflow-y: auto; }
.log li { font-size: 11.5px; line-height: 1.4; color: var(--text-faint); border-left: 2px solid var(--line); padding-left: 8px; }
.log li.ok { border-color: var(--ok); color: var(--text-dim); }
.log li.bad { border-color: var(--bad); color: #f0a9a4; }
.log li time { display: block; font-size: 10px; color: var(--text-faint); opacity: 0.7; }

/* --------------------------------------------------------- linha do dia */

/* A faixa das 24h com um risco por comentário já feito e um por previsto.
   Existe porque "3 de 12 hoje" não responde a pergunta que importa — se o que
   falta ainda cabe antes da janela fechar. */
.dia {
  position: relative;
  height: 26px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: var(--bg-input);
  overflow: hidden;
}
.dia .janela { position: absolute; top: 0; bottom: 0; background: rgba(24, 119, 242, 0.1); }
.dia i {
  position: absolute; top: 4px; bottom: 4px;
  width: 2px; border-radius: 1px;
  background: var(--text-faint);
}
.dia i.feito { background: var(--ok); }
.dia i.previsto { background: var(--accent); opacity: 0.55; }
.dia i.falhou { background: var(--bad); }
.dia .agora { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--warn); }
.dia-eixo { display: flex; justify-content: space-between; font-size: 10px; color: var(--text-faint); font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- dialogs */

dialog {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-raised);
  color: var(--text);
  padding: 0;
  max-width: 560px;
  width: calc(100% - 40px);
  max-height: 86vh;
}
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }

.dialog-body { padding: 18px; display: flex; flex-direction: column; gap: 14px; overflow-y: auto; max-height: 86vh; }
.dialog-body h2 { font-size: 14px; text-transform: none; letter-spacing: 0; color: var(--text); }
.dialog-body p { margin: 0; font-size: 12.5px; color: var(--text-dim); line-height: 1.55; }
.dialog-body code { font-family: var(--mono); font-size: 11.5px; background: var(--bg-input); padding: 1px 4px; border-radius: 3px; }

fieldset { border: 1px solid var(--line-soft); border-radius: 7px; padding: 12px; margin: 0; display: flex; flex-direction: column; gap: 9px; }
legend { padding: 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-faint); }

menu { display: flex; justify-content: flex-end; gap: 8px; margin: 0; padding: 0; }

.verdict {
  padding: 11px 13px;
  border-radius: 7px;
  border: 1px solid rgba(210, 153, 34, 0.4);
  background: rgba(210, 153, 34, 0.09);
  color: #f2d492;
  font-size: 12.5px;
  line-height: 1.55;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}
.verdict.is-bad { border-color: rgba(248, 81, 73, 0.45); background: rgba(248, 81, 73, 0.1); color: #ffb3ae; }
.verdict.is-ok { border-color: rgba(63, 185, 80, 0.4); background: rgba(63, 185, 80, 0.08); color: #a5e0ad; }

.diag-shape { display: grid; grid-template-columns: 132px 1fr; gap: 3px 10px; margin: 0; font-size: 11.5px; }
.diag-shape dt { color: var(--text-faint); }
.diag-shape dd { margin: 0; color: var(--text-dim); word-break: break-word; font-family: var(--mono); font-size: 11px; }

/* --------------------------------------------------- lista de conferência */

/* Colar 20 links de uma vez e ver, linha a linha, o que foi reconhecido e o
   que não foi — antes de gravar. Sem isto o erro só aparece na hora de
   comentar, horas depois, num post que nem existe. */
.recipe-list { display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow-y: auto; }
.recipe-row {
  display: grid; grid-template-columns: 8px 1fr auto; align-items: center; gap: 9px;
  padding: 8px 10px;
  background: var(--bg-input);
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  font-size: 12px;
}
.recipe-row .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); }
.recipe-row.is-ok .dot { background: var(--ok); }
.recipe-row.is-bad .dot { background: var(--bad); }
.recipe-row .meta { color: var(--text-faint); font-size: 10.5px; font-family: var(--mono); word-break: break-all; }
.recipe-row .state { font-size: 11px; color: var(--text-faint); white-space: nowrap; }

/* ---------------------------------------------------------------- toasts */

.toast-stack { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }

.toast {
  padding: 10px 14px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: #10161d;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
  font-size: 12.5px;
  max-width: 380px;
  animation: rise 0.18s ease-out;
}
.toast.ok { border-color: rgba(63, 185, 80, 0.4); }
.toast.bad { border-color: rgba(248, 81, 73, 0.45); }

@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

@media (max-width: 1180px) {
  .layout { grid-template-columns: 280px minmax(0, 1fr); }
  .queue { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--line); flex-direction: row; flex-wrap: wrap; }
  .queue .panel { flex: 1 1 240px; }
}

/* --------------------------------------------------- painel em destaque */

/* Colar links é a única entrada de dados da ferramenta: tudo começa aqui, e o
   painel sinaliza isso em vez de deixar o campo se perder entre os outros. */
.panel.destaque {
  border: 1px solid rgba(24, 119, 242, 0.35);
  background: rgba(24, 119, 242, 0.06);
  border-radius: 8px;
  padding: 12px;
}
.panel.destaque h2 { color: var(--accent); }

/* ------------------------------------------------------- tela do navegador */

/* A janela do Chrome dirigido, quando a ferramenta roda num servidor. Grande
   de propósito: é por ela que se digita a senha e o código do 2FA, e se lê um
   checkpoint do Facebook.

   O `display: flex` vai só no `[open]`. Regra de autor vence a do navegador
   independentemente de especificidade, então um display no seletor sem
   `[open]` deixaria o diálogo fechado visível na página. */
dialog.dlg-tela {
  max-width: none;
  width: min(96vw, 1640px);
  height: 92vh;
  max-height: 92vh;
}
dialog.dlg-tela[open] { display: flex; flex-direction: column; }

.tela-barra {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.tela-barra .hint { margin: 0 auto 0 4px; font-size: 11px; }

/* O estado do controle precisa ser legível de relance: é a diferença entre um
   clique inofensivo e um clique que navega para fora no meio de um comentário. */
.tela-estado {
  font-family: var(--mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
}
.tela-estado.is-vivo {
  color: var(--warn);
  border-color: rgba(210, 153, 34, 0.5);
  background: rgba(210, 153, 34, 0.1);
}

#tela {
  flex: 1;
  width: 100%;
  min-height: 0;
  border: 0;
  background: #000;
  display: block;
}
