/* Base: reset, tipografia, controles e componentes compartilhados entre
   site, painel e overlay. Consome só tokens. */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scrollbar-gutter: stable;
}

/* O dialog torna o fundo inerte, mas não bloqueia sua rolagem por padrão. */
html:has(dialog:modal),
html:has(dialog:modal) body {
  overflow: hidden;
  overscroll-behavior: none;
}

dialog:modal { overscroll-behavior: contain; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--text-md);
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  text-rendering: optimizeLegibility;
}

h1,
h2,
h3,
h4,
p,
ul,
ol,
dl,
dd,
figure {
  margin: 0;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

p {
  text-wrap: pretty;
}

a {
  color: var(--brand);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
}

a:hover {
  color: var(--brand-hover);
}

img,
svg {
  display: block;
  max-width: 100%;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

::selection {
  background: var(--brand-soft);
}

.container {
  width: min(100% - 2 * var(--space-4), var(--container));
  margin-inline: auto;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: -100px;
  left: var(--space-4);
  z-index: 100;
  padding: var(--space-2) var(--space-3);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-2);
}

.skip-link:focus {
  top: var(--space-2);
}

.stack > * + * {
  margin-top: var(--space-4);
}

/* marca */
.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.brand__logo img { display: block; width: 32px; height: 32px; }

/* botões: cinco estados, uma ação primária por bloco */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: 0 var(--space-5);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: var(--text-md);
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition:
    background-color var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out),
    transform var(--duration-fast) var(--ease-out);
}

.btn:active {
  transform: translateY(1px);
}

.btn[disabled],
.btn[aria-disabled='true'] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn[aria-busy='true'] {
  pointer-events: none;
  color: transparent;
  position: relative;
}

.btn[aria-busy='true']::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-color: var(--text-faint) transparent var(--text-faint) transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.btn-primary {
  background: var(--brand);
  color: var(--on-brand);
}

.btn-primary:hover {
  background: var(--brand-hover);
  color: var(--on-brand);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}

.btn-secondary:hover {
  border-color: var(--text-faint);
  color: var(--text);
}

.btn-ghost {
  background: transparent;
  color: var(--text-soft);
}

.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--text);
}

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: transparent;
}

.btn-danger:hover {
  border-color: var(--danger);
  color: var(--danger);
}

.btn-caution {
  background: var(--caution);
  color: var(--on-caution);
}

.btn-caution:hover {
  background: var(--caution-hover);
  color: var(--on-caution);
}

.btn-sm {
  min-height: 36px;
  padding: 0 var(--space-4);
  font-size: var(--text-sm);
}

.btn-lg {
  min-height: 52px;
  padding: 0 var(--space-6);
  font-size: var(--text-lg);
}

.btn-block {
  width: 100%;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-soft);
  cursor: pointer;
}

.icon-btn:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

/* formulários: rótulo acima, erro junto do campo */
.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.field label,
.field legend {
  font-weight: 600;
  font-size: var(--text-sm);
}

.label-note {
  font-weight: 400;
  color: var(--text-soft);
}

.field input:not([type='checkbox']):not([type='radio']),
.field select,
.field textarea {
  width: 100%;
  min-height: 44px;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: var(--text-md);
}

.field textarea {
  resize: vertical;
  line-height: 1.5;
}

.field input::placeholder,
.field textarea::placeholder {
  color: var(--text-faint);
}

.field input:hover,
.field select:hover,
.field textarea:hover {
  border-color: var(--text-faint);
}

.field input[aria-invalid='true'],
.field textarea[aria-invalid='true'],
.field select[aria-invalid='true'] {
  border-color: var(--danger);
}

.field-error {
  display: flex;
  gap: var(--space-1);
  font-size: var(--text-sm);
  color: var(--danger);
}

.field-error::before {
  content: '!';
  flex: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--danger);
  color: var(--surface);
  font-size: var(--text-xs);
  font-weight: 700;
  text-align: center;
  line-height: 18px;
}

.hint {
  font-size: var(--text-sm);
  color: var(--text-soft);
}

.form-error {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: var(--text-sm);
}

.field-hp {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.check {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
}

.check input {
  width: 20px;
  height: 20px;
  margin: 2px 0 0;
  accent-color: var(--brand);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
}

/* chips de status: fundo suave + texto forte + ícone/texto, nunca só cor */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 24px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-pill);
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
}

.chip__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.chip--live {
  background: var(--live-soft);
  color: var(--live-text);
}

.chip--live .chip__dot {
  background: var(--live);
  animation: pulse 1.6s ease-out infinite;
}

.chip--ai {
  background: var(--ai-soft);
  color: var(--ai);
}

.chip--ok {
  background: var(--success-soft);
  color: var(--success);
}

.chip--warn {
  background: var(--warning-soft);
  color: var(--warning);
}

.chip--danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.chip--neutral {
  background: var(--surface-3);
  color: var(--text-soft);
}

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: var(--text-sm);
  font-weight: 600;
  flex: none;
}

.avatar--live {
  box-shadow: 0 0 0 2px var(--live);
}

/* De onde é a live: cores da plataforma e nome acessível no aria-label. */
.platform-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.1em;
  height: 1.1em;
  vertical-align: -0.2em;
  flex: none;
  color: var(--platform-color, var(--text));
}

.platform-icon--youtube { --platform-color: var(--platform-youtube); }
.platform-icon--twitch { --platform-color: var(--platform-twitch); }
.platform-icon--instagram { --platform-color: var(--platform-instagram); }
.platform-icon--facebook { --platform-color: var(--platform-facebook); }
.platform-icon--kwai { --platform-color: var(--platform-kwai); }
.platform-icon--tiktok svg { filter: drop-shadow(-0.6px -0.6px 0 var(--platform-tiktok-cyan)) drop-shadow(0.6px 0.6px 0 var(--platform-tiktok-pink)); }

.platform-icon svg {
  width: 100%;
  height: 100%;
}

.avatar .platform-icon {
  width: 55%;
  height: 55%;
  vertical-align: 0;
}

/* mensagens */
.flash,
.notice {
  margin-top: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: 600;
}

.flash--success,
.notice--success {
  background: var(--success-soft);
  color: var(--success);
}

.flash--error,
.notice--error {
  background: var(--danger-soft);
  color: var(--danger);
}

.notice--warn {
  background: var(--warning-soft);
  color: var(--warning);
}

.notice--info {
  background: var(--brand-soft);
  color: var(--brand);
}

/* listas de definição */
.dl {
  display: grid;
  gap: var(--space-3);
}

.dl > div {
  display: grid;
  gap: var(--space-1);
}

.dl dt {
  font-size: var(--text-sm);
  color: var(--text-soft);
}

.dl dd {
  font-weight: 600;
}

/* número que muda sozinho não dança */
.num {
  font-variant-numeric: tabular-nums;
}

/* página de erro */
.error-page {
  padding: var(--space-9) 0;
  max-width: 560px;
}

.error-page__status {
  font-family: var(--font-display);
  font-size: var(--text-4xl);
  color: var(--text-faint);
  line-height: 1;
}

.error-page__title {
  margin-top: var(--space-3);
  font-size: var(--text-2xl);
}

.error-page__message {
  margin: var(--space-3) 0 var(--space-5);
  color: var(--text-soft);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 var(--live-soft);
  }
  70% {
    box-shadow: 0 0 0 6px transparent;
  }
  100% {
    box-shadow: 0 0 0 0 transparent;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* O logo já traz o próprio fundo menta e o raio; a moldura antiga atrás dele sobraria nos cantos. */
:is(.sidebar-brand__mark, .docs-brand__mark):has(> img) { background: none; }
:is(.sidebar-brand__mark, .docs-brand__mark) img { display: block; width: 100%; height: 100%; }
