:root {
  /* ── NVIDIA GAMER PALETTE ── */
  --bg:        #000000;
  --bg2:       #080808;
  --bg3:       #0f0f0f;
  --bg4:       #141414;
  --bg5:       #1a1a1a;
  --border:    rgba(0,102,204,0.1);
  --border2:   rgba(0,102,204,0.2);
  --border3:   rgba(0,102,204,0.35);
  --accent:    #0066cc;
  --accent2:   #0080ff;
  --accent3:   #33aaff;
  --accent-rgb: 0,102,204;
  --teal:      #0066cc;
  --teal2:     #33aaff;
  --teal-rgb:  0,102,204;
  --text:      #ffffff;
  --text2:     #a0a0a0;
  --text3:     #505050;
  --danger:    #ff4444;
  --success:   #0066cc;
  --warning:   #ffaa00;
  --user-glow: rgba(0,102,204,0.18);
  --ai-glow:   rgba(0,102,204,0.09);
  --r:         6px;
  --r2:        10px;
  --r3:        14px;
  --shadow:    0 8px 40px rgba(0,0,0,0.9);
  --shadow2:   0 24px 80px rgba(0,0,0,0.95);
  --glow-accent: 0 0 20px rgba(0,102,204,0.6), 0 0 80px rgba(0,102,204,0.25);
  --glow-teal:   0 0 20px rgba(0,102,204,0.5), 0 0 80px rgba(0,102,204,0.2);
  --font:      'Inter', system-ui, -apple-system, sans-serif;
  --mono:      'Geist Mono', 'Fira Code', monospace, 'JetBrains Mono', monospace;
  --trans:     all 0.2s cubic-bezier(0.4,0,0.2,1);
  --trans-slow: all 0.45s cubic-bezier(0.4,0,0.2,1);
  --trans-spring: all 0.4s cubic-bezier(0.34,1.56,0.64,1);
  --trans-fast: all 0.12s cubic-bezier(0.4,0,0.2,1);
  --blur:      blur(16px) saturate(220%);
  --blur2:     blur(24px) saturate(250%);
  --scanline: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,102,204,0.015) 2px,
    rgba(0,102,204,0.015) 4px
  );
}
.light {
  --bg:      #f4f4f8;
  --bg2:     #ffffff;
  --bg3:     #f0f0f5;
  --bg4:     #e8e8f0;
  --border:  rgba(0,0,0,0.07);
  --border2: rgba(0,0,0,0.12);
  --text:    #1a1830;
  --text2:   #6b6890;
  --text3:   #a8a6c0;
  --user-glow: rgba(0,102,204,0.08);
  --ai-glow:   rgba(0,102,204,0.05);
  --shadow:  0 8px 32px rgba(0,0,0,0.1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
body {
  font-size: 17px;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* ══════════════════════════════════════════════════════════
   LOGIN
══════════════════════════════════════════════════════════ */
#login-screen { display: none; }
#login-screen.visible {
  display: flex; align-items: center; justify-content: center;
  height: 100vh; position: relative; overflow: hidden;
  background: #07070e url('/static/img/back.jpg') center/cover no-repeat;
}
#login-screen::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse 80% 70% at 50% 50%, rgba(0,0,0,0.75) 0%, rgba(0,0,0,0.92) 100%);
}
.login-grid {
  position: absolute; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    linear-gradient(rgba(0,102,204,0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,102,204,0.05) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 70% 70% at 50% 50%, black 20%, transparent 100%);
  -webkit-mask-image: radial-gradient(ellipse 70% 70% at 50% 50%, black 20%, transparent 100%);
  animation: gridPulse 6s ease-in-out infinite alternate;
}
@keyframes gridPulse { from { opacity:.4; } to { opacity:1; } }
.login-particles { position: absolute; inset: 0; pointer-events: none; z-index: 0; }
.lp { position: absolute; border-radius: 50%; animation: lpFloat linear infinite; }
.lp1 { width:3px;height:3px;background:var(--accent2);left:15%;top:20%;opacity:.6;animation-duration:8s;animation-delay:0s; }
.lp2 { width:2px;height:2px;background:var(--teal2);left:75%;top:60%;opacity:.5;animation-duration:11s;animation-delay:-3s; }
.lp3 { width:4px;height:4px;background:var(--accent3);left:55%;top:15%;opacity:.4;animation-duration:14s;animation-delay:-6s; }
.lp4 { width:2px;height:2px;background:var(--teal);left:30%;top:75%;opacity:.5;animation-duration:9s;animation-delay:-2s; }
.lp5 { width:3px;height:3px;background:var(--accent);left:85%;top:30%;opacity:.4;animation-duration:12s;animation-delay:-5s; }
.lp6 { width:2px;height:2px;background:var(--teal2);left:45%;top:85%;opacity:.6;animation-duration:10s;animation-delay:-1s; }
@keyframes lpFloat {
  0%   { transform: translateY(0) scale(1); opacity:.6; }
  50%  { transform: translateY(-40px) scale(1.4); opacity:1; }
  100% { transform: translateY(0) scale(1); opacity:.6; }
}
@keyframes ambientShift {
  from { opacity: 0.8; transform: scale(1); }
  to   { opacity: 1;   transform: scale(1.05); }
}
.login-box {
  position: relative; z-index: 2;
  background: rgba(8,8,18,0.78);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 28px;
  padding: 0 0 36px;
  width: 440px;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.04) inset,
              0 40px 100px rgba(0,0,0,0.85),
              0 0 80px rgba(0,102,204,0.1);
  animation: loginIn 0.7s cubic-bezier(0.34,1.15,0.64,1);
  overflow: hidden;
}
@keyframes loginIn {
  from { opacity:0; transform: translateY(48px) scale(0.93); filter: blur(16px); }
  to   { opacity:1; transform: none; filter: blur(0); }
}
.login-top-bar {
  height: 3px; width: 100%;
  background: linear-gradient(90deg, var(--accent), var(--teal), var(--accent2), var(--accent));
  background-size: 300% 100%;
  animation: barShimmer 4s ease infinite;
}
@keyframes barShimmer {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
.login-box > *:not(.login-top-bar):not(.login-logo-wrap) { padding-left: 44px; padding-right: 44px; }
.login-logo-wrap {
  position: relative; width: 92px; height: 92px;
  margin: 36px auto 20px; display: flex; align-items: center; justify-content: center;
}
.login-logo-ring {
  position: absolute; inset: 0; border-radius: 50%;
  border: 1.5px solid transparent;
  border-top-color: var(--accent); border-right-color: rgba(124,106,247,0.3);
  animation: nvSpin 2.5s linear infinite;
}
.login-logo-ring::before {
  content: ''; position: absolute; inset: 5px; border-radius: 50%;
  border: 1px solid transparent;
  border-bottom-color: var(--teal); border-left-color: rgba(45,212,191,0.3);
  animation: nvSpin 1.8s linear infinite reverse;
}
.login-logo {
  width: 64px; height: 64px; border-radius: 18px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,102,204,0.1); border: 1px solid rgba(0,102,204,0.22);
  filter: drop-shadow(0 0 20px rgba(0,102,204,0.6));
  animation: logoPulse 4s ease-in-out infinite;
  position: relative; z-index: 1; margin: 0;
}
@keyframes logoPulse {
  0%,100% { filter: drop-shadow(0 0 20px rgba(0,102,204,0.6)); }
  50%      { filter: drop-shadow(0 0 36px rgba(124,106,247,0.95)) drop-shadow(0 0 12px rgba(45,212,191,0.5)); }
}
.login-logo img { width: 44px; height: 44px; object-fit: contain; }
.login-badge {
  text-align: center; font-size: .6rem; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--accent2); margin-bottom: 16px; opacity: 0.75;
}
.login-box h1 {
  text-align: center; font-size: 1.75rem; font-weight: 700;
  margin-bottom: 8px; letter-spacing: -0.04em;
  background: linear-gradient(135deg, #fff 0%, var(--accent3) 60%, var(--teal2) 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.login-box p {
  text-align: center; color: var(--text2); font-size: .85rem;
  margin-bottom: 28px; line-height: 1.6;
}
.login-footer {
  display: flex; align-items: center; justify-content: center;
  gap: 8px; margin-top: 20px;
  font-size: .68rem; color: var(--text3); letter-spacing: 0.02em;
}
}
.input-group svg {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--text3); pointer-events: none; width: 16px; height: 16px;
}
/* Cache icône cadenas natif Chrome/Firefox */
input[type="password"]::-webkit-credentials-auto-fill-button,
input[type="password"]::-webkit-strong-password-auto-fill-button,
input[type="password"]::-webkit-contacts-auto-fill-button { display: none !important; visibility: hidden; }
input[type="password"]::-ms-reveal,
input[type="password"]::-ms-clear { display: none; }

.input-group input {
  width: 100%; padding: 13px 16px;
  border-radius: 10px; border: 1px solid var(--border2);
  background: var(--bg3); color: var(--text);
  font-size: .9rem; font-family: var(--font);
  outline: none; transition: var(--trans);
}
.input-group input:focus {
  border-color: var(--accent); background: var(--bg4);
  box-shadow: 0 0 0 3px rgba(0,102,204,0.15);
}
.btn-primary {
  width: 100%; padding: 14px; border-radius: 14px; border: none;
  background: transparent;
  color: #fff; font-size: .9rem; font-weight: 600;
  cursor: pointer; transition: var(--trans);
  margin-top: 8px; letter-spacing: 0.02em;
  position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  box-shadow: 0 4px 24px rgba(0,102,204,0.4), inset 0 1px 0 rgba(255,255,255,0.15);
}
.btn-primary-bg {
  position: absolute; inset: 0;
  background: linear-gradient(135deg, var(--accent) 0%, #0055bb 50%, var(--teal) 100%);
  background-size: 200% 200%;
  animation: btnGradient 4s ease infinite;
  transition: var(--trans);
}
@keyframes btnGradient {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
.btn-primary span { position: relative; z-index: 1; }
.btn-primary svg  { position: relative; z-index: 1; }
.btn-primary::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(105deg, transparent 40%, rgba(255,255,255,0.12) 50%, transparent 60%);
  transform: translateX(-100%);
  transition: transform 0.6s ease;
  z-index: 1;
}
.btn-primary:hover::after { transform: translateX(100%); }
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 36px rgba(0,102,204,0.55), 0 0 60px rgba(0,102,204,0.2), inset 0 1px 0 rgba(255,255,255,0.2);
}
.btn-primary:active { transform: translateY(0); box-shadow: 0 4px 16px rgba(0,102,204,0.4); }
.retry-btn {
  display: inline-block; margin-top: 6px; padding: 4px 14px;
  border-radius: 6px; border: 1px solid var(--border2);
  background: var(--bg3); color: var(--accent2);
  font-size: .78rem; font-family: var(--font); cursor: pointer;
  transition: var(--trans);
}
.retry-btn:hover { background: var(--bg4); border-color: var(--accent); color: var(--accent3); }
.login-error {
  color: var(--danger); font-size: .8rem; margin-top: 10px;
  text-align: center; min-height: 18px;
}

/* ══════════════════════════════════════════════════════════
   APP LAYOUT
══════════════════════════════════════════════════════════ */
#app {
  display: none; flex: 1; flex-direction: row;
  height: 100vh; overflow: hidden;
}

/* ══════════════════════════════════════════════════════════
   SIDEBAR
══════════════════════════════════════════════════════════ */
#sidebar {
  width: 272px; min-width: 272px;
  background: rgba(14,14,26,0.85);
  backdrop-filter: blur(10px);
  border-right: 1px solid rgba(0,102,204,0.2);
  display: flex; flex-direction: column;
  overflow: hidden;
  transition: transform 0.35s cubic-bezier(0.4,0,0.2,1);
  box-shadow: 1px 0 0 rgba(255,255,255,0.03);
  position: relative;
  z-index: 100;
}
.sidebar-header {
  padding: 20px 14px 14px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(0,102,204,0.04) 0%, transparent 100%);
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px; margin-bottom: 14px;
}
.brand-icon {
  width: 34px; height: 34px;
  background: transparent;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: var(--trans-spring);
  filter: drop-shadow(0 0 10px rgba(0,102,204,0.7));
}
.brand-icon:hover {
  filter: drop-shadow(0 0 18px rgba(0,102,204,1.0));
  transform: scale(1.1) rotate(-4deg);
}
.brand-icon img { width: 34px; height: 34px; object-fit: contain; }
.brand-text { font-size: .78rem; font-weight: 700; letter-spacing: 0.06em; color: var(--text3); text-transform: uppercase; }
.btn-new {
  width: 100%; padding: 10px 14px;
  border-radius: 12px; border: 1px solid var(--border2);
  background: linear-gradient(135deg, rgba(0,102,204,0.08), rgba(0,102,204,0.04));
  color: var(--text2);
  cursor: pointer; font-size: .82rem; font-family: var(--font); font-weight: 500;
  transition: var(--trans);
  display: flex; align-items: center; gap: 9px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05), 0 2px 8px rgba(0,0,0,0.2);
  position: relative; overflow: hidden;
}
.btn-new::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(105deg, transparent 40%, rgba(255,255,255,0.06) 50%, transparent 60%);
  transform: translateX(-100%);
  transition: transform 0.5s ease;
}
.btn-new:hover::after { transform: translateX(100%); }
.btn-new:hover {
  border-color: rgba(0,102,204,0.5); color: var(--accent2);
  background: rgba(0,102,204,0.12);
  box-shadow: 0 4px 20px rgba(0,102,204,0.2), inset 0 1px 0 rgba(255,255,255,0.08);
  transform: translateY(-1px);
}
.btn-new:active { transform: translateY(0); }
.btn-new svg { width: 15px; height: 15px; flex-shrink: 0; }
.conv-list { flex: 1; overflow-y: auto; padding: 8px 6px; }
.conv-section-label {
  font-size: .65rem; font-weight: 700; letter-spacing: 0.1em;
  color: var(--text3); text-transform: uppercase;
  padding: 10px 10px 4px; margin-top: 4px;
}
.conv-item {
  padding: 9px 10px; border-radius: 10px; cursor: pointer;
  margin-bottom: 1px; display: flex; align-items: center; gap: 8px;
  transition: var(--trans); position: relative; overflow: hidden;
  border: 1px solid transparent;
}
.conv-item:hover {
  background: rgba(255,255,255,0.04);
  border-color: var(--border);
}
.conv-item.active {
  background: linear-gradient(135deg, rgba(0,102,204,0.14), rgba(0,102,204,0.07));
  border-color: rgba(0,102,204,0.22);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05), 0 2px 12px rgba(0,102,204,0.1);
}
.conv-item.active::before {
  content: ''; position: absolute; left: 0; top: 15%; bottom: 15%;
  width: 2.5px;
  background: linear-gradient(180deg, var(--accent3), var(--accent));
  border-radius: 99px;
  box-shadow: 0 0 8px var(--accent);
}
.conv-item.active::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(105deg, transparent 40%, rgba(255,255,255,0.03) 50%, transparent 60%);
  animation: shimmer 3s ease-in-out infinite;
}
@keyframes shimmer {
  0%   { transform: translateX(-100%); }
  60%,100% { transform: translateX(100%); }
}
.conv-dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--text3); flex-shrink: 0;
  transition: var(--trans);
}
.conv-item.active .conv-dot {
  background: var(--accent2);
  box-shadow: 0 0 6px var(--accent), 0 0 12px rgba(0,102,204,0.4);
}
.conv-title {
  font-size: .82rem; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; flex: 1;
  color: var(--text2); transition: var(--trans);
}
.conv-item:hover .conv-title { color: var(--text); }
.conv-item.active .conv-title { color: var(--text); font-weight: 500; }
.conv-del {
  color: var(--text3); font-size: .7rem; opacity: 0;
  padding: 4px 6px; border-radius: 6px; border: none;
  background: none; cursor: pointer;
  transition: var(--trans); flex-shrink: 0;
  display: flex; align-items: center;
}
.conv-item:hover .conv-del { opacity: 1; }
.conv-del:hover { color: var(--danger); background: rgba(248,113,113,0.1); }
.conv-del svg { width: 12px; height: 12px; }
.sidebar-footer {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: linear-gradient(0deg, rgba(0,102,204,0.03) 0%, transparent 100%);
}
.footer-row {
  display: flex; gap: 2px; align-items: center;
  padding: 2px 0;
}
.btn-icon {
  background: none; border: none; color: var(--text3);
  cursor: pointer; padding: 8px; border-radius: 10px;
  font-size: 1rem; transition: var(--trans);
  display: flex; align-items: center; justify-content: center;
  position: relative;
}
.btn-icon svg { width: 17px; height: 17px; transition: var(--trans); }
.btn-icon:hover {
  background: rgba(255,255,255,0.06);
  color: var(--text);
  box-shadow: 0 2px 10px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.05);
  transform: translateY(-1px);
}
.btn-icon:active { transform: translateY(0); box-shadow: none; }
.btn-icon.active { color: var(--accent); background: rgba(0,102,204,0.12); box-shadow: 0 0 12px rgba(0,102,204,0.15); }
.btn-icon[title]:hover::after {
  content: attr(title);
  position: absolute; bottom: calc(100% + 8px); left: 50%;
  transform: translateX(-50%);
  background: var(--bg5); color: var(--text);
  font-size: .68rem; font-family: var(--font);
  padding: 5px 10px; border-radius: 8px;
  border: 1px solid var(--border3);
  white-space: nowrap; pointer-events: none;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  z-index: 100;
  animation: tooltipIn 0.15s cubic-bezier(0.4,0,0.2,1);
}
@keyframes tooltipIn {
  from { opacity:0; transform: translateX(-50%) translateY(4px); }
  to   { opacity:1; transform: translateX(-50%) translateY(0); }
}

/* ══════════════════════════════════════════════════════════
   MAIN
══════════════════════════════════════════════════════════ */
#main { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

/* ── CONFIG BAR ── */
#config-bar {
  padding: 10px 20px;
  background: rgba(14,14,26,0.88);
  border-bottom: 1px solid transparent;
  background-clip: padding-box;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.06),
    0 4px 24px rgba(0,0,0,0.5),
    inset 0 -1px 0 rgba(255,255,255,0.03);
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  min-height: 60px;
  position: sticky; top: 0; z-index: 10;
}
#config-bar::before {
  content: '';
  position: absolute; inset-inline: 0; bottom: 0; height: 1px;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(0,102,204,0.35) 30%,
    rgba(0,102,204,0.2) 70%,
    transparent 100%);
  pointer-events: none;
}
.select-wrap { display: flex; flex-direction: column; gap: 3px; }
.select-wrap label {
  font-size: .65rem; font-weight: 600;
  color: var(--text3); text-transform: uppercase; letter-spacing: 0.08em;
}
.custom-select {
  position: relative; display: inline-block;
}
.custom-select select {
  padding: 7px 32px 7px 12px;
  border-radius: 10px;
  border: 1px solid var(--border2);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  font-size: .82rem; font-family: var(--font);
  cursor: pointer; outline: none;
  appearance: none; -webkit-appearance: none;
  transition: var(--trans);
  min-width: 150px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05), 0 2px 8px rgba(0,0,0,0.2);
}
.custom-select select:hover {
  border-color: rgba(0,102,204,0.45);
  background: rgba(0,102,204,0.07);
  box-shadow: 0 0 0 1px rgba(0,102,204,0.15), inset 0 1px 0 rgba(255,255,255,0.07);
}
.custom-select select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0,102,204,0.15), inset 0 1px 0 rgba(255,255,255,0.07);
}
.custom-select::after {
  content: '';
  position: absolute; right: 11px; top: 50%;
  transform: translateY(-50%);
  width: 0; height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--text3);
  pointer-events: none;
  transition: var(--trans);
}
.custom-select:hover::after { border-top-color: var(--accent2); }
/* ── CUSTOM DROPDOWN ── */
.custom-select select { display: none; }
.cs-trigger {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 12px; border-radius: 10px;
  border: 1px solid var(--border2);
  background: rgba(255,255,255,0.04);
  color: var(--text); font-size: .82rem; font-family: var(--font);
  cursor: pointer; min-width: 150px; gap: 8px;
  transition: var(--trans);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05), 0 2px 8px rgba(0,0,0,0.2);
  user-select: none;
}
.cs-trigger:hover {
  border-color: rgba(0,102,204,0.45);
  background: rgba(0,102,204,0.07);
  box-shadow: 0 0 0 1px rgba(0,102,204,0.15), inset 0 1px 0 rgba(255,255,255,0.07);
}
.cs-trigger svg {
  width: 12px; height: 12px; flex-shrink: 0; color: var(--text3);
  transition: transform 0.2s ease;
}
.cs-trigger.open { border-color: rgba(0,102,204,0.5); background: rgba(0,102,204,0.08); }
.cs-trigger.open svg { transform: rotate(180deg); color: var(--accent2); }
.cs-dropdown {
  position: absolute; top: calc(100% + 6px); left: 0; min-width: 100%;
  background: rgba(12,12,22,0.95);
  border: 1px solid rgba(255,255,255,0.10);
  border-top: 1px solid rgba(255,255,255,0.15);
  border-radius: 12px; padding: 6px;
  z-index: 500;
  box-shadow: 0 20px 60px rgba(0,0,0,0.7), inset 0 1px 0 rgba(255,255,255,0.06);
  animation: csDropIn 0.18s cubic-bezier(0.34,1.2,0.64,1);
  max-height: 260px; overflow-y: auto;
}
@keyframes csDropIn {
  from { opacity:0; transform: translateY(-8px) scale(0.97); filter: blur(4px); }
  to   { opacity:1; transform: none; filter: blur(0); }
}
.cs-option {
  padding: 8px 12px; border-radius: 8px; font-size: .82rem;
  color: var(--text2); cursor: pointer; transition: var(--trans);
  white-space: nowrap;
}
.cs-option:hover { background: rgba(0,102,204,0.1); color: var(--text); }
.cs-option.selected {
  background: rgba(0,102,204,0.15); color: var(--accent2);
  font-weight: 500;
}
.cs-option.selected::before {
  content: '✓ '; font-size: .7rem; opacity: 0.7;
}
#local-url-wrap { display: none; align-items: flex-end; gap: 8px; }
#local-url-wrap input {
  padding: 7px 12px; border-radius: 10px;
  border: 1px solid var(--border2);
  background: rgba(255,255,255,0.04); color: var(--text); font-size: .82rem;
  font-family: var(--font); outline: none; width: 190px; transition: var(--trans);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
}
#local-url-wrap input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0,102,204,0.15), inset 0 1px 0 rgba(255,255,255,0.07);
}
.btn-detect {
  padding: 7px 12px; border-radius: 10px; border: 1px solid var(--border2);
  background: rgba(255,255,255,0.04); color: var(--text2); font-size: .78rem;
  font-family: var(--font); cursor: pointer; transition: var(--trans);
  display: flex; align-items: center; gap: 5px; white-space: nowrap;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
}
.btn-detect:hover {
  border-color: rgba(0,102,204,0.4); color: var(--teal);
  background: rgba(0,102,204,0.07);
  box-shadow: 0 0 0 1px rgba(0,102,204,0.1), 0 4px 14px rgba(0,102,204,0.12);
  transform: translateY(-1px);
}
.btn-detect:active { transform: translateY(0); }
.btn-detect svg { width: 13px; height: 13px; }
#credit-badge {
  margin-left: auto;
  font-size: .75rem; color: var(--teal2);
  background: rgba(0,102,204,0.07);
  padding: 7px 14px; border-radius: 12px;
  border: 1px solid rgba(0,102,204,0.18);
  cursor: pointer; transition: var(--trans);
  display: flex; align-items: center; gap: 7px; font-weight: 500;
  box-shadow: 0 2px 12px rgba(0,102,204,0.1), inset 0 1px 0 rgba(255,255,255,0.06);
  animation: badgePulse 4s ease-in-out infinite;
}
@keyframes badgePulse {
  0%,100% { box-shadow: 0 2px 12px rgba(0,102,204,0.1), inset 0 1px 0 rgba(255,255,255,0.06); }
  50%      { box-shadow: 0 2px 20px rgba(0,102,204,0.22), inset 0 1px 0 rgba(255,255,255,0.08); }
}
#credit-badge:hover {
  background: rgba(0,102,204,0.13);
  border-color: var(--teal);
  box-shadow: 0 4px 20px rgba(0,102,204,0.25), 0 0 0 1px rgba(0,102,204,0.15);
  transform: translateY(-1px);
  animation: none;
}
#credit-badge:active { transform: translateY(0); }
#credit-badge svg { width: 14px; height: 14px; }

/* ── CHAT AREA ── */
#chat-area {
  flex: 1; overflow-y: auto;
  padding: 32px 0 120px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  position: relative;
  background: #080b12;
}
#chat-area > * {
  width: 100%;
  max-width: 800px;
  padding-left: 24px;
  padding-right: 24px;
}

/* ── WELCOME ── */
.welcome {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; text-align: center;
  margin: auto; padding: 40px 20px;
  animation: fadeUp 0.5s cubic-bezier(0.4,0,0.2,1);
}
@keyframes fadeUp {
  from { opacity:0; transform: translateY(24px) scale(0.97); filter: blur(6px); }
  to   { opacity:1; transform: none; filter: blur(0); }
}
.welcome-orb {
  width: 88px; height: 88px;
  background: transparent;
  border-radius: 24px; display: flex; align-items: center; justify-content: center;
  margin-bottom: 20px;
  filter: drop-shadow(0 0 24px rgba(0,102,204,0.6)) drop-shadow(0 0 8px rgba(0,102,204,0.3));
  animation: pulse 3s ease-in-out infinite;
}
.welcome-orb img { width: 80px; height: 80px; object-fit: contain; }
@keyframes pulse {
  0%,100% { box-shadow: 0 0 40px rgba(0,102,204,0.15); }
  50%      { box-shadow: 0 0 60px rgba(0,102,204,0.3); }
}
.welcome h2 { font-size: 1.6rem; font-weight: 600; margin-bottom: 8px; letter-spacing: -0.02em; }
.welcome p  { font-size: .9rem; color: var(--text2); max-width: 360px; line-height: 1.6; }
.welcome-pills {
  display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 24px;
}
.welcome-pill {
  padding: 7px 14px; border-radius: 20px;
  border: 1px solid var(--border2); background: var(--bg3);
  font-size: .78rem; color: var(--text2); cursor: pointer;
  transition: var(--trans);
}
.welcome-pill:hover { border-color: var(--accent); color: var(--accent); background: rgba(0,102,204,0.06); }

/* ── MESSAGES ── */
.msg-group { display: flex; flex-direction: column; gap: 2px; margin-bottom: 16px; width: 100%; max-width: 800px; }
.msg {
  display: flex; gap: 10px;
  max-width: 100%;
  animation: msgIn 0.3s cubic-bezier(0.34,1.1,0.64,1);
  padding: 2px 0;
}
@keyframes msgIn {
  from { opacity:0; transform: translateY(16px) scale(0.97); filter: blur(6px); }
  to   { opacity:1; transform: none; filter: blur(0); }
}
.msg.user  { align-self: flex-end; flex-direction: row-reverse; max-width: 75%; }
.msg.assistant { align-self: flex-start; max-width: 75%; }

.avatar {
  width: 32px; height: 32px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; flex-shrink: 0; font-weight: 600;
  align-self: flex-end; margin-bottom: 2px;
  position: relative;
}
.msg.user .avatar {
  background: linear-gradient(135deg, var(--accent), #004499);
  color: #fff;
  box-shadow: 0 2px 16px rgba(0,102,204,0.5), inset 0 1px 0 rgba(255,255,255,0.2);
}
.msg.assistant .avatar {
  background: linear-gradient(135deg, rgba(0,102,204,0.18), rgba(0,102,204,0.08));
  border: 1px solid rgba(0,102,204,0.28);
  color: var(--teal);
  box-shadow: 0 2px 12px rgba(0,102,204,0.15), inset 0 1px 0 rgba(255,255,255,0.06);
}
.avatar svg { width: 15px; height: 15px; }

.bubble {
  padding: 13px 17px; line-height: 1.75; font-size: .9rem;
  position: relative; max-width: calc(100% - 44px);
  transition: box-shadow 0.2s ease;
}
.msg.user .bubble {
  background: linear-gradient(135deg, rgba(0,102,204,0.2), rgba(80,140,0,0.12));
  border: 1px solid rgba(0,102,204,0.25);
  border-top-color: rgba(0,102,204,0.35);
  border-radius: var(--r) var(--r) 4px var(--r);
  color: var(--text);
  box-shadow: 0 4px 24px var(--user-glow), inset 0 1px 0 rgba(255,255,255,0.07);
}
.msg.user .bubble:hover {
  box-shadow: 0 6px 32px rgba(0,102,204,0.28), inset 0 1px 0 rgba(255,255,255,0.09);
}
.msg.assistant .bubble {
  background: rgba(14,14,26,0.75);
  border: 1px solid var(--border);
  border-top-color: rgba(255,255,255,0.08);
  border-radius: var(--r) var(--r) var(--r) 4px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.04);
}
.msg.assistant .bubble:hover {
  border-color: rgba(255,255,255,0.09);
  box-shadow: 0 6px 32px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.06);
}

/* Markdown */
.bubble h1,.bubble h2,.bubble h3,.bubble h4 {
  margin: .9em 0 .4em; color: var(--accent3); font-weight: 600; letter-spacing: -0.01em;
}
.bubble h1 { font-size: 1.2rem; } .bubble h2 { font-size: 1.05rem; } .bubble h3 { font-size: .95rem; }
.bubble p  { margin: .4em 0; }
.bubble ul,.bubble ol { margin: .4em 0 .4em 1.4em; }
.bubble li { margin: .25em 0; }
.bubble pre {
  background: rgba(5,5,12,0.9);
  border: 1px solid var(--border2);
  border-top: 1px solid rgba(255,255,255,0.07);
  border-radius: 12px; padding: 16px; overflow-x: auto;
  margin: .7em 0; position: relative;
  box-shadow: inset 0 2px 12px rgba(0,0,0,0.4), 0 2px 8px rgba(0,0,0,0.2);
}
.bubble code {
  font-family: var(--mono); font-size: .82rem;
}
.bubble :not(pre) > code {
  background: rgba(0,102,204,0.13); color: var(--accent3);
  padding: 2px 7px; border-radius: 5px; font-size: .82rem;
  border: 1px solid rgba(0,102,204,0.18);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
}
.bubble blockquote {
  border-left: 2px solid var(--accent); padding-left: 14px;
  color: var(--text2); margin: .5em 0; font-style: italic;
  background: rgba(0,102,204,0.04); border-radius: 0 8px 8px 0;
  padding: 8px 14px;
}
.bubble table { border-collapse: collapse; width: 100%; margin: .7em 0; font-size: .85rem; }
.bubble th,.bubble td { border: 1px solid var(--border2); padding: 7px 11px; }
.bubble th {
  background: rgba(0,102,204,0.08); color: var(--accent3);
  font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: 0.04em;
}
.bubble tr:hover td { background: rgba(255,255,255,0.02); }
.bubble a { color: var(--teal2); text-decoration: none; border-bottom: 1px solid rgba(105,255,158,0.3); transition: var(--trans); }
.bubble a:hover { color: var(--teal); border-color: var(--teal2); }
.bubble strong { color: var(--text); font-weight: 600; }
.bubble hr { border: none; border-top: 1px solid var(--border2); margin: 1em 0; }

/* Copy button on code blocks */
.copy-btn {
  position: absolute; top: 8px; right: 8px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border2);
  color: var(--text3); font-size: .72rem; font-family: var(--font);
  padding: 4px 9px; border-radius: 6px; cursor: pointer;
  opacity: 0; transition: var(--trans); display: flex; align-items: center; gap: 4px;
}
.copy-btn svg { width: 11px; height: 11px; }
.bubble pre:hover .copy-btn { opacity: 1; }
.copy-btn:hover {
  color: var(--text); border-color: var(--accent);
  background: rgba(0,102,204,0.12);
  box-shadow: 0 2px 8px rgba(0,102,204,0.2);
}

/* ── NV SPINNER ── */
.nv-spinner {
  position: relative;
  width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  margin: 6px 0;
}
.nv-spinner-ring {
  position: absolute; inset: 0;
  border-radius: 50%;
  border: 1.5px solid transparent;
  border-top-color: var(--accent);
  border-right-color: rgba(124,106,247,0.3);
  animation: nvSpin 1.1s cubic-bezier(0.4,0,0.2,1) infinite;
  box-shadow: 0 0 12px rgba(124,106,247,0.4), inset 0 0 8px rgba(124,106,247,0.1);
}
.nv-spinner-ring::before {
  content: '';
  position: absolute; inset: 4px;
  border-radius: 50%;
  border: 1px solid transparent;
  border-bottom-color: var(--teal);
  border-left-color: rgba(45,212,191,0.3);
  animation: nvSpin 0.8s cubic-bezier(0.4,0,0.2,1) infinite reverse;
}
.nv-spinner-logo {
  width: 22px; height: 22px;
  color: var(--accent2);
  display: flex; align-items: center; justify-content: center;
  animation: nvPulse 2s ease-in-out infinite;
  filter: drop-shadow(0 0 4px rgba(124,106,247,0.7));
}
.nv-spinner-logo svg { width: 18px; height: 18px; }
@keyframes nvSpin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
@keyframes nvPulse {
  0%,100% { opacity: 0.7; transform: scale(0.92); filter: drop-shadow(0 0 4px rgba(124,106,247,0.5)); }
  50%      { opacity: 1;   transform: scale(1.08); filter: drop-shadow(0 0 10px rgba(124,106,247,0.9)); }
}

/* Typing indicator */
.typing-dots {
  display: inline-flex; gap: 5px; align-items: center; padding: 4px 0;
}
.typing-dots span {
  display: inline-block; width: 6px; height: 6px;
  background: var(--teal); border-radius: 50%;
  animation: dot 1.4s infinite cubic-bezier(0.4,0,0.6,1);
  box-shadow: 0 0 6px rgba(0,102,204,0.5);
}
.typing-dots span:nth-child(2) { animation-delay: .16s; }
.typing-dots span:nth-child(3) { animation-delay: .32s; }
@keyframes dot {
  0%,60%,100% { transform: scale(.7); opacity: .3; box-shadow: 0 0 4px rgba(0,102,204,0.3); }
  30%          { transform: scale(1.3); opacity: 1; box-shadow: 0 0 10px rgba(0,102,204,0.7); }
}

/* ── INPUT BAR ── */
#input-bar {
  padding: 14px 20px 16px;
  background: rgba(10,10,18,0.75);
  
  border-top: 1px solid rgba(0,102,204,0.2);
  box-shadow:
    0 -1px 0 rgba(255,255,255,0.06),
    0 -4px 24px rgba(0,0,0,0.4);
  position: fixed;
  bottom: 0;
  left: 272px;
  right: 0;
  z-index: 50;
}
#input-bar::before {
  content: '';
  position: absolute; inset-inline: 0; top: 0; height: 1px;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(0,102,204,0.3) 30%,
    rgba(0,102,204,0.18) 70%,
    transparent 100%);
  pointer-events: none;
}
.input-wrapper {
  display: flex; gap: 8px; align-items: flex-end;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border2);
  border-top-color: rgba(255,255,255,0.09);
  border-radius: var(--r2);
  padding: 10px 10px 10px 16px;
  transition: var(--trans);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05), 0 4px 20px rgba(0,0,0,0.25);
}
.input-wrapper:focus-within {
  border-color: rgba(0,102,204,0.45);
  border-top-color: rgba(0,102,204,0.6);
  background: rgba(0,102,204,0.05);
  box-shadow:
    0 0 0 3px rgba(0,102,204,0.1),
    inset 0 1px 0 rgba(255,255,255,0.07),
    0 4px 24px rgba(0,102,204,0.12);
}
#user-input {
  flex: 1; background: none; border: none; outline: none;
  color: var(--text); font-size: .9rem; font-family: var(--font);
  resize: none; max-height: 180px; min-height: 24px;
  line-height: 1.5; padding: 3px 0;
}
#user-input::placeholder { color: var(--text3); }
#send-btn {
  width: 38px; height: 38px; border-radius: 12px; border: none;
  background: linear-gradient(135deg, var(--accent) 0%, #004499 100%);
  color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: var(--trans-spring); flex-shrink: 0;
  box-shadow: 0 4px 20px rgba(0,102,204,0.5), inset 0 1px 0 rgba(255,255,255,0.2);
  position: relative; overflow: hidden;
}
#send-btn::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.15), transparent 60%);
  opacity: 0; transition: var(--trans);
}
#send-btn::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(105deg, transparent 40%, rgba(255,255,255,0.1) 50%, transparent 60%);
  transform: translateX(-100%);
  transition: transform 0.5s ease;
}
#send-btn:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 8px 32px rgba(0,102,204,0.65), inset 0 1px 0 rgba(255,255,255,0.25);
}
#send-btn:hover::before { opacity: 1; }
#send-btn:hover::after { transform: translateX(100%); }
#send-btn:active { transform: translateY(0) scale(0.97); box-shadow: 0 2px 8px rgba(0,102,204,0.4); }
#send-btn:disabled { opacity: .35; cursor: not-allowed; transform: none; box-shadow: none; }
#send-btn svg { width: 16px; height: 16px; position: relative; }
.input-hint {
  text-align: center; font-size: .7rem; color: var(--text3);
  margin-top: 8px; letter-spacing: 0.01em;
}

/* ── MODAL CREDITS ── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.88);
  z-index: 100; align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; animation: overlayIn 0.2s ease; }
@keyframes overlayIn {
  from { opacity:0; }
  to   { opacity:1; }
}
.modal {
  background: rgba(14,14,26,0.85);
  border: 1px solid rgba(255,255,255,0.10);
  border-top: 1px solid rgba(255,255,255,0.16);
  border-radius: var(--r2); padding: 32px 36px; min-width: 340px;
  box-shadow: var(--shadow2), inset 0 1px 0 rgba(255,255,255,0.07);
  animation: modalIn 0.3s cubic-bezier(0.34,1.2,0.64,1);
  position: relative; overflow: hidden;
}
.modal::before {
  content: '';
  position: absolute; inset-inline: 0; top: 0; height: 1px;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(0,102,204,0.4) 40%,
    rgba(0,102,204,0.25) 70%,
    transparent 100%);
  pointer-events: none;
}
@keyframes modalIn {
  from { opacity:0; transform: scale(0.93) translateY(16px); filter: blur(8px); }
  to   { opacity:1; transform: none; filter: blur(0); }
}
.modal-header {
  display: flex; align-items: center; gap: 10px; margin-bottom: 20px;
}
.modal-header svg { width: 18px; height: 18px; color: var(--teal); }
.modal h3 { font-size: 1rem; font-weight: 600; }
.credit-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0; border-bottom: 1px solid var(--border);
  font-size: .85rem; transition: var(--trans);
}
.credit-row:last-child { border-bottom: none; }
.credit-row:hover { padding-left: 4px; }
.credit-label { color: var(--text2); }
.credit-val {
  font-weight: 600; color: var(--text); font-family: var(--mono); font-size: .82rem;
  background: rgba(255,255,255,0.04); padding: 2px 8px; border-radius: 6px;
  border: 1px solid var(--border);
}
.close-btn {
  margin-top: 20px; width: 100%; padding: 10px; border-radius: 10px;
  border: 1px solid var(--border2);
  background: rgba(255,255,255,0.03); color: var(--text2);
  cursor: pointer; font-family: var(--font); font-size: .85rem;
  transition: var(--trans);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
}
.close-btn:hover {
  background: rgba(255,255,255,0.07); color: var(--text);
  border-color: var(--border3);
  box-shadow: 0 4px 16px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.07);
}

/* ── TOAST ── */
.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 200;
  background: rgba(14,14,26,0.9);
  border: 1px solid rgba(255,255,255,0.10);
  border-top: 1px solid rgba(255,255,255,0.15);
  border-radius: 12px; padding: 11px 16px;
  font-size: .83rem; color: var(--text2);
  display: flex; align-items: center; gap: 8px;
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,0.06);
  animation: toastIn 0.3s cubic-bezier(0.34,1.2,0.64,1);
}
.toast svg { width: 15px; height: 15px; color: var(--success); filter: drop-shadow(0 0 6px rgba(74,222,128,0.5)); }
@keyframes toastIn {
  from { opacity:0; transform: translateY(16px) scale(0.95); filter: blur(4px); }
  to   { opacity:1; transform: none; filter: blur(0); }
}

/* ── TOKEN COUNTER ── */
.token-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 0 20px 10px; font-size: .7rem; color: var(--text3);
}
.token-pill {
  background: var(--bg3); border: 1px solid var(--border);
  padding: 3px 8px; border-radius: 20px; display: flex; align-items: center; gap: 5px;
}
.token-pill svg { width: 11px; height: 11px; }

/* ── MSG ACTION BAR ── */
.msg-actions {
  display: flex; gap: 2px; align-items: center;
  margin-top: 4px; padding-left: 2px;
}
.msg-action-btn {
  background: none; border: none;
  border-radius: 6px; padding: 5px 7px;
  color: var(--text3); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: var(--trans);
}
.msg-action-btn svg { width: 14px; height: 14px; flex-shrink: 0; }
.msg-action-btn:hover { background: var(--bg4); color: var(--text2); }
.msg-action-btn.liked  { color: var(--success); }
.msg-action-btn.disliked { color: var(--danger); }
.msg-action-btn.active { color: var(--accent2); }
.msg-bubble-wrap { display: flex; flex-direction: column; max-width: calc(100% - 44px); }

/* ── HLJS OVERRIDE ── */
.hljs { background: transparent !important; }

/* ══════════════════════════════════════════════════════════
   RESPONSIVE MOBILE
══════════════════════════════════════════════════════════ */

/* ── Tablet (≤900px) ── */
@media (max-width: 900px) {
  #sidebar { width: 240px; min-width: 240px; }
  .custom-select select { min-width: 120px; }
  #config-bar { gap: 8px; padding: 8px 12px; }
}


/* ── Mobile (≤680px) ── */
@media (max-width: 680px) {

  /* Sidebar drawer */
  #sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 100;
    width: 280px !important; min-width: 280px !important;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
    box-shadow: 4px 0 32px rgba(0,0,0,0.5);
  }
  #sidebar.open { transform: translateX(0); }

  /* Overlay */
  #sidebar-overlay {
    display: none; position: fixed; inset: 0; z-index: 99;
    background: rgba(0,0,0,0.55);
  }
  #sidebar-overlay.open { display: block; }

  /* Burger */
  #burger-btn { display: flex !important; }

  /* Layout */
  #app { flex-direction: column; }
  #main { width: 100%; min-height: 0; }
  body { height: 100dvh; }

  /* Config bar */
  #config-bar {
    padding: 8px 10px; gap: 6px;
    flex-wrap: nowrap !important;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    scrollbar-width: none; min-height: 52px;
  }
  #config-bar::-webkit-scrollbar { display: none; }
  .select-wrap label { font-size: .6rem; }
  .custom-select select { min-width: 100px !important; font-size: .78rem; padding: 6px 24px 6px 8px; }
  #credit-badge { font-size: .68rem; padding: 4px 8px; white-space: nowrap; flex-shrink: 0; }
  #theme-picker-wrap { flex-shrink: 0; }

  /* Chat */
  #chat-area { padding: 16px 12px 8px; }
  .msg { max-width: 100% !important; }
  .bubble { font-size: .86rem; padding: 10px 13px; }
  .bubble pre { padding: 12px; font-size: .78rem; }
  .avatar { width: 28px; height: 28px; border-radius: 8px; }
  .avatar svg { width: 13px; height: 13px; }

  /* Welcome */
  .welcome h2 { font-size: 1.3rem; }
  .welcome-orb { width: 56px; height: 56px; font-size: 22px; }
  .welcome-pills {
    flex-wrap: nowrap !important; overflow-x: auto;
    justify-content: flex-start !important;
    padding-bottom: 4px; scrollbar-width: none; gap: 6px;
  }
  .welcome-pills::-webkit-scrollbar { display: none; }
  .welcome-pill { font-size: .72rem; padding: 5px 10px; flex-shrink: 0; }

  /* Input bar + safe-area notch */
  #input-bar {
    padding: 8px 10px calc(12px + env(safe-area-inset-bottom));
  }
  .input-hint { font-size: .65rem; }
  #user-input { font-size: .9rem; }

  /* Login */
  .login-box { width: calc(100vw - 32px); padding: 36px 24px; margin: 16px; }
  .login-box h1 { font-size: 1.3rem; }

  /* Modal bottom-sheet */
  .modal-overlay { align-items: flex-end; }
  .modal { border-radius: var(--r2) var(--r2) 0 0; margin: 0; width: 100%; padding: 24px 20px; }

  /* Toast */
  .toast { left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); font-size: .8rem; }
}

/* ── Très petit mobile (≤380px) ── */
@media (max-width: 380px) {
  .custom-select select { min-width: 95px; font-size: .75rem; }
  #config-bar { gap: 6px; }
  .bubble { padding: 9px 11px; font-size: .84rem; }
}

/* ── THEME PICKER ── */
#theme-picker-wrap {
  position: relative;
}
#theme-picker-btn {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 14px; border-radius: 12px;
  border: 1px solid var(--border2);
  background: var(--bg3); color: var(--text2);
  font-size: .75rem; font-family: var(--font); font-weight: 500;
  cursor: pointer; transition: var(--trans);
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15), inset 0 1px 0 rgba(255,255,255,0.04);
}
#theme-picker-btn:hover {
  border-color: var(--accent); color: var(--accent);
  background: rgba(0,102,204,0.08);
  box-shadow: 0 4px 16px rgba(0,102,204,0.15);
  transform: translateY(-1px);
}
#theme-picker-btn:active { transform: translateY(0); }
#theme-picker-btn svg { width: 14px; height: 14px; flex-shrink: 0; }
.theme-dot-preview {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent); flex-shrink: 0;
  box-shadow: 0 0 6px var(--accent);
  transition: background 0.3s, box-shadow 0.3s;
}
#theme-palette {
  display: none;
  position: absolute; top: calc(100% + 10px); right: 0;
  background: rgba(17,17,24,0.75);
  border: 1px solid var(--border2);
  border-radius: 16px;
  padding: 14px 16px;
  z-index: 200;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.07);
  min-width: 200px;
  animation: paletteIn 0.22s cubic-bezier(0.34,1.56,0.64,1);
}
#theme-palette.open { display: block; }
@keyframes paletteIn {
  from { opacity:0; transform: translateY(-10px) scale(0.94); filter: blur(4px); }
  to   { opacity:1; transform: none; filter: blur(0); }
}
.palette-title {
  font-size: .65rem; font-weight: 600; letter-spacing: 0.08em;
  color: var(--text3); text-transform: uppercase; margin-bottom: 10px;
}
.palette-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.palette-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: 9px;
  cursor: pointer; transition: var(--trans);
  border: 1px solid transparent;
  font-size: .8rem; color: var(--text2);
}
.palette-item:hover { background: var(--bg3); color: var(--text); }
.palette-item.active { border-color: var(--accent); background: rgba(0,102,204,0.08); color: var(--text); }
.palette-swatch {
  width: 18px; height: 18px; border-radius: 50%; flex-shrink: 0;
  position: relative;
}
.palette-swatch::after {
  content: ''; position: absolute; inset: -2px;
  border-radius: 50%; border: 2px solid transparent;
  transition: var(--trans);
}
.palette-item.active .palette-swatch::after { border-color: var(--accent); }

/* ── Touch : zones de tap plus grandes ── */
@media (hover: none) and (pointer: coarse) {
  .btn-icon { padding: 10px; }
  .btn-new  { padding: 11px 12px; }
  .conv-item { padding: 11px 10px; }
  .conv-del { opacity: 1; padding: 6px 8px; }
  .welcome-pill { padding: 9px 14px; }
  #send-btn { width: 42px; height: 42px; }
  .custom-select select { padding: 9px 28px 9px 10px; }
}


#auth-screen {
  background: #07070e url('/static/img/back.jpg') center/cover no-repeat;
}
#auth-screen::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: rgba(0,0,0,0.88);
  z-index: 0;
}
#auth-screen > * { position: relative; z-index: 1; }

/* ══ SPLIT LOGIN ══════════════════════════════════════════════ */
#login-screen {
  display: none;
  position: fixed; inset: 0; z-index: 1000;
  flex-direction: row;
}
#login-screen.visible { display: flex; }
#auth-screen { display: none; flex-direction: row; }
#auth-screen.visible { display: flex !important; }

.split-left {
  width: 480px; min-width: 380px; flex-shrink: 0;
  background: #06060f;
  display: flex; align-items: center; justify-content: center;
  position: relative; z-index: 2;
  box-shadow: 4px 0 60px rgba(0,0,0,0.8);
  overflow: hidden;
}
.split-left::before {
  content: '';
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(ellipse 60% 40% at 50% 0%, rgba(0,102,204,0.07) 0%, transparent 70%),
    radial-gradient(ellipse 40% 30% at 50% 100%, rgba(0,102,204,0.04) 0%, transparent 70%);
}
.split-left::after {
  content: '';
  position: absolute; top: 0; right: 0; width: 1px; height: 100%;
  background: linear-gradient(180deg, transparent, rgba(0,102,204,0.4) 30%, rgba(0,102,204,0.6) 50%, rgba(0,102,204,0.4) 70%, transparent);
}

.split-right {
  flex: 1; position: relative; overflow: hidden;
}
.split-right-img {
  position: absolute; inset: 0;
  background-size: cover; background-position: center;
  transform: scale(1.05);
  animation: imgBreath 12s ease-in-out infinite alternate;
  filter: brightness(0.25) saturate(0.6);
}
@keyframes imgBreath {
  from { transform: scale(1.05); }
  to   { transform: scale(1.12); }
}
.split-right-overlay {
  position: absolute; inset: 0;
  background:
    linear-gradient(270deg, transparent 40%, rgba(6,6,15,0.85) 100%),
    linear-gradient(180deg, rgba(0,0,0,0.2) 0%, rgba(0,0,0,0.5) 100%);
}
.split-right-text {
  position: absolute; bottom: 60px; left: 60px; z-index: 2;
}
.srt-badge {
  font-size: .6rem; font-weight: 700; letter-spacing: .2em;
  color: var(--accent); opacity: .8; margin-bottom: 16px;
  font-family: var(--font-mono, monospace);
}
.srt-headline {
  font-size: clamp(2.5rem, 5vw, 4rem);
  font-weight: 800; line-height: 1.05;
  color: #fff; letter-spacing: -0.04em;
  text-shadow: 0 0 80px rgba(0,102,204,0.3);
  animation: headlineIn 1.2s cubic-bezier(0.16,1,0.3,1) both;
}
@keyframes headlineIn {
  from { opacity:0; transform: translateY(30px); filter: blur(8px); }
  to   { opacity:1; transform: none; filter: blur(0); }
}
.srt-line {
  width: 48px; height: 3px; margin-top: 24px;
  background: linear-gradient(90deg, var(--accent), transparent);
  animation: lineIn 1.4s cubic-bezier(0.16,1,0.3,1) both;
}
@keyframes lineIn {
  from { width: 0; opacity: 0; }
  to   { width: 48px; opacity: 1; }
}

/* ── Form ── */
.split-form-wrap {
  width: 100%; max-width: 360px; padding: 0 32px;
  animation: formIn 0.8s cubic-bezier(0.16,1,0.3,1) both;
}
@keyframes formIn {
  from { opacity:0; transform: translateX(-24px); filter: blur(6px); }
  to   { opacity:1; transform: none; filter: blur(0); }
}
.sf-logo {
  margin-bottom: 32px;
}
.sf-logo img {
  width: 48px; height: 48px; object-fit: contain;
  filter: drop-shadow(0 0 16px rgba(0,102,204,0.5));
  animation: logoPulse2 4s ease-in-out infinite;
}
@keyframes logoPulse2 {
  0%,100% { filter: drop-shadow(0 0 16px rgba(0,102,204,0.5)); }
  50%      { filter: drop-shadow(0 0 28px rgba(0,102,204,0.9)); }
}
.sf-eyebrow {
  font-size: .55rem; font-weight: 700; letter-spacing: .18em;
  color: var(--accent); opacity: .75; margin-bottom: 10px;
  font-family: var(--font-mono, monospace);
}
.sf-title {
  font-size: 2rem; font-weight: 800; letter-spacing: -0.04em;
  color: #fff; margin-bottom: 8px; line-height: 1.1;
}
.sf-sub {
  font-size: .82rem; color: var(--text2); margin-bottom: 32px;
  line-height: 1.6;
}
.sf-field {
  position: relative; margin-bottom: 14px;
}
.sf-field svg {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--text3); pointer-events: none;
  transition: color 0.2s;
}
.sf-field input {
  width: 100%; padding: 13px 16px 13px 42px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px; color: #fff;
  font-size: .88rem; font-family: var(--font);
  outline: none;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}
.sf-field input::placeholder { color: var(--text3); }
.sf-field input:focus {
  border-color: var(--accent);
  background: rgba(0,102,204,0.06);
  box-shadow: 0 0 0 3px rgba(0,102,204,0.12), 0 0 20px rgba(0,102,204,0.08);
}
.sf-field input:focus + svg,
.sf-field:focus-within svg { color: var(--accent); }

.sf-btn {
  width: 100%; padding: 14px 20px; margin-top: 8px;
  border: none; border-radius: 12px;
  background: transparent; cursor: pointer;
  color: #fff; font-size: .9rem; font-weight: 700;
  letter-spacing: 0.03em;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  position: relative; overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 4px 32px rgba(0,102,204,0.35), inset 0 1px 0 rgba(255,255,255,0.12);
}
.sf-btn-glow {
  position: absolute; inset: 0;
  background: linear-gradient(135deg, #0066cc 0%, #4a7a00 50%, #0080ff 100%);
  background-size: 200% 200%;
  animation: sfGrad 4s ease infinite;
}
@keyframes sfGrad {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
.sf-btn-text, .sf-btn svg {
  position: relative; z-index: 1;
}
.sf-btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.sf-btn::after {
  content: '';
  position: absolute; inset: 0; z-index: 1;
  background: linear-gradient(105deg, transparent 40%, rgba(255,255,255,0.15) 50%, transparent 60%);
  transform: translateX(-100%);
  transition: transform 0.6s ease;
}
.sf-btn:hover::after { transform: translateX(100%); }
.sf-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 40px rgba(0,102,204,0.55), 0 0 60px rgba(0,102,204,0.2), inset 0 1px 0 rgba(255,255,255,0.2);
}
.sf-btn:active { transform: translateY(0); }

.sf-switch {
  text-align: center; margin-top: 18px;
  font-size: .78rem; color: var(--text3);
}
.sf-switch a {
  color: var(--accent); text-decoration: none; font-weight: 600;
  transition: opacity 0.2s;
}
.sf-switch a:hover { opacity: 0.75; }

.sf-error {
  min-height: 18px; margin-top: 12px;
  font-size: .78rem; color: #f87171; text-align: center;
}
.sf-footer {
  margin-top: 40px; font-size: .65rem;
  color: var(--text3); opacity: .5; text-align: center;
}
.sf-footer span { color: var(--accent); opacity: .8; }

/* Shake */
@keyframes sfShake {
  0%,100% { transform: translateX(0); }
  20%,60% { transform: translateX(-8px); }
  40%,80% { transform: translateX(8px); }
}
.sf-shake { animation: sfShake 0.4s ease; }

/* Responsive */
@media (max-width: 700px) {
  .split-right { display: none; }
  .split-left { width: 100%; min-width: unset; }
  .split-form-wrap { padding: 0 24px; }
}

.upload-btn {
  background: rgba(0,102,204,0.1);
  border: 1px solid rgba(0,102,204,0.3);
  color: #0066cc;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.upload-btn:hover {
  background: rgba(0,102,204,0.2);
  border-color: rgba(0,102,204,0.5);
}

.drop-zone {
  border: 2px dashed rgba(0,102,204,0.4);
  border-radius: 12px;
  padding: 40px 20px;
  text-align: center;
  background: rgba(0,102,204,0.05);
  cursor: pointer;
  transition: all 0.3s;
  margin: 20px 0;
}
.drop-zone:hover, .drop-zone.active {
  border-color: rgba(0,102,204,0.7);
  background: rgba(0,102,204,0.12);
}
.drop-zone svg {
  width: 48px;
  height: 48px;
  color: #0066cc;
  margin-bottom: 12px;
}
.drop-zone p {
  color: var(--text2);
  font-size: 0.95rem;
  margin: 0;
}

@keyframes slideInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}
.msg { animation: slideInUp 0.3s ease-out; }
.welcome { animation: fadeIn 0.5s ease-out; }
.welcome-pill { animation: slideInUp 0.4s ease-out both; }
.welcome-pill:nth-child(1) { animation-delay: 0.1s; }
.welcome-pill:nth-child(2) { animation-delay: 0.2s; }
.welcome-pill:nth-child(3) { animation-delay: 0.3s; }
.welcome-pill:nth-child(4) { animation-delay: 0.4s; }
.welcome-pill:nth-child(5) { animation-delay: 0.5s; }

.pmenu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px; border-radius: 8px;
  font-size: .85rem; color: var(--text);
  cursor: pointer; transition: background 0.15s;
}
.pmenu-item:hover { background: rgba(0,102,204,0.1); color: #0066cc; }
.pmenu-icon { font-size: 1rem; width: 20px; text-align: center; }
.pmenu-sep { height: 1px; background: rgba(255,255,255,0.08); margin: 4px 8px; }
#plus-btn { font-size: 1.3rem; font-weight: 300; padding: 4px 10px; }

.sv-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(0,102,204,0.2);
  border-radius: 12px;
  padding: 16px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}
.sv-card:hover {
  background: rgba(0,102,204,0.08);
  border-color: rgba(0,102,204,0.45);
  transform: translateY(-2px);
}
.sv-card-icon { font-size: 1.4rem; margin-bottom: 8px; }
.sv-card-title { font-size: .85rem; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.sv-card-sub { font-size: .75rem; color: var(--text3); line-height: 1.4; }

.sv-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(0,102,204,0.2);
  border-radius: 16px;
  padding: 28px 24px;
  cursor: pointer;
  transition: all 0.25s;
  text-align: left;
}
.sv-card:hover {
  background: rgba(0,102,204,0.1);
  border-color: rgba(0,102,204,0.5);
  transform: translateY(-3px);
  box-shadow: 0 8px 32px rgba(0,102,204,0.2);
}
.sv-card-icon {
  color: #0080ff;
  margin-bottom: 14px;
}
.sv-card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.sv-card-sub {
  font-size: .8rem;
  color: var(--text3);
  line-height: 1.5;
}
