/* ============================================================
   ChatGPT PRO — Codex Style
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #212121;
  --bg-sidebar:  #181818;
  --bg-input:    #2f2f2f;
  --bg-hover:    #2a2a2a;
  --bg-active:   #303030;
  --border:      rgba(255,255,255,0.08);
  --text-primary:#ececec;
  --text-muted:  #8e8e93;
  --text-dim:    #555;
  --accent:      #10a37f;
  --send-bg:     #ececec;
  --send-color:  #1a1a1a;
  --radius-sm:   8px;
  --radius-md:   12px;
  --radius-lg:   16px;
  --radius-xl:   24px;
}

html, body { height: 100%; background: var(--bg); color: var(--text-primary); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 15px; overflow: hidden; }

/* ── Splash ─────────────────────────────────────────────── */
#splash {
  position: fixed; inset: 0; z-index: 9999;
  background: #000;
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.5s ease;
}
#splash.fade-out { opacity: 0; pointer-events: none; }
#splash-logo {
  width: 60px; height: 60px;
  
  animation: splash-pulse 1.8s ease-in-out infinite;
}
@keyframes splash-pulse {
  0%,100% { opacity: 0.5; transform: scale(0.92); }
  50%      { opacity: 1;   transform: scale(1); }
}

/* ── Login ──────────────────────────────────────────────── */
#login-screen {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
}
.login-box {
  width: 340px; padding: 40px 32px; border-radius: 20px;
  background: var(--bg-input); border: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  text-align: center;
}
.login-logo { width: 48px; height: 48px; border-radius: 10px; margin-bottom: 4px; }
.login-box h2 { font-size: 20px; font-weight: 600; }
.login-box p { color: var(--text-muted); font-size: 14px; }
.login-box input {
  width: 100%; padding: 11px 14px; background: var(--bg-hover);
  border: 1px solid var(--border); border-radius: var(--radius-md);
  color: var(--text-primary); font-size: 15px; outline: none; margin-top: 4px;
  font-family: monospace; letter-spacing: 0.05em; text-align: center;
}
.login-box input:focus { border-color: var(--accent); }
.login-box button {
  width: 100%; padding: 12px; background: var(--text-primary);
  color: #111; border: none; border-radius: var(--radius-md);
  font-size: 15px; font-weight: 600; cursor: pointer; transition: opacity .15s;
}
.login-box button:hover { opacity: 0.88; }
.error-msg { color: #ff6b6b; font-size: 13px; min-height: 18px; }

/* ── App shell ──────────────────────────────────────────── */
#app { display: flex; height: 100vh; overflow: hidden; }

/* ── Sidebar ─────────────────────────────────────────────── */
#sidebar {
  width: 260px; min-width: 260px;
  background: var(--bg-sidebar);
  display: flex; flex-direction: column;
  border-right: 1px solid var(--border);
  transition: width .2s ease, min-width .2s ease;
  overflow: hidden;
}
#sidebar.collapsed { width: 0; min-width: 0; border-right: none; }

.sb-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 12px 8px;
}
.sb-brand { display: flex; align-items: center; gap: 8px; padding: 4px 4px; }
.sb-brand img { border-radius: 6px; }
.sb-brand-name { font-size: 16px; font-weight: 600; color: var(--text-primary); }

.sb-menu { display: flex; flex-direction: column; gap: 2px; padding: 4px 8px 8px; }

.sb-new-chat {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  background: var(--bg-active); border: 1px solid var(--border);
  color: var(--text-primary); cursor: pointer; font-size: 14px; font-weight: 500;
  transition: background .15s; width: 100%;
}
.sb-new-chat:hover { background: var(--bg-hover); }

.sb-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  background: none; border: none;
  color: var(--text-muted); cursor: pointer; font-size: 14px;
  transition: background .15s, color .15s; width: 100%;
}
.sb-row:hover { background: var(--bg-hover); color: var(--text-primary); }

.sb-section-label {
  padding: 8px 12px 4px; font-size: 11px; font-weight: 600;
  color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.06em;
}

#conversations-list { flex: 1; overflow-y: auto; padding: 0 8px 8px; }
#conversations-list::-webkit-scrollbar { width: 4px; }
#conversations-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

.conv-item {
  display: flex; align-items: center;
  padding: 8px 8px; border-radius: var(--radius-sm);
  cursor: pointer; font-size: 13.5px; color: var(--text-muted);
  transition: background .12s, color .12s; gap: 8px;
}
.conv-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.conv-item.active { background: var(--bg-active); color: var(--text-primary); }
.conv-item .conv-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-item .del-conv {
  opacity: 0; background: none; border: none; color: var(--text-muted);
  cursor: pointer; padding: 2px; border-radius: 4px; display: flex; align-items: center;
  transition: opacity .15s, color .15s; flex-shrink: 0;
}
.conv-item:hover .del-conv { opacity: 1; }
.conv-item .del-conv:hover { color: #ff6b6b; }

.sidebar-footer { border-top: 1px solid var(--border); padding: 10px 12px; }
#user-info { display: flex; align-items: center; gap: 10px; }
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; flex-shrink: 0;
}
.user-details { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.user-details span:first-child { font-size: 13px; font-weight: 500; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plan-badge { font-size: 11px; color: var(--accent); font-weight: 600; }
.icon-btn {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); border-radius: 6px; padding: 5px;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ── Main ───────────────────────────────────────────────── */
#main {
  flex: 1; display: flex; flex-direction: column;
  min-width: 0; position: relative; background: var(--bg);
}

/* ── Header ─────────────────────────────────────────────── */
#chat-header {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 16px; min-height: 44px;
  flex-shrink: 0;
}

.model-picker { position: relative; }

/* Model btn in HEADER (unused now, kept for fallback) */
.model-btn {
  display: flex; align-items: center; gap: 6px;
  background: none; border: none; cursor: pointer;
  color: var(--text-primary); font-size: 15px; font-weight: 600;
  padding: 6px 8px; border-radius: var(--radius-sm);
  transition: background .15s;
}
.model-btn:hover { background: var(--bg-hover); }

/* Model btn in INPUT BAR (Codex style) */
.composer-model-wrap { position: relative; }
.composer-model-btn {
  display: flex; align-items: center; gap: 5px;
  background: rgba(255,255,255,0.08); border: none; cursor: pointer;
  color: var(--text-muted); font-size: 13px; font-weight: 500;
  padding: 5px 10px 5px 12px; border-radius: 20px;
  transition: background .15s, color .15s; white-space: nowrap;
}
.composer-model-btn:hover { background: rgba(255,255,255,0.13); color: var(--text-primary); }

/* ── Empty state ────────────────────────────────────────── */
#empty-state {
  display: none; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; flex: 1; padding: 40px 32px; text-align: center;
}
#main.empty #empty-state { display: flex; }
#main.empty #messages { display: none; }
#empty-state h1 { font-size: 28px; font-weight: 600; color: var(--text-primary); white-space: nowrap; }

/* ── Messages ───────────────────────────────────────────── */
#messages { flex: 1; overflow-y: auto; padding: 24px 0; }
#messages::-webkit-scrollbar { width: 4px; }
#messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

.thread { max-width: 760px; margin: 0 auto; padding: 0 28px; display: flex; flex-direction: column; gap: 6px; }

.msg { display: flex; flex-direction: column; padding: 4px 0; }
.msg.user { align-items: flex-end; }
.msg.assistant { align-items: flex-start; }

.msg.user .bubble {
  background: var(--bg-input); color: var(--text-primary);
  padding: 10px 16px; border-radius: 18px 18px 4px 18px;
  max-width: 80%; line-height: 1.55; font-size: 15px; word-break: break-word;
}

.msg.assistant .md { max-width: 100%; line-height: 1.7; font-size: 15px; color: var(--text-primary); }
.msg.assistant .md p { margin: 0 0 10px; }
.msg.assistant .md p:last-child { margin-bottom: 0; }
.msg.assistant .md h1,.msg.assistant .md h2,.msg.assistant .md h3 { margin: 16px 0 8px; font-weight: 600; }
.msg.assistant .md ul,.msg.assistant .md ol { padding-left: 20px; margin: 8px 0; }
.msg.assistant .md li { margin: 4px 0; }
.msg.assistant .md a { color: var(--accent); text-decoration: none; }
.msg.assistant .md a:hover { text-decoration: underline; }
.msg.assistant .md code.inline { background: rgba(255,255,255,0.1); padding: 1px 6px; border-radius: 4px; font-family: monospace; font-size: 13px; }
.msg.assistant .md blockquote { border-left: 3px solid var(--border); padding-left: 12px; color: var(--text-muted); margin: 8px 0; }
.msg.assistant .md table { border-collapse: collapse; width: 100%; margin: 8px 0; font-size: 14px; }
.msg.assistant .md th,.msg.assistant .md td { border: 1px solid var(--border); padding: 8px 12px; }
.msg.assistant .md th { background: var(--bg-input); font-weight: 600; }
.msg.assistant .md img.gen { max-width: 100%; border-radius: 12px; cursor: pointer; margin: 8px 0; }

/* Code blocks */
.codeblock { background: #0d1117; border: 1px solid #30363d; border-radius: 10px; overflow: hidden; margin: 10px 0; }
.code-head { background: #161b22; padding: 8px 14px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #30363d; }
.code-head span { color: #8b949e; font-size: 12px; font-family: monospace; }
.copy-code { background: none; border: 1px solid #30363d; color: #8b949e; border-radius: 6px; padding: 3px 8px; cursor: pointer; font-size: 12px; display: inline-flex; align-items: center; gap: 4px; transition: color .15s, border-color .15s; }
.copy-code:hover { color: #e6edf3; border-color: #8b949e; }
.codeblock pre { margin: 0; background: transparent !important; padding: 14px 16px; overflow-x: auto; }
.codeblock pre code.hljs { background: transparent; padding: 0; font-size: 13px; }

.msg-actions { display: flex; align-items: center; gap: 4px; margin-top: 6px; opacity: 0; transition: opacity .15s; }
.msg:hover .msg-actions { opacity: 1; }
.act { background: none; border: none; cursor: pointer; color: var(--text-muted); padding: 5px; border-radius: 6px; display: flex; align-items: center; transition: color .15s, background .15s; }
.act:hover { color: var(--text-primary); background: var(--bg-hover); }
.regen-btn { display: inline-flex; align-items: center; gap: 4px; background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 12px; padding: 4px 6px; border-radius: 6px; transition: color .15s, background .15s; }
.regen-btn:hover { color: var(--text-primary); background: var(--bg-hover); }

/* Typing */
.msg.pending { min-height: 44px; }
.typing-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); margin-top: 14px; animation: typing-blink 1.2s ease-in-out infinite; }
@keyframes typing-blink { 0%,100%{opacity:.2} 50%{opacity:1} }
.img-loading { display: flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: 14px; padding: 12px 0; }
.img-loading span::after { content:'.'; animation: dots 1.2s steps(3,end) infinite; }
@keyframes dots { 0%{content:'.'} 33%{content:'..'} 66%{content:'...'} }
.searching-row { display: flex; align-items: center; gap: 8px; color: var(--accent); font-size: 13px; padding: 8px 0; }
.searching-row svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Attachments */
.attach-row { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 0 8px; }
.thumb { position: relative; width: 60px; height: 60px; border-radius: 8px; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb button { position: absolute; top: 2px; right: 2px; background: rgba(0,0,0,.7); border: none; color: #fff; width: 18px; height: 18px; border-radius: 50%; cursor: pointer; font-size: 11px; display: flex; align-items: center; justify-content: center; }

/* Mode chip */
.mode-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(16,163,127,.15); color: var(--accent);
  border-radius: 20px; padding: 5px 6px 5px 10px;
  font-size: 13px; font-weight: 500; margin-bottom: 6px;
  width: fit-content; user-select: none;
}
.mode-chip button {
  background: rgba(16,163,127,.2); border: none; color: var(--accent); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 50%;
  transition: background .15s; flex-shrink: 0;
}
.mode-chip button:hover { background: rgba(16,163,127,.4); }

/* ── Input area ──────────────────────────────────────────── */
#input-area { padding: 0 20px 16px; flex-shrink: 0; max-width: 800px; width: 100%; margin: 0 auto; box-sizing: border-box; }

.composer {
  background: var(--bg-input); border-radius: 18px;
  border: 1px solid var(--border); transition: border-color .15s;
  padding: 14px 14px 10px; display: flex; flex-direction: column;
}
.composer:focus-within { border-color: rgba(255,255,255,0.2); }

#message-input {
  width: 100%; background: none; border: none; outline: none;
  color: var(--text-primary); font-size: 15px; line-height: 1.6;
  resize: none; min-height: 26px; max-height: 180px; overflow-y: auto;
  font-family: inherit; display: block;
}
#message-input::placeholder { color: var(--text-dim); }

.composer-bottom {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 10px; min-height: 36px;
}
.composer-left, .composer-right { display: flex; align-items: center; gap: 2px; }

.composer-icon-btn {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); padding: 7px; border-radius: 8px;
  display: flex; align-items: center; transition: background .15s, color .15s;
  flex-shrink: 0;
}
.composer-icon-btn:hover { background: rgba(255,255,255,0.08); color: var(--text-primary); }
.composer-icon-btn[aria-pressed="true"] { color: var(--accent); background: rgba(16,163,127,.15); }

.send-btn {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  background: var(--send-bg); color: var(--send-color);
  border: none; cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: opacity .15s, background .15s;
}
.send-btn:disabled { background: rgba(255,255,255,0.1); color: var(--text-dim); cursor: default; }
.send-btn:not(:disabled):hover { opacity: 0.85; }

/* Stop button (Codex blue square) */
.stop-btn {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  background: #1d4ed8; color: #fff;
  border: none; cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.stop-btn:hover { background: #1e40af; }

.disclaimer { text-align: center; font-size: 12px; color: var(--text-dim); padding: 8px 0 0; }

/* Plus menu */
.plus-wrap { position: relative; }
.menu {
  position: absolute; bottom: calc(100% + 6px); left: 0;
  background: #2c2c2e; border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 6px; min-width: 180px;
  box-shadow: 0 8px 32px rgba(0,0,0,.6); z-index: 200;
}
.menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 8px;
  background: none; border: none; cursor: pointer;
  color: var(--text-primary); font-size: 14px; width: 100%;
  transition: background .12s;
}
.menu-item:hover { background: var(--bg-hover); }

/* Model menu — opens upward, anchored to the right */
.menu-up-right {
  bottom: calc(100% + 8px); top: auto;
  left: auto; right: 0; min-width: 200px;
}

/* ── Toast ──────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(16px);
  background: #3a3a3a; color: var(--text-primary); padding: 10px 18px;
  border-radius: 20px; font-size: 14px; opacity: 0; pointer-events: none;
  transition: opacity .25s, transform .25s; z-index: 9000; white-space: nowrap;
  box-shadow: 0 4px 20px rgba(0,0,0,.5);
}
.toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Lightbox ───────────────────────────────────────────── */
.lightbox { position: fixed; inset: 0; z-index: 8000; }
.lightbox-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.85); backdrop-filter: blur(4px); }
.lightbox-content { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 16px; }
.lightbox-close { position: absolute; top: 16px; right: 16px; background: rgba(255,255,255,.1); border: none; color: #fff; width: 36px; height: 36px; border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background .15s; }
.lightbox-close:hover { background: rgba(255,255,255,.2); }
#lightbox-img { max-width: 90vw; max-height: 80vh; border-radius: 12px; object-fit: contain; }
.lightbox-actions { display: flex; gap: 12px; }
.lb-btn { display: flex; align-items: center; gap: 8px; padding: 8px 16px; background: rgba(255,255,255,.1); color: #fff; border-radius: 20px; text-decoration: none; font-size: 14px; transition: background .15s; }
.lb-btn:hover { background: rgba(255,255,255,.2); }

/* ── Codex selector ─────────────────────────────────────── */
.composer-model-btn { background: rgba(255,255,255,0.07); color: #cfcfcf; font-size: 13.5px; padding: 6px 12px 6px 14px; border-radius: 999px; }
.composer-model-btn:hover { background: rgba(255,255,255,0.12); color: #fff; }
.cx-pop {
  position: absolute; bottom: calc(100% + 10px); right: 0; z-index: 300;
  width: 256px; background: #2a2a2a; border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px; padding: 12px; box-shadow: 0 12px 40px rgba(0,0,0,.55);
}
.cx-pop[hidden] { display: none !important; }
.cx-pop-title {
  display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%;
  background: none; border: none; color: #fff; font-size: 14px; font-weight: 600;
  padding: 4px 0 12px; cursor: pointer;
}
.cx-chev { color: #9a9a9a; font-weight: 400; }
.cx-pop-title:hover .cx-chev { color: #fff; }
.cx-slider { position: relative; height: 30px; cursor: pointer; user-select: none; }
.cx-track { position: absolute; inset: 0; background: #3a3a3a; border-radius: 999px; overflow: hidden; }
.cx-fill { position: absolute; left: 0; top: 0; bottom: 0; background: #3b82f6; border-radius: 999px; transition: width .18s ease; }
.cx-dot { position: absolute; top: 50%; width: 4px; height: 4px; margin: -2px 0 0 -2px; border-radius: 50%; background: rgba(255,255,255,.55); pointer-events: none; }
.cx-dot[data-i="0"] { left: 14px; } .cx-dot[data-i="1"] { left: 50%; } .cx-dot[data-i="2"] { left: calc(100% - 14px); }
.cx-thumb {
  position: absolute; top: 50%; width: 30px; height: 30px; margin: -15px 0 0 -15px;
  background: #fff; border-radius: 50%; box-shadow: 0 2px 6px rgba(0,0,0,.4);
  transition: left .18s ease; pointer-events: none;
}
#cx-model-view .cx-model {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  background: none; border: none; color: #ececec; font-size: 13.5px; text-align: left;
  padding: 9px 10px; border-radius: 10px; cursor: pointer;
}
#cx-model-view .cx-model:hover { background: rgba(255,255,255,0.07); }
#cx-model-view .cx-back { color: #9a9a9a; font-size: 12px; padding: 2px 10px 8px; background: none; border: none; cursor: pointer; }
#cx-model-view .cx-back:hover { color: #fff; }

/* Send / stop — Codex blue */
.send-btn { background: #2563eb; color: #fff; }
.send-btn:disabled { background: #1e3a8a; color: rgba(255,255,255,.45); }
.stop-btn { background: #2563eb; }

/* Lixeira das conversas (discreta, aparece no hover) */
.conv-item .conv-delete {
  background: transparent !important; border: none; color: #8e8e8e;
  width: 26px; height: 26px; border-radius: 6px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; opacity: 0; transition: opacity .15s, color .15s, background .15s; flex-shrink: 0;
}
.conv-item .conv-delete svg { width: 15px; height: 15px; }
.conv-item:hover .conv-delete, .conv-item.active .conv-delete { opacity: 1; }
.conv-item .conv-delete:hover { color: #ff6b6b; background: rgba(255,255,255,.08) !important; }

/* ── PWA mobile ── */
* { -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; height: 100dvh; overscroll-behavior: none; }
#app { height: 100dvh; }
#input-area { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
@media (max-width: 700px) {
  #sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 60; width: 280px; box-shadow: 8px 0 30px rgba(0,0,0,.5); padding-top: env(safe-area-inset-top); }
  #sidebar.collapsed { width: 0; box-shadow: none; }
  #chat-header { padding-top: max(8px, env(safe-area-inset-top)); }
  #input-area { padding-left: 10px; padding-right: 10px; }
  #empty-state h1 { font-size: 22px; white-space: normal; }
  .login-box { margin: 16px; padding: 32px 22px; }
  .cx-pop { width: 230px; }
  #message-input { font-size: 16px; } /* evita zoom no iOS */
}

@media (hover: none) {
  .conv-item .conv-delete { opacity: 1 !important; }
  .msg-actions { opacity: 1 !important; }
}


/* ── Gerando imagem (placeholder animado estilo ChatGPT) ── */
.img-gen { display: flex; flex-direction: column; gap: 10px; padding: 6px 0; }
.img-gen-box {
  position: relative; width: min(380px, 100%); aspect-ratio: 1 / 1; border-radius: 16px; overflow: hidden;
  background: #262626; border: 1px solid rgba(255,255,255,.07);
}
.img-gen-glow {
  position: absolute; inset: -40%;
  background:
    radial-gradient(circle at 25% 30%, rgba(99,102,241,.55), transparent 45%),
    radial-gradient(circle at 75% 25%, rgba(236,72,153,.45), transparent 45%),
    radial-gradient(circle at 70% 78%, rgba(14,165,233,.5), transparent 48%),
    radial-gradient(circle at 25% 75%, rgba(16,185,129,.4), transparent 45%);
  filter: blur(38px);
  animation: imgGenFloat 6s ease-in-out infinite alternate;
}
.img-gen-shimmer {
  position: absolute; inset: 0;
  background: linear-gradient(110deg, transparent 30%, rgba(255,255,255,.14) 50%, transparent 70%);
  background-size: 250% 100%;
  animation: imgGenShimmer 1.8s linear infinite;
}
.img-gen-label { color: var(--text-muted); font-size: 14px; }
.img-gen-label span::after { content: '.'; animation: dots 1.2s steps(3, end) infinite; }
@keyframes imgGenFloat {
  0%   { transform: translate(-6%, -4%) rotate(0deg) scale(1); }
  100% { transform: translate(6%, 5%) rotate(25deg) scale(1.15); }
}
@keyframes imgGenShimmer {
  0%   { background-position: 150% 0; }
  100% { background-position: -100% 0; }
}


/* ── Biblioteca de imagens ── */
#library { display: none; flex: 1; overflow-y: auto; padding: 28px 28px 24px; }
#main.library #library { display: block; }
#main.library #messages, #main.library #empty-state { display: none !important; }
#library::-webkit-scrollbar { width: 6px; }
#library::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 3px; }
.lib-inner { max-width: 980px; margin: 0 auto; }
.lib-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 18px; }
.lib-head h2 { font-size: 22px; font-weight: 600; color: var(--text-primary); }
.lib-count { color: var(--text-muted); font-size: 13px; }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.lib-item { position: relative; aspect-ratio: 1 / 1; border-radius: 14px; overflow: hidden; background: #262626; cursor: pointer; }
.lib-item img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .25s ease; }
.lib-item:hover img { transform: scale(1.04); }
.lib-del {
  position: absolute; top: 8px; right: 8px; width: 30px; height: 30px; border-radius: 50%;
  border: none; background: rgba(0,0,0,.6); color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity .15s, background .15s;
}
.lib-item:hover .lib-del { opacity: 1; }
.lib-del:hover { background: rgba(220,38,38,.9); }
@media (hover: none) { .lib-del { opacity: 1; } }
.lib-skel { aspect-ratio: 1 / 1; border-radius: 14px; background: #262626; position: relative; overflow: hidden; }
.lib-skel::after { content: ''; position: absolute; inset: 0; background: linear-gradient(110deg, transparent 30%, rgba(255,255,255,.08) 50%, transparent 70%); background-size: 250% 100%; animation: imgGenShimmer 1.6s linear infinite; }
.lib-empty { grid-column: 1 / -1; text-align: center; color: var(--text-muted); padding: 90px 0; font-size: 15px; line-height: 1.7; }
@media (max-width: 700px) { #library { padding: 18px 14px; } .lib-grid { grid-template-columns: repeat(2, 1fr); } }

/* ═════ Codex dark + Work + Projetos ═════ */
:root {
  --bg:          #1b1b1b;
  --bg-sidebar:  #141414;
  --bg-input:    #282828;
  --bg-hover:    #222222;
  --bg-active:   #2a2a2a;
  --border:      rgba(255,255,255,0.06);
}
#sidebar { border-right: none; }
.sb-new-chat { background: none; border: none; }
.sb-new-chat:hover { background: var(--bg-hover); }
.sb-scroll { flex: 1; overflow-y: auto; min-height: 0; }
.sb-scroll::-webkit-scrollbar { width: 4px; }
.sb-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }
#conversations-list { flex: none; overflow: visible; }
.sb-section-label { text-transform: none; font-size: 12.5px; letter-spacing: 0; color: var(--text-muted); font-weight: 500; padding: 14px 12px 4px; }
.sb-section-head { display: flex; align-items: center; justify-content: space-between; padding-right: 10px; }
.sb-add { padding: 3px; opacity: .7; margin-top: 8px; }
.sb-add:hover { opacity: 1; }
#projects-list { padding: 0 8px; }
.proj-item { display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: var(--radius-sm); cursor: pointer; font-size: 13.5px; color: var(--text-primary); transition: background .12s; }
.proj-item:hover { background: var(--bg-hover); }
.proj-item.active { background: var(--bg-active); }
.proj-item svg { flex-shrink: 0; color: var(--text-muted); }
.proj-item .conv-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proj-more, .conv-move { opacity: 0; background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 2px 4px; border-radius: 4px; display: flex; align-items: center; flex-shrink: 0; }
.proj-item:hover .proj-more, .conv-item:hover .conv-move { opacity: 1; }
.proj-more:hover, .conv-move:hover { color: var(--text-primary); }
.conv-item.sub { padding-left: 32px; }
.proj-empty { padding: 4px 8px 6px 32px; font-size: 12.5px; color: var(--text-dim); }
.pop-menu { position: fixed; z-index: 500; min-width: 190px; background: #2a2a2a; border: 1px solid rgba(255,255,255,.08); border-radius: 12px; padding: 5px; box-shadow: 0 10px 30px rgba(0,0,0,.45); }
.pop-menu button { display: flex; align-items: center; gap: 8px; width: 100%; background: none; border: none; color: var(--text-primary); font-size: 13.5px; padding: 8px 10px; border-radius: 8px; cursor: pointer; text-align: left; }
.pop-menu button:hover { background: rgba(255,255,255,.07); }
.pop-menu button.danger { color: #ff6b6b; }
.pop-menu .pop-label { font-size: 11.5px; color: var(--text-muted); padding: 6px 10px 4px; }

#chat-header { position: relative; min-height: 58px; }
.mode-switch { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); display: flex; background: #242424; border: 1px solid var(--border); border-radius: 999px; padding: 3px; gap: 2px; z-index: 5; }
.mode-switch button { background: none; border: none; color: var(--text-muted); font-size: 13.5px; font-weight: 600; padding: 7px 36px; border-radius: 999px; cursor: pointer; transition: background .15s, color .15s; }
.mode-switch button:hover { color: var(--text-primary); }
.mode-switch button.active { background: #363636; color: #fff; }

#main.empty #empty-state { flex: 0 0 auto; margin-top: auto; padding: 0 32px 22px; }
#main.empty #input-area { margin-bottom: auto; padding-bottom: 40px; }
#empty-state h1 { font-size: 27px; font-weight: 500; }
.project-chip { display: inline-flex; align-items: center; gap: 6px; color: var(--text-muted); font-size: 13.5px; }
.project-chip[hidden] { display: none; }

.composer { border-radius: 26px; padding: 12px 12px 8px 16px; }
.doc-chip { display: inline-flex; align-items: center; gap: 8px; background: rgba(255,255,255,.06); border: 1px solid var(--border); border-radius: 10px; padding: 6px 8px 6px 10px; font-size: 13px; color: var(--text-primary); max-width: 240px; }
.doc-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-chip button { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 12px; }
.doc-chip button:hover { color: #fff; }

.work-suggest { display: none; flex-direction: column; gap: 2px; margin: 14px 6px 0; }
#main.empty.work .work-suggest { display: flex; }
.work-suggest button { display: flex; align-items: center; gap: 12px; background: none; border: none; color: var(--text-muted); font-size: 14px; padding: 9px 12px; border-radius: 10px; cursor: pointer; text-align: left; transition: background .15s, color .15s; }
.work-suggest button:hover { background: var(--bg-hover); color: var(--text-primary); }
#main.empty.work .disclaimer { display: none; }

.cx-model.locked { opacity: .55; cursor: not-allowed; }
.cx-model.locked:hover { opacity: .7; }
.cx-lock { display: inline-flex; color: var(--text-muted); }

/* ═════ Imagens no chat: tamanho estilo ChatGPT ═════ */
.msg.assistant .md img.gen { display: block; width: auto; max-width: min(100%, 400px); max-height: 400px; height: auto; object-fit: contain; border-radius: 18px; margin: 6px 0; }
.img-gen-box { width: min(100%, 400px) !important; max-width: 400px !important; aspect-ratio: 1 / 1; }
.msg.user .user-imgs img, .msg.user img { max-width: 160px; max-height: 160px; border-radius: 12px; object-fit: cover; }
/* ── Anexos: carregando + arrastar e soltar ── */
.thumb.loading { background: rgba(255,255,255,.06); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; }
.thumb-spin { width: 20px; height: 20px; border: 2px solid rgba(255,255,255,.18); border-top-color: #fff; border-radius: 50%; animation: thumb-spin .8s linear infinite; flex-shrink: 0; }
.thumb-spin.sm { width: 13px; height: 13px; }
@keyframes thumb-spin { to { transform: rotate(360deg); } }
.doc-chip.loading { color: var(--text-muted); }
.doc-chip .doc-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.drag-over::after { content: "Solte aqui para adicionar à conversa"; position: fixed; inset: 10px; z-index: 9999; display: flex; align-items: center; justify-content: center; border: 2px dashed rgba(255,255,255,.35); border-radius: 18px; background: rgba(18,18,18,.86); color: #fff; font-size: 17px; font-weight: 600; pointer-events: none; }

/* ── Arquivos gerados pela IA (cartão de download) + exportar resposta ── */
.file-card { display: flex; align-items: center; gap: 12px; max-width: 460px; margin: 10px 0; padding: 12px 14px; background: rgba(255,255,255,.04); border: 1px solid var(--border); border-radius: 14px; }
.file-ico { flex-shrink: 0; width: 42px; height: 42px; border-radius: 10px; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 800; font-size: 12px; letter-spacing: .02em; }
.file-meta { flex: 1; min-width: 0; }
.file-name { font-weight: 600; font-size: 14px; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; display: flex; align-items: center; gap: 6px; }
.file-dl { flex-shrink: 0; display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 999px; border: none; background: var(--text-primary); color: #111; font-size: 13px; font-weight: 600; cursor: pointer; }
.file-dl:hover { opacity: .88; }
.file-dl:disabled { opacity: .7; cursor: default; }
.file-card.loading { opacity: .85; }
.export-overlay { position: fixed; inset: 0; z-index: 9998; }
.export-menu { position: fixed; z-index: 9999; width: 210px; padding: 6px; background: #1f1f1f; border: 1px solid rgba(255,255,255,.12); border-radius: 12px; box-shadow: 0 16px 40px rgba(0,0,0,.5); }
.export-title { padding: 6px 10px 8px; font-size: 11.5px; color: var(--text-muted); }
.export-menu button { display: block; width: 100%; text-align: left; padding: 9px 10px; border: none; background: none; border-radius: 8px; color: var(--text-primary); font-size: 13.5px; cursor: pointer; }
.export-menu button:hover { background: var(--bg-hover); }

/* ── Ditado pelo microfone (onda + ✕ / ✓, igual ao ChatGPT) ── */
#mic-btn[hidden] { display: none; }
.rec-bar { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.rec-bar[hidden] { display: none; }
.composer.recording .composer-left, .composer.recording .composer-right { display: none; }
.rec-wave { flex: 1; min-width: 0; height: 28px; color: var(--text-primary); }
.rec-time { font-size: 13px; color: var(--text-muted); font-variant-numeric: tabular-nums; min-width: 34px; text-align: right; }
.rec-busy { display: none; flex: 1; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text-muted); }
.rec-bar.busy .rec-wave, .rec-bar.busy .rec-time { display: none; }
.rec-bar.busy .rec-busy { display: flex; }
.rec-bar.busy #rec-done { opacity: .5; pointer-events: none; }

/* ── Aviso de versão nova (extensão / app Windows) ── */
.update-bar { position: fixed; top: 44px; left: 50%; transform: translateX(-50%); z-index: 9000; display: flex; align-items: center; gap: 12px; padding: 7px 8px 7px 16px; background: #1f1f1f; border: 1px solid rgba(255,255,255,.14); border-radius: 999px; box-shadow: 0 10px 30px rgba(0,0,0,.45); font-size: 13.5px; color: var(--text-primary); white-space: nowrap; }
.update-bar a { padding: 6px 14px; border-radius: 999px; background: var(--text-primary); color: #111; font-weight: 600; text-decoration: none; }
.update-bar a:hover { opacity: .88; }
.update-bar button { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 13px; padding: 4px 6px; }
.update-bar button:hover { color: #fff; }
