* {
  box-sizing: border-box;
  font-family: system-ui, sans-serif;
}

/* Accessibility: label for form field (removes "No label associated" console warning) */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

html {
  height: 100%;
}

:root {
  --focus-primary: #00b4ff;
  --focus-secondary: #00ecbc;
  --focus-accent: #00c8ff;
  --focus-bg-start: #0a192f;
  --focus-bg-end: #02060a;
  --focus-text: #e6fbff;
  --focus-text-soft: #94a3b8;
  /* UI quality bar: spacing rhythm, premium minimal */
  --focus-space-xs: 4px;
  --focus-space-sm: 8px;
  --focus-space-md: 16px;
  --focus-space-lg: 24px;
  --focus-space-xl: 32px;
  --focus-font-size-base: 1rem;
  --focus-line-height: 1.5;
}

body {
  margin: 0;
  min-width: 320px; /* mobile-first safe */
  background: radial-gradient(circle at top, var(--focus-bg-start), var(--focus-bg-end));
  color: var(--focus-text);
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Header */
.header {
  height: 48px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

/* AI0 Logo Mark: 1:1, no stretch, safe padding (>=12% canvas) */
.logo-mark {
  width: 32px;
  height: 32px;
  object-fit: contain;
  flex-shrink: 0;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  opacity: 1;
  transition: opacity 0.3s ease, background 0.3s ease;
}
.dot.dot-loading {
  background: #f59e0b !important;
  animation: dotPulseBlue 1.2s ease-in-out infinite;
}
.dot.dot-ready {
  background: #22c55e !important;
}
.dot.dot-cloud {
  background: #0ff !important;
}
.dot.thinking {
  animation: dotPulseBlue 1.2s ease-in-out infinite;
}
@keyframes dotPulseBlue {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.icon-btn {
  background: none;
  border: none;
  color: var(--focus-text-soft);
  font-size: 18px;
  cursor: pointer;
  padding: 8px;
}

.icon-btn:hover {
  color: var(--focus-accent);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.header-actions-settings {
  margin-left: auto;
}

/* Core */
.core-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 0;
}

.core {
  width: 220px;
  height: 220px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  letter-spacing: 2px;
  background: rgba(0, 180, 255, 0.06);
  box-shadow:
    0 0 50px rgba(0, 180, 255, 0.45),
    0 0 80px rgba(0, 180, 255, 0.2),
    inset 0 0 30px rgba(0, 180, 255, 0.2);
  transition: box-shadow 0.4s ease;
}

.core.active {
  box-shadow:
    0 0 60px rgba(0, 220, 255, 0.8),
    inset 0 0 30px rgba(0, 220, 255, 0.4);
}

.stage-subtitle {
  font-size: 14px;
  color: var(--focus-text-soft);
  max-width: 280px;
  text-align: center;
  line-height: 1.4;
  margin-top: 12px;
}

/* Quick/Deep/Write + Private mode */
.input-modes {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 8px 16px;
  flex-wrap: wrap;
  border-top: 1px solid rgba(0, 180, 255, 0.1);
}

.quick-deep-toggle {
  display: flex;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(0, 180, 255, 0.3);
}

.quick-deep-btn {
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 500;
  border: none;
  background: rgba(0, 180, 255, 0.08);
  color: var(--focus-text-soft);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.quick-deep-btn:not(:last-child) {
  border-right: 1px solid rgba(0, 180, 255, 0.3);
}

.quick-deep-btn:hover {
  background: rgba(0, 180, 255, 0.15);
  color: var(--focus-text);
}

.quick-deep-btn.active {
  background: var(--focus-primary);
  color: #001018;
}

.private-mode-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--focus-text-soft);
  cursor: pointer;
}

.private-mode-toggle input {
  margin: 0;
}

/* Try this buttons — shown when chat empty */
.try-this-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 16px;
  justify-content: center;
  align-items: center;
  max-width: min(900px, 95vw);
  margin: 0 auto;
  border-top: 1px solid rgba(0, 180, 255, 0.15);
}

.try-this-wrap.hidden {
  display: none;
}

.try-this-btn {
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 10px;
  border: 1px solid rgba(0, 180, 255, 0.4);
  background: rgba(0, 180, 255, 0.08);
  color: var(--focus-text);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
  white-space: nowrap;
}

.try-this-btn:hover {
  background: rgba(0, 180, 255, 0.18);
  border-color: var(--focus-primary);
  transform: translateY(-1px);
}

.try-this-btn:active {
  transform: translateY(0);
}

.try-this-btn:focus {
  outline: none;
  box-shadow: 0 0 0 2px var(--focus-primary);
}

/* Chat — مكان عرض الرسائل (Output). Always visible and scrollable (منع الشاشة الفاضية) */
.chat {
  flex: 1;
  min-height: 0;
  max-width: 900px;
  margin: 0 auto;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat:empty {
  display: flex;
  min-height: 80px;
}

/* P1: relative so .msg-actions can be absolute and not take layout space */
.msg {
  position: relative !important;
  transform: none !important;
  width: fit-content;
  max-width: min(760px, 85%);
  padding: 10px 14px;
  border-radius: 14px;
  margin-bottom: 10px;
  font-size: 14px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg.user {
  background: linear-gradient(135deg, var(--focus-primary), var(--focus-secondary));
  color: #001018;
  margin-left: auto;
  align-self: flex-end;
}

.msg.ai {
  align-self: flex-start;
  background: rgba(255,255,255,0.08);
  color: var(--focus-text);
  border: 1px solid rgba(255,255,255,0.12);
}

/* Meta badges — Direct, Vision, Web, Planned, Verified */
.msg-meta-badges {
  font-size: 10px;
  opacity: 0.7;
  margin-bottom: 6px;
  color: var(--focus-text-soft);
}

/* P0 single-submit bubbles (initChat uses msg-user / msg-assistant) */
.msg-user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--focus-primary), var(--focus-secondary));
  color: #001018;
}
.msg-assistant {
  align-self: flex-start;
  background: rgba(255,255,255,0.08);
  color: var(--focus-text);
  border: 1px solid rgba(255,255,255,0.12);
}

/* Input */
.input-bar {
  height: 56px;
  display: flex;
  padding: 8px;
  gap: 8px;
}

.input-bar input {
  flex: 1;
  background: rgba(0,0,0,0.35);
  border: 1px solid var(--focus-primary);
  border-radius: 10px;
  color: var(--focus-text);
  padding: 0 12px;
  font-size: 16px;
}

.input-bar input:focus {
  outline: none;
  border-color: var(--focus-accent);
}

.input-bar input::placeholder {
  color: var(--focus-text-soft);
  opacity: 0.6;
}

.input-bar button {
  width: 56px;
  border-radius: 10px;
  border: none;
  background: var(--focus-primary);
  color: #001018;
  font-size: 18px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.input-bar #stopBtn {
  background: rgba(239, 68, 68, 0.3);
  color: #fca5a5;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
}
.input-bar #stopBtn:hover {
  background: rgba(239, 68, 68, 0.5);
}

/* Attachment preview — thumbnails for images */
#attachPreview,
#attachment-preview {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
  align-items: center;
}

#attachPreview:not(.hidden) img,
.attachment-thumb {
  width: 88px;
  height: 88px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.input-bar button:hover {
  background: var(--focus-accent);
}

.input-bar button:active {
  background: var(--focus-secondary);
}

/* History */
.history {
  position: fixed;
  right: 0;
  top: 0;
  width: 240px;
  height: 100%;
  background: var(--focus-bg-end);
  padding: 16px;
  border-left: 1px solid var(--focus-primary);
  z-index: 100;
}

.history h3 {
  margin: 0 0 16px 0;
  color: var(--focus-text-soft);
  font-size: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.close-panel {
  background: none;
  border: none;
  color: var(--focus-text-soft);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  border-radius: 4px;
}

.close-panel:hover {
  color: var(--focus-accent);
  background: rgba(255,255,255,0.1);
}

.history button {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--focus-primary);
  color: var(--focus-text);
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  width: 100%;
}

.history button:hover {
  background: rgba(0, 0, 0, 0.4);
  border-color: var(--focus-accent);
}

.history #newChatBtn {
  background: linear-gradient(135deg, var(--focus-primary), var(--focus-secondary));
  color: #001018;
  font-weight: 600;
  border: none;
}

.history #newChatBtn:hover {
  opacity: 0.9;
}

/* Chat item hover effect */
.chat-item:hover {
  background: rgba(0, 180, 255, 0.15) !important;
  border-color: var(--focus-accent) !important;
}

.delete-chat-btn:hover {
  background: rgba(255,77,77,1) !important;
}

/* P0: Strict separation — .msg-body text only, .msg-actions buttons only */
.msg-body,
.msg-content {
  flex: 1;
}

/* P1: Action buttons — hidden by default; hover shows real buttons only (no raw HTML). No layout space when hidden. */
.msg-actions {
  position: absolute;
  right: 4px;
  bottom: 4px;
  display: none !important;
  gap: 4px;
  pointer-events: none;
}
.msg:hover .msg-actions {
  display: flex !important;
  pointer-events: auto;
}

.msg-action-btn {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  color: var(--focus-text-soft);
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.msg-action-btn:hover {
  background: rgba(255,255,255,0.2);
  color: var(--focus-accent);
  border-color: var(--focus-accent);
}

.msg-action-btn svg {
  display: block;
}

/* Markdown styling in messages */
.msg-body pre,
.msg-content pre {
  background: rgba(0,0,0,0.3);
  padding: 12px;
  border-radius: 6px;
  overflow-x: auto;
  margin: 8px 0;
}

.msg-body code,
.msg-content code {
  background: rgba(0,0,0,0.3);
  padding: 2px 6px;
  border-radius: 3px;
  font-family: 'Courier New', monospace;
  font-size: 13px;
}

.msg-body pre code,
.msg-content pre code {
  background: none;
  padding: 0;
}

/* Code blocks: dark box, file label, copy button, scroll if long */
.ai0-code-block {
  margin: 12px 0;
  padding: 0;
  background: #0d1117;
  border: 1px solid rgba(0, 180, 255, 0.4);
  border-radius: 12px;
  overflow: hidden;
  user-select: text;
  -webkit-user-select: text;
  position: relative;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.ai0-code-header {
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 600;
  color: rgba(174, 212, 255, 0.9);
  background: rgba(0, 0, 0, 0.3);
  border-bottom: 1px solid rgba(0, 180, 255, 0.25);
  font-family: 'Consolas', 'Monaco', monospace;
}
.ai0-code-header:empty { display: none; }
.ai0-code-copy-btn {
  position: absolute;
  top: 6px;
  right: 10px;
  padding: 4px 8px;
  font-size: 13px;
  background: rgba(0, 180, 255, 0.2);
  border: 1px solid rgba(0, 180, 255, 0.5);
  border-radius: 4px;
  color: var(--focus-text, #e6fbff);
  cursor: pointer;
  opacity: 0.85;
}
.ai0-code-copy-btn:hover {
  opacity: 1;
  background: rgba(0, 180, 255, 0.3);
}
.ai0-code-block .ai0-code-pre {
  margin: 0;
  padding: 14px 16px;
  background: none !important;
  overflow: auto;
  max-height: 420px;
  border-radius: 0 0 12px 12px;
}
.ai0-code-block .ai0-code-pre code {
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.5;
  color: #c9d1d9;
}

.msg-body p,
.msg-content p {
  margin: 8px 0;
}

.msg-body ul, .msg-body ol,
.msg-content ul, .msg-content ol {
  margin: 8px 0;
  padding-left: 24px;
}

.msg-body blockquote,
.msg-content blockquote {
  border-left: 3px solid var(--focus-accent);
  padding-left: 12px;
  margin: 8px 0;
  opacity: 0.8;
}

.msg-body h1, .msg-body h2, .msg-body h3,
.msg-content h1, .msg-content h2, .msg-content h3 {
  margin: 12px 0 8px 0;
  color: var(--focus-accent);
}

.msg-body a,
.msg-content a {
  color: var(--focus-accent);
  text-decoration: underline;
}

.msg-body table,
.msg-content table {
  border-collapse: collapse;
  margin: 8px 0;
  width: 100%;
}

.msg-body th, .msg-body td,
.msg-content th, .msg-content td {
  border: 1px solid rgba(255,255,255,0.2);
  padding: 6px 12px;
  text-align: left;
}

.msg-body th,
.msg-content th {
  background: rgba(0,0,0,0.3);
  font-weight: 600;
}

/* Search input focus */
#searchChats:focus {
  outline: none;
  border-color: var(--focus-accent);
}

.hidden {
  display: none;
}

/* Settings Panel */
.settings {
  position: fixed;
  right: 0;
  top: 0;
  width: 300px;
  height: 100%;
  background: var(--focus-bg-end);
  padding: 16px;
  padding-bottom: 32px;
  border-left: 1px solid var(--focus-primary);
  box-shadow: -20px 0 40px rgba(0,0,0,0.6);
  z-index: 200;
  overflow-y: auto;
  overflow-x: hidden;
}

.settings h3 {
  margin: 0 0 20px 0;
  color: var(--focus-text-soft);
  font-size: 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.setting {
  margin-bottom: 20px;
  font-size: 14px;
}

/* Settings section headers */
.settings-section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--focus-text-soft);
  margin: 20px 0 10px 0;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.settings-section-title:first-of-type { margin-top: 0; }

/* Settings links (Docs & Tools section) */
.settings-link {
  display: block;
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 6px;
  border-radius: 6px;
  background: rgba(0,0,0,0.25);
  border: 1px solid rgba(255,255,255,0.06);
  color: var(--focus-primary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s;
}
.settings-link:hover {
  background: rgba(0,0,0,0.4);
  border-color: var(--focus-primary);
}

/* Personality & Pace */
.personality-vibe {
  font-size: 13px;
  color: var(--focus-text-soft, rgba(255,255,255,0.75));
  margin: 0 0 12px 0;
  padding: 8px 0;
  border-bottom: 1px solid rgba(0,180,255,0.2);
}
.personality-slider-wrap { margin-bottom: 14px; }
.personality-slider-wrap label { display: block; font-weight: 600; margin-bottom: 2px; }
.personality-hint {
  display: block;
  font-size: 11px;
  color: var(--focus-text-soft, rgba(255,255,255,0.6));
  margin-bottom: 4px;
}

/* Easter egg: Haydi Tamayel — barely visible, reveals on hover */
.settings-ghost {
  display: block;
  margin-top: 24px;
  padding-bottom: 8px;
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--focus-text-soft, rgba(255,255,255,0.12));
  opacity: 0.2;
  transition: opacity 0.3s;
}
.settings-ghost:hover {
  opacity: 0.6;
  color: var(--focus-accent, rgba(0,200,255,0.5));
}

.setting label {
  display: block;
  margin-bottom: 8px;
  color: var(--focus-text-soft);
  font-weight: 500;
}

.setting label input[type="checkbox"] {
  margin-right: 8px;
  margin-left: 0;
}

.settings select {
  width: 100%;
  background: rgba(0,0,0,0.4);
  border: 1px solid var(--focus-primary);
  border-radius: 6px;
  color: var(--focus-text);
  padding: 8px 12px;
  font-size: 14px;
  cursor: pointer;
  appearance: auto; /* Ensure native dropdown appears */
  -webkit-appearance: menulist; /* For WebKit browsers */
  -moz-appearance: menulist; /* For Firefox */
  z-index: 1000; /* Ensure dropdown appears above other elements */
  position: relative;
}

.settings select:focus {
  outline: none;
  border-color: var(--focus-accent);
  box-shadow: 0 0 0 2px rgba(0, 180, 255, 0.2);
}

/* Ensure dropdown options are visible */
.settings select option {
  background: rgba(10, 26, 36, 0.95);
  color: var(--focus-text);
  padding: 8px;
}

.settings select optgroup {
  background: rgba(0, 180, 255, 0.1);
  color: var(--focus-accent);
  font-weight: 600;
  padding: 4px 8px;
}

.settings select optgroup option {
  background: rgba(0,0,0,0.6);
  color: var(--focus-text);
  padding-left: 20px;
}

.danger {
  margin-top: 32px;
  margin-bottom: 16px;
  background: #ff4d4d;
  border: none;
  padding: 12px;
  width: 100%;
  border-radius: 8px;
  color: white;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.2s ease;
}

.danger:hover {
  background: #ff6666;
}

/* Focus Mode Theme Customizer */
.focus-theme-customizer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.focus-color-picker {
  display: flex;
  align-items: center;
  gap: 8px;
}

.focus-color-picker label {
  min-width: 60px;
  font-size: 12px;
  margin: 0;
}

.focus-color-picker input[type="color"] {
  width: 50px;
  height: 32px;
  border: 2px solid var(--focus-primary);
  border-radius: 6px;
  cursor: pointer;
  background: transparent;
  padding: 2px;
}

.focus-color-picker input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

.focus-color-picker input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 4px;
}

.focus-apply-btn,
.focus-reset-btn {
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  margin-top: 4px;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.focus-apply-btn {
  background: linear-gradient(135deg, var(--focus-primary), var(--focus-secondary));
  color: #001018;
}

.focus-apply-btn:hover {
  opacity: 0.9;
}

.focus-reset-btn {
  background: rgba(255,255,255,0.1);
  color: var(--focus-text);
  border: 1px solid var(--focus-primary);
}

.focus-reset-btn:hover {
  background: rgba(255,255,255,0.15);
}

/* Keep style: just size + active state, no theme break */
.input-bar #micBtn svg {
  width: 18px;
  height: 18px;
}

/* Lucide uses currentColor */
.input-bar #micBtn {
  color: var(--focus-accent);
}

/* When listening */
.input-bar #micBtn.active {
  outline: 2px solid var(--focus-accent);
  outline-offset: 2px;
}

/* Speak button (TTS) - same style as mic */
.input-bar #speakBtn svg {
  width: 18px;
  height: 18px;
}

.input-bar #speakBtn {
  color: var(--focus-accent);
}

.input-bar #speakBtn.active {
  outline: 2px solid var(--focus-accent);
  outline-offset: 2px;
}

/* Use Last Image button */
.input-bar #useLastImageBtn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: none;
  background: rgba(0, 180, 255, 0.1);
  color: var(--focus-accent);
  font-size: 18px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.input-bar #useLastImageBtn:hover {
  background: rgba(0, 180, 255, 0.2);
  transform: scale(1.05);
}

.input-bar #useLastImageBtn:active {
  transform: scale(0.95);
}

/* =========================
   Day / Night Theme (data-theme="day" | "night")
   Drop-in: fixes washed-out day mode, keeps blue night mode.
   ========================= */

body[data-theme="day"],
body[data-theme="night"] {
  transition: background 240ms ease, color 240ms ease, border-color 240ms ease;
}

/* Day: darker text, white chips, stronger borders, readable */
body[data-theme="day"] {
  background: linear-gradient(180deg, #fafcff 0%, #f5f9ff 100%) !important;
  color: #334155 !important;
}

body[data-theme="day"] .stage-subtitle,
body[data-theme="day"] .private-mode-toggle,
body[data-theme="day"] .muted,
body[data-theme="day"] .personality-hint {
  color: #64748b !important;
}

body[data-theme="day"] .try-this-btn {
  background: rgba(255, 255, 255, 0.92) !important;
  color: #334155 !important;
  border: 1px solid rgba(148, 163, 184, 0.20) !important;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}

body[data-theme="day"] .try-this-btn:hover {
  border-color: rgba(96, 165, 250, 0.35) !important;
  transform: translateY(-1px);
}

body[data-theme="day"] .core {
  background: radial-gradient(circle at 35% 30%, #ffffff 0%, #f5f9ff 48%, #eef6fc 100%) !important;
  border: 1px solid rgba(148, 163, 184, 0.22) !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.6),
    0 0 0 8px rgba(96, 165, 250, 0.04),
    0 8px 24px rgba(15, 23, 42, 0.06) !important;
}

body[data-theme="day"] .core span {
  color: #334155 !important;
}

body[data-theme="day"] .input-modes,
body[data-theme="day"] .input-bar,
body[data-theme="day"] .icon-btn,
body[data-theme="day"] .quick-deep-toggle {
  background: rgba(255, 255, 255, 0.70) !important;
  border-color: rgba(148, 163, 184, 0.18) !important;
}

body[data-theme="day"] .quick-deep-btn {
  background: transparent !important;
  color: #64748b !important;
}

body[data-theme="day"] .quick-deep-btn.active {
  background: rgba(59, 130, 246, 0.85) !important;
  color: white !important;
}

body[data-theme="day"] .focus-reset-btn {
  background: rgba(255, 255, 255, 0.8) !important;
  border: 1px solid rgba(148, 163, 184, 0.22) !important;
  color: #475569 !important;
}

body[data-theme="day"] .focus-reset-btn:hover {
  background: rgba(255, 255, 255, 0.95) !important;
}

body[data-theme="day"] .input-bar input,
body[data-theme="day"] textarea {
  background: rgba(255, 255, 255, 0.92) !important;
  color: #334155 !important;
}

body[data-theme="day"] .input-bar input::placeholder,
body[data-theme="day"] textarea::placeholder {
  color: #64748b !important;
}

body[data-theme="day"] .header {
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
}

body[data-theme="day"] .msg.user {
  background: linear-gradient(135deg, #2f80ed, #60a5fa) !important;
  color: white !important;
}

body[data-theme="day"] .msg.msg-assistant,
body[data-theme="day"] .msg.ai {
  background: rgba(255, 255, 255, 0.9) !important;
  color: #0f172a !important;
  border: 1px solid rgba(148, 163, 184, 0.2) !important;
}

/* Night: keep blue mode (default dark) */
body[data-theme="night"] {
  background: radial-gradient(circle at top, #0a1630, #06111f) !important;
  color: #eff6ff !important;
}

/* =========================
   Pure White Theme (data-theme="white")
   ========================= */

[data-theme="white"] {
  /* Backgrounds */
  --bg: #ffffff;
  --panel: #ffffff;
  --panel-2: #ffffff;

  /* Text */
  --text: #0b1220;
  --text-2: #1f2a3a;
  --muted: #526074;

  /* Borders */
  --border: rgba(11, 18, 32, 0.10);
  --border-2: rgba(11, 18, 32, 0.06);

  /* AI0 identity accent (blue ring) */
  --accent: #0ea5e9;
  --accent-2: #38bdf8;
  --accent-soft: rgba(14,165,233,0.10);

  /* Shadows (very light to keep "clean") */
  --shadow-soft: 0 10px 30px rgba(2, 6, 23, 0.08);

  /* Chat bubbles */
  --bubble-ai: #ffffff;
  --bubble-ai-border: rgba(11,18,32,0.10);

  --bubble-user: rgba(14,165,233,0.10);
  --bubble-user-border: rgba(14,165,233,0.22);

  /* Focus glow */
  --glow: 0 0 0 6px rgba(14,165,233,0.10);
}

/* App base */
[data-theme="white"] body,
[data-theme="white"] .app {
  background: var(--bg);
  color: var(--text);
}

/* Body background */
body[data-theme="white"] {
  background: #ffffff;
  color: var(--text);
}

/* Containers */
[data-theme="white"] .panel,
[data-theme="white"] .chat-shell,
body[data-theme="white"] .header,
body[data-theme="white"] .main,
body[data-theme="white"] .settings,
body[data-theme="white"] .history {
  background: var(--panel);
  border-color: var(--border);
  box-shadow: var(--shadow-soft);
}

/* Messages */
body[data-theme="white"] .msg.ai {
  background: var(--bubble-ai);
  border: 1px solid var(--bubble-ai-border);
  color: var(--text);
}

body[data-theme="white"] .msg.user {
  background: var(--bubble-user);
  border: 1px solid var(--bubble-user-border);
  color: var(--text);
}

/* Inputs */
body[data-theme="white"] input,
body[data-theme="white"] textarea {
  background: #ffffff;
  border: 1px solid var(--border);
  color: var(--text);
}

body[data-theme="white"] input:focus,
body[data-theme="white"] textarea:focus {
  border-color: rgba(14,165,233,0.55);
  box-shadow: var(--glow);
}

/* Buttons */
body[data-theme="white"] .btn,
body[data-theme="white"] .icon-btn,
body[data-theme="white"] .try-this-btn {
  background: #ffffff;
  border: 1px solid var(--border);
  color: var(--text);
}

body[data-theme="white"] .focus-reset-btn {
  background: rgba(11, 18, 32, 0.06);
  border: 1px solid var(--border);
  color: var(--text);
}

body[data-theme="white"] .focus-reset-btn:hover {
  background: rgba(11, 18, 32, 0.10);
}

body[data-theme="white"] .btn.primary,
body[data-theme="white"] #sendBtn {
  background: linear-gradient(135deg, rgba(14,165,233,0.98), rgba(56,189,248,0.98));
  border: 1px solid rgba(14,165,233,0.30);
  color: #fff;
}

/* Big ring (keeps AI0 identity) */
body[data-theme="white"] .core {
  background: radial-gradient(circle at 50% 50%,
    rgba(14,165,233,0.18),
    rgba(14,165,233,0.05) 55%,
    transparent 72%);
  border: 1px solid rgba(14,165,233,0.28);
  box-shadow:
    0 0 0 10px rgba(14,165,233,0.06),
    0 18px 50px rgba(2, 6, 23, 0.08);
  color: var(--text);
}

/* Header adjustments */
body[data-theme="white"] .header {
  border-bottom: 1px solid var(--border);
}

body[data-theme="white"] .dot {
  background: var(--accent);
}

/* Settings panel */
body[data-theme="white"] .settings {
  border-left: 1px solid var(--border);
}

body[data-theme="white"] .settings select {
  background: #ffffff;
  border: 1px solid var(--border);
  color: var(--text);
}

body[data-theme="white"] .settings select option {
  background: #ffffff;
  color: var(--text);
}

/* History panel */
body[data-theme="white"] .history {
  border-left: 1px solid var(--border);
}

body[data-theme="white"] .history button {
  background: #ffffff;
  border: 1px solid var(--border);
  color: var(--text);
}

body[data-theme="white"] .history button:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

/* Input bar */
body[data-theme="white"] .input-bar {
  border-top: 1px solid var(--border);
  background: var(--panel);
}

body[data-theme="white"] .input-bar input {
  background: #ffffff;
  border: 1px solid var(--border);
  color: var(--text);
}

body[data-theme="white"] .input-bar input::placeholder {
  color: var(--muted);
}

/* Message actions */
body[data-theme="white"] .msg-action-btn {
  background: rgba(11, 18, 32, 0.05);
  border: 1px solid var(--border);
  color: var(--text-2);
}

body[data-theme="white"] .msg-action-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

/* Code blocks */
body[data-theme="white"] .msg-content pre {
  background: rgba(11, 18, 32, 0.05);
  border: 1px solid var(--border);
}

body[data-theme="white"] .msg-content code {
  background: rgba(11, 18, 32, 0.05);
  border: 1px solid var(--border);
}

/* Links */
body[data-theme="white"] .msg-content a {
  color: var(--accent);
}

/* Tables */
body[data-theme="white"] .msg-content th,
body[data-theme="white"] .msg-content td {
  border: 1px solid var(--border);
}

body[data-theme="white"] .msg-content th {
  background: rgba(11, 18, 32, 0.05);
}

/* =========================
   Pure White by Time (data-theme="white-auto")
   Copy of Pure White - applied automatically by userDateTime (day=white, night=dark)
   Backup: original "white" stays manual in case auto breaks
   ========================= */
[data-theme="white-auto"],
body[data-theme="white-auto"],
[data-theme="white-auto"] body,
[data-theme="white-auto"] .app,
[data-theme="white-auto"] .panel,
[data-theme="white-auto"] .chat-shell,
body[data-theme="white-auto"] .header,
body[data-theme="white-auto"] .main,
body[data-theme="white-auto"] .settings,
body[data-theme="white-auto"] .history,
body[data-theme="white-auto"] .msg.ai,
body[data-theme="white-auto"] .msg.user,
body[data-theme="white-auto"] input,
body[data-theme="white-auto"] textarea,
body[data-theme="white-auto"] .btn,
body[data-theme="white-auto"] .icon-btn,
body[data-theme="white-auto"] .btn.primary,
body[data-theme="white-auto"] #sendBtn,
body[data-theme="white-auto"] .core,
body[data-theme="white-auto"] .dot,
body[data-theme="white-auto"] .settings select,
body[data-theme="white-auto"] .settings select option,
body[data-theme="white-auto"] .history button,
body[data-theme="white-auto"] .input-bar,
body[data-theme="white-auto"] .input-bar input,
body[data-theme="white-auto"] .msg-action-btn,
body[data-theme="white-auto"] .msg-content pre,
body[data-theme="white-auto"] .msg-content code,
body[data-theme="white-auto"] .msg-content a,
body[data-theme="white-auto"] .msg-content th,
body[data-theme="white-auto"] .msg-content td {
  /* Same as Pure White - use same CSS variables */
}
[data-theme="white-auto"] {
  --bg: #ffffff;
  --panel: #ffffff;
  --panel-2: #ffffff;
  --text: #0b1220;
  --text-2: #1f2a3a;
  --muted: #526074;
  --border: rgba(11, 18, 32, 0.10);
  --border-2: rgba(11, 18, 32, 0.06);
  --accent: #0ea5e9;
  --accent-2: #38bdf8;
  --accent-soft: rgba(14,165,233,0.10);
  --shadow-soft: 0 10px 30px rgba(2, 6, 23, 0.08);
  --bubble-ai: #ffffff;
  --bubble-ai-border: rgba(11,18,32,0.10);
  --bubble-user: rgba(14,165,233,0.10);
  --bubble-user-border: rgba(14,165,233,0.22);
  --glow: 0 0 0 6px rgba(14,165,233,0.10);
}
[data-theme="white-auto"] body,
[data-theme="white-auto"] .app { background: var(--bg); color: var(--text); }
body[data-theme="white-auto"] { background: #ffffff; color: var(--text); }
[data-theme="white-auto"] .panel,
[data-theme="white-auto"] .chat-shell,
body[data-theme="white-auto"] .header,
body[data-theme="white-auto"] .main,
body[data-theme="white-auto"] .settings,
body[data-theme="white-auto"] .history {
  background: var(--panel); border-color: var(--border); box-shadow: var(--shadow-soft);
}
body[data-theme="white-auto"] .msg.ai {
  background: var(--bubble-ai); border: 1px solid var(--bubble-ai-border); color: var(--text);
}
body[data-theme="white-auto"] .msg.user {
  background: var(--bubble-user); border: 1px solid var(--bubble-user-border); color: var(--text);
}
body[data-theme="white-auto"] input,
body[data-theme="white-auto"] textarea {
  background: #ffffff; border: 1px solid var(--border); color: var(--text);
}
body[data-theme="white-auto"] input:focus,
body[data-theme="white-auto"] textarea:focus {
  border-color: rgba(14,165,233,0.55); box-shadow: var(--glow);
}
body[data-theme="white-auto"] .btn,
body[data-theme="white-auto"] .icon-btn,
body[data-theme="white-auto"] .try-this-btn {
  background: #ffffff; border: 1px solid var(--border); color: var(--text);
}

body[data-theme="white-auto"] .focus-reset-btn {
  background: rgba(11, 18, 32, 0.06);
  border: 1px solid var(--border);
  color: var(--text);
}

body[data-theme="white-auto"] .focus-reset-btn:hover {
  background: rgba(11, 18, 32, 0.10);
}
body[data-theme="white-auto"] .btn.primary,
body[data-theme="white-auto"] #sendBtn {
  background: linear-gradient(135deg, rgba(14,165,233,0.98), rgba(56,189,248,0.98));
  border: 1px solid rgba(14,165,233,0.30); color: #fff;
}
body[data-theme="white-auto"] .core {
  background: radial-gradient(circle at 50% 50%, rgba(14,165,233,0.18), rgba(14,165,233,0.05) 55%, transparent 72%);
  border: 1px solid rgba(14,165,233,0.28);
  box-shadow: 0 0 0 10px rgba(14,165,233,0.06), 0 18px 50px rgba(2, 6, 23, 0.08);
  color: var(--text);
}
body[data-theme="white-auto"] .header { border-bottom: 1px solid var(--border); }
body[data-theme="white-auto"] .dot { background: var(--accent); }
body[data-theme="white-auto"] .settings { border-left: 1px solid var(--border); }
body[data-theme="white-auto"] .settings select {
  background: #ffffff; border: 1px solid var(--border); color: var(--text);
}
body[data-theme="white-auto"] .settings select option { background: #ffffff; color: var(--text); }
body[data-theme="white-auto"] .history { border-left: 1px solid var(--border); }
body[data-theme="white-auto"] .history button {
  background: #ffffff; border: 1px solid var(--border); color: var(--text);
}
body[data-theme="white-auto"] .history button:hover {
  background: var(--accent-soft); border-color: var(--accent);
}
body[data-theme="white-auto"] .input-bar {
  border-top: 1px solid var(--border); background: var(--panel);
}
body[data-theme="white-auto"] .input-bar input {
  background: #ffffff; border: 1px solid var(--border); color: var(--text);
}
body[data-theme="white-auto"] .input-bar input::placeholder { color: var(--muted); }
body[data-theme="white-auto"] .msg-action-btn {
  background: rgba(11, 18, 32, 0.05); border: 1px solid var(--border); color: var(--text-2);
}
body[data-theme="white-auto"] .msg-action-btn:hover {
  background: var(--accent-soft); border-color: var(--accent); color: var(--accent);
}
body[data-theme="white-auto"] .msg-content pre,
body[data-theme="white-auto"] .msg-content code {
  background: rgba(11, 18, 32, 0.05); border: 1px solid var(--border);
}
body[data-theme="white-auto"] .msg-content a { color: var(--accent); }
body[data-theme="white-auto"] .msg-content th,
body[data-theme="white-auto"] .msg-content td { border: 1px solid var(--border); }
body[data-theme="white-auto"] .msg-content th { background: rgba(11, 18, 32, 0.05); }

/* 🎤 GPT-style Microphone Animations */
@keyframes pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.7;
    transform: scale(1.05);
  }
}

#micBtn.active {
  animation: pulse 1.5s ease-in-out infinite !important;
  box-shadow: 0 0 20px rgba(14, 165, 233, 0.6) !important;
}

#listeningIndicator {
  animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translate(-50%, -60%);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%);
  }
}
