@font-face {
  font-family: 'Bricolage Grotesque';
  src: url('/fonts/bricolage.woff2') format('woff2');
  font-weight: 200 800;
  font-display: swap;
}
@font-face {
  font-family: 'Atkinson Hyperlegible';
  src: url('/fonts/atkinson-400.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Atkinson Hyperlegible';
  src: url('/fonts/atkinson-700.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}

:root {
  --paper: #f3efe4;
  --sheet: #fbf9f3;
  --sunken: #e9e4d6;
  --ink: #1b211d;
  --ink-2: #4d564f;
  --ink-3: #6b736c;
  --line: #d8d2c1;
  --felt: #0f3d2e;
  --felt-2: #17533f;
  --felt-ink: #f3efe4;
  --felt-ink-2: #b4c7bb;
  --accent: #14694c;
  --accent-ink: #ffffff;
  --live: #14794f;
  --shadow: #a8650a;
  --off: #6b736c;
  --danger: #a5301f;
  --danger-soft: #f6e2dc;
  --warn-soft: #f7e9cd;
  --ok-soft: #dcefe3;
  --bubble-bot: #e9e4d6;
  --radius: 10px;
  --display: 'Bricolage Grotesque', Georgia, serif;
  --body: 'Atkinson Hyperlegible', Verdana, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #131815;
    --sheet: #1b211d;
    --sunken: #101411;
    --ink: #eeebe1;
    --ink-2: #b9bfb6;
    --ink-3: #939a91;
    --line: #333b35;
    --felt: #0b2a20;
    --felt-2: #143d2f;
    --accent: #3fb587;
    --accent-ink: #08130e;
    --live: #3fb587;
    --shadow: #e0a13c;
    --off: #939a91;
    --danger: #f0917f;
    --danger-soft: #3a1f19;
    --warn-soft: #3a2e15;
    --ok-soft: #16322a;
    --bubble-bot: #262d28;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.5 var(--body);
}
h1, h2, h3 { font-family: var(--display); line-height: 1.12; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.9rem, 4vw, 2.7rem); font-weight: 700; }
h2 { font-size: 1.3rem; font-weight: 650; }
h3 { font-size: 1.05rem; font-weight: 650; }
p { margin: 0; }
a { color: var(--accent); }
.muted { color: var(--ink-2); }
.small { font-size: 0.875rem; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* Formulários */
label.field { display: grid; gap: 6px; font-weight: 700; font-size: 0.925rem; }
label.field small { font-weight: 400; color: var(--ink-2); font-size: 0.85rem; }
input, textarea, select {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--sheet);
  border: 1.5px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  min-height: 44px;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
textarea { resize: vertical; line-height: 1.55; }
button { font: inherit; cursor: pointer; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 8px;
  border: 1.5px solid var(--ink);
  background: transparent;
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
  transition: transform 120ms ease, background 120ms ease;
}
.btn:hover:not(:disabled) { background: var(--sunken); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 85%, black); }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.danger:hover:not(:disabled) { background: var(--danger-soft); }
.btn.quiet { border-color: var(--line); font-weight: 400; }
.form-error { color: var(--danger); font-weight: 700; font-size: 0.925rem; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }

/* Entrada */
.gate { min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
.gate-art {
  background: var(--felt);
  color: var(--felt-ink);
  padding: clamp(24px, 6vw, 72px);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 20px;
  position: relative;
  overflow: hidden;
}
.gate-art::before {
  content: '';
  position: absolute;
  width: 130vh;
  height: 130vh;
  top: -60vh;
  left: -40vh;
  border: 2px solid color-mix(in srgb, var(--felt-ink) 16%, transparent);
  border-radius: 50%;
  box-shadow: 0 0 0 34px color-mix(in srgb, var(--felt-2) 55%, transparent), 0 0 0 36px color-mix(in srgb, var(--felt-ink) 12%, transparent);
}
.gate-art h1 { font-size: clamp(2.4rem, 6vw, 4.5rem); font-weight: 750; position: relative; }
.gate-art p { color: var(--felt-ink-2); max-width: 42ch; position: relative; font-size: 1.1rem; }
.gate-form { display: grid; align-content: center; padding: clamp(24px, 6vw, 72px); }
.gate-form form { display: grid; gap: 18px; width: 100%; max-width: 400px; }

/* Estrutura */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100dvh; }
.side {
  background: var(--felt);
  color: var(--felt-ink);
  padding: 22px 14px;
  display: flex;
  flex-direction: column;
  gap: 26px;
  position: sticky;
  top: 0;
  height: 100dvh;
  overflow-y: auto;
}
.wordmark { font: 750 1.4rem/1 var(--display); padding: 0 10px; letter-spacing: -0.015em; }
.wordmark span { display: block; font: 400 0.8rem/1.4 var(--body); color: var(--felt-ink-2); margin-top: 4px; letter-spacing: 0; }
.side nav { display: grid; gap: 2px; }
.side a {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--felt-ink);
  text-decoration: none;
}
.side a:hover { background: var(--felt-2); }
.side a[aria-current='page'] { background: var(--felt-2); font-weight: 700; box-shadow: inset 3px 0 0 var(--felt-ink); }
.side :focus-visible { outline-color: var(--felt-ink); }
.side-label { font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--felt-ink-2); padding: 0 10px 6px; }
.side-foot { margin-top: auto; display: grid; gap: 2px; border-top: 1px solid var(--felt-2); padding-top: 12px; }
.side-foot .who { padding: 4px 10px 8px; font-size: 0.875rem; color: var(--felt-ink-2); overflow-wrap: anywhere; }
.side-foot button { background: none; border: 0; color: var(--felt-ink); text-align: left; min-height: 42px; padding: 8px 10px; border-radius: 8px; }
.side-foot button:hover { background: var(--felt-2); }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--felt-ink-2); }
.side .dot.live { background: #5fe0a8; box-shadow: 0 0 0 3px rgb(95 224 168 / 0.25); }
.side .dot.shadow { background: #f0b552; }
.side .dot.off { background: transparent; border: 2px solid var(--felt-ink-2); }

main { padding: clamp(20px, 4vw, 44px); min-width: 0; animation: rise 280ms ease both; }
.page-head { display: grid; gap: 8px; margin-bottom: 28px; }
.eyebrow { font-size: 0.8rem; letter-spacing: 0.09em; text-transform: uppercase; color: var(--ink-2); font-weight: 700; }
.panel { background: var(--sheet); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.stack { display: grid; gap: 18px; }
.narrow { max-width: 760px; }

/* Seletor de modo */
.brand-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 20px 32px; margin-bottom: 18px; }
.switch-wrap { display: grid; gap: 8px; justify-items: end; max-width: 100%; }
.mode-switch {
  --pos: 0;
  --tone: var(--off);
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 112px);
  max-width: 100%;
  padding: 4px;
  border-radius: 12px;
  background: var(--sunken);
  border: 1px solid var(--line);
  box-shadow: inset 0 2px 5px rgb(0 0 0 / 0.1);
}
.mode-switch.shadow { --pos: 1; --tone: var(--shadow); }
.mode-switch.live { --pos: 2; --tone: var(--live); }
.mode-switch::before {
  content: '';
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: calc((100% - 8px) / 3);
  transform: translateX(calc(var(--pos) * 100%));
  background: var(--tone);
  border-radius: 9px;
  box-shadow: 0 2px 5px rgb(0 0 0 / 0.28), inset 0 1px 0 rgb(255 255 255 / 0.22);
  transition: transform 240ms cubic-bezier(0.3, 1.3, 0.5, 1), background 240ms ease;
}
.mode-switch label { position: relative; display: grid; place-items: center; min-height: 44px; cursor: pointer; font-weight: 700; font-size: 0.925rem; color: var(--ink-2); text-align: center; }
.mode-switch input { position: absolute; inset: 0; opacity: 0; min-height: 0; margin: 0; cursor: pointer; }
.mode-switch input:disabled { cursor: not-allowed; }
.mode-switch label:has(input:checked) { color: #fff; }
.mode-switch label:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
@media (prefers-color-scheme: dark) {
  .mode-switch label:has(input:checked) { color: #0d1410; }
}
.mode-note { font-size: 0.9rem; color: var(--ink-2); text-align: right; max-width: 40ch; }

.notice { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px; padding: 12px 16px; border-radius: 8px; margin-bottom: 18px; background: var(--warn-soft); font-size: 0.95rem; }
.notice.ok { background: var(--ok-soft); }
.notice.bad { background: var(--danger-soft); }
.chips { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 0.85rem; padding: 2px 10px; border-radius: 99px; background: var(--sheet); border: 1px solid var(--line); }

/* Área de trabalho da marca */
.workbench { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(320px, 1fr); gap: 20px; align-items: start; }
.tabs { display: flex; gap: 4px; border-bottom: 1.5px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs button {
  background: none;
  border: 0;
  padding: 10px 14px;
  min-height: 44px;
  color: var(--ink-2);
  font-weight: 700;
  border-bottom: 3px solid transparent;
  margin-bottom: -1.5px;
  white-space: nowrap;
}
.tabs button[aria-selected='true'] { color: var(--ink); border-bottom-color: var(--accent); }
.tabs button:hover { color: var(--ink); }
.editor { min-height: 52vh; font-size: 0.975rem; }
.save-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; position: sticky; bottom: 0; padding: 12px 0 2px; background: var(--sheet); }

/* Passos da conexão */
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 22px; counter-reset: step; }
.steps > li { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 12px; counter-increment: step; }
.steps > li::before {
  content: counter(step);
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--felt);
  color: var(--felt-ink);
  font: 700 1rem var(--display);
}
.steps .body { display: grid; gap: 10px; min-width: 0; }
.copy-row { display: flex; gap: 8px; }
.copy-row input { font-size: 0.9rem; min-width: 0; }

/* Chat de teste */
.tester { position: sticky; top: 20px; display: flex; flex-direction: column; max-height: calc(100dvh - 40px); padding: 0; overflow: hidden; }
.tester-head { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.tester-head p { font-size: 0.85rem; color: var(--ink-2); }
.tester-head .btn { min-height: 36px; padding: 0 12px; font-size: 0.875rem; }
.messages { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 10px; min-height: 300px; }
.bubble { max-width: 86%; padding: 9px 13px; border-radius: 14px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 0.96rem; animation: rise 180ms ease both; }
.bubble.user { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 4px; }
.bubble.bot { align-self: flex-start; background: var(--bubble-bot); border-bottom-left-radius: 4px; }
.bubble.typing { color: var(--ink-2); font-style: italic; }
.event-note { align-self: stretch; text-align: center; font-size: 0.85rem; padding: 6px 10px; border-radius: 8px; background: var(--warn-soft); }
.event-note.ok { background: var(--ok-soft); }
.event-note.bad { background: var(--danger-soft); }
.suggestions { display: grid; gap: 8px; margin: auto 0; }
.suggestions p { color: var(--ink-2); font-size: 0.9rem; text-align: center; margin-bottom: 4px; }
.suggestions button { background: transparent; border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; min-height: 44px; color: var(--ink); text-align: left; }
.suggestions button:hover { background: var(--sunken); }
.composer { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.composer input { min-width: 0; }

/* Painel */
.brand-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px 28px; }
.brand-row-head { grid-column: 1 / -1; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; }
.brand-row-head a { color: inherit; text-decoration: none; }
.brand-row-head a:hover { text-decoration: underline; }
.pill { display: inline-flex; align-items: center; gap: 7px; font-size: 0.875rem; font-weight: 700; }
.pill .dot.live { background: var(--live); }
.pill .dot.shadow { background: var(--shadow); }
.pill .dot.off { background: transparent; border: 2px solid var(--off); }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; align-content: start; }
.stat strong { display: block; font: 700 2.1rem/1.1 var(--display); font-variant-numeric: tabular-nums; }
.stat span { font-size: 0.85rem; color: var(--ink-2); }
.reasons { display: grid; gap: 10px; align-content: start; }
.reason { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px 10px; font-size: 0.9rem; }
.reason b { font-variant-numeric: tabular-nums; }
.reason .track { grid-column: 1 / -1; height: 6px; }
.reason .bar { display: block; height: 100%; min-width: 4px; background: var(--accent); border-radius: 0 4px 4px 0; }

/* Tabelas */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
th { text-align: left; font-size: 0.8rem; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-2); padding: 8px 12px; border-bottom: 1.5px solid var(--line); white-space: nowrap; }
td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.filter { max-width: 280px; margin-bottom: 18px; }
.empty { text-align: center; padding: 40px 20px; color: var(--ink-2); display: grid; gap: 14px; justify-items: center; }

/* Sobreposições */
dialog { border: 0; border-radius: 12px; padding: 24px; width: min(460px, calc(100vw - 32px)); background: var(--sheet); color: var(--ink); box-shadow: 0 20px 60px rgb(0 0 0 / 0.35); }
dialog::backdrop { background: rgb(10 20 15 / 0.55); }
dialog .stack { gap: 14px; }
#toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 20; width: max-content; max-width: calc(100vw - 32px); }
#toast div { background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 8px; font-weight: 700; font-size: 0.95rem; animation: rise 180ms ease both; }

@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { *, *::before { animation: none !important; transition: none !important; } }

@media (max-width: 1100px) {
  .workbench { grid-template-columns: minmax(0, 1fr); }
  .tester { position: static; max-height: 560px; }
  .editor { min-height: 40vh; }
  .brand-row { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 780px) {
  .gate { grid-template-columns: minmax(0, 1fr); }
  .gate-art { min-height: 34vh; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; padding: 14px 16px; gap: 12px; overflow: visible; }
  .side nav { display: flex; overflow-x: auto; gap: 4px; }
  .side a { white-space: nowrap; }
  .side-label { display: none; }
  .side-foot { margin-top: 0; display: flex; flex-wrap: wrap; align-items: center; padding-top: 8px; }
  .side-foot .who { flex-basis: 100%; padding-bottom: 0; }
  main { padding: 20px 16px; }
  .switch-wrap { justify-items: stretch; width: 100%; }
  .mode-switch { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .mode-note { text-align: left; max-width: none; }
  .two-col { grid-template-columns: minmax(0, 1fr); }
}
