:root {
  --clr-bg-left:   #0d0220;
  --clr-bg-left2:  #190838;
  --clr-accent:    #e75480;
  --clr-accent2:   #9333ea;
  --clr-text:      #ffffff;
  --clr-muted:     rgba(255,255,255,0.45);
  --clr-faint:     rgba(255,255,255,0.10);
  --clr-border:    rgba(255,255,255,0.14);
  --clr-input-bg:  rgba(255,255,255,0.06);
  --font-h:        'Sora', sans-serif;
  --font-b:        'DM Sans', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: var(--font-b);
  background: var(--clr-bg-left);
  color: var(--clr-text);
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

.toast {
  position: fixed; top: 24px; left: 50%;
  transform: translateX(-50%); z-index: 9999;
  display: flex; align-items: center; gap: 10px;
  padding: 13px 22px; border-radius: 14px;
  font-family: var(--font-h); font-size: 13.5px; font-weight: 600;
  white-space: nowrap; backdrop-filter: blur(16px);
  box-shadow: 0 10px 40px rgba(0,0,0,0.5); animation: toastIn 0.35s ease;
}
.toast.success { background: linear-gradient(135deg,#112d1f,#1a4731); border: 1px solid rgba(105,219,124,0.35); }
.toast.error   { background: linear-gradient(135deg,#3a0f17,#5e1b27); border: 1px solid rgba(255,107,107,0.35); }
.toast.info    { background: linear-gradient(135deg,#0e1f3a,#1a3560); border: 1px solid rgba(116,192,252,0.35); }

@keyframes toastIn {
  from { opacity:0; transform: translateX(-50%) translateY(-16px); }
  to   { opacity:1; transform: translateX(-50%) translateY(0); }
}

.auth-wrapper { display: flex; min-height: 100vh; }
.panel { display: flex; align-items: center; justify-content: center; position: relative; overflow: hidden; }
.panel-form {
  flex: 1; min-height: 100vh;
  background: linear-gradient(155deg, var(--clr-bg-left) 0%, var(--clr-bg-left2) 60%, #120430 100%);
  padding: 48px 40px;
}
.orb { position: absolute; border-radius: 50%; pointer-events: none; }
.orb-top    { width:380px; height:380px; background:radial-gradient(circle,rgba(147,51,234,.18) 0%,transparent 70%); top:-120px; left:-100px; }
.orb-bottom { width:260px; height:260px; background:radial-gradient(circle,rgba(231,84,128,.14) 0%,transparent 70%); bottom:40px; right:-60px; }
.form-container { width: 100%; max-width: 420px; margin: 0 auto; position: relative; z-index: 1; }

.logo { display: flex; align-items: center; gap: 10px; margin-bottom: 34px; }
.logo-icon {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, var(--clr-accent), var(--clr-accent2));
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; box-shadow: 0 4px 16px rgba(231,84,128,0.4);
}
.logo-text {
  font-family: var(--font-h); font-weight: 800; font-size: 19px; letter-spacing: -0.4px;
  background: linear-gradient(135deg, #fff 30%, rgba(255,255,255,0.65));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}

.tab-toggle {
  display: flex; background: var(--clr-faint); border: 1px solid var(--clr-border);
  border-radius: 14px; padding: 4px; margin-bottom: 34px; position: relative;
}
.tab-btn {
  flex: 1; padding: 11px; border: none; background: transparent; color: var(--clr-muted);
  font-family: var(--font-h); font-weight: 600; font-size: 14px; cursor: pointer;
  border-radius: 11px; transition: color 0.3s cubic-bezier(.4,0,.2,1); position: relative; z-index: 1;
}
.tab-btn.active { color: white; }
.tab-indicator {
  position: absolute; top:4px; bottom:4px; width: calc(50% - 4px); left: 4px;
  border-radius: 10px; background: linear-gradient(135deg, var(--clr-accent), var(--clr-accent2));
  box-shadow: 0 4px 16px rgba(231,84,128,0.4); transition: left 0.3s cubic-bezier(.4,0,.2,1); pointer-events: none;
}
.tab-indicator.right { left: calc(50%); }

.form-body { transition: opacity .3s ease, transform .3s ease; }
.form-body.fading { opacity:0; transform: translateY(14px); }

.form-heading { margin-bottom: 26px; }
.form-heading h1 {
  font-family: var(--font-h); font-weight: 800; font-size: 27px;
  letter-spacing: -0.5px; line-height: 1.1; margin-bottom: 6px;
}
.form-heading p { color: var(--clr-muted); font-size: 13.5px; }

.input-group { margin-bottom: 14px; }
.input-wrap {
  display: flex; align-items: center; gap: 12px;
  background: var(--clr-input-bg); border: 1.5px solid var(--clr-border);
  border-radius: 13px; padding: 13px 16px;
  transition: border-color 0.3s cubic-bezier(.4,0,.2,1), background 0.3s cubic-bezier(.4,0,.2,1), box-shadow 0.3s cubic-bezier(.4,0,.2,1);
}
.input-wrap:focus-within {
  border-color: var(--clr-accent); background: rgba(255,255,255,0.09);
  box-shadow: 0 0 0 3px rgba(231,84,128,0.12);
}
.input-wrap.has-error { border-color: #ff6b6b; }
.input-icon { color: var(--clr-muted); display:flex; flex-shrink:0; }
.input-wrap input { flex:1; background:none; border:none; outline:none; color:white; font-family:var(--font-b); font-size:14px; }
.input-wrap input::placeholder { color: rgba(255,255,255,0.32); }

.eye-btn { background:none; border:none; cursor:pointer; color:var(--clr-muted); display:flex; padding:0; transition: color 0.3s cubic-bezier(.4,0,.2,1); }
.eye-btn:hover { color:white; }

.field-error { color:#ff9090; font-size:11.5px; margin:4px 0 0 4px; min-height:16px; }

.strength-wrap { margin:-4px 0 14px; padding:0 2px; }
.strength-bars { display:flex; gap:5px; margin-bottom:4px; }
.strength-bar  { flex:1; height:4px; border-radius:3px; background:rgba(255,255,255,0.12); transition:background .4s ease; }
.strength-label { font-size:11px; float:right; font-weight:600; }

.remember-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.remember-label { display:flex; align-items:center; gap:8px; color:var(--clr-muted); font-size:13px; cursor:pointer; }
.remember-label input[type="checkbox"] { accent-color:var(--clr-accent); width:14px; height:14px; cursor:pointer; }
.forgot-link { color:var(--clr-accent); font-size:13px; text-decoration:none; font-weight:600; transition:opacity 0.3s cubic-bezier(.4,0,.2,1); }
.forgot-link:hover { opacity:.75; }

.submit-btn {
  width: 100%; padding: 15px; border-radius: 12px; border: none; cursor: pointer;
  background: linear-gradient(135deg, var(--clr-accent) 0%, var(--clr-accent2) 100%);
  color: white; font-family: var(--font-h); font-weight: 700; font-size: 15px;
  letter-spacing: 0.4px; position: relative; overflow: hidden; margin-bottom: 20px;
  box-shadow: 0 6px 20px rgba(231,84,128,0.4);
  transition: transform 0.3s cubic-bezier(.4,0,.2,1), box-shadow 0.3s cubic-bezier(.4,0,.2,1);
}
.submit-btn:hover { transform:translateY(-2px); box-shadow:0 12px 30px rgba(231,84,128,0.55); }
.submit-btn:active { transform:translateY(0); }

.btn-shimmer {
  position:absolute; inset:0;
  background: linear-gradient(105deg, transparent 40%, rgba(255,255,255,0.15) 50%, transparent 60%);
  background-size: 200% 100%; animation: shimmer 2.8s infinite;
}
@keyframes shimmer {
  0%  { background-position: -200% center; }
  100%{ background-position: 200% center; }
}

.divider { text-align:center; margin-bottom:18px; position:relative; }
.divider::before, .divider::after { content:''; position:absolute; top:50%; width:28%; height:1px; background:var(--clr-border); }
.divider::before { left:0; } .divider::after { right:0; }
.divider span { color:rgba(255,255,255,0.28); font-size:12px; }

.social-row { display:flex; justify-content:center; gap:12px; margin-bottom:22px; }
.social-btn {
  width:44px; height:44px; border-radius:50%;
  border:1.5px solid rgba(255,255,255,0.2); background:rgba(255,255,255,0.06);
  color:white; display:flex; align-items:center; justify-content:center;
  cursor:pointer; backdrop-filter:blur(4px); transition:all 0.3s cubic-bezier(.4,0,.2,1);
}
.social-btn:hover { background:rgba(255,255,255,0.16); border-color:rgba(255,255,255,0.4); transform:translateY(-3px); box-shadow:0 6px 20px rgba(0,0,0,0.3); }

.switch-text { text-align:center; color:rgba(255,255,255,0.35); font-size:13px; }
.switch-btn {
  background:none; border:none; color:var(--clr-accent); cursor:pointer;
  font-weight:700; font-size:13px; font-family:inherit; padding:0 0 0 5px;
  transition:opacity 0.3s cubic-bezier(.4,0,.2,1);
}
.switch-btn:hover { opacity:.75; }

.verify-screen {
  position:fixed; inset:0; z-index:200;
  background: linear-gradient(135deg,#0d0220 0%,#2a0845 50%,#5e0a6e 100%);
  display:flex; align-items:center; justify-content:center; animation:fadeIn .4s ease;
}
@keyframes fadeIn { from{opacity:0;} to{opacity:1;} }

.verify-card {
  background:rgba(255,255,255,0.07); backdrop-filter:blur(24px);
  border:1px solid rgba(255,255,255,0.14); border-radius:24px;
  padding:44px 40px; text-align:center; max-width:420px; width:90%; animation:slideUp .4s ease;
}
@keyframes slideUp { from{transform:translateY(24px);opacity:0;} to{transform:translateY(0);opacity:1;} }

.verify-icon {
  width:64px; height:64px; border-radius:50%;
  background:linear-gradient(135deg,var(--clr-accent),var(--clr-accent2));
  display:flex; align-items:center; justify-content:center; margin:0 auto 20px;
  box-shadow:0 8px 30px rgba(231,84,128,0.45);
}
.verify-title { font-family:var(--font-h); font-weight:800; font-size:24px; margin-bottom:8px; }
.verify-sub   { color:var(--clr-muted); font-size:14px; margin-bottom:4px; }
.verify-email { color:var(--clr-accent); font-family:var(--font-h); font-weight:600; font-size:14px; margin-bottom:28px; }

.otp-row { display:flex; gap:10px; justify-content:center; margin-bottom:14px; }
.otp-box {
  width:46px; height:54px; border-radius:12px;
  border:1.5px solid var(--clr-border); background:var(--clr-input-bg);
  color:white; font-family:var(--font-h); font-size:22px; font-weight:700;
  text-align:center; outline:none; caret-color:var(--clr-accent);
  transition:border-color 0.3s cubic-bezier(.4,0,.2,1), box-shadow 0.3s cubic-bezier(.4,0,.2,1), background 0.3s cubic-bezier(.4,0,.2,1);
}
.otp-box:focus { border-color:var(--clr-accent); background:rgba(255,255,255,0.1); box-shadow:0 0 0 3px rgba(231,84,128,0.18); }
.otp-box.filled { border-color:rgba(147,51,234,0.6); background:rgba(147,51,234,0.1); }
.otp-box.error-state { border-color:#ff6b6b; animation:shake .4s ease; }
.otp-error { color:#ff9090; font-size:12.5px; margin-bottom:14px; }
.verify-submit { margin-top:6px; }

.resend-row { display:flex; align-items:center; justify-content:center; gap:8px; margin-bottom:20px; font-size:13px; }
.resend-label { color:var(--clr-muted); }
.resend-btn { background:none; border:none; color:var(--clr-accent); font-weight:700; font-size:13px; cursor:pointer; font-family:inherit; transition:opacity 0.3s cubic-bezier(.4,0,.2,1); }
.resend-btn:hover { opacity:.75; }
.resend-btn:disabled { opacity:.4; cursor:not-allowed; }
.resend-timer { color:var(--clr-muted); font-size:13px; }
.resend-timer strong { color:white; }

.back-btn {
  display:inline-flex; align-items:center; gap:6px;
  background:none; border:none; color:var(--clr-muted);
  font-size:13px; cursor:pointer; font-family:inherit; transition:color 0.3s cubic-bezier(.4,0,.2,1);
}
.back-btn:hover { color:white; }

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

.chat-sidebar {
  width: 260px; flex-shrink: 0;
  background: rgba(255,255,255,0.03);
  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;
}
.chat-sidebar.collapsed { width: 0; padding: 0; opacity: 0; pointer-events: none; }

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

.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);
  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;
}
.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;
}
.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%;
}

.sidebar-bottom { border-top: 1px solid var(--clr-border); padding-top: 14px; margin-top: 10px; position: relative; }
.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 6px; border-radius: 10px; cursor: pointer;
  transition: background 0.2s ease;
}
.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;
}
.signout-icon-btn:hover { color: white; background: rgba(255,255,255,0.08); }

.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); }
.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;
}
.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: 90%;
  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; }

.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;
}
.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; 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 cubic-bezier(.4,0,.2,1);
}
.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 ease, background 0.2s ease, border-color 0.2s ease;
}
.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;
}
.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 ease;
}
.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; }
.preview-name {
  flex: 1; font-size: 13px; color: rgba(255,255,255,0.7);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.preview-remove {
  background: none; border: none; color: rgba(255,255,255,0.4);
  cursor: pointer; font-size: 14px; padding: 4px; transition: color 0.2s ease;
}
.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 ease, box-shadow 0.3s ease;
}
.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 ease, background 0.2s ease;
  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;
}
.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 ease, box-shadow 0.2s ease, background 0.2s ease; 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);
}

.modal-overlay {
  position:fixed; inset:0; z-index:400;
  background:rgba(0,0,0,0.6); backdrop-filter:blur(6px);
  display:flex; align-items:center; justify-content:center; animation:fadeIn .3s ease;
}
.modal-card {
  background:linear-gradient(135deg,#1a0535,#0d0220);
  border:1px solid rgba(255,255,255,0.14); border-radius:20px;
  padding:36px; max-width:440px; width:90%; animation:slideUp .3s ease;
}
.modal-card h3 { font-family:var(--font-h); font-weight:800; font-size:20px; margin-bottom:10px; }
.modal-card p { color:var(--clr-muted); font-size:13.5px; margin-bottom:16px; }
.modal-card ol { color:rgba(255,255,255,0.7); font-size:13px; padding-left:18px; margin-bottom:24px; line-height:2; }
.modal-portal-btn {
  display:inline-block; padding:11px 22px; border-radius:10px;
  background:linear-gradient(135deg,var(--clr-accent),var(--clr-accent2));
  color:white; text-decoration:none; font-family:var(--font-h); font-weight:700; font-size:13.5px;
  margin-bottom:12px; margin-right:10px; transition:opacity 0.3s ease;
}
.modal-portal-btn:hover { opacity:0.85; }
.modal-close-btn {
  padding:11px 22px; border-radius:10px; 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:13.5px;
  cursor:pointer; transition:all 0.3s ease;
}
.modal-close-btn:hover { border-color:rgba(255,255,255,0.4); color:white; }
#setup-modal { position:fixed; inset:0; z-index:400; }

@keyframes shake {
  0%,100%{transform:translateX(0);} 20%{transform:translateX(-6px);}
  40%{transform:translateX(6px);} 60%{transform:translateX(-4px);}
  80%{transform:translateX(4px);}
}

@media (max-width: 860px) {
  .auth-wrapper { flex-direction:column; }
  .panel-form { flex:none; min-height:100vh; width:100%; padding:36px 24px; }
  .chat-sidebar { position: absolute; left: 0; top: 0; bottom: 0; z-index: 50; }
  .chat-sidebar.collapsed { width: 0; }
  .msg-actions { display: none; }
}