:root, html[data-theme="dark"] {
  color-scheme: dark;
  --bg-main: #212121;
  --bg-sidebar: #171717;
  --bg-surface: #2f2f2f;
  --bg-surface-2: #262626;
  --bg-hover: #2a2a2a;
  --bg-hover-strong: #383838;
  --bg-composer: #2f2f2f;
  --bg-user-bubble: #2f2f2f;
  --bg-modal: #262626;
  --bg-input: #1b1b1b;
  --bg-code: #0d0d0d;
  --bg-code-head: #2f2f2f;
  --text-primary: #ececec;
  --text-secondary: #b4b4b4;
  --text-muted: #8e8e8e;
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --send-bg: #ffffff;
  --send-fg: #0d0d0d;
  --send-disabled-bg: #4a4a4a;
  --send-disabled-fg: #212121;
  --accent: #10a37f;
  --accent-soft: rgba(16, 163, 127, 0.14);
  --shadow-composer: 0 2px 12px rgba(0, 0, 0, 0.22);
  --scrollbar-thumb: rgba(255, 255, 255, 0.16);
  --scrollbar-thumb-hover: rgba(255, 255, 255, 0.28);
}

html[data-theme="light"] {
  color-scheme: light;
  --bg-main: #ffffff;
  --bg-sidebar: #f9f9f9;
  --bg-surface: #f4f4f4;
  --bg-surface-2: #efefef;
  --bg-hover: #ececec;
  --bg-hover-strong: #e3e3e3;
  --bg-composer: #f4f4f4;
  --bg-user-bubble: #f4f4f4;
  --bg-modal: #ffffff;
  --bg-input: #f9f9f9;
  --bg-code: #1e1e1e;
  --bg-code-head: #2d2d2d;
  --text-primary: #0d0d0d;
  --text-secondary: #5d5d5d;
  --text-muted: #787878;
  --border-subtle: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.15);
  --send-bg: #0d0d0d;
  --send-fg: #ffffff;
  --send-disabled-bg: #d7d7d7;
  --send-disabled-fg: #ffffff;
  --accent: #10a37f;
  --accent-soft: rgba(16, 163, 127, 0.10);
  --shadow-composer: 0 2px 12px rgba(0, 0, 0, 0.06);
  --scrollbar-thumb: rgba(0, 0, 0, 0.16);
  --scrollbar-thumb-hover: rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }
html, body {
  height: 100%;
  margin: 0;
  background-color: var(--bg-main);
  color: var(--text-primary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* Scrollbar minimalista estilo ChatGPT */
.gpt-scroll::-webkit-scrollbar { width: 6px; height: 6px; }
.gpt-scroll::-webkit-scrollbar-track { background: transparent; }
.gpt-scroll::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 999px; }
.gpt-scroll::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-thumb-hover); }

/* Sidebar transitions */
#app-sidebar {
  width: 260px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  transition: margin-left 0.22s cubic-bezier(0.4, 0, 0.2, 1), transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
}
body.sidebar-collapsed #app-sidebar {
  margin-left: -260px;
}
@media (max-width: 768px) {
  #app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 45;
    margin-left: 0 !important;
    transform: translateX(-100%);
  }
  body.mobile-sidebar-open #app-sidebar {
    transform: translateX(0);
  }
  body.mobile-sidebar-open #mobile-backdrop {
    display: block;
  }
}

/* Markdown rendering estilo ChatGPT */
.gpt-prose {
  color: var(--text-primary);
  font-size: 0.96rem;
  line-height: 1.7;
  word-break: break-word;
}
.gpt-prose > *:first-child { margin-top: 0; }
.gpt-prose > *:last-child { margin-bottom: 0; }
.gpt-prose p { margin: 0.65rem 0; }
.gpt-prose h1, .gpt-prose h2, .gpt-prose h3, .gpt-prose h4 {
  color: var(--text-primary);
  font-weight: 600;
  margin: 1.15rem 0 0.45rem;
  line-height: 1.35;
}
.gpt-prose h1 { font-size: 1.25rem; }
.gpt-prose h2 { font-size: 1.12rem; }
.gpt-prose h3 { font-size: 1rem; }
.gpt-prose ul, .gpt-prose ol { margin: 0.6rem 0; padding-left: 1.4rem; }
.gpt-prose ul { list-style-type: disc; }
.gpt-prose ol { list-style-type: decimal; }
.gpt-prose li { margin: 0.28rem 0; }
.gpt-prose li > p { margin: 0.2rem 0; }
.gpt-prose ul ul, .gpt-prose ol ol, .gpt-prose ul ol, .gpt-prose ol ul { margin: 0.25rem 0; }
.gpt-prose ul.task-list, .gpt-prose ol.task-list { list-style: none; padding-left: 0.2rem; }
.gpt-prose li.task-list-item { list-style: none; display: flex; align-items: flex-start; gap: 0.5rem; }
.gpt-prose li.task-list-item > input[type="checkbox"] { margin-top: 0.35rem; accent-color: var(--accent); }
.gpt-prose strong { font-weight: 600; color: var(--text-primary); }
.gpt-prose a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.gpt-prose hr { border: 0; border-top: 1px solid var(--border-subtle); margin: 1.1rem 0; }
.gpt-prose blockquote {
  border-left: 3px solid var(--border-strong);
  padding-left: 0.9rem;
  color: var(--text-secondary);
  margin: 0.75rem 0;
}
.gpt-prose code {
  background: var(--bg-surface);
  padding: 0.14rem 0.38rem;
  border-radius: 6px;
  font-size: 0.85em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}
.gpt-prose pre {
  background: var(--bg-code);
  color: #e5e5e5;
  border-radius: 12px;
  overflow: hidden;
  margin: 0.85rem 0;
  border: 1px solid var(--border-subtle);
}
.gpt-prose pre .code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-code-head);
  color: #b4b4b4;
  font-size: 0.72rem;
  padding: 0.4rem 0.85rem;
  font-family: ui-sans-serif, system-ui, sans-serif;
}
.gpt-prose pre code {
  display: block;
  background: transparent;
  padding: 0.85rem 1rem;
  overflow-x: auto;
  font-size: 0.84rem;
  line-height: 1.55;
  color: #e5e5e5;
}
.gpt-prose .table-wrap {
  overflow-x: auto;
  margin: 0.85rem 0;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
}
.gpt-prose .table-wrap table {
  margin: 0;
  border: 0;
  border-radius: 0;
  min-width: 520px;
}
.gpt-prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.85rem 0;
  font-size: 0.86rem;
  border-radius: 10px;
  overflow: hidden;
}
.gpt-prose th, .gpt-prose td {
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.55rem 0.75rem;
  text-align: left;
  white-space: nowrap;
}
.gpt-prose td:nth-child(1), .gpt-prose th:nth-child(1) { white-space: normal; min-width: 140px; }
.gpt-prose th {
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-surface);
}
.gpt-prose tr:last-child td { border-bottom: none; }

/* Surfaces and buttons */
.hidden { display: none !important; }
.gpt-icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: background-color 0.15s ease, color 0.15s ease;
  cursor: pointer;
}
.gpt-icon-btn:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}
.gpt-side-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 13.5px;
  color: var(--text-primary);
  transition: background-color 0.14s ease;
  text-align: left;
  cursor: pointer;
}
.gpt-side-item:hover { background-color: var(--bg-hover); }
.gpt-side-item.active { background-color: var(--bg-hover-strong); }

.gpt-surface {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
}
.gpt-modal-card {
  background-color: var(--bg-modal);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
}
.gpt-input {
  background-color: var(--bg-input);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
}
.gpt-input:focus {
  outline: none;
  border-color: var(--text-secondary);
}
.gpt-input::placeholder { color: var(--text-muted); }

/* Thinking pulse dot */
@keyframes gptPulse {
  0%, 100% { transform: scale(0.85); opacity: 0.45; }
  50% { transform: scale(1.1); opacity: 1; }
}
.gpt-pulse-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--text-primary);
  animation: gptPulse 1.2s ease-in-out infinite;
}

/* Composer */
.composer-shell {
  background-color: var(--bg-composer);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-composer);
  border-radius: 26px;
  transition: border-color 0.15s ease;
}
.composer-shell:focus-within {
  border-color: var(--border-strong);
}
#submit-btn {
  width: 34px;
  height: 34px;
  border-radius: 9999px;
  background-color: var(--send-bg);
  color: var(--send-fg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s ease, transform 0.12s ease, background-color 0.15s ease;
  flex-shrink: 0;
}
#submit-btn:disabled {
  background-color: var(--send-disabled-bg);
  color: var(--send-disabled-fg);
  cursor: default;
  opacity: 0.85;
}
#submit-btn:not(:disabled):hover {
  opacity: 0.88;
}

/* Novo chat em destaque + hover interativo (linha full-width padrão nav-list) */
.new-chat-btn {
  font-weight: 500;
  color: var(--text-primary);
  background: var(--accent-soft);
  border: 1px solid var(--border-subtle);
  transition: transform 0.15s ease, background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.new-chat-btn:hover {
  transform: translateY(-1px);
  background: var(--bg-hover-strong);
  border-color: var(--accent);
  box-shadow: 0 2px 10px rgba(16, 163, 127, 0.28);
}
.new-chat-btn:active { transform: translateY(0) scale(0.99); }
.new-chat-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.new-chat-btn svg { flex-shrink: 0; }

/* Estrela de favoritar conversa */
.fav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 7px;
  transition: background-color 0.14s ease, transform 0.12s ease;
  cursor: pointer;
}
.fav-btn:hover { background: var(--bg-hover-strong); transform: scale(1.12); }
.fav-btn.fav-on { opacity: 1 !important; color: var(--accent) !important; }
.fav-btn.fav-off { color: var(--text-muted); }
