.chat-screen {
  position: fixed; inset: 0; z-index: 300;
  display: flex; overflow: hidden;
  background: linear-gradient(160deg, #0a0118 0%, #150330 100%);
  animation: fadeIn .4s ease;
}

.chat-sidebar {
  width: 260px; flex-shrink: 0;
  background: rgba(13,2,32,0.98);
  border-right: 1px solid var(--clr-border);
  display: flex; flex-direction: column;
  padding: 20px 14px;
  transition: width 0.3s cubic-bezier(.4,0,.2,1), opacity 0.3s ease;
  overflow: hidden; position: relative; z-index: 10;
}
.chat-sidebar.collapsed { width: 0; padding: 0; opacity: 0; pointer-events: none; }

.sidebar-top { margin-bottom: 20px; flex-shrink: 0; }
.sidebar-logo { display: flex; align-items: center; gap: 9px; margin-bottom: 16px; }
.sidebar-logo .logo-icon { width: 32px; height: 32px; font-size: 15px; flex-shrink: 0; }
.sidebar-logo .logo-text { font-size: 16px; white-space: nowrap; }

.new-chat-btn {
  width: 100%; display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; border-radius: 10px; border: none; cursor: pointer;
  background: linear-gradient(135deg, var(--clr-accent), var(--clr-accent2));
  color: white; font-family: var(--font-h); font-weight: 600; font-size: 13px;
  box-shadow: 0 4px 14px rgba(231,84,128,0.35); white-space: nowrap;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.new-chat-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(231,84,128,0.5); }

.sidebar-section-label {
  font-family: var(--font-h); font-size: 10px; font-weight: 700;
  letter-spacing: 1.2px; text-transform: uppercase;
  color: rgba(255,255,255,0.25); padding: 0 6px; margin-bottom: 8px;
}

.chat-history { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.chat-history::-webkit-scrollbar { width: 4px; }
.chat-history::-webkit-scrollbar-track { background: transparent; }
.chat-history::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

.history-item {
  display: flex; align-items: center; gap: 6px;
  padding: 9px 10px; border-radius: 9px; cursor: pointer;
  transition: background 0.2s ease; min-width: 0;
}
.history-item:hover { background: rgba(255,255,255,0.07); }
.history-item.active { background: rgba(231,84,128,0.12); }
.history-item:hover .history-actions { opacity: 1; }

.history-title {
  flex: 1; font-size: 13px; color: rgba(255,255,255,0.6);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.history-item.active .history-title,
.history-item:hover .history-title { color: white; }

.history-actions { display: flex; gap: 3px; opacity: 0; transition: opacity 0.2s ease; flex-shrink: 0; }

.history-action-btn {
  background: none; border: none; cursor: pointer;
  color: rgba(255,255,255,0.3); display: flex; align-items: center;
  padding: 3px; border-radius: 5px; transition: color 0.2s ease, background 0.2s ease;
}
.history-action-btn:hover { color: white; background: rgba(255,255,255,0.1); }
.history-delete-btn:hover { color: #ff6b6b; background: rgba(255,107,107,0.1); }

.history-rename-input {
  flex: 1; background: rgba(255,255,255,0.08);
  border: 1px solid var(--clr-accent); border-radius: 5px;
  color: white; font-size: 13px; font-family: var(--font-b);
  padding: 2px 6px; outline: none; width: 100%; min-width: 0;
}

.sidebar-bottom { border-top: 1px solid var(--clr-border); padding-top: 14px; margin-top: 10px; position: relative; flex-shrink: 0; }
.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 6px; border-radius: 10px; cursor: pointer;
  transition: background 0.2s ease; min-width: 0;
}
.sidebar-user:hover { background: rgba(255,255,255,0.06); }

.sidebar-avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--clr-accent), var(--clr-accent2));
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-h); font-weight: 800; font-size: 14px;
  box-shadow: 0 3px 10px rgba(231,84,128,0.4);
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-username {
  display: block; font-family: var(--font-h); font-weight: 700;
  font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-plan { font-size: 11px; color: rgba(255,255,255,0.35); }

.signout-icon-btn {
  background: none; border: none; cursor: pointer;
  color: rgba(255,255,255,0.3); padding: 5px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  transition: color 0.2s ease, background 0.2s ease; flex-shrink: 0;
}
.signout-icon-btn:hover { color: white; background: rgba(255,255,255,0.08); }

.sidebar-close-btn { display: none; }

.user-panel {
  position: absolute; bottom: 70px; left: 10px; right: 10px;
  background: linear-gradient(135deg, #1e0640, #130328);
  border: 1px solid rgba(255,255,255,0.14); border-radius: 14px;
  padding: 8px; z-index: 100;
  box-shadow: 0 16px 40px rgba(0,0,0,0.6); backdrop-filter: blur(20px);
  animation: slideUp 0.2s ease;
}
.user-panel-header { display: flex; align-items: center; gap: 10px; padding: 10px 10px 12px; }
.user-panel-avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--clr-accent), var(--clr-accent2));
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-h); font-weight: 800; font-size: 15px;
  box-shadow: 0 3px 10px rgba(231,84,128,0.4);
}
.user-panel-name { font-family: var(--font-h); font-weight: 700; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-panel-email { font-size: 11px; color: rgba(255,255,255,0.35); overflow: hidden; text-overflow: ellipsis; }
.user-panel-divider { height: 1px; background: rgba(255,255,255,0.08); margin: 4px 0; }
.user-panel-item {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 9px; border: none; cursor: pointer;
  background: transparent; color: rgba(255,255,255,0.7);
  font-family: var(--font-b); font-size: 13px; text-align: left;
  transition: background 0.2s ease, color 0.2s ease;
}
.user-panel-item:hover { background: rgba(255,255,255,0.07); color: white; }
.user-panel-signout { color: rgba(255,100,100,0.8); }
.user-panel-signout:hover { background: rgba(255,100,100,0.1); color: #ff8080; }

.signout-modal-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.25s ease; padding: 20px;
}
.signout-modal-card {
  background: linear-gradient(135deg, #1a0535, #0d0220);
  border: 1px solid rgba(255,255,255,0.14); border-radius: 22px;
  padding: 36px 32px; text-align: center; max-width: 360px; width: 100%;
  animation: slideUp 0.25s ease;
}
.signout-modal-icon {
  width: 56px; height: 56px; border-radius: 50%;
  background: rgba(231,84,128,0.12); border: 1px solid rgba(231,84,128,0.3);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 18px; color: var(--clr-accent);
}
.signout-modal-title { font-family: var(--font-h); font-weight: 800; font-size: 20px; margin-bottom: 8px; }
.signout-modal-sub { color: var(--clr-muted); font-size: 13.5px; margin-bottom: 26px; }
.signout-modal-btns { display: flex; gap: 10px; }
.signout-cancel-btn {
  flex: 1; padding: 12px; border-radius: 11px; cursor: pointer;
  background: transparent; border: 1.5px solid rgba(255,255,255,0.2);
  color: var(--clr-muted); font-family: var(--font-h); font-weight: 600; font-size: 14px;
  transition: all 0.2s ease;
}
.signout-cancel-btn:hover { border-color: rgba(255,255,255,0.4); color: white; }
.signout-confirm-btn {
  flex: 1; padding: 12px; border-radius: 11px; cursor: pointer; border: none;
  background: linear-gradient(135deg, var(--clr-accent), var(--clr-accent2));
  color: white; font-family: var(--font-h); font-weight: 700; font-size: 14px;
  box-shadow: 0 4px 14px rgba(231,84,128,0.4); transition: all 0.2s ease;
}
.signout-confirm-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(231,84,128,0.55); }

.chat-main { flex: 1; display: flex; flex-direction: column; overflow: hidden; position: relative; min-width: 0; width: 100%; }

.chat-topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 20px; border-bottom: 1px solid var(--clr-border);
  background: rgba(255,255,255,0.02); flex-shrink: 0;
}
.sidebar-toggle {
  background: none; border: none; cursor: pointer;
  color: rgba(255,255,255,0.5); display: flex; padding: 6px; border-radius: 8px;
  transition: color 0.2s ease, background 0.2s ease; flex-shrink: 0;
}
.sidebar-toggle:hover { color: white; background: rgba(255,255,255,0.07); }
.chat-model-label {
  font-family: var(--font-h); font-weight: 700; font-size: 15px;
  background: linear-gradient(135deg, #fff, rgba(255,255,255,0.7));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}

.chat-messages {
  flex: 1; overflow-y: auto; overflow-x: hidden; padding: 30px 20px;
  display: flex; flex-direction: column; gap: 20px;
}
.chat-messages::-webkit-scrollbar { width: 5px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

.chat-welcome {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  flex: 1; text-align: center; position: relative; padding: 40px 20px;
}
.welcome-orb-1 {
  position: absolute; width: 400px; height: 400px; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, rgba(147,51,234,0.1) 0%, transparent 70%);
  top: 50%; left: 50%; transform: translate(-50%, -50%);
}
.welcome-orb-2 {
  position: absolute; width: 250px; height: 250px; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, rgba(231,84,128,0.08) 0%, transparent 70%);
  top: 40%; left: 60%; transform: translate(-50%, -50%);
}
.welcome-title {
  font-family: var(--font-h); font-weight: 800; font-size: 32px;
  letter-spacing: -0.5px; margin-bottom: 28px; position: relative;
  background: linear-gradient(135deg, #fff 40%, rgba(255,255,255,0.6));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}

.suggestion-chips { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; max-width: 560px; position: relative; }
.chip {
  padding: 10px 18px; border-radius: 50px;
  border: 1px solid rgba(255,255,255,0.15); background: rgba(255,255,255,0.05);
  color: rgba(255,255,255,0.75); font-family: var(--font-b); font-size: 13.5px;
  cursor: pointer; backdrop-filter: blur(8px); transition: all 0.25s;
}
.chip:hover {
  background: rgba(231,84,128,0.12); border-color: rgba(231,84,128,0.4);
  color: white; transform: translateY(-2px); box-shadow: 0 6px 20px rgba(231,84,128,0.2);
}

.msg { display: flex; flex-direction: column; max-width: 720px; animation: msgIn 0.3s ease; }
@keyframes msgIn { from{opacity:0;transform:translateY(10px);} to{opacity:1;transform:translateY(0);} }

.msg.user { align-self: flex-end; align-items: flex-end; }
.msg.ai   { align-self: flex-start; align-items: flex-start; }

.msg-row { display: flex; gap: 12px; align-items: flex-end; }
.msg.user .msg-row { flex-direction: row-reverse; }

.msg-actions {
  display: flex; gap: 4px; align-items: center;
  margin-top: 5px; opacity: 0; transition: opacity 0.2s ease;
}
.msg:hover .msg-actions { opacity: 1; }
.msg.user .msg-actions { margin-right: 44px; justify-content: flex-end; }
.msg.ai  .msg-actions  { margin-left: 44px; }

.msg-action-btn {
  background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 7px; padding: 5px 7px; cursor: pointer;
  color: rgba(255,255,255,0.4); display: flex; align-items: center;
  transition: color 0.2s, background 0.2s, border-color 0.2s;
}
.msg-action-btn:hover { color: white; background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.2); }
.msg-action-btn.msg-action-active { color: var(--clr-accent); border-color: rgba(231,84,128,0.4); background: rgba(231,84,128,0.1); }

.msg-avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-h); font-weight: 800; font-size: 13px;
}
.msg.user .msg-avatar { background: linear-gradient(135deg, var(--clr-accent), var(--clr-accent2)); box-shadow: 0 3px 10px rgba(231,84,128,0.4); }
.msg.ai .msg-avatar   { background: linear-gradient(135deg, var(--clr-accent), var(--clr-accent2)); box-shadow: 0 3px 10px rgba(147,51,234,0.4); }
.ai-avatar-inner { font-family: var(--font-h); font-weight: 800; font-size: 16px; color: white; }

.msg-bubble {
  padding: 12px 16px; border-radius: 16px;
  font-size: 14px; line-height: 1.65; max-width: 560px;
  word-break: break-word; overflow-wrap: break-word;
}
.msg.user .msg-bubble {
  background: linear-gradient(135deg, var(--clr-accent), var(--clr-accent2));
  border-radius: 16px 4px 16px 16px; box-shadow: 0 4px 16px rgba(231,84,128,0.3);
}
.msg.ai .msg-bubble {
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 4px 16px 16px 16px; color: rgba(255,255,255,0.9);
}

.msg.ai .msg-bubble h1,.msg.ai .msg-bubble h2,.msg.ai .msg-bubble h3 {
  font-family: var(--font-h); font-weight: 700; font-size: 15px; margin: 12px 0 6px; color: white;
}
.msg.ai .msg-bubble h1:first-child,.msg.ai .msg-bubble h2:first-child,.msg.ai .msg-bubble h3:first-child { margin-top: 0; }
.msg.ai .msg-bubble p { margin-bottom: 8px; line-height: 1.7; }
.msg.ai .msg-bubble p:last-child { margin-bottom: 0; }
.msg.ai .msg-bubble ul,.msg.ai .msg-bubble ol { padding-left: 20px; margin-bottom: 10px; line-height: 2; }
.msg.ai .msg-bubble li { margin-bottom: 2px; }
.msg.ai .msg-bubble strong { color: white; font-weight: 700; }
.msg.ai .msg-bubble em { color: rgba(255,255,255,0.75); font-style: italic; }
.msg.ai .msg-bubble code { background: rgba(255,255,255,0.1); padding: 2px 7px; border-radius: 5px; font-size: 12.5px; font-family: monospace; color: #e2b4ff; }
.msg.ai .msg-bubble pre { background: rgba(0,0,0,0.35); border: 1px solid rgba(255,255,255,0.1); border-radius: 10px; padding: 14px; margin: 10px 0; overflow-x: auto; position: relative; }
.msg.ai .msg-bubble pre code { background: none; padding: 0; font-size: 13px; color: #e2b4ff; }
.msg.ai .msg-bubble blockquote { border-left: 3px solid var(--clr-accent); padding-left: 12px; margin: 8px 0; color: rgba(255,255,255,0.6); }
.msg.ai .msg-bubble hr { border: none; border-top: 1px solid rgba(255,255,255,0.1); margin: 12px 0; }
.msg.ai .msg-bubble a { color: var(--clr-accent); text-decoration: none; }
.msg.ai .msg-bubble a:hover { text-decoration: underline; }

.code-copy-btn {
  position: absolute; top: 8px; right: 8px;
  background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.15);
  border-radius: 6px; padding: 4px 10px; cursor: pointer;
  color: rgba(255,255,255,0.6); font-size: 11px; font-family: var(--font-b); transition: all 0.2s;
}
.code-copy-btn:hover { background: rgba(255,255,255,0.2); color: white; }

.msg-image { max-width: 100%; max-height: 300px; border-radius: 10px; display: block; margin-bottom: 4px; }

.typing-cursor { display: inline-block; animation: cursorBlink 0.7s infinite; color: var(--clr-accent); font-weight: 400; }
@keyframes cursorBlink { 0%,100%{opacity:1;} 50%{opacity:0;} }

.typing-indicator { display: flex; gap: 5px; padding: 4px 2px; }
.typing-dot { width: 7px; height: 7px; border-radius: 50%; background: rgba(255,255,255,0.4); animation: typingBounce 1.2s 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(-6px);opacity:1;} }

.chat-input-area { padding: 16px 20px 20px; border-top: 1px solid var(--clr-border); background: rgba(255,255,255,0.02); flex-shrink: 0; }
.image-preview-bar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12); border-radius: 10px; margin-bottom: 10px; }
.preview-thumb { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; flex-shrink: 0; }
.preview-name { flex: 1; font-size: 13px; color: rgba(255,255,255,0.7); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.preview-remove { background: none; border: none; color: rgba(255,255,255,0.4); cursor: pointer; font-size: 14px; padding: 4px; transition: color 0.2s; flex-shrink: 0; }
.preview-remove:hover { color: white; }

.chat-input-wrap {
  display: flex; align-items: flex-end; gap: 10px;
  background: rgba(255,255,255,0.06); border: 1.5px solid rgba(255,255,255,0.14);
  border-radius: 16px; padding: 10px 12px; transition: border-color 0.3s, box-shadow 0.3s;
}
.chat-input-wrap:focus-within { border-color: var(--clr-accent); box-shadow: 0 0 0 3px rgba(231,84,128,0.1); }
.attach-btn { background: none; border: none; cursor: pointer; color: rgba(255,255,255,0.35); display: flex; padding: 4px; flex-shrink: 0; border-radius: 6px; transition: color 0.2s, background 0.2s; align-self: flex-end; margin-bottom: 2px; }
.attach-btn:hover { color: white; background: rgba(255,255,255,0.08); }

.chat-textarea { flex: 1; background: none; border: none; outline: none; color: white; font-family: var(--font-b); font-size: 14px; resize: none; max-height: 160px; line-height: 1.5; scrollbar-width: none; min-width: 0; }
.chat-textarea::-webkit-scrollbar { display: none; }
.chat-textarea::placeholder { color: rgba(255,255,255,0.3); }

.send-btn {
  width: 36px; height: 36px; border-radius: 10px; border: none; cursor: pointer;
  background: linear-gradient(135deg, var(--clr-accent), var(--clr-accent2));
  color: white; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; box-shadow: 0 3px 12px rgba(231,84,128,0.4);
  transition: transform 0.2s, box-shadow 0.2s, background 0.2s; align-self: flex-end;
}
.send-btn:hover { transform: scale(1.08); box-shadow: 0 5px 18px rgba(231,84,128,0.55); }
.send-btn:active { transform: scale(0.95); }
.send-btn.cancel-mode { background: rgba(255,255,255,0.12); box-shadow: none; border: 1.5px solid rgba(255,255,255,0.2); }
.send-btn.cancel-mode:hover { background: rgba(255,255,255,0.18); transform: scale(1.05); box-shadow: none; }

.chat-disclaimer { text-align: center; font-size: 11px; color: rgba(255,255,255,0.22); margin-top: 10px; font-family: var(--font-b); }

@media (max-width: 1024px) {
  .sidebar-logo { display: flex; align-items: center; }
  .sidebar-close-btn {
    display: flex; align-items: center; justify-content: center;
    margin-left: auto; background: none; border: none; cursor: pointer;
    color: rgba(255,255,255,0.5); padding: 4px; border-radius: 6px; flex-shrink: 0;
    transition: color 0.2s, background 0.2s;
  }
  .sidebar-close-btn:hover { color: white; background: rgba(255,255,255,0.08); }
}

@media (max-width: 600px) {
  .chat-sidebar {
    position: fixed !important; top: 0 !important; left: 0 !important;
    bottom: 0 !important; height: 100dvh !important; width: 75vw !important;
    max-width: 280px !important; z-index: 200 !important;
    transform: translateX(-100%) !important;
    transition: transform 0.3s cubic-bezier(.4,0,.2,1) !important;
    opacity: 1 !important; pointer-events: all !important; padding: 20px 14px !important;
  }
  .chat-sidebar:not(.collapsed) { transform: translateX(0) !important; box-shadow: 8px 0 32px rgba(0,0,0,0.7) !important; }
  .chat-sidebar.collapsed { transform: translateX(-100%) !important; }
  .chat-main { width: 100vw !important; min-width: 0 !important; }
  .welcome-title { font-size: 20px; margin-bottom: 20px; }
  .chip { font-size: 12px; padding: 8px 12px; }
  .suggestion-chips { gap: 7px; }
  .msg { max-width: 92%; }
  .msg-bubble { font-size: 13.5px; padding: 10px 13px; }
  .msg-actions { display: flex !important; opacity: 1 !important; }
  .msg.user .msg-actions { margin-right: 0; }
  .msg.ai  .msg-actions  { margin-left: 0; }
  .chat-messages { padding: 14px 12px; gap: 14px; }
  .chat-input-area { padding: 10px 12px 12px; }
  .chat-textarea { font-size: 16px; }
  .chat-topbar { padding: 12px 14px; gap: 10px; }
  .signout-modal-card { padding: 24px 16px; }
  .signout-modal-btns { flex-direction: column; }
}