/* ═══════════════════════════════════════════════════════════
   PRIVEX AI — DESIGN SYSTEM v2
   Inter font · Warm dark palette · Stroke-only SVG icons
   ═══════════════════════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Inter:ital,wght@0,300;0,400;0,500;1,400&display=swap');

/* ── DESIGN TOKENS ─────────────────────────────────────────── */
:root {
  /* Background layers */
  --bg:           #0b0b0e;
  --surface:      #111115;
  --elevated:     #18181d;
  --hover:        #1e1e24;
  --active:       #25252e;

  /* Borders */
  --border:       #1e1e26;
  --border-mid:   #2a2a36;
  --border-strong:#38383f;

  /* Text */
  --text-1:       #f0f0f2;
  --text-2:       #8a8a95;
  --text-3:       #44444d;

  /* Accent & status */
  --accent:       #ffffff;
  --green:        #22c55e;
  --red:          #ef4444;
  --amber:        #f59e0b;

  /* Chat */
  --user-bubble:  #17171c;
  --model-bubble: transparent;

  /* Radii */
  --r-sm:   6px;
  --r-md:   10px;
  --r-lg:   14px;
  --r-xl:   18px;
  --r-full: 9999px;

  /* Typography */
  --font:        'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --fs-xs:       11px;
  --fs-sm:       12px;
  --fs-base:     14px;
  --fs-md:       15px;
  --fs-lg:       17px;

  /* Layout */
  --sidebar-w:   260px;
  --topbar-h:    56px;
  --inputbar-h:  auto;
  --chat-max-w:  720px;

  /* Transitions */
  --t-fast:  100ms ease;
  --t-base:  180ms ease;
  --t-slow:  300ms ease;
}

/* Light theme override */
[data-theme="light"] {
  --bg:           #f7f7f8;
  --surface:      #ffffff;
  --elevated:     #f0f0f2;
  --hover:        #e8e8ec;
  --active:       #e0e0e6;
  --border:       #e2e2e8;
  --border-mid:   #d0d0d8;
  --border-strong:#b8b8c2;
  --text-1:       #111115;
  --text-2:       #5a5a65;
  --text-3:       #9a9aa5;
  --user-bubble:  #ededf2;
  --model-bubble: transparent;
}

/* Font size data variants */
[data-font="sm"]  { font-size: 13px; }
[data-font="md"]  { font-size: 14px; }
[data-font="lg"]  { font-size: 16px; }

/* Chat width data variants */
[data-width="compact"] { --chat-max-w: 560px; }
[data-width="normal"]  { --chat-max-w: 720px; }
[data-width="wide"]    { --chat-max-w: 920px; }

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

html,
body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  font-size: var(--fs-base);
  background: var(--bg);
  color: var(--text-1);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button {
  cursor: pointer;
  font-family: inherit;
  border: none;
  background: none;
}

a { color: inherit; }

input,
textarea,
select {
  font-family: inherit;
  font-size: inherit;
}

/* ── SVG ICON UTILITIES ─────────────────────────────────────── */
/* All stroke-based SVG icons inherit color from parent,
   no fill, capped at the declared size. */
.icon-stroke {
  display: inline-block;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
  vertical-align: middle;
  pointer-events: none;
}

.icon-12 { width: 12px; height: 12px; }
.icon-14 { width: 14px; height: 14px; }
.icon-16 { width: 16px; height: 16px; }
.icon-18 { width: 18px; height: 18px; }
.icon-20 { width: 20px; height: 20px; }
.icon-24 { width: 24px; height: 24px; }

/* ── HIDDEN UTILITY ─────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── SCROLLBAR ──────────────────────────────────────────────── */
::-webkit-scrollbar       { width: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-mid); border-radius: 99px; }

/* ═══════════════════════════════════════════════════════════
   LOADING SCREEN
   ═══════════════════════════════════════════════════════════ */
/* ═══════════════════════════════════════════════════════════
   APP LAYOUT
   ═══════════════════════════════════════════════════════════ */
#app {
  display: flex;
  flex-direction: row;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

/* ═══════════════════════════════════════════════════════════
   SIDEBAR
   ═══════════════════════════════════════════════════════════ */
#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
  transition: transform var(--t-slow);
}

/* ── Brand header ── */
#sidebar-header {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}

.brand-circle {
  width: 30px;
  height: 30px;
  border-radius: var(--r-full);
  background: var(--elevated);
  border: 1px solid var(--border-mid);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 400;
  color: var(--text-2);
  flex-shrink: 0;
}

.brand-details {
  display: flex;
  flex-direction: column;
}

.brand-name {
  font-size: var(--fs-base);
  font-weight: 400;
  color: var(--text-1);
  line-height: 1.2;
}

.brand-subtext {
  font-size: var(--fs-xs);
  color: var(--text-3);
  line-height: 1.2;
}

/* ── Status row ── */
#sidebar-status-row {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 16px 8px;
  flex-shrink: 0;
}

.status-dot-pulse {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
  animation: status-pulse 2.5s ease-in-out infinite;
}

@keyframes status-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.35; }
}

.status-label {
  font-size: var(--fs-xs);
  color: var(--text-3);
}

/* ── New chat button ── */
.new-chat-container {
  padding: 2px 12px 10px;
  flex-shrink: 0;
}

#newChatBtn {
  width: 100%;
  height: 34px;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: opacity var(--t-fast), transform var(--t-fast);
}

#newChatBtn:hover  { opacity: 0.9; }
#newChatBtn:active { transform: scale(0.97); }

/* ── Sidebar section label ── */
.sidebar-list-divider {
  padding: 4px 16px 4px;
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-3);
  flex-shrink: 0;
}

/* ── Chat list ── */
#chatList {
  flex: 1;
  overflow-y: auto;
  padding: 2px 0;
}

.chat-item {
  position: relative;
  display: flex;
  align-items: center;
  margin: 1px 8px;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background var(--t-fast);
  min-height: 36px;
  padding: 0 4px 0 12px;
  gap: 4px;
}

.chat-item:hover {
  background: var(--hover);
}

.chat-item.active {
  background: var(--active);
}

.chat-item-title {
  flex: 1;
  font-size: var(--fs-sm);
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 8px 0;
  line-height: 1.2;
  transition: color var(--t-fast);
  user-select: none;
}

.chat-item:hover .chat-item-title,
.chat-item.active .chat-item-title {
  color: var(--text-1);
}

.conv-actions-btn {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-3);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity var(--t-fast), background var(--t-fast), color var(--t-fast);
}

.chat-item:hover .conv-actions-btn {
  opacity: 1;
}

.conv-actions-btn:hover {
  background: var(--border-mid);
  color: var(--text-1);
}

/* ── Context menu ── */
.context-menu {
  position: fixed;
  z-index: 500;
  background: var(--elevated);
  border: 1px solid var(--border-mid);
  border-radius: var(--r-md);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45), 0 2px 8px rgba(0,0,0,0.3);
  min-width: 140px;
  overflow: hidden;
  animation: ctxFadeIn 120ms ease;
}

@keyframes ctxFadeIn {
  from { opacity: 0; transform: scale(0.95) translateY(-4px); }
  to   { opacity: 1; transform: scale(1)    translateY(0); }
}

.context-menu-item {
  width: 100%;
  height: 36px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 14px;
  font-size: var(--fs-sm);
  color: var(--text-1);
  background: transparent;
  border: none;
  text-align: left;
  cursor: pointer;
  transition: background var(--t-fast);
}

.context-menu-item:hover {
  background: var(--hover);
}

.context-menu-item.danger {
  color: var(--red);
}

.context-menu-item.danger:hover {
  background: rgba(239, 68, 68, 0.08);
}

/* ── Sidebar footer ── */
#sidebar-footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-footer-btn {
  height: 40px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 9px;
  font-size: var(--fs-sm);
  color: var(--text-2);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
  text-align: left;
}

.sidebar-footer-btn:hover {
  background: var(--hover);
  color: var(--text-1);
}

/* ═══════════════════════════════════════════════════════════
   SIDEBAR BACKDROP (mobile)
   ═══════════════════════════════════════════════════════════ */
#sidebarBackdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
}

#sidebarBackdrop.open {
  display: block;
}

/* ═══════════════════════════════════════════════════════════
   MAIN AREA
   ═══════════════════════════════════════════════════════════ */
#main {
  flex: 1;
  min-width: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  overflow: hidden;
}

/* ── Topbar ── */
#topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 12px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.hamburger-btn {
  display: none;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--text-2);
  align-items: center;
  justify-content: center;
  transition: background var(--t-fast), color var(--t-fast);
  flex-shrink: 0;
}

.hamburger-btn:hover {
  background: var(--hover);
  color: var(--text-1);
}

#activeTitle {
  font-size: var(--fs-base);
  font-weight: 400;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

#activeTitle:hover {
  color: var(--text-2);
}

.mode-pill-badge {
  font-size: var(--fs-xs);
  color: var(--text-3);
  padding: 3px 8px;
  border-radius: var(--r-full);
  border: 1px solid var(--border);
  white-space: nowrap;
}

.topbar-settings-btn {
  height: 30px;
  padding: 0 10px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-2);
  font-size: var(--fs-xs);
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: border-color var(--t-fast), color var(--t-fast), background var(--t-fast);
}

.topbar-settings-btn:hover {
  border-color: var(--border-strong);
  color: var(--text-1);
  background: var(--hover);
}

/* ═══════════════════════════════════════════════════════════
   MESSAGES AREA
   ═══════════════════════════════════════════════════════════ */
#messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ── Welcome container ── */
#welcomeContainer {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  pointer-events: none;
  user-select: none;
  width: 100%;
  max-width: 420px;
  padding: 0 24px;
}

#welcomeContainer.hidden {
  display: none;
}

.welcome-logo {
  width: 44px;
  height: 44px;
  border-radius: var(--r-full);
  background: var(--surface);
  border: 1px solid var(--border-mid);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 300;
  color: var(--text-2);
  margin-bottom: 6px;
}

.welcome-title {
  font-size: 22px;
  font-weight: 300;
  color: var(--text-1);
  letter-spacing: -0.02em;
}

.welcome-subtitle {
  font-size: var(--fs-sm);
  color: var(--text-3);
  line-height: 1.5;
  max-width: 300px;
}

.welcome-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-top: 8px;
}

.welcome-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: var(--fs-xs);
  color: var(--text-3);
  padding: 4px 10px;
  border-radius: var(--r-full);
  border: 1px solid var(--border);
  background: var(--surface);
}

/* ── Messages inner ── */
.messages-inner {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 20px 0 120px;
  max-width: var(--chat-max-w);
  width: 100%;
  margin: 0 auto;
}

/* ── Message wrappers ── */
.msg-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 4px 24px;
}

.msg-wrapper:hover .msg-actions {
  opacity: 1;
}

/* User message */
.msg-wrapper.user {
  align-items: flex-end;
}

/* Model message */
.msg-wrapper.model {
  align-items: flex-start;
}

/* Error message */
.msg-wrapper.error .msg-bubble {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: var(--red);
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--r-lg);
  font-size: var(--fs-sm);
}

/* ── Message bubbles ── */
.msg-bubble {
  max-width: 80%;
  word-break: break-word;
}

.msg-wrapper.user .msg-bubble {
  background: var(--user-bubble);
  border: 1px solid var(--border);
  border-radius: var(--r-xl) var(--r-xl) var(--r-sm) var(--r-xl);
  padding: 10px 14px;
  font-size: var(--fs-base);
  color: var(--text-1);
  line-height: 1.55;
}

.msg-wrapper.model .msg-bubble {
  background: var(--model-bubble);
  border-radius: 0;
  padding: 0;
  max-width: 100%;
}

/* Model message layout (brand circle + text column) */
.model-message-container {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
}

.model-brand-circle {
  width: 24px;
  height: 24px;
  border-radius: var(--r-full);
  background: var(--surface);
  border: 1px solid var(--border-mid);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 400;
  color: var(--text-2);
  flex-shrink: 0;
  margin-top: 2px;
}

.model-text-content {
  flex: 1;
  min-width: 0;
  padding: 0;
  font-size: var(--fs-base);
  line-height: 1.65;
  color: var(--text-1);
}

/* User message text */
.message-content {
  font-size: var(--fs-base);
  line-height: 1.55;
  color: var(--text-1);
  white-space: pre-wrap;
}

/* Image attachments */
.msg-attachment-container {
  margin-bottom: 8px;
}

.msg-attachment-img {
  max-width: 280px;
  max-height: 240px;
  border-radius: var(--r-lg);
  object-fit: contain;
  display: block;
}

/* Timestamp */
.msg-timestamp {
  font-size: var(--fs-xs);
  color: var(--text-3);
  margin-top: 3px;
  padding: 0 2px;
}

/* ── Message action buttons ── */
.msg-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  opacity: 0;
  transition: opacity var(--t-fast);
}

.msg-action-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
}

.msg-action-btn:hover {
  background: var(--hover);
  color: var(--text-1);
}

/* ── Typing indicator ── */
.typing-indicator-container {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 8px 0;
}

.typing-dot {
  width: 6px;
  height: 6px;
  background: var(--text-3);
  border-radius: 50%;
  animation: typing-bounce 1.2s ease-in-out infinite;
}

.typing-dot:nth-child(1) { animation-delay: 0s; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30%            { transform: translateY(-5px); }
}

/* Streaming cursor */
.streaming-cursor::after {
  content: '▋';
  animation: blink 0.8s step-end infinite;
  margin-left: 1px;
  color: var(--text-3);
}

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

/* ── Markdown content ── */
.model-text-content h1,
.model-text-content h2,
.model-text-content h3,
.model-text-content h4 {
  font-weight: 500;
  margin: 16px 0 6px;
  color: var(--text-1);
}

.model-text-content h1 { font-size: 18px; }
.model-text-content h2 { font-size: 16px; }
.model-text-content h3 { font-size: 14px; }

.model-text-content p { margin-bottom: 10px; }
.model-text-content p:last-child { margin-bottom: 0; }

.model-text-content ul,
.model-text-content ol {
  margin: 6px 0 10px 18px;
}

.model-text-content li { margin-bottom: 3px; }

.model-text-content strong { font-weight: 500; }
.model-text-content em     { font-style: italic; }

.model-text-content a {
  color: var(--text-1);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.model-text-content code {
  font-family: 'JetBrains Mono', 'Fira Mono', 'Menlo', monospace;
  font-size: 12px;
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--text-1);
}

.model-text-content pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px;
  overflow-x: auto;
  margin: 10px 0;
  position: relative;
}

.model-text-content pre code {
  background: transparent;
  border: none;
  padding: 0;
  font-size: 13px;
  line-height: 1.6;
}

.model-text-content blockquote {
  border-left: 3px solid var(--border-mid);
  margin: 8px 0;
  padding: 4px 14px;
  color: var(--text-2);
  font-style: italic;
}

.model-text-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 12px 0;
}

/* Code copy button */
.code-copy {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  border: 1px solid var(--border-mid);
  border-radius: var(--r-sm);
  background: var(--elevated);
  color: var(--text-2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--t-fast), background var(--t-fast);
}

.model-text-content pre:hover .code-copy { opacity: 1; }
.code-copy:hover { background: var(--hover); color: var(--text-1); }
.code-copy[data-copied="true"] { color: var(--green); }

/* ═══════════════════════════════════════════════════════════
   INPUT BAR
   ═══════════════════════════════════════════════════════════ */
#input-bar {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  background: var(--bg);
  padding: 14px 20px 16px;
}

.input-container {
  max-width: var(--chat-max-w);
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Image preview */
#imagePreviewContainer {
  display: flex;
  align-items: center;
  gap: 8px;
}

.image-preview-wrapper {
  position: relative;
  display: inline-flex;
}

#imagePreview {
  max-width: 80px;
  max-height: 60px;
  object-fit: cover;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
}

#removeImageBtn {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--elevated);
  border: 1px solid var(--border-mid);
  color: var(--text-2);
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  line-height: 1;
}

/* Textarea wrapper */
.textarea-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border-mid);
  border-radius: var(--r-xl);
  padding: 8px 8px 8px 12px;
  transition: border-color var(--t-fast);
}

.textarea-wrapper:focus-within {
  border-color: var(--border-strong);
}

.input-actions-left {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  margin-bottom: 2px;
}

.input-action-btn {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
  flex-shrink: 0;
}

.input-action-btn:hover {
  background: var(--hover);
  color: var(--text-1);
}

.input-action-btn.recording {
  color: var(--red);
  animation: mic-pulse 1.2s ease-in-out infinite;
}

@keyframes mic-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

#messageInput {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  font-size: var(--fs-base);
  color: var(--text-1);
  line-height: 1.5;
  max-height: 200px;
  overflow-y: auto;
  padding: 2px 0;
}

#messageInput::placeholder {
  color: var(--text-3);
}

#sendBtn {
  width: 32px;
  height: 32px;
  border-radius: var(--r-md);
  border: none;
  background: var(--border-mid);
  color: var(--text-3);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--t-fast), color var(--t-fast), transform var(--t-fast);
  margin-bottom: 0;
}

#sendBtn.active,
#sendBtn:not(:disabled):hover {
  background: var(--accent);
  color: var(--bg);
}

#sendBtn:active:not(:disabled) {
  transform: scale(0.93);
}

#sendBtn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.input-disclaimer {
  font-size: var(--fs-xs);
  color: var(--text-3);
  text-align: center;
  line-height: 1.4;
}

/* ═══════════════════════════════════════════════════════════
   LOCAL SETUP WIZARD
   ═══════════════════════════════════════════════════════════ */
#localSetupGuide {
  flex: 1;
  overflow-y: auto;
  padding: 32px 20px;
}

.setup-wizard-container {
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.wizard-header h2 {
  font-size: 18px;
  font-weight: 400;
  color: var(--text-1);
  margin-bottom: 6px;
}

.wizard-header p {
  font-size: var(--fs-sm);
  color: var(--text-2);
}

.wizard-steps {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.wizard-step {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px 20px;
}

.wizard-step-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.step-number {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--elevated);
  border: 1px solid var(--border-mid);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-xs);
  color: var(--text-2);
  flex-shrink: 0;
}

.wizard-step-title h3 {
  font-size: var(--fs-base);
  font-weight: 400;
  color: var(--text-1);
}

.wizard-step-body p {
  font-size: var(--fs-sm);
  color: var(--text-2);
  line-height: 1.55;
  margin-bottom: 10px;
}

/* Spec grid */
.spec-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.spec-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.spec-item label {
  font-size: var(--fs-xs);
  color: var(--text-3);
  font-weight: 400;
}

.spec-item input,
.spec-item select {
  height: 34px;
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text-1);
  padding: 0 10px;
  font-size: var(--fs-sm);
  outline: none;
  transition: border-color var(--t-fast);
}

.spec-item input:focus,
.spec-item select:focus {
  border-color: var(--border-strong);
}

/* Analyzer result */
.analyzer-loading {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.scanning-bar-container {
  width: 100%;
  height: 4px;
  background: var(--bg-modifier-hover);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.scanning-bar {
  width: 40%;
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  animation: scanSweep 1.5s ease-in-out infinite;
  box-shadow: 0 0 8px var(--primary);
}

.scanning-text {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  animation: pulseText 1.5s infinite;
}

@keyframes scanSweep {
  0% { transform: translateX(-100%); }
  50% { transform: translateX(250%); }
  100% { transform: translateX(-100%); }
}

@keyframes pulseText {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

.analyzer-result {
  margin-top: 14px;
  animation: slideInFade 0.4s ease forwards;
}

.recommendation-card {
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px;
}

.recommendation-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.recommendation-title {
  font-size: var(--fs-base);
  font-weight: 500;
  color: var(--text-1);
  font-family: monospace;
}

.rating-stars {
  font-size: 13px;
  color: var(--amber);
}

.recommendation-info p {
  font-size: var(--fs-sm);
  color: var(--text-2);
  margin-bottom: 4px !important;
}

.terminal-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 10px 14px;
  margin-top: 10px;
  gap: 8px;
}

.terminal-box code {
  font-family: 'JetBrains Mono', 'Fira Mono', 'Menlo', monospace;
  font-size: 13px;
  color: var(--text-1);
}

.terminal-copy-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--t-fast), color var(--t-fast);
}

.terminal-copy-btn:hover {
  background: var(--hover);
  color: var(--text-1);
}

/* ═══════════════════════════════════════════════════════════
   FIRST LAUNCH OVERLAY
   ═══════════════════════════════════════════════════════════ */
.settings-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

/* Choice cards (first launch + theme picker) */
.choice-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 16px;
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  color: var(--text-1);
  cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast);
  text-align: center;
}

.choice-card:hover {
  border-color: rgba(255, 255, 255, 0.4);
  background: var(--hover);
  transform: scale(1.02);
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.1);
}

.choice-card.active {
  border-color: var(--accent);
  background: var(--elevated);
}

/* ── First-launch card ── */
.first-launch-card {
  background: var(--surface);
  border: 1px solid var(--border-mid);
  border-radius: var(--r-xl);
  box-shadow: 0 24px 80px rgba(0,0,0,0.55);
  width: 520px;
  max-width: calc(100vw - 40px);
  padding: 36px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  animation: fadeIn 200ms ease;
}

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

.first-launch-logo {
  width: 48px;
  height: 48px;
  border-radius: var(--r-full);
  background: var(--elevated);
  border: 1px solid var(--border-mid);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 300;
  color: var(--text-2);
  margin-bottom: 4px;
}

.first-launch-title {
  font-size: 20px;
  font-weight: 400;
  color: var(--text-1);
  letter-spacing: -0.02em;
}

.first-launch-sub {
  font-size: var(--fs-sm);
  color: var(--text-3);
  text-align: center;
  line-height: 1.5;
}

.first-launch-choices {
  display: flex;
  gap: 12px;
  width: 100%;
  margin-top: 8px;
}

/* Tall variant for first-launch */
.choice-card--tall {
  flex: 1;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  padding: 18px 18px;
  min-height: 120px;
}

.choice-card-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--r-md);
  background: var(--hover);
  border: 1px solid var(--border-mid);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  flex-shrink: 0;
}

.choice-card-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
}

.choice-card-text strong {
  font-size: var(--fs-base);
  font-weight: 500;
  color: var(--text-1);
}

.choice-card-text span {
  font-size: var(--fs-xs);
  color: var(--text-3);
  line-height: 1.4;
}

.first-launch-footnote {
  font-size: var(--fs-xs);
  color: var(--text-3);
  margin-top: 4px;
}



/* ═══════════════════════════════════════════════════════════
   SETTINGS MODAL
   ═══════════════════════════════════════════════════════════ */
.settings-modal {
  background: var(--surface);
  border: 1px solid var(--border-mid);
  border-radius: var(--r-xl);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6), 0 4px 16px rgba(0,0,0,0.4);
  width: 700px;
  max-width: calc(100vw - 40px);
  height: 480px;
  max-height: calc(100vh - 80px);
  display: flex;
  flex-direction: row;
  overflow: hidden;
  transform: scale(0.97) translateY(8px);
  opacity: 0;
  transition: transform var(--t-slow), opacity var(--t-slow);
}

.settings-overlay.open .settings-modal,
.settings-overlay:not(.hidden) .settings-modal {
  /* Handled by JS adding .open class to overlay */
}

.settings-overlay.open .settings-modal {
  transform: scale(1) translateY(0);
  opacity: 1;
}

/* ── Settings sidebar nav ── */
.settings-modal-sidebar {
  width: 160px;
  min-width: 160px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 8px;
  gap: 2px;
  flex-shrink: 0;
}

.settings-tab-btn {
  height: 36px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 10px;
  border: none;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--text-2);
  font-size: var(--fs-sm);
  cursor: pointer;
  text-align: left;
  transition: background var(--t-fast), color var(--t-fast);
  white-space: nowrap;
}

.settings-tab-btn:hover {
  background: var(--hover);
  color: var(--text-1);
}

.settings-tab-btn.active {
  background: var(--active);
  color: var(--text-1);
}

/* ── Settings main content ── */
.settings-modal-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.settings-modal-header {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.settings-modal-title h2 {
  font-size: var(--fs-base);
  font-weight: 400;
  color: var(--text-1);
}

.settings-close-btn {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}

.settings-close-btn:hover {
  background: var(--hover);
  color: var(--text-1);
  border-color: var(--border-mid);
}

/* ── Settings panels ── */
.settings-tab-panel {
  display: none;
  flex-direction: column;
  gap: 18px;
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.settings-tab-panel.active {
  display: flex;
}

.settings-section-title {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-3);
}

.settings-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.settings-row label {
  font-size: var(--fs-sm);
  color: var(--text-2);
  font-weight: 400;
}

.row-inline {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}

.settings-description {
  font-size: var(--fs-xs);
  color: var(--text-3);
  line-height: 1.4;
}

.settings-row input[type="password"],
.settings-row input[type="text"],
.settings-row select {
  height: 36px;
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text-1);
  padding: 0 12px;
  font-size: var(--fs-sm);
  outline: none;
  transition: border-color var(--t-fast);
}

.settings-row input:focus,
.settings-row select:focus {
  border-color: var(--border-strong);
}

.action-row-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.status-line {
  font-size: var(--fs-xs);
  color: var(--text-2);
  margin-top: 2px;
}

/* Mode selector pills */
.settings-mode-selector {
  display: flex;
  gap: 6px;
}

.toggle-pill-btn {
  height: 30px;
  padding: 0 14px;
  border-radius: var(--r-full);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-2);
  font-size: var(--fs-sm);
  cursor: pointer;
  transition: all var(--t-fast);
}

.toggle-pill-btn:hover {
  background: var(--hover);
  color: var(--text-1);
}

.toggle-pill-btn.active {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

/* Appearance cards row */
.appearance-cards-row {
  display: flex;
  gap: 8px;
}

.appearance-cards-row .choice-card {
  flex: 1;
  height: 64px;
  gap: 6px;
}

/* Segmented control */
.segmented-control {
  display: flex;
  gap: 4px;
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 3px;
}

.segment-btn {
  flex: 1;
  height: 26px;
  border: none;
  border-radius: calc(var(--r-md) - 2px);
  background: transparent;
  color: var(--text-2);
  font-size: var(--fs-xs);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
  font-family: inherit;
}

.segment-btn:hover {
  color: var(--text-1);
}

.segment-btn.active {
  background: var(--surface);
  color: var(--text-1);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

/* Toggle switch */
.toggle-switch-wrapper {
  position: relative;
  display: inline-flex;
  cursor: pointer;
  flex-shrink: 0;
}

.toggle-switch-wrapper input[type="checkbox"] {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-slider {
  width: 36px;
  height: 20px;
  background: var(--elevated);
  border: 1px solid var(--border-mid);
  border-radius: var(--r-full);
  position: relative;
  transition: background var(--t-base), border-color var(--t-base);
}

.toggle-slider::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text-3);
  transition: transform var(--t-base), background var(--t-base);
}

.toggle-switch-wrapper input:checked + .toggle-slider {
  background: var(--green);
  border-color: var(--green);
}

.toggle-switch-wrapper input:checked + .toggle-slider::after {
  transform: translateX(16px);
  background: #fff;
}

/* TTS speed slider */
.slider-container {
  display: flex;
  align-items: center;
  gap: 10px;
}

.slider-container input[type="range"] {
  flex: 1;
  height: 4px;
  accent-color: var(--accent);
  cursor: pointer;
}

.slider-container span {
  font-size: var(--fs-xs);
  color: var(--text-2);
  min-width: 32px;
  text-align: right;
}

/* About tab */
.about-tab-details {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.about-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: var(--fs-sm);
  color: var(--text-2);
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.about-row:last-of-type { border-bottom: none; }

.about-privacy-note {
  font-size: var(--fs-xs);
  color: var(--text-3);
  line-height: 1.5;
  margin-top: 4px;
  padding: 10px 12px;
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}

/* ── Button primitives ── */
.btn-primary {
  height: 34px;
  padding: 0 16px;
  border: none;
  border-radius: var(--r-md);
  background: var(--accent);
  color: var(--bg);
  font-size: var(--fs-sm);
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  transition: opacity var(--t-fast), transform var(--t-fast);
}

.btn-primary:hover  { opacity: 0.9; }
.btn-primary:active { transform: scale(0.97); }

.btn-secondary {
  height: 34px;
  padding: 0 16px;
  border: 1px solid var(--border-mid);
  border-radius: var(--r-md);
  background: transparent;
  color: var(--text-1);
  font-size: var(--fs-sm);
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  transition: border-color var(--t-fast), background var(--t-fast);
}

.btn-secondary:hover {
  border-color: var(--border-strong);
  background: var(--hover);
}

.text-btn-danger {
  background: transparent;
  border: none;
  color: var(--red);
  font-size: var(--fs-sm);
  cursor: pointer;
  font-family: inherit;
  padding: 4px 0;
  transition: opacity var(--t-fast);
}

.text-btn-danger:hover { opacity: 0.8; }

/* ── Model caps labels ── */
.model-caps {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.cap-badge {
  font-size: var(--fs-xs);
  padding: 2px 7px;
  border-radius: var(--r-full);
  border: 1px solid var(--border);
  color: var(--text-2);
}

/* ═══════════════════════════════════════════════════════════
   OFFLINE BANNER
   ═══════════════════════════════════════════════════════════ */
#offlineBanner {
  background: var(--amber);
  color: #000;
  font-size: var(--fs-xs);
  font-weight: 500;
  text-align: center;
  padding: 7px 16px;
  z-index: 100;
  position: relative;
}

/* ═══════════════════════════════════════════════════════════
   TOAST NOTIFICATION
   ═══════════════════════════════════════════════════════════ */
#toastContainer {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
}

.toast {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--elevated);
  border: 1px solid var(--border-mid);
  border-radius: var(--r-full);
  padding: 8px 16px;
  font-size: var(--fs-sm);
  color: var(--text-1);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  animation: toastIn 180ms ease;
  transition: opacity 200ms ease;
  pointer-events: auto;
}

.toast.fade-out {
  opacity: 0;
}

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

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE — MOBILE
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  #sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 50;
    transform: translateX(-100%);
  }

  #sidebar.open {
    transform: translateX(0);
  }

  .hamburger-btn {
    display: flex;
  }

  .topbar-settings-btn span {
    display: none;
  }

  #messages {
    padding-bottom: 0;
  }

  .messages-inner {
    padding: 12px 0 100px;
  }

  .msg-wrapper {
    padding: 4px 14px;
  }

  .msg-bubble {
    max-width: 92%;
  }

  .welcome-pills {
    flex-direction: column;
  }

  input, textarea, select, button {
    font-size: 16px !important; /* iOS zoom prevention */
  }

  .settings-modal {
    flex-direction: column;
    height: auto;
    max-height: calc(100vh - 40px);
  }

  .settings-modal-sidebar {
    width: 100%;
    min-width: 0;
    border-right: none;
    border-bottom: 1px solid var(--border);
    flex-direction: row;
    padding: 8px;
    overflow-x: auto;
  }

  .settings-tab-btn {
    flex-shrink: 0;
  }

  .spec-grid {
    grid-template-columns: 1fr;
  }
}

/* ═══════════════════════════════════════════════════════════
   PRINT / EXPORT
   ═══════════════════════════════════════════════════════════ */
@media print {
  #sidebar,
  #topbar,
  #input-bar,
  #loadingScreen,
  .settings-overlay,
  #toastContainer {
    display: none !important;
  }

  #main {
    height: auto;
    overflow: visible;
  }

  #messages {
    overflow: visible;
    height: auto;
  }

  body {
    background: #fff;
    color: #000;
  }
}

/* ═══════════════════════════════════════════════════════════
   ADAPTIVE UI & LOCAL MODEL WIZARD
   ═══════════════════════════════════════════════════════════ */

/* Cinematic Push Transitions */
.push-out {
  animation: pushOut 300ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.push-in {
  animation: pushIn 300ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes pushOut {
  from { opacity: 1; transform: scale(1); }
  to   { opacity: 0; transform: scale(0.95); }
}

@keyframes pushIn {
  from { opacity: 0; transform: scale(1.05); }
  to   { opacity: 1; transform: scale(1); }
}

/* Connection Checking Ring */
.connection-ring-container {
  position: relative;
  width: 64px;
  height: 64px;
  margin: 0 auto;
}

.pulse-ring {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  color: var(--accent);
  animation: ringPulse 1.5s infinite cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes ringPulse {
  0% { transform: scale(0.8); opacity: 1; stroke-width: 3; }
  100% { transform: scale(1.6); opacity: 0; stroke-width: 1; }
}

.pulse-ring.success {
  animation: none;
  color: #10b981; /* Green */
  transform: scale(1);
}

.pulse-ring.success circle {
  stroke-dasharray: 200;
  stroke-dashoffset: 200;
  animation: drawCircle 400ms ease-out forwards;
}

.pulse-ring.success #connectionCheckMark {
  display: block;
  stroke-dasharray: 40;
  stroke-dashoffset: 40;
  animation: drawCheck 300ms 200ms ease-out forwards;
}

.pulse-ring.error {
  animation: none;
  color: #f59e0b; /* Amber */
  transform: scale(1);
}

@keyframes drawCircle {
  to { stroke-dashoffset: 0; }
}
@keyframes drawCheck {
  to { stroke-dashoffset: 0; }
}

.connection-ring-logo {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 24px;
  color: var(--text-1);
}

/* Setup Wizard */
.setup-wizard-card {
  display: flex;
  flex-direction: column;
}

.wizard-header {
  padding: 24px 32px;
  border-bottom: 1px solid var(--border-mid);
}

.wizard-title {
  margin: 0 0 16px;
  font-size: var(--fs-lg);
  font-weight: 500;
}

.wizard-steps {
  display: flex;
  align-items: center;
  gap: 8px;
}

.step-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--text-3);
  transition: background 300ms, transform 300ms;
}

.step-dot.completed {
  background: rgba(255, 255, 255, 0.6);
}

.step-dot.active {
  background: var(--text-1);
  transform: scale(1.2);
}

.step-line {
  flex: 1;
  height: 2px;
  background: var(--border-mid);
  position: relative;
  overflow: hidden;
}

.step-line::after {
  content: '';
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 0%;
  background: var(--text-1);
  transition: width 300ms ease-out;
}

.step-line.filled::after {
  width: 100%;
}

.wizard-step-content {
  padding: 32px;
  flex: 1;
  animation: fadeIn 300ms ease;
}

.wizard-footer {
  padding: 24px 32px;
  border-top: 1px solid var(--border-mid);
  display: flex;
  justify-content: flex-end;
  background: var(--bg);
  border-bottom-left-radius: var(--r-xl);
  border-bottom-right-radius: var(--r-xl);
}

.spec-cards-row {
  display: flex;
  gap: 16px;
  margin-top: 24px;
}

.spec-card {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
}

.spec-label {
  font-size: var(--fs-xs);
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.spec-edit-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 24px;
}

.input-with-icon {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-icon input {
  width: 100%;
  padding-right: 32px;
}

.input-with-icon .edit-icon {
  position: absolute;
  right: 12px;
  color: var(--accent);
}

.hero-recommendation-card {
  background: linear-gradient(145deg, var(--surface), var(--bg));
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  padding: 24px;
  margin-top: 24px;
}

.hero-rec-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.hero-rec-header h1 {
  margin: 0;
  font-size: var(--fs-xl);
  font-weight: 600;
  color: var(--accent);
}

.quality-badge {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: var(--fs-xs);
  font-weight: 600;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.rec-bullets {
  margin: 0;
  padding-left: 20px;
  color: var(--text-2);
  font-size: var(--fs-sm);
  line-height: 1.5;
}

.install-steps {
  margin-top: 32px;
}

.install-steps p {
  margin: 8px 0;
  font-size: var(--fs-sm);
  color: var(--text-2);
}

.terminal-block {
  background: #000;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  color: #a8b2c1;
  margin-top: 8px;
}

.terminal-block .icon-btn {
  background: none;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  padding: 4px;
}

.terminal-block .icon-btn:hover {
  color: var(--text-1);
}

/* Model Selection Cards */
.model-selection-panel {
  display: flex;
  flex-direction: column;
}

.slide-in-right {
  animation: slideInRight 300ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.model-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all 120ms ease;
  border-left: 3px solid transparent;
}

.model-card:hover {
  background: var(--hover);
  border-color: var(--border-mid);
}

.model-card.active {
  background: rgba(255, 255, 255, 0.03);
  border-left-color: var(--text-1);
  border-color: var(--border-strong);
}

.model-card-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.model-card-name {
  font-weight: 500;
  font-size: var(--fs-md);
  color: var(--text-1);
}

.model-badges {
  display: flex;
  gap: 6px;
}

.model-badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.model-badge.chat { background: rgba(59, 130, 246, 0.15); color: #60a5fa; border: 1px solid rgba(59, 130, 246, 0.3); }
.model-badge.vision { background: rgba(168, 85, 247, 0.15); color: #c084fc; border: 1px solid rgba(168, 85, 247, 0.3); }
.model-badge.code { background: rgba(16, 185, 129, 0.15); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.3); }
.model-badge.fast { background: rgba(245, 158, 11, 0.15); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.3); }

.model-card-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.model-card-size {
  font-size: var(--fs-sm);
  color: var(--text-3);
}

.model-check {
  color: var(--text-1);
  opacity: 0;
  transition: opacity 120ms;
}

.model-card.active .model-check {
  opacity: 1;
}

/* Chat Mode Tabs */
.chat-mode-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  justify-content: center;
}

.mode-tab-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-2);
  padding: 4px 12px;
  border-radius: 16px;
  font-size: var(--fs-xs);
  cursor: pointer;
  transition: all 150ms ease;
  font-weight: 500;
}

.mode-tab-btn:hover {
  background: var(--hover);
  color: var(--text-1);
}

.mode-tab-btn.active {
  background: var(--text-1);
  color: var(--bg);
  border-color: var(--text-1);
}

/* Slide in fade for image attach */
.slide-in-fade {
  animation: slideInFade 250ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

/* Streaming Cursor */
.streaming-cursor {
  display: inline-block;
  width: 2px;
  height: 1.2em;
  background-color: var(--text-1);
  vertical-align: text-bottom;
  margin-left: 2px;
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

/* ═══════════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
   ═══════════════════════════════════════════════════════════ */
.toast-pill {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translate(-50%, -100%);
  z-index: 99999;
  background: var(--surface);
  border: 1px solid var(--border-mid);
  border-radius: var(--r-full);
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  transition: transform 300ms cubic-bezier(0.34, 1.56, 0.64, 1), opacity 300ms ease;
  opacity: 0;
}

.toast-pill.toast-enter {
  transform: translate(-50%, 24px);
  opacity: 1;
}

.toast-pill.toast-exit {
  transform: translate(-50%, -100%);
  opacity: 0;
}

.toast-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.toast-success { border-left: 3px solid #10b981; }
.toast-success .toast-icon { color: #10b981; }

.toast-error { border-left: 3px solid #ef4444; }
.toast-error .toast-icon { color: #ef4444; }

.toast-warning { border-left: 3px solid #f59e0b; }
.toast-warning .toast-icon { color: #f59e0b; }

.toast-info { /* default */ }
.toast-info .toast-icon { color: var(--text-2); }

/* ═══════════════════════════════════════════════════════════
   SCROLL TO BOTTOM BUTTON
   ═══════════════════════════════════════════════════════════ */
.scroll-bottom-btn {
  position: absolute;
  bottom: 24px;
  right: 24px;
  width: 36px;
  height: 36px;
  border-radius: var(--r-full);
  background: var(--surface);
  border: 1px solid var(--border-mid);
  color: var(--text-2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  transition: opacity 200ms ease, transform 200ms ease;
}

.scroll-bottom-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.scroll-bottom-btn.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
}

.scroll-bottom-btn svg {
  width: 18px;
  height: 18px;
}

.unread-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #3b82f6; /* Blue for new messages */
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  border-radius: var(--r-full);
  padding: 2px 6px;
  border: 2px solid var(--bg);
}

.unread-badge.hidden {
  display: none;
}