/* InstantAI — Precision Speed design system */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #1B1B1A;
  --bg-sidebar: #171716;
  --bg-hover: rgba(255,255,255,0.05);
  --bg-active: rgba(255,255,255,0.08);
  --bg-bubble: #151514;
  --bg-input: #212120;
  --text: #F0F0F2;
  --text-dim: #9494A0;
  --text-muted: #787884;
  --border: rgba(255,255,255,0.08);
  --accent: #00D9FF;
  --accent-glow: rgba(0,217,255,0.35);
  --danger: #FF3B30;
  --success: #34C759;
  --warning: #FF9F0A;
  --msg-w: 720px;
  --sb-w: 260px;

  --radius-card: 24px;
  --radius-btn: 18px;
  --radius-pill: 999px;
  --radius-tile: 20px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;

  --shadow-subtle: 0 6px 12px rgba(0,0,0,0.25);
  --shadow-medium: 0 12px 24px rgba(0,0,0,0.35);
  --shadow-dramatic: 0 20px 48px rgba(0,0,0,0.5);
  --shadow-sm: 0 2px 6px rgba(0,0,0,0.3);
  --shadow-md: 0 6px 16px rgba(0,0,0,0.4);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.5);

  --transition-fast: 0.1s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-base: 0.15s cubic-bezier(0.16, 1, 0.3, 1);
  --ease-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);

  --font-display: 'Geist', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-hero: ui-rounded, 'SF Pro Rounded', -apple-system, system-ui, sans-serif;
  --font-body: 'Geist', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --spring: cubic-bezier(0.16, 1, 0.3, 1);
  --font-mono: 'Geist Mono', 'SF Mono', Monaco, Consolas, monospace;
}

html, body { height: 100%; overflow: hidden; }

body {
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.hidden { display: none !important; }

/* ═══ LAYOUT ═══ */
#app { display: flex; height: 100vh; height: 100dvh; }

/* ═══ SIDEBAR ═══ */
.sidebar {
  width: var(--sb-w);
  background: var(--bg-sidebar);
  background-image: radial-gradient(ellipse at 50% 0%, rgba(0, 217, 255, 0.04) 0%, transparent 60%);
  border-right: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
}

.sb-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.sb-brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.03em;
  color: var(--text);
}

.brand-ai {
  color: var(--accent);
}

.sb-new {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  color: var(--text-dim);
  padding: 6px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.1s var(--ease-expo), background 0.1s var(--ease-expo), color 0.1s var(--ease-expo), border-color 0.1s var(--ease-expo);
}
.sb-new:hover {
  background: rgba(255,255,255,0.08);
  color: var(--text);
}
.sb-new:active {
  background: rgba(255,255,255,0.10);
  transform: scale(0.97);
}

.sb-search { padding: 8px 12px; }

.sb-search input {
  width: 100%;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  color: var(--text);
  font-size: 13px;
  font-family: var(--font-body);
  outline: none;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}
.sb-search input:focus {
  border-color: rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.06);
}
.sb-search input::placeholder { color: var(--text-muted); }

.sb-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}

.chat-item {
  padding: 12px 14px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-radius: 12px;
  margin: 2px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background 0.08s var(--ease-expo), color 0.08s var(--ease-expo), transform 0.1s var(--ease-expo);
}
.chat-item:hover {
  background: rgba(255,255,255,0.05);
  color: var(--text);
}
.chat-item:active {
  transform: scale(0.98);
}
.chat-item.active {
  background: rgba(0, 217, 255, 0.06);
  color: var(--text);
}

.chat-item-title {
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.chat-item-menu {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  padding: 0 4px;
  opacity: 0;
  flex-shrink: 0;
  transition: opacity var(--transition-fast), color var(--transition-fast);
  border-radius: 4px;
}
.chat-item:hover .chat-item-menu { opacity: 0.7; }
.chat-item-menu:hover { opacity: 1 !important; color: var(--text); }

.rename-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  color: var(--text);
  font-size: 14px;
  font-family: var(--font-body);
  outline: none;
}

.sb-footer {
  padding: 10px 12px;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.sb-user-status {
  padding: 6px 12px;
  margin-bottom: 4px;
}
.sb-signin-link {
  background: none;
  border: 1px solid rgba(0,217,255,0.2);
  color: var(--accent);
  font-size: 13px;
  font-family: var(--font-body);
  font-weight: 500;
  cursor: pointer;
  padding: 8px 12px;
  width: 100%;
  text-align: center;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast), border-color var(--transition-fast), transform 0.1s var(--ease-expo);
}
.sb-signin-link:hover {
  background: rgba(0,217,255,0.06);
  border-color: rgba(0,217,255,0.35);
}
.sb-signin-link:active { transform: scale(0.97); }
.sb-user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-dim);
  padding: 4px 0;
}
.sb-user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(0,217,255,0.15), rgba(0,217,255,0.06));
  border: 1px solid rgba(0,217,255,0.12);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}
.sb-user-email {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sb-footer-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 14px;
  font-family: var(--font-body);
  cursor: pointer;
  padding: 10px 12px;
  width: 100%;
  text-align: left;
  border-radius: var(--radius-md);
  transition: background 0.1s var(--ease-expo), color 0.1s var(--ease-expo), transform 0.1s var(--ease-expo);
}
.sb-footer-btn:hover {
  color: var(--text);
  background: rgba(255,255,255,0.05);
}
.sb-footer-btn:active {
  transform: scale(0.97);
}

/* ═══ CHAT AREA ═══ */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
  position: relative;
  background:
    radial-gradient(ellipse at 20% 80%, rgba(0, 217, 255, 0.015) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(139, 92, 246, 0.01) 0%, transparent 50%),
    var(--bg);
}

.chat-area.drag-over::after {
  content: 'Drop files here';
  position: absolute;
  inset: 0;
  background: rgba(0, 217, 255, 0.03);
  border: 2px dashed rgba(0, 217, 255, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: 500;
  color: var(--accent);
  z-index: 50;
  pointer-events: none;
}

/* ═══ TOPBAR ═══ */
.topbar {
  display: flex;
  align-items: center;
  height: 56px;
  padding: 0 20px;
  flex-shrink: 0;
  position: relative;
  z-index: 10;
  background: rgba(27, 27, 26, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

/* Hamburger button (mobile) */
.menu-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  transition: background var(--transition-fast);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
}
.menu-btn:hover { background: var(--bg-hover); }

.hamburger-line {
  display: block;
  width: 18px;
  height: 1.5px;
  background: var(--text);
  margin: 3px 0;
  transition: transform 0.15s var(--ease-expo), opacity 0.15s var(--ease-expo);
  border-radius: 1px;
}

/* Mode pill */
.mode-pill {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text);
  padding: 7px 20px;
  border-radius: var(--radius-pill);
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  margin: 0 auto;
  transition: background 0.12s var(--ease-out), border-color 0.12s var(--ease-out), transform 0.1s var(--ease-expo);
}
.mode-pill::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  margin-right: 8px;
  flex-shrink: 0;
  box-shadow: 0 0 6px rgba(0, 217, 255, 0.4);
}
.mode-pill:hover {
  background: rgba(255, 255, 255, 0.09);
  border-color: rgba(255, 255, 255, 0.14);
}
.mode-pill:active {
  transform: scale(0.97);
}

.topbar-right { display: flex; gap: 6px; }

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: none;
  border: 1px solid transparent;
  color: var(--text-dim);
  font-size: 19px;
  cursor: pointer;
  padding: 0;
  border-radius: 10px;
  transition: background 0.1s var(--ease-expo), color 0.1s var(--ease-expo), border-color 0.1s var(--ease-expo), transform 0.1s var(--ease-expo);
}
.icon-btn:hover {
  background: rgba(255,255,255,0.06);
  color: var(--text);
  border-color: rgba(255,255,255,0.06);
}
.icon-btn:active {
  background: rgba(255,255,255,0.09);
  transform: scale(0.95);
}

/* ═══ MESSAGES ═══ */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 0 8px;
  /* Disable browser scroll anchoring so streaming messages follow properly */
  overflow-anchor: none;
}

/* Scrollbar */
.messages::-webkit-scrollbar { width: 4px; }
.messages::-webkit-scrollbar-track { background: transparent; }
.messages::-webkit-scrollbar-thumb {
  background: transparent;
  border-radius: 4px;
}
.messages:hover::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); }
.messages::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.15); }

.msg-row {
  max-width: var(--msg-w);
  margin: 0 auto;
  padding: 0 20px 16px;
  position: relative;
  animation: msgFadeIn 0.18s var(--ease-expo);
  /* content-visibility removed: caused scrollHeight to be inaccurate during streaming */
}

/* Streaming message should never be scroll-anchored */
.msg-row.assistant:has(.streaming-cursor) {
  overflow-anchor: none;
}

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

.msg-row.user {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.msg-bubble {
  display: inline-block;
  background: var(--bg-bubble);
  padding: 12px 16px;
  border-radius: var(--radius-tile);
  max-width: 75%;
  font-size: 15px;
  line-height: 1.55;
  word-wrap: break-word;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

/* Assistant message text */
.msg-row.assistant .msg-text {
  font-size: 16px;
  line-height: 1.7;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-wrap: break-word;
  word-break: break-word;
}
.msg-row.assistant .msg-text p {
  margin-bottom: 12px;
}
.msg-row.assistant .msg-text p:last-child { margin-bottom: 0; }
.msg-row.assistant .msg-text ul,
.msg-row.assistant .msg-text ol {
  margin: 10px 0 10px 22px;
}
.msg-row.assistant .msg-text li {
  margin-bottom: 6px;
  line-height: 1.6;
}
.msg-row.assistant .msg-text strong { color: #fff; }
.msg-row.assistant .msg-text em { color: var(--text-dim); font-style: italic; }
.msg-row.assistant .msg-text a {
  color: var(--accent);
  text-decoration: none;
  transition: opacity var(--transition-fast);
}
.msg-row.assistant .msg-text a:hover { text-decoration: underline; opacity: 0.85; }
.msg-row.assistant .msg-text blockquote {
  background: rgba(255,255,255,0.03);
  padding: 14px 18px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.06);
  color: var(--text-dim);
  margin: 12px 0;
}
.msg-row.assistant .msg-text table {
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 14px;
  width: 100%;
}
.msg-row.assistant .msg-text th,
.msg-row.assistant .msg-text td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
}
.msg-row.assistant .msg-text th {
  background: var(--bg-bubble);
  color: #fff;
  font-weight: 600;
}
.msg-row.assistant .msg-text h1,
.msg-row.assistant .msg-text h2,
.msg-row.assistant .msg-text h3,
.msg-row.assistant .msg-text h4 {
  color: #fff;
  margin: 18px 0 8px;
  line-height: 1.3;
  font-family: var(--font-display);
}
.msg-row.assistant .msg-text h1 { font-size: 20px; }
.msg-row.assistant .msg-text h2 { font-size: 18px; }
.msg-row.assistant .msg-text h3 { font-size: 16px; }
.msg-row.assistant .msg-text hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

/* Inline code */
.msg-row.assistant .msg-text code {
  background: rgba(255,255,255,0.07);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
  font-family: var(--font-mono);
}

/* ═══ CODE BLOCKS ═══ */
.code-block {
  background: rgba(8, 8, 16, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-md);
  margin: 14px 0;
  overflow: hidden;
}

.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.code-lang {
  font-size: 12px;
  color: var(--text-dim);
  text-transform: lowercase;
  font-weight: 500;
  font-family: var(--font-mono);
}

.code-copy-btn {
  background: none;
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--text-dim);
  font-size: 12px;
  font-family: var(--font-body);
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast), transform 0.1s var(--ease-expo);
}
.code-copy-btn:hover {
  background: rgba(255,255,255,0.06);
  color: var(--text);
  border-color: rgba(255,255,255,0.18);
}
.code-copy-btn:active {
  transform: scale(0.95);
}

.code-block pre {
  padding: 16px;
  overflow-x: auto;
  margin: 0;
  background: transparent;
  border: none;
}

.code-block pre code {
  background: none !important;
  padding: 0 !important;
  font-size: 13px;
  line-height: 1.6;
  font-family: var(--font-mono);
}

/* Code block scrollbar */
.code-block pre::-webkit-scrollbar { height: 4px; }
.code-block pre::-webkit-scrollbar-track { background: transparent; }
.code-block pre::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 2px; }

/* Math blocks */
.math-block {
  margin: 14px 0;
  overflow-x: auto;
  text-align: center;
}

/* Action buttons */
.msg-actions {
  display: flex;
  gap: 4px;
  margin-top: 6px;
  opacity: 0;
  transition: opacity var(--transition-base);
}
.msg-row:hover .msg-actions { opacity: 1; }

.user-actions {
  justify-content: flex-end;
}

.msg-action-btn {
  background: none;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-family: var(--font-body);
  cursor: pointer;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast), background var(--transition-fast), border-color var(--transition-fast), transform 0.1s var(--ease-expo);
}
.msg-action-btn:hover {
  color: var(--text-dim);
  background: var(--bg-hover);
  border-color: var(--border);
}
.msg-action-btn:active {
  transform: scale(0.95);
}

/* ═══ SOURCE PILLS ═══ */
.sources-row {
  margin-top: 12px;
}

.sources-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 8px;
  font-family: var(--font-display);
}

.sources-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.source-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 6px 14px;
  font-size: 12px;
  color: var(--text-dim);
  text-decoration: none;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), transform 0.1s var(--ease-expo);
}

.source-pill:hover {
  background: rgba(0, 217, 255, 0.06);
  border-color: rgba(0, 217, 255, 0.2);
  color: var(--text);
}
.source-pill:active { transform: scale(0.97); }

.source-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  border-radius: 4px;
  background: rgba(0, 217, 255, 0.1);
  font-size: 10px;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
}

/* Speed badge */
.speed-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 14px;
  color: var(--accent);
  margin-top: 10px;
  font-weight: 600;
  font-family: var(--font-display);
  letter-spacing: -0.01em;
  opacity: 0.7;
  font-variant-numeric: tabular-nums;
  padding: 4px 12px;
  background: rgba(0, 217, 255, 0.05);
  border: 1px solid rgba(0, 217, 255, 0.1);
  border-radius: var(--radius-pill);
}

/* Speed badge pulsing during streaming */
.speed-badge.streaming-active {
  animation: speedPulse 1.8s cubic-bezier(0.4, 0, 0.6, 1) infinite;
  opacity: 0.9;
}

/* Settled state after streaming ends */
.speed-badge.streaming-settled {
  opacity: 0.55;
  transition: opacity 0.6s cubic-bezier(0.23, 1, 0.32, 1);
}

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

/* Streaming cursor */
.streaming-cursor::after {
  content: '';
  display: inline-block;
  width: 2px;
  height: 18px;
  background: var(--accent);
  border-radius: 1px;
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: cursorPulse 0.6s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}
@keyframes cursorPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

/* Error state for assistant messages */
.msg-text.msg-error {
  background: rgba(255, 59, 48, 0.05);
  border: 1px solid rgba(255, 59, 48, 0.12);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  color: #f08080;
}

/* Inline retry button on error messages */
.msg-retry-btn {
  display: inline-block;
  background: none;
  border: 1px solid rgba(255, 68, 68, 0.2);
  color: #f08080;
  font-size: 13px;
  font-family: var(--font-body);
  padding: 5px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin-top: 10px;
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}
.msg-retry-btn:hover {
  background: rgba(255, 68, 68, 0.08);
  border-color: rgba(255, 68, 68, 0.35);
  color: #ff9999;
}

/* Edit message */
.edit-wrap {
  width: 100%;
  max-width: 100%;
}

.edit-textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--accent);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  resize: none;
  outline: none;
  font-family: var(--font-body);
  min-height: 60px;
  transition: border-color var(--transition-fast);
}

.edit-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  justify-content: flex-end;
}

.edit-save-btn, .edit-cancel-btn {
  padding: 8px 18px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font-body);
  cursor: pointer;
  border: none;
  transition: opacity var(--transition-fast), transform 0.1s var(--ease-expo);
}

.edit-save-btn {
  background: var(--accent);
  color: #000;
  font-weight: 600;
}
.edit-save-btn:hover { opacity: 0.9; }
.edit-save-btn:active { transform: scale(0.97); }

.edit-cancel-btn {
  background: var(--bg-hover);
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.edit-cancel-btn:hover { color: var(--text); background: var(--bg-active); }
.edit-cancel-btn:active { transform: scale(0.97); }

/* ═══ EMPTY STATE ═══ */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--text-dim);
  height: 100%;
  padding: 20px;
}

.empty-brand {
  font-family: var(--font-display);
  font-size: 40px;
  font-weight: 700;
  letter-spacing: -0.04em;
  color: var(--text);
  opacity: 0.07;
  user-select: none;
  margin-bottom: 4px;
}

.empty-sub {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  color: rgba(255,255,255,0.85);
  margin-top: 2px;
  letter-spacing: -0.02em;
}

.empty-speed-hint {
  font-size: 13px;
  color: rgba(0,217,255,0.65);
  margin-top: 6px;
  font-family: var(--font-display);
  font-weight: 500;
  letter-spacing: 0.02em;
}

.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  max-width: 540px;
  margin-top: 24px;
}

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

.suggestion-chip {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--text-dim);
  padding: 10px 20px;
  border-radius: var(--radius-pill);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.12s var(--ease-out), color 0.12s var(--ease-out), background 0.12s var(--ease-out), transform 0.1s var(--ease-expo);
  letter-spacing: -0.01em;
  opacity: 0;
  animation: chipFadeIn 0.25s var(--ease-expo) forwards;
}
.suggestion-chip:hover {
  border-color: rgba(0, 217, 255, 0.35);
  color: var(--text);
  background: rgba(0, 217, 255, 0.04);
}
.suggestion-chip:active {
  transform: scale(0.97);
}

/* ═══ FILE PREVIEW BAR ═══ */
.file-preview {
  max-width: var(--msg-w);
  margin: 0 auto;
  padding: 8px 24px 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.file-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-bubble);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 6px 14px;
  font-size: 13px;
  color: var(--text-dim);
  transition: border-color var(--transition-fast);
}

.file-chip-icon {
  display: flex;
  align-items: center;
  color: var(--text-muted);
}

.file-chip-name {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-chip-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  transition: color var(--transition-fast);
}
.file-chip-remove:hover { color: var(--danger); }

/* ═══ INPUT BAR ═══ */
.input-wrap {
  padding: 12px 20px 20px;
  flex-shrink: 0;
}

.input-bar {
  position: relative;
  max-width: var(--msg-w);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 52px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-card);
  padding: 8px 12px 8px 16px;
  transition: border-color 0.12s var(--ease-expo), box-shadow 0.12s var(--ease-expo), background 0.12s var(--ease-expo);
}

.input-bar:focus-within {
  border-color: rgba(0, 217, 255, 0.3);
  box-shadow: 0 0 0 3px rgba(0, 217, 255, 0.06), 0 2px 8px rgba(0, 0, 0, 0.2);
  background: rgba(255, 255, 255, 0.05);
}

.input-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 5px;
  opacity: 0.5;
  transition: opacity var(--transition-fast), transform var(--transition-fast), color var(--transition-fast);
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}
.input-btn:hover { opacity: 0.8; color: var(--text-dim); }
.input-btn:active { transform: scale(0.92); }
.input-btn.active { opacity: 1; color: var(--accent); }

#msgInput {
  flex: 1;
  background: none;
  border: none;
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  resize: none;
  outline: none;
  max-height: 180px;
  font-family: var(--font-body);
  /* No transition on height -- must resize instantly on each keystroke */
}
#msgInput::placeholder { color: var(--text-muted); }

.send-btn {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  border: none;
  background: var(--text-muted);
  color: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.1s var(--ease-expo), opacity 0.12s var(--ease-expo), background 0.12s var(--ease-expo);
}
.send-btn:not(:disabled) {
  background: var(--accent);
}
.send-btn:not(:disabled):hover {
  opacity: 0.9;
  transform: scale(1.04);
}
.send-btn:not(:disabled):active { transform: scale(0.92); }
.send-btn:disabled { cursor: default; opacity: 0.25; }

/* ═══ CONTEXT MENU ═══ */
.ctx-menu {
  position: fixed;
  background: rgba(26, 26, 30, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 4px;
  z-index: 300;
  min-width: 130px;
  box-shadow: var(--shadow-dramatic);
  animation: ctxFadeIn 0.1s var(--ease-expo);
}
@keyframes ctxFadeIn { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: scale(1); } }

.ctx-item {
  display: block;
  width: 100%;
  background: none;
  border: none;
  color: var(--text);
  font-size: 14px;
  font-family: var(--font-body);
  padding: 8px 14px;
  text-align: left;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}
.ctx-item:hover { background: var(--bg-hover); }
.ctx-item.danger { color: var(--danger); }

/* ═══ MODAL OVERLAY ═══ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
  animation: overlayFadeIn 0.12s var(--ease-expo);
}
@keyframes overlayFadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ═══ AUTH CARD ═══ */
.auth-card {
  background: #111114;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-card);
  padding: 36px 32px;
  width: 100%;
  max-width: 380px;
  text-align: center;
  box-shadow: var(--shadow-dramatic);
  animation: cardSlideUp 0.18s var(--ease-expo);
}
@keyframes cardSlideUp { from { opacity: 0; transform: translateY(12px) scale(0.97); } to { opacity: 1; transform: translateY(0) scale(1); } }

.auth-brand-mark {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 6px;
  color: var(--text);
}
.auth-brand-mark .brand-ai {
  color: var(--accent);
}

.auth-subtitle { color: var(--text-dim); font-size: 14px; margin-bottom: 28px; line-height: 1.5; }

.auth-error {
  background: rgba(255,68,68,0.08);
  border: 1px solid rgba(255,68,68,0.2);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  margin-bottom: 14px;
}

.auth-input {
  display: block;
  width: 100%;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-md);
  padding: 13px 16px;
  color: var(--text);
  font-size: 15px;
  font-family: var(--font-body);
  margin-bottom: 12px;
  outline: none;
  transition: border-color 0.12s var(--ease-expo), box-shadow 0.12s var(--ease-expo);
}
.auth-input:focus {
  border-color: rgba(0, 217, 255, 0.3);
  box-shadow: 0 0 0 3px rgba(0, 217, 255, 0.06);
}
.auth-input::placeholder { color: var(--text-muted); }

.auth-btn {
  display: block;
  width: 100%;
  padding: 14px;
  border-radius: var(--radius-btn);
  font-size: 16px;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  border: none;
  margin-bottom: 10px;
  transition: opacity var(--transition-fast), transform var(--transition-fast);
}
.auth-btn:active { transform: scale(0.98); }
.auth-btn.primary {
  background: var(--accent);
  color: #000;
  font-weight: 700;
}
.auth-btn.primary:hover { opacity: 0.9; }
.auth-btn.primary:disabled { opacity: 0.5; cursor: default; }
.auth-btn.oauth {
  background: var(--bg-bubble);
  color: var(--text);
  border: 1px solid var(--border);
}
.auth-btn.oauth:hover {
  background: var(--bg-hover);
  border-color: rgba(255,255,255,0.15);
}
.auth-btn.skip { background: none; color: var(--text-muted); font-size: 14px; }
.auth-btn.skip:hover { color: var(--text); }
.auth-btn.danger { background: var(--danger); color: #fff; }
.auth-btn.danger:hover { opacity: 0.9; }
.auth-btn.danger-outline { background: none; border: 1px solid var(--danger); color: var(--danger); }
.auth-btn.danger-outline:hover { background: rgba(255,68,68,0.06); }

.auth-toggle-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  font-family: var(--font-body);
  cursor: pointer;
  margin: 6px 0 10px;
  display: block;
  width: 100%;
  transition: color var(--transition-fast);
}
.auth-toggle-btn:hover { color: var(--text-dim); }
.auth-toggle-btn span { color: var(--accent); font-weight: 500; }

.auth-divider {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 18px 0;
  color: var(--text-muted);
  font-size: 13px;
}
.auth-divider::before, .auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ═══ SETTINGS PANEL ═══ */
.settings-panel {
  background: rgba(22, 22, 26, 0.95);
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-card);
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-dramatic);
  animation: cardSlideUp 0.15s var(--ease-expo);
}

/* Settings panel scrollbar */
.settings-panel::-webkit-scrollbar { width: 5px; }
.settings-panel::-webkit-scrollbar-track { background: transparent; }
.settings-panel::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 3px; }

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

.settings-header h3 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.close-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 18px;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast), color var(--transition-fast), transform 0.1s var(--ease-expo);
}
.close-btn:hover { color: var(--text); background: var(--bg-hover); }
.close-btn:active { transform: scale(0.92); }

.settings-body { padding: 24px; }

.settings-section {
  margin-bottom: 28px;
}
.settings-section:last-child { margin-bottom: 0; }
.settings-section h4 {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 12px;
}

.settings-field label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.settings-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  color: var(--text);
  font-size: 14px;
  font-family: var(--font-body);
  outline: none;
  transition: border-color var(--transition-fast);
}
.settings-input:focus { border-color: rgba(255,255,255,0.18); }
.settings-input[readonly] { opacity: 0.6; }

.settings-textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  color: var(--text);
  font-size: 14px;
  font-family: var(--font-body);
  resize: vertical;
  min-height: 80px;
  outline: none;
  transition: border-color var(--transition-fast);
}
.settings-textarea:focus { border-color: var(--accent); }

.settings-save-btn {
  background: var(--accent);
  color: #000;
  border: none;
  padding: 8px 20px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  margin-top: 10px;
  transition: opacity var(--transition-fast);
}
.settings-save-btn:hover {
  opacity: 0.9;
}
.settings-save-btn:active { transform: scale(0.97); }

.settings-dim { color: var(--text-muted); font-size: 14px; }

.settings-actions { display: flex; flex-direction: column; gap: 10px; }

.mode-radios { display: flex; gap: 8px; }

.mode-radio {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 14px;
  color: var(--text-dim);
  transition: border-color var(--transition-fast), background var(--transition-fast), color var(--transition-fast);
}
.mode-radio input { display: none; }
.mode-radio.active {
  border-color: var(--accent);
  color: var(--text);
  background: rgba(0, 217, 255, 0.06);
}
.mode-radio:hover:not(.active) {
  border-color: rgba(255,255,255,0.15);
  background: var(--bg-hover);
}

/* ═══ PAYWALL (full-screen overlay) ═══ */
.paywall-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  animation: overlayFadeIn 0.12s var(--ease-expo);
}

.paywall-content {
  position: relative;
  z-index: 1;
  max-width: 480px;
  width: 100%;
  margin: 0 auto;
  padding: 48px 24px 40px;
}

.pw-close-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.5);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-fast), color var(--transition-fast);
  z-index: 5;
}
.pw-close-btn:hover { background: rgba(255,255,255,0.1); color: #fff; }
.pw-close-btn:active { transform: scale(0.92); }

.pw-trial-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  margin-top: 20px;
  border: 1px solid rgba(0,217,255,0.3);
  background: rgba(0,217,255,0.04);
}
.pw-trial-icon {
  font-size: 22px;
  color: var(--accent);
  flex-shrink: 0;
}
.pw-trial-text {
  font-family: var(--font-hero);
  font-size: 20px;
  font-weight: 800;
  color: #fff;
}

.pw-features {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-left: 4px;
}
.pw-feature-row {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 15px;
  color: rgba(255,255,255,0.85);
}
.pw-feature-check {
  color: var(--accent);
  font-size: 16px;
  flex-shrink: 0;
}

.pw-plans {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 22px;
}

.pw-plan {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border-radius: 14px;
  cursor: pointer;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.02);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: border-color 0.12s var(--ease-expo), background 0.12s var(--ease-expo), transform 0.1s var(--ease-expo);
}
.pw-plan:hover { border-color: rgba(255,255,255,0.15); }
.pw-plan:active { transform: scale(0.98); }
.pw-plan.selected {
  border-color: var(--accent);
  border-width: 2px;
  background: rgba(0,217,255,0.04);
}

.pw-radio {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: border-color 0.12s var(--ease-expo);
}
.pw-plan.selected .pw-radio {
  border-color: var(--accent);
  border-width: 2px;
}
.pw-radio-inner {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0;
  transform: scale(0.5);
  transition: opacity 0.12s var(--ease-expo), transform 0.15s var(--spring);
}
.pw-plan.selected .pw-radio-inner {
  opacity: 1;
  transform: scale(1);
}

.pw-plan-info { flex: 1; }
.pw-plan-name {
  font-family: var(--font-hero);
  font-size: 16px;
  font-weight: 700;
  color: #fff;
}
.pw-plan-sub {
  font-size: 13px;
  color: rgba(255,255,255,0.45);
  margin-top: 2px;
}

.pw-plan-right { text-align: right; }
.pw-plan-price {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
}
.pw-plan-badge {
  display: inline-block;
  margin-top: 4px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: #000;
  padding: 3px 8px;
  border-radius: 999px;
  background: linear-gradient(135deg, #5CE7FF, #00D9FF);
}

.pw-disclosure {
  font-size: 11px;
  color: rgba(255,255,255,0.55);
  text-align: center;
  margin-top: 10px;
}

.pw-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin-top: 18px;
}
.pw-footer-link {
  background: none;
  border: none;
  color: rgba(255,255,255,0.35);
  font-size: 11px;
  cursor: pointer;
  font-family: var(--font-body);
  transition: color var(--transition-fast);
}
.pw-footer-link:hover { color: rgba(255,255,255,0.6); }
.pw-footer-dot {
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
}

/* ═══ AUTH MODAL ATMOSPHERE ═══ */
.auth-atmosphere-overlay {
  background: rgba(7, 7, 10, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(12px);
}

/* ═══ MODE PICKER ═══ */
.mode-picker {
  background: rgba(22, 22, 26, 0.95);
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-card);
  padding: 24px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-dramatic);
  animation: cardSlideUp 0.15s var(--ease-expo);
}

.mode-picker h3 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 18px;
  text-align: center;
  letter-spacing: -0.02em;
}

.mode-card {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-bubble);
  border: 1px solid var(--border);
  border-radius: 16px;
  cursor: pointer;
  margin-bottom: 8px;
  text-align: left;
  color: var(--text);
  font-family: var(--font-body);
  transition: border-color var(--transition-fast), background var(--transition-fast), transform 0.1s var(--ease-expo);
}
.mode-card:last-child { margin-bottom: 0; }
.mode-card:hover {
  border-color: rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.04);
}
.mode-card:active {
  transform: scale(0.98);
}
.mode-card.active {
  border-color: var(--accent);
  background: rgba(0, 217, 255, 0.06);
}

.mode-card-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  opacity: 0.6;
}
.mode-card.active .mode-card-dot {
  opacity: 1;
}

.mode-card-info { flex: 1; }
.mode-card-info strong { display: block; font-size: 15px; font-weight: 600; }
.mode-card-info p { font-size: 13px; color: var(--text-dim); margin: 2px 0 0; line-height: 1.4; }

.mode-check { color: var(--accent); font-size: 18px; flex-shrink: 0; }

/* Thinking toggle inside mode picker */
.mode-divider {
  height: 1px;
  background: var(--border);
  margin: 12px 0;
}

.mode-think-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 16px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 16px;
  cursor: pointer;
  color: var(--text);
  font-family: var(--font-body);
  transition: border-color var(--transition-fast), background var(--transition-fast);
}
.mode-think-toggle:hover {
  border-color: rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.03);
}
.mode-think-toggle.active {
  border-color: var(--accent);
  background: rgba(0, 217, 255, 0.04);
}

.mode-think-icon {
  flex-shrink: 0;
  opacity: 0.5;
}
.mode-think-toggle.active .mode-think-icon {
  opacity: 1;
  color: var(--accent);
}

.mode-think-info { flex: 1; text-align: left; }
.mode-think-info strong { display: block; font-size: 14px; font-weight: 600; }
.mode-think-info p { font-size: 12px; color: var(--text-dim); margin: 2px 0 0; line-height: 1.4; }

.mode-think-switch {
  width: 40px;
  height: 22px;
  border-radius: 11px;
  background: rgba(255,255,255,0.1);
  flex-shrink: 0;
  position: relative;
  transition: background 0.15s var(--ease-expo);
}
.mode-think-switch.on {
  background: var(--accent);
}
.mode-think-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s var(--ease-expo);
}
.mode-think-switch.on .mode-think-knob {
  transform: translateX(18px);
}

/* Thinking badge on mode pill */
.pill-think-badge {
  font-size: 10px;
  font-weight: 700;
  background: rgba(0, 217, 255, 0.15);
  color: var(--accent);
  padding: 1px 6px;
  border-radius: 6px;
  margin-left: 4px;
  letter-spacing: 0.02em;
  vertical-align: middle;
}
.mode-pill.thinking-on {
  border-color: rgba(0, 217, 255, 0.3);
}

/* ═══ PRE-TOKEN CHARGING ANIMATION ═══ */
.pre-token-dots {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  height: 24px;
  transition: opacity 200ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* Bolt icon */
.pre-token-bolt {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  animation: boltPulse 800ms cubic-bezier(0.16, 1, 0.3, 1) infinite;
}

.pre-token-bolt svg {
  width: 16px;
  height: 16px;
  filter: drop-shadow(0 0 6px var(--accent-glow));
}

@keyframes boltPulse {
  0% { opacity: 0.5; transform: scale(0.95); }
  50% { opacity: 1; transform: scale(1.05); }
  100% { opacity: 0.5; transform: scale(0.95); }
}

/* Energy bar */
.pre-token-bar {
  position: relative;
  flex: 1;
  max-width: 160px;
  height: 3px;
  border-radius: 2px;
  background: rgba(0, 217, 255, 0.1);
  overflow: hidden;
}

.pre-token-bar::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 2px;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(0, 217, 255, 0.15) 20%,
    transparent 40%
  );
  animation: barFill 1.2s cubic-bezier(0.16, 1, 0.3, 1) infinite;
}

.pre-token-bar::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 40%;
  height: 100%;
  border-radius: 2px;
  background: linear-gradient(90deg,
    transparent,
    var(--accent) 50%,
    transparent
  );
  opacity: 0.9;
  animation: barSweep 800ms cubic-bezier(0.16, 1, 0.3, 1) infinite;
}

@keyframes barFill {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(200%); }
}

@keyframes barSweep {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(350%); }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .pre-token-bolt {
    animation: none;
    opacity: 0.7;
  }
  .pre-token-bar::before,
  .pre-token-bar::after {
    animation: none;
  }
  .pre-token-bar::after {
    opacity: 0.4;
    transform: translateX(0);
    width: 100%;
    background: var(--accent);
  }
}

/* Content emergence — fade in when first token replaces the bolt animation */
.msg-text.content-emerge {
  opacity: 0;
  transform: translateY(2px);
}
.msg-text.content-emerged {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 200ms cubic-bezier(0.16, 1, 0.3, 1),
              transform 200ms cubic-bezier(0.16, 1, 0.3, 1);
}

@media (prefers-reduced-motion: reduce) {
  .msg-text.content-emerge {
    opacity: 1;
    transform: none;
  }
  .msg-text.content-emerged {
    transition-duration: 0.01ms;
  }
}

/* ═══ SCROLL TO BOTTOM ═══ */
.scroll-bottom-btn {
  position: absolute;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: var(--bg-bubble);
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s var(--ease-expo), transform 0.15s var(--ease-expo);
  z-index: 5;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}
.scroll-bottom-btn.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}
.scroll-bottom-btn:hover {
  background: var(--bg-active);
  border-color: rgba(255, 255, 255, 0.15);
}
.scroll-bottom-btn:active {
  transform: translateX(-50%) scale(0.92);
}

/* ═══ COMPRESSION PILL ═══ */
.compression-pill {
  max-width: var(--msg-w);
  margin: 0 auto 8px;
  padding: 0 24px;
}

.compression-pill span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 217, 255, 0.05);
  border: 1px solid rgba(0, 217, 255, 0.12);
  border-radius: var(--radius-pill);
  padding: 8px 18px;
  font-size: 13px;
  color: var(--accent);
  cursor: pointer;
  transition: transform 0.1s var(--ease-expo), background 0.1s var(--ease-expo), color 0.1s var(--ease-expo), border-color 0.1s var(--ease-expo), opacity 0.1s var(--ease-expo);
}

.compression-pill span:hover {
  background: rgba(0, 217, 255, 0.08);
  border-color: rgba(0, 217, 255, 0.2);
}

.compression-pill span:active {
  transform: scale(0.97);
}

.compression-tuning {
  animation: tuningPulse 0.6s ease-in-out infinite !important;
}

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

/* ═══ LOAD MORE BUTTON ═══ */
.load-more-btn {
  display: block;
  max-width: var(--msg-w);
  margin: 0 auto 20px;
  padding: 10px 22px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-pill);
  color: var(--text-dim);
  font-size: 13px;
  font-family: var(--font-body);
  cursor: pointer;
  transition: transform 0.1s var(--ease-expo), background 0.1s var(--ease-expo), color 0.1s var(--ease-expo), border-color 0.1s var(--ease-expo), opacity 0.1s var(--ease-expo);
}

.load-more-btn:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.12);
  color: var(--text);
}

.load-more-btn:active {
  transform: scale(0.98);
}

/* ═══ TOAST ═══ */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(26, 26, 30, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text);
  padding: 10px 24px;
  border-radius: var(--radius-pill);
  font-size: 14px;
  z-index: 300;
  box-shadow: var(--shadow-medium);
  animation: toastIn 0.15s var(--ease-expo);
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(8px) scale(0.97); }
  to { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}
/* ═══ THINKING BADGE ═══ */
.thinking-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 0;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.02em;
}
.thinking-icon {
  width: 12px;
  height: 12px;
  opacity: 0.6;
  flex-shrink: 0;
}
.thinking-badge-clickable {
  cursor: pointer;
  transition: color 0.12s var(--ease-expo);
}
.thinking-badge-clickable:hover {
  color: var(--text-dim);
}
.thinking-badge-clickable:hover .thinking-chevron {
  opacity: 1;
  transform: translateX(2px);
}
.thinking-chevron {
  opacity: 0.4;
  transition: opacity 0.12s var(--ease-expo), transform 0.12s var(--ease-expo);
}
.thinking-badge-loading span {
  animation: thinkLoadPulse 1s ease-in-out infinite;
}
@keyframes thinkLoadPulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* Summarized thinking display */
.thinking-summary {
  margin-bottom: 10px;
  padding: 10px 14px;
  border-left: 2px solid rgba(255, 255, 255, 0.08);
  animation: thinkSummaryIn 0.2s var(--ease-expo);
}
@keyframes thinkSummaryIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.thinking-summary-header {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.thinking-summary-content {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-dim);
}
.thinking-summary-content ul {
  padding-left: 16px;
  margin: 0;
}
.thinking-summary-content li {
  margin-bottom: 3px;
}

.toast-with-action {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px 10px 20px;
}
.toast-action-btn {
  background: linear-gradient(135deg, #5CE7FF, #00D9FF);
  color: #07070A;
  border: none;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.1s var(--ease-expo);
}
.toast-action-btn:hover { transform: scale(1.04); }
.toast-action-btn:active { transform: scale(0.97); }

/* ═══ MOBILE ═══ */
@media (max-width: 767px) {
  .sidebar {
    position: fixed;
    left: -100%;
    top: 0;
    bottom: 0;
    width: 280px;
    z-index: 100;
    transition: left 0.18s var(--ease-expo);
    will-change: left;
  }
  .sidebar.open { left: 0; }

  .sb-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s var(--ease-expo);
  }
  .sb-backdrop.show { opacity: 1; pointer-events: auto; }

  .menu-btn { display: flex; }

  .msg-row { padding: 0 16px 16px; }
  .input-wrap { padding: 8px 16px 16px; }
  .file-preview { padding: 8px 16px 0; }
  .compression-pill { padding: 0 16px; }
  #msgInput { font-size: 16px; }

  .modal-overlay { padding: 16px; }
  .auth-card { max-width: 100%; padding: 28px 20px; }
  .paywall-content { padding: 36px 18px 32px; }

  .empty-brand { font-size: 32px; }
  .empty-sub { font-size: 19px; }
  .empty-speed-hint { font-size: 12px; }
  .suggestions { gap: 8px; margin-top: 20px; }
}

/* ═══ SCROLLBAR (sb-list) ═══ */
.sb-list::-webkit-scrollbar { width: 3px; }
.sb-list::-webkit-scrollbar-track { background: transparent; }
.sb-list::-webkit-scrollbar-thumb { background: transparent; border-radius: 2px; }
.sb-list:hover::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); }

/* Message image preview */
.msg-image {
  max-width: 200px;
  max-height: 200px;
  border-radius: 16px;
  margin-bottom: 6px;
  display: block;
}

/* Document badge in message */
.doc-badge {
  display: inline-block;
  background: rgba(255,255,255,0.06);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

/* ═══ FOCUS VISIBLE (accessibility) ═══ */
:focus-visible {
  outline: 2px solid rgba(0, 217, 255, 0.5);
  outline-offset: 2px;
  transition: outline-offset 0.1s var(--ease-expo);
}

input:focus-visible,
textarea:focus-visible,
.auth-input:focus-visible,
.settings-input:focus-visible,
.settings-textarea:focus-visible {
  outline: none;
}

/* ═══ SELECTION ═══ */
::selection {
  background: rgba(0, 217, 255, 0.2);
  color: #fff;
}

/* ═══ ARTIFACT VIEWER ═══ */
.artifact-panel {
  position: fixed;
  top: 0;
  right: -50%;
  width: 50%;
  height: 100%;
  background: rgba(7, 7, 10, 0.98);
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  border-left: 1px solid rgba(255,255,255,0.08);
  z-index: 150;
  display: flex;
  flex-direction: column;
  transition: right 0.2s var(--ease-expo);
  box-shadow: -8px 0 32px rgba(0,0,0,0.5);
  will-change: right;
}

.artifact-panel.open {
  right: 0;
}

.artifact-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 140;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s var(--ease-expo);
}

.artifact-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

.artifact-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}

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

.artifact-icon {
  display: flex;
  align-items: center;
  color: var(--text-dim);
  flex-shrink: 0;
}

.artifact-header h3 {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
}

.artifact-close-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 22px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.artifact-close-btn:hover {
  color: var(--text);
  background: var(--bg-hover);
}

.artifact-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
}

/* Artifact body typography */
.artifact-body p { margin-bottom: 12px; }
.artifact-body p:last-child { margin-bottom: 0; }
.artifact-body h1, .artifact-body h2, .artifact-body h3, .artifact-body h4 {
  color: #fff;
  margin: 20px 0 10px;
  line-height: 1.3;
  font-family: var(--font-display);
}
.artifact-body h1 { font-size: 22px; }
.artifact-body h2 { font-size: 19px; }
.artifact-body h3 { font-size: 17px; }
.artifact-body h4 { font-size: 15px; font-weight: 600; }
.artifact-body ul, .artifact-body ol {
  margin: 10px 0 10px 22px;
}
.artifact-body li {
  margin-bottom: 6px;
  line-height: 1.6;
}
.artifact-body strong { color: #fff; }
.artifact-body em { color: var(--text-dim); font-style: italic; }
.artifact-body a {
  color: var(--accent);
  text-decoration: none;
}
.artifact-body a:hover { text-decoration: underline; opacity: 0.85; }
.artifact-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 14px;
}
.artifact-body th {
  text-align: left;
  padding: 10px 12px;
  background: rgba(255,255,255,0.04);
  border-bottom: 1px solid rgba(255,255,255,0.1);
  color: var(--text);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.artifact-body td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  color: var(--text-dim);
  vertical-align: top;
}
.artifact-body tr:hover td {
  background: rgba(255,255,255,0.02);
}
.artifact-body blockquote {
  background: rgba(255,255,255,0.03);
  padding: 14px 18px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.06);
  color: var(--text-dim);
  margin: 12px 0;
}
.artifact-body code {
  background: rgba(255,255,255,0.07);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
  font-family: var(--font-mono);
}
.artifact-body table {
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 14px;
  width: 100%;
}
.artifact-body th, .artifact-body td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
}
.artifact-body th {
  background: var(--bg-bubble);
  color: #fff;
  font-weight: 600;
}
.artifact-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

/* Artifact body scrollbar */
.artifact-body::-webkit-scrollbar { width: 5px; }
.artifact-body::-webkit-scrollbar-track { background: transparent; }
.artifact-body::-webkit-scrollbar-thumb { background: transparent; border-radius: 3px; }
.artifact-body:hover::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); }

.artifact-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}

.artifact-tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.04);
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-body);
  cursor: pointer;
  transition: transform 0.1s var(--ease-expo), background 0.1s var(--ease-expo), color 0.1s var(--ease-expo), border-color 0.1s var(--ease-expo), opacity 0.1s var(--ease-expo);
  white-space: nowrap;
}
.artifact-tool-btn:hover {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.18);
  color: var(--text);
}
.artifact-tool-btn:active {
  transform: scale(0.97);
}

/* ═══ ARTIFACT INDICATOR CARD ═══ */
.artifact-indicator {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  margin-top: 8px;
  cursor: pointer;
  transition: transform 0.1s var(--ease-expo), background 0.1s var(--ease-expo), color 0.1s var(--ease-expo), border-color 0.1s var(--ease-expo), opacity 0.1s var(--ease-expo);
}

.artifact-indicator:hover {
  border-color: rgba(0, 217, 255, 0.3);
  background: rgba(0, 217, 255, 0.04);
}

.artifact-indicator svg {
  width: 20px;
  height: 20px;
  color: var(--accent);
  flex-shrink: 0;
}

.artifact-indicator-info {
  flex: 1;
  min-width: 0;
}

.artifact-indicator-info strong {
  display: block;
  font-size: 14px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.artifact-indicator-info span {
  font-size: 12px;
  color: var(--text-muted);
}

.artifact-open-btn {
  margin-left: auto;
  font-size: 13px;
  color: var(--accent);
  font-weight: 500;
  flex-shrink: 0;
}

/* "Building document..." indicator during streaming */
.artifact-creating {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 13px;
  font-style: italic;
  padding: 8px 0;
}

.artifact-bolt {
  animation: boltPulseArtifact 800ms cubic-bezier(0.16, 1, 0.3, 1) infinite alternate;
  filter: drop-shadow(0 0 4px rgba(0, 217, 255, 0.5));
  flex-shrink: 0;
}
@keyframes boltPulseArtifact {
  0% { opacity: 0.5; transform: scale(0.95); }
  100% { opacity: 1; transform: scale(1.05); }
}

.artifact-creating-bar {
  width: 80px;
  height: 3px;
  border-radius: 3px;
  background: rgba(0, 217, 255, 0.1);
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}
.artifact-creating-bar::after {
  content: '';
  position: absolute;
  top: 0;
  left: -40%;
  width: 40%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(0, 217, 255, 0.6), transparent);
  border-radius: 3px;
  animation: artifactBarSweep 1s cubic-bezier(0.16, 1, 0.3, 1) infinite;
}
@keyframes artifactBarSweep {
  0% { left: -40%; }
  100% { left: 100%; }
}

/* Mode upsell nudge (after artifact in Instant mode) */
.mode-upsell {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  margin-top: 8px;
  border-radius: 10px;
  background: rgba(0, 217, 255, 0.06);
  border: 1px solid rgba(0, 217, 255, 0.12);
  font-size: 13px;
  color: var(--text-secondary);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.2s var(--spring), transform 0.2s var(--spring);
}
.mode-upsell.visible {
  opacity: 1;
  transform: translateY(0);
}
.mode-upsell-text {
  flex: 1;
}
.mode-upsell-btn {
  padding: 5px 12px;
  border-radius: 6px;
  border: 1px solid rgba(0, 217, 255, 0.25);
  background: rgba(0, 217, 255, 0.1);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.mode-upsell-btn:hover { background: rgba(0, 217, 255, 0.18); }
.mode-upsell-btn:active { transform: scale(0.96); }
.mode-upsell-genius {
  background: rgba(168, 85, 247, 0.1);
  border-color: rgba(168, 85, 247, 0.25);
  color: #a855f7;
}
.mode-upsell-genius:hover { background: rgba(168, 85, 247, 0.18); }
.mode-upsell-dismiss {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  padding: 2px 4px;
  line-height: 1;
  opacity: 0.6;
  transition: opacity 0.15s;
}
.mode-upsell-dismiss:hover { opacity: 1; }
@media (max-width: 480px) {
  .mode-upsell { flex-wrap: wrap; }
  .mode-upsell-text { width: 100%; }
}

/* Legacy artifact trigger button (below assistant messages) */
.artifact-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-md);
  padding: 8px 16px;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-body);
  cursor: pointer;
  margin-top: 8px;
  transition: transform 0.1s var(--ease-expo), background 0.1s var(--ease-expo), color 0.1s var(--ease-expo), border-color 0.1s var(--ease-expo), opacity 0.1s var(--ease-expo);
}
.artifact-btn:hover {
  background: rgba(0, 217, 255, 0.06);
  border-color: rgba(0, 217, 255, 0.2);
  color: var(--accent);
}
.artifact-btn:active {
  transform: scale(0.97);
}

/* Mobile artifact panel */
@media (max-width: 767px) {
  .artifact-panel {
    width: 100%;
    right: -100%;
  }
  .artifact-body {
    padding: 20px 18px;
  }
  .artifact-toolbar {
    flex-wrap: wrap;
    padding: 12px 16px;
  }
  .artifact-tool-btn {
    flex: 1;
    justify-content: center;
    min-width: 0;
  }
}

/* ═══ THINKING BLOCK ═══ */
.thinking-block {
  margin-bottom: 10px;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.thinking-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 0;
  background: none;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition: color 0.1s var(--ease-expo);
}

.thinking-toggle:hover {
  color: var(--text-dim);
}

.thinking-toggle::-webkit-details-marker { display: none; }

.thinking-arrow {
  font-size: 9px;
  transition: transform 0.15s var(--ease-expo);
  color: var(--text-muted);
}

details[open] .thinking-arrow {
  transform: rotate(90deg);
}

.thinking-content {
  padding: 10px 14px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.6;
  font-style: italic;
  white-space: pre-wrap;
  border-left: 2px solid rgba(255, 255, 255, 0.06);
  margin-left: 2px;
  max-height: 300px;
  overflow-y: auto;
}

/* Thinking indicator during streaming */
.thinking-indicator {
  color: var(--accent);
  font-style: italic;
  font-size: 13px;
  padding: 8px 0;
  opacity: 0.7;
  animation: thinkPulse 1.5s ease-in-out infinite;
}

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

/* ═══ REUSABLE: GLASS CARD ═══ */
.glass-card {
  background: rgba(255,255,255,0.03);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 20px;
}

/* ═══ REUSABLE: EYEBROW ═══ */
.eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
}
.eyebrow-bar {
  width: 22px;
  height: 2px;
  background: var(--accent);
  flex-shrink: 0;
}
.eyebrow-text {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 2.4px;
  color: var(--accent);
  font-family: var(--font-hero);
}

/* ═══ REUSABLE: GRADIENT CTA ═══ */
.gradient-cta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0 22px;
  height: 58px;
  border: none;
  border-radius: var(--radius-btn);
  cursor: pointer;
  font-family: var(--font-hero);
  font-size: 18px;
  font-weight: 600;
  color: #000;
  background: linear-gradient(135deg, #5CE7FF, #00D9FF);
  position: relative;
  overflow: hidden;
  transition: opacity 0.1s var(--ease-expo), transform 0.1s var(--ease-expo);
  box-shadow: 0 14px 28px rgba(0,217,255,0.35);
  letter-spacing: -0.01em;
}
.gradient-cta::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(255,255,255,0.28), transparent 60%);
  pointer-events: none;
  border-radius: inherit;
}
.gradient-cta:hover { opacity: 0.92; transform: translateY(-1px); }
.gradient-cta:active { transform: translateY(0) scale(0.98); }
.gradient-cta:disabled { opacity: 0.4; cursor: default; transform: none; }

.gradient-cta .cta-arrow {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(0,0,0,0.12);
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ═══ REUSABLE: ATMOSPHERE BACKGROUND ═══ */
.atmosphere-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 30% 60%, rgba(0, 217, 255, 0.07) 0%, transparent 55%),
    radial-gradient(ellipse at 75% 25%, rgba(139, 92, 246, 0.05) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 50%, rgba(0, 217, 255, 0.03) 0%, transparent 70%),
    var(--bg);
  pointer-events: none;
}

/* ═══════════════════════════════════════════════
   ONBOARDING: MAC-WINDOW 3-STEP FLOW
   One centered window, content transitions inside
   ═══════════════════════════════════════════════ */

/* ── Page background ── */
.ob-bg {
  position: fixed;
  inset: 0;
  z-index: 999;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 45%, rgba(0,217,255,0.025) 0%, transparent 55%),
    var(--bg);
}

/* ── Overlay container ── */
.ob-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  overflow: hidden;
  transition: opacity 0.4s ease, transform 0.4s ease;
}
.ob-overlay.ob-dismissing {
  opacity: 0;
  transform: scale(1.02);
  pointer-events: none;
}

/* ── Centering wrapper ── */
.ob-center-wrap {
  position: absolute;
  inset: 0;
  z-index: 1001;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
}

/* ═══ THE WINDOW ═══ */

.ob-window {
  width: 100%;
  max-width: 860px;
  min-height: 540px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 24px 80px rgba(0,0,0,0.6);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

/* ── Title bar ── */
.ob-titlebar {
  display: flex;
  align-items: center;
  height: 40px;
  padding: 0 14px;
  background: rgba(255,255,255,0.04);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}

.ob-traffic-lights {
  display: flex;
  gap: 7px;
  flex-shrink: 0;
}
.ob-tl {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}
.ob-tl-red { background: #FF5F57; }
.ob-tl-yellow { background: #FEBC2E; }
.ob-tl-green { background: #28C840; }

.ob-titlebar-label {
  flex: 1;
  text-align: center;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 500;
  color: rgba(255,255,255,0.45);
  letter-spacing: 0.2px;
}

.ob-titlebar-spacer {
  width: 55px; /* balances traffic lights width */
  flex-shrink: 0;
}

/* ── Window body ── */
.ob-body {
  flex: 1;
  background: #0D0D10;
  position: relative;
  overflow: hidden;
  overflow-y: auto;
  min-height: 480px;
}

/* ═══ STEP CONTENT ═══ */

.ob-step {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  overflow-y: auto;
}
.ob-step.active {
  opacity: 1;
  pointer-events: auto;
}

/* ═══ STEP 0: THE HOOK ═══ */

.ob-hook-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0;
}

.ob-hook-bolt {
  margin-bottom: 20px;
  opacity: 0.9;
}
.ob-hook-bolt svg {
  display: block;
}

.ob-hook-name {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.03em;
  line-height: 1;
}

.ob-hook-tagline {
  font-family: var(--font-body);
  font-size: 16px;
  color: rgba(255,255,255,0.4);
  margin-top: 12px;
  line-height: 1.5;
  max-width: 340px;
}

/* ═══ STEP 1: THE PROOF (speed race) ═══ */

.ob-proof-content {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  gap: 0;
}

/* User message bubble */
.ob-proof-user-msg {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 16px;
  flex-shrink: 0;
}

.ob-user-bubble {
  max-width: 70%;
  padding: 10px 16px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  word-wrap: break-word;
  font-size: 14px;
  color: #fff;
  line-height: 1.4;
}

/* Two columns */
.ob-proof-columns {
  display: flex;
  gap: 12px;
  flex: 1;
  min-height: 0;
  min-width: 0;
}

.ob-proof-col {
  flex: 1;
  min-width: 0;
  border-radius: 10px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  overflow: visible;
}
.ob-proof-col-slow {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
}
.ob-proof-col-fast {
  background: rgba(0,217,255,0.02);
  border: 1px solid rgba(0,217,255,0.10);
}

.ob-proof-col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  flex-shrink: 0;
}

.ob-proof-label {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.ob-proof-label-dim { color: rgba(255,255,255,0.3); }
.ob-proof-label-cyan { color: var(--accent); }

.ob-proof-speed-counter {
  display: flex;
  align-items: center;
  gap: 3px;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  color: rgba(255,255,255,0.25);
  font-variant-numeric: tabular-nums;
}
.ob-proof-speed-cyan {
  color: var(--accent);
}

.ob-mini-bolt {
  opacity: 0.5;
}
.ob-proof-speed-cyan .ob-mini-bolt {
  opacity: 0.9;
}

.ob-proof-dots-area {
  min-height: 24px;
  margin-bottom: 8px;
  flex-shrink: 0;
  overflow: visible;
  display: flex;
  align-items: center;
}

/* Typing dots (shared) */
.ob-typing-dots {
  display: inline-flex;
  gap: 3px;
  color: rgba(255,255,255,0.3);
}
.ob-typing-dots-cyan {
  color: var(--accent);
}
.ob-typing-dots span:not(.ob-done-tag) {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.3;
  animation: obDotPulse 0.75s ease-in-out infinite;
}
.ob-typing-dots span:not(.ob-done-tag):nth-child(2) { animation-delay: 0.15s; }
.ob-typing-dots span:not(.ob-done-tag):nth-child(3) { animation-delay: 0.3s; }
@keyframes obDotPulse {
  0%, 100% { opacity: 0.2; }
  50% { opacity: 0.9; }
}

.ob-done-tag {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  padding: 3px 10px;
  border-radius: 4px;
  line-height: 1;
  min-height: 20px;
}
.ob-done-dim { color: rgba(255,255,255,0.3); background: rgba(255,255,255,0.04); }
.ob-done-cyan { color: var(--accent); background: rgba(0,217,255,0.08); }

.ob-proof-text {
  font-size: 13px;
  line-height: 1.55;
  color: rgba(255,255,255,0.35);
  flex: 1;
  overflow: hidden;
  min-height: 100px;
  word-wrap: break-word;
  overflow-wrap: break-word;
}
.ob-proof-text-bright {
  color: rgba(255,255,255,0.85);
}

/* 55x FASTER badge */
.ob-proof-badge-wrap {
  text-align: center;
  padding-top: 14px;
  flex-shrink: 0;
}

.ob-faster-badge {
  display: inline-flex;
  align-items: center;
  padding: 7px 20px;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1.2px;
  color: var(--accent);
  background: transparent;
  border: 1px solid rgba(0,217,255,0.3);
  border-radius: 999px;
  opacity: 0;
  transform: scale(0.85);
  transition: opacity 0.3s ease, transform 0.35s cubic-bezier(0.25, 1, 0.5, 1);
}
.ob-faster-badge.visible {
  opacity: 1;
  transform: scale(1);
}

/* ═══ STEP 2: THE DEMO ═══ */

.ob-demo-content {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
}

.ob-demo-chat {
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
  overflow-y: auto;
}

.ob-demo-user-bubble {
  align-self: flex-end;
  max-width: 75%;
  padding: 10px 16px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  font-size: 14px;
  color: #fff;
  line-height: 1.4;
}

.ob-demo-response-area {
  display: flex;
  flex-direction: column;
}

.ob-demo-response-text {
  font-size: 14px;
  line-height: 1.65;
  color: #fff;
  white-space: pre-wrap;
}

.ob-demo-speed-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 10px;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(0,217,255,0.06);
  border: 1px solid rgba(0,217,255,0.10);
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  width: fit-content;
}

/* ═══ CTA BUTTON (below window) ═══ */

.ob-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  max-width: 260px;
  height: 46px;
  margin-top: 28px;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  color: #07070A;
  background: linear-gradient(135deg, #5CE7FF, #00D9FF);
  box-shadow: 0 6px 16px rgba(0,217,255,0.15);
  transition: opacity 0.2s ease, transform 0.2s ease;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
  letter-spacing: -0.01em;
}
.ob-cta::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(255,255,255,0.2), transparent 60%);
  pointer-events: none;
  border-radius: inherit;
}
.ob-cta:hover {
  transform: translateY(-1px);
}
.ob-cta:active {
  transform: translateY(0) scale(0.98);
}
.ob-cta:disabled {
  opacity: 0.4;
  cursor: default;
  transform: none;
}

.ob-cta-arrow {
  display: block;
  flex-shrink: 0;
}

/* ═══ PROGRESS DOTS (below CTA) ═══ */

.ob-dots {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  flex-shrink: 0;
}
.ob-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  transition: background 0.3s ease, transform 0.3s ease;
}
.ob-dot.active {
  background: var(--accent);
  transform: scale(1.2);
}

/* ═══ MOBILE (<600px) ═══ */

@media (max-width: 599px) {

  .ob-center-wrap {
    padding: 20px 16px;
  }

  .ob-window {
    max-width: none;
    min-height: 360px;
    border-radius: 10px;
  }

  .ob-titlebar {
    height: 36px;
    padding: 0 12px;
  }
  .ob-tl {
    width: 10px;
    height: 10px;
  }
  .ob-titlebar-label {
    font-size: 12px;
  }
  .ob-titlebar-spacer {
    width: 47px;
  }

  .ob-body {
    min-height: 320px;
  }

  .ob-step {
    padding: 24px;
  }

  /* Hook */
  .ob-hook-bolt svg {
    width: 32px;
    height: 32px;
  }
  .ob-hook-name {
    font-size: 24px;
  }
  .ob-hook-tagline {
    font-size: 14px;
    max-width: none;
  }

  /* Proof: stack columns vertically */
  .ob-proof-columns {
    flex-direction: column;
    gap: 10px;
  }
  .ob-proof-col {
    padding: 12px;
  }
  .ob-proof-text {
    min-height: 60px;
    font-size: 12px;
  }
  .ob-user-bubble {
    font-size: 13px;
    padding: 8px 12px;
  }
  .ob-proof-label {
    font-size: 10px;
  }
  .ob-proof-speed-counter {
    font-size: 11px;
  }

  /* Demo */
  .ob-demo-user-bubble {
    font-size: 13px;
    padding: 8px 12px;
  }
  .ob-demo-response-text {
    font-size: 13px;
  }

  /* CTA */
  .ob-cta {
    max-width: none;
    margin-top: 20px;
  }
}

/* ═══ COOKIE CONSENT BANNER ═══ */
.cookie-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 2000;
  background: rgba(13, 13, 16, 0.95);
  backdrop-filter: blur(20px);
  border-top: 1px solid rgba(255,255,255,0.08);
  padding: 16px 24px;
  animation: slideUp 0.3s ease-out;
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.cookie-inner {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.cookie-inner p {
  font-size: 13px;
  color: rgba(255,255,255,0.6);
  margin: 0;
  line-height: 1.5;
}
.cookie-inner a {
  color: var(--accent);
  text-decoration: none;
}
.cookie-buttons {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.cookie-accept {
  background: var(--accent);
  color: #07070A;
  border: none;
  padding: 8px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.cookie-decline {
  background: transparent;
  color: rgba(255,255,255,0.4);
  border: 1px solid rgba(255,255,255,0.1);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
}
@media (max-width: 600px) {
  .cookie-inner {
    flex-direction: column;
    text-align: center;
  }
}

/* ═══ GLOBAL SCROLLBAR (non-message areas) ═══ */
*::-webkit-scrollbar { width: 4px; height: 4px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 4px; }
*::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.15); }

/* Override for messages area (show only on hover) */
.messages::-webkit-scrollbar-thumb { background: transparent; }
.messages:hover::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); }

/* ═══ BOOKMARKS / SAVED ═══ */

/* Star button in message action bar */
.msg-star-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 6px;
  color: var(--text-muted);
  transition: color var(--transition-fast), background var(--transition-fast), transform 0.14s var(--ease-expo);
}
.msg-star-btn svg {
  transition: fill 0.15s var(--ease-expo), stroke 0.15s var(--ease-expo);
}
.msg-star-btn:hover {
  color: var(--accent);
  background: rgba(0, 217, 255, 0.08);
  border-color: rgba(0, 217, 255, 0.25);
}
.msg-star-btn.saved {
  color: var(--accent);
  opacity: 1;
}
.msg-star-btn.saved svg {
  filter: drop-shadow(0 0 6px rgba(0, 217, 255, 0.45));
}
.msg-star-btn.saved:hover {
  color: var(--accent);
  background: rgba(0, 217, 255, 0.12);
}
.msg-star-btn:active {
  transform: scale(0.88);
}

/* Sidebar "Saved" count badge */
.sb-saved-count {
  display: inline-block;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  margin-left: 2px;
}
.sb-saved-count.pulse {
  animation: savedCountPulse 0.4s var(--ease-expo);
}
@keyframes savedCountPulse {
  0% { transform: translateY(0); opacity: 0.6; }
  50% { transform: translateY(-1px); opacity: 1; color: var(--accent); }
  100% { transform: translateY(0); opacity: 1; }
}

/* Highlight pulse for messages when jumping from Saved */
.msg-highlight-pulse {
  animation: msgHighlightPulse 1.6s var(--ease-expo);
}
@keyframes msgHighlightPulse {
  0% { background: transparent; }
  25% { background: rgba(0, 217, 255, 0.10); box-shadow: 0 0 0 1px rgba(0, 217, 255, 0.35); border-radius: 12px; }
  100% { background: transparent; }
}

/* Saved page layout */
.saved-page {
  max-width: var(--msg-w);
  margin: 0 auto;
  padding: 40px 20px 80px;
}

.saved-header {
  margin-bottom: 28px;
}

.saved-title {
  font-family: var(--font-hero);
  font-size: 42px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.05;
  margin-top: 10px;
  color: var(--text);
}

.saved-subtitle {
  color: var(--text-muted);
  font-size: 15px;
  margin-top: 6px;
}

.saved-search-wrap {
  position: relative;
  margin-bottom: 24px;
}

.saved-search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.saved-search {
  width: 100%;
  background: rgba(255,255,255,0.035);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-md);
  padding: 13px 16px 13px 42px;
  color: var(--text);
  font-size: 14px;
  font-family: var(--font-body);
  outline: none;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}
.saved-search::placeholder { color: var(--text-muted); }
.saved-search:focus {
  border-color: rgba(0, 217, 255, 0.35);
  background: rgba(255,255,255,0.05);
  box-shadow: 0 0 0 3px rgba(0, 217, 255, 0.06);
}

.saved-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.saved-loading {
  color: var(--text-muted);
  font-size: 14px;
  padding: 24px;
  text-align: center;
}

/* Saved card */
.saved-card {
  position: relative;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius-lg);
  padding: 18px 20px 14px;
  animation: savedCardIn 0.34s var(--ease-expo) both;
  transition: border-color 0.18s var(--ease-expo), background 0.18s var(--ease-expo), transform 0.18s var(--ease-expo);
}
.saved-card:hover {
  border-color: rgba(0,217,255,0.22);
  background: rgba(255,255,255,0.045);
}
@keyframes savedCardIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.saved-card-q {
  color: var(--text-muted);
  font-size: 12px;
  text-transform: none;
  margin-bottom: 10px;
  line-height: 1.5;
  opacity: 0.85;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.saved-card-q::before {
  content: "You asked: ";
  color: var(--text-muted);
  opacity: 0.75;
}

.saved-card-body {
  position: relative;
  max-height: 70px;
  overflow: hidden;
  margin-bottom: 12px;
}

.saved-card-preview {
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.6;
  letter-spacing: -0.005em;
}

.saved-card-fade {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 28px;
  background: linear-gradient(to bottom, transparent, rgba(30, 30, 36, 0.98));
  pointer-events: none;
}

.saved-card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255,255,255,0.04);
}

.saved-card-open {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-body);
  cursor: pointer;
  padding: 4px 0;
  letter-spacing: -0.005em;
  transition: opacity var(--transition-fast);
}
.saved-card-open:hover { opacity: 0.82; }
.saved-card-open::after {
  content: " \2192";
  opacity: 0.75;
}

.saved-card-star {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  transition: background var(--transition-fast), transform 0.1s var(--ease-expo);
}
.saved-card-star:hover {
  background: rgba(0,217,255,0.08);
}
.saved-card-star:active { transform: scale(0.9); }

/* Saved empty state */
.saved-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  text-align: center;
}
.saved-empty-bolt {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, rgba(0,217,255,0.12), rgba(0,217,255,0.03));
  border: 1px solid rgba(0,217,255,0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  margin-bottom: 18px;
}
.saved-empty-text {
  color: var(--text-muted);
  font-size: 14px;
  max-width: 320px;
  line-height: 1.55;
}
.saved-empty-cta {
  margin-top: 14px;
  background: var(--accent);
  color: #000;
  border: none;
  padding: 10px 20px;
  border-radius: var(--radius-btn);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  transition: opacity var(--transition-fast), transform 0.1s var(--ease-expo);
}
.saved-empty-cta:hover { opacity: 0.9; }
.saved-empty-cta:active { transform: scale(0.97); }

/* ═══ IN-CHAT SEARCH ═══ */
.chat-search-bar {
  position: absolute;
  top: 64px;
  left: 50%;
  transform: translateX(-50%) translateY(-14px);
  display: flex;
  align-items: center;
  gap: 8px;
  width: calc(100% - 40px);
  max-width: 540px;
  background: rgba(22, 22, 26, 0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  box-shadow: 0 12px 36px rgba(0,0,0,0.5), 0 0 0 1px rgba(0, 217, 255, 0.08);
  opacity: 0;
  pointer-events: none;
  z-index: 50;
  transition: opacity 200ms cubic-bezier(0.16, 1, 0.3, 1), transform 200ms cubic-bezier(0.16, 1, 0.3, 1);
}
.chat-search-bar.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.chat-search-icon {
  color: var(--text-muted);
  flex-shrink: 0;
}

.chat-search-input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text);
  font-size: 14px;
  font-family: var(--font-body);
  outline: none;
  padding: 2px 0;
  min-width: 0;
}
.chat-search-input::placeholder { color: var(--text-muted); }

.chat-search-counter {
  color: var(--text-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.2px;
  padding: 0 4px;
  flex-shrink: 0;
  white-space: nowrap;
}
.chat-search-counter.zero { color: var(--text-muted); opacity: 0.7; }

.chat-search-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 6px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-fast), color var(--transition-fast), transform 0.1s var(--ease-expo);
}
.chat-search-btn:hover {
  background: rgba(255,255,255,0.07);
  color: var(--text);
}
.chat-search-btn:active { transform: scale(0.92); }
.chat-search-btn:disabled {
  opacity: 0.35;
  cursor: default;
  pointer-events: none;
}

.chat-search-divider {
  width: 1px;
  height: 18px;
  background: rgba(255,255,255,0.08);
  margin: 0 2px;
}

/* Search matches */
mark.search-match {
  background: rgba(0, 217, 255, 0.20);
  color: var(--text);
  padding: 1px 2px;
  border-radius: 3px;
  box-shadow: 0 0 0 1px rgba(0, 217, 255, 0.25) inset;
}
mark.search-match-current {
  background: rgba(0, 217, 255, 0.42);
  box-shadow: 0 0 0 1px rgba(0, 217, 255, 0.9) inset, 0 0 16px rgba(0, 217, 255, 0.4);
  color: #fff;
}

/* Current-match message glow pulse */
.msg-row.search-current-msg {
  animation: searchGlowPulse 600ms var(--ease-expo);
}
@keyframes searchGlowPulse {
  0% { box-shadow: 0 0 0 0 rgba(0, 217, 255, 0); }
  30% { box-shadow: 0 0 0 1px rgba(0, 217, 255, 0.35), 0 0 26px rgba(0, 217, 255, 0.28); }
  100% { box-shadow: 0 0 0 0 rgba(0, 217, 255, 0); }
}

/* Small hint text under bar when zero results */
.chat-search-hint {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  text-align: center;
  padding-top: 6px;
  color: var(--text-muted);
  font-size: 11px;
  letter-spacing: 0.2px;
  pointer-events: none;
}

/* ═══ QUICK ACTIONS (per-conversation chips) ═══ */

/* Consent prompt after first AI response */
.qa-consent {
  max-width: var(--msg-w);
  margin: 6px 0 0;
  padding: 14px 18px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-lg);
  animation: qaFadeIn 0.38s var(--ease-expo) both;
}
.qa-consent-label {
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 10px;
  letter-spacing: -0.005em;
}
.qa-consent-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.qa-consent-btn {
  background: rgba(255,255,255,0.045);
  border: 1px solid rgba(255,255,255,0.10);
  color: var(--text);
  font-size: 13px;
  font-family: var(--font-body);
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 20px;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), transform 0.1s var(--ease-expo);
}
.qa-consent-btn:hover {
  background: rgba(255,255,255,0.07);
  border-color: rgba(255,255,255,0.18);
}
.qa-consent-btn.primary {
  background: rgba(0, 217, 255, 0.12);
  border-color: rgba(0, 217, 255, 0.35);
  color: var(--accent);
}
.qa-consent-btn.primary:hover {
  background: rgba(0, 217, 255, 0.18);
  border-color: rgba(0, 217, 255, 0.5);
}
.qa-consent-btn:active { transform: scale(0.97); }
.qa-consent-btn.dismiss {
  color: var(--text-muted);
  background: transparent;
  border-color: transparent;
}
.qa-consent-btn.dismiss:hover {
  color: var(--text-dim);
  background: rgba(255,255,255,0.04);
}

/* Quick action chips row */
.qa-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.qa-chip {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(0, 217, 255, 0.25);
  color: var(--text);
  font-size: 13px;
  font-family: var(--font-body);
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 20px;
  cursor: pointer;
  opacity: 0;
  transform: translateY(4px);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  transition: background 0.15s var(--ease-expo), border-color 0.15s var(--ease-expo), color 0.15s var(--ease-expo), transform 0.12s var(--ease-expo), opacity 0.18s var(--ease-expo);
}
.qa-chip.visible {
  opacity: 1;
  transform: translateY(0);
}
.qa-chip:hover {
  background: rgba(0, 217, 255, 0.10);
  border-color: rgba(0, 217, 255, 0.50);
  color: var(--accent);
}
.qa-chip:active {
  transform: scale(0.96);
}
.qa-chip.fading {
  opacity: 0;
  transform: scale(0.94);
  pointer-events: none;
}

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

/* ═══ REDUCED MOTION ═══ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ═══ STUDY MODE ═══ */

/* Pill: persistent header strip shown when Study Mode is on */
.study-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 16px auto 8px;
  max-width: 820px;
  padding: 10px 16px;
  background: rgba(0, 217, 255, 0.06);
  border: 1px solid rgba(0, 217, 255, 0.22);
  border-radius: 12px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 5;
}
.study-pill-left {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 600;
  color: #00D9FF;
  letter-spacing: 0.3px;
}
.study-pill-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #00D9FF;
  box-shadow: 0 0 8px rgba(0, 217, 255, 0.5);
}
.study-pill-exit {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.65);
  padding: 5px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}
.study-pill-exit:hover { border-color: rgba(255, 255, 255, 0.25); color: #fff; }

/* Sidebar Study Folder link */
.sb-study-link {
  display: flex;
  align-items: center;
  gap: 10px;
  width: calc(100% - 20px);
  padding: 10px 14px;
  margin: 6px 10px;
  background: rgba(0, 217, 255, 0.05);
  border: 1px solid rgba(0, 217, 255, 0.18);
  border-radius: 10px;
  color: #00D9FF;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
  font-family: inherit;
  text-align: left;
  box-sizing: border-box;
}
.sb-study-link:hover {
  background: rgba(0, 217, 255, 0.1);
  border-color: rgba(0, 217, 255, 0.3);
}
.sb-study-title { flex: 1; }
.sb-study-count {
  font-size: 11px;
  opacity: 0.7;
  font-weight: 500;
}

/* Folder view */
.study-folder-wrap { padding: 28px 24px; max-width: 1000px; margin: 0 auto; }
.study-folder-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
  flex-wrap: wrap;
}
.study-folder-title {
  font-size: 22px;
  font-weight: 700;
  color: #ECECEC;
  letter-spacing: -0.01em;
}
.study-folder-count {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.45);
  font-weight: 500;
  margin-left: 8px;
}
.study-folder-actions { display: flex; gap: 8px; }
.study-folder-add {
  background: linear-gradient(135deg, #00D9FF, #0097b3);
  color: #000;
  border: none;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0, 217, 255, 0.25);
  font-family: inherit;
}
.study-folder-back {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.7);
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}
.study-folder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}
.study-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 14px;
  padding: 16px;
  cursor: pointer;
  transition: all 0.18s ease;
  min-height: 150px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.study-card:hover {
  transform: translateY(-2px);
  border-color: rgba(0, 217, 255, 0.3);
  background: rgba(0, 217, 255, 0.04);
}
.study-card-icon { font-size: 22px; }
.study-card-title {
  font-size: 13px;
  font-weight: 600;
  color: #ECECEC;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.study-card-tags {
  margin-top: auto;
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.study-tag {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.55);
  background: rgba(255, 255, 255, 0.04);
  padding: 2px 7px;
  border-radius: 6px;
  text-transform: lowercase;
}
.study-empty {
  padding: 80px 20px;
  text-align: center;
}
.study-empty-icon { font-size: 44px; margin-bottom: 16px; }
.study-empty-title {
  font-size: 18px;
  font-weight: 600;
  color: #ECECEC;
  margin-bottom: 6px;
}
.study-empty-sub {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.5);
  margin-bottom: 24px;
  max-width: 380px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.5;
}
.study-empty-cta {
  background: linear-gradient(135deg, #00D9FF, #0097b3);
  color: #000;
  border: none;
  padding: 12px 24px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0, 217, 255, 0.25);
  font-family: inherit;
}

/* Study modal (add material / preview) */
.study-modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 100;
}
.study-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #1a1a1a;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  width: min(620px, calc(100vw - 40px));
  max-height: 86vh;
  overflow-y: auto;
  z-index: 101;
  padding: 24px;
}
.study-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.study-modal-title {
  font-size: 17px;
  font-weight: 600;
  color: #ECECEC;
}
.study-modal-close {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.5);
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
  font-family: inherit;
}
.study-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 20px;
}
.study-tab-btn {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.5);
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  font-family: inherit;
}
.study-tab-btn.active {
  color: #00D9FF;
  border-bottom-color: #00D9FF;
}
.study-tab-panel { display: none; }
.study-tab-panel.active { display: block; }

.study-file-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 40px 20px;
  border: 2px dashed rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  cursor: pointer;
  text-align: center;
  color: rgba(255, 255, 255, 0.65);
  transition: all 0.18s ease;
}
.study-file-label:hover {
  border-color: rgba(0, 217, 255, 0.3);
  background: rgba(0, 217, 255, 0.03);
}
.study-file-icon { font-size: 36px; }
.study-file-prompt { font-size: 13px; line-height: 1.5; }
.study-file-prompt small { opacity: 0.6; font-size: 11px; }

.study-input, .study-textarea {
  width: 100%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 12px 14px;
  color: #ECECEC;
  font-size: 14px;
  font-family: inherit;
  margin-bottom: 12px;
  outline: none;
  resize: vertical;
}
.study-input:focus, .study-textarea:focus {
  border-color: rgba(0, 217, 255, 0.35);
}
.study-textarea { min-height: 200px; }
.study-paste-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.study-char-count {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.4);
}
.study-submit {
  background: linear-gradient(135deg, #00D9FF, #0097b3);
  color: #000;
  border: none;
  padding: 10px 24px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.study-upload-status {
  margin-top: 14px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.55);
  text-align: center;
  min-height: 14px;
}

.study-preview-modal .study-preview-tags {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.study-preview-body {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  padding: 16px;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.8);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 420px;
  overflow-y: auto;
}
.study-preview-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.study-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.8);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
}
.study-btn.danger {
  background: rgba(255, 59, 48, 0.08);
  border-color: rgba(255, 59, 48, 0.3);
  color: #FF3B30;
}

/* Quiz artifact (inline under message) */
.quiz-artifact {
  background: rgba(0, 217, 255, 0.03);
  border: 1px solid rgba(0, 217, 255, 0.18);
  border-left: 3px solid #00D9FF;
  border-radius: 12px;
  padding: 20px;
  margin: 14px 0;
}
.quiz-header {
  font-size: 14px;
  font-weight: 700;
  color: #00D9FF;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  margin-bottom: 18px;
}
.quiz-question-block {
  margin-bottom: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}
.quiz-question-block:last-of-type { border-bottom: none; }
.quiz-question {
  font-size: 15px;
  font-weight: 600;
  color: #ECECEC;
  line-height: 1.5;
  margin-bottom: 12px;
}
.quiz-choices {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.quiz-choice-btn {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #ECECEC;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}
.quiz-choice-btn:hover:not(.disabled):not(.correct):not(.wrong) {
  border-color: rgba(0, 217, 255, 0.35);
  background: rgba(0, 217, 255, 0.05);
}
.quiz-choice-btn.correct {
  background: rgba(52, 199, 89, 0.1);
  border-color: rgba(52, 199, 89, 0.4);
  color: #34C759;
  font-weight: 600;
}
.quiz-choice-btn.wrong {
  background: rgba(255, 59, 48, 0.08);
  border-color: rgba(255, 59, 48, 0.3);
  color: #FF3B30;
  font-weight: 600;
}
.quiz-choice-btn.disabled {
  opacity: 0.45;
  cursor: default;
}
.quiz-why {
  margin-top: 10px;
  font-size: 12px;
  font-style: italic;
  color: rgba(255, 255, 255, 0.55);
  line-height: 1.5;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 8px;
}
.quiz-summary {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid rgba(0, 217, 255, 0.15);
}
.quiz-score {
  font-size: 20px;
  font-weight: 700;
  color: #00D9FF;
  margin-bottom: 12px;
}
.quiz-review-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: rgba(255, 255, 255, 0.45);
  margin-bottom: 10px;
}
.quiz-review-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}
.quiz-review-row:last-child { border-bottom: none; }
.quiz-review-q {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
  flex: 1;
  line-height: 1.5;
}
.quiz-explain-more-chip {
  background: rgba(0, 217, 255, 0.08);
  border: 1px solid rgba(0, 217, 255, 0.3);
  color: #00D9FF;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
}
.quiz-explain-more-chip:hover { background: rgba(0, 217, 255, 0.15); }

.quiz-fallback {
  text-align: center;
  padding: 24px;
}
.quiz-fallback-title {
  font-size: 14px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.75);
  margin-bottom: 4px;
}
.quiz-fallback-sub {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.45);
}

/* ── Flashcards artifact — swipeable deck with 3D flip ──────────────── */
.flashcards-artifact {
  background:
    radial-gradient(ellipse at top, rgba(0, 217, 255, 0.08) 0%, transparent 60%),
    rgba(0, 217, 255, 0.025);
  border: 1px solid rgba(0, 217, 255, 0.18);
  border-radius: 16px;
  padding: 22px 20px 20px;
  margin: 14px 0;
  max-width: 560px;
  overflow: hidden;
}

.flashcards-header {
  margin-bottom: 18px;
}
.flashcards-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.flashcards-label {
  font-size: 11px;
  font-weight: 700;
  color: #00D9FF;
  text-transform: uppercase;
  letter-spacing: 1.6px;
}
.flashcards-count {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.5);
  font-variant-numeric: tabular-nums;
}
.flashcards-progress-bar {
  height: 3px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 2px;
  overflow: hidden;
}
.flashcards-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #00D9FF, #5CE7FF);
  box-shadow: 0 0 8px rgba(0, 217, 255, 0.4);
  border-radius: 2px;
  transition: width 0.42s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Stack container — allows peek cards behind and 3D perspective */
.flashcards-stack {
  position: relative;
  height: 220px;
  perspective: 1400px;
  margin-bottom: 20px;
}

/* Peek cards behind the active one */
.flashcard-peek {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 100%;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(255, 255, 255, 0.05);
  pointer-events: none;
}
.flashcard-peek-1 {
  transform: translateY(6px) scale(0.975);
  opacity: 0.7;
}
.flashcard-peek-2 {
  transform: translateY(12px) scale(0.95);
  opacity: 0.45;
}

/* The flippable card */
.flashcard {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 100%;
  cursor: pointer;
  transform-style: preserve-3d;
  transition: transform 0.58s cubic-bezier(0.34, 1.2, 0.64, 1);
}
.flashcard.flipped {
  transform: rotateY(180deg);
}
.flashcard:active {
  transition-duration: 0.2s;
}
.flashcard:not(.flipped):hover .flashcard-front {
  border-color: rgba(0, 217, 255, 0.4);
  box-shadow: 0 8px 32px rgba(0, 217, 255, 0.12);
}

.flashcard-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
}

.flashcard-face {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 16px;
  padding: 24px 26px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.flashcard-front {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04) 0%, rgba(255, 255, 255, 0.02) 100%),
    #141414;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.flashcard-back {
  background:
    linear-gradient(180deg, rgba(0, 217, 255, 0.06) 0%, rgba(0, 217, 255, 0.02) 100%),
    #141414;
  border: 1px solid rgba(0, 217, 255, 0.3);
  box-shadow: 0 8px 32px rgba(0, 217, 255, 0.15);
  transform: rotateY(180deg);
}

.flashcard-hint {
  font-size: 10px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.35);
  text-transform: uppercase;
  letter-spacing: 1.8px;
  margin-bottom: 14px;
}
.flashcard-hint.back {
  color: #00D9FF;
  opacity: 0.7;
}

.flashcard-text {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Rounded', 'SF Pro Display', system-ui, sans-serif;
  font-size: 22px;
  font-weight: 600;
  line-height: 1.35;
  color: #F5F5F5;
  letter-spacing: -0.015em;
  max-width: 100%;
  overflow-wrap: break-word;
}
.flashcard-back .flashcard-text {
  font-size: 15px;
  font-weight: 500;
  line-height: 1.55;
  color: rgba(255, 255, 255, 0.88);
  letter-spacing: -0.005em;
  max-height: 140px;
  overflow-y: auto;
}
.flashcard-back .flashcard-text::-webkit-scrollbar { width: 3px; }
.flashcard-back .flashcard-text::-webkit-scrollbar-thumb { background: rgba(0, 217, 255, 0.25); border-radius: 2px; }

/* Action buttons below the card */
.flashcards-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.flashcards-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 18px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  letter-spacing: -0.005em;
}
.flashcards-action-btn svg {
  flex-shrink: 0;
}

.flashcards-action-btn.review {
  background: rgba(255, 149, 0, 0.08);
  border: 1px solid rgba(255, 149, 0, 0.25);
  color: #FF9F0A;
}
.flashcards-action-btn.review:hover:not(.disabled) {
  background: rgba(255, 149, 0, 0.14);
  border-color: rgba(255, 149, 0, 0.45);
  transform: translateY(-1px);
}
.flashcards-action-btn.review:active:not(.disabled) {
  transform: translateY(0) scale(0.98);
}

.flashcards-action-btn.got {
  background: linear-gradient(180deg, rgba(52, 199, 89, 0.14), rgba(52, 199, 89, 0.06));
  border: 1px solid rgba(52, 199, 89, 0.35);
  color: #34C759;
}
.flashcards-action-btn.got:hover:not(.disabled) {
  background: linear-gradient(180deg, rgba(52, 199, 89, 0.22), rgba(52, 199, 89, 0.1));
  border-color: rgba(52, 199, 89, 0.55);
  box-shadow: 0 4px 16px rgba(52, 199, 89, 0.18);
  transform: translateY(-1px);
}
.flashcards-action-btn.got:active:not(.disabled) {
  transform: translateY(0) scale(0.98);
}

.flashcards-action-btn.disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

/* End-of-deck summary */
.flashcards-summary {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 24px 12px 8px;
  animation: flashcardsSummaryIn 0.42s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes flashcardsSummaryIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.flashcards-summary-icon {
  color: #00D9FF;
  margin-bottom: 12px;
  filter: drop-shadow(0 0 12px rgba(0, 217, 255, 0.45));
}

.flashcards-summary-title {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Rounded', system-ui, sans-serif;
  font-size: 22px;
  font-weight: 700;
  color: #F5F5F5;
  letter-spacing: -0.02em;
  margin-bottom: 18px;
}

.flashcards-summary-stats {
  display: flex;
  gap: 28px;
  margin-bottom: 22px;
}
.flashcards-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.flashcards-stat .stat-num {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Rounded', system-ui, sans-serif;
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.flashcards-stat .stat-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.6px;
  color: rgba(255, 255, 255, 0.45);
}
.flashcards-stat.got .stat-num { color: #34C759; }
.flashcards-stat.review .stat-num { color: #FF9F0A; }

.flashcards-summary-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  width: 100%;
}
.flashcards-btn {
  padding: 11px 20px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.8);
}
.flashcards-btn:hover {
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.07);
}
.flashcards-btn.primary {
  background: linear-gradient(135deg, #5CE7FF, #00D9FF);
  color: #000;
  border: none;
  font-weight: 700;
  box-shadow: 0 4px 16px rgba(0, 217, 255, 0.28);
}
.flashcards-btn.primary:hover {
  box-shadow: 0 6px 22px rgba(0, 217, 255, 0.4);
  transform: translateY(-1px);
}
.flashcards-btn.primary:active {
  transform: translateY(0);
}

.flashcards-fallback {
  text-align: center;
  padding: 28px;
}
.flashcards-fallback-title {
  font-size: 14px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.75);
  margin-bottom: 4px;
}
.flashcards-fallback-sub {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.45);
}

/* Study Guide artifact card */
.study-guide-artifact {
  background: rgba(0, 217, 255, 0.03);
  border: 1px solid rgba(0, 217, 255, 0.18);
  border-radius: 12px;
  padding: 18px;
  margin: 14px 0;
}
.study-guide-header {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 700;
  color: #00D9FF;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  margin-bottom: 8px;
}
.study-guide-icon { font-size: 18px; }
.study-guide-preview {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.65);
  line-height: 1.6;
  margin-bottom: 14px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.study-guide-open {
  background: transparent;
  border: 1px solid rgba(0, 217, 255, 0.35);
  color: #00D9FF;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.study-guide-open:hover { background: rgba(0, 217, 255, 0.08); }

