body {
  font-family: 'Inter', var(--font);
  height: 100vh;
  overflow: hidden;
  display: flex;
}

#sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--bg-raised);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: margin-left 0.18s ease;
}

#sidebar.collapsed {
  margin-left: -260px;
}

.sb-head {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 18px 16px;
  font-weight: 700;
  font-size: 14px;
}

.sb-head img {
  width: 20px;
  height: 20px;
  border-radius: 5px;
}

.sb-new {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 12px 14px;
  height: 36px;
  padding: 0 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  transition: border-color 0.15s ease;
}

.sb-new:hover {
  border-color: var(--gold-dim);
}

.sb-section-label {
  padding: 0 16px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 6px;
}

#history {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px;
}

.hi {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 7px;
  font-size: 13px;
  color: var(--text-dim);
  cursor: pointer;
  transition: background 0.12s ease;
}

.hi:hover {
  background: rgba(255, 255, 255, 0.04);
}

.hi.active {
  background: var(--gold-soft);
  color: var(--text);
}

.hi-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hi-del {
  opacity: 0;
  background: none;
  border: none;
  color: var(--text-faint);
  font-size: 13px;
  padding: 2px 4px;
}

.hi:hover .hi-del {
  opacity: 1;
}

.hi-del:hover {
  color: var(--danger);
}

.hi-empty {
  padding: 10px;
  font-size: 12.5px;
  color: var(--text-faint);
}

.sb-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
}

.sb-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--gold-soft);
  color: var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sb-foot-info {
  flex: 1;
  min-width: 0;
}

.sb-user-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sb-user-tier {
  font-size: 11.5px;
  color: var(--text-faint);
}

.sb-user-tier a {
  color: var(--gold);
}

.sb-user-tier a:hover {
  text-decoration: underline;
}

#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

#topbar {
  height: 56px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
}

.tb-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.tb-toggle {
  background: none;
  border: none;
  color: var(--text-dim);
  padding: 6px;
  border-radius: 6px;
}

.tb-toggle:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

.tb-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-dim);
}

.tb-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tb-icon-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  color: var(--text-faint);
}

.tb-icon-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-dim);
}

#chat-area {
  flex: 1;
  overflow-y: auto;
}

#welcome {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  text-align: center;
}

.wlc-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--gold-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
}

.wlc-icon img {
  width: 24px;
  height: 24px;
}

.wlc-heading {
  font-size: 26px;
  font-weight: 800;
  margin: 0 0 8px;
  letter-spacing: -0.01em;
}

.wlc-sub {
  font-size: 14px;
  color: var(--text-dim);
  margin: 0 0 26px;
}

.cat-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.cat-pill {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-dim);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 7px 15px;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.cat-pill:hover {
  border-color: var(--gold-dim);
  color: var(--text);
}

#messages {
  max-width: 760px;
  margin: 0 auto;
  padding: 28px 20px 12px;
  display: none;
}

.msg {
  display: flex;
  gap: 12px;
  margin-bottom: 22px;
}

.msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
}

.msg.user .msg-avatar {
  background: var(--bg-card);
  color: var(--text-dim);
  border: 1px solid var(--border);
}

.msg.ai .msg-avatar {
  background: var(--gold-soft);
  color: var(--gold);
  overflow: hidden;
  padding: 0;
}

.msg.ai .msg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.msg-body {
  flex: 1;
  min-width: 0;
  padding-top: 4px;
}

.msg-name {
  font-size: 12.5px;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--text-dim);
}

.msg-text {
  font-size: 14.5px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.msg-files {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.msg-file-chip {
  font-size: 11.5px;
  color: var(--text-dim);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
}

.typing-dots {
  display: flex;
  gap: 4px;
  padding-top: 6px;
}

.typing-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-faint);
  animation: typingBlink 1.2s infinite ease-in-out;
}

.typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes typingBlink {
  0%, 80%, 100% { opacity: 0.25; }
  40% { opacity: 1; }
}

#input-wrap {
  padding: 14px 20px 18px;
  max-width: 760px;
  margin: 0 auto;
  width: 100%;
}

.input-box {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 10px 12px 8px;
  transition: border-color 0.15s ease;
}

.input-box:focus-within {
  border-color: var(--gold-dim);
}

#strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}

.strip-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--text-dim);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
}

.strip-chip button {
  background: none;
  border: none;
  color: var(--text-faint);
  font-size: 11px;
  padding: 0;
}

#ta {
  width: 100%;
  border: none;
  background: none;
  color: var(--text);
  font-size: 14.5px;
  font-family: inherit;
  resize: none;
  outline: none;
  max-height: 200px;
  padding: 4px 2px;
}

#ta::placeholder {
  color: var(--text-faint);
}

.input-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
}

.input-left, .input-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ib-btn {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-faint);
  border-radius: 7px;
}

.ib-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-dim);
}

.model-pill {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 10px;
  background: var(--bg-raised);
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  font-size: 12px;
  cursor: pointer;
}

.pill-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold);
}

.pill-name {
  font-weight: 600;
}

.pill-provider {
  color: var(--text-faint);
  font-size: 11px;
}

.pill-chev {
  color: var(--text-faint);
}

.model-menu {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  width: 300px;
  max-height: 380px;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 8px;
  z-index: 30;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
}

.model-menu.open {
  display: block;
}

.model-section {
  margin-bottom: 10px;
}

.model-section-label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  margin-bottom: 2px;
}

.provider-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--gold-soft);
  color: var(--gold);
}

.provider-badge.badge-github {
  background: #0d1117;
  color: #f0f6fc;
  border: 1px solid #30363d;
}

.provider-badge.badge-groq {
  background: rgba(249, 115, 22, 0.16);
  color: #f97316;
  border: 1px solid rgba(249, 115, 22, 0.35);
}

.provider-badge.badge-nvidia {
  background: rgba(118, 185, 0, 0.16);
  color: #76b900;
  border: 1px solid rgba(118, 185, 0, 0.35);
}

/* Badge Best — couleur or avec étoile */
.provider-badge.badge-best {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(234, 179, 8, 0.15);
  color: #eab308;
  border: 1px solid rgba(234, 179, 8, 0.35);
}

.model-section-best {
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
  padding-bottom: 4px;
}

.provider-desc {
  font-size: 10.5px;
  color: var(--text-faint);
}

.model-option {
  display: flex;
  flex-direction: column;
  padding: 7px 8px;
  border-radius: 6px;
  font-size: 12.5px;
  cursor: pointer;
}

.model-option:hover {
  background: rgba(255, 255, 255, 0.05);
}

.model-option.selected {
  background: var(--gold-soft);
}

.model-option .mo-name {
  font-weight: 600;
}

.model-option .mo-sub {
  font-size: 11px;
  color: var(--text-faint);
}

.mo-empty {
  padding: 10px 8px;
  font-size: 11.5px;
  color: var(--text-faint);
  font-style: italic;
}

.send-btn {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gold);
  border: none;
  border-radius: 7px;
  color: #16140b;
}

.send-btn:disabled {
  background: var(--bg-raised);
  color: var(--text-faint);
}

.disclaimer {
  text-align: center;
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 10px;
}

#error-toast {
  display: none;
  align-items: flex-start;
  gap: 10px;
  max-width: 760px;
  margin: 0 auto 10px;
  padding: 11px 14px;
  background: rgba(209, 100, 100, 0.1);
  border: 1px solid rgba(209, 100, 100, 0.3);
  border-radius: 9px;
}

#error-toast.show {
  display: flex;
}

.err-icon {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--danger);
  color: #1a0d0d;
  font-size: 11px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.err-body {
  flex: 1;
}

.err-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--danger);
}

.err-msg {
  font-size: 12px;
  color: var(--text-dim);
}

.err-close {
  background: none;
  border: none;
  color: var(--text-faint);
  font-size: 13px;
}

#recaptcha-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
}

#recaptcha-overlay.ts-visible {
  display: flex;
}

.ts-card {
  width: 340px;
  max-width: calc(100vw - 32px);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px 20px;
  text-align: center;
}

.ts-title {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 6px;
}

.ts-subtitle {
  font-size: 12.5px;
  color: var(--text-dim);
  margin: 0 0 16px;
}

#recaptcha-widget {
  display: flex;
  justify-content: center;
  min-height: 65px;
}

.ts-bypassed {
  font-size: 12.5px;
  color: var(--text-dim);
  padding: 14px 0;
}

.ts-err {
  font-size: 12.5px;
  color: var(--danger);
  margin-top: 10px;
}

@media (max-width: 720px) {
  #sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 50;
  }
  #sidebar.collapsed {
    margin-left: -260px;
  }
}
