/* ================================================================
   NovAI Design System
   ================================================================ */
:root {
  --bg-base:     #06060f;
  --bg-surface:  #0d0d1c;
  --bg-elevated: #13132a;
  --bg-hover:    #1a1a32;
  --bg-active:   #201d3a;
  --border:      rgba(255,255,255,0.07);
  --border-focus:rgba(124,58,237,0.5);
  --text-primary:#eeeeff;
  --text-secondary:#8080aa;
  --text-muted:  #44445a;
  --purple:      #7c3aed;
  --purple-light:#a855f7;
  --cyan:        #06b6d4;
  --cyan-light:  #22d3ee;
  --gradient:    linear-gradient(90deg,#7c3aed 0%,#06b6d4 100%);
  --gradient-text:linear-gradient(120deg,#a855f7 0%,#22d3ee 100%);
  --sidebar-w:   260px;
  --sidebar-c:   60px;
  --topbar-h:    56px;
  --r-sm:8px; --r-md:12px; --r-lg:20px; --r-pill:999px;
  --ease:cubic-bezier(0.4,0,0.2,1);
  --t:0.3s var(--ease); --t-fast:0.15s var(--ease);
  --font:'Inter',-apple-system,BlinkMacSystemFont,sans-serif;
}
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
html,body{height:100%;overflow:hidden}
body{font-family:var(--font);background:var(--bg-base);color:var(--text-primary);display:flex;-webkit-font-smoothing:antialiased}
button{cursor:pointer;border:none;background:none;font-family:inherit;color:inherit}
textarea,input{font-family:inherit}
svg{display:block;flex-shrink:0}
a{color:var(--cyan-light);text-decoration:none}
a:hover{text-decoration:underline}
::-webkit-scrollbar{width:4px}
::-webkit-scrollbar-track{background:transparent}
::-webkit-scrollbar-thumb{background:var(--bg-elevated);border-radius:2px}

/* ================================================================
   SIDEBAR
   ================================================================ */
.sidebar{
  position:fixed;top:0;left:0;bottom:0;
  width:var(--sidebar-w);
  background:var(--bg-surface);
  border-right:1px solid var(--border);
  display:flex;flex-direction:column;
  transition:width var(--t),transform var(--t);
  z-index:100;overflow:hidden;
}
.sidebar.collapsed{width:var(--sidebar-c)}

.sidebar-header{
  display:flex;align-items:center;gap:10px;
  padding:14px 12px;min-height:60px;
  border-bottom:1px solid var(--border);
}
.sidebar-logo-wrap{
  display:flex;align-items:center;gap:8px;
  overflow:hidden;white-space:nowrap;
  transition:opacity var(--t),width var(--t);
}
.sidebar.collapsed .sidebar-logo-wrap{opacity:0;width:0;pointer-events:none}
.sidebar-brand{
  font-size:17px;font-weight:700;
  background:var(--gradient-text);
  -webkit-background-clip:text;-webkit-text-fill-color:transparent;background-clip:text;
  letter-spacing:-0.5px;
}

.new-chat-btn{
  display:flex;align-items:center;gap:10px;
  margin:10px 10px 4px;padding:10px 12px;
  border-radius:var(--r-md);
  background:linear-gradient(135deg,rgba(124,58,237,0.12),rgba(6,182,212,0.08));
  border:1px solid rgba(124,58,237,0.22);
  color:var(--text-primary);font-size:13.5px;font-weight:500;
  transition:all var(--t);white-space:nowrap;overflow:hidden;
}
.new-chat-btn:hover{
  background:linear-gradient(135deg,rgba(124,58,237,0.22),rgba(6,182,212,0.15));
  border-color:rgba(124,58,237,0.45);
  box-shadow:0 0 20px rgba(124,58,237,0.25);
  transform:translateY(-1px);
}
.new-chat-btn .btn-icon{width:18px;height:18px;flex-shrink:0}

.sidebar-section{flex:1;overflow-y:auto;padding:8px 0}
.sidebar-section-label{font-size:10.5px;font-weight:600;text-transform:uppercase;letter-spacing:1px;color:var(--text-muted);padding:4px 16px 6px}

.no-history-msg{font-size:12px;color:var(--text-muted);padding:8px 16px;font-style:italic}

.history-item{
  display:flex;align-items:center;gap:10px;
  width:calc(100% - 16px);margin:1px 8px;padding:8px 10px;
  border-radius:var(--r-sm);
  color:var(--text-secondary);text-align:left;
  transition:all var(--t-fast);overflow:hidden;white-space:nowrap;
}
.history-item:hover{background:var(--bg-hover);color:var(--text-primary)}
.history-item.active{background:var(--bg-active);color:var(--text-primary)}
.history-icon{width:14px;height:14px;flex-shrink:0;opacity:0.5}
.history-item-text{display:flex;flex-direction:column;gap:2px;overflow:hidden;min-width:0}
.history-label{font-size:13px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.history-time{font-size:10.5px;color:var(--text-muted)}

/* Collapse transitions */
.new-chat-btn .btn-label,
.sidebar-section-label,
.no-history-msg,
.history-item-text,
.sidebar-footer-btn .btn-label,
.model-info-text{transition:opacity var(--t)}
.sidebar.collapsed .new-chat-btn .btn-label,
.sidebar.collapsed .sidebar-section-label,
.sidebar.collapsed .no-history-msg,
.sidebar.collapsed .history-item-text,
.sidebar.collapsed .model-info-text{opacity:0;pointer-events:none}

/* Footer */
.sidebar-footer{border-top:1px solid var(--border);padding:12px}
.model-info-card{display:flex;align-items:center;gap:10px;overflow:hidden}
.model-info-dot{width:8px;height:8px;border-radius:50%;flex-shrink:0}
.model-info-dot.purple{background:var(--purple-light);box-shadow:0 0 8px var(--purple-light)}
.model-info-dot.cyan{background:var(--cyan);box-shadow:0 0 8px var(--cyan)}
.model-info-text{display:flex;flex-direction:column;gap:2px;overflow:hidden;white-space:nowrap}
.model-info-name{font-size:13px;font-weight:600;color:var(--text-primary)}
.model-info-sub{font-size:11px;color:var(--text-muted)}

/* Icon button */
.icon-btn{
  width:36px;height:36px;border-radius:var(--r-sm);
  display:flex;align-items:center;justify-content:center;
  color:var(--text-secondary);transition:all var(--t-fast);flex-shrink:0;
}
.icon-btn svg{width:20px;height:20px}
.icon-btn:hover{background:var(--bg-hover);color:var(--text-primary)}

/* ================================================================
   MAIN CONTENT
   ================================================================ */
.main-content{
  flex:1;margin-left:var(--sidebar-w);
  display:flex;flex-direction:column;height:100vh;
  transition:margin-left var(--t);overflow:hidden;
  position:relative;z-index:10;
}
.sidebar.collapsed~.main-content{margin-left:var(--sidebar-c)}

.topbar{
  display:none;align-items:center;justify-content:space-between;
  padding:10px 16px;height:var(--topbar-h);
  border-bottom:1px solid var(--border);background:var(--bg-base);
  position:sticky;top:0;z-index:50;
}
.topbar-logo{display:flex;align-items:center;gap:8px}
.topbar-brand{font-size:18px;font-weight:700;background:var(--gradient-text);-webkit-background-clip:text;-webkit-text-fill-color:transparent;background-clip:text}
/* topbar right-side actions — only shown on mobile */
.topbar-actions{display:flex;align-items:center;gap:4px}
.topbar-action-btn{display:none}

/* ================================================================
   CHAT VIEWPORT
   ================================================================ */
.chat-viewport{flex:1;overflow-y:auto;display:flex;flex-direction:column;scroll-behavior:smooth}
.chat-viewport::-webkit-scrollbar{width:4px}

/* ================================================================
   WELCOME SCREEN
   ================================================================ */
.welcome-screen{
  flex:1;display:flex;flex-direction:column;
  align-items:center;justify-content:center;
  padding:60px 24px 40px;
  animation:fadeInUp 0.55s var(--ease) both;
}
.welcome-logo-wrap{display:flex;flex-direction:column;align-items:center;margin-bottom:48px;text-align:center}
.welcome-logo-mark{
  margin-bottom:22px;
  filter:drop-shadow(0 0 18px rgba(6,182,212,0.4)) drop-shadow(0 0 36px rgba(124,58,237,0.25));
}
.welcome-title{
  font-size:clamp(44px,6vw,72px);font-weight:700;letter-spacing:-2.5px;
  background:var(--gradient-text);-webkit-background-clip:text;-webkit-text-fill-color:transparent;background-clip:text;
  line-height:1;margin-bottom:14px;
}
.welcome-subtitle{font-size:15px;color:var(--text-secondary);max-width:380px;line-height:1.65}

.suggestion-grid{display:grid;grid-template-columns:repeat(2,1fr);gap:10px;max-width:680px;width:100%}
.suggestion-card{
  display:flex;align-items:flex-start;gap:12px;padding:14px 16px;
  background:var(--bg-surface);border:1px solid var(--border);
  border-radius:var(--r-md);text-align:left;
  transition:all var(--t);animation:fadeInUp 0.5s var(--ease) both;
  position:relative;overflow:hidden;
}
.suggestion-card:nth-child(1){animation-delay:.08s}
.suggestion-card:nth-child(2){animation-delay:.13s}
.suggestion-card:nth-child(3){animation-delay:.18s}
.suggestion-card:nth-child(4){animation-delay:.23s}
.suggestion-card:hover{
  background:var(--bg-hover);border-color:rgba(124,58,237,0.32);
  transform:translateY(-2px);box-shadow:0 8px 28px rgba(124,58,237,0.1),0 2px 8px rgba(0,0,0,0.4);
}
.suggestion-icon{font-size:21px;line-height:1;flex-shrink:0;margin-top:1px}
.suggestion-text{display:flex;flex-direction:column;gap:3px}
.suggestion-text strong{font-size:13px;font-weight:600;color:var(--text-primary);line-height:1.3}
.suggestion-text span{font-size:12px;color:var(--text-secondary);line-height:1.4}

/* ================================================================
   MESSAGES
   ================================================================ */
.messages-container{
  padding:28px 24px 20px;display:flex;flex-direction:column;
  max-width:800px;width:100%;margin:0 auto;
}
.messages-container:empty{display:none}

.message-row{display:flex;gap:12px;padding:14px 0;animation:fadeInUp 0.3s var(--ease) both}
.message-row.user-row{justify-content:flex-end}

.msg-avatar{width:32px;height:32px;border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:13px;font-weight:700;flex-shrink:0;margin-top:2px}
.ai-avatar{background:var(--gradient);box-shadow:0 0 10px rgba(124,58,237,0.4);font-size:15px}
.user-avatar{background:linear-gradient(135deg,#2d2f4a,#3d4060)}

.msg-bubble{max-width:min(600px,80%);line-height:1.72;font-size:15px}
.user-bubble{
  background:var(--bg-elevated);border:1px solid var(--border);
  border-radius:var(--r-lg) var(--r-lg) var(--r-sm) var(--r-lg);
  padding:11px 16px;color:var(--text-primary);white-space:pre-wrap;word-break:break-word;
}
.ai-content{padding:2px 0;color:var(--text-primary)}
.ai-content p{margin-bottom:12px}
.ai-content p:last-of-type{margin-bottom:0}
.ai-content strong{font-weight:600}
.ai-content em{color:var(--text-secondary);font-style:italic}
.ai-content h1,.ai-content h2,.ai-content h3{font-weight:600;color:var(--text-primary);margin:18px 0 8px}
.ai-content h1{font-size:20px}.ai-content h2{font-size:17px}.ai-content h3{font-size:15px}
.ai-content ul,.ai-content ol{padding-left:22px;margin-bottom:12px}
.ai-content li{margin-bottom:5px}

/* Tables */
.ai-content table{border-collapse:collapse;width:100%;margin:14px 0;font-size:13.5px}
.ai-content th,.ai-content td{padding:8px 12px;border:1px solid var(--border);text-align:left}
.ai-content th{background:var(--bg-elevated);font-weight:600;color:var(--text-primary)}
.ai-content tr:hover td{background:rgba(255,255,255,0.02)}

/* Code */
.ai-content pre{background:#0a0a18;border:1px solid rgba(255,255,255,0.08);border-radius:var(--r-sm);margin:14px 0;overflow:hidden}
.code-block-header{display:flex;align-items:center;justify-content:space-between;padding:8px 14px;background:rgba(255,255,255,0.03);border-bottom:1px solid rgba(255,255,255,0.06)}
.code-lang-label{font-size:11px;font-weight:600;color:var(--text-muted);text-transform:uppercase;letter-spacing:1px}
.code-copy-btn{font-size:11px;font-weight:500;color:var(--text-muted);padding:3px 10px;border-radius:5px;border:1px solid rgba(255,255,255,0.08);transition:all var(--t-fast)}
.code-copy-btn:hover{color:var(--text-secondary);border-color:rgba(124,58,237,0.3);background:rgba(124,58,237,0.08)}
.ai-content pre code{display:block;padding:14px 16px;font-family:'JetBrains Mono','Fira Code','Cascadia Code',monospace;font-size:13px;line-height:1.65;color:#cdd6f4;overflow-x:auto;tab-size:2}
.ai-content :not(pre)>code{background:var(--bg-elevated);border:1px solid rgba(255,255,255,0.1);border-radius:4px;padding:2px 6px;font-size:13px;font-family:'JetBrains Mono','Fira Code',monospace;color:var(--cyan-light)}

/* Syntax tokens */
.tk-keyword{color:#cba6f7}.tk-string{color:#a6e3a1}.tk-comment{color:#585b70;font-style:italic}
.tk-number{color:#fab387}.tk-function{color:#89b4fa}.tk-builtin{color:#f38ba8}

/* Action buttons */
.msg-actions{display:flex;align-items:center;gap:2px;margin-top:8px;opacity:0;transition:opacity var(--t-fast)}
.message-row:hover .msg-actions{opacity:1}
.action-btn{display:flex;align-items:center;gap:5px;padding:5px 9px;border-radius:var(--r-sm);font-size:12px;color:var(--text-muted);transition:all var(--t-fast)}
.action-btn svg{width:13px;height:13px}
.action-btn:hover{background:var(--bg-hover);color:var(--text-secondary)}
.action-btn.liked{color:var(--cyan)}.action-btn.disliked{color:var(--purple-light)}.action-btn.copied{color:#a6e3a1}

/* Streaming cursor */
.streaming-cursor{display:inline-block;width:2px;height:1.1em;background:var(--cyan);margin-left:2px;vertical-align:text-bottom;border-radius:1px;animation:blink 0.75s ease-in-out infinite}
.stream-code-pending{display:block;font-family:'JetBrains Mono','Fira Code',monospace;font-size:13px;color:var(--text-secondary);white-space:pre-wrap;margin:8px 0}

/* ================================================================
   THINKING STEPS
   ================================================================ */
.thinking-steps{display:flex;flex-direction:column;gap:6px;padding:4px 0}
.thinking-step{
  display:flex;align-items:center;gap:8px;
  font-size:13px;color:var(--text-muted);
  transition:color var(--t-fast);opacity:0.4;
}
.thinking-step.done{opacity:0.5}
.thinking-step.done .step-dot{background:var(--purple-light);box-shadow:none}
.thinking-step.done .step-label{text-decoration:line-through;color:var(--text-muted)}
.thinking-step.active{opacity:1;color:var(--text-secondary)}
.thinking-step.active .step-dot{
  background:var(--cyan);
  box-shadow:0 0 8px var(--cyan);
  animation:dotPulse 1s ease-in-out infinite;
}
.step-dot{width:6px;height:6px;border-radius:50%;background:var(--bg-hover);flex-shrink:0;transition:all var(--t-fast)}
.step-label{transition:color var(--t-fast)}

/* ================================================================
   MODEL SELECTOR
   ================================================================ */
.model-selector-bar{display:flex;align-items:center;gap:6px;max-width:800px;width:100%;padding:0 2px;overflow-x:auto;scrollbar-width:none;margin-bottom:8px}
.model-selector-bar::-webkit-scrollbar{display:none}
.model-chip{display:flex;align-items:center;gap:6px;padding:5px 13px;border-radius:var(--r-pill);border:1px solid var(--border);background:transparent;color:var(--text-secondary);font-size:12.5px;font-weight:500;white-space:nowrap;transition:all var(--t-fast);flex-shrink:0}
.model-chip:hover:not(:disabled):not(.soon){background:var(--bg-hover);color:var(--text-primary);border-color:rgba(124,58,237,0.3)}
.model-chip.active{background:linear-gradient(135deg,rgba(124,58,237,0.14),rgba(6,182,212,0.09));border-color:rgba(124,58,237,0.4);color:var(--text-primary)}
.model-dot{width:6px;height:6px;border-radius:50%}
.model-dot.purple{background:var(--purple-light);box-shadow:0 0 6px var(--purple-light)}
.model-dot.cyan{background:var(--cyan);box-shadow:0 0 6px var(--cyan)}
.model-badge{font-size:9.5px;font-weight:700;letter-spacing:0.5px;color:var(--cyan);padding:1px 5px;border-radius:3px;border:1px solid rgba(6,182,212,0.3);background:rgba(6,182,212,0.08)}
.model-chip.soon{opacity:0.38;cursor:not-allowed}
.soon-badge{font-size:10px;padding:1px 5px;border-radius:3px;background:rgba(255,255,255,0.06);color:var(--text-muted)}

/* ================================================================
   INPUT AREA
   ================================================================ */
.input-area-wrap{padding:14px 24px 20px;background:linear-gradient(to top,var(--bg-base) 65%,transparent);display:flex;flex-direction:column;align-items:center;gap:8px}
.input-container{display:flex;align-items:flex-end;gap:8px;background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--r-lg);padding:9px 9px 9px 14px;max-width:800px;width:100%;transition:border-color var(--t),box-shadow var(--t);position:relative}
.input-container:focus-within{border-color:var(--border-focus);box-shadow:0 0 0 3px rgba(124,58,237,0.1),0 0 40px rgba(124,58,237,0.08)}
.attach-btn{color:var(--text-muted);margin-bottom:1px}
.attach-btn:hover{color:var(--text-secondary);background:var(--bg-hover)}
.attach-btn svg{width:18px;height:18px}
.chat-input{flex:1;background:none;border:none;outline:none;color:var(--text-primary);font-size:15px;line-height:1.6;resize:none;max-height:200px;overflow-y:auto;padding:4px 0;caret-color:var(--cyan)}
.chat-input::placeholder{color:var(--text-muted)}
.send-btn{width:35px;height:35px;border-radius:50%;display:flex;align-items:center;justify-content:center;background:var(--bg-elevated);color:var(--text-muted);flex-shrink:0;border:1px solid var(--border);transition:all var(--t-fast)}
.send-btn svg{width:16px;height:16px}
.send-btn:disabled{cursor:not-allowed;opacity:0.35}
.send-btn.active{background:var(--gradient);border-color:transparent;color:white;box-shadow:0 0 14px rgba(124,58,237,0.45),0 0 28px rgba(6,182,212,0.2)}
.send-btn.active:hover{transform:scale(1.07);box-shadow:0 0 22px rgba(124,58,237,0.6),0 0 44px rgba(6,182,212,0.3)}
.send-btn.stopping{background:rgba(248,113,113,0.15);border-color:rgba(248,113,113,0.3);color:#f87171}
.input-disclaimer{font-size:11.5px;color:var(--text-muted);text-align:center}

/* ================================================================
   MOBILE OVERLAY
   ================================================================ */
.mobile-overlay{display:none;position:fixed;inset:0;background:rgba(0,0,0,0.65);backdrop-filter:blur(3px);z-index:90;opacity:0;pointer-events:none;transition:opacity var(--t)}
.mobile-overlay.visible{opacity:1;pointer-events:all}

/* ================================================================
   LOGO ANIMATIONS
   ================================================================ */
@keyframes fadeIn{from{opacity:0}to{opacity:1}}
@keyframes fadeInUp{from{opacity:0;transform:translateY(14px)}to{opacity:1;transform:translateY(0)}}
@keyframes blink{0%,100%{opacity:1}50%{opacity:0}}
@keyframes dotPulse{0%,100%{box-shadow:0 0 6px var(--cyan)}50%{box-shadow:0 0 14px var(--cyan),0 0 28px rgba(6,182,212,0.5)}}
@keyframes starPulse{
  0%,100%{filter:drop-shadow(0 0 4px #06b6d4);transform:scale(1) rotate(0deg)}
  50%{filter:drop-shadow(0 0 14px #06b6d4) drop-shadow(0 0 28px #7c3aed);transform:scale(1.3) rotate(18deg)}
}
@keyframes starAura{0%,100%{opacity:0.25;transform:scale(1)}50%{opacity:0.55;transform:scale(1.35)}}
@keyframes particleFade{
  0%,100%{opacity:0;transform:translate(0,0) scale(0.5)}
  40%{opacity:0.9}100%{opacity:0;transform:translate(var(--dx,6px),var(--dy,-10px)) scale(1.3)}
}
.star-animate{animation:starPulse 3.5s ease-in-out infinite;transform-origin:60px 11px}
.star-aura{animation:starAura 3.5s ease-in-out infinite}
.star-particle{opacity:0;animation:particleFade 3s ease-in-out infinite}
.sp1{--dx:5px;--dy:-8px;animation-delay:0s;animation-duration:2.8s}
.sp2{--dx:-4px;--dy:6px;animation-delay:.7s;animation-duration:3.2s}
.sp3{--dx:-6px;--dy:-10px;animation-delay:1.4s;animation-duration:2.5s}
.sp4{--dx:8px;--dy:4px;animation-delay:.4s;animation-duration:3.5s}
.sp5{--dx:3px;--dy:-6px;animation-delay:1.8s;animation-duration:2.9s}

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media(max-width:768px){
  .sidebar{transform:translateX(calc(-1 * var(--sidebar-w)));box-shadow:none}
  .sidebar.mobile-open{transform:translateX(0);box-shadow:8px 0 50px rgba(0,0,0,0.7)}
  .sidebar.collapsed{width:var(--sidebar-w);transform:translateX(calc(-1 * var(--sidebar-w)))}
  .mobile-overlay{display:block}
  .main-content{margin-left:0 !important}
  .topbar{display:flex}
  /* Show the account + settings icon buttons in the topbar on mobile */
  .topbar-action-btn{display:flex}
  .suggestion-grid{grid-template-columns:1fr}
  .messages-container{padding-left:16px;padding-right:16px}
  /* Safe-area: keep input area above home bar / browser chrome on iOS */
  .input-area-wrap{
    padding:10px 12px max(16px, env(safe-area-inset-bottom, 16px));
  }
  .welcome-screen{padding:40px 16px 32px}
  /* Send button: 40×40 saves row height while staying easy to tap */
  .send-btn{width:40px;height:40px}
  /* Mode selector: single horizontally-scrollable row, no wrapping */
  .mode-selector{
    overflow-x:auto;
    flex-wrap:nowrap;
    -webkit-overflow-scrolling:touch;
    scrollbar-width:none;
    gap:5px;
    padding:4px 12px 0;
  }
  .mode-selector::-webkit-scrollbar{display:none}
  /* Mode chips: compact on mobile — saves ~8px vertical height vs 44px default */
  .mode-chip{padding:6px 12px;font-size:12px;min-height:36px}
  /* Attach button: hidden on mobile — reclaims horizontal space in the input row */
  .attach-btn{display:none}
  /* Textarea: starts at one row, expands up to 160px */
  .chat-input{font-size:16px;min-height:44px;max-height:160px} /* 16px prevents iOS zoom-on-focus */
  /* Message bubbles: don't overflow on narrow screens */
  .msg-bubble{max-width:90%}
  /* Input disclaimer can shrink a bit but stay readable */
  .input-disclaimer{font-size:12px}
  /* Settings drawer: full-width bottom sheet — ensure inner content scrolls */
  .settings-drawer{overflow-y:auto}
}
@media(max-width:480px){
  .welcome-title{font-size:38px}
  .msg-bubble{max-width:92%}
  /* Suggestion cards: keep text ≥ 14px */
  .suggestion-text strong{font-size:13px}
  .suggestion-text span{font-size:12px}
}

/* Thinking avatar logo */
.thinking-avatar { overflow: visible !important; }
.thinking-logo-svg { display: block; }

/* ================================================================
   PREMIUM ANIMATIONS
   ================================================================ */

/* ── 1. Message send swoosh ──────────────────────────────────── */
.message-row.user-row.msg-entering .user-bubble {
  animation: msgSwoop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes msgSwoop {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.92);
    box-shadow: 0 0 0 0 rgba(124,58,237,0);
  }
  60% {
    box-shadow: 0 0 20px rgba(124,58,237,0.4), 0 0 40px rgba(6,182,212,0.2);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    box-shadow: none;
  }
}

/* Send-ripple overlay on input area when sending */
.input-container.sending::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--r-lg);
  background: linear-gradient(90deg, rgba(124,58,237,0.15), rgba(6,182,212,0.15));
  animation: sendRipple 0.5s ease-out forwards;
  pointer-events: none;
}

@keyframes sendRipple {
  from { opacity: 1; transform: scale(1); }
  to   { opacity: 0; transform: scale(1.03); }
}

/* ── 2. Enhanced thinking animation ─────────────────────────── */
.thinking-row {
  position: relative;
}
.thinking-row::before {
  content: '';
  position: absolute;
  left: 44px;
  top: 14px;
  bottom: 14px;
  width: 200px;
  background: linear-gradient(90deg,
    rgba(124,58,237,0.06) 0%,
    rgba(6,182,212,0.06) 100%
  );
  border-radius: 12px;
  animation: thinkBg 2s ease-in-out infinite;
  pointer-events: none;
}

@keyframes thinkBg {
  0%, 100% { opacity: 0.5; transform: scaleX(0.95); }
  50%       { opacity: 1;   transform: scaleX(1); }
}

/* Active step dot ripple */
.step-dot { position: relative; }

.thinking-step.active .step-dot::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 1.5px solid var(--cyan);
  animation: stepRipple 1.2s ease-out infinite;
}

@keyframes stepRipple {
  from { opacity: 0.8; transform: scale(1); }
  to   { opacity: 0;   transform: scale(2.5); }
}

/* Spinning ring on thinking avatar */
.thinking-row .ai-avatar {
  position: relative;
}
.thinking-row .ai-avatar::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: conic-gradient(
    from 0deg,
    transparent 0deg,
    var(--purple) 60deg,
    var(--cyan) 120deg,
    transparent 180deg,
    transparent 360deg
  );
  animation: spinRing 1.5s linear infinite;
  z-index: -1;
  mask: radial-gradient(farthest-side, transparent calc(100% - 2.5px), white calc(100% - 2.5px));
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 2.5px), white calc(100% - 2.5px));
}

@keyframes spinRing { to { transform: rotate(360deg); } }

/* ── 3. AI response entrance ─────────────────────────────────── */
.message-row.ai-row {
  animation: aiEntrance 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes aiEntrance {
  from {
    opacity: 0;
    transform: translateX(-8px);
    filter: blur(2px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
    filter: blur(0);
  }
}

/* ── 4. Send button pulse on active ──────────────────────────── */
.send-btn.active {
  animation: sendBtnPulse 2s ease-in-out infinite;
}

@keyframes sendBtnPulse {
  0%, 100% { box-shadow: 0 0 14px rgba(124,58,237,0.45), 0 0 28px rgba(6,182,212,0.2); }
  50%       { box-shadow: 0 0 20px rgba(124,58,237,0.7),  0 0 40px rgba(6,182,212,0.35); }
}

/* ── 5. Suggestion card hover shimmer ────────────────────────── */
.suggestion-card::before {
  content: '';
  position: absolute;
  top: 0; left: -100%;
  width: 60%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.04), transparent);
  transition: left 0.5s ease;
}
.suggestion-card:hover::before {
  left: 150%;
}

/* ── 6. Streaming cursor upgrade ─────────────────────────────── */
.streaming-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: linear-gradient(to bottom, var(--purple-light), var(--cyan));
  margin-left: 2px;
  vertical-align: text-bottom;
  border-radius: 2px;
  animation: cursorBlink 0.8s ease-in-out infinite,
             cursorGlow  2s   ease-in-out infinite;
}

@keyframes cursorBlink { 0%,100%{opacity:1} 50%{opacity:0} }
@keyframes cursorGlow {
  0%,100% { box-shadow: 0 0 4px var(--cyan); }
  50%      { box-shadow: 0 0 10px var(--cyan), 0 0 20px rgba(6,182,212,0.5); }
}

/* ── Thinking meta (timer + model badge) ─────────────────────── */
.thinking-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(255,255,255,0.05);
}

.thinking-model-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--purple-light);
  background: rgba(124,58,237,0.12);
  border: 1px solid rgba(124,58,237,0.25);
  padding: 2px 9px;
  border-radius: var(--r-pill);
}

.thinking-model-badge.code {
  color: var(--cyan-light);
  background: rgba(6,182,212,0.1);
  border-color: rgba(6,182,212,0.25);
}

.thinking-time {
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  color: var(--cyan);
  letter-spacing: 0.5px;
  min-width: 40px;
  animation: timerPulse 1s ease-in-out infinite;
}

@keyframes timerPulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.55; }
}

/* Thinking row wrapper needs column flex */
.thinking-row > div:not(.msg-avatar):not(.thinking-avatar) {
  display: flex;
  flex-direction: column;
}

/* ── Chat history delete button ──────────────────────────────── */
.history-item {
  position: relative; /* needed for delete btn positioning */
}

.history-delete-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 5px;
  flex-shrink: 0;
  margin-left: auto;
  color: var(--text-muted);
  opacity: 0;
  transition: opacity var(--t-fast), background var(--t-fast), color var(--t-fast);
}

.history-delete-btn svg {
  width: 13px;
  height: 13px;
}

.history-item:hover .history-delete-btn {
  opacity: 1;
}

.history-delete-btn:hover {
  background: rgba(248, 113, 113, 0.15);
  color: #f87171;
}

/* Delete animation */
.history-item.deleting {
  animation: itemDelete 0.25s ease-out forwards;
}

@keyframes itemDelete {
  to {
    opacity: 0;
    transform: translateX(-12px) scale(0.95);
    max-height: 0;
    padding: 0;
    margin: 0;
  }
}

/* ── Web search thinking step ────────────────────────────────── */
.thinking-step.active .step-label[data-searching="true"] {
  color: var(--cyan-light);
}

/* Animated ellipsis for "Searching the web" step */
.thinking-step.active .step-label::after {
  content: '';
  display: inline-block;
  animation: dotsAppear 1.5s steps(4, end) infinite;
  width: 1.2em;
  text-align: left;
}

@keyframes dotsAppear {
  0%   { content: ''; }
  25%  { content: '.'; }
  50%  { content: '..'; }
  75%  { content: '...'; }
  100% { content: ''; }
}

/* Expanded thinking row when doing web search */
.thinking-row.web-searching .thinking-steps {
  border-left: 2px solid rgba(6,182,212,0.3);
  padding-left: 12px;
  margin-left: 2px;
}

/* ================================================================
   SETTINGS PANEL
   ================================================================ */
.settings-panel {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
}

.settings-panel.hidden { display: none; }

.settings-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(8px);
  animation: fadeIn 0.25s ease both;
}

.settings-drawer {
  position: relative;
  width: 380px;
  max-width: 100vw;
  height: 100vh;
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.34, 1.1, 0.64, 1);
  box-shadow: -20px 0 60px rgba(0,0,0,0.5);
}

.settings-panel.visible .settings-drawer {
  transform: translateX(0);
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg-surface);
  z-index: 1;
}

.settings-title {
  font-size: 18px;
  font-weight: 700;
  background: var(--gradient-text);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.4px;
}

.settings-section {
  padding: 24px;
  border-bottom: 1px solid var(--border);
}

.settings-section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.settings-section-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.55;
  margin-bottom: 16px;
}

/* Language grid */
.language-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.lang-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 500;
  transition: all 0.2s cubic-bezier(0.34, 1.3, 0.64, 1);
  text-align: left;
}

.lang-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: rgba(124,58,237,0.3);
  transform: translateY(-1px);
}

.lang-btn.active {
  background: linear-gradient(135deg, rgba(124,58,237,0.18), rgba(6,182,212,0.12));
  border-color: rgba(124,58,237,0.45);
  color: var(--text-primary);
  box-shadow: 0 0 12px rgba(124,58,237,0.15);
}

.lang-flag { font-size: 20px; line-height: 1; }
.lang-name { font-size: 13px; font-weight: 500; }

.lang-auto-note {
  font-size: 12px;
  color: var(--text-muted);
  background: rgba(6,182,212,0.06);
  border: 1px solid rgba(6,182,212,0.15);
  border-radius: var(--r-sm);
  padding: 8px 12px;
  line-height: 1.5;
}

/* Model setting buttons */
.model-setting-btns { display: flex; flex-direction: column; gap: 8px; }

.model-setting-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  text-align: left;
  transition: all 0.2s cubic-bezier(0.34, 1.2, 0.64, 1);
}

.model-setting-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  transform: translateX(3px);
}

.model-setting-btn.active {
  background: linear-gradient(135deg, rgba(124,58,237,0.12), rgba(6,182,212,0.08));
  border-color: rgba(124,58,237,0.35);
  color: var(--text-primary);
}

.model-setting-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}
.model-setting-dot.purple { background: var(--purple-light); box-shadow: 0 0 8px var(--purple-light); }
.model-setting-dot.cyan   { background: var(--cyan);         box-shadow: 0 0 8px var(--cyan); }

.model-setting-btn > div { display: flex; flex-direction: column; gap: 2px; }
.model-setting-btn strong { font-size: 14px; font-weight: 600; }
.model-setting-btn span   { font-size: 12px; color: var(--text-muted); line-height: 1.4; }
.model-setting-btn.active span { color: var(--text-secondary); }

/* Danger button */
.settings-danger-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--r-md);
  border: 1px solid rgba(248,113,113,0.2);
  background: rgba(248,113,113,0.06);
  color: #f87171;
  font-size: 13.5px;
  font-weight: 500;
  transition: all 0.2s ease;
  width: 100%;
  justify-content: center;
}

.settings-danger-btn:hover {
  background: rgba(248,113,113,0.12);
  border-color: rgba(248,113,113,0.4);
  transform: translateY(-1px);
}

.settings-footer {
  margin-top: auto;
  padding: 20px 24px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  border-top: 1px solid var(--border);
}

/* ================================================================
   ULTRA-SMOOTH ANIMATION UPGRADES
   ================================================================ */

/* Better spring physics on all interactive elements */
button, .suggestion-card, .history-item, .model-chip, .lang-btn {
  will-change: transform;
}

/* Smoother sidebar transition with spring */
.sidebar {
  transition: width 0.4s cubic-bezier(0.34, 1.1, 0.64, 1),
              transform 0.4s cubic-bezier(0.34, 1.1, 0.64, 1) !important;
}

/* Message entries with spring bounce */
@keyframes msgSwoop {
  0%   { opacity: 0; transform: translateY(18px) scale(0.94); filter: blur(2px); }
  60%  { box-shadow: 0 0 24px rgba(124,58,237,0.35), 0 0 48px rgba(6,182,212,0.15); }
  80%  { transform: translateY(-2px) scale(1.005); }
  100% { opacity: 1; transform: translateY(0) scale(1); box-shadow: none; filter: blur(0); }
}

@keyframes aiEntrance {
  0%   { opacity: 0; transform: translateX(-12px); filter: blur(3px); }
  70%  { transform: translateX(2px); }
  100% { opacity: 1; transform: translateX(0); filter: blur(0); }
}

/* Ambient glow on welcome screen — slow drift */
.welcome-logo-mark {
  animation: logoDrift 8s ease-in-out infinite;
}

@keyframes logoDrift {
  0%, 100% { filter: drop-shadow(0 0 18px rgba(6,182,212,0.4)) drop-shadow(0 0 36px rgba(124,58,237,0.25)); transform: translateY(0px); }
  50%       { filter: drop-shadow(0 0 28px rgba(6,182,212,0.6)) drop-shadow(0 0 56px rgba(124,58,237,0.4)); transform: translateY(-4px); }
}

/* Smooth text streaming cursor upgrade */
.streaming-cursor {
  display: inline-block;
  width: 2.5px;
  height: 1.15em;
  background: linear-gradient(to bottom, var(--purple-light), var(--cyan));
  margin-left: 3px;
  vertical-align: text-bottom;
  border-radius: 2px;
  animation: cursorBlink 0.85s cubic-bezier(0.4, 0, 0.6, 1) infinite,
             cursorGlow 2.5s ease-in-out infinite;
}

@keyframes cursorBlink {
  0%, 45% { opacity: 1; }
  55%, 100% { opacity: 0; }
}

@keyframes cursorGlow {
  0%, 100% { box-shadow: 0 0 6px rgba(6,182,212,0.6); }
  50%       { box-shadow: 0 0 14px rgba(6,182,212,0.9), 0 0 28px rgba(124,58,237,0.4); }
}

/* Ripple on send button click */
.send-btn.active:active {
  transform: scale(0.92);
  transition: transform 0.1s ease !important;
}

/* Smooth code block appearance */
.ai-content pre {
  animation: codeBlockIn 0.3s cubic-bezier(0.34, 1.1, 0.64, 1) both;
}

@keyframes codeBlockIn {
  from { opacity: 0; transform: translateY(6px) scale(0.99); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Thinking ring upgrade — double ring */
.thinking-row .ai-avatar::after {
  content: '';
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  background: conic-gradient(
    from 0deg,
    transparent 0deg,
    var(--purple) 40deg,
    var(--cyan) 100deg,
    transparent 160deg,
    transparent 360deg
  );
  animation: spinRing 1.2s linear infinite;
  z-index: -1;
  mask: radial-gradient(farthest-side, transparent calc(100% - 3px), white calc(100% - 3px));
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), white calc(100% - 3px));
}

/* Second trailing ring */
.thinking-row .ai-avatar::before {
  content: '';
  position: absolute;
  inset: -9px;
  border-radius: 50%;
  background: conic-gradient(
    from 180deg,
    transparent 0deg,
    rgba(124,58,237,0.3) 40deg,
    rgba(6,182,212,0.3) 80deg,
    transparent 120deg
  );
  animation: spinRing 1.8s linear infinite reverse;
  z-index: -2;
  mask: radial-gradient(farthest-side, transparent calc(100% - 2px), white calc(100% - 2px));
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 2px), white calc(100% - 2px));
}

.thinking-avatar {
  position: relative;
  overflow: visible !important;
}

/* Welcome screen background aurora */
.welcome-screen::before {
  content: '';
  position: fixed;
  top: -30%;
  left: -10%;
  width: 60%;
  height: 60%;
  background: radial-gradient(ellipse at center, rgba(124,58,237,0.06) 0%, transparent 70%);
  animation: auroraDrift 12s ease-in-out infinite;
  pointer-events: none;
  z-index: -1;
}

.welcome-screen::after {
  content: '';
  position: fixed;
  bottom: -20%;
  right: -10%;
  width: 50%;
  height: 50%;
  background: radial-gradient(ellipse at center, rgba(6,182,212,0.05) 0%, transparent 70%);
  animation: auroraDrift 16s ease-in-out infinite reverse;
  pointer-events: none;
  z-index: -1;
}

@keyframes auroraDrift {
  0%, 100% { transform: translate(0, 0) scale(1); opacity: 0.6; }
  33%  { transform: translate(4%, -3%) scale(1.05); opacity: 1; }
  66%  { transform: translate(-3%, 2%) scale(0.97); opacity: 0.7; }
}

/* Smooth input focus glow pulse */
.input-container:focus-within {
  animation: inputGlowPulse 3s ease-in-out infinite;
}

@keyframes inputGlowPulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(124,58,237,0.1), 0 0 20px rgba(124,58,237,0.06); }
  50%       { box-shadow: 0 0 0 3px rgba(124,58,237,0.15), 0 0 32px rgba(6,182,212,0.1); }
}

/* History item enter animation */
.history-item {
  animation: historySlideIn 0.25s cubic-bezier(0.34, 1.1, 0.64, 1) both;
}

@keyframes historySlideIn {
  from { opacity: 0; transform: translateX(-8px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* Suggestion cards stagger upgrade */
.suggestion-card:hover {
  transition: all 0.25s cubic-bezier(0.34, 1.3, 0.64, 1) !important;
  transform: translateY(-3px) scale(1.01) !important;
}

/* Scrollbar upgrade */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-thumb {
  background: linear-gradient(to bottom, rgba(124,58,237,0.3), rgba(6,182,212,0.3));
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(to bottom, rgba(124,58,237,0.5), rgba(6,182,212,0.5));
}

/* Mobile settings panel */
@media (max-width: 768px) {
  .settings-drawer {
    width: 100vw;
    min-width: 0; /* override desktop min-width constraints */
    height: auto;
    max-height: 90vh;
    border-radius: 20px 20px 0 0;
    border-left: none;
    border-top: 1px solid var(--border);
    /* pad bottom so content clears the home bar on iOS */
    padding-bottom: env(safe-area-inset-bottom);
  }
  .settings-panel {
    align-items: flex-end;
    justify-content: center;
  }
  .settings-panel.hidden { display: none; }
  .settings-panel .settings-overlay { border-radius: 0; }
  .language-grid { grid-template-columns: repeat(2, 1fr); }
  /* Settings sections: tighter padding on mobile */
  .settings-section { padding: 20px 16px; }
  .settings-header  { padding: 16px 20px; }
  .settings-footer  { padding: 16px 20px; }
}

/* ================================================================
   LANGUAGE SWITCHING TRANSITIONS
   ================================================================ */

/* Smooth text content changes when language switches */
#welcomeSubtitle, #inputDisclaimer, #noHistoryMsg, #newChatLabel, #modelInfoSub {
  transition: opacity 0.3s ease;
}

.lang-switching #welcomeSubtitle,
.lang-switching #inputDisclaimer,
.lang-switching #noHistoryMsg,
.lang-switching #newChatLabel,
.lang-switching #modelInfoSub {
  opacity: 0;
}

/* Suggestion card text fade on language switch */
.suggestion-card .suggestion-text strong,
.suggestion-card .suggestion-text span {
  transition: opacity 0.25s ease;
}

/* ================================================================
   ENHANCED THINKING ANIMATION
   ================================================================ */

/* Subtle background pulse on the whole thinking row */
.thinking-row {
  position: relative;
  background: transparent;
  transition: background 0.5s ease;
}

.thinking-row::after {
  content: '';
  position: absolute;
  left: 44px;
  top: 8px;
  bottom: 8px;
  right: 0;
  border-radius: 12px;
  background: linear-gradient(135deg,
    rgba(124,58,237,0.04) 0%,
    rgba(6,182,212,0.04) 100%
  );
  pointer-events: none;
  animation: thinkRowGlow 2s ease-in-out infinite;
}

@keyframes thinkRowGlow {
  0%, 100% { opacity: 0.5; }
  50%       { opacity: 1; }
}

/* Active step gets a gradient background behind text */
.thinking-step.active {
  background: linear-gradient(90deg,
    rgba(124,58,237,0.06) 0%,
    transparent 100%
  );
  border-radius: 6px;
  padding: 2px 6px;
  margin: -2px -6px;
}

/* Done steps get a subtle checkmark-ish left border */
.thinking-step.done::before {
  content: '✓';
  font-size: 9px;
  color: var(--purple-light);
  opacity: 0.6;
  margin-right: 2px;
}

/* Step dot ripple upgrade */
.thinking-step.active .step-dot {
  position: relative;
}

.thinking-step.active .step-dot::before {
  content: '';
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  border: 1px solid var(--cyan);
  opacity: 0;
  animation: dotRippleA 1.4s ease-out infinite;
}

.thinking-step.active .step-dot::after {
  content: '';
  position: absolute;
  inset: -9px;
  border-radius: 50%;
  border: 1px solid var(--purple-light);
  opacity: 0;
  animation: dotRippleA 1.4s ease-out 0.4s infinite;
}

@keyframes dotRippleA {
  0%   { transform: scale(0.5); opacity: 0.7; }
  100% { transform: scale(2.2); opacity: 0; }
}

/* ================================================================
   RESPONSE QUALITY INDICATORS
   ================================================================ */

/* Web search tag shown in responses that used web data */
.web-sourced-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  color: var(--cyan);
  background: rgba(6,182,212,0.08);
  border: 1px solid rgba(6,182,212,0.2);
  border-radius: var(--r-pill);
  padding: 2px 8px;
  margin-top: 10px;
  font-weight: 500;
}

/* Live data indicator */
.live-data-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: #4ade80;
  background: rgba(74,222,128,0.08);
  border: 1px solid rgba(74,222,128,0.2);
  border-radius: var(--r-pill);
  padding: 2px 9px;
  margin-top: 10px;
  font-weight: 500;
}

.live-data-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4ade80;
  animation: livePulse 1.5s ease-in-out infinite;
}

@keyframes livePulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.5; transform: scale(0.7); }
}

/* ================================================================
   SETTINGS PANEL REFINEMENTS
   ================================================================ */

/* Settings button in sidebar footer */
.sidebar-settings-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border-radius: var(--r-sm);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  transition: all var(--t-fast);
  white-space: nowrap;
  overflow: hidden;
  margin-bottom: 6px;
}

.sidebar-settings-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.sidebar-settings-btn svg {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
}

.sidebar-settings-btn .btn-label {
  transition: opacity var(--t);
}

.sidebar.collapsed .sidebar-settings-btn .btn-label {
  opacity: 0;
  pointer-events: none;
}

/* Active language flag highlight */
.lang-btn.active .lang-flag {
  filter: drop-shadow(0 0 6px rgba(124,58,237,0.5));
  transform: scale(1.1);
  transition: all 0.2s ease;
}

/* ================================================================
   TIMEZONE / TIME RESPONSE STYLING
   ================================================================ */

.ai-content .time-display {
  font-size: 32px;
  font-weight: 700;
  background: var(--gradient-text);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -1px;
  line-height: 1.2;
  margin: 8px 0;
}

/* ================================================================
   MODE SELECTOR TABS
   ================================================================ */

.mode-selector {
  display: flex;
  gap: 6px;
  padding: 6px 12px 2px;
  flex-wrap: wrap;
}

.mode-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.04);
  color: rgba(255,255,255,0.5);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s ease;
  letter-spacing: 0.02em;
}

.mode-chip:hover {
  background: rgba(124,58,237,0.15);
  border-color: rgba(124,58,237,0.4);
  color: rgba(255,255,255,0.85);
}

.mode-chip.active {
  background: rgba(124,58,237,0.22);
  border-color: rgba(124,58,237,0.6);
  color: #c4b5fd;
  font-weight: 600;
}

.mode-chip[data-mode="math"].active {
  background: rgba(16,185,129,0.18);
  border-color: rgba(16,185,129,0.5);
  color: #6ee7b7;
}

.mode-chip[data-mode="history"].active {
  background: rgba(245,158,11,0.18);
  border-color: rgba(245,158,11,0.5);
  color: #fcd34d;
}

.mode-chip[data-mode="deep"].active {
  background: rgba(59,130,246,0.18);
  border-color: rgba(59,130,246,0.5);
  color: #93c5fd;
}

/* ================================================================
   ACCOUNT BUTTON (sidebar)
   ================================================================ */

.account-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 12px;
  margin-bottom: 8px;
  border-radius: 10px;
  border: 1px solid rgba(124,58,237,0.3);
  background: rgba(124,58,237,0.1);
  color: #c4b5fd;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s ease;
  text-align: left;
}

.account-btn:hover {
  background: rgba(124,58,237,0.22);
  border-color: rgba(124,58,237,0.55);
  color: #ddd6fe;
}

/* ================================================================
   ACCOUNT MODAL
   ================================================================ */

.account-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.account-modal.hidden { display: none; }

.account-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
}

.account-dialog {
  position: relative;
  width: 100%;
  max-width: 420px;
  margin: 16px;
  background: #1a1025;
  border: 1px solid rgba(124,58,237,0.3);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0,0,0,0.6), 0 0 0 1px rgba(124,58,237,0.15);
  animation: accountSlideIn 0.25s ease;
}

@keyframes accountSlideIn {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.account-header {
  padding: 28px 28px 0;
  text-align: center;
  position: relative;
}

.account-logo {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(124,58,237,0.2);
  border: 1px solid rgba(124,58,237,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 14px;
  color: #c4b5fd;
}

.account-logo svg { width: 24px; height: 24px; }

.account-title {
  font-size: 20px;
  font-weight: 700;
  color: #f0eaff;
  margin: 0 0 6px;
}

.account-subtitle {
  font-size: 13px;
  color: rgba(255,255,255,0.5);
  margin: 0 0 20px;
  line-height: 1.5;
}

.account-close-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.5);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.account-close-btn:hover { background: rgba(255,255,255,0.12); color: #fff; }
.account-close-btn svg { width: 16px; height: 16px; }

.account-tabs {
  display: flex;
  padding: 0 28px;
  gap: 4px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 24px;
}

.account-tab {
  flex: 1;
  padding: 10px;
  font-size: 13px;
  font-weight: 500;
  color: rgba(255,255,255,0.4);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  margin-bottom: -1px;
}

.account-tab.active {
  color: #c4b5fd;
  border-bottom-color: #7c3aed;
}

.account-form {
  padding: 0 28px 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.account-field { display: flex; flex-direction: column; gap: 6px; }

.account-label {
  font-size: 12px;
  font-weight: 500;
  color: rgba(255,255,255,0.6);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.account-input {
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.05);
  color: #f0eaff;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s ease;
}

.account-input::placeholder { color: rgba(255,255,255,0.25); }

.account-input:focus {
  border-color: rgba(124,58,237,0.6);
  background: rgba(124,58,237,0.08);
}

.account-submit-btn {
  padding: 12px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, #7c3aed, #5b21b6);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
  margin-top: 4px;
  letter-spacing: 0.02em;
}

.account-submit-btn:hover {
  background: linear-gradient(135deg, #8b5cf6, #6d28d9);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(124,58,237,0.4);
}

.account-coming-soon {
  font-size: 12px;
  color: rgba(255,255,255,0.35);
  text-align: center;
  margin: 0;
  line-height: 1.5;
}

/* ================================================================
   ACCOUNT MODAL — MOBILE
   ================================================================ */
@media (max-width: 480px) {
  .account-dialog {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    margin: 0;
    border-radius: 20px 20px 0 0;
    max-width: 100%;
  }
  .account-header  { padding: 20px 20px 0; }
  .account-form    { padding: 0 20px 20px; }
  .account-tabs    { padding: 0 20px; }
  .account-title   { font-size: 18px; }
}

/* ================================================================
   LOCAL AI STATUS INDICATOR (sidebar)
   ================================================================ */

.local-ai-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  margin-bottom: 6px;
  border-radius: var(--r-sm);
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  overflow: hidden;
  transition: border-color var(--t), background var(--t);
  min-height: 36px;
}

.local-ai-card:has(#localAiEnableBtn:not([hidden])) {
  background: rgba(124,58,237,0.05);
  border-color: rgba(124,58,237,0.18);
}

.local-ai-indicator {
  display: flex;
  align-items: center;
  gap: 7px;
  overflow: hidden;
  flex-shrink: 1;
  min-width: 0;
}

/* --- dot states --- */
.local-ai-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--text-muted);
  transition: background var(--t), box-shadow var(--t);
}

.local-ai-dot.state-downloading {
  background: var(--purple-light);
  box-shadow: 0 0 8px var(--purple-light);
  animation: localAiDotPulse 1.2s ease-in-out infinite;
}

.local-ai-dot.state-ready {
  background: #4ade80;
  box-shadow: 0 0 8px rgba(74,222,128,0.7);
  animation: none;
}

@keyframes localAiDotPulse {
  0%, 100% { box-shadow: 0 0 5px var(--purple-light); transform: scale(1); }
  50%       { box-shadow: 0 0 14px var(--purple-light), 0 0 28px rgba(168,85,247,0.35); transform: scale(1.25); }
}

/* Spinner that replaces the dot during download */
.local-ai-dot.state-downloading {
  width: 9px;
  height: 9px;
  background: transparent;
  border: 1.5px solid var(--purple-light);
  border-top-color: transparent;
  border-radius: 50%;
  box-shadow: none;
  animation: localAiSpin 0.75s linear infinite;
}

@keyframes localAiSpin {
  to { transform: rotate(360deg); }
}

.local-ai-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color var(--t), opacity var(--t);
}

.local-ai-label.state-downloading {
  color: var(--purple-light);
}

.local-ai-label.state-ready {
  color: #4ade80;
}

/* Enable button */
.local-ai-enable-btn {
  flex-shrink: 0;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  background: linear-gradient(135deg, rgba(124,58,237,0.22), rgba(6,182,212,0.12));
  border: 1px solid rgba(124,58,237,0.38);
  color: #c4b5fd;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
  cursor: pointer;
  transition: all var(--t-fast);
}

.local-ai-enable-btn:hover {
  background: linear-gradient(135deg, rgba(124,58,237,0.38), rgba(6,182,212,0.22));
  border-color: rgba(124,58,237,0.6);
  color: #ddd6fe;
  box-shadow: 0 0 14px rgba(124,58,237,0.3);
  transform: translateY(-1px);
}

.local-ai-enable-btn[hidden] {
  display: none;
}

/* Sidebar collapsed — hide text, keep dots */
.sidebar.collapsed .local-ai-card {
  justify-content: center;
  padding: 8px 6px;
}

.sidebar.collapsed .local-ai-label,
.sidebar.collapsed .local-ai-enable-btn {
  opacity: 0;
  pointer-events: none;
  width: 0;
  padding: 0;
  margin: 0;
  overflow: hidden;
}

/* ================================================================
   WEBLLM DOWNLOAD TOAST
   ================================================================ */

.llm-toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(110%);
  z-index: 500;
  min-width: 320px;
  max-width: min(480px, calc(100vw - 32px));
  background: var(--bg-elevated);
  border: 1px solid rgba(124,58,237,0.3);
  border-radius: var(--r-md);
  box-shadow:
    0 8px 32px rgba(0,0,0,0.5),
    0 0 0 1px rgba(124,58,237,0.08),
    inset 0 1px 0 rgba(255,255,255,0.04);
  padding: 14px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  opacity: 0;
  pointer-events: none;
  transition:
    transform 0.38s cubic-bezier(0.34,1.2,0.64,1),
    opacity 0.28s var(--ease);
}

.llm-toast.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: all;
}

.llm-toast.dismissed {
  transform: translateX(-50%) translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition:
    transform 0.22s var(--ease),
    opacity 0.22s var(--ease);
}

/* Subtle shimmer along the top edge while downloading */
.llm-toast::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(124,58,237,0.6) 30%,
    rgba(6,182,212,0.6) 70%,
    transparent 100%
  );
  border-radius: var(--r-md) var(--r-md) 0 0;
  animation: toastShimmer 2.5s ease-in-out infinite;
}

@keyframes toastShimmer {
  0%, 100% { opacity: 0.5; }
  50%       { opacity: 1; }
}

.llm-toast-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.llm-toast-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.llm-toast-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: var(--purple-light);
  display: flex;
  align-items: center;
  justify-content: center;
}

.llm-toast-icon svg {
  width: 16px;
  height: 16px;
}

.llm-toast-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.llm-toast-dismiss {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: all var(--t-fast);
}

.llm-toast-dismiss svg { width: 13px; height: 13px; }

.llm-toast-dismiss:hover {
  background: var(--bg-hover);
  color: var(--text-secondary);
}

.llm-toast-body {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.llm-toast-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.llm-toast-model {
  font-size: 12px;
  font-weight: 600;
  color: var(--purple-light);
  background: rgba(124,58,237,0.1);
  border: 1px solid rgba(124,58,237,0.22);
  padding: 1px 7px;
  border-radius: var(--r-pill);
}

.llm-toast-pct {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  font-family: 'JetBrains Mono','Fira Code',monospace;
  min-width: 36px;
}

.llm-toast-size {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: auto;
}

.llm-toast-eta-row {
  min-height: 16px;
}

.llm-toast-eta {
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  transition: opacity 0.3s ease;
}

.llm-toast-eta:empty {
  display: none;
}

/* Progress bar */
.llm-toast-bar-wrap {
  height: 4px;
  background: rgba(255,255,255,0.06);
  border-radius: 2px;
  overflow: hidden;
}

.llm-toast-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--purple) 0%, var(--cyan) 100%);
  border-radius: 2px;
  transition: width 0.4s cubic-bezier(0.4,0,0.2,1);
  position: relative;
  overflow: hidden;
}

/* Moving shine on the bar */
.llm-toast-bar::after {
  content: '';
  position: absolute;
  top: 0; bottom: 0;
  width: 50%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
  animation: barShine 1.8s ease-in-out infinite;
}

@keyframes barShine {
  from { left: -50%; }
  to   { left: 150%; }
}

@media (max-width: 768px) {
  .llm-toast {
    /* clear mobile input area + home bar */
    bottom: calc(80px + env(safe-area-inset-bottom, 0px));
    left: 16px;
    right: 16px;
    min-width: 0;
    transform: translateY(110%);
  }
  .llm-toast.visible  { transform: translateY(0); }
  .llm-toast.dismissed{ transform: translateY(20px); }
}

/* ================================================================
   TERMS OF SERVICE GATE
   ================================================================ */

.terms-gate {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: radial-gradient(ellipse at 40% 40%, rgba(124,58,237,0.18) 0%, rgba(6,6,15,0.98) 60%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.terms-gate.accepted {
  opacity: 0;
  pointer-events: none;
}

.terms-box {
  width: 100%;
  max-width: 520px;
  background: rgba(13,13,28,0.97);
  border: 1px solid rgba(124,58,237,0.3);
  border-radius: 24px;
  padding: 40px 36px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  box-shadow: 0 32px 80px rgba(0,0,0,0.7), 0 0 0 1px rgba(124,58,237,0.1);
  animation: termsAppear 0.6s cubic-bezier(0.16,1,0.3,1) both;
}

@keyframes termsAppear {
  from { opacity: 0; transform: translateY(24px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.terms-logo-wrap {
  filter: drop-shadow(0 0 16px rgba(124,58,237,0.5)) drop-shadow(0 0 32px rgba(6,182,212,0.25));
  margin-bottom: 4px;
}

.terms-title {
  font-size: 28px;
  font-weight: 700;
  color: #eeeeff;
  letter-spacing: -1px;
  text-align: center;
  margin: 0;
}

.terms-brand {
  background: linear-gradient(120deg, #a855f7, #22d3ee);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.terms-tagline {
  font-size: 14px;
  color: rgba(255,255,255,0.5);
  text-align: center;
  margin: 0;
  line-height: 1.5;
}

.terms-scroll {
  width: 100%;
  max-height: 200px;
  overflow-y: auto;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 16px 18px;
  font-size: 13px;
  color: rgba(255,255,255,0.55);
  line-height: 1.65;
  scrollbar-width: thin;
}

.terms-scroll h3 {
  font-size: 13px;
  font-weight: 600;
  color: rgba(255,255,255,0.75);
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.terms-scroll p { margin: 0 0 8px; }

.terms-scroll ul {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.terms-scroll li strong { color: rgba(255,255,255,0.8); }

.terms-agree-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 28px;
  border-radius: 14px;
  border: none;
  background: linear-gradient(135deg, #7c3aed 0%, #06b6d4 100%);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  letter-spacing: 0.01em;
  box-shadow: 0 4px 24px rgba(124,58,237,0.4);
  margin-top: 4px;
  width: 100%;
  justify-content: center;
}

.terms-agree-btn svg { width: 18px; height: 18px; }

.terms-agree-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(124,58,237,0.55);
}

.terms-agree-btn:active { transform: translateY(0); }

.terms-footnote {
  font-size: 11.5px;
  color: rgba(255,255,255,0.25);
  text-align: center;
  margin: 0;
}

/* ================================================================
   TERMS GATE — MOBILE
   ================================================================ */
@media (max-width: 480px) {
  .terms-gate { padding: 12px; align-items: flex-end; }
  .terms-box  {
    padding: 28px 20px 20px;
    border-radius: 20px 20px 0 0;
    /* full-height with scroll on very small screens */
    max-height: calc(100vh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    overflow-y: auto;
    /* safe-area inset so agree button isn't hidden by home bar */
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
  }
  .terms-scroll { max-height: 150px; }
  .terms-title  { font-size: 22px; }
  .terms-agree-btn { font-size: 14px; padding: 12px 20px; }
}

/* ================================================================
   TERMS GATE — Step 2: Model download
   ================================================================ */
.terms-model-step {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  width: 100%;
  animation: termsAppear 0.45s cubic-bezier(0.16,1,0.3,1) both;
}

.terms-model-step.visible {
  display: flex;
}

.tms-icon-wrap {
  filter: drop-shadow(0 0 14px rgba(124,58,237,0.5)) drop-shadow(0 0 28px rgba(6,182,212,0.2));
  margin-bottom: 2px;
}

.tms-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
  text-align: center;
  margin: 0;
  background: linear-gradient(120deg, #a855f7, #22d3ee);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.tms-subtitle {
  font-size: 13.5px;
  color: rgba(255,255,255,0.5);
  text-align: center;
  line-height: 1.6;
  margin: 0;
  max-width: 380px;
}

.tms-download-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 14px 28px;
  border-radius: 14px;
  border: none;
  background: linear-gradient(135deg, #7c3aed 0%, #06b6d4 100%);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  letter-spacing: 0.01em;
  box-shadow: 0 4px 24px rgba(124,58,237,0.4);
  width: 100%;
  justify-content: center;
}

.tms-download-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(124,58,237,0.55);
}

.tms-download-btn:active { transform: translateY(0); }

.tms-download-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.tms-skip-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.32);
  font-size: 12.5px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: color 0.15s ease;
  letter-spacing: 0.02em;
}

.tms-skip-btn:hover { color: rgba(255,255,255,0.6); }

.tms-progress-wrap {
  display: none;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(124,58,237,0.2);
  border-radius: 14px;
  padding: 16px 18px;
}

.tms-progress-wrap.visible { display: flex; }

.tms-progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.tms-model-badge {
  font-size: 12px;
  font-weight: 600;
  background: rgba(124,58,237,0.18);
  color: #a78bfa;
  border: 1px solid rgba(124,58,237,0.3);
  border-radius: 6px;
  padding: 2px 10px;
  letter-spacing: 0.04em;
}

.tms-pct {
  font-size: 14px;
  font-weight: 700;
  color: #eeeeff;
  font-variant-numeric: tabular-nums;
}

.tms-eta {
  font-size: 12px;
  color: rgba(255,255,255,0.38);
  font-variant-numeric: tabular-nums;
}

.tms-bar-track {
  width: 100%;
  height: 6px;
  background: rgba(255,255,255,0.07);
  border-radius: 999px;
  overflow: hidden;
}

.tms-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #7c3aed, #06b6d4);
  border-radius: 999px;
  transition: width 0.4s ease;
  box-shadow: 0 0 8px rgba(124,58,237,0.6);
}

.tms-status {
  font-size: 12.5px;
  color: rgba(255,255,255,0.45);
  text-align: center;
  letter-spacing: 0.02em;
}

.tms-status.ready {
  color: #34d399;
  font-weight: 600;
}

/* ================================================================
   NOVA PARTICLE SYSTEM — submit burst + text trail
   ================================================================ */

#starParticleLayer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 600;
  overflow: hidden;
}

/* Base particle — only transform + opacity animated (GPU composited) */
.nova-p {
  position: fixed;
  pointer-events: none;
  font-style: normal;
  line-height: 1;
  transform-origin: center;
  will-change: transform, opacity;
  user-select: none;
}

/* ── Wave particle: flies from send btn → thinking area ── */
/* Strong ease-out: starts fast (responsive), curves gently to target */
.nova-p--wave {
  animation: novaWave var(--dur, 640ms) cubic-bezier(0.23, 1, 0.32, 1) var(--delay, 0ms) both;
}

@keyframes novaWave {
  0% {
    opacity: 1;
    transform: translate(0, 0) scale(1) rotate(0deg);
  }
  65% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    /* Arc slightly off the straight line — particles "catch a current" */
    transform: translate(var(--dx), var(--dy))
               scale(var(--se, 0.25))
               rotate(var(--rot, 540deg));
  }
}

/* ── Text trail: shimmering wake behind the typing cursor ── */
/* Fast (380ms), low opacity max — seen every response so must be subtle */
.nova-p--trail {
  animation: novaTrail 380ms ease-out forwards;
}

@keyframes novaTrail {
  0%   { opacity: 0.65; transform: translate(0, 0) scale(1); }
  40%  { opacity: 0.65; }
  100% { opacity: 0;    transform: translate(var(--tdx, 3px), var(--tdy, -18px)) scale(0.15); }
}

/* Reduced motion: no movement, only gentle fade */
@media (prefers-reduced-motion: reduce) {
  .nova-p--wave,
  .nova-p--trail {
    animation: novaFadeOnly 300ms ease-out forwards;
  }
  @keyframes novaFadeOnly {
    from { opacity: 1; }
    to   { opacity: 0; }
  }
}

/* ================================================================
   LOGO STAR FLIGHT ANIMATION
   ================================================================ */

/* The flying star element */
.logo-star-fly {
  position: fixed;
  pointer-events: none;
  z-index: 700;
  font-style: normal;
  line-height: 1;
  user-select: none;
  will-change: transform, opacity;
  transform-origin: center center;

  /* Start position set via inline style; CSS vars drive animation deltas */
  left: var(--star-x);
  top:  var(--star-y);

  font-size: 36px;
  color: #fff;
  text-shadow:
    0 0 20px #c4b5fd,
    0 0 40px #7c3aed,
    0 0 60px #7c3aed;
}

/* Phase 1 — shoot upward from send button, arc to hover point */
@keyframes starFlight {
  0% {
    opacity: 0;
    transform: translate(0, 0) scale(0.5) rotate(-15deg);
  }
  8% {
    opacity: 1;
  }
  100% {
    opacity: 1;
    transform:
      translate(var(--star-dx), var(--star-dy))
      scale(1)
      rotate(0deg);
  }
}

.logo-star-fly--flight {
  animation: starFlight 750ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* ================================================================
   THINKING ROW SHAKE — fires when the star impacts the thinking area
   ================================================================ */
@keyframes thinkRowShake {
  0%   { transform: translateX(0) scale(1); }
  15%  { transform: translateX(-6px) scale(1.01); }
  30%  { transform: translateX(5px) scale(1.01); }
  45%  { transform: translateX(-4px); }
  60%  { transform: translateX(3px); }
  75%  { transform: translateX(-2px); }
  90%  { transform: translateX(1px); }
  100% { transform: translateX(0) scale(1); }
}

.thinking-row--shake {
  animation: thinkRowShake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

/* ================================================================
   THINKING BURST — burst particles, shimmer, orbit
   ================================================================ */

/* ── Burst particles ──────────────────────────────────────────── */
.think-burst-p {
  position: fixed;
  pointer-events: none;
  z-index: 650;
  font-style: normal;
  line-height: 1;
  user-select: none;
  will-change: transform, opacity;
  transform-origin: center;
  animation: thinkBurstOut var(--tb-dur, 180ms) cubic-bezier(0.22, 1, 0.36, 1) var(--tb-delay, 0ms) both;
}

@keyframes thinkBurstOut {
  0%   { opacity: 1;   transform: translate(0, 0) scale(1.2) rotate(0deg); }
  60%  { opacity: 0.8; }
  100% { opacity: 0;   transform: translate(var(--tb-dx), var(--tb-dy)) scale(0.1) rotate(var(--tb-rot, 360deg)); }
}

/* ── Row shimmer overlay ──────────────────────────────────────── */
.think-shimmer {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  pointer-events: none;
  z-index: 2;
  overflow: hidden;
}

.think-shimmer::after {
  content: '';
  position: absolute;
  top: 0;
  left: -80%;
  width: 60%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(168, 85, 247, 0.18) 30%,
    rgba(6, 182, 212, 0.22) 50%,
    rgba(168, 85, 247, 0.18) 70%,
    transparent 100%
  );
  animation: thinkShimmerSweep 420ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes thinkShimmerSweep {
  from { left: -80%; opacity: 1; }
  to   { left: 140%; opacity: 0; }
}

/* ── Orbit particles ──────────────────────────────────────────── */
.think-orbit-p {
  position: absolute;
  pointer-events: none;
  z-index: 3;
  font-style: normal;
  line-height: 1;
  user-select: none;
  will-change: transform, opacity;
  /* orbit center anchored to left-center of the thinking-steps area */
  top: 50%;
  left: 44px;
  transform-origin: 0 0;
  animation:
    orbit-path var(--orb-dur, 1.2s) linear var(--orb-delay, 0s) infinite,
    orbitFadeIn 0.3s ease var(--orb-delay, 0s) both;
}

@keyframes orbit-path {
  from { transform: rotate(var(--orb-start, 0deg)) translateX(var(--orb-rx, 38px)) translateY(var(--orb-ry, 0px)) scale(1); }
  to   { transform: rotate(calc(var(--orb-start, 0deg) + 360deg)) translateX(var(--orb-rx, 38px)) translateY(var(--orb-ry, 0px)) scale(1); }
}

@keyframes orbitFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.think-orbit-p.fading {
  animation: orbitFadeOut 0.4s ease forwards !important;
}

@keyframes orbitFadeOut {
  from { opacity: 1; }
  to   { opacity: 0; }
}

/* Phase 2 — hover pulse above thinking area */
@keyframes starHover {
  0%, 100% { transform: translate(var(--star-dx), var(--star-dy)) scale(0.95); }
  50%       { transform: translate(var(--star-dx), var(--star-dy)) scale(1.05); }
}

.logo-star-fly--hover {
  animation: starHover 340ms ease-in-out both;
}

/* Phase 3 — dive into thinking row, absorbed */
@keyframes starDive {
  0% {
    opacity: 1;
    transform:
      translate(var(--star-dx), var(--star-dy))
      scale(1.05);
  }
  60% {
    opacity: 0.6;
  }
  100% {
    opacity: 0;
    transform:
      translate(var(--star-dx), calc(var(--star-dy) + var(--star-dive-extra, 40px)))
      scale(0.15)
      rotate(20deg);
  }
}

.logo-star-fly--dive {
  animation: starDive 350ms cubic-bezier(0.55, 0, 1, 0.45) both;
}

/* Phase 6 — emerge from thinking row, pop upward before streaming */
@keyframes starEmerge {
  0% {
    opacity: 0;
    transform: translate(0, 0) scale(0.3) rotate(-20deg);
  }
  30% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(0, -55px) scale(1.4) rotate(25deg);
  }
}

.logo-star-fly--emerge {
  font-size: 22px;
  animation: starEmerge 380ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* Burst ring that flashes when the star lands */
@keyframes starBurst {
  0%   { opacity: 0.9; transform: translate(var(--star-dx), var(--star-dy)) scale(0.2); }
  60%  { opacity: 0.5; }
  100% { opacity: 0;   transform: translate(var(--star-dx), var(--star-dy)) scale(2.8); }
}

.logo-star-burst {
  position: fixed;
  pointer-events: none;
  z-index: 700;
  width: 48px;
  height: 48px;
  margin-left: -24px;
  margin-top: -24px;
  border-radius: 50%;
  border: 1.5px solid rgba(196, 181, 253, 0.85);
  box-shadow: 0 0 12px rgba(124,58,237,0.7), inset 0 0 8px rgba(124,58,237,0.3);
  will-change: transform, opacity;
  animation: starBurst 320ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* ================================================================
   THINKING → RESPONSE TRANSITION
   ================================================================ */

.thinking-row {
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.thinking-row.swoosh-out {
  opacity: 0;
  transform: translateY(8px) scale(0.97);
  pointer-events: none;
}

.ai-message-wrap {
  animation: responseIn 0.4s cubic-bezier(0.16,1,0.3,1) both;
}

@keyframes responseIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Step label swoosh */
.thinking-step-label {
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.thinking-step-label.step-changing {
  opacity: 0;
  transform: translateX(-6px);
}

/* ================================================================
   NOVA WAVE CANVAS — full-screen submit sweep
   ================================================================ */

#novaWaveCanvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  pointer-events: none;
  opacity: 0;
  mix-blend-mode: screen;
  /* opacity is driven by JS — canvas starts invisible */
}

/* ================================================================
   NOVA COMET TRAIL — particles spawned along the star's flight path
   ================================================================ */

/* Each comet particle is GPU-composited: only transform + opacity move */
.nova-comet-particle {
  position: fixed;
  pointer-events: none;
  line-height: 1;
  transform-origin: center;
  will-change: transform, opacity;
  user-select: none;
  font-style: normal;
  /* --cp-dx, --cp-dy, --cp-dur, --cp-delay set inline per particle */
}

/* Dense head particles (close to star): bright, fast fade */
.nova-comet-particle--head {
  animation: cometHead var(--cp-dur, 320ms) ease-out var(--cp-delay, 0ms) forwards;
}

@keyframes cometHead {
  0%   { opacity: 1;    transform: translate(0, 0) scale(1); }
  30%  { opacity: 0.9; }
  100% { opacity: 0;    transform: translate(var(--cp-dx, 0px), var(--cp-dy, -8px)) scale(0.25); }
}

/* Tail particles (further behind star): softer, slightly longer life */
.nova-comet-particle--tail {
  animation: cometTail var(--cp-dur, 480ms) ease-out var(--cp-delay, 0ms) forwards;
}

@keyframes cometTail {
  0%   { opacity: 0.8;  transform: translate(0, 0) scale(0.9); }
  20%  { opacity: 0.65; }
  100% { opacity: 0;    transform: translate(var(--cp-dx, 0px), var(--cp-dy, -14px)) scale(0.1); }
}

/* Reduced motion: skip movement, only fade */
@media (prefers-reduced-motion: reduce) {
  .nova-comet-particle--head,
  .nova-comet-particle--tail {
    animation: cometFadeOnly var(--cp-dur, 350ms) ease-out forwards;
  }
  @keyframes cometFadeOnly {
    from { opacity: 1; }
    to   { opacity: 0; }
  }
}

/* ================================================================
   WRITER STAR — glowing neon star that leads the streaming cursor
   ================================================================ */

.writer-star {
  position: fixed;
  pointer-events: none;
  z-index: 650;
  font-style: normal;
  line-height: 1;
  user-select: none;
  font-size: 14px;
  color: #fff;
  text-shadow:
    0 0 6px #e9d5ff,
    0 0 14px #c4b5fd,
    0 0 28px #7c3aed,
    0 0 42px rgba(124, 58, 237, 0.6);
  will-change: left, top, transform, opacity;
  transition: left 80ms ease-out, top 80ms ease-out;
}

/* Burst-and-fade keyframe for when streaming ends */
@keyframes writerStarBurst {
  0%   { transform: scale(1);   opacity: 1; }
  60%  { transform: scale(2.8); opacity: 0.7; }
  100% { transform: scale(3.2); opacity: 0; }
}

.writer-star--burst {
  animation: writerStarBurst 300ms ease-out forwards !important;
  transition: none !important;
}

/* Sparkle dots that trail behind the star */
.writer-sparkle {
  position: fixed;
  pointer-events: none;
  z-index: 649;
  user-select: none;
  border-radius: 50%;
  width: 3px;
  height: 3px;
  will-change: left, top, opacity;
  /* lag behind the star to create trailing effect */
  transition: left 160ms ease-out, top 160ms ease-out, opacity 200ms ease-out;
}

/* Reduced motion: skip movement, only fade */
@media (prefers-reduced-motion: reduce) {
  .writer-star {
    transition: opacity 300ms ease-out !important;
  }
  .writer-star--burst {
    animation: writerStarFadeOnly 300ms ease-out forwards !important;
  }
  @keyframes writerStarFadeOnly {
    from { opacity: 1; }
    to   { opacity: 0; }
  }
  .writer-sparkle {
    transition: opacity 200ms ease-out !important;
  }
}

/* ================================================================
   NOVA AMBIENT GLOW — soft lingering radial on page background
   Sits below the wave canvas (z-index 1 vs canvas z-index 2).
   Opacity is driven entirely by JS via triggerAmbientGlow().
   ================================================================ */

#novaAmbientGlow {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(
    ellipse 80% 60% at 50% 100%,
    rgba(124, 58, 237, 0.07)  0%,
    rgba(6, 182, 212, 0.04)  40%,
    transparent              70%
  );
  opacity: 0;
  transition: opacity 200ms ease-in;
  will-change: opacity;
}

/* ================================================================
   TERMS GATE — STEP 2: LOCAL AI DOWNLOAD
   ================================================================ */

/*
 * Step 1: .terms-box   (existing)
 * Step 2: .terms-model-step  (this section)
 *
 * JS adds .terms-box--step2 to .terms-gate so the ambient border
 * glow shifts from purple to cyan when on step 2.
 * JS toggles .terms-step-hidden on whichever panel is off-screen.
 */

/* ── Step transition: smooth fade+slide between step 1 and step 2 */
.terms-box,
.terms-model-step {
  transition:
    opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.terms-step-hidden {
  opacity: 0 !important;
  transform: translateY(12px) scale(0.98) !important;
  pointer-events: none !important;
  position: absolute !important;
}

/* ── .terms-gate modifier: cyan glow replaces purple on step 2 ── */
.terms-gate.terms-box--step2 .terms-box {
  border-color: rgba(6, 182, 212, 0.3);
  box-shadow:
    0 32px 80px rgba(0, 0, 0, 0.7),
    0 0 0 1px rgba(6, 182, 212, 0.12),
    0 0 60px rgba(6, 182, 212, 0.08);
}

/* ── Step 2 container (.terms-model-step) ────────────────────── */
.terms-model-step {
  width: 100%;
  max-width: 520px;
  background: rgba(13, 13, 28, 0.97);
  border: 1px solid rgba(6, 182, 212, 0.28);
  border-radius: 24px;
  padding: 44px 40px 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  box-shadow:
    0 32px 80px rgba(0, 0, 0, 0.7),
    0 0 0 1px rgba(6, 182, 212, 0.1),
    0 0 80px rgba(6, 182, 212, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  position: relative;
  overflow: hidden;
  animation: termsStep2Appear 0.55s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes termsStep2Appear {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Cyan-to-purple shimmer stripe across the top edge */
.terms-model-step::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(6, 182, 212, 0.55) 35%,
    rgba(124, 58, 237, 0.55) 65%,
    transparent 100%
  );
  animation: step2TopShimmer 3s ease-in-out infinite;
}

@keyframes step2TopShimmer {
  0%, 100% { opacity: 0.5; }
  50%       { opacity: 1; }
}

/* ── Icon area (.tms-icon-wrap) ──────────────────────────────── */
.tms-icon-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background: radial-gradient(
    ellipse at center,
    rgba(6, 182, 212, 0.14) 0%,
    rgba(124, 58, 237, 0.10) 60%,
    transparent 100%
  );
  border: 1px solid rgba(6, 182, 212, 0.2);
  position: relative;
  flex-shrink: 0;
  margin-bottom: 4px;
}

/* Outer glow ring */
.tms-icon-wrap::before {
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 1px solid rgba(6, 182, 212, 0.12);
  animation: tmsIconRingPulse 3s ease-in-out infinite;
}

/* Second, wider ring */
.tms-icon-wrap::after {
  content: '';
  position: absolute;
  inset: -18px;
  border-radius: 50%;
  border: 1px solid rgba(124, 58, 237, 0.08);
  animation: tmsIconRingPulse 3s ease-in-out 0.6s infinite;
}

@keyframes tmsIconRingPulse {
  0%, 100% { opacity: 0.4; transform: scale(1); }
  50%       { opacity: 1;   transform: scale(1.05); }
}

.tms-icon-wrap svg {
  animation: tmsIconGlowPulse 3.5s ease-in-out infinite;
}

@keyframes tmsIconGlowPulse {
  0%, 100% {
    filter:
      drop-shadow(0 0 8px rgba(6, 182, 212, 0.5))
      drop-shadow(0 0 20px rgba(124, 58, 237, 0.25));
  }
  50% {
    filter:
      drop-shadow(0 0 16px rgba(6, 182, 212, 0.8))
      drop-shadow(0 0 36px rgba(124, 58, 237, 0.45));
  }
}

/* ── Title and subtitle ───────────────────────────────────────── */
.tms-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.7px;
  text-align: center;
  margin: 0;
  background: linear-gradient(120deg, #a855f7 0%, #22d3ee 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.25;
}

.tms-subtitle {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.5);
  text-align: center;
  margin: 0;
  line-height: 1.6;
  max-width: 360px;
}

/* ── Download button (.tms-download-btn) ─────────────────────── */
.tms-download-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 15px 28px;
  border-radius: 14px;
  border: none;
  background: linear-gradient(135deg, #7c3aed 0%, #06b6d4 100%);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  box-shadow:
    0 4px 24px rgba(124, 58, 237, 0.45),
    0 0 0 1px rgba(6, 182, 212, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
  transition:
    transform 0.2s cubic-bezier(0.34, 1.3, 0.64, 1),
    box-shadow 0.2s ease;
  animation: tmsDownloadPulse 2.5s ease-in-out infinite;
}

@keyframes tmsDownloadPulse {
  0%, 100% {
    box-shadow:
      0 4px 24px rgba(124, 58, 237, 0.45),
      0 0 0 1px rgba(6, 182, 212, 0.2),
      inset 0 1px 0 rgba(255, 255, 255, 0.15);
  }
  50% {
    box-shadow:
      0 6px 36px rgba(124, 58, 237, 0.65),
      0 0 40px rgba(6, 182, 212, 0.25),
      0 0 0 1px rgba(6, 182, 212, 0.3),
      inset 0 1px 0 rgba(255, 255, 255, 0.15);
  }
}

/* Shimmer sweep on hover */
.tms-download-btn::before {
  content: '';
  position: absolute;
  top: 0; left: -70%;
  width: 50%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.18),
    transparent
  );
  transition: left 0.55s ease;
}

.tms-download-btn:hover::before { left: 130%; }

.tms-download-btn:hover {
  transform: translateY(-2px);
  box-shadow:
    0 8px 40px rgba(124, 58, 237, 0.65),
    0 0 50px rgba(6, 182, 212, 0.3),
    0 0 0 1px rgba(6, 182, 212, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
  animation: none;
}

.tms-download-btn:active {
  transform: translateY(0) scale(0.99);
  transition-duration: 0.1s;
}

.tms-download-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  animation: none;
}

/* ── Skip link (.tms-skip-btn) ───────────────────────────────── */
.tms-skip-btn {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.28);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: color 0.2s ease, background 0.2s ease;
  letter-spacing: 0.01em;
  margin-top: -8px;
}

.tms-skip-btn:hover {
  color: rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.05);
}

/* ── Progress area (.tms-progress-wrap) — hidden until active ── */
.tms-progress-wrap {
  display: none;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  padding: 18px 20px;
  background: rgba(6, 182, 212, 0.04);
  border: 1px solid rgba(6, 182, 212, 0.15);
  border-radius: 14px;
  animation: tmsProgressAreaIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.tms-progress-wrap.active {
  display: flex;
}

@keyframes tmsProgressAreaIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Progress meta row: model badge left, percentage right */
.tms-progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* Model name pill badge */
.tms-model-badge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--purple-light);
  background: rgba(124, 58, 237, 0.12);
  border: 1px solid rgba(124, 58, 237, 0.28);
  padding: 3px 10px;
  border-radius: var(--r-pill);
}

/* Percentage readout */
.tms-pct {
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  color: var(--cyan-light);
  letter-spacing: 0.03em;
  min-width: 38px;
  text-align: right;
}

/* ETA / size hint line */
.tms-eta {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.35);
  letter-spacing: 0.01em;
  margin-top: -4px;
}

/* ── Progress bar track ───────────────────────────────────────── */
.tms-bar-track {
  width: 100%;
  height: 5px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 3px;
  overflow: hidden;
}

/* ── Progress bar fill (purple → cyan gradient, animated shine) ─ */
.tms-bar-fill {
  height: 100%;
  width: 0%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--purple) 0%, var(--cyan) 100%);
  transition: width 0.45s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.tms-bar-fill::after {
  content: '';
  position: absolute;
  top: 0; bottom: 0;
  width: 55%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.32),
    transparent
  );
  animation: tmsBarShine 1.6s ease-in-out infinite;
}

@keyframes tmsBarShine {
  from { left: -55%; }
  to   { left: 150%; }
}

/* ── Status text (.tms-status) ───────────────────────────────── */
.tms-status {
  font-size: 12.5px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.45);
  letter-spacing: 0.01em;
  text-align: center;
  transition: color 0.3s ease;
}

.tms-status.state-downloading {
  color: var(--purple-light);
  animation: tmsStatusPulse 1.5s ease-in-out infinite;
}

.tms-status.state-installing {
  color: var(--cyan-light);
  animation: tmsStatusPulse 1.2s ease-in-out infinite;
}

.tms-status.state-ready {
  color: #4ade80;
  font-weight: 600;
  animation: none;
}

@keyframes tmsStatusPulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.55; }
}

/* ── Mobile responsive ───────────────────────────────────────── */
@media (max-width: 560px) {
  .terms-model-step {
    padding: 32px 24px 28px;
    gap: 16px;
  }
  .tms-title { font-size: 20px; }
  .tms-icon-wrap { width: 68px; height: 68px; }
  .tms-download-btn { font-size: 14px; padding: 13px 20px; }
}

/* ================================================================
   BETA BADGE
   ================================================================ */
.beta-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(6,182,212,0.15);
  border: 1px solid rgba(6,182,212,0.35);
  color: #22d3ee;
  vertical-align: middle;
  margin-left: 6px;
  line-height: 1;
}
.beta-badge--lg {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 6px;
}

/* ================================================================
   TERMS INLINE AI MODEL SECTION
   ================================================================ */

.terms-ai-section {
  width: 100%;
  border: 1px solid rgba(124,58,237,0.25);
  border-radius: 12px;
  background: rgba(124,58,237,0.06);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.terms-ai-download-area {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.terms-ai-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.terms-ai-icon {
  font-size: 20px;
  color: #c4b5fd;
  text-shadow: 0 0 10px rgba(124,58,237,0.7);
  flex-shrink: 0;
}

.terms-ai-info strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #f0eaff;
}

.terms-ai-size {
  font-size: 11px;
  color: rgba(255,255,255,0.4);
}

.terms-ai-dl-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, #7c3aed, #06b6d4);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.18s ease;
  flex-shrink: 0;
}

.terms-ai-dl-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(124,58,237,0.45); }
.terms-ai-dl-btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.terms-ai-progress-area {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.terms-ai-progress-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
}

.terms-ai-status-label { color: rgba(255,255,255,0.65); }
.terms-ai-pct { color: #c4b5fd; font-weight: 600; font-variant-numeric: tabular-nums; }

.terms-ai-bar-track {
  width: 100%;
  height: 4px;
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
  overflow: hidden;
}

.terms-ai-bar-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #7c3aed, #06b6d4);
  border-radius: 2px;
  transition: width 0.4s ease;
}

.terms-ai-eta {
  font-size: 11px;
  color: rgba(255,255,255,0.35);
  min-height: 14px;
}

.terms-ai-ready-area {
  display: flex;
  align-items: center;
  gap: 8px;
}

.terms-ai-ready-icon {
  font-size: 16px;
  color: #34d399;
  text-shadow: 0 0 10px rgba(52,211,153,0.6);
}

.terms-ai-ready-text {
  font-size: 13px;
  font-weight: 600;
  color: #34d399;
}

/* Agree button disabled state */
.terms-agree-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
  background: rgba(100,80,140,0.4) !important;
}

/* AGB / EULA link */
.terms-agb-link {
  color: #67e8f9;
  text-decoration: underline;
  text-underline-offset: 2px;
  font-size: inherit;
  transition: color 0.15s ease;
}
.terms-agb-link:hover { color: #a5f3fc; }

.terms-agb-check-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  font-size: 13px;
  color: rgba(255,255,255,0.65);
  line-height: 1.5;
  width: 100%;
  padding: 4px 0;
}

.terms-agb-checkbox {
  width: 18px;
  height: 18px;
  min-width: 18px;
  border-radius: 5px;
  border: 2px solid rgba(124,58,237,0.5);
  background: rgba(124,58,237,0.1);
  cursor: pointer;
  accent-color: #7c3aed;
  margin-top: 1px;
}

.terms-agb-check-text { flex: 1; }

.welcome-privacy-note {
  font-size: 11.5px;
  color: rgba(255,255,255,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  margin-top: 16px;
  margin-bottom: 4px;
  padding-bottom: 8px;
}
.welcome-privacy-icon { font-size: 13px; }
.welcome-privacy-link {
  color: #67e8f9;
  text-decoration: none;
  border-bottom: 1px solid rgba(6,182,212,0.3);
  transition: color 0.15s ease, border-color 0.15s ease;
}
.welcome-privacy-link:hover { color: #a5f3fc; border-color: rgba(165,243,252,0.5); }

/* ================================================================
   PRIVACY SPLASH — full-screen overlay shown once after first agree
   ================================================================ */

.privacy-splash {
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: radial-gradient(ellipse at 50% 30%, rgba(124,58,237,0.2) 0%, rgba(6,6,15,0.98) 55%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
  transition: opacity 0.5s ease;
}

.privacy-splash.hidden { display: none; }
.privacy-splash.closing { opacity: 0; pointer-events: none; }

.privacy-splash-box {
  width: 100%;
  max-width: 640px;
  background: rgba(13,13,28,0.97);
  border: 1px solid rgba(124,58,237,0.25);
  border-radius: 24px;
  padding: 44px 40px 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  box-shadow: 0 32px 80px rgba(0,0,0,0.7), 0 0 0 1px rgba(124,58,237,0.1);
  animation: termsAppear 0.6s cubic-bezier(0.16,1,0.3,1) both;
  max-height: 90vh;
  overflow-y: auto;
}

.privacy-splash-star {
  font-size: 40px;
  color: #c4b5fd;
  text-shadow: 0 0 20px rgba(124,58,237,0.8), 0 0 40px rgba(124,58,237,0.4);
  animation: novaStarPulse 2s ease-in-out infinite;
  line-height: 1;
}

.privacy-splash-title {
  font-size: clamp(24px,4vw,36px);
  font-weight: 700;
  text-align: center;
  color: #f0eaff;
  letter-spacing: -1px;
  margin: 0;
  line-height: 1.2;
}

.privacy-splash-accent {
  background: linear-gradient(120deg, #c4b5fd, #22d3ee);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.privacy-splash-sub {
  font-size: 15px;
  color: rgba(255,255,255,0.55);
  text-align: center;
  margin: 0;
  line-height: 1.6;
  max-width: 480px;
}

.privacy-cards-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
}

@media (max-width: 520px) {
  .privacy-cards-grid { grid-template-columns: 1fr; }
  .privacy-splash-box { padding: 28px 16px 24px; }
}

.privacy-card {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(124,58,237,0.07);
  border: 1px solid rgba(124,58,237,0.18);
  transition: border-color 0.2s ease, background 0.2s ease;
}

.privacy-card:hover {
  background: rgba(124,58,237,0.13);
  border-color: rgba(124,58,237,0.35);
}

.privacy-card-icon {
  font-size: 22px;
  flex-shrink: 0;
  margin-top: 1px;
}

.privacy-card strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #f0eaff;
  margin-bottom: 4px;
}

.privacy-card p {
  font-size: 12px;
  color: rgba(255,255,255,0.5);
  line-height: 1.55;
  margin: 0;
}

.privacy-got-it-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 32px;
  border-radius: 14px;
  border: none;
  background: linear-gradient(135deg, #7c3aed 0%, #06b6d4 100%);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 24px rgba(124,58,237,0.4);
  width: 100%;
  justify-content: center;
}

.privacy-got-it-btn svg { width: 18px; height: 18px; }
.privacy-got-it-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 32px rgba(124,58,237,0.55); }

.privacy-splash-footer {
  font-size: 12px;
  color: rgba(255,255,255,0.35);
  margin: 0;
  text-align: center;
}

/* ================================================================
   MOBILE CHAT COMFORT — max-width: 768px
   ================================================================ */
@media (max-width: 768px) {
  /* 1. Message row spacing — tighten gap between messages */
  .message-row {
    padding: 6px 0;
  }

  /* 2. Avatar — lock to 32px on mobile (no larger overrides) */
  .msg-avatar,
  .ai-avatar {
    width: 32px;
    height: 32px;
    font-size: 13px;
  }

  /* 3. Bubble max-width — user bubble gets more room on narrow screens */
  .user-bubble {
    max-width: 88%;
    padding: 10px 14px;
  }

  /* 4. AI content — left padding so text doesn't start at the very edge */
  .ai-content {
    padding: 2px 0 2px 2px;
    font-size: 14px;
    line-height: 1.7;
  }

  /* 5. AI response text — ensure minimum 14px for readability */
  .ai-content p,
  .ai-content li,
  .ai-content td,
  .ai-content th {
    font-size: 14px;
  }

  /* 6. Code blocks — horizontal scroll without breaking layout */
  .ai-content pre {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }

  .ai-content pre code {
    font-size: 12px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .ai-content :not(pre) > code {
    font-size: 12px;
    word-break: break-word;
  }

  /* 7. Table overflow — block display with horizontal scroll */
  .ai-content table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    font-size: 13px;
  }
}

/* ================================================================
   WELCOME SCREEN — MOBILE FIXES
   ================================================================ */

@media (max-width: 768px) {
  /* 1. Reduce top padding so logo + title fit without scrolling */
  .welcome-screen {
    padding: 20px 16px 16px;
  }

  /* 3. Title size and letter-spacing */
  .welcome-title {
    font-size: clamp(32px, 7vw, 48px);
    letter-spacing: -1.5px;
  }

  /* 6. Logo wrap bottom margin */
  .welcome-logo-wrap {
    margin-bottom: 24px;
  }

  /* 2. Logo SVG dimensions */
  .welcome-logo-mark svg {
    width: 72px;
    height: 72px;
  }

  /* 5. Suggestion card padding; remove fixed min-height */
  .suggestion-card {
    padding: 12px 14px;
    min-height: 0;
  }

  /* 5. Suggestion icon size */
  .suggestion-icon {
    font-size: 28px;
  }

  /* 7. Beta badge slightly smaller on mobile */
  .beta-badge--lg {
    font-size: 10px;
    padding: 3px 8px;
  }

  /* 8. Privacy note — centered, wraps neatly */
  .welcome-privacy-note {
    font-size: 11px;
    text-align: center;
    flex-wrap: wrap;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  /* 4. Single-column suggestion grid on very small screens */
  .suggestion-grid {
    grid-template-columns: 1fr;
  }
}

/* ================================================================
   MOBILE SCROLL & TOUCH IMPROVEMENTS
   ================================================================ */

/* 1. Momentum scrolling on all scrollable containers */
@media (max-width: 768px) {
  .chat-viewport,
  .sidebar-section,
  .terms-scroll,
  .settings-drawer,
  .privacy-splash-box {
    -webkit-overflow-scrolling: touch;
  }
}

/* 2. Remove tap highlight on interactive elements */
@media (max-width: 768px) {
  button, a, .suggestion-card, .history-item, .mode-chip, .model-chip {
    -webkit-tap-highlight-color: transparent;
  }
}

/* 3. Active press states for touch devices (hover unavailable on coarse pointers) */
@media (hover: none) and (pointer: coarse) {
  .suggestion-card:active {
    transform: scale(0.97);
    background: rgba(124,58,237,0.12);
  }
  .mode-chip:active {
    transform: scale(0.95);
  }
  .new-chat-btn:active {
    transform: scale(0.97);
  }
  .terms-agree-btn:active:not(:disabled) {
    transform: scale(0.98);
  }
  .privacy-got-it-btn:active {
    transform: scale(0.98);
  }
}

/* 4. Prevent double-tap zoom on interactive elements */
button, a, input[type="checkbox"], .suggestion-card {
  touch-action: manipulation;
}

/* 5. Hide scrollbars on mobile for a cleaner look */
@media (max-width: 768px) {
  ::-webkit-scrollbar {
    display: none;
  }
  * {
    scrollbar-width: none;
  }
}

/* ================================================================
   MOBILE POLISH — topbar height, thinking indicator, touch targets,
   markdown headings
   ================================================================ */

/* 1. Topbar height — 52px on mobile to maximise chat space */
@media (max-width: 768px) {
  :root { --topbar-h: 52px; }

  /* 2. Thinking step labels — compact, ellipsis on overflow */
  .thinking-step .step-label {
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
  }

  /* 6. Topbar action buttons — 40×40px minimum touch target */
  .topbar-action-btn {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
  }

  /* 7. Markdown headings — smaller sizes on narrow screens */
  .ai-content h1 { font-size: 18px; }
  .ai-content h2 { font-size: 16px; }
  .ai-content h3 { font-size: 15px; }
}

/* ================================================================
   FEEDBACK ROW (thumbs up / down on AI responses)
   ================================================================ */

.feedback-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

/* Show on hover of the ai-row, or after a vote */
.ai-row:hover .feedback-row,
.feedback-row.voted { opacity: 1; }

.feedback-btn {
  background: none;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s ease;
  color: rgba(255,255,255,0.5);
}

.feedback-btn:hover {
  border-color: rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.05);
}

.feedback-row.voted-up .feedback-btn[data-val="up"] {
  background: rgba(52,211,153,0.2);
  border-color: #34d399;
  color: #34d399;
}

.feedback-row.voted-down .feedback-btn[data-val="down"] {
  background: rgba(239,68,68,0.2);
  border-color: #ef4444;
  color: #ef4444;
}

.feedback-btn.voted { pointer-events: none; }

.feedback-label {
  font-size: 11px;
  color: rgba(255,255,255,0.25);
}

.feedback-reasons {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.feedback-reason-btn {
  font-size: 10px;
  padding: 2px 8px;
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: 4px;
  background: rgba(239,68,68,0.08);
  color: rgba(255,255,255,0.5);
  cursor: pointer;
  transition: all 0.15s ease;
}

.feedback-reason-btn:hover {
  background: rgba(239,68,68,0.15);
  color: #fca5a5;
}

.feedback-reason-btn:disabled {
  cursor: default;
}
