/* ═══════════════════════════════════════════════════════════════════════
   GROWTH CREATIVE STUDIO · LAYOUT
   Inspiração: Claude Projects (Cowork). Light theme, 3 painéis.
   ═══════════════════════════════════════════════════════════════════════ */

[x-cloak] { display: none !important; }
html, body { height: 100%; }
body { background: var(--bg); }

button { font-family: inherit; }

/* ─── LAYOUT BASE (3 painéis) ─────────────────────────────────────── */

.layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 340px;
  min-height: 100vh;
  background: var(--bg);
}

/* ─── LEFT SIDEBAR (dark) ─────────────────────────────────────────── */

.lsb {
  background: var(--sidebar-bg);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow: hidden;
}

.lsb-logo {
  padding: 18px 20px 16px 20px;
  border-bottom: 1px solid var(--sidebar-border);
}
.lsb-logo img {
  width: 100%; max-width: 180px; height: auto; display: block;
}

.lsb-scroll {
  flex: 1; overflow-y: auto; padding: 12px 10px 14px 10px;
}

.lsb-section { margin-bottom: 12px; }

.lsb-section-hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 12px 6px 12px;
}
.lsb-section-hdr span {
  font-family: var(--mono); font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1.2px;
  color: var(--sidebar-muted);
}

.lsb-list { list-style: none; display: flex; flex-direction: column; gap: 1px; }

.lsb-item {
  position: relative;
  width: 100%;
  display: flex; align-items: center; gap: 9px;
  padding: 7px 10px 7px 12px;
  background: transparent;
  border: none; border-radius: 6px;
  font-family: var(--font); font-size: 13px; font-weight: 500;
  color: var(--sidebar-text);
  cursor: pointer; text-align: left;
  transition: background .12s, color .12s;
  min-height: 32px;
}
.lsb-item:hover { background: rgba(255,255,255,0.05); color: #fff; }
.lsb-item.active {
  background: var(--accent);
  color: #fff;
}
.lsb-item.active .lsb-item-icon { color: #fff; }

.lsb-item-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px;
  color: var(--sidebar-muted);
  flex-shrink: 0;
}
.lsb-item-icon svg { width: 14px; height: 14px; }
.lsb-item:hover .lsb-item-icon { color: #fff; }

.lsb-item-name { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

.lsb-item .count {
  font-family: var(--mono); font-size: 10px; font-weight: 600;
  color: var(--sidebar-muted);
  background: rgba(255,255,255,0.06);
  padding: 1px 7px; border-radius: 9px;
  letter-spacing: .3px;
}
.lsb-item.active .count { background: rgba(255,255,255,0.18); color: #fff; }
.lsb-item:hover:not(.active) .count { color: #fff; background: rgba(255,255,255,0.1); }

/* Pin indicator (icon ao lado do nome) — visível quando pinned */
.lsb-pin-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 12px; height: 12px;
  color: var(--accent);
  flex-shrink: 0;
}
.lsb-item.active .lsb-pin-mark { color: #fff; }
.lsb-pin-mark svg { width: 11px; height: 11px; }

/* 3-dots menu button */
.lsb-menu-btn {
  display: none;
  align-items: center; justify-content: center;
  width: 22px; height: 22px;
  background: transparent; border: none;
  color: var(--sidebar-muted);
  border-radius: 4px;
  cursor: pointer;
  transition: all .12s;
  flex-shrink: 0;
}
.lsb-menu-btn svg { width: 13px; height: 13px; }
.lsb-menu-btn:hover { background: rgba(255,255,255,0.1); color: #fff; }
.lsb-item:hover .lsb-menu-btn,
.lsb-item.menu-open .lsb-menu-btn { display: inline-flex; }
.lsb-item.active .lsb-menu-btn { color: rgba(255,255,255,0.85); }
.lsb-item.active .lsb-menu-btn:hover { background: rgba(255,255,255,0.18); color: #fff; }

/* Popover menu */
.popover-menu {
  position: fixed;
  z-index: 300;
  min-width: 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
  box-shadow: 0 8px 28px rgba(0,0,0,.12);
  padding: 5px;
  font-family: var(--font);
}
.popover-item {
  display: flex; align-items: center; gap: 9px;
  width: 100%;
  padding: 8px 10px;
  background: transparent; border: none; border-radius: 6px;
  font-size: 13px; color: var(--ink);
  text-align: left; cursor: pointer;
  transition: background .1s;
}
.popover-item:hover { background: var(--s2); }
.popover-item.danger { color: var(--red); }
.popover-item.danger:hover { background: var(--red-bg); }
.popover-item .pi-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px;
  flex-shrink: 0;
  color: var(--muted2);
}
.popover-item.danger .pi-icon { color: var(--red); }
.popover-item .pi-icon svg { width: 15px; height: 15px; }
.popover-sep { height: 1px; background: var(--border); margin: 4px 6px; }

.lsb-section-add {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  background: transparent; border: none;
  color: var(--sidebar-muted);
  border-radius: 5px;
  cursor: pointer;
  transition: all .12s;
}
.lsb-section-add svg { width: 13px; height: 13px; }
.lsb-section-add:hover { background: rgba(255,255,255,0.08); color: #fff; }

.lsb-empty {
  padding: 6px 12px;
  font-size: 11.5px; color: var(--sidebar-muted); font-style: italic;
}

/* Pesquisa de conversas */
.lsb-search {
  position: relative;
  padding: 0 10px;
  margin-bottom: 6px;
}
.lsb-search-icon {
  position: absolute;
  left: 19px; top: 50%; transform: translateY(-50%);
  width: 12px; height: 12px;
  color: var(--sidebar-muted);
  pointer-events: none;
}
.lsb-search input {
  width: 100%;
  padding: 6px 9px 6px 27px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 6px;
  color: #fff;
  font-family: var(--font); font-size: 12.5px;
  outline: none;
  transition: all .12s;
}
.lsb-search input::placeholder { color: var(--sidebar-muted); }
.lsb-search input:focus {
  background: rgba(255,255,255,0.09);
  border-color: var(--accent);
}

/* Toggle arquivadas */
.lsb-archived-toggle {
  display: flex; align-items: center; gap: 8px;
  width: calc(100% - 16px);
  margin: 8px 8px 4px 8px;
  padding: 7px 10px;
  background: transparent;
  border: 1px dashed rgba(255,255,255,0.1);
  border-radius: 6px;
  font-family: var(--mono); font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .8px;
  color: var(--sidebar-muted);
  cursor: pointer;
  transition: all .12s;
}
.lsb-archived-toggle:hover { color: #fff; border-color: rgba(255,255,255,0.2); }
.lsb-archived-toggle svg { width: 12px; height: 12px; }
.lsb-archived-toggle .count {
  margin-left: auto;
  font-family: var(--mono); font-size: 9px;
  background: rgba(255,255,255,0.08);
  padding: 1px 6px; border-radius: 9px;
}

.lsb-archived-list .lsb-item {
  opacity: 0.55;
}
.lsb-archived-list .lsb-item:hover { opacity: 1; }
.lsb-archived-restore {
  font-family: var(--mono); font-size: 13px;
  color: var(--accent);
  margin-left: 4px;
  flex-shrink: 0;
}

.lsb-foot {
  padding: 10px 20px;
  border-top: 1px solid var(--sidebar-border);
  font-family: var(--mono); font-size: 10px;
  color: var(--sidebar-muted);
  letter-spacing: .5px; text-transform: uppercase;
}

/* dark scrollbar para lsb-scroll */
.lsb-scroll::-webkit-scrollbar { width: 6px; }
.lsb-scroll::-webkit-scrollbar-track { background: transparent; }
.lsb-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 3px; }
.lsb-scroll::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.15); }

/* icon-btn fora da sidebar (right side cards, header) */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  background: transparent; border: none;
  color: var(--muted); cursor: pointer;
  border-radius: 5px;
  transition: background .12s, color .12s;
}
.icon-btn:hover { background: var(--s3); color: var(--ink); }
.icon-btn svg { width: 13px; height: 13px; }
.icon-btn.active { color: var(--accent); }

/* ─── CENTER ──────────────────────────────────────────────────────── */

.center {
  display: flex; flex-direction: column;
  min-width: 0; min-height: 100vh;
  background: var(--bg);
}

/* Empty state — sem projecto activo */
.empty-state {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  padding: 40px;
}
.empty-state-inner { text-align: center; max-width: 380px; }
.empty-state-bars { display: flex; align-items: flex-end; gap: 5px; justify-content: center; margin-bottom: 18px; height: 38px; }
.empty-state-bars span { width: 8px; background: var(--accent); border-radius: 3px; display: block; }
.empty-state h2 { font-family: var(--brand); font-size: 28px; color: var(--ink); margin-bottom: 10px; letter-spacing: -.3px; }
.empty-state p { font-size: 14px; color: var(--muted2); line-height: 1.6; }

/* ─── PROJECT HOME (project active, no conversation) ─────────────── */

.ph {
  flex: 1;
  display: flex; flex-direction: column;
  padding: 36px 48px 28px 48px;
  max-width: 880px; margin: 0 auto; width: 100%;
}

.ph-hdr {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 22px;
}
.ph-title {
  font-family: var(--brand);
  font-size: 36px; font-weight: 400; color: var(--ink);
  letter-spacing: -.5px; line-height: 1.1;
  margin: 0;
  padding: 2px 6px;
  border-radius: 6px;
  transition: background .12s;
}
.ph-title:hover { background: var(--s2); }
.ph-title-input {
  flex: 1;
  font-family: var(--brand);
  font-size: 36px; font-weight: 400; color: var(--ink);
  letter-spacing: -.5px; line-height: 1.1;
  padding: 2px 6px;
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 6px;
  box-shadow: 0 0 0 3px var(--accent-bg);
  outline: none;
  width: 100%;
}
.ph-actions { display: flex; gap: 4px; }
.ph-actions .icon-btn { width: 32px; height: 32px; }
.ph-actions .icon-btn svg { width: 16px; height: 16px; }

.ph-empty {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
  padding: 60px 20px;
  color: var(--muted2);
}
.ph-empty-icon {
  width: 36px; height: 36px;
  margin-bottom: 14px;
  color: var(--mute);
  stroke: var(--accent);
}
.ph-empty p { font-size: 13px; max-width: 320px; line-height: 1.55; }

/* Recent chats list (project home) */
.recent-chats { margin-top: 30px; }
.recent-chats-hdr {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px;
}
.recent-chats-list {
  display: flex; flex-direction: column;
  gap: 6px;
  list-style: none;
}
.recent-chat {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
  cursor: pointer;
  transition: all .12s;
  text-align: left;
}
.recent-chat:hover { border-color: var(--border2); background: var(--s2); }
.recent-chat-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  background: var(--accent-bg); color: var(--accent);
  border-radius: 8px;
  flex-shrink: 0;
}
.recent-chat-icon svg { width: 16px; height: 16px; }
.recent-chat-main { flex: 1; min-width: 0; }
.recent-chat-title {
  font-size: 13.5px; font-weight: 600; color: var(--ink);
  display: flex; align-items: center; gap: 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.recent-chat-pin {
  display: inline-flex; color: var(--accent);
  flex-shrink: 0;
}
.recent-chat-pin svg { width: 11px; height: 11px; }
.recent-chat-meta {
  font-family: var(--mono); font-size: 10.5px;
  color: var(--muted); margin-top: 3px;
  text-transform: uppercase; letter-spacing: .3px;
}
.recent-chat-snippet {
  font-size: 12.5px;
  color: var(--muted2);
  margin-top: 4px;
  line-height: 1.4;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
}

/* ─── COMPOSER PROMINENT ──────────────────────────────────────────── */

.composer-prominent {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  transition: border-color .12s, box-shadow .12s;
}
.composer-prominent:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}

.composer-prominent textarea {
  width: 100%;
  min-height: 56px;
  max-height: 240px;
  border: none; background: transparent;
  resize: none;
  padding: 4px 4px 8px 4px;
  font-family: var(--font); font-size: 15px; color: var(--ink);
  line-height: 1.5;
  outline: none;
}
.composer-prominent textarea::placeholder { color: var(--muted); }
.composer-prominent textarea:focus { box-shadow: none; }

.composer-bottom {
  display: flex; align-items: center; gap: 10px;
  padding-top: 8px;
}
.composer-attach {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--muted2);
  cursor: pointer;
  transition: all .12s;
}
.composer-attach:hover { background: var(--s2); border-color: var(--border2); color: var(--ink); }
.composer-attach svg { width: 16px; height: 16px; }

.composer-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px;
  background: var(--s2); border: 1px solid var(--border);
  border-radius: 7px;
  font-family: var(--mono); font-size: 11px; color: var(--muted2);
  letter-spacing: .3px;
}
.composer-chip strong { color: var(--ink); font-weight: 600; }

.composer-spacer { flex: 1; }

.composer-send {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 16px;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 7px;
  color: #fff;
  font-family: var(--font); font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: all .12s;
}
.composer-send:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.composer-send:disabled { opacity: .5; cursor: not-allowed; }

.composer-stop {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 16px;
  background: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 7px;
  color: #fff;
  font-family: var(--font); font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: all .12s;
}
.composer-stop:hover { background: #000; border-color: #000; }
.composer-stop svg { color: var(--accent); }

/* ─── CHAT VIEW (conversation open) ──────────────────────────────── */

.cv {
  flex: 1;
  display: flex; flex-direction: column;
  min-height: 0;
}

.cv-hdr {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px;
  padding: 18px 48px 14px 48px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.cv-back {
  display: inline-flex; align-items: center; gap: 5px;
  background: transparent; border: none;
  font-family: var(--font); font-size: 12px; font-weight: 600;
  color: var(--muted2); cursor: pointer;
  padding: 4px 8px; border-radius: 5px;
  transition: all .12s;
}
.cv-back:hover { color: var(--ink); background: var(--s3); }

.cv-title-wrap { flex: 1; display: flex; align-items: center; gap: 8px; }
.cv-title-input {
  flex: 1;
  background: transparent;
  border: 1px solid transparent;
  padding: 5px 8px; border-radius: 7px;
  font-family: var(--brand); font-size: 22px; font-weight: 400;
  color: var(--ink);
  outline: none;
  transition: border-color .12s, background .12s;
  min-width: 0;
}
.cv-title-input:hover { background: var(--s2); }
.cv-title-input:focus { background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }

.cv-actions { display: flex; gap: 4px; }

.cv-msgs {
  flex: 1; overflow-y: auto;
  padding: 24px 48px 16px 48px;
}
.cv-msgs-inner { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }

.msg { display: flex; }
.msg.user { justify-content: flex-end; }
.msg.assistant { justify-content: flex-start; }

.msg-bubble {
  max-width: 88%;
  padding: 13px 16px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
}
.msg.user .msg-bubble {
  background: var(--accent-bg);
  border-color: var(--accent-border);
}

.msg-meta {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 6px;
  font-size: 11px;
}
.msg-author { font-weight: 700; color: var(--ink); }
.msg.assistant .msg-author { color: var(--accent); }
.msg-time { font-family: var(--mono); color: var(--muted); font-size: 10px; letter-spacing: .3px; text-transform: uppercase; }

.msg-md { font-size: 14.5px; line-height: 1.6; color: var(--ink); }
.msg-md p { margin: 0 0 0.6rem 0; }
.msg-md p:last-child { margin-bottom: 0; }
.msg-md ul, .msg-md ol { margin: 0.4rem 0 0.7rem 1.2rem; }
.msg-md ul { list-style: disc; }
.msg-md ol { list-style: decimal; }
.msg-md li { margin-bottom: 0.25rem; }
.msg-md strong { color: var(--ink); font-weight: 700; }
.msg-md h1, .msg-md h2, .msg-md h3 { font-weight: 700; margin: 0.7rem 0 0.4rem 0; }
.msg-md h1 { font-size: 1.1rem; }
.msg-md h2 { font-size: 1.02rem; }
.msg-md h3 { font-size: 0.95rem; }
.msg-md code { background: var(--s3); padding: 0.1rem 0.35rem; border-radius: 4px; font-family: var(--mono); font-size: 0.9em; }
.msg-md pre { background: var(--s3); padding: 0.7rem; border-radius: 7px; overflow-x: auto; margin: 0.5rem 0; }
.msg-md pre code { background: transparent; padding: 0; }
.msg-md a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.msg-md img {
  display: block;
  max-width: 100%;
  max-height: 380px;
  width: auto;
  height: auto;
  margin: 10px 0;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--s2);
  cursor: zoom-in;
}

.typing { display: flex; gap: 4px; padding: 4px 0; }
.typing-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing-dot:nth-child(2) { animation-delay: 0.15s; }
.typing-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

.cv-composer-wrap {
  padding: 8px 48px 24px 48px;
  background: var(--bg);
}
.cv-composer-inner { max-width: 760px; margin: 0 auto; }

.composer-hint {
  margin-top: 6px;
  display: flex; justify-content: space-between;
  font-family: var(--mono); font-size: 10px;
  color: var(--muted); letter-spacing: .5px;
  text-transform: uppercase;
}

/* ─── RIGHT SIDEBAR (cards) ───────────────────────────────────────── */

.rsb {
  background: var(--bg);
  border-left: 1px solid var(--border);
  /* topo aumentado: deixa espaço para o badge fixo do utilizador
     (32px alto + 14px top + folga). */
  padding: 64px 16px 18px 16px;
  display: flex; flex-direction: column; gap: 10px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}

.r-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.r-card-hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 10px 16px;
  cursor: pointer;
  user-select: none;
}
.r-card-title { font-size: 13px; font-weight: 700; color: var(--ink); }
.r-card-hdr-actions { display: flex; gap: 2px; align-items: center; }
.r-card-chevron {
  width: 16px; height: 16px;
  color: var(--muted);
  transition: transform .15s;
}
.r-card.collapsed .r-card-chevron { transform: rotate(-90deg); }
.r-card.collapsed .r-card-body { display: none; }

.r-card-body {
  padding: 0 16px 14px 16px;
}

.r-card-help {
  font-size: 12.5px;
  color: var(--muted2);
  line-height: 1.5;
  font-style: italic;
}

.r-card-content {
  font-size: 13px;
  color: var(--ink);
  line-height: 1.55;
  max-height: 200px; overflow-y: auto;
  white-space: pre-wrap;
}

.ctx-sub {
  font-family: var(--mono); font-size: 10px;
  font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .8px;
  margin-top: 12px; margin-bottom: 6px;
}
.ctx-sub:first-child { margin-top: 0; }

.ctx-items { list-style: none; display: flex; flex-direction: column; gap: 2px; }

.ctx-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 12.5px; color: var(--ink);
  text-decoration: none;
  cursor: default;
  transition: background .12s;
}
.ctx-item.actionable { cursor: pointer; }
.ctx-item.actionable:hover { background: var(--s2); }
.ctx-item .ctx-icon {
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  color: var(--muted2);
}
.ctx-item .ctx-icon svg { width: 14px; height: 14px; }
.ctx-item .ctx-name {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ctx-item .ctx-size {
  font-family: var(--mono); font-size: 10px;
  color: var(--muted); flex-shrink: 0;
  letter-spacing: .3px;
}
.ctx-item .ctx-del {
  display: none;
  background: transparent; border: none;
  color: var(--muted); cursor: pointer;
  padding: 2px 4px; border-radius: 4px;
  font-size: 14px; line-height: 1;
}
.ctx-item:hover .ctx-del { display: inline-flex; align-items: center; }
.ctx-item .ctx-del:hover { color: var(--red); background: var(--red-bg); }

/* ─── USER BADGE (top right corner) ───────────────────────────────── */

.user-badge {
  display: flex; align-items: center; gap: 10px;
  padding: 5px 12px 5px 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: border-color .12s, box-shadow .12s;
}
.user-badge:hover { border-color: var(--border2); }
.user-badge-meta { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.2; }
.user-badge-name { font-family: var(--font); font-size: 12.5px; font-weight: 600; color: var(--ink); max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-badge-role { font-family: var(--mono); font-size: 9.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.user-badge-chevron { color: var(--muted); flex-shrink: 0; }

.pending-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px;
  background: var(--amber-bg);
  border: 1px solid var(--amber-border);
  border-radius: 999px;
  color: var(--amber);
  font-family: var(--mono); font-size: 11px; font-weight: 700;
  cursor: pointer;
  transition: all .12s;
}
.pending-pill:hover { background: #fff4e0; }

.user-menu {
  min-width: 220px;
}

/* ─── AVATARS ────────────────────────────────────────────────────── */

.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  overflow: hidden;
  flex-shrink: 0;
  font-family: var(--font);
  font-weight: 700;
  letter-spacing: -.3px;
  user-select: none;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-sm { width: 28px; height: 28px; font-size: 10.5px; }
.avatar-md { width: 38px; height: 38px; font-size: 13px; }
.avatar-lg { width: 72px; height: 72px; font-size: 22px; }

/* ─── SETTINGS MODAL ─────────────────────────────────────────────── */

/* Settings ocupa praticamente todo o ecrã — só margem fina à volta.
   `!important` necessário para vencer o `.modal { width: min(520px, ...) }`
   definido em tokens.css que carrega antes deste ficheiro. */
/* Settings ≈ metade do ecrã, com mínimos para usabilidade. */
.modal.settings-modal {
  width: max(760px, 50vw) !important;
  max-width: calc(100vw - 48px) !important;
  height: 80vh !important;
  max-height: 90vh !important;
}
.settings-body {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 0;
  height: calc(80vh - 56px);  /* topo do modal-hdr ≈ 56px */
  max-height: calc(80vh - 56px);
}
.settings-nav {
  background: var(--s2);
  border-right: 1px solid var(--border);
  padding: 16px 10px;
  display: flex; flex-direction: column; gap: 2px;
}
.settings-tab {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 9px 12px;
  background: transparent;
  border: none; border-radius: 7px;
  font-family: var(--font); font-size: 13px; font-weight: 500;
  color: var(--muted2); cursor: pointer; text-align: left;
  transition: all .12s;
}
.settings-tab:hover { background: var(--surface); color: var(--ink); }
.settings-tab.active { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.settings-tab svg { width: 16px; height: 16px; flex-shrink: 0; }
.settings-tab .count-pill {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  font-family: var(--mono); font-size: 10px; font-weight: 700;
  padding: 1px 7px; border-radius: 9px;
}

.settings-main {
  padding: 24px 32px 32px;
  overflow-y: auto;
  background: var(--surface);
  min-width: 0;
}

.profile-hero {
  display: flex; align-items: center; gap: 22px;
  padding: 18px;
  background: var(--s2);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.user-create-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 16px;
  margin-bottom: 16px;
}
.user-create-grid .form-row { margin-bottom: 0; }

/* Wrapper para tabelas largas — scroll horizontal quando o container é apertado. */
.table-scroll {
  width: 100%;
  overflow-x: auto;
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.table-scroll .users-table { margin-top: 0; min-width: 720px; border: none; }

.users-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
  table-layout: auto;
}
.users-table th {
  font-family: var(--mono); font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1px;
  color: var(--muted); text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--s2);
  white-space: nowrap;
}
.users-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  vertical-align: middle;
}
.users-table tr:last-child td { border-bottom: none; }
.users-table .mono { font-family: var(--mono); }
.users-table .small { font-size: 12px; color: var(--muted2); }
/* email cell: deixa respirar, não quebra a meio */
.users-table td.email-cell {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--muted2);
  white-space: nowrap;
  min-width: 240px;
}

.user-row { display: flex; align-items: center; gap: 10px; }
.user-row-name { font-weight: 600; color: var(--ink); }
.user-row-you {
  display: inline-block;
  font-family: var(--mono); font-size: 9px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .5px;
  color: var(--accent);
  background: var(--accent-bg);
  border: 1px solid var(--accent-border);
  padding: 1px 6px; border-radius: 4px;
  margin-top: 2px;
}

.fsel.small { padding: 5px 26px 5px 10px; font-size: 12px; }

/* ─── VISIBILITY LIST ────────────────────────────────────────────── */

.visibility-list { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.visibility-row {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: border-color .12s;
}
.visibility-row:hover { border-color: var(--border2); }

.visibility-toggle { display: inline-flex; align-items: center; cursor: pointer; flex-shrink: 0; }
.visibility-toggle input { display: none; }
.visibility-check {
  width: 38px; height: 22px;
  background: var(--s3);
  border: 1px solid var(--border2);
  border-radius: 999px;
  position: relative;
  transition: background .15s, border-color .15s;
}
.visibility-check::after {
  content: ''; position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  background: var(--surface);
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0,0,0,.15);
  transition: transform .15s;
}
.visibility-toggle input:checked + .visibility-check {
  background: var(--accent); border-color: var(--accent);
}
.visibility-toggle input:checked + .visibility-check::after {
  transform: translateX(16px);
}

.visibility-main { flex: 1; min-width: 0; }
.visibility-name { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.visibility-meta { font-family: var(--mono); font-size: 11px; color: var(--muted); margin-top: 3px; letter-spacing: .2px; }
.visibility-meta code { background: var(--s3); padding: 1px 5px; border-radius: 3px; color: var(--accent); font-size: 10.5px; }

/* ─── SKILLS PICKER ──────────────────────────────────────────────── */

.skills-popup {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 -8px 28px rgba(0,0,0,.10);
  max-height: 320px;
  overflow-y: auto;
  z-index: 20;
}
.skills-popup-hdr {
  padding: 8px 14px;
  background: var(--s2);
  font-family: var(--mono); font-size: 10px;
  text-transform: uppercase; letter-spacing: 1px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}
.skills-item {
  display: grid;
  grid-template-columns: 140px 130px 1fr;
  gap: 12px; align-items: baseline;
  width: 100%;
  padding: 10px 14px;
  background: transparent; border: none;
  text-align: left; cursor: pointer;
  transition: background .1s;
  border-bottom: 1px solid var(--border);
}
.skills-item:hover { background: var(--accent-bg); }
.skills-item:last-child { border-bottom: none; }
.skills-cmd { font-family: var(--mono); font-size: 12px; color: var(--accent); font-weight: 600; }
.skills-label { font-size: 13px; font-weight: 600; color: var(--ink); }
.skills-desc { font-size: 12px; color: var(--muted2); line-height: 1.4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 720px) {
  .skills-item { grid-template-columns: 1fr; gap: 2px; }
  .skills-cmd { font-size: 11px; }
}

/* ─── DROP OVERLAY (drag-and-drop no chat) ───────────────────────── */

.center { position: relative; }
.drop-overlay {
  position: absolute; inset: 0;
  background: rgba(234, 70, 42, 0.08);
  border: 3px dashed var(--accent);
  border-radius: 12px;
  z-index: 40;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
  margin: 12px;
}
.drop-overlay-card {
  text-align: center;
  padding: 28px 40px;
  background: var(--surface);
  border: 1px solid var(--accent-border);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(234, 70, 42, 0.2);
}
.drop-overlay-card svg { color: var(--accent); margin: 0 auto 10px auto; display: block; }
.drop-overlay-title { font-family: var(--brand); font-size: 20px; color: var(--ink); margin-bottom: 6px; }
.drop-overlay-sub { font-size: 13px; color: var(--muted2); }

/* ─── LIGHTBOX ───────────────────────────────────────────────────── */

.lightbox {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 250;
  display: flex; align-items: center; justify-content: center;
  padding: 40px;
  cursor: zoom-out;
}
.lightbox img {
  max-width: 100%; max-height: 100%;
  border-radius: 6px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
  cursor: default;
}
.lightbox-close {
  position: absolute; top: 16px; right: 20px;
  width: 38px; height: 38px;
  background: rgba(255,255,255,0.1);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 50%;
  font-size: 24px; line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .12s;
}
.lightbox-close:hover { background: rgba(255,255,255,0.2); }
.lightbox-download {
  position: absolute; top: 16px; right: 70px;
  width: 38px; height: 38px;
  background: rgba(255,255,255,0.1);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 50%;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  text-decoration: none;
  transition: background .12s;
}
.lightbox-download:hover { background: rgba(255,255,255,0.2); }

/* ─── SCHEDULED TASKS (card direito) ─────────────────────────────── */

.sched-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.sched-item {
  background: var(--s2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  transition: opacity .12s;
}
.sched-item.disabled { opacity: 0.6; }

.sched-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.sched-main { flex: 1; min-width: 0; }
.sched-title { font-size: 13px; font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sched-when {
  font-family: var(--mono); font-size: 10.5px;
  color: var(--accent); letter-spacing: .3px;
  margin-top: 3px;
}
.sched-status {
  font-family: var(--mono); font-size: 10px;
  color: var(--green); margin-top: 3px; letter-spacing: .3px;
}
.sched-status.err { color: var(--red); }

.sched-actions {
  display: flex; gap: 5px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}
.sched-actions .btn { padding: 4px 9px; font-size: 11px; }

/* ─── COST SPARK CHART (settings → Custos) ───────────────────────── */

.cost-spark {
  display: flex; align-items: flex-end; gap: 4px;
  height: 120px;
  padding: 14px 12px 6px 12px;
  background: var(--s2);
  border: 1px solid var(--border);
  border-radius: 9px;
}
.cost-bar-wrap {
  flex: 1;
  display: flex; flex-direction: column; align-items: center;
  justify-content: flex-end;
  min-width: 0;
  height: 100%;
  cursor: default;
}
.cost-bar {
  width: 100%; max-width: 18px;
  background: var(--accent);
  border-radius: 2px 2px 0 0;
  min-height: 3px;
  transition: opacity .12s;
}
.cost-bar-wrap:hover .cost-bar { opacity: 0.7; }
.cost-bar-label {
  font-family: var(--mono); font-size: 9px;
  color: var(--muted); margin-top: 4px;
  letter-spacing: -.3px;
}

/* ─── TEAM ACCESS (acessos dos colaboradores) ────────────────────── */

.collab-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 16px;
  min-height: 320px;
}
.collab-list {
  display: flex; flex-direction: column; gap: 4px;
  padding-right: 12px;
  border-right: 1px solid var(--border);
  max-height: 480px; overflow-y: auto;
}
.collab-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 8px 10px;
  background: transparent; border: 1px solid transparent;
  border-radius: 7px;
  cursor: pointer; text-align: left;
  transition: all .12s;
}
.collab-item:hover { background: var(--s2); }
.collab-item.active { background: var(--accent-bg); border-color: var(--accent-border); }
.collab-item-main { flex: 1; min-width: 0; }
.collab-item-name { font-size: 13px; font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.collab-item-email { font-family: var(--mono); font-size: 10.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.collab-detail { min-width: 0; }

/* ─── REQUESTS LIST ──────────────────────────────────────────────── */

.requests-list { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.request-row {
  display: flex; justify-content: space-between; align-items: center;
  gap: 16px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
}
.request-main { flex: 1; min-width: 0; }
.request-title { font-size: 14px; font-weight: 700; color: var(--ink); }
.request-meta { font-family: var(--mono); font-size: 11px; color: var(--muted2); margin-top: 4px; letter-spacing: .2px; }
.request-meta code { background: var(--s3); padding: 1px 5px; border-radius: 3px; color: var(--accent); font-size: 10.5px; }
.request-actions { display: flex; gap: 8px; }

/* responsive — settings em ecrãs pequenos */
@media (max-width: 720px) {
  .settings-body { grid-template-columns: 1fr; }
  .settings-nav { flex-direction: row; overflow-x: auto; border-right: none; border-bottom: 1px solid var(--border); }
  .user-create-grid { grid-template-columns: 1fr; }
  .collab-layout { grid-template-columns: 1fr; }
  .collab-list { border-right: none; border-bottom: 1px solid var(--border); padding-right: 0; padding-bottom: 12px; max-height: 220px; }
}

/* ─── MOBILE LAYOUT (general) ─────────────────────────────────────── */

/* botão hamburger — só visível em mobile/tablet */
.mobile-menu-btn {
  display: none;
  position: fixed; top: 12px; left: 12px;
  z-index: 60;
  width: 40px; height: 40px;
  background: var(--sidebar-bg);
  color: #fff;
  border: none; border-radius: 9px;
  align-items: center; justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0,0,0,.18);
  transition: background .12s;
}
.mobile-menu-btn:hover { background: #1f1f1f; }
.mobile-menu-btn svg { width: 20px; height: 20px; }

/* Botão "Nova conversa" no fundo da sidebar mobile */
.lsb-mobile-cta {
  display: none;
  position: sticky; bottom: 0;
  margin: 8px;
  padding: 12px;
  background: var(--accent);
  color: #fff;
  border: none; border-radius: 8px;
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  align-items: center; justify-content: center; gap: 8px;
}
.lsb-mobile-cta:hover { background: var(--accent-hover); }
.lsb-mobile-cta svg { width: 15px; height: 15px; }

/* Tablet/laptop pequeno: esconde sidebar direita */
@media (max-width: 1200px) {
  .layout { grid-template-columns: 260px 1fr; }
  .rsb { display: none; }
}

/* Tablet portrait/landscape pequeno: sidebar esquerda vira overlay */
@media (max-width: 920px) {
  .layout { grid-template-columns: 1fr; }
  .lsb {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: 300px;
    z-index: 55;
    transform: translateX(-100%);
    transition: transform .22s ease-out;
    box-shadow: 4px 0 28px rgba(0,0,0,.25);
    height: 100vh;
  }
  .lsb.mobile-open { transform: translateX(0); }
  .mobile-menu-btn { display: inline-flex; }
  .lsb-mobile-cta { display: inline-flex; }

  /* user badge mais pequeno (mantém visível) */
  .user-badge-role { display: none; }
  .user-badge { padding: 4px 8px 4px 4px; }
  .user-badge-name { font-size: 12px; }

  /* esconder o pending pill em ecrã pequeno — vai pelo menu utilizador */
  .pending-pill { display: none; }

  /* esconder coluna conv-list (já está integrada na sidebar overlay) */
  .conv-list { display: none; }

  /* project home — espaço para o hamburger */
  .ph { padding: 64px 18px 18px 18px; }
  .ph-title { font-size: 28px; }
  .ph-hdr { gap: 8px; flex-wrap: wrap; }

  /* chat — espaço para o hamburger */
  .cv-hdr { padding: 60px 16px 12px 16px; flex-wrap: wrap; gap: 8px; }
  .cv-msgs { padding: 18px 16px 12px 16px; }
  .cv-composer-wrap { padding: 8px 16px 16px 16px; }
  .cv-title-input { font-size: 18px; }
  .msg-bubble { max-width: 94%; }

  /* composer prominente em mobile */
  .composer-prominent textarea { font-size: 14px; min-height: 44px; }

  /* settings em ecrã pequeno */
  .settings-modal { width: 100vw; max-width: 100vw; max-height: 100vh; height: 100vh; border-radius: 0; }
  .settings-body { max-height: calc(100vh - 60px); height: calc(100vh - 60px); grid-template-columns: 1fr; }
  .settings-main { padding: 16px; }
  /* nav em mobile: scroll horizontal de tabs */
  .settings-nav {
    flex-direction: row;
    overflow-x: auto;
    padding: 8px;
    border-right: none;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }
  .settings-tab { flex-shrink: 0; padding: 8px 12px; font-size: 12.5px; }

  /* tabelas continuam com scroll horizontal via .table-scroll */
  .table-scroll { max-width: 100%; }

  /* modal grandes (galeria, landing pages) preenchem ecrã */
  .modal.modal-xl, .modal.modal-lg { width: 100vw; max-width: 100vw; max-height: 100vh; border-radius: 0; }
}

@media (max-width: 480px) {
  /* phones pequenos: ainda mais compacto */
  .lsb { width: 90vw; }
  .ph-title { font-size: 24px; }
  .ph { padding: 60px 14px 14px 14px; }
  .cv-hdr { padding: 56px 14px 10px 14px; }
  .cv-msgs { padding: 14px 14px 10px 14px; }
}

/* overlay quando sidebar aberta em mobile */
.mobile-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 50;
}
.mobile-overlay.show { display: block; }

/* ─── MODAL ────────────────────────────────────────────────────────  */

/* Overrides ao tokens.css (que força width: min(520px, ...)) */
.modal { width: min(580px, calc(100vw - 32px)) !important; max-width: none !important; }
.modal.modal-lg { width: min(820px, calc(100vw - 32px)) !important; }

.form-row { margin-bottom: 16px; }
.form-row:last-child { margin-bottom: 0; }
.form-label {
  display: block;
  font-family: var(--mono); font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1px;
  color: var(--muted2); margin-bottom: 6px;
}
.form-input, .form-textarea {
  width: 100%;
  padding: 10px 12px;
  font-family: var(--font); font-size: 13.5px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--ink);
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.form-textarea { font-family: var(--mono); font-size: 12.5px; min-height: 100px; resize: vertical; line-height: 1.55; }
.form-input.mono { font-family: var(--mono); font-size: 12.5px; }
.form-input:focus, .form-textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
.form-help { font-size: 11.5px; color: var(--muted); margin-top: 5px; line-height: 1.4; }

.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 22px 14px;
  background: var(--s2); border: 1.5px dashed var(--border2);
  border-radius: 9px;
  text-align: center;
  cursor: pointer;
  transition: all .12s;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--accent); background: var(--accent-bg); }
.dropzone-icon { color: var(--muted); width: 22px; height: 22px; margin-bottom: 6px; }
.dropzone-text { font-size: 12px; color: var(--muted2); }
.dropzone-text strong { color: var(--ink); font-weight: 600; }

.file-list { margin-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.file-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px;
  background: var(--s2); border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
}
.file-row .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.file-row .size { font-family: var(--mono); font-size: 10px; color: var(--muted); }
.file-row .rm { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 14px; line-height: 1; padding: 2px 6px; border-radius: 4px; }
.file-row .rm:hover { color: var(--red); background: var(--red-bg); }

/* ─── SCROLLBARS ──────────────────────────────────────────────────── */

.scroll-fine { scrollbar-width: thin; scrollbar-color: var(--border2) transparent; }
.scroll-fine::-webkit-scrollbar { width: 8px; height: 8px; }
.scroll-fine::-webkit-scrollbar-track { background: transparent; }
.scroll-fine::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }
.scroll-fine::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ─── LOGS TABLE (admin) ───────────────────────────────────────────── */

.logs-table-wrap {
  border: 1px solid var(--border);
  border-radius: 9px;
  overflow: auto;
  max-height: 60vh;
  background: var(--surface);
}
.logs-table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
  font-size: 13px;
}
.logs-table thead th {
  position: sticky; top: 0;
  background: var(--s2);
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted2);
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
}
.logs-table tbody td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.logs-table tbody tr:last-child td { border-bottom: none; }
.logs-table tbody tr:hover { background: var(--s2); }

/* ─── SEARCH (Cmd+K) ──────────────────────────────────────────────── */

.search-trigger {
  display: inline-flex; align-items: center; gap: 8px;
  height: 32px; padding: 0 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted2);
  font-family: var(--font);
  font-size: 12.5px;
  cursor: pointer;
  transition: all .12s;
}
.search-trigger:hover { color: var(--ink); border-color: var(--border2); }
.search-trigger-label { font-weight: 500; }
.search-trigger-kbd {
  display: inline-flex; align-items: center;
  padding: 1px 5px;
  background: var(--s2);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
}

.search-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 15, 15, 0.55);
  z-index: 200;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 80px 24px 24px;
  backdrop-filter: blur(2px);
}
.search-modal {
  width: 100%; max-width: 620px;
  background: var(--surface);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
  overflow: hidden;
  display: flex; flex-direction: column;
  max-height: 70vh;
}
.search-input-wrap {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
}
.search-input {
  flex: 1; min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font);
  font-size: 15px;
  color: var(--ink);
}
.search-input::placeholder { color: var(--muted); }
.search-results {
  flex: 1; overflow: auto;
  padding: 8px;
}
.search-empty, .search-loading {
  padding: 32px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}
.search-group { padding: 8px 4px; }
.search-group-title {
  padding: 6px 10px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted2);
}
.search-result {
  width: 100%;
  display: flex; align-items: flex-start; gap: 10px;
  padding: 8px 10px;
  background: transparent;
  border: none;
  border-radius: 7px;
  text-align: left;
  cursor: pointer;
  transition: background .12s;
  color: var(--ink);
}
.search-result:hover { background: var(--s2); }
.search-result-kind {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 22px;
  background: var(--accent-bg);
  color: var(--accent);
  border: 1px solid var(--accent-border, var(--accent));
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 700;
  margin-top: 1px;
}
.search-result-kind.blue { background: var(--blue-bg); color: var(--blue); border-color: var(--blue-border, var(--blue)); }
.search-result-kind.green { background: var(--green-bg); color: var(--green); border-color: var(--green-border, var(--green)); }
.search-result-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.search-result-title { font-weight: 500; font-size: 13.5px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-result-snippet { font-size: 12.5px; color: var(--ink); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.search-result-meta { font-family: var(--mono); font-size: 10.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 760px) {
  .search-trigger-label, .search-trigger-kbd { display: none; }
  .search-trigger { padding: 0 8px; }
  .search-overlay { padding: 24px 12px; }
}

/* ─── MESSAGE ACTIONS (quote + bookmark) ──────────────────────────── */

.msg-bookmark-tag {
  display: inline-flex; align-items: center;
  margin-left: 4px; color: var(--accent);
}
.msg-actions {
  display: flex; gap: 6px;
  margin-top: 8px;
  opacity: 0;
  transition: opacity .12s;
}
.msg:hover .msg-actions { opacity: 1; }
.msg-action {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--muted);
  font-family: var(--font);
  font-size: 11px;
  cursor: pointer;
  transition: all .12s;
}
.msg-action:hover { color: var(--ink); border-color: var(--border2); background: var(--s2); }
.msg-action.on { color: var(--accent); border-color: var(--accent); background: var(--accent-bg); }

/* ─── BOOKMARKS LIST (right card) ─────────────────────────────────── */

.bookmarks-list { display: flex; flex-direction: column; gap: 6px; }
.bookmark-item {
  padding: 8px 10px;
  background: var(--s2);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: all .12s;
}
.bookmark-item:hover { background: var(--surface); border-color: var(--accent-border, var(--accent)); }
.bookmark-meta {
  display: flex; gap: 6px; align-items: baseline;
  font-family: var(--mono);
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted2);
  margin-bottom: 4px;
}
.bookmark-author { font-weight: 700; color: var(--accent); }
.bookmark-conv {
  color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  min-width: 0; flex: 1;
}
.bookmark-snippet {
  font-size: 12px; line-height: 1.4; color: var(--ink);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ─── PRESENCE (avatar stack) ─────────────────────────────────────── */

.presence-stack { display: inline-flex; align-items: center; }
.presence-stack > * { margin-left: -6px; }
.presence-stack > *:first-child { margin-left: 0; }
.presence-avatar {
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 2px solid var(--surface);
  background: var(--accent);
  color: #fff;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  overflow: hidden;
  text-transform: uppercase;
}
.presence-avatar img { width: 100%; height: 100%; object-fit: cover; }
.presence-more {
  background: var(--s2);
  color: var(--muted);
  border-color: var(--border);
}

/* ─── TEMPLATES DE PROMPTS ────────────────────────────────────────── */

.templates-popup {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  width: 360px;
  max-height: 380px;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
  box-shadow: 0 8px 28px rgba(0,0,0,.12);
  z-index: 50;
  display: flex; flex-direction: column;
}
.templates-popup-hdr {
  padding: 9px 12px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted2);
  border-bottom: 1px solid var(--border);
}
.templates-item {
  width: 100%;
  padding: 9px 12px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  text-align: left;
  cursor: pointer;
  display: flex; flex-direction: column; gap: 2px;
  transition: background .12s;
}
.templates-item:hover { background: var(--s2); }
.templates-item:last-of-type { border-bottom: none; }
.templates-title {
  font-size: 13px; font-weight: 600; color: var(--ink);
}
.templates-preview {
  font-size: 11.5px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.templates-popup-foot {
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end;
}

/* Grid de cards no modal de gestão */
.templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
}
.template-card {
  padding: 10px 12px;
  background: var(--s2);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.template-card-hdr {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 6px;
  gap: 8px;
}
.template-card-title {
  font-size: 13px; font-weight: 600; color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.template-card-actions { display: flex; gap: 2px; flex-shrink: 0; }
.template-card-actions .icon-btn { width: 24px; height: 24px; }
.template-card-body {
  font-size: 12px; line-height: 1.4; color: var(--muted2);
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: pre-wrap;
}

/* ─── BACKUPS LIST ────────────────────────────────────────────────── */

.backups-list { display: flex; flex-direction: column; gap: 6px; }
.backup-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  background: var(--s2);
  border: 1px solid var(--border);
  border-radius: 7px;
}
.backup-main { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.backup-meta { font-size: 11.5px; color: var(--muted); font-family: var(--mono); }
.backup-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ─── GALERIA DE CRIATIVOS ────────────────────────────────────────── */

.modal.modal-xl { width: min(1280px, calc(100vw - 32px)) !important; max-width: none !important; }

.creative-group { margin-bottom: 24px; }
.creative-group-hdr {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.creative-group-title { font-size: 14px; font-weight: 600; color: var(--ink); }
.creative-group-count {
  font-family: var(--mono); font-size: 10.5px;
  color: var(--muted); text-transform: uppercase; letter-spacing: 1px;
}
.creative-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}
.creative-tile {
  display: flex; flex-direction: column;
  background: var(--s2);
  border: 1px solid var(--border);
  border-radius: 7px;
  overflow: hidden;
  cursor: pointer;
  padding: 0;
  transition: transform .12s, box-shadow .12s, border-color .12s;
}
.creative-tile:hover { border-color: var(--accent); box-shadow: 0 6px 18px rgba(0,0,0,.08); transform: translateY(-1px); }
.creative-tile img {
  width: 100%; aspect-ratio: 1 / 1; object-fit: cover; display: block;
  background: #fafafa;
}
.creative-tile-meta {
  padding: 6px 8px;
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  min-width: 0;
}
.creative-tile-name {
  font-size: 11px; color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  flex: 1; min-width: 0;
}
.creative-tile-size {
  font-family: var(--mono); font-size: 10px; color: var(--muted);
  flex-shrink: 0;
}

/* ─── API TOKENS LIST ─────────────────────────────────────────────── */

.tokens-list { display: flex; flex-direction: column; gap: 6px; }
.token-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  background: var(--s2);
  border: 1px solid var(--border);
  border-radius: 7px;
}
.token-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.token-name { font-size: 13px; font-weight: 600; color: var(--ink); }
.token-meta { font-size: 11px; color: var(--muted); }

/* ─── CRIATIVOS · versões ─────────────────────────────────────────── */

.creative-card { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.creative-card .creative-tile { position: relative; }
.creative-versions-badge {
  position: absolute; top: 6px; right: 6px;
  background: var(--accent);
  color: #fff;
  font-family: var(--mono); font-size: 10px; font-weight: 700;
  padding: 2px 6px; border-radius: 10px;
  letter-spacing: .5px;
}
.creative-versions-row {
  display: flex; gap: 4px; flex-wrap: wrap;
  padding: 0 2px;
}
.creative-version-dot {
  width: 16px; height: 6px;
  background: var(--border2);
  border: none; border-radius: 3px;
  padding: 0;
  cursor: pointer;
  transition: background .12s;
}
.creative-version-dot:hover { background: var(--muted); }
.creative-version-dot.latest { background: var(--accent); }

/* ─── BRAND KIT GROUPS (Contexto card) ────────────────────────────── */

.ctx-group { margin-bottom: 8px; }
.ctx-group:last-child { margin-bottom: 0; }
.ctx-group-label {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 10px 2px 10px;
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--muted2);
}
.ctx-group-count {
  font-family: var(--mono); font-size: 9px;
  background: var(--s2);
  padding: 1px 6px; border-radius: 8px;
  color: var(--muted);
}

/* ─── CRIATIVOS · selecção para Drive ─────────────────────────────── */

.creative-tile-wrap { position: relative; }
.creative-select {
  position: absolute; top: 8px; left: 8px;
  background: rgba(255,255,255,0.92);
  border-radius: 4px;
  padding: 2px 4px;
  display: inline-flex; align-items: center;
  box-shadow: 0 1px 3px rgba(0,0,0,.15);
  cursor: pointer;
  opacity: 0;
  transition: opacity .12s;
}
.creative-card:hover .creative-select,
.creative-card.selected .creative-select { opacity: 1; }
.creative-select input { margin: 0; cursor: pointer; }
.creative-card.selected .creative-tile { outline: 2px solid var(--accent); outline-offset: -2px; }

/* ─── LANDING PAGES (modal) ───────────────────────────────────────── */

.lp-list { display: flex; flex-direction: column; gap: 6px; list-style: none; padding: 0; margin: 0; }
.lp-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: var(--s2);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.lp-main { flex: 1; min-width: 0; cursor: pointer; }
.lp-name { font-weight: 600; font-size: 14px; color: var(--ink); }
.lp-meta { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.lp-actions { display: flex; gap: 6px; flex-shrink: 0; }

.lp-tabs {
  display: flex; gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}
.lp-tabs button {
  padding: 9px 14px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  font-family: var(--font);
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  transition: all .12s;
  margin-bottom: -1px;
}
.lp-tabs button:hover { color: var(--ink); }
.lp-tabs button.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

/* ─── AUTH OVERLAY (login no frontend Vercel) ────────────────────── */

.auth-overlay {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  background: var(--sidebar-bg);
  padding: 24px;
}
.auth-card {
  width: 100%; max-width: 380px;
  background: var(--surface);
  border-radius: 14px;
  padding: 32px 28px;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.auth-logo { display: block; margin: 0 auto 22px; width: 70%; height: auto; }
.auth-title { text-align: center; font-family: var(--brand); font-size: 18px; color: var(--ink); margin-bottom: 4px; }
.auth-sub {
  text-align: center; font-size: 12px; color: var(--muted);
  margin-bottom: 22px; font-family: var(--mono);
  text-transform: uppercase; letter-spacing: 1px;
}
.auth-label {
  display: block; font-family: var(--mono); font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1px; color: var(--muted2);
  margin-bottom: 6px; margin-top: 12px;
}
.auth-input {
  width: 100%; padding: 11px 13px;
  font-family: var(--font); font-size: 14px;
  border: 1px solid var(--border); border-radius: 8px;
  outline: none; transition: border-color .12s, box-shadow .12s;
  background: var(--surface); color: var(--ink);
}
.auth-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
.auth-input.auth-totp {
  font-family: var(--mono); font-size: 22px;
  letter-spacing: 8px; text-align: center;
}
.auth-submit {
  margin-top: 22px; width: 100%; padding: 11px;
  background: var(--accent); color: #fff;
  border: none; border-radius: 8px;
  font-family: var(--font); font-size: 14px; font-weight: 600;
  cursor: pointer; transition: background .12s;
}
.auth-submit:hover { background: var(--accent-hover); }
.auth-submit:disabled { opacity: .7; cursor: not-allowed; }
.auth-error {
  background: var(--red-bg); color: var(--red);
  border: 1px solid var(--red-border); border-radius: 7px;
  padding: 8px 12px; font-size: 12.5px;
  margin-top: 14px; text-align: center; font-weight: 500;
}
.auth-foot {
  margin-top: 18px; text-align: center;
  font-family: var(--mono); font-size: 10px;
  color: var(--muted); letter-spacing: .5px; text-transform: uppercase;
}
