/* ============================================================
   SCARLET AI — Premium CSS
   ============================================================ */

/* --- RESET & VARIABLES --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --scarlet: #8B0000;
  --neon: #FF3131;
  --neon-dim: rgba(255,49,49,0.18);
  --neon-glow: 0 0 18px rgba(255,49,49,0.55), 0 0 40px rgba(139,0,0,0.3);
  --neon-glow-sm: 0 0 8px rgba(255,49,49,0.4);

  --bg: #0A0A0B;
  --bg2: #111113;
  --bg3: #17171A;
  --surface: rgba(255,255,255,0.04);
  --surface2: rgba(255,255,255,0.07);
  --border: rgba(255,255,255,0.08);
  --border-red: rgba(255,49,49,0.25);

  --text: #F2F2F5;
  --text-muted: #888899;
  --text-dim: #555566;

  --radius: 14px;
  --radius-sm: 8px;
  --radius-lg: 20px;
  --radius-xl: 28px;

  --sidebar-w: 280px;
  --topbar-h: 60px;

  --font-size: 15px;
  --transition: 0.2s cubic-bezier(0.4,0,0.2,1);
  --transition-slow: 0.4s cubic-bezier(0.4,0,0.2,1);

  --glass: rgba(17,17,19,0.85);
  --glass-border: rgba(255,255,255,0.07);
}

/* Light mode */
body.light-mode {
  --bg: #F5F4F2;
  --bg2: #EEECEA;
  --bg3: #E8E6E3;
  --surface: rgba(0,0,0,0.04);
  --surface2: rgba(0,0,0,0.07);
  --border: rgba(0,0,0,0.1);
  --text: #1A1A22;
  --text-muted: #666677;
  --text-dim: #AAAABC;
  --glass: rgba(245,244,242,0.9);
  --glass-border: rgba(0,0,0,0.08);
}

/* Glow intensities */
body.glow-minimal { --neon-glow: none; --neon-glow-sm: none; }
body.glow-strong  { --neon-glow: 0 0 30px rgba(255,49,49,0.8), 0 0 70px rgba(139,0,0,0.5); --neon-glow-sm: 0 0 14px rgba(255,49,49,0.6); }

/* Font sizes */
body.font-small  { --font-size: 13px; }
body.font-large  { --font-size: 17px; }

html { height: 100%; }

body {
  font-family: 'DM Sans', sans-serif;
  font-size: var(--font-size);
  background: var(--bg);
  color: var(--text);
  height: 100%;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
}

/* --- AMBIENT / NOISE --- */
.noise-overlay {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.035'/%3E%3C/svg%3E");
  background-size: 200px 200px;
  opacity: 0.6;
}

.ambient { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.blob {
  position: absolute; border-radius: 50%; filter: blur(80px); opacity: 0.12;
  animation: blobFloat 14s ease-in-out infinite;
}
.blob-1 { width: 500px; height: 500px; background: var(--neon); top: -200px; right: -100px; animation-delay: 0s; }
.blob-2 { width: 400px; height: 400px; background: var(--scarlet); bottom: -150px; left: -100px; animation-delay: -5s; }
.blob-3 { width: 300px; height: 300px; background: #FF6B35; top: 50%; left: 50%; transform: translate(-50%,-50%); animation-delay: -10s; opacity: 0.06; }

@keyframes blobFloat {
  0%, 100% { transform: translate(0,0) scale(1); }
  33% { transform: translate(30px,-20px) scale(1.05); }
  66% { transform: translate(-20px,30px) scale(0.95); }
}

/* --- APP LAYOUT --- */
.app {
  position: fixed; inset: 0; z-index: 1;
  display: flex;
}

/* =====================
   SIDEBAR
   ===================== */
.sidebar {
  width: var(--sidebar-w);
  height: 100%;
  background: var(--glass);
  backdrop-filter: blur(20px);
  border-right: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  gap: 0;
  transition: transform var(--transition-slow);
  z-index: 100;
  flex-shrink: 0;
}

.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border);
}

.logo {
  display: flex; align-items: center; gap: 8px;
  user-select: none;
}
.logo-icon {
  font-size: 22px;
  color: var(--neon);
  filter: drop-shadow(var(--neon-glow-sm));
  line-height: 1;
}
.logo-text {
  font-family: 'Syne', sans-serif;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: var(--text);
}
.logo-text em {
  font-style: normal;
  color: var(--neon);
}

.sidebar-close { display: none; }

.btn-new-chat {
  display: flex; align-items: center; gap: 8px;
  margin: 12px 12px 8px;
  padding: 10px 14px;
  background: linear-gradient(135deg, var(--scarlet), var(--neon));
  border: none; border-radius: var(--radius);
  color: #fff;
  font-family: 'DM Sans', sans-serif;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--neon-glow);
  letter-spacing: 0.01em;
}
.btn-new-chat:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 25px rgba(255,49,49,0.7), 0 4px 20px rgba(0,0,0,0.3);
}
.btn-new-chat svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 2.5; }

.sidebar-search {
  display: flex; align-items: center; gap: 8px;
  margin: 4px 12px 8px;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: var(--transition);
}
.sidebar-search:focus-within {
  border-color: var(--border-red);
  background: var(--surface2);
}
.sidebar-search svg { width: 13px; height: 13px; stroke: var(--text-muted); fill: none; stroke-width: 2; flex-shrink: 0; }
.sidebar-search input {
  flex: 1; background: none; border: none; outline: none;
  color: var(--text); font-size: 12.5px; font-family: inherit;
}
.sidebar-search input::placeholder { color: var(--text-dim); }

.chat-list-label {
  padding: 8px 16px 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.chat-list {
  flex: 1; overflow-y: auto; padding: 4px 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.chat-list::-webkit-scrollbar { width: 4px; }
.chat-list::-webkit-scrollbar-track { background: transparent; }
.chat-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.chat-item {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  margin-bottom: 1px;
  border: 1px solid transparent;
  animation: fadeInLeft 0.3s ease both;
}
@keyframes fadeInLeft {
  from { opacity: 0; transform: translateX(-12px); }
  to   { opacity: 1; transform: translateX(0); }
}
.chat-item:hover { background: var(--surface2); border-color: var(--border); }
.chat-item.active { background: var(--neon-dim); border-color: var(--border-red); }
.chat-item-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--neon); flex-shrink: 0; opacity: 0.6;
}
.chat-item.active .chat-item-dot { opacity: 1; box-shadow: 0 0 6px var(--neon); }
.chat-item-title {
  flex: 1; font-size: 13px; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-item.active .chat-item-title { color: var(--text); }
.chat-item-actions {
  display: none; gap: 2px;
}
.chat-item:hover .chat-item-actions { display: flex; }
.chat-item-actions button {
  background: none; border: none; cursor: pointer;
  color: var(--text-dim); padding: 3px 4px; border-radius: 4px;
  font-size: 11px; transition: var(--transition);
}
.chat-item-actions button:hover { color: var(--neon); background: var(--surface2); }

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
}
.btn-settings {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 9px 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); cursor: pointer;
  color: var(--text-muted); font-size: 13px; font-family: inherit;
  transition: var(--transition);
}
.btn-settings:hover { background: var(--surface2); color: var(--text); border-color: var(--border-red); }
.btn-settings svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; }

/* Sidebar overlay */
.sidebar-overlay {
  display: none; position: fixed; inset: 0; z-index: 99;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
}

/* =====================
   MAIN
   ===================== */
.main {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
  height: 100%;
  position: relative;
}

/* --- TOPBAR --- */
.topbar {
  display: flex; align-items: center; gap: 12px;
  height: var(--topbar-h); padding: 0 16px;
  background: var(--glass);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--glass-border);
  flex-shrink: 0;
  z-index: 10;
}

.hamburger { display: none; }

.topbar-title {
  flex: 1; font-family: 'Syne', sans-serif;
  font-size: 14px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--text);
}

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

/* --- CHAT AREA --- */
.chat-area {
  flex: 1; overflow-y: auto;
  padding: 24px 0;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  position: relative;
}
.chat-area::-webkit-scrollbar { width: 4px; }
.chat-area::-webkit-scrollbar-track { background: transparent; }
.chat-area::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* --- WELCOME SCREEN --- */
.welcome {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 60px 24px 40px;
  min-height: calc(100vh - var(--topbar-h) - 100px);
  animation: fadeUp 0.6s ease both;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}

.welcome-glyph {
  font-size: 56px; line-height: 1;
  color: var(--neon);
  filter: drop-shadow(var(--neon-glow));
  margin-bottom: 16px;
  animation: pulseGlow 3s ease-in-out infinite;
}
@keyframes pulseGlow {
  0%, 100% { filter: drop-shadow(0 0 15px rgba(255,49,49,0.5)); }
  50%       { filter: drop-shadow(0 0 35px rgba(255,49,49,0.9)); }
}

.welcome-title {
  font-family: 'Syne', sans-serif;
  font-size: clamp(32px, 5vw, 52px);
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--text);
  margin-bottom: 8px;
  text-align: center;
}
.welcome-title span { color: var(--neon); }

.welcome-sub {
  font-size: 15px; color: var(--text-muted);
  margin-bottom: 40px; text-align: center;
  letter-spacing: 0.02em;
}

.welcome-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
  width: 100%; max-width: 520px;
}

.prompt-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer; color: var(--text-muted);
  font-size: 13px; font-family: inherit; text-align: left;
  transition: var(--transition);
  animation: fadeUp 0.6s ease both;
}
.prompt-chip:nth-child(2) { animation-delay: 0.07s; }
.prompt-chip:nth-child(3) { animation-delay: 0.14s; }
.prompt-chip:nth-child(4) { animation-delay: 0.21s; }
.prompt-chip:hover {
  background: var(--neon-dim);
  border-color: var(--border-red);
  color: var(--text);
  transform: translateY(-2px);
  box-shadow: var(--neon-glow-sm);
}
.chip-icon { font-size: 16px; flex-shrink: 0; }

/* --- MESSAGES --- */
.messages {
  display: flex; flex-direction: column; gap: 0;
  max-width: 760px; margin: 0 auto;
  padding: 0 16px;
  width: 100%;
}

.msg {
  display: flex; gap: 12px;
  padding: 14px 0;
  animation: msgIn 0.35s cubic-bezier(0.4,0,0.2,1) both;
  position: relative;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

.msg-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; flex-shrink: 0; font-weight: 700;
  font-family: 'Syne', sans-serif;
  position: relative; top: 2px;
}
.msg.user .msg-avatar {
  background: linear-gradient(135deg, var(--scarlet), var(--neon));
  color: #fff;
  box-shadow: var(--neon-glow-sm);
  order: 2;
}
.msg.ai .msg-avatar {
  background: var(--surface2);
  border: 1px solid var(--border-red);
  color: var(--neon);
}

.msg-content-wrap {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 4px;
}
.msg.user .msg-content-wrap { order: 1; align-items: flex-end; }

.msg-meta {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; color: var(--text-dim);
}
.msg.user .msg-meta { flex-direction: row-reverse; }
.msg-name { font-weight: 600; color: var(--text-muted); }

.msg-bubble {
  max-width: 88%;
  padding: 11px 16px;
  border-radius: var(--radius);
  font-size: var(--font-size);
  line-height: 1.65;
  word-break: break-word;
  position: relative;
}

.msg.user .msg-bubble {
  background: linear-gradient(135deg, var(--scarlet), #A00000);
  color: #fff;
  border-radius: var(--radius) var(--radius-sm) var(--radius) var(--radius);
  box-shadow: 0 2px 12px rgba(139,0,0,0.35);
}
.msg.ai .msg-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm) var(--radius) var(--radius) var(--radius);
}

/* Code blocks in messages */
.msg-bubble pre {
  background: rgba(0,0,0,0.4);
  border: 1px solid var(--border);
  border-radius: 8px; padding: 12px 14px;
  overflow-x: auto; margin: 8px 0;
  font-size: 12.5px; line-height: 1.5;
}
.msg-bubble code {
  font-family: 'Fira Code', 'Cascadia Code', monospace;
  font-size: 12.5px;
  background: rgba(255,49,49,0.12);
  padding: 1px 5px; border-radius: 4px;
}
.msg-bubble pre code { background: none; padding: 0; }

/* Markdown in messages */
.msg-bubble h1,.msg-bubble h2,.msg-bubble h3 { margin: 8px 0 4px; font-family: 'Syne', sans-serif; }
.msg-bubble p { margin-bottom: 6px; }
.msg-bubble ul, .msg-bubble ol { padding-left: 20px; margin-bottom: 6px; }
.msg-bubble li { margin-bottom: 2px; }
.msg-bubble strong { color: var(--neon); font-weight: 600; }
.msg.user .msg-bubble strong { color: rgba(255,255,255,0.9); }
.msg-bubble a { color: var(--neon); text-decoration: underline; }

/* Image in message */
.msg-image {
  max-width: 260px; border-radius: 10px;
  border: 1px solid var(--border);
  cursor: pointer; display: block;
  transition: var(--transition);
}
.msg-image:hover { transform: scale(1.02); box-shadow: var(--neon-glow-sm); }

/* File attachment */
.msg-file {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  background: rgba(255,255,255,0.07);
  border: 1px solid var(--border);
  border-radius: 8px; font-size: 12.5px;
}
.msg-file svg { width: 14px; height: 14px; stroke: var(--neon); fill: none; stroke-width: 2; }

/* Message actions */
.msg-actions {
  display: flex; gap: 4px; margin-top: 4px;
  opacity: 0; transition: var(--transition);
}
.msg:hover .msg-actions { opacity: 1; }
.msg-action-btn {
  display: flex; align-items: center; gap: 4px;
  padding: 4px 8px; border-radius: 6px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text-dim); font-size: 11px;
  cursor: pointer; font-family: inherit;
  transition: var(--transition);
}
.msg-action-btn:hover { color: var(--neon); border-color: var(--border-red); background: var(--neon-dim); }
.msg-action-btn svg { width: 11px; height: 11px; stroke: currentColor; fill: none; stroke-width: 2; }

/* Typing indicator */
.typing-indicator {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 0;
  animation: msgIn 0.3s ease both;
}
.typing-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--surface2); border: 1px solid var(--border-red);
  display: flex; align-items: center; justify-content: center;
  color: var(--neon); font-size: 14px;
}
.typing-bubble {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm) var(--radius) var(--radius) var(--radius);
  padding: 12px 16px;
  display: flex; align-items: center; gap: 5px;
}
.typing-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--neon); opacity: 0.4;
  animation: typingBounce 1.2s ease-in-out infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* =====================
   INPUT ZONE
   ===================== */
.input-zone {
  padding: 12px 16px 14px;
  flex-shrink: 0;
  background: linear-gradient(to top, var(--bg) 70%, transparent);
  max-width: 792px; margin: 0 auto; width: 100%;
}

.attachment-previews {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-bottom: 8px;
}
.att-preview {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 8px;
  background: var(--neon-dim); border: 1px solid var(--border-red);
  font-size: 12px; color: var(--text);
  animation: fadeUp 0.2s ease both;
}
.att-preview-img {
  width: 36px; height: 36px; object-fit: cover; border-radius: 6px;
}
.att-remove {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 14px; line-height: 1;
  padding: 0 2px; transition: var(--transition);
}
.att-remove:hover { color: var(--neon); }

.input-bar {
  display: flex; align-items: flex-end; gap: 8px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  padding: 8px 8px 8px 12px;
  backdrop-filter: blur(20px);
  transition: var(--transition);
  box-shadow: 0 4px 24px rgba(0,0,0,0.2);
}
.input-bar:focus-within {
  border-color: var(--border-red);
  box-shadow: var(--neon-glow-sm), 0 4px 24px rgba(0,0,0,0.3);
}

.input-tools { display: flex; gap: 2px; align-items: center; }

.btn-attach {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none; border-radius: 8px;
  color: var(--text-dim); cursor: pointer;
  transition: var(--transition);
}
.btn-attach:hover { color: var(--neon); background: var(--neon-dim); box-shadow: var(--neon-glow-sm); }
.btn-attach svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 2; }

#messageInput {
  flex: 1; background: none; border: none; outline: none;
  color: var(--text); font-family: 'DM Sans', sans-serif;
  font-size: var(--font-size); line-height: 1.5;
  resize: none; max-height: 160px; overflow-y: auto;
  scrollbar-width: thin;
  padding: 6px 0;
  align-self: center;
}
#messageInput::placeholder { color: var(--text-dim); }

.input-right { display: flex; gap: 4px; align-items: center; }

.btn-voice {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 50%; color: var(--text-muted); cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
}
.btn-voice:hover { color: var(--neon); border-color: var(--border-red); box-shadow: var(--neon-glow-sm); }
.btn-voice.active { background: var(--neon-dim); border-color: var(--neon); color: var(--neon); animation: pulseBorder 1.5s ease infinite; }
.btn-voice svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; }
@keyframes pulseBorder {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,49,49,0.4); }
  50% { box-shadow: 0 0 0 5px rgba(255,49,49,0); }
}

.btn-send {
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--scarlet), var(--neon));
  border: none; border-radius: 50%;
  color: #fff; cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--neon-glow-sm);
  flex-shrink: 0;
}
.btn-send:hover {
  transform: scale(1.08);
  box-shadow: var(--neon-glow);
}
.btn-send:active { transform: scale(0.95); }
.btn-send svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 2; }

.input-hint {
  text-align: center; font-size: 11px; color: var(--text-dim);
  margin-top: 7px;
}

/* =====================
   ICON BUTTON (generic)
   ===================== */
.btn-icon {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); cursor: pointer;
  color: var(--text-muted); transition: var(--transition);
}
.btn-icon:hover { color: var(--neon); border-color: var(--border-red); background: var(--neon-dim); }
.btn-icon svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 2; }

/* =====================
   SETTINGS MODAL
   ===================== */
.modal-backdrop {
  display: none; position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.7); backdrop-filter: blur(8px);
  align-items: center; justify-content: center;
  padding: 16px;
}
.modal-backdrop.open { display: flex; animation: backdropIn 0.2s ease; }
@keyframes backdropIn { from { opacity: 0; } to { opacity: 1; } }

.settings-modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%; max-width: 620px;
  max-height: 85vh;
  display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  animation: modalSlide 0.3s cubic-bezier(0.4,0,0.2,1) both;
  overflow: hidden;
}
@keyframes modalSlide {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-header h2 { font-family: 'Syne', sans-serif; font-size: 17px; font-weight: 700; }
.modal-close { flex-shrink: 0; }

.settings-layout {
  display: flex; flex: 1; min-height: 0; overflow: hidden;
}

.settings-tabs {
  display: flex; flex-direction: column; gap: 2px;
  padding: 14px 10px;
  border-right: 1px solid var(--border);
  min-width: 150px; flex-shrink: 0;
  overflow-y: auto;
}
.stab {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  background: none; border: 1px solid transparent;
  cursor: pointer; color: var(--text-muted);
  font-size: 12.5px; font-family: inherit; text-align: left;
  transition: var(--transition);
  white-space: nowrap;
}
.stab:hover { background: var(--surface); color: var(--text); }
.stab.active { background: var(--neon-dim); border-color: var(--border-red); color: var(--text); }
.stab svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 2; flex-shrink: 0; }

.settings-panels {
  flex: 1; overflow-y: auto; padding: 16px 20px;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}

.spanel { display: none; }
.spanel.active { display: flex; flex-direction: column; gap: 20px; }

.setting-group {
  display: flex; flex-direction: column; gap: 10px;
}
.setting-label {
  font-size: 12px; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--text-muted);
  display: flex; align-items: center; gap: 8px;
}

.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
}
.toggle-row strong { font-size: 13.5px; font-weight: 600; }
.toggle-row p.setting-hint { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }

.toggle { position: relative; display: inline-flex; width: 42px; height: 24px; cursor: pointer; flex-shrink: 0; }
.toggle input { display: none; }
.toggle-slider {
  position: absolute; inset: 0; border-radius: 24px;
  background: var(--border); transition: var(--transition);
}
.toggle-slider::before {
  content: ''; position: absolute;
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; top: 3px; left: 3px;
  transition: var(--transition);
}
.toggle input:checked + .toggle-slider { background: var(--neon); box-shadow: var(--neon-glow-sm); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); }

.color-swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch {
  width: 28px; height: 28px; border-radius: 50%;
  border: 2px solid transparent; cursor: pointer;
  transition: var(--transition);
}
.swatch:hover, .swatch.active { border-color: #fff; transform: scale(1.15); box-shadow: 0 0 10px rgba(255,255,255,0.3); }

.btn-group {
  display: flex; gap: 6px;
}
.btn-group.vertical { flex-direction: column; }
.bgroup-btn {
  flex: 1; padding: 8px 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); cursor: pointer;
  color: var(--text-muted); font-size: 12.5px; font-family: inherit;
  transition: var(--transition); text-align: center;
}
.bgroup-btn:hover { background: var(--surface2); color: var(--text); }
.bgroup-btn.active { background: var(--neon-dim); border-color: var(--border-red); color: var(--text); }

.range-slider {
  width: 100%; -webkit-appearance: none; appearance: none;
  height: 4px; border-radius: 4px;
  background: var(--border); outline: none;
}
.range-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--neon); cursor: pointer;
  box-shadow: var(--neon-glow-sm);
  transition: var(--transition);
}
.range-slider::-webkit-slider-thumb:hover { transform: scale(1.2); }
.range-labels { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-dim); margin-top: 4px; }
.range-val { color: var(--neon); font-weight: 600; }

.api-input-row { display: flex; gap: 8px; }
.text-input {
  flex: 1; padding: 9px 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text);
  font-family: inherit; font-size: 13px; outline: none;
  transition: var(--transition);
}
.text-input:focus { border-color: var(--border-red); background: var(--surface2); }

.btn-primary-sm {
  padding: 9px 16px;
  background: linear-gradient(135deg, var(--scarlet), var(--neon));
  border: none; border-radius: var(--radius-sm);
  color: #fff; font-size: 12.5px; font-family: inherit;
  font-weight: 600; cursor: pointer; transition: var(--transition);
  white-space: nowrap;
  box-shadow: var(--neon-glow-sm);
}
.btn-primary-sm:hover { transform: translateY(-1px); box-shadow: var(--neon-glow); }

.btn-text-sm {
  background: none; border: none; cursor: pointer;
  color: var(--text-dim); font-size: 12px; font-family: inherit;
  padding: 4px 0; text-decoration: underline;
  transition: var(--transition);
}
.btn-text-sm:hover { color: var(--neon); }

.btn-danger-outline {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px;
  background: rgba(255,49,49,0.05);
  border: 1px solid rgba(255,49,49,0.3);
  border-radius: var(--radius-sm); cursor: pointer;
  color: #FF5555; font-size: 13px; font-family: inherit;
  transition: var(--transition);
}
.btn-danger-outline:hover { background: rgba(255,49,49,0.12); border-color: var(--neon); }
.btn-danger-outline svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; }

/* =====================
   LIGHTBOX
   ===================== */
.lightbox {
  display: none; position: fixed; inset: 0; z-index: 2000;
  background: rgba(0,0,0,0.92); backdrop-filter: blur(12px);
  align-items: center; justify-content: center;
}
.lightbox.open { display: flex; animation: backdropIn 0.2s ease; }
.lightbox-close {
  position: absolute; top: 20px; right: 20px;
  width: 40px; height: 40px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); transition: var(--transition);
}
.lightbox-close:hover { color: var(--neon); border-color: var(--border-red); }
.lightbox-close svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; }
#lightboxImg {
  max-width: 90vw; max-height: 88vh;
  border-radius: var(--radius);
  box-shadow: 0 20px 80px rgba(0,0,0,0.6);
  animation: modalSlide 0.3s ease;
}

/* =====================
   TOAST
   ===================== */
.toast-container {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
  z-index: 9999; display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  padding: 10px 18px; border-radius: 20px;
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--text); font-size: 13px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  animation: toastIn 0.3s ease both;
  pointer-events: auto;
  white-space: nowrap;
}
.toast.success { border-color: var(--border-red); color: var(--neon); }
.toast.error { border-color: rgba(255,80,80,0.4); color: #FF5555; }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(-10px) scale(0.95); }
}

/* =====================
   RENAME INPUT
   ===================== */
.chat-item-title input {
  background: none; border: none; border-bottom: 1px solid var(--border-red);
  outline: none; color: var(--text); font-size: 13px; width: 100%;
  padding: 0; font-family: inherit;
}

/* =====================
   SCROLLBAR for chat
   ===================== */
.chat-area { padding-bottom: 8px; }

/* =====================
   RESPONSIVE
   ===================== */
@media (max-width: 720px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    transform: translateX(-100%);
    z-index: 200;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: flex; }
  .sidebar-overlay.open { display: block; }
  .hamburger { display: flex; }

  .welcome-grid { grid-template-columns: 1fr; }
  .welcome { padding: 40px 16px 30px; }

  .settings-layout { flex-direction: column; }
  .settings-tabs { flex-direction: row; overflow-x: auto; border-right: none; border-bottom: 1px solid var(--border); padding: 10px; min-width: 0; }
  .stab { flex-shrink: 0; }

  .input-zone { padding: 8px 10px 12px; }

  .messages { padding: 0 10px; }
}

@media (max-width: 440px) {
  .btn-voice { display: none; }
  .topbar-actions .btn-icon:first-child { display: none; }
}

/* Empty chat-list state */
.empty-state {
  text-align: center; padding: 24px 16px;
  color: var(--text-dim); font-size: 12.5px;
}
.empty-state svg { width: 28px; height: 28px; stroke: var(--text-dim); fill: none; stroke-width: 1.5; margin: 0 auto 8px; display: block; }
