/* ==========================================================================
   OmniChat — Design tokens
   Direção: console de roteamento — várias "linhas" (modelos) convergindo
   numa única conversa. Tipografia técnica, acentos de sinal/canal.
   ========================================================================== */

:root {
  /* cor — tema escuro (padrão) */
  --bg: #12141a;
  --surface: #1a1d24;
  --surface-2: #21252e;
  --surface-3: #2a2f3a;
  --border: #2b303b;
  --text: #e8eaef;
  --text-muted: #8b93a6;
  --text-faint: #5b6272;
  --accent: #4fd8c4;
  --accent-strong: #6ee9d6;
  --accent-ink: #08211d;
  --live: #f2a93b;
  --danger: #e5637a;
  --danger-ink: #2a1015;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.35);

  /* tipografia */
  --font-display: 'Space Grotesk', 'Inter', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;

  --sidebar-w: 280px;
  --radius: 10px;
  --radius-sm: 7px;
  --radius-pill: 999px;
}

[data-theme='light'] {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f0f1f4;
  --surface-3: #e6e8ec;
  --border: #dfe2e8;
  --text: #171a21;
  --text-muted: #656d7d;
  --text-faint: #9aa1b0;
  --accent: #0f9c88;
  --accent-strong: #0c8674;
  --accent-ink: #e3f7f3;
  --live: #b96e0c;
  --danger: #c93a55;
  --danger-ink: #fbe8ec;
  --shadow: 0 12px 32px rgba(20, 24, 34, 0.12);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
button { font-family: inherit; }
::selection { background: var(--accent); color: var(--accent-ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* CRÍTICO: o atributo `hidden` precisa sempre vencer, mesmo sobre classes
   que definem `display` (ex.: .modal-overlay, .profile-form, .icon-btn
   usam display:flex/inline-flex). Sem isso, um elemento com `hidden` E uma
   dessas classes continua visível — [hidden] e uma classe têm a mesma
   especificidade CSS (0,1,0), e regra de autor sempre vence a do
   navegador em empate. Foi exatamente esse bug que deixava a tela de
   login/criar-conta sempre aberta com os dois formulários juntos. */
[hidden] { display: none !important; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ==========================================================================
   Layout
   ========================================================================== */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100dvh;
  overflow: hidden;
  transition: grid-template-columns .18s ease;
}

/* Recolher a sidebar em telas largas (desktop) — em telas estreitas isso é
   tratado à parte, como overlay (ver bloco Responsivo mais abaixo). */
@media (min-width: 861px) {
  .app.sidebar-collapsed { grid-template-columns: 0 1fr; }
  .app.sidebar-collapsed .sidebar { overflow: hidden; padding-left: 0; padding-right: 0; border-right: none; }
  .app.sidebar-collapsed .sidebar > * { opacity: 0; pointer-events: none; }
  .app.sidebar-collapsed .topbar__menu { display: inline-flex; }
}

/* ==========================================================================
   Sidebar
   ========================================================================== */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 14px 12px 12px;
}
.sidebar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 4px 14px;
}
.brand { display: flex; align-items: center; gap: 9px; color: var(--text); }
.brand__mark { color: var(--accent); display: flex; }
.brand__name {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 17px;
  letter-spacing: -0.01em;
}
.brand__name b { font-weight: 700; }
.pulse-dot { animation: pulse-dot 1.8s ease-in-out infinite; transform-origin: center; }
@keyframes pulse-dot {
  0%, 100% { opacity: .55; transform: scale(.85); }
  50% { opacity: 1; transform: scale(1); }
}
.sidebar__close { display: none; }

.btn-new-chat {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.btn-new-chat:hover { border-color: var(--accent); color: var(--accent-strong); }
.btn-new-chat svg { flex-shrink: 0; }

.sidebar__label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.sidebar__label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 18px 6px 6px;
}
.sidebar__new-folder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px; height: 26px;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--text-faint);
  cursor: pointer;
}
.sidebar__new-folder:hover { background: var(--surface-2); color: var(--accent-strong); }

.chat-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 0;
}
.chat-list__empty {
  color: var(--text-faint);
  font-size: 12.5px;
  text-align: center;
  margin: 18px 10px;
  line-height: 1.6;
}
.chat-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 9px 10px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
  transition: background .12s, color .12s;
}
.chat-item:hover { background: var(--surface-2); color: var(--text); }
.chat-item.is-active { background: var(--surface-2); color: var(--text); }
.chat-item.is-active::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: var(--radius-pill);
  background: var(--accent);
}
.chat-item__dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-faint);
  flex-shrink: 0;
}
.chat-item__title {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-item__delete {
  display: none;
  padding: 4px;
  border-radius: 6px;
  color: var(--text-faint);
  flex-shrink: 0;
}
.chat-item:hover .chat-item__delete { display: flex; }
.chat-item__delete:hover { color: var(--danger); background: var(--danger-ink); }

.chat-item__pin {
  display: none;
  padding: 4px;
  border-radius: 6px;
  color: var(--text-faint);
  flex-shrink: 0;
}
.chat-item:hover .chat-item__pin { display: flex; }
.chat-item__pin:hover { color: var(--accent-strong); background: var(--surface-3); }
.chat-item.is-pinned .chat-item__pin { display: flex; color: var(--accent); }

.chat-item__move {
  display: none;
  padding: 4px;
  border-radius: 6px;
  color: var(--text-faint);
  flex-shrink: 0;
}
.chat-item:hover .chat-item__move { display: flex; }
.chat-item__move:hover { color: var(--accent-strong); background: var(--surface-3); }

.chat-item.is-dragging { opacity: .4; }

/* ------------------------------- Pastas ------------------------------- */
.folder-header {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 4px 2px 2px;
  border-radius: var(--radius-sm);
  margin-top: 10px;
}
.folder-header:first-child { margin-top: 0; }
.folder-header.is-drop-target {
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  outline: 1px dashed var(--accent);
}
.folder-header__toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
  padding: 5px 4px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
}
.folder-header__toggle:hover { color: var(--text); }
.folder-header__chevron { flex-shrink: 0; transition: transform .12s; color: var(--text-faint); }
.folder-header.is-collapsed .folder-header__chevron { transform: rotate(-90deg); }
.folder-header__icon { flex-shrink: 0; color: var(--text-faint); }
.folder-header__name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.folder-header__count {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-faint);
  flex-shrink: 0;
}
.folder-header__actions {
  display: none;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}
.folder-header:hover .folder-header__actions { display: flex; }
.folder-header__rename, .folder-header__delete {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px; height: 20px;
  background: transparent;
  border: none;
  border-radius: 5px;
  color: var(--text-faint);
  cursor: pointer;
}
.folder-header__rename:hover { color: var(--accent-strong); background: var(--surface-3); }
.folder-header__delete:hover { color: var(--danger); background: var(--danger-ink); }
.folder-header__rename-input {
  flex: 1;
  min-width: 0;
  padding: 4px 6px;
  background: var(--surface-2);
  border: 1px solid var(--accent);
  border-radius: 5px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 11px;
}
.folder-header__rename-input:focus { outline: none; }
.folder-group__items { display: flex; flex-direction: column; gap: 2px; }
.folder-group__empty {
  padding: 4px 10px 6px 30px;
  font-size: 11.5px;
  color: var(--text-faint);
  font-style: italic;
}

.folder-menu {
  position: fixed;
  z-index: 60;
  min-width: 180px;
  max-height: 260px;
  overflow-y: auto;
  list-style: none;
  padding: 6px;
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.folder-menu ul { list-style: none; margin: 0; padding: 0; }
.folder-menu__item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 9px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 12.5px;
  text-align: left;
  cursor: pointer;
}
.folder-menu__item:hover { background: var(--surface-2); }
.folder-menu__item.is-current { color: var(--accent-strong); }
.folder-menu__empty { padding: 10px; color: var(--text-faint); font-size: 12px; text-align: center; }

.sidebar__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 6px 2px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}
.conn-status {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-faint);
}
.conn-status__dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-faint);
  box-shadow: 0 0 0 3px transparent;
  transition: background .2s, box-shadow .2s;
}
.conn-status--ok .conn-status__dot { background: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
.conn-status--error .conn-status__dot { background: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 20%, transparent); }

.icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: background .12s, color .12s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

.instructions-dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--bg);
}

.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(10, 11, 14, .55);
  z-index: 30;
}

/* ==========================================================================
   Main / topbar
   ========================================================================== */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.topbar__menu { display: none; }
.topbar__delete { margin-left: auto; }

/* modelo — dropdown customizado (canal de roteamento) */
.model-select { position: relative; }
.model-select__btn {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 11px 7px 9px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  color: var(--text);
  font-family: var(--font-display);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color .15s;
}
.model-select__btn:hover { border-color: var(--accent); }
.model-select__chevron { color: var(--text-faint); margin-left: 2px; }
.model-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-faint);
  flex-shrink: 0;
}
.model-select__menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 20;
  list-style: none;
  margin: 0;
  padding: 6px;
  min-width: 260px;
  max-height: 340px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.model-select__empty {
  padding: 14px 10px;
  color: var(--text-faint);
  font-size: 12.5px;
  text-align: center;
  line-height: 1.6;
}
.model-option {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 9px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
.model-option:hover { background: var(--surface-2); }
.model-option.is-selected { background: var(--surface-2); color: var(--accent-strong); }
.model-option__name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-option__provider {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-faint);
}

/* ==========================================================================
   Mensagens — log de transmissão (não bolhas)
   ========================================================================== */
.messages {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}
.empty-state {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 24px;
  color: var(--text-muted);
}
.empty-state__mark { color: var(--accent); margin-bottom: 14px; opacity: .9; }
.empty-state h1 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  margin: 0 0 8px;
  color: var(--text);
}
.empty-state p { max-width: 360px; margin: 0; font-size: 13.5px; color: var(--text-faint); }

.message-log {
  max-width: 820px;
  margin: 0 auto;
  padding: 20px 20px 30px;
}
.msg {
  display: flex;
  gap: 14px;
  padding: 16px 0;
}
.msg__rule {
  width: 3px;
  border-radius: var(--radius-pill);
  flex-shrink: 0;
  background: var(--border);
  margin-top: 3px;
}
.msg[data-role='assistant'] .msg__rule { background: var(--accent); }
.msg[data-role='user'] .msg__rule { background: var(--text-faint); opacity: .5; }
.msg__body { flex: 1; min-width: 0; }
.msg__meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 6px;
  font-family: var(--font-mono);
}
.msg__author {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 500;
  color: var(--text-muted);
}
.msg[data-role='assistant'] .msg__author { color: var(--accent-strong); }
.msg__model { font-size: 11px; color: var(--text-faint); }
.msg__time { font-size: 11px; color: var(--text-faint); margin-left: auto; }
.msg__content { font-size: 14.5px; color: var(--text); word-wrap: break-word; }
.msg__content p:first-child { margin-top: 0; }
.msg__content p:last-child { margin-bottom: 0; }
.msg__content.is-streaming::after {
  content: '';
  display: inline-block;
  width: 7px; height: 14px;
  margin-left: 2px;
  background: var(--live);
  vertical-align: text-bottom;
  animation: caret-blink 1s step-end infinite;
}
@keyframes caret-blink { 50% { opacity: 0; } }

.msg__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
}
.msg__actions {
  display: flex;
  gap: 6px;
  opacity: 0;
  transition: opacity .12s;
}
.msg:hover .msg__actions, .msg__actions.is-visible { opacity: 1; }
.msg__action {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 9px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 11.5px;
  cursor: pointer;
  transition: border-color .12s, color .12s;
}
.msg__action:hover { border-color: var(--accent); color: var(--accent-strong); }

.msg__version-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  flex-shrink: 0;
}
.msg__version-nav button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px; height: 22px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
}
.msg__version-nav button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent-strong); }
.msg__version-nav button:disabled { opacity: .35; cursor: default; }
.msg__version-label { min-width: 28px; text-align: center; }

.msg__edit-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}
.msg__edit-textarea {
  width: 100%;
  min-height: 60px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14.5px;
  line-height: 1.5;
  resize: vertical;
}
.msg__edit-textarea:focus { outline: none; }
.msg__edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.msg__edit-actions .btn-primary,
.msg__edit-actions .btn-secondary {
  padding: 6px 12px;
  font-size: 12.5px;
}

/* ==========================================================================
   Composer
   ========================================================================== */
.composer {
  flex-shrink: 0;
  padding: 12px 20px calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: var(--bg);
}
.composer__box {
  max-width: 820px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 8px 8px 8px 16px;
  transition: border-color .15s;
}
.composer__box:focus-within { border-color: var(--accent); }
.composer__input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14.5px;
  line-height: 1.5;
  resize: none;
  max-height: 200px;
  padding: 7px 0;
}
.composer__input:focus { outline: none; }
.composer__input::placeholder { color: var(--text-faint); }
.composer__send {
  flex-shrink: 0;
  width: 36px; height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
  transition: opacity .12s, transform .12s;
}
.composer__send:hover { transform: scale(1.05); }
.composer__send:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.composer__send.is-stop { background: var(--danger); color: #2a0d13; }
.composer__hint {
  max-width: 820px;
  margin: 7px auto 0;
  text-align: center;
  font-size: 11px;
  color: var(--text-faint);
  font-family: var(--font-mono);
}

/* ==========================================================================
   Toast
   ========================================================================== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 16px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  box-shadow: var(--shadow);
  z-index: 100;
  animation: toast-in .18s ease-out;
}
@keyframes toast-in { from { opacity: 0; transform: translateX(-50%) translateY(8px); } }

/* ==========================================================================
   Modal — configurações
   ========================================================================== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(8, 9, 12, .6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}
.modal {
  width: 100%;
  max-width: 440px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.modal__header h2 {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  margin: 0;
}
.modal__body { padding: 18px; display: flex; flex-direction: column; gap: 16px; }

/* ==========================================================================
   Paleta de comandos (Ctrl/⌘+K)
   ========================================================================== */
.palette-overlay { align-items: flex-start; padding-top: 12vh; }
.palette {
  width: 100%;
  max-width: 560px;
  max-height: 60vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.palette__input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.palette__search-icon { color: var(--text-faint); flex-shrink: 0; }
.palette__input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
}
.palette__input:focus { outline: none; }
.palette__input::placeholder { color: var(--text-faint); }
.palette__esc {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-faint);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 2px 6px;
  flex-shrink: 0;
}
.palette__list {
  list-style: none;
  margin: 0;
  padding: 6px;
  overflow-y: auto;
}
.palette__empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--text-faint);
  font-size: 13px;
  margin: 0;
}
.palette__group-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 10px 10px 4px;
}
.palette__item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
}
.palette__item-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px; height: 22px;
  color: var(--text-faint);
  flex-shrink: 0;
}
.palette__item-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette__item-hint {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  flex-shrink: 0;
}
.palette__item.is-active { background: var(--surface-2); }
.palette__item.is-active .palette__item-icon { color: var(--accent-strong); }
.palette__item:hover { background: var(--surface-2); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-size: 12.5px; font-weight: 600; color: var(--text-muted); }
.field__hint { font-size: 11px; color: var(--text-faint); }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 9px 11px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
}
.field select, .field textarea { font-family: var(--font-body); }
.field textarea { resize: vertical; line-height: 1.5; }

.model-checklist {
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  padding: 4px;
}
.model-checklist__item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 6px;
  cursor: pointer;
}
.model-checklist__item:hover { background: var(--surface-3); }
.model-checklist__item input { width: auto; padding: 0; accent-color: var(--accent); }
.model-checklist__item span { font-size: 12.5px; font-family: var(--font-mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-checklist__empty { padding: 10px 8px; color: var(--text-faint); font-size: 12px; text-align: center; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); outline: none; }
.field__input-group { position: relative; display: flex; }
.field__input-group input { padding-right: 38px; }
.field__toggle {
  position: absolute;
  right: 4px; top: 4px; bottom: 4px;
  width: 32px;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: none;
  color: var(--text-faint);
  cursor: pointer;
  border-radius: 6px;
}
.field__toggle:hover { color: var(--text); }

.theme-toggle { display: flex; gap: 8px; }
.theme-toggle__opt {
  flex: 1;
  padding: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 12.5px;
  cursor: pointer;
}
.theme-toggle__opt.is-active { border-color: var(--accent); color: var(--accent-strong); background: color-mix(in srgb, var(--accent) 10%, var(--surface-2)); }

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

.two-factor-section {
  border-top: 1px solid var(--border);
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.two-factor-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.two-factor-status .field__hint { margin: 0; flex: 1; }
.two-factor-setup,
.two-factor-disable {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
}
.two-factor-secret {
  font-family: var(--font-mono);
  font-size: 14px;
  letter-spacing: 0.06em;
  word-break: break-all;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--accent-strong);
}
.modal__status { font-size: 12px; color: var(--text-faint); font-family: var(--font-mono); }
.modal__status.is-ok { color: var(--accent-strong); }
.modal__status.is-error { color: var(--danger); }

.modal__footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }
.btn-primary, .btn-secondary {
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 13.5px;
  cursor: pointer;
  border: 1px solid transparent;
}
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-strong); }
.btn-secondary { background: transparent; border-color: var(--border); color: var(--text-muted); }
.btn-secondary:hover { color: var(--text); border-color: var(--text-faint); }
.btn-danger { background: transparent; border-color: var(--border); color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); background: var(--danger-ink); }

/* ==========================================================================
   Responsivo
   ========================================================================== */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    inset: 0 30% 0 0;
    z-index: 40;
    max-width: 320px;
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: var(--shadow);
  }
  .app.sidebar-open .sidebar { transform: translateX(0); }
  .app.sidebar-open .sidebar-overlay { display: block; }
  .sidebar__close { display: inline-flex; }
  .topbar__menu { display: inline-flex; }
  .message-log { padding: 14px 14px 24px; }
  .composer { padding: 10px 12px calc(12px + env(safe-area-inset-bottom)); }
  .model-select__btn .model-select__name { max-width: 42vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* ==========================================================================
   V4 — Tela de login / criar conta (conta real, persistida no servidor)
   ========================================================================== */
.profile-screen {
  position: fixed; inset: 0;
  z-index: 200;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.profile-screen__card {
  width: 100%;
  max-width: 380px;
  text-align: center;
}
.profile-screen__brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  color: var(--accent);
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 16px;
  margin-bottom: 30px;
}
.profile-screen__brand span { color: var(--text); }
.profile-screen__brand b { font-weight: 700; }
.profile-screen h1 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 6px;
}
.profile-screen__hint { color: var(--text-faint); font-size: 12.5px; margin: 0 0 20px; }

.auth-tabs {
  display: flex;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 4px;
  margin-bottom: 22px;
}
.auth-tab {
  flex: 1;
  padding: 8px;
  background: transparent;
  border: none;
  border-radius: var(--radius-pill);
  color: var(--text-muted);
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 13px;
  cursor: pointer;
}
.auth-tab.is-active { background: var(--surface); color: var(--accent-strong); box-shadow: 0 1px 0 var(--border); }

/* Quando o autocadastro está desativado, só a aba "Entrar" existe — tira a
   aparência de seletor (fundo/borda da pílula) pra não parecer um controle
   quebrado com uma opção só. */
.auth-tabs--single {
  background: transparent;
  border: none;
  padding: 0;
}
.auth-tabs--single .auth-tab.is-active {
  background: transparent;
  box-shadow: none;
  cursor: default;
}

.profile-form { text-align: left; display: flex; flex-direction: column; gap: 16px; }
.profile-form h1 { text-align: center; }
.field__hint.is-error { color: var(--danger); }
.auth-error {
  background: var(--danger-ink);
  color: var(--danger);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 12.5px;
  text-align: left;
}

.profile-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  min-width: 0;
}
.profile-chip__avatar {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--accent-strong);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-size: 10.5px;
  font-weight: 600;
  flex-shrink: 0;
}
.profile-chip__name {
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 110px;
}

/* ==========================================================================
   V2 — Busca na sidebar
   ========================================================================== */
.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 4px 2px;
  padding: 7px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-faint);
}
.search-box:focus-within { border-color: var(--accent); color: var(--text-muted); }
.search-box input {
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  width: 100%;
}
.search-box input:focus { outline: none; }
.search-box input::-webkit-search-cancel-button { display: none; }

.chat-item__text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.chat-item__snippet {
  font-size: 11px;
  color: var(--text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar__tools { margin: 10px 2px 0; }
.text-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  padding: 7px 8px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-faint);
  font-size: 12px;
  cursor: pointer;
}
.text-btn:hover { background: var(--surface-2); color: var(--text-muted); }

.sidebar__footer-actions { display: flex; align-items: center; gap: 2px; }

/* ==========================================================================
   V2 — Topbar: exportar / compartilhar
   ========================================================================== */
.topbar__actions { display: flex; align-items: center; gap: 2px; margin-left: auto; }
.export-menu { position: relative; }
.export-menu__list {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 20;
  list-style: none;
  margin: 0;
  padding: 6px;
  min-width: 160px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.export-menu__list button {
  width: 100%;
  text-align: left;
  padding: 8px 9px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}
.export-menu__list button:hover { background: var(--surface-2); }

/* ==========================================================================
   V2 — Mensagens: chip de modelo, estatísticas, anexos
   ========================================================================== */
.msg__model-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-faint);
}
.msg__stats { font-size: 11px; color: var(--text-faint); }
.msg__stats::before { content: '·'; margin-right: 8px; }
.msg__model-chip + .msg__stats::before { content: none; }

.msg__attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}
.msg__attachments:empty { display: none; margin: 0; }
.msg-attachment--image {
  max-width: 220px;
  max-height: 220px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  object-fit: cover;
}
.msg-attachment--pdf {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: 12px;
  color: var(--text-muted);
}

/* ==========================================================================
   V2 — Composer: anexos
   ========================================================================== */
.composer__attach {
  flex-shrink: 0;
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  background: transparent;
  border: none;
  border-radius: 50%;
  color: var(--text-faint);
  cursor: pointer;
  margin-bottom: 1px;
}
.composer__attach:hover { background: var(--surface-3); color: var(--text); }

.attachment-chips {
  max-width: 820px;
  margin: 0 auto 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px 5px 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: 12px;
  color: var(--text-muted);
}
.chip__thumb { width: 22px; height: 22px; border-radius: 5px; object-fit: cover; }
.chip__icon { display: flex; color: var(--text-faint); }
.chip__name { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip__remove {
  display: flex; align-items: center; justify-content: center;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--surface-3);
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  flex-shrink: 0;
}
.chip__remove:hover { color: var(--danger); }

/* ==========================================================================
   V3 — Switch (toggle) e campos em linha
   ========================================================================== */
.field--row {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.field--row .field__label { display: block; }
.field--row .field__hint { display: block; margin-top: 2px; }

.switch { position: relative; display: inline-block; width: 38px; height: 22px; flex-shrink: 0; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch__track {
  position: absolute; inset: 0;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  transition: background .15s;
}
.switch__track::before {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--text-faint);
  transition: transform .15s, background .15s;
}
.switch input:checked + .switch__track { background: color-mix(in srgb, var(--accent) 25%, var(--surface-3)); border-color: var(--accent); }
.switch input:checked + .switch__track::before { transform: translateX(16px); background: var(--accent); }

/* ==========================================================================
   V3 — Atalhos de teclado
   ========================================================================== */
.shortcut-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.shortcut-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.shortcut-item span { font-size: 13px; color: var(--text-muted); }
.shortcut-item kbd {
  font-family: var(--font-mono);
  font-size: 11.5px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: 3px 8px;
  color: var(--text);
  white-space: nowrap;
}

/* profile-chip__name já trata overflow via max-width fixo (110px) em telas pequenas */
