/* ------------------------------------------------------------ Reset & Base ------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-primary: #131314;
  --bg-secondary: #1e1f20;
  --bg-tertiary: #2a2b2c;
  --bg-hover: #282829;
  --bg-input: #1e1f20;
  --bg-code: #1e1f20;
  --bg-code-header: #2a2b2c;
  --text-primary: #e3e3e3;
  --text-secondary: #9aa0a6;
  --text-muted: #6c757d;
  --border-color: #2a2b2c;
  --accent-blue: #4285f4;
  --accent-purple: #9b72cb;
  --accent-pink: #d96570;
  --accent-orange: #f7a948;
  --danger: #f28b82;
  --scrim: rgba(0, 0, 0, 0.55);
  --sidebar-width: 272px;
  --transition: 0.2s ease;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 24px;
  --radius-pill: 999px;
  --shadow-menu: 0 4px 20px rgba(0, 0, 0, 0.45);
}

[data-theme="light"] {
  --bg-primary: #ffffff;
  --bg-secondary: #f0f4f9;
  --bg-tertiary: #e9eef6;
  --bg-hover: #e9eef6;
  --bg-input: #f0f4f9;
  --text-primary: #1f1f1f;
  --text-secondary: #575b5f;
  --text-muted: #80868b;
  --border-color: #e0e3e7;
  --danger: #d93025;
  --scrim: rgba(0, 0, 0, 0.3);
  --shadow-menu: 0 4px 20px rgba(0, 0, 0, 0.15);
}

html, body {
  height: 100%;
  font-family: 'Google Sans', 'Roboto', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.6;
  overflow: hidden;
}

.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-tertiary); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #3c3d3e; }

/* ------------------------------------------------------------ Sidebar ------------------------------------------------------------ */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  height: 100vh;
  border-right: 1px solid var(--border-color);
  transition: width var(--transition), min-width var(--transition), opacity var(--transition), transform var(--transition);
  overflow: hidden;
}

.sidebar.collapsed {
  width: 0;
  min-width: 0;
  opacity: 0;
  border-right: none;
}

.sidebar-scrim { display: none; }

.sidebar-header {
  display: flex;
  align-items: center;
  padding: 16px 12px 8px;
  gap: 8px;
}

.new-chat-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 12px 12px;
  padding: 10px 16px 10px 12px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border: none;
  border-radius: var(--radius-pill);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  width: fit-content;
  transition: background var(--transition), color var(--transition);
}

.new-chat-pill:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.new-chat-pill .material-icons-round { font-size: 20px; }

.sidebar-section {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.sidebar-label {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  padding: 4px 16px 6px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 6px 8px 16px;
  border-radius: var(--radius-pill);
  margin: 0 8px 2px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 13px;
  transition: background var(--transition);
  position: relative;
}

.history-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.history-item.active { background: rgba(66, 133, 244, 0.16); color: var(--text-primary); }
.history-item > .material-icons-round { font-size: 18px; flex-shrink: 0; }

.history-title {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.item-menu-btn {
  width: 28px;
  height: 28px;
  opacity: 0;
  flex-shrink: 0;
}
.item-menu-btn .material-icons-round { font-size: 18px; }
.history-item:hover .item-menu-btn { opacity: 1; }

.history-empty {
  padding: 12px 16px;
  color: var(--text-muted);
  font-size: 12px;
}

.sidebar-footer {
  border-top: 1px solid var(--border-color);
  padding: 8px 0 max(8px, env(safe-area-inset-bottom));
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  margin: 0 8px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 13px;
  transition: background var(--transition);
  user-select: none;
}

.sidebar-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.sidebar-item .material-icons-round { font-size: 20px; }

/* ------------------------------------------------------------ Buttons ------------------------------------------------------------ */
.icon-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  width: 40px;
  height: 40px;
  border-radius: var(--radius-pill);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), color var(--transition), opacity var(--transition);
  flex-shrink: 0;
}

.icon-btn:hover:not(:disabled) { background: var(--bg-hover); color: var(--text-primary); }
.icon-btn:disabled { opacity: 0.35; cursor: default; }
.icon-btn .material-icons-round { font-size: 22px; }

/* ------------------------------------------------------------ Main Content ------------------------------------------------------------ */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
  overflow: hidden;
}

/* ------------------------------------------------------------ Topbar ------------------------------------------------------------ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  height: 60px;
  flex-shrink: 0;
}

.topbar-left { display: flex; align-items: center; gap: 8px; }
.topbar-menu { display: none; }

.gemini-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
}

.gemini-icon { width: 24px; height: 24px; }

.gemini-wordmark {
  font-size: 18px;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.gemini-model-badge {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  padding: 3px 8px 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-family: inherit;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition);
}

.gemini-model-badge:hover { background: var(--bg-tertiary); }
.gemini-model-badge .material-icons-round { font-size: 16px; }

.model-menu {
  position: absolute;
  top: 36px;
  left: 0;
  min-width: 280px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-menu);
  padding: 6px;
  z-index: 300;
}

.model-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
}

.model-option:hover { background: var(--bg-hover); }
.model-option-text { display: flex; flex-direction: column; gap: 2px; }
.model-option-name { font-size: 13px; font-weight: 500; color: var(--text-primary); }
.model-option-desc { font-size: 12px; color: var(--text-muted); }
.model-check { font-size: 18px; color: var(--accent-blue); visibility: hidden; }
.model-option.selected .model-check { visibility: visible; }

.topbar-right { display: flex; align-items: center; gap: 4px; }

.avatar-btn { background: transparent; border: none; cursor: pointer; border-radius: var(--radius-pill); padding: 2px; }

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4285F4, #9B72CB);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  font-size: 13px;
}

/* ------------------------------------------------------------ Chat Area ------------------------------------------------------------ */
.chat-area {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ------------------------------------------------------------ Welcome Screen ------------------------------------------------------------ */
.welcome-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 40px 24px 24px;
  gap: 40px;
  min-height: 0;
}

.welcome-greeting { text-align: center; }

.greeting-text {
  font-size: clamp(28px, 5vw, 48px);
  font-weight: 400;
  line-height: 1.2;
  margin-bottom: 8px;
}

.gradient-text {
  background: linear-gradient(90deg, #4285F4 0%, #9B72CB 33%, #D96570 66%, #F7A948 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.greeting-sub { color: var(--text-secondary); font-size: 18px; font-weight: 400; }

.suggestion-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  width: 100%;
  max-width: 680px;
}

.suggestion-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 24px;
  min-height: 100px;
  position: relative;
}

.suggestion-card:hover { background: var(--bg-tertiary); border-color: #3c3d3e; }
[data-theme="light"] .suggestion-card:hover { border-color: #c6cdd5; }

.suggestion-text { font-size: 13px; color: var(--text-primary); line-height: 1.5; }
.card-icon { align-self: flex-end; color: var(--text-muted); font-size: 20px; }

/* ------------------------------------------------------------ Messages ------------------------------------------------------------ */
.messages-container {
  padding: 24px 0 40px;
  display: flex;
  flex-direction: column;
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
}

.message-wrap { padding: 4px 24px; width: 100%; }

.user-wrap { display: flex; justify-content: flex-end; }
.assistant-wrap { display: flex; justify-content: flex-start; }

.message { max-width: 100%; }

/* User bubble */
.user-message { display: flex; flex-direction: column; align-items: flex-end; max-width: 100%; }

.user-message .message-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 18px 18px 4px 18px;
  padding: 12px 16px;
  max-width: 72%;
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.user-message .message-content.has-image { padding: 6px; }

.user-image {
  max-width: 280px;
  max-height: 280px;
  border-radius: 14px;
  display: block;
}

.user-actions {
  display: flex;
  justify-content: flex-end;
  gap: 2px;
  margin-top: 4px;
  opacity: 0;
  transition: opacity var(--transition);
}

.user-wrap:hover .user-actions { opacity: 1; }

/* Assistant message */
.assistant-message { display: flex; gap: 12px; align-items: flex-start; width: 100%; }

.assistant-icon {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  margin-top: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.message-body { flex: 1; min-width: 0; }

.assistant-message .message-content {
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.7;
  word-break: break-word;
}

.assistant-message .message-content p { margin-bottom: 12px; }
.assistant-message .message-content p:last-child { margin-bottom: 0; }

.assistant-message .message-content h1,
.assistant-message .message-content h2,
.assistant-message .message-content h3,
.assistant-message .message-content h4 {
  margin: 16px 0 8px;
  font-weight: 600;
  color: var(--text-primary);
}

.assistant-message .message-content h1 { font-size: 20px; }
.assistant-message .message-content h2 { font-size: 17px; }
.assistant-message .message-content h3 { font-size: 15px; }
.assistant-message .message-content h4 { font-size: 14px; }

.assistant-message .message-content ul,
.assistant-message .message-content ol {
  padding-left: 20px;
  margin-bottom: 12px;
}

.assistant-message .message-content li { margin-bottom: 4px; }
.assistant-message .message-content strong { font-weight: 600; color: var(--text-primary); }
.assistant-message .message-content em { font-style: italic; }

.assistant-message .message-content a { color: var(--accent-blue); text-decoration: none; }
.assistant-message .message-content a:hover { text-decoration: underline; }

.assistant-message .message-content blockquote {
  border-left: 3px solid var(--border-color);
  padding-left: 12px;
  color: var(--text-secondary);
  margin: 12px 0;
}

.assistant-message .message-content hr {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 16px 0;
}

.assistant-message .message-content table {
  border-collapse: collapse;
  margin: 12px 0;
  width: 100%;
  font-size: 13px;
  display: block;
  overflow-x: auto;
}

.assistant-message .message-content th,
.assistant-message .message-content td {
  border: 1px solid var(--border-color);
  padding: 8px 12px;
  text-align: left;
}

.assistant-message .message-content th { background: var(--bg-secondary); font-weight: 600; }

/* Code */
code:not(pre code) {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: 'Google Sans Mono', 'Courier New', monospace;
  font-size: 12.5px;
  color: #e8c468;
}

[data-theme="light"] code:not(pre code) { color: #b05a00; }

.code-block {
  background: #1e1f20;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin: 12px 0;
}

.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: #2a2b2c;
  border-bottom: 1px solid #333438;
  font-size: 12px;
  color: #9aa0a6;
}

.copy-code-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  background: transparent;
  border: none;
  color: #9aa0a6;
  cursor: pointer;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: background var(--transition), color var(--transition);
  font-family: inherit;
}

.copy-code-btn:hover { background: #333438; color: #e3e3e3; }
.copy-code-btn .material-icons-round { font-size: 14px; }

.code-block pre {
  padding: 14px;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.6;
  background: #1e1f20 !important;
}

.code-block code {
  font-family: 'Google Sans Mono', 'Courier New', monospace;
  background: transparent !important;
  border: none;
  padding: 0;
  font-size: 13px;
}

/* Message actions */
.message-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-top: 8px;
  opacity: 0;
  transition: opacity var(--transition);
}

.message-wrap:hover .message-actions { opacity: 1; }

.action-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-pill);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), color var(--transition);
}

.action-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.action-btn.voted { color: var(--accent-blue); }
.action-btn .material-icons-round { font-size: 16px; }
/* Loud-speaker: alone on the right side of the row, a touch bigger */
.action-btn.tts-action { margin-left: auto; width: 38px; height: 38px; }
.action-btn.tts-action .material-icons-round { font-size: 20px; }

/* Streaming cursor */
.stream-cursor {
  display: inline-block;
  width: 9px;
  height: 16px;
  background: var(--accent-blue);
  border-radius: 2px;
  margin-left: 3px;
  vertical-align: text-bottom;
  animation: cursor-blink 1s steps(2) infinite;
}

@keyframes cursor-blink { 0%, 50% { opacity: 1; } 50.01%, 100% { opacity: 0.15; } }

/* Generated / uploaded images */
.gen-image {
  max-width: min(420px, 100%);
  border-radius: var(--radius-md);
  display: block;
  border: 1px solid var(--border-color);
}

.image-skeleton {
  width: min(420px, 100%);
  aspect-ratio: 1;
  border-radius: var(--radius-md);
  background: linear-gradient(110deg, var(--bg-secondary) 30%, var(--bg-tertiary) 50%, var(--bg-secondary) 70%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.image-skeleton .material-icons-round { font-size: 40px; opacity: 0.5; }

@keyframes shimmer { to { background-position: -200% 0; } }

/* Error bubble */
.error-bubble {
  background: rgba(242, 139, 130, 0.12);
  border: 1px solid rgba(242, 139, 130, 0.4);
  color: var(--danger);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 13px;
  width: fit-content;
}

/* Edit mode */
.edit-textarea {
  width: 100%;
  min-width: 280px;
  min-height: 80px;
  background: var(--bg-primary);
  border: 1px solid var(--accent-blue);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.6;
  padding: 10px;
  resize: vertical;
  outline: none;
}

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

/* ------------------------------------------------------------ Typing indicator (kept for compatibility) ------------------------------------------------------------ */
.typing-indicator { display: flex; align-items: center; gap: 5px; padding: 14px 0 4px; height: 32px; }
.typing-indicator span {
  width: 8px; height: 8px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  animation: typing-bounce 1.4s infinite ease-in-out;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* ------------------------------------------------------------ Input Area ------------------------------------------------------------ */
.input-area { flex-shrink: 0; padding: 0 24px 16px; background: var(--bg-primary); }
.input-box-wrapper { max-width: 800px; margin: 0 auto; }

.attachment-strip { padding: 0 4px 8px; }

.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 6px 6px 6px 8px;
  max-width: 320px;
}

.attachment-chip img {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: var(--radius-sm);
}

.attachment-chip span {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.attachment-remove { width: 28px; height: 28px; }
.attachment-remove .material-icons-round { font-size: 16px; }

.input-box {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 28px;
  padding: 12px 14px 10px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.input-box:focus-within {
  border-color: #4a4b4c;
  box-shadow: 0 0 0 1px rgba(66, 133, 244, 0.15);
}

[data-theme="light"] .input-box:focus-within { border-color: #c6cdd5; }

.input-tools-left, .input-tools-right {
  display: flex;
  align-items: center;
  gap: 2px;
  padding-bottom: 2px;
}

.tool-btn { color: var(--text-muted); }
.tool-btn:hover { color: var(--text-secondary); background: var(--bg-tertiary); }

.tool-btn.recording {
  color: #fff;
  background: var(--aura-grad);
  animation: mic-pulse 1.2s ease-in-out infinite;
}

@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.46); }
  50% { box-shadow: 0 0 0 8px rgba(45, 212, 191, 0); }
}

.image-mode-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-pill);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 12.5px;
  padding: 6px 12px 6px 8px;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  height: 34px;
}

.image-mode-chip .material-icons-round { font-size: 18px; }
.image-mode-chip:hover { background: var(--bg-tertiary); color: var(--text-secondary); }

.image-mode-chip.active {
  background: rgba(66, 133, 244, 0.18);
  border-color: rgba(66, 133, 244, 0.5);
  color: var(--accent-blue);
}

textarea#message-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: 'Google Sans', sans-serif;
  font-size: 14px;
  line-height: 1.6;
  resize: none;
  padding: 6px 4px;
  min-height: 28px;
  max-height: 200px;
  overflow-y: auto;
  caret-color: var(--accent-blue);
}

textarea#message-input::placeholder { color: var(--text-muted); }

.send-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-pill);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--text-muted);
  color: var(--bg-primary);
  flex-shrink: 0;
  transition: background var(--transition), transform var(--transition);
}

.send-btn:not(:disabled) { background: var(--text-primary); cursor: pointer; }
.send-btn:not(:disabled):hover { background: #ffffff; transform: scale(1.05); }
[data-theme="light"] .send-btn:not(:disabled):hover { background: #000; }
.send-btn:disabled { cursor: not-allowed; }
.send-btn .material-icons-round { font-size: 20px; }

.send-btn.stop-mode { background: var(--accent-pink); color: #fff; }
.send-btn.stop-mode:hover { background: #c25560; }

.disclaimer {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 10px;
}

/* ------------------------------------------------------------ Context menu ------------------------------------------------------------ */
.context-menu {
  position: fixed;
  min-width: 160px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-menu);
  padding: 6px;
  z-index: 400;
}

.context-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-primary);
  transition: background var(--transition);
}

.context-menu-item:hover { background: var(--bg-hover); }
.context-menu-item .material-icons-round { font-size: 18px; color: var(--text-secondary); }
.context-menu-item.danger { color: var(--danger); }
.context-menu-item.danger .material-icons-round { color: var(--danger); }

/* ------------------------------------------------------------ Modal ------------------------------------------------------------ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--scrim);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 24px;
}

.modal-overlay[hidden] {
  display: none;
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 24px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-menu);
}

.modal-title { font-size: 16px; font-weight: 500; margin-bottom: 12px; }
.modal-text { font-size: 13px; color: var(--text-secondary); margin-bottom: 8px; }

.modal-input {
  width: 100%;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  padding: 10px 12px;
  outline: none;
  margin-top: 4px;
}

.modal-input:focus { border-color: var(--accent-blue); }

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

.modal-btn {
  background: transparent;
  border: none;
  border-radius: var(--radius-pill);
  color: var(--accent-blue);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 16px;
  cursor: pointer;
  transition: background var(--transition);
}

.modal-btn:hover { background: rgba(66, 133, 244, 0.12); }
.modal-btn.primary { background: var(--accent-blue); color: #fff; }
.modal-btn.primary:hover { background: #5a95f5; }

/* ------------------------------------------------------------ Toast ------------------------------------------------------------ */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 600;
  align-items: center;
}

.toast {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-size: 13px;
  box-shadow: var(--shadow-menu);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.toast.show { opacity: 1; transform: translateY(0); }

/* Premium upsell toast (message + Upgrade button) and sidebar entry */
.premium-toast { display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 18px; }
.premium-toast-btn {
  border: 0;
  border-radius: 999px;
  padding: 7px 14px;
  cursor: pointer;
  background: var(--accent-blue);
  color: #fff;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
}
.premium-toast-btn:hover { filter: brightness(1.1); }
#premium-item > .material-icons-round { color: var(--accent-blue); }

/* ------------------------------------------------------------ Responsive (drawer covers phones + iPad/tab portrait) ------------------------------------------------------------ */
@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    z-index: 200;
    height: 100vh;
    transform: translateX(-100%);
    box-shadow: none;
  }

  .sidebar.collapsed { width: var(--sidebar-width); min-width: var(--sidebar-width); opacity: 1; }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.5);
    opacity: 1;
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
  }

  body.sidebar-open .sidebar-scrim {
    display: block;
    position: fixed;
    inset: 0;
    background: var(--scrim);
    z-index: 150;
  }

  .topbar-menu { display: flex; }
  .suggestion-grid { grid-template-columns: 1fr; }
  .messages-container { padding: 16px 0 24px; }
  .message-wrap { padding: 4px 16px; }
  .user-message .message-content { max-width: 88%; }
  .input-area { padding: 0 12px 12px; }
  .image-mode-chip .chip-label { display: none; }
  .image-mode-chip { padding: 6px 8px; }
  .model-menu { min-width: 240px; }
}

/* ------------------------------------------------------------
   Aura v2 layer: rebrand, voice mode, thinking, gems, search,
   share, attachments menu, code preview, language menu.
   ------------------------------------------------------------ */
:root {
  --aura-1: #2fd8ff;
  --aura-2: #8b5cf6;
  --aura-3: #c084fc;
  --aura-grad: linear-gradient(135deg, #2fd8ff 0%, #5b8cff 45%, #a855f7 100%);
}

/* ---- Brand ---- */
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-orb {
  width: 26px; height: 26px; border-radius: 8px; flex: none;
  background: url("/static/icons/star.png") center / 88% no-repeat,
    linear-gradient(145deg, #161c38 0%, #0d1126 55%, #141b3e 100%);
  border: 1px solid rgba(139, 148, 255, 0.16);
  box-shadow: 0 0 12px rgba(91, 140, 255, 0.45);
}
.brand-orb.small { width: 22px; height: 22px; border-radius: 7px; box-shadow: 0 0 8px rgba(91, 140, 255, 0.4); display: inline-block; }
.topbar-orb { width: 24px; height: 24px; border-radius: 8px; margin: 0 4px; }
.brand-wordmark { font-size: 20px; font-weight: 500; color: var(--text-primary); letter-spacing: 0.2px; }
.gradient-text {
  background: var(--aura-grad);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.gem-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: var(--radius-pill);
  background: var(--bg-secondary); border: 1px solid var(--border-color);
  color: var(--text-secondary); font-size: 12.5px; min-width: 0;
}
.gem-badge .material-icons-round { font-size: 15px; color: var(--aura-2); }
.gem-badge span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- Welcome ---- */
.welcome-orb {
  width: 74px; height: 74px; border-radius: 22px; margin: 0 auto 18px;
  background: url("/static/icons/star.png") center / 88% no-repeat,
    linear-gradient(145deg, #161c38 0%, #0d1126 55%, #141b3e 100%);
  border: 1px solid rgba(139, 148, 255, 0.16);
  box-shadow: 0 0 40px rgba(139, 92, 246, 0.45);
  animation: aura-breathe 4s ease-in-out infinite;
}
@keyframes aura-breathe {
  0%, 100% { transform: scale(1); box-shadow: 0 0 32px rgba(139, 92, 246, 0.35); }
  50% { transform: scale(1.04); box-shadow: 0 0 52px rgba(47, 216, 255, 0.5); }
}
.welcome-greeting { text-align: center; }
.gems-block { margin-top: 28px; width: 100%; max-width: 760px; }
.gems-label { display: block; font-size: 13px; color: var(--text-muted); margin: 0 0 10px 4px; }
.gems-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.gem-chip {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px;
  background: var(--bg-secondary); border: 1px solid var(--border-color);
  border-radius: var(--radius-md); cursor: pointer; transition: background var(--transition), border-color var(--transition);
  min-width: 0;
}
.gem-chip:hover { background: var(--bg-hover); }
.gem-chip.active { border-color: var(--aura-2); background: rgba(139, 92, 246, 0.12); }
.gem-chip .material-icons-round { font-size: 20px; color: var(--aura-1); flex: none; }
.gem-chip:nth-child(2) .material-icons-round { color: var(--aura-2); }
.gem-chip:nth-child(3) .material-icons-round { color: var(--aura-3); }
.gem-chip:nth-child(4) .material-icons-round { color: var(--accent-orange); }
.gem-chip-text { display: flex; flex-direction: column; min-width: 0; }
.gem-chip-text b { font-size: 13.5px; font-weight: 500; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gem-chip-text small { font-size: 11.5px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---- Sidebar: search ---- */
.search-box {
  display: flex; align-items: center; gap: 8px;
  margin: 4px 12px 10px; padding: 8px 12px;
  background: var(--bg-secondary); border-radius: var(--radius-pill);
  border: 1px solid transparent;
}
.search-box:focus-within { border-color: var(--border-color); }
.search-box .material-icons-round { font-size: 18px; color: var(--text-muted); }
.search-box input {
  flex: 1; min-width: 0; background: none; border: none; outline: none;
  color: var(--text-primary); font-size: 13.5px; font-family: inherit;
}
.search-box input::placeholder { color: var(--text-muted); }
.search-clear { width: 22px; height: 22px; }
.search-clear .material-icons-round { font-size: 15px; }
.sidebar.collapsed .search-box { display: none; }

.history-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.history-snippet {
  font-size: 11px; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ---- Sidebar: language menu ---- */
.sidebar-item { position: relative; }
.lang-menu {
  position: absolute; bottom: calc(100% + 6px); left: 8px; z-index: 60;
  background: var(--bg-tertiary); border-radius: var(--radius-md);
  box-shadow: var(--shadow-menu); padding: 6px; min-width: 150px;
}
.lang-menu[hidden] { display: none; }
.lang-option {
  padding: 9px 14px; border-radius: var(--radius-sm); font-size: 13.5px;
  color: var(--text-primary); cursor: pointer; white-space: nowrap;
}
.lang-option:hover { background: var(--bg-hover); }
.lang-option.selected { color: var(--aura-1); font-weight: 500; }

/* ---- Composer ---- */
.input-tools-left, .input-tools-right { position: relative; }
.mode-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: var(--radius-pill);
  background: none; border: 1px solid var(--border-color);
  color: var(--text-secondary); font-size: 12.5px; font-family: inherit;
  cursor: pointer; transition: all var(--transition); flex: none;
}
.mode-chip .material-icons-round { font-size: 16px; }
.mode-chip:hover { background: var(--bg-hover); }
.mode-chip.active { background: rgba(45, 212, 191, 0.14); border-color: var(--aura-1); color: var(--aura-1); }
#web-mode-btn.active { background: rgba(139, 92, 246, 0.14); border-color: var(--aura-2); color: var(--aura-2); }

.attach-menu {
  position: absolute; bottom: calc(100% + 10px); left: 0; z-index: 60;
  background: var(--bg-tertiary); border-radius: var(--radius-md);
  box-shadow: var(--shadow-menu); padding: 6px; min-width: 180px;
}
.attach-menu[hidden] { display: none; }
.attach-option {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: var(--radius-sm);
  font-size: 13.5px; color: var(--text-primary); cursor: pointer; white-space: nowrap;
}
.attach-option:hover { background: var(--bg-hover); }
.attach-option .material-icons-round { font-size: 19px; color: var(--text-secondary); }

.model-pill {
  display: inline-flex; align-items: center; gap: 2px;
  padding: 6px 10px; border-radius: var(--radius-pill);
  background: none; border: none; color: var(--text-secondary);
  font-size: 12.5px; font-family: inherit; cursor: pointer; flex: none;
}
.model-pill:hover { background: var(--bg-hover); }
.model-pill .material-icons-round { font-size: 16px; }
.input-tools-right .model-menu {
  position: absolute; bottom: calc(100% + 10px); top: auto; right: 0; left: auto;
}

.send-btn:not(:disabled) { background: var(--aura-grad); color: #fff; }
.send-btn:not(:disabled):hover { filter: brightness(1.12); background: var(--aura-grad); }
[data-theme="light"] .send-btn:not(:disabled):hover { background: var(--aura-grad); filter: brightness(1.05); }
.send-btn.stop-mode:not(:disabled) { background: var(--bg-tertiary); color: var(--text-primary); }

.attachment-chip .file-glyph { font-size: 22px; color: var(--aura-2); }
#attachment-thumb[hidden] { display: none; }

.voice-btn .material-icons-round { color: var(--aura-1); }

/* ---- Messages: file bubble, thinking, code header ---- */
.file-bubble { display: flex; align-items: center; gap: 8px; }
.file-bubble .material-icons-round { font-size: 20px; color: var(--aura-2); }

.thought-panel {
  margin: 2px 0 10px; border: 1px solid var(--border-color);
  border-radius: var(--radius-md); overflow: hidden; max-width: 100%;
}
.thought-panel[hidden] { display: none; }
.thought-toggle {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 8px 12px; background: var(--bg-secondary); border: none;
  color: var(--text-secondary); font-size: 12.5px; font-family: inherit; cursor: pointer;
}
.thought-toggle .material-icons-round { font-size: 17px; color: var(--aura-2); }
.thought-toggle .thought-chevron { margin-left: auto; color: var(--text-muted); }
.thought-content {
  padding: 10px 14px; font-size: 12.5px; line-height: 1.55;
  color: var(--text-secondary); white-space: pre-wrap; max-height: 240px; overflow-y: auto;
  border-top: 1px solid var(--border-color);
}
.thought-content[hidden] { display: none; }

.code-header-right { display: flex; align-items: center; gap: 4px; }

/* ---- HTML preview overlay ---- */
.preview-overlay {
  position: fixed; inset: 0; z-index: 400; background: var(--scrim);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.preview-box {
  width: min(920px, 100%); height: min(640px, 90vh);
  background: var(--bg-primary); border-radius: var(--radius-md);
  display: flex; flex-direction: column; overflow: hidden; box-shadow: var(--shadow-menu);
}
.preview-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 8px 8px 16px; background: var(--bg-secondary);
  font-size: 13px; color: var(--text-secondary);
}
.preview-frame { flex: 1; border: none; background: #fff; }

/* ---- Voice conversation overlay ---- */
.voice-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: radial-gradient(ellipse at 50% 30%, rgba(139, 92, 246, 0.14), transparent 60%), var(--bg-primary);
  display: flex; align-items: center; justify-content: center;
}
.voice-overlay[hidden] { display: none; }
.voice-center { display: flex; flex-direction: column; align-items: center; gap: 26px; padding: 24px; max-width: 560px; }
.voice-orb {
  width: 150px; height: 150px; border-radius: 50%; cursor: pointer; position: relative;
  display: flex; align-items: center; justify-content: center;
}
.voice-orb-core {
  width: 120px; height: 120px; border-radius: 50%;
  background: radial-gradient(circle at 32% 30%, #9beeff 0%, var(--aura-1) 22%, var(--aura-2) 62%, var(--aura-3) 100%);
  box-shadow: 0 0 46px rgba(139, 92, 246, 0.55);
  transition: transform 0.25s ease;
}
.voice-orb::before, .voice-orb::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid rgba(45, 212, 191, 0.4); opacity: 0;
}
.voice-overlay[data-state="listening"] .voice-orb::before { animation: voice-ring 1.8s ease-out infinite; }
.voice-overlay[data-state="listening"] .voice-orb::after { animation: voice-ring 1.8s ease-out 0.9s infinite; }
@keyframes voice-ring {
  0% { transform: scale(0.82); opacity: 0.85; }
  100% { transform: scale(1.35); opacity: 0; }
}
.voice-overlay[data-state="processing"] .voice-orb-core { animation: voice-throb 1.1s ease-in-out infinite; }
@keyframes voice-throb {
  0%, 100% { transform: scale(0.92); filter: saturate(0.8); }
  50% { transform: scale(1.0); filter: saturate(1.3); }
}
.voice-overlay[data-state="speaking"] .voice-orb-core { animation: voice-speak 0.55s ease-in-out infinite; }
@keyframes voice-speak {
  0%, 100% { transform: scale(0.96); }
  50% { transform: scale(1.08); }
}
.voice-status { font-size: 17px; color: var(--text-primary); font-weight: 500; text-align: center; }
.voice-transcript {
  font-size: 14.5px; color: var(--text-secondary); text-align: center;
  min-height: 44px; max-height: 120px; overflow-y: auto; line-height: 1.5;
}
body.voice-open { overflow: hidden; }

/* ---- Share modal ---- */
.share-link-row { display: flex; align-items: center; gap: 8px; margin-top: 14px; }
.share-link { flex: 1; min-width: 0; font-size: 12.5px; color: var(--text-secondary); }
.danger-btn { color: var(--danger); }

/* ---- Share page ---- */
.share-page { background: var(--bg-primary); min-height: 100vh; display: flex; flex-direction: column; }
.share-header {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 22px; border-bottom: 1px solid var(--border-color);
  position: sticky; top: 0; background: var(--bg-primary); z-index: 5;
}
.share-main { flex: 1; width: 100%; max-width: 820px; margin: 0 auto; padding: 26px 18px 60px; }
.share-title { font-size: 21px; font-weight: 500; color: var(--text-primary); margin-bottom: 26px; }
.share-messages { display: flex; flex-direction: column; gap: 8px; }
.share-footer {
  text-align: center; padding: 18px; font-size: 12.5px; color: var(--text-muted);
  border-top: 1px solid var(--border-color);
}

/* ---- Small screens ---- */
@media (max-width: 540px) {
  .mode-chip .chip-label { display: none; }
  .mode-chip { padding: 7px 9px; }
  .gems-row { grid-template-columns: 1fr 1fr; }
  .brand-wordmark { font-size: 18px; }
  .gem-badge { max-width: 120px; }
  .gem-badge span:last-child { display: none; }
  .voice-orb { width: 130px; height: 130px; }
  .voice-orb-core { width: 104px; height: 104px; }
}

/* v2 fixes: hidden-attribute wins; welcome content must not clip */
.gem-badge[hidden] { display: none; }
.welcome-screen { justify-content: flex-start; overflow-y: auto; padding-top: max(5vh, 20px); padding-bottom: 24px; }
.welcome-greeting { margin-top: 0; }

/* Touch devices have no hover: keep chat-row action menus always visible */
@media (hover: none) {
  .item-menu-btn { opacity: 1; }
}

/* ------------------------------------------------------------
   v3 · 3D glass & depth polish
   ------------------------------------------------------------ */
:root {
  --glass-bg: rgba(22, 24, 34, 0.68);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-highlight: rgba(255, 255, 255, 0.06);
  --shadow-pop: 0 16px 40px rgba(0, 0, 0, 0.55), 0 2px 8px rgba(0, 0, 0, 0.35);
  --shadow-soft: 0 6px 24px rgba(0, 0, 0, 0.35);
}
[data-theme="light"] {
  --glass-bg: rgba(255, 255, 255, 0.78);
  --glass-border: rgba(15, 18, 34, 0.08);
  --glass-highlight: rgba(255, 255, 255, 0.65);
  --shadow-pop: 0 16px 40px rgba(31, 36, 64, 0.16), 0 2px 8px rgba(31, 36, 64, 0.08);
  --shadow-soft: 0 6px 24px rgba(31, 36, 64, 0.10);
}

body {
  background-image:
    radial-gradient(1100px 700px at 85% -10%, rgba(124, 77, 255, 0.13), transparent 60%),
    radial-gradient(900px 620px at -10% 110%, rgba(0, 196, 180, 0.10), transparent 55%);
  background-attachment: fixed;
}
[data-theme="light"] body {
  background-image:
    radial-gradient(1100px 700px at 85% -10%, rgba(124, 77, 255, 0.07), transparent 60%),
    radial-gradient(900px 620px at -10% 110%, rgba(0, 196, 180, 0.06), transparent 55%);
}
html { scroll-behavior: smooth; }

/* --- Glass popovers & modals --- */
.attach-menu, .model-menu, .context-menu, .modal, .toast {
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(24px) saturate(1.5);
  backdrop-filter: blur(24px) saturate(1.5);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-pop), inset 0 1px 0 var(--glass-highlight);
}
@keyframes menuPop {
  from { opacity: 0; transform: translateY(6px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}
.attach-menu:not([hidden]), .model-menu:not([hidden]), .context-menu:not([hidden]) {
  animation: menuPop 0.18s cubic-bezier(0.2, 0.9, 0.3, 1.3);
}
.modal-overlay:not([hidden]) .modal { animation: menuPop 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.2); }
.modal-overlay { -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }

/* --- Composer: floating glass slab --- */
.input-box {
  border: 1px solid var(--glass-border);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  transition: box-shadow 0.25s ease, border-color 0.25s ease;
}
.input-box:focus-within {
  border-color: rgba(124, 77, 255, 0.45);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(124, 77, 255, 0.22),
              0 0 26px rgba(124, 77, 255, 0.17), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
[data-theme="light"] .input-box {
  box-shadow: 0 10px 30px rgba(31, 36, 64, 0.10), inset 0 1px 0 rgba(255, 255, 255, 0.85);
}
[data-theme="light"] .input-box:focus-within {
  box-shadow: 0 12px 36px rgba(31, 36, 64, 0.14), 0 0 0 1px rgba(124, 77, 255, 0.18),
              0 0 26px rgba(124, 77, 255, 0.10);
}

/* --- Tactile press & hover feedback --- */
.icon-btn, .mode-chip, .model-pill, .send-btn, .gem-chip, .suggestion-card,
.attach-option, .history-item, .modal-btn, .model-option, .context-menu-item {
  transition: transform 0.16s cubic-bezier(0.2, 0.8, 0.4, 1), box-shadow 0.2s ease,
              background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.icon-btn:active, .mode-chip:active, .model-pill:active, .gem-chip:active,
.attach-option:active, .modal-btn:active, .model-option:active,
.context-menu-item:active, .suggestion-card:active, .history-item:active { transform: scale(0.95); }
.send-btn:active { transform: scale(0.88); }
@media (hover: hover) {
  .gem-chip:hover, .suggestion-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-soft); }
  .send-btn:hover { filter: brightness(1.1); }
}
.send-btn {
  box-shadow: 0 4px 16px rgba(124, 77, 255, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

/* --- Glossy 3D orbs --- */
.brand-orb {
  position: relative;
  box-shadow: 0 4px 14px rgba(91, 140, 255, 0.35);
}
.welcome-orb {
  position: relative;
  box-shadow: 0 18px 50px rgba(124, 77, 255, 0.4), 0 4px 18px rgba(47, 216, 255, 0.25);
  animation: orbFloat 5s ease-in-out infinite;
}
@keyframes orbFloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

/* --- Messages: depth + entrance --- */
.user-message .message-content {
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
[data-theme="light"] .user-message .message-content { box-shadow: 0 6px 18px rgba(31, 36, 64, 0.10); }
@keyframes msgIn { from { opacity: 0; transform: translateY(8px); } }
.message-wrap { animation: msgIn 0.28s cubic-bezier(0.2, 0.8, 0.3, 1); }

/* --- Sidebar & topbar hairlines --- */
.sidebar { box-shadow: inset -1px 0 0 var(--glass-border); }
.topbar { box-shadow: 0 1px 0 var(--glass-border); }
.history-item { border: 1px solid transparent; }
.history-item.active { border-color: var(--glass-border); box-shadow: inset 0 1px 0 var(--glass-highlight); }

/* --- Mic recording pulse --- */
#mic-btn.recording {
  color: #ff5c7a;
  animation: micPulse 1.2s ease-in-out infinite;
  border-radius: 50%;
}
@keyframes micPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 92, 122, 0.45); }
  50%      { box-shadow: 0 0 0 10px rgba(255, 92, 122, 0); }
}

/* --- Voice call overlay v3 --- */
body.voice-open { overflow: hidden; }
.voice-overlay {
  background: rgba(8, 9, 14, 0.84);
  -webkit-backdrop-filter: blur(30px) saturate(1.4);
  backdrop-filter: blur(30px) saturate(1.4);
}
.voice-orb {
  width: 168px; height: 168px;
  position: relative;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.voice-orb-core {
  position: absolute; inset: 0;
  border-radius: 50%;
  background: conic-gradient(from 210deg, #00c4b4, #7c4dff, #ff6d92, #00c4b4);
  box-shadow: inset 0 -14px 30px rgba(0, 0, 0, 0.4), inset 0 10px 22px rgba(255, 255, 255, 0.25),
              0 10px 40px rgba(124, 77, 255, 0.4);
  animation: coreSpin 9s linear infinite;
}
@keyframes coreSpin { to { transform: rotate(360deg); } }
.voice-orb::before {
  content: "";
  position: absolute; left: 20%; top: 12%; width: 42%; height: 30%;
  border-radius: 50%;
  background: radial-gradient(rgba(255, 255, 255, 0.8), transparent 70%);
  filter: blur(2px);
  z-index: 2;
  pointer-events: none;
}
.voice-orb-glow {
  position: absolute; inset: -26%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(124, 77, 255, 0.38), transparent 65%);
  filter: blur(18px);
  z-index: -1;
  animation: glowPulse 3.2s ease-in-out infinite;
}
@keyframes glowPulse { 0%, 100% { opacity: 0.7; } 50% { opacity: 1; } }

.voice-overlay[data-state="listening"] .voice-orb { animation: orbBreathe 1.6s ease-in-out infinite; }
@keyframes orbBreathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.07); } }
.voice-overlay[data-state="listening"] .voice-orb::after {
  content: "";
  position: absolute; inset: -12px;
  border-radius: 50%;
  border: 2px solid rgba(0, 196, 180, 0.5);
  animation: ringPing 1.6s ease-out infinite;
}
@keyframes ringPing {
  from { transform: scale(0.92); opacity: 0.9; }
  to   { transform: scale(1.28); opacity: 0; }
}
.voice-overlay[data-state="thinking"] .voice-orb-core,
.voice-overlay[data-state="processing"] .voice-orb-core {
  animation: coreSpin 1.1s linear infinite;
  filter: saturate(0.75) brightness(0.92);
}
.voice-overlay[data-state="speaking"] .voice-orb { animation: orbTalk 0.55s ease-in-out infinite; }
@keyframes orbTalk { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }

.voice-status { font-size: 15px; letter-spacing: 0.3px; opacity: 0.85; min-height: 22px; }
.voice-transcript { max-width: 640px; font-size: 17px; opacity: 0.95; }
.voice-reply {
  max-width: 640px;
  margin-top: 10px;
  font-size: 15px;
  line-height: 1.55;
  color: rgba(255, 255, 255, 0.62);
  max-height: 28vh;
  overflow-y: auto;
  padding: 0 18px;
}
.voice-hint { margin-top: 26px; font-size: 12.5px; color: rgba(255, 255, 255, 0.38); }

/* --- Scrollbars --- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.14); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.22); }
[data-theme="light"] ::-webkit-scrollbar-thumb { background: rgba(31, 36, 64, 0.18); }

/* --- Calm mode --- */
@media (prefers-reduced-motion: reduce) {
  .voice-orb, .voice-orb-core, .voice-orb-glow, .welcome-orb, .message-wrap,
  .attach-menu, .model-menu, .context-menu, .modal { animation: none !important; }
}

/* Touch devices: message/user action bars must not be hover-gated */
@media (hover: none) {
  .message-actions, .user-actions { opacity: 1; }
}

/* ------------------------------------------------------------ Auth gate (login) ------------------------------------------------------------ */
#auth-gate {
  position: fixed;
  inset: 0;
  z-index: 320;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  overflow-y: auto;
  background:
    radial-gradient(60% 50% at 20% 10%, rgba(45, 212, 191, 0.14), transparent 60%),
    radial-gradient(55% 45% at 85% 20%, rgba(139, 92, 246, 0.16), transparent 60%),
    radial-gradient(70% 60% at 50% 100%, rgba(251, 113, 133, 0.10), transparent 65%),
    #0e0f13;
}
.auth-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  width: 100%;
  max-width: 460px;
  margin: auto;
}
.auth-orb {
  width: 88px;
  height: 88px;
  border-radius: 26px;
  position: relative;
  background: url("/static/icons/star.png") center / 88% no-repeat,
    linear-gradient(145deg, #161c38 0%, #0d1126 55%, #141b3e 100%);
  border: 1px solid rgba(139, 148, 255, 0.16);
  box-shadow: 0 8px 40px rgba(139, 92, 246, 0.4), 0 2px 14px rgba(47, 216, 255, 0.3);
  animation: authFloat 5s ease-in-out infinite;
}
@keyframes authFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-7px); }
}
.auth-title {
  margin: 18px 0 6px;
  font-size: 30px;
  font-weight: 500;
  letter-spacing: 0.4px;
  color: #e3e3e3;
}
.auth-tagline {
  margin: 0 0 22px;
  color: #9aa0a6;
  font-size: 14.5px;
  line-height: 1.5;
  max-width: 320px;
}
#clerk-mount { width: 100%; display: flex; justify-content: center; }
#auth-gate .cl-rootBox { width: auto; max-width: 100%; }
#auth-gate .cl-cardBox { width: min(400px, 94vw); box-shadow: 0 18px 60px rgba(0, 0, 0, 0.5); }
.cl-formFieldInput::placeholder { color: #6c757d; opacity: 1; }
.auth-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #9aa0a6;
  font-size: 14px;
  margin-top: 18px;
}
.auth-spin { animation: authSpin 1s linear infinite; font-size: 20px; }
@keyframes authSpin { to { transform: rotate(360deg); } }
.auth-error { margin-top: 16px; color: #e3e3e3; font-size: 14px; }
.auth-error p { margin: 0 0 12px; color: #f28b82; }
.auth-retry {
  border: none;
  cursor: pointer;
  padding: 10px 22px;
  border-radius: var(--radius-pill);
  background: linear-gradient(120deg, var(--aura-2), var(--aura-3));
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
}
.auth-retry:active { transform: scale(0.97); }
.auth-offline {
  margin-top: 16px;
  color: #e3e3e3;
  font-size: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.auth-offline-icon { font-size: 34px; color: #9aa0a6; }
.auth-offline-title { margin: 0; font-size: 16px; font-weight: 500; }
.auth-offline-hint { margin: 0; color: #9aa0a6; max-width: 280px; }

/* Light-mode auth gate */
[data-theme="light"] #auth-gate {
  background:
    radial-gradient(60% 50% at 20% 10%, rgba(45, 212, 191, 0.16), transparent 60%),
    radial-gradient(55% 45% at 85% 20%, rgba(139, 92, 246, 0.14), transparent 60%),
    radial-gradient(70% 60% at 50% 100%, rgba(251, 113, 133, 0.10), transparent 65%),
    #f6f8fd;
}
[data-theme="light"] .auth-title { color: #1f1f1f; }
[data-theme="light"] .auth-tagline { color: #575b5f; }
[data-theme="light"] #auth-gate .cl-cardBox { box-shadow: 0 18px 60px rgba(31, 36, 64, 0.18); }
[data-theme="light"] .cl-formFieldInput::placeholder { color: #80868b; }
[data-theme="light"] .auth-loading { color: #575b5f; }
[data-theme="light"] .auth-error { color: #1f1f1f; }
[data-theme="light"] .auth-error p { color: #d93025; }
[data-theme="light"] .auth-offline { color: #1f1f1f; }
[data-theme="light"] .auth-offline-icon, [data-theme="light"] .auth-offline-hint { color: #575b5f; }

/* Account row in sidebar */
.account-item { gap: 10px; }
.account-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.account-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13.5px;
}
#logout-btn { flex-shrink: 0; }
@media (prefers-reduced-motion: reduce) {
  .auth-orb, .auth-spin { animation: none; }
}

/* hidden-attribute guards (display:flex classes otherwise override [hidden]) */
#auth-gate[hidden], .auth-loading[hidden], .auth-error[hidden], .auth-offline[hidden], .account-item[hidden] { display: none; }

/* ---- Call mode v3: live camera, gadgets ---- */
#voice-camera {
  position: absolute; right: 16px; bottom: max(20px, env(safe-area-inset-bottom)); width: 132px;
  max-height: 200px; border-radius: 14px; border: 1px solid rgba(255, 255, 255, 0.22);
  object-fit: cover; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); z-index: 2; background: #000;
}
#voice-camera[hidden] { display: none; }
.translation-block {
  margin-top: 10px; padding: 8px 12px; border-left: 3px solid var(--aura-2);
  background: rgba(139, 92, 246, 0.08); border-radius: 8px; font-size: 0.95em;
}

/* ---- v3.1: system-synced theme, typography & TTS player ---- */
:root { color-scheme: dark; }
:root[data-theme="light"] { color-scheme: light; }

html, body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
.assistant-message .message-content { font-size: 15px; line-height: 1.78; letter-spacing: 0.004em; }
.assistant-message .message-content p { margin-bottom: 14px; }
.assistant-message .message-content li { margin: 6px 0; }
.user-message .message-content { font-size: 15px; line-height: 1.65; }

/* Sidebar drawer: gentle ease-out glide (no pop) */
.sidebar {
  transition: width 0.34s cubic-bezier(0.16, 1, 0.3, 1), min-width 0.34s cubic-bezier(0.16, 1, 0.3, 1),
    opacity 0.28s ease-out, transform 0.34s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Inline TTS audio player */
.tts-player {
  display: inline-flex; align-items: center; gap: 10px; margin-top: 12px;
  padding: 7px 12px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  animation: ttsIn 0.25s cubic-bezier(0.2, 0.8, 0.4, 1);
}
[data-theme="light"] .tts-player {
  background: rgba(31, 36, 64, 0.05); border-color: rgba(31, 36, 64, 0.12);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}
@keyframes ttsIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.tts-btn {
  width: 34px; height: 34px; border-radius: 50%; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, 0.08); color: var(--text-primary);
  transition: background 0.2s, transform 0.15s;
}
.tts-btn:hover { background: rgba(255, 255, 255, 0.16); }
.tts-btn:active { transform: scale(0.92); }
.tts-btn .material-icons-round { font-size: 19px; }
[data-theme="light"] .tts-btn { background: rgba(31, 36, 64, 0.08); }
[data-theme="light"] .tts-btn:hover { background: rgba(31, 36, 64, 0.15); }
.tts-bars { display: flex; align-items: flex-end; gap: 3px; height: 18px; padding-left: 2px; }
.tts-bars span {
  width: 3px; height: 6px; border-radius: 2px;
  background: linear-gradient(180deg, var(--aura-1), var(--aura-3));
}
.tts-player.playing .tts-bars span { animation: ttsBar 0.9s ease-in-out infinite; }
.tts-player.playing .tts-bars span:nth-child(2) { animation-delay: 0.15s; }
.tts-player.playing .tts-bars span:nth-child(3) { animation-delay: 0.3s; }
.tts-player.playing .tts-bars span:nth-child(4) { animation-delay: 0.45s; }
.tts-player.loading .tts-bars span { animation: ttsBar 1.4s ease-in-out infinite; opacity: 0.45; }
.tts-player.loading .tts-bars span:nth-child(2) { animation-delay: 0.2s; }
.tts-player.loading .tts-bars span:nth-child(3) { animation-delay: 0.4s; }
.tts-player.loading .tts-bars span:nth-child(4) { animation-delay: 0.6s; }
.tts-player.paused .tts-bars span { opacity: 0.5; }
@keyframes ttsBar { 0%, 100% { height: 5px; } 50% { height: 17px; } }
@media (prefers-reduced-motion: reduce) {
  .tts-bars span, .tts-player { animation: none !important; }
}

/* ------------------------------------------------------------
   v3.2 · multi-device layer: phone / iPad·tab / laptop / desktop
   ------------------------------------------------------------ */

/* Real mobile viewport height (URL bar safe) */
.app-container, .sidebar, .main-content { height: 100dvh; }

/* Notch / home-indicator safe areas */
.input-area { padding-bottom: max(16px, env(safe-area-inset-bottom)); }
@media (max-width: 900px) {
  .input-area { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .sidebar { padding-left: env(safe-area-inset-left); }
}
.voice-overlay { padding-bottom: env(safe-area-inset-bottom); }

/* Laptop (901–1280px): slimmer sidebar so chat keeps room */
@media (min-width: 901px) and (max-width: 1280px) {
  :root { --sidebar-width: 236px; }
}

/* Desktop (≥1440px): wider, airier reading column */
@media (min-width: 1440px) {
  .messages-container { max-width: 900px; }
  .input-box-wrapper { max-width: 900px; }
  .suggestion-grid { max-width: 760px; }
  .gems-block { max-width: 820px; }
  .assistant-message .message-content { font-size: 16px; }
  .user-message .message-content { font-size: 16px; }
  .message-wrap { padding: 6px 32px; }
}

/* Big tablets landscape / small laptop (901–1180px): comfortable column */
@media (min-width: 901px) and (max-width: 1180px) {
  .messages-container, .input-box-wrapper { max-width: 720px; }
}

/* Suggestion cards: 2-up on tablets, 4-up on wide desktop */
@media (min-width: 901px) and (max-width: 1180px) {
  .suggestion-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1600px) {
  .suggestion-grid { grid-template-columns: repeat(4, 1fr); max-width: 1080px; }
}

/* Coarse pointers (touch tablets): larger tap targets */
@media (pointer: coarse) {
  .icon-btn, .sidebar-item, .model-option { min-height: 44px; }
  .suggestion-card { min-height: 112px; }
}

/* Sidebar on/off toggle: when collapsed on big screens, show the topbar menu button so it can be reopened */
@media (min-width: 901px) {
  body.sidebar-collapsed .topbar-menu { display: flex; }
}

/* ---- v3.4: theme-adaptive star logo orbs ---- */
[data-theme="light"] .brand-orb,
[data-theme="light"] .auth-orb,
[data-theme="light"] .welcome-orb {
  background: url("/static/icons/star.png") center / 88% no-repeat,
    linear-gradient(145deg, #ffffff 0%, #edf1fc 58%, #e6ecfa 100%);
  border-color: rgba(31, 36, 64, 0.10);
}
[data-theme="light"] .brand-orb { box-shadow: 0 2px 10px rgba(91, 140, 255, 0.28); }
[data-theme="light"] .brand-orb.small { box-shadow: 0 2px 8px rgba(91, 140, 255, 0.24); }
[data-theme="light"] .welcome-orb { box-shadow: 0 12px 34px rgba(91, 140, 255, 0.25), 0 2px 10px rgba(168, 85, 247, 0.14); }
[data-theme="light"] .auth-orb { box-shadow: 0 12px 34px rgba(91, 140, 255, 0.25), 0 2px 10px rgba(168, 85, 247, 0.14); }

/* ---- v3.5: sidebar theme switch ---- */
.theme-switch {
  margin-left: auto;
  flex: none;
  width: 42px;
  height: 24px;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background: var(--bg-hover);
  position: relative;
  transition: background 0.25s ease, border-color 0.25s ease;
}
.theme-switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
html:not([data-theme="light"]) .theme-switch {
  background: var(--aura-grad);
  border-color: transparent;
}
html:not([data-theme="light"]) .theme-switch::after {
  transform: translateX(18px);
}
#theme-toggle:focus-visible {
  outline: 2px solid var(--aura-2);
  outline-offset: -2px;
}
@media (prefers-reduced-motion: reduce) {
  .theme-switch, .theme-switch::after { transition: none; }
}

/* ---- v3.6: Gemini-style composer & topbar account ---- */
.input-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.input-toolbar .input-tools-left { flex-wrap: wrap; padding-bottom: 0; }
.input-toolbar .input-tools-right { padding-bottom: 0; }
textarea#message-input { width: 100%; padding: 4px 6px 10px; }
.input-tools-right .voice-btn {
  width: 46px;
  height: 38px;
  border-radius: 999px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}
.input-tools-right .voice-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.input-box.has-content #mic-btn,
.input-box.has-content .voice-btn { display: none; }
.input-box:not(.has-content) .send-btn:not(.stop-mode) { display: none; }

.topbar-right { position: relative; }
.avatar-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  padding: 0;
  margin-left: 4px;
  cursor: pointer;
  overflow: hidden;
  background: var(--aura-grad);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.avatar-btn img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-btn[hidden] { display: none; }
.avatar-initial { color: #fff; font-size: 15px; font-weight: 600; text-transform: uppercase; line-height: 1; }
.avatar-initial[hidden] { display: none; }
.account-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 320;
  min-width: 250px;
  max-width: min(320px, calc(100vw - 24px));
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  box-shadow: 0 14px 44px rgba(0, 0, 0, 0.38);
  padding: 8px;
}
[data-theme="light"] .account-menu { box-shadow: 0 14px 44px rgba(31, 36, 64, 0.18); }
.account-menu[hidden] { display: none; }
.account-menu-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 6px;
}
.account-menu-head img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; flex: none; }
.avatar-initial.big {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--aura-grad);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex: none;
}
.avatar-initial.big[hidden] { display: none; }
.account-menu-idbox { display: flex; flex-direction: column; min-width: 0; }
#account-menu-name { font-size: 14px; font-weight: 500; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#account-menu-email { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 10px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 13px;
  user-select: none;
}
.account-menu-item:hover { background: var(--bg-hover); color: var(--text-primary); }
/* Owner-only stats line: informational, not clickable */
.account-menu-item.account-menu-stats { cursor: default; font-size: 12px; color: var(--text-muted); }
.account-menu-item.account-menu-stats:hover { background: none; color: var(--text-muted); }
.account-menu-item .material-icons-round { font-size: 18px; }

/* ---- v3.7: Wisp Pro (Whop subscription) ---- */
.pro-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.4px;
  border-radius: 999px;
  background: var(--aura-grad);
  color: #fff;
  vertical-align: middle;
}
body.is-premium .pro-tag { display: none; }
.pro-badge {
  margin-left: auto;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.4px;
  border-radius: 999px;
  background: var(--aura-grad);
  color: #fff;
  flex: none;
}
#account-menu-pro .material-icons-round { color: var(--accent-blue); }

.upgrade-modal { text-align: center; max-width: 340px; }
.upgrade-star {
  width: 56px;
  height: 56px;
  object-fit: contain;
  margin: 4px auto 10px;
  display: block;
  filter: drop-shadow(0 0 18px rgba(90, 120, 255, 0.45));
}
.upgrade-title { text-align: center; font-size: 20px; }
.upgrade-tagline { text-align: center; }
.upgrade-feats { display: flex; flex-direction: column; gap: 10px; margin: 14px 2px 6px; text-align: left; }
.upgrade-feat { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-secondary); }
.upgrade-feat .material-icons-round { font-size: 18px; color: var(--accent-blue); flex: none; }
.upgrade-price { margin: 10px 0 2px; color: var(--text-primary); }
.upgrade-price strong { font-size: 22px; font-weight: 600; }
.upgrade-price span { color: var(--text-muted); font-size: 13px; }
.upgrade-manage { margin: 12px 0 2px; display: flex; flex-direction: column; gap: 6px; align-items: center; }
.upgrade-status { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-primary); }
.upgrade-status .material-icons-round { font-size: 18px; color: #6fd08c; }
.upgrade-renews { font-size: 12px; color: var(--text-muted); }
.upgrade-modal .modal-actions { justify-content: center; margin-top: 14px; }
.modal-btn.danger { color: var(--accent-pink); }
.modal-btn.danger:hover { background: rgba(230, 90, 110, 0.12); }

/* ---- v3.8: Wisp Pro duration packs ---- */
.upgrade-picker { display: flex; flex-direction: column; gap: 12px; margin: 12px 0 2px; }
.upgrade-packs { display: flex; gap: 8px; justify-content: center; }
.pack-card {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 6px;
  border-radius: 14px;
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-primary);
  font-family: inherit;
  cursor: pointer;
  position: relative;
}
.pack-card.selected { border-color: var(--accent-blue); background: rgba(91, 140, 255, 0.10); }
.pack-months { font-size: 12px; color: var(--text-secondary); }
.pack-price { font-size: 15px; font-weight: 600; }
.pack-save {
  position: absolute;
  top: -8px;
  right: -4px;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--aura-grad);
  color: #fff;
}
.pack-card.best { border-color: var(--accent-blue); }
.pack-flag {
  font-size: 9px;
  font-weight: 700;
  color: var(--accent-blue);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.months-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.months-label { font-size: 12px; color: var(--text-muted); text-align: left; }
.months-stepper { display: flex; align-items: center; gap: 4px; }
.months-step {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-primary);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  font-family: inherit;
}
.months-step:hover { background: rgba(128, 128, 128, 0.12); }
.months-count { min-width: 74px; text-align: center; font-size: 13px; color: var(--text-primary); }
.upgrade-total-row { display: flex; align-items: baseline; justify-content: center; gap: 8px; }
.upgrade-total { font-size: 24px; font-weight: 600; color: var(--text-primary); }
.upgrade-once { font-size: 12px; color: var(--text-muted); }
.upgrade-hint {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  color: var(--accent-blue);
  font-family: inherit;
  padding: 0;
}

/* Offline chip — floats below the header, clean, never stacks */
.offline-chip {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 64px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 70;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  border-radius: var(--radius-pill);
  font-size: 12.5px;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  pointer-events: none;
  max-width: calc(100vw - 32px);
  white-space: nowrap;
}
.offline-chip .material-icons-round { font-size: 16px; color: var(--accent-orange); }

/* Payment trouble — dot on the sidebar Premium item + fix-it row in the Pro sheet */
.premium-alert-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-orange);
  box-shadow: 0 0 6px var(--accent-orange);
  flex: none;
}
.upgrade-payment-issue {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 12.5px;
  color: var(--text-primary);
  text-decoration: none;
  background: rgba(255, 159, 67, 0.10);
  border: 1px solid rgba(255, 159, 67, 0.28);
  text-align: left;
}
.upgrade-payment-issue > .material-icons-round { font-size: 18px; color: var(--accent-orange); }
.upgrade-payment-fix {
  color: var(--accent-blue);
  font-weight: 600;
  white-space: nowrap;
  margin-left: auto;
}
body.offline #message-input { opacity: 0.5; }

/* ---- v4: Gemini-Live style call screen + model menu thinking level ---- */
.voice-overlay {
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  padding: max(14px, env(safe-area-inset-top)) 16px max(18px, env(safe-area-inset-bottom));
}
.voice-picker-pill {
  margin: 6px auto 0;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #e8eaed; font-size: 13px; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.voice-picker-pill .material-icons-round { font-size: 18px; opacity: 0.85; }
.voice-picker-title {
  color: #e8eaed;
  font-weight: 650;
  letter-spacing: 0.01em;
  background: linear-gradient(100deg, #ffffff 10%, #9beeff 48%, #c4a7ff 88%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.voice-picker-name {
  color: #7ee7ff;
  font-weight: 650;
  padding-left: 8px;
  border-left: 1px solid rgba(255, 255, 255, 0.2);
}
.voice-picker-sheet {
  position: absolute;
  top: calc(max(14px, env(safe-area-inset-top)) + 58px);
  left: 50%; transform: translateX(-50%);
  min-width: 232px; z-index: 6;
  background: rgba(20, 22, 34, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 18px; padding: 8px;
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
  display: flex; flex-direction: column; gap: 2px;
}
.voice-picker-sheet[hidden] { display: none; }
.voice-picker-sheet button {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 12px; border-radius: 12px;
  border: none; background: transparent;
  color: #e8eaed; font-size: 14px; cursor: pointer; text-align: left;
}
.voice-picker-sheet button:hover { background: rgba(255, 255, 255, 0.07); }
.voice-opt-mark { width: 20px; text-align: center; color: #7ee7ff; }
.voice-opt-name { flex: 1; }
.voice-opt-check { font-size: 18px; visibility: hidden; }
.voice-picker-sheet button.active .voice-opt-check { visibility: visible; color: #7ee7ff; }
.voice-center { flex: 1; justify-content: center; margin: 0 auto; width: 100%; max-width: 640px; gap: 14px; }
.voice-bar {
  display: flex; align-items: center; justify-content: center;
  gap: 30px; padding: 6px 0 2px;
}
.voice-bar-btn {
  width: 54px; height: 54px; border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.07);
  color: #e8eaed; display: flex; align-items: center; justify-content: center;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.voice-bar-btn .material-icons-round { font-size: 23px; }
.voice-bar-btn:active { background: rgba(255, 255, 255, 0.14); }
#voice-cam-btn.cam-on .material-icons-round { color: #7ee7ff; }
/* the live blob sits in the bar and dances in color while Wisp talks */
.voice-orb { width: 88px; height: 88px; flex: none; }
.voice-overlay[data-state="speaking"] .voice-orb { animation: none; }
.voice-overlay[data-state="speaking"] .voice-orb-core {
  animation: blobDance 0.9s ease-in-out infinite, coreSpin 3.2s linear infinite;
}
@keyframes blobDance {
  0%, 100% { transform: scale(0.93); filter: hue-rotate(0deg) saturate(1.35) brightness(1.05); }
  33% { transform: scale(1.12); filter: hue-rotate(45deg) saturate(1.6) brightness(1.15); }
  66% { transform: scale(1.01); filter: hue-rotate(-40deg) saturate(1.5) brightness(1.1); }
}
#voice-camera {
  bottom: calc(max(18px, env(safe-area-inset-bottom)) + 88px);
}

/* Model menu: divider + thinking level section */
.model-menu-divider { height: 1px; background: var(--border-color); margin: 6px 6px; }
.model-menu-heading {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 14px 4px; font-size: 12px; color: var(--text-muted);
}
.model-menu-heading-sub { color: var(--accent-blue); font-weight: 600; }
.think-option {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 14px; border-radius: 10px; cursor: pointer;
}
.think-option:hover { background: var(--bg-hover); }
.think-option .model-check { visibility: hidden; }
.think-option.selected .model-check { visibility: visible; }

/* ---- Offline outbox (v4) ---- */
body.offline #message-input { opacity: 1; } /* typing allowed: messages queue */
.pending-wrap .user-message { opacity: 0.8; }
.pending-wrap .message-content { border: 1px dashed rgba(128, 128, 128, 0.5); }
.pending-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-secondary);
}
.pending-meta .material-icons-round { font-size: 15px; }
.pending-discard {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  cursor: pointer;
  padding: 0;
}
.pending-discard:hover { background: rgba(128, 128, 128, 0.18); }
.pending-discard .material-icons-round { font-size: 16px; }
body.offline #send-btn:not(:disabled) #send-icon { color: var(--accent-orange); }

/* Owner-only free-access granting in the account menu (v4) */
.account-menu-item.account-menu-freeaccess {
  display: block; cursor: default;
  font-size: 12px; color: var(--text-muted);
}
.account-menu-item.account-menu-freeaccess:hover { background: none; color: var(--text-muted); }
.free-access-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
#free-access-form { display: flex; gap: 6px; }
#free-access-email { flex: 1 1 90px; min-width: 0; }
#free-access-email, #free-access-plan, #free-access-add {
  font: inherit; font-size: 12px; color: var(--text-primary);
  background: transparent; border: 1px solid var(--border-color);
  border-radius: 8px; padding: 5px 8px;
}
#free-access-plan option { color: initial; background: initial; }
#free-access-add { cursor: pointer; flex-shrink: 0; }
#free-access-add:disabled { opacity: 0.6; cursor: default; }
#free-access-status { margin-top: 6px; word-break: break-word; }
#free-access-status.err { color: var(--danger); }
.free-access-row { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.free-access-who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.free-access-remove {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 15px; line-height: 1; padding: 2px 6px; border-radius: 6px;
}
.free-access-remove:hover { color: var(--danger); }

/* Owner-only price-guard alert (v4): dot on the avatar + menu detail row */
.avatar-btn { position: relative; }
.avatar-alert-dot {
  position: absolute; top: 0; right: 0; width: 10px; height: 10px;
  border-radius: 50%; background: var(--danger);
  border: 2px solid var(--bg-primary); pointer-events: none;
}
.account-menu-item.account-menu-price-alert {
  cursor: default; font-size: 12px; color: var(--danger);
  align-items: flex-start; white-space: normal; word-break: break-word;
}
.account-menu-item.account-menu-price-alert:hover { background: none; }
.account-menu-item.account-menu-price-alert .material-icons-round { font-size: 16px; margin-top: 1px; }

/* v4: outbox overview — sidebar "waiting to send" badge + cross-chat list */
.outbox-item {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 12px 10px;
  padding: 8px 14px;
  background: transparent;
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-pill);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  width: calc(100% - 24px);
  text-align: left;
  transition: background var(--transition), color var(--transition);
}
.outbox-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.outbox-item > .material-icons-round { font-size: 18px; color: var(--accent-orange); flex-shrink: 0; }
.outbox-item-label {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.outbox-count {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--accent-orange);
  color: #1f1f1f;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.outbox-modal { max-width: 420px; width: calc(100vw - 48px); }
.outbox-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 12px 0 4px;
  max-height: 50vh;
  overflow-y: auto;
}
.outbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
}
.outbox-row:hover { background: var(--bg-hover); }
.outbox-row > .material-icons-round { font-size: 18px; color: var(--accent-orange); flex-shrink: 0; }
.outbox-row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.outbox-row-title {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.outbox-row-snippet {
  font-size: 13px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.outbox-row-discard { width: 32px; height: 32px; }
.outbox-row-discard .material-icons-round { font-size: 18px; }
