:root {
  --bg: #131922;
  --surface: #1b2330;
  --surface-2: #222c3b;
  --line: #2a3445;
  --line-strong: #39465b;
  --text: #e4e9f0;
  --muted: #8a95a7;
  --accent: #f0b440;
  --accent-ink: #1a1406;
  --accent-soft: rgba(240, 180, 64, 0.14);
  --ok: #3bc4a4;
  --ok-soft: rgba(59, 196, 164, 0.14);
  --warn: #f0b440;
  --bad: #e5675a;
  --bad-soft: rgba(229, 103, 90, 0.14);
  --code-bg: #0f141c;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --radius-s: 6px;
  --radius-m: 10px;
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif;
  --mono: "Cascadia Code", "Cascadia Mono", Consolas, "SFMono-Regular", Menlo, monospace;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #eef1f5;
  --surface: #ffffff;
  --surface-2: #f5f7fa;
  --line: #dbe1ea;
  --line-strong: #c3ccd9;
  --text: #18202c;
  --muted: #5d6a7d;
  --accent: #b97c00;
  --accent-ink: #ffffff;
  --accent-soft: rgba(185, 124, 0, 0.12);
  --ok: #138a6f;
  --ok-soft: rgba(19, 138, 111, 0.12);
  --warn: #b97c00;
  --bad: #c4402f;
  --bad-soft: rgba(196, 64, 47, 0.1);
  --code-bg: #f3f5f8;
  --shadow: 0 18px 50px rgba(24, 32, 44, 0.18);
  color-scheme: light;
}

* { box-sizing: border-box; }

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }
a:hover { text-decoration: none; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

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

code, pre, .mono { font-family: var(--mono); font-size: 13px; }

/* ---------- Estrutura ---------- */

.shell {
  display: grid;
  grid-template-columns: 232px 1fr;
  min-height: 100vh;
}

.sidebar {
  border-right: 1px solid var(--line);
  padding: 22px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--bg);
}

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

.brand svg { flex: none; }

.brand strong {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.brand span { display: block; color: var(--muted); font-size: 12px; }

.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-s);
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
}

.nav a:hover { color: var(--text); background: var(--surface); }

.nav a[aria-current="page"] {
  color: var(--text);
  background: var(--surface-2);
  box-shadow: inset 3px 0 0 var(--accent);
}

.nav svg { width: 18px; height: 18px; flex: none; }

.sidebar-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 4px;
}

.sidebar-foot .btn { justify-content: flex-start; }

.shell > div,
.connect-stage > *,
.doc-layout > *,
.grid-2 > *,
.chat-layout > * { min-width: 0; }

.main {
  padding: 32px clamp(16px, 4vw, 48px) 64px;
  max-width: 1180px;
  width: 100%;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 26px;
  flex-wrap: wrap;
}

h1 {
  font-family: var(--font-display);
  font-size: 30px;
  line-height: 1.15;
  font-weight: 650;
  letter-spacing: -0.015em;
  margin: 0;
}

h2 {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
  margin: 0 0 4px;
}

h3 { font-size: 15px; font-weight: 600; margin: 0 0 4px; }

.lede { color: var(--muted); margin: 6px 0 0; max-width: 62ch; }

.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- Botões ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  padding: 8px 14px;
  border-radius: var(--radius-s);
  font-weight: 550;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.12s ease, border-color 0.12s ease;
}

.btn:hover { background: var(--surface-2); border-color: var(--muted); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.btn-primary:hover { background: var(--accent); filter: brightness(1.07); border-color: var(--accent); }

.btn-danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); }
.btn-danger:hover { background: var(--bad-soft); border-color: var(--bad); }

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

.btn-sm { padding: 5px 10px; font-size: 13px; }

.btn svg { width: 16px; height: 16px; }

/* ---------- Formulários ---------- */

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }

.field label { font-weight: 550; font-size: 14px; }

.field .hint { color: var(--muted); font-size: 13px; }

.input, select.input, textarea.input {
  width: 100%;
  background: var(--code-bg);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-s);
  padding: 9px 11px;
  outline: none;
}

.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

textarea.input { min-height: 96px; resize: vertical; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1 1 220px; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; }

.toggle {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.toggle:last-child { border-bottom: 0; }

.toggle input { position: absolute; opacity: 0; pointer-events: none; }

.switch {
  flex: none;
  width: 36px;
  height: 20px;
  border-radius: 20px;
  background: var(--line-strong);
  position: relative;
  margin-top: 2px;
  transition: background-color 0.15s ease;
}

.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text);
  transition: transform 0.15s ease;
}

.toggle input:checked + .switch { background: var(--accent); }
.toggle input:checked + .switch::after { transform: translateX(16px); background: var(--accent-ink); }
.toggle input:focus-visible + .switch { outline: 2px solid var(--accent); outline-offset: 2px; }

.toggle .t-text strong { display: block; font-weight: 550; }
.toggle .t-text span { color: var(--muted); font-size: 13px; }

.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 6px 18px; margin: 4px 0 16px; }
.checks label { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; cursor: pointer; }
.checks input { margin-top: 4px; accent-color: var(--accent); }
.checks code { color: var(--muted); font-size: 12px; display: block; }

/* ---------- Superfícies ---------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: 22px;
  margin-bottom: 18px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.panel-head p { margin: 0; color: var(--muted); font-size: 14px; }

/* ---------- Lista de instâncias (linhas de painel de controle) ---------- */

.board {
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  background: var(--surface);
  overflow: hidden;
}

.board-row {
  display: grid;
  grid-template-columns: 44px minmax(140px, 1.3fr) minmax(130px, 1fr) minmax(120px, 0.9fr) 110px auto;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  color: inherit;
}

.board-row:last-child { border-bottom: 0; }

a.board-row:hover { background: var(--surface-2); }

.board-head {
  background: var(--surface-2);
  color: var(--muted);
  font-size: 13px;
  font-weight: 550;
  padding-top: 10px;
  padding-bottom: 10px;
}

.board-row .name { font-weight: 600; font-size: 16px; }
.board-row .sub { color: var(--muted); font-size: 13px; }
.board-row .actions { display: flex; gap: 6px; justify-content: flex-end; }

/* Lâmpada de estado: o elemento de identidade do painel */
.lamp {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
}

.lamp::after {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
}

.lamp[data-state="open"] { border-color: color-mix(in srgb, var(--ok) 55%, var(--line)); background: var(--ok-soft); }
.lamp[data-state="open"]::after { background: var(--ok); box-shadow: 0 0 10px var(--ok); }

.lamp[data-state="connecting"],
.lamp[data-state="reconnecting"] { border-color: color-mix(in srgb, var(--warn) 55%, var(--line)); background: var(--accent-soft); }
.lamp[data-state="connecting"]::after,
.lamp[data-state="reconnecting"]::after { background: var(--warn); animation: blink 1.1s ease-in-out infinite; }

.lamp[data-state="close"] { border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); background: var(--bad-soft); }
.lamp[data-state="close"]::after { background: var(--bad); }

.lamp.lg { width: 44px; height: 44px; }
.lamp.lg::after { width: 16px; height: 16px; }

@keyframes blink { 50% { opacity: 0.25; } }

.state-text[data-state="open"] { color: var(--ok); }
.state-text[data-state="connecting"],
.state-text[data-state="reconnecting"] { color: var(--warn); }
.state-text[data-state="close"] { color: var(--bad); }
.state-text { font-weight: 600; font-size: 14px; }

.empty {
  padding: 56px 24px;
  text-align: center;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-m);
}

.empty h2 { margin-bottom: 6px; }
.empty p { color: var(--muted); margin: 0 auto 18px; max-width: 46ch; }

/* ---------- Detalhe da instância ---------- */

.inst-head {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

.inst-head .meta { flex: 1 1 260px; }
.inst-head .meta p { margin: 2px 0 0; color: var(--muted); }

.back { color: var(--muted); text-decoration: none; font-size: 14px; display: inline-block; margin-bottom: 12px; }
.back:hover { color: var(--text); }

.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 22px;
  overflow-x: auto;
}

.tabs button {
  border: 0;
  background: none;
  padding: 10px 14px;
  color: var(--muted);
  font-weight: 550;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
}

.tabs button:hover { color: var(--text); }
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }

.connect-stage {
  display: grid;
  grid-template-columns: minmax(260px, 380px) 1fr;
  gap: 28px;
  align-items: start;
}

.qr-frame {
  aspect-ratio: 1;
  background: #ffffff;
  border-radius: var(--radius-m);
  display: grid;
  place-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  position: relative;
}

.qr-frame img { width: 100%; height: 100%; image-rendering: pixelated; }

.qr-frame.placeholder {
  background: var(--surface-2);
  color: var(--muted);
  text-align: center;
  padding: 28px;
}

.qr-frame.placeholder .lamp { margin: 0 auto 12px; }

.pair-code {
  font-family: var(--mono);
  font-size: 34px;
  letter-spacing: 0.12em;
  font-weight: 700;
  color: var(--accent);
  text-align: center;
  padding: 18px;
  border: 1px dashed var(--accent);
  border-radius: var(--radius-m);
  background: var(--accent-soft);
}

.steps { margin: 0; padding-left: 20px; color: var(--muted); }
.steps li { margin-bottom: 6px; }
.steps strong { color: var(--text); font-weight: 550; }

.kv { display: grid; grid-template-columns: 160px 1fr; gap: 8px 16px; margin: 0; }
.kv dt { color: var(--muted); font-size: 14px; }
.kv dd { margin: 0; word-break: break-all; }

.secret {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  padding: 6px 6px 6px 12px;
}

.secret code { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Conversas ---------- */

.chat-layout { display: grid; grid-template-columns: 300px 1fr; gap: 0; border: 1px solid var(--line); border-radius: var(--radius-m); overflow: hidden; min-height: 460px; background: var(--surface); }

.chat-list { border-right: 1px solid var(--line); overflow-y: auto; max-height: 620px; }

.chat-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 12px 14px;
  cursor: pointer;
}

.chat-item:hover { background: var(--surface-2); }
.chat-item[aria-current="true"] { background: var(--surface-2); box-shadow: inset 3px 0 0 var(--accent); }
.chat-item strong { display: block; font-weight: 600; font-size: 14px; }
.chat-item span { color: var(--muted); font-size: 13px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.chat-view { display: flex; flex-direction: column; max-height: 620px; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column-reverse; gap: 8px; }

.bubble {
  max-width: 72%;
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  align-self: flex-start;
  white-space: pre-wrap;
  word-break: break-word;
}

.bubble.me { align-self: flex-end; background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
.bubble .b-meta { display: block; font-size: 11px; color: var(--muted); margin-top: 4px; text-align: right; }
.bubble a { font-size: 13px; }

.chat-compose { border-top: 1px solid var(--line); padding: 12px; display: flex; gap: 8px; }
.chat-compose .input { flex: 1; }

/* ---------- Logs ---------- */

.log-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.log-table th { text-align: left; color: var(--muted); font-weight: 550; padding: 8px 10px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); }
.log-table td { padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.log-table td.msg { font-family: var(--mono); font-size: 12.5px; word-break: break-word; }
.log-wrap { max-height: 560px; overflow: auto; }

.lvl { font-weight: 700; font-size: 12px; }
.lvl-error { color: var(--bad); }
.lvl-warn { color: var(--warn); }
.lvl-info { color: var(--ok); }

/* ---------- Docs ---------- */

.doc-layout { display: grid; grid-template-columns: 210px 1fr; gap: 32px; align-items: start; }

.doc-toc { position: sticky; top: 24px; display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.doc-toc a { color: var(--muted); text-decoration: none; padding: 4px 8px; border-radius: var(--radius-s); }
.doc-toc a:hover { color: var(--text); background: var(--surface); }

.endpoint { padding: 20px 0; border-bottom: 1px solid var(--line); }
.endpoint:last-child { border-bottom: 0; }
.endpoint p { color: var(--muted); margin: 6px 0 12px; max-width: 70ch; }

.route { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.route code { font-size: 14px; color: var(--text); }

.method {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid currentColor;
}

.m-get { color: var(--ok); }
.m-post { color: var(--accent); }
.m-put { color: #8fa8ff; }
.m-delete { color: var(--bad); }

pre.code {
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  padding: 14px 16px;
  overflow-x: auto;
  margin: 8px 0 0;
  line-height: 1.55;
  position: relative;
}

.code-wrap { position: relative; }
.code-wrap .copy-btn { position: absolute; top: 8px; right: 8px; }

.doc-section { scroll-margin-top: 20px; margin-bottom: 34px; }
.doc-section > h2 { font-size: 22px; margin-bottom: 8px; }

/* ---------- Auth ---------- */

.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 32px 28px;
  box-shadow: var(--shadow);
}

.auth-card .brand { padding: 0 0 24px; }
.auth-card h1 { font-size: 24px; margin-bottom: 6px; }
.auth-card .lede { margin-bottom: 22px; }

.alert {
  padding: 10px 12px;
  border-radius: var(--radius-s);
  font-size: 14px;
  margin-bottom: 14px;
  border: 1px solid;
}

.alert-error { color: var(--bad); background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.alert-info { color: var(--text); background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.alert-ok { color: var(--ok); background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }

/* ---------- Modal e toast ---------- */

.modal-back {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 12, 0.62);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 50;
}

.modal {
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  padding: 24px;
  box-shadow: var(--shadow);
  animation: rise 0.16s ease-out;
}

.modal h2 { margin-bottom: 4px; }
.modal .lede { margin-bottom: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

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

.toasts {
  position: fixed;
  bottom: 18px;
  right: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 60;
  max-width: calc(100vw - 36px);
}

.toast {
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-left: 3px solid var(--accent);
  padding: 10px 14px;
  border-radius: var(--radius-s);
  box-shadow: var(--shadow);
  font-size: 14px;
  max-width: 380px;
  animation: rise 0.16s ease-out;
}

.toast.error { border-left-color: var(--bad); }
.toast.ok { border-left-color: var(--ok); }

.hidden { display: none !important; }

.mobile-bar { display: none; }

/* ---------- Responsivo ---------- */

@media (max-width: 900px) {
  .board-row { grid-template-columns: 34px 1fr auto; }
  .board-row .col-phone, .board-row .col-msgs, .board-head { display: none; }
  .board-row .col-state { grid-column: 2; }
  .board-row .actions { grid-column: 3; grid-row: 1 / span 2; }
  .connect-stage { grid-template-columns: 1fr; }
  .doc-layout { grid-template-columns: 1fr; }
  .doc-toc { position: static; flex-direction: row; flex-wrap: wrap; }
  .chat-layout { grid-template-columns: 1fr; }
  .chat-list { max-height: 220px; border-right: 0; border-bottom: 1px solid var(--line); }
  .grid-2 { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; }
  .kv dt { margin-top: 6px; }
}

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 260px;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow);
    background: var(--surface);
  }
  .shell.nav-open .sidebar { transform: none; }
  .mobile-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    background: var(--bg);
    z-index: 30;
  }
  .main { padding: 22px 16px 48px; }
  h1 { font-size: 25px; }
}

/* ---------- v1.1: atualização, transcrição, mídia ---------- */

.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;
}

.banner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  margin-bottom: 22px;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line));
  background: var(--accent-soft);
  border-radius: var(--radius-m);
  flex-wrap: wrap;
}

.banner-text { display: flex; flex-direction: column; gap: 4px; flex: 1 1 320px; min-width: 0; }
.banner-text strong { font-size: 15px; }
.banner-text > span { color: var(--muted); font-size: 14px; }
.banner-notes { margin: 4px 0 0; padding-left: 18px; font-size: 14px; }
.banner-err { color: var(--bad) !important; }
.banner-ok { border-color: color-mix(in srgb, var(--ok) 45%, var(--line)); background: var(--ok-soft); }
.banner-error { border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); background: var(--bad-soft); }

.progress {
  height: 6px;
  border-radius: 6px;
  background: var(--line);
  overflow: hidden;
  margin: 8px 0 4px;
}

.progress > span {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 6px;
  transition: width 0.3s ease;
}

.progress.indeterminate > span { width: 35%; animation: slide 1.2s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(300%); } }

.pill {
  font-size: 13px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid var(--line-strong);
  color: var(--muted);
}

.pill[data-state="ok"] { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 50%, var(--line)); background: var(--ok-soft); }

.engine-pick { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }

.engine {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-m);
  cursor: pointer;
  background: var(--surface-2);
}

.engine:has(input:checked) { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.engine input, .model-pick input { margin-top: 4px; accent-color: var(--accent); }
.engine > span > strong, .model-pick > span > strong { display: block; font-weight: 600; }
.engine > span > span, .model-pick > span > span { color: var(--muted); font-size: 13px; }

.model-list { border: 1px solid var(--line); border-radius: var(--radius-m); overflow: hidden; }

.model-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 14px;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.model-row:last-child { border-bottom: 0; }
.model-pick { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.model-state { font-size: 13px; white-space: nowrap; }

.dl-box { margin-top: 12px; padding: 12px 14px; border: 1px dashed var(--line-strong); border-radius: var(--radius-m); }

/* Mídia nas conversas */
.bubble.has-media { padding: 6px; }
.bubble.has-media .b-text { display: block; padding: 4px 6px 0; }
.bubble.has-media .b-meta { padding: 0 6px; }

.b-img {
  display: block;
  max-width: min(320px, 100%);
  max-height: 320px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--code-bg);
}

.b-img.b-sticker { max-width: 160px; background: transparent; }

.b-audio { display: block; width: 280px; max-width: 100%; height: 40px; }
.b-video { display: block; max-width: min(320px, 100%); max-height: 320px; border-radius: 8px; background: #000; }
.b-doc { display: inline-block; padding: 6px; }
.b-missing { display: block; color: var(--muted); font-size: 13px; padding: 6px; font-style: italic; }

.b-transcript {
  margin: 6px 4px 0;
  padding: 8px 10px;
  border-left: 3px solid var(--accent);
  background: var(--code-bg);
  border-radius: 0 6px 6px 0;
  font-size: 14px;
}

.b-transcript > span { display: block; font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 2px; }
.b-transcript.pending { color: var(--muted); font-style: italic; }
.b-tr-btn { margin: 6px 4px 0; }

.attach-btn { padding: 8px; cursor: pointer; }
.attach-btn svg { width: 20px; height: 20px; }

.attach-chip {
  display: flex;
  align-items: center;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding: 10px 12px;
  background: var(--surface-2);
}

.attach-chip img { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; }
.attach-kind { font-size: 12px; font-weight: 700; padding: 6px 8px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); }
.attach-name { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.attach-name strong { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-name span { color: var(--muted); font-size: 12px; }

.chat-view.drop { box-shadow: inset 0 0 0 2px var(--accent); }

@media (max-width: 760px) {
  .engine-pick { grid-template-columns: 1fr; }
  .model-row { grid-template-columns: 1fr auto; }
  .model-row .model-state { grid-column: 1; }
}

/* ---------- v1.1.1: gravação de áudio ---------- */

.mic-btn { padding: 8px; }
.mic-btn svg { width: 20px; height: 20px; }
.mic-btn:hover { color: var(--accent); }

.rec-bar {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 6px 0 12px;
  min-height: 40px;
  border: 1px solid color-mix(in srgb, var(--bad) 45%, var(--line));
  background: var(--bad-soft);
  border-radius: var(--radius-s);
  min-width: 0;
}

.rec-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--bad);
  flex: none;
  animation: blink 1.1s ease-in-out infinite;
}

.rec-time { font-family: var(--mono); font-size: 15px; font-weight: 600; min-width: 44px; }

.rec-level {
  flex: 1;
  height: 6px;
  border-radius: 6px;
  background: var(--line);
  overflow: hidden;
  min-width: 40px;
}

.rec-level > span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--bad);
  border-radius: 6px;
  transition: width 0.12s linear;
}

/* ---------- v1.1.2: nova conversa ---------- */

.chat-side {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  min-height: 0;
  max-height: 620px;
}

.chat-side .chat-list { border-right: 0; flex: 1; max-height: none; }

.chat-tools {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border-bottom: 1px solid var(--line);
}

.chat-tools .input { padding: 7px 10px; font-size: 14px; }
.chat-tools .btn { justify-content: center; }

.chat-item.draft strong::after {
  content: "Nova";
  margin-left: 8px;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 50%, var(--line));
  border-radius: 10px;
  padding: 0 6px;
  vertical-align: 1px;
}

.chat-empty { padding: 18px 14px; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.chat-empty p { margin: 0; }

.chat-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.ch-head-text { display: flex; flex-direction: column; min-width: 0; }
.ch-head-text strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-head-text span { color: var(--muted); font-size: 13px; }

.ch-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  flex: none;
  background: var(--surface);
}

.ch-avatar-empty {
  display: grid;
  place-items: center;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--line));
}

.chat-start { margin: auto; text-align: center; display: flex; flex-direction: column; gap: 4px; max-width: 40ch; }
.chat-start span { color: var(--muted); font-size: 14px; }

.nc-result { min-height: 64px; margin-bottom: 8px; }

.nc-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid color-mix(in srgb, var(--ok) 45%, var(--line));
  background: var(--ok-soft);
  border-radius: var(--radius-m);
}

.nc-card .ch-avatar { width: 46px; height: 46px; }
.nc-card > span:last-child { display: flex; flex-direction: column; min-width: 0; }
.nc-card strong { font-weight: 600; }
.nc-card span span { font-size: 13px; }
.nc-card .mono:empty { display: none; }
.nc-missing { border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); background: var(--bad-soft); }
.nc-missing span span { color: var(--muted); }

@media (max-width: 900px) {
  .chat-side { border-right: 0; border-bottom: 1px solid var(--line); max-height: 320px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
