* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #0c0c0e;
  --surface: #161618;
  --surface-2: #1e1e21;
  --border: #2a2a2e;
  --text: #e8e8ed;
  --text-muted: #8e8e96;
  --accent: #6c5ce7;
  --accent-glow: rgba(108, 92, 231, 0.25);
  --green: #2ecc71;
  --bubble-bot: #1e1e24;
  --bubble-user: #6c5ce7;
  --radius: 12px;
  --sidebar-w: 280px;
  --theme-intensity: 1;
  --msg-rate: 1;
}

:root[data-theme="light"] {
  --bg: #f5f5f8;
  --surface: #ffffff;
  --surface-2: #f0f0f4;
  --border: #dcdce3;
  --text: #1b1b21;
  --text-muted: #6b6b76;
  --accent: #6c5ce7;
  --accent-glow: rgba(108, 92, 231, 0.15);
  --green: #27ae60;
  --bubble-bot: #eaeaf0;
  --bubble-user: #6c5ce7;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

#app {
  display: flex;
  height: 100%;
}

/* sidebar */
#sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

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

.sidebar-header h2 {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.sidebar-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

.sidebar-tab {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 8px;
  padding: 6px 0;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.sidebar-tab:hover {
  color: var(--text);
}

.sidebar-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

#add-memory-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

#add-memory-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

#memory-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.memory-item {
  background: var(--surface-2);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
  position: relative;
  word-break: break-word;
}

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

.memory-item .memory-time {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

.memory-item .memory-del {
  position: absolute;
  top: 6px;
  right: 8px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  opacity: 0;
  transition: opacity 0.15s;
}

.memory-item:hover .memory-del {
  opacity: 1;
}

.memory-item .memory-del:hover {
  color: #e74c3c;
}

.memory-empty {
  color: var(--text-muted);
  text-align: center;
  padding: 40px 16px;
  font-size: 13px;
}

#history-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.history-session {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  transition: border-color 0.15s;
}

.history-session.open {
  border-color: var(--accent);
}

.history-session-head {
  padding: 10px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.history-session-head:hover {
  background: var(--border);
}

.history-session-preview {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.history-session-time {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.history-session-msg {
  font-size: 12px;
  padding: 3px 0;
  line-height: 1.5;
}

.history-session-msg .who {
  font-weight: 700;
  color: var(--accent);
  margin-right: 6px;
}

.history-session-msg.user .who {
  color: var(--text);
}

.history-msgs {
  display: none;
  border-top: 1px solid var(--border);
  padding: 8px 12px;
  max-height: 240px;
  overflow-y: auto;
}

.history-session.open .history-msgs {
  display: block;
}

/* main */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

#chat-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  min-height: 0;
}

/* welcome screen */
#welcome {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

#welcome.hidden {
  opacity: 0;
  visibility: hidden;
}

#welcome-bg {
  position: absolute;
  inset: -30px;
  background: linear-gradient(135deg, #1c3a2e 0%, #2f6b4f 45%, #a7c957 100%);
  background-size: cover;
  background-position: center;
  filter: blur(14px);
  transform: scale(1.1);
  opacity: 0.9;
}

:root[data-theme="light"] #welcome-bg {
  opacity: 0.5;
}

.welcome-inner {
  position: relative;
  z-index: 2;
  text-align: center;
  padding: 0 20px;
}

.welcome-inner h1 {
  font-size: 44px;
  font-weight: 800;
  letter-spacing: -1px;
  color: #fff;
  text-shadow: 0 4px 30px rgba(0,0,0,0.4);
  margin-bottom: 8px;
}

:root[data-theme="light"] .welcome-inner h1 {
  color: #143d2a;
  text-shadow: 0 4px 30px rgba(255,255,255,0.3);
}

.welcome-inner .welcome-sub {
  font-size: 15px;
  color: rgba(255,255,255,0.85);
  text-shadow: 0 2px 12px rgba(0,0,0,0.35);
}

:root[data-theme="light"] .welcome-inner .welcome-sub {
  color: #2f6b4f;
}

.welcome-files-btn {
  margin-top: 18px;
  padding: 9px 18px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.35);
  background: rgba(0,0,0,0.3);
  color: #fff;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: all 0.2s;
}

.welcome-files-btn:hover {
  border-color: #fff;
  transform: translateY(-1px);
}

:root[data-theme="light"] .welcome-files-btn {
  background: rgba(255,255,255,0.6);
  border-color: rgba(20,61,42,0.25);
  color: #143d2a;
}

/* hide button - can be dragged around; NEVER hides itself */
#hide-btn {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 400;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 18px;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  transition: all 0.2s;
}

#hide-btn.dragging {
  cursor: grabbing;
  transition: none;
}

#hide-btn:hover {
  border-color: var(--accent);
  transform: scale(1.05);
}

#hide-btn.dragging:hover {
  transform: none;
}

#app.collapsed #hide-btn {
  border-color: var(--accent);
}

#app.collapsed #chat-header,
#app.collapsed #chat-messages {
  display: none;
}

#app.collapsed #input-area {
  border-top: none;
}

#chat-header {
  display: flex;
  align-items: center;
  padding: 12px 52px 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  gap: 12px;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 0;
}

.logo {
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.5px;
}

.badge {
  font-size: 18px;
  font-weight: 400;
  color: var(--accent);
}

#clock {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  min-width: 90px;
  text-align: center;
  letter-spacing: 0.3px;
}

.status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  font-size: 12px;
  color: var(--text-muted);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px rgba(46, 204, 113, 0.4);
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
}

.icon-btn:hover {
  color: var(--text);
  background: var(--surface-2);
}

/* chat messages */
#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  z-index: 2;
  min-height: 0;
}

.message {
  display: flex;
  gap: 10px;
  max-width: 85%;
  min-width: 0;
  animation: msg-in 0.2s ease-out;
}

@keyframes msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.message {
  animation-duration: calc(0.2s * var(--msg-rate, 1));
}

.message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  flex-shrink: 0;
  margin-top: 4px;
}

.message.bot .avatar {
  background: var(--accent);
  color: #fff;
}

.message.user .avatar {
  background: #2d2d35;
  color: var(--text-muted);
}

.bubble {
  background: var(--bubble-bot);
  border-radius: var(--radius);
  border-top-left-radius: 2px;
  padding: 10px 14px;
  line-height: 1.55;
  overflow-wrap: break-word;
  word-break: break-word;
  min-width: 0;
}

.message.user .bubble {
  background: var(--bubble-user);
  border-radius: var(--radius);
  border-top-right-radius: 2px;
}

.bubble p {
  margin-bottom: 6px;
}

.bubble p:last-child {
  margin-bottom: 0;
}

.bubble ul {
  margin: 6px 0 0 16px;
}

.bubble li {
  margin-bottom: 4px;
}

.bubble code {
  background: rgba(255, 255, 255, 0.08);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
}

.bubble img {
  max-width: 100%;
  border-radius: 8px;
  display: block;
  margin-top: 8px;
  cursor: pointer;
}

.bubble .typing-dots {
  display: inline-flex;
  gap: 3px;
}

.bubble .typing-dots span {
  width: 6px;
  height: 6px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: dot-bounce 1.2s infinite;
}

.bubble .typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.bubble .typing-dots span:nth-child(3) { animation-delay: 0.4s; }

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

/* input area */
#input-area {
  padding: 12px 20px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  position: relative;
  z-index: 3;
  transition: background 0.3s, padding 0.3s;
}

/* small compact prompt on the welcome screen */
#input-area.small {
  background: transparent;
  border-top: none;
  padding: 0 20px 28px;
}

#input-area.small #chat-form {
  max-width: 560px;
  margin: 0 auto;
}

#input-area.small #chat-input {
  background: rgba(0,0,0,0.35);
  border-color: rgba(255,255,255,0.25);
  color: #fff;
  backdrop-filter: blur(8px);
}

:root[data-theme="light"] #input-area.small #chat-input {
  background: rgba(255,255,255,0.7);
  border-color: rgba(20,61,42,0.25);
  color: #143d2a;
}

#input-area.small #chat-input::placeholder {
  color: rgba(255,255,255,0.7);
}

:root[data-theme="light"] #input-area.small #chat-input::placeholder {
  color: rgba(20,61,42,0.6);
}

#input-area.small .input-btn {
  background: rgba(0,0,0,0.35);
  border-color: rgba(255,255,255,0.25);
  color: #fff;
  backdrop-filter: blur(8px);
}

:root[data-theme="light"] #input-area.small .input-btn {
  background: rgba(255,255,255,0.7);
  border-color: rgba(20,61,42,0.25);
  color: #143d2a;
}

#loading-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 4px 8px;
  font-size: 12px;
  color: var(--text-muted);
}

#loading-indicator.hidden {
  display: none;
}

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

#chat-form {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

#chat-input {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  line-height: 1.45;
  outline: none;
  resize: none;
  min-height: 40px;
  max-height: 160px;
  overflow-y: auto;
  transition: border-color 0.15s;
}

#chat-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

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

.input-btn {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 17px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.input-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.input-btn.recording {
  background: #e74c3c;
  border-color: #e74c3c;
  color: #fff;
  animation: pulse 1.2s infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.5); }
  50% { box-shadow: 0 0 0 6px rgba(231, 76, 60, 0); }
}

#attach-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 4px 8px;
}

#attach-preview.hidden {
  display: none;
}

.attach-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 12px;
  max-width: 200px;
}

.attach-chip .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attach-chip .x {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  padding: 0 2px;
}

.attach-chip .x:hover {
  color: #e74c3c;
}

.attach-img {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid var(--border);
}

.message .bubble .attach-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.message .bubble .attach-inline img.thumb {
  width: 120px;
  height: 120px;
  object-fit: cover;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid var(--border);
}

.message .bubble .file-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 12px;
  margin: 2px 4px 2px 0;
}

/* image modal */
#image-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 100;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
}

#image-modal.open {
  display: flex;
}

#image-modal img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 8px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.6);
}

/* settings overlay */
#settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

#settings-overlay.hidden {
  display: none;
}

#settings-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 400px;
  max-width: 90vw;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 16px 64px rgba(0,0,0,0.5);
}

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

.settings-header h2 {
  font-size: 16px;
  font-weight: 600;
}

.settings-body {
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.setting-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.setting-group label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.setting-group select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s;
}

.setting-group select:focus {
  border-color: var(--accent);
}

#settings-memory-list {
  max-height: 150px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#settings-memory-list .memory-item {
  margin-bottom: 0;
}

/* scrollbar */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* responsive */
#sidebar-backdrop {
  display: none;
}

@media (max-width: 700px) {
  #sidebar {
    display: none;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-w);
    z-index: 350;
    box-shadow: 8px 0 30px rgba(0,0,0,0.4);
  }

  #app.show-sidebar #sidebar {
    display: flex;
  }

  #app.show-sidebar #sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 340;
  }

  #hide-btn {
    top: 10px;
    right: 10px;
  }

  .message {
    max-width: 95%;
  }

  #chat-messages {
    padding: 12px;
  }

  #input-area {
    padding: 10px 12px 14px;
  }

  #input-area.small {
    padding: 0 12px 20px;
  }

  #settings-panel {
    width: 95vw;
    max-height: 90vh;
  }
}
/* AI info tab */
#ai-info-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 12px;
  overflow: hidden;
}

#ai-info-tab.hidden {
  display: none;
}

.ai-info-header {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

#ai-info-editor {
  flex: 1;
  resize: none;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  line-height: 1.55;
  outline: none;
  min-height: 120px;
  transition: border-color 0.15s;
}

#ai-info-editor:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

#ai-info-editor::placeholder {
  color: var(--text-muted);
  font-size: 12px;
}

.ai-info-footer {
  display: flex;
  justify-content: flex-end;
  padding-top: 6px;
}

#ai-info-status {
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
}

/* ============ News tab ============ */
#news-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#news-tab.hidden {
  display: none;
}

.news-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

#news-refresh {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

#news-refresh:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

#news-refresh:disabled {
  opacity: 0.5;
  cursor: default;
}

.news-status {
  font-size: 12px;
  color: var(--text-muted);
  padding: 12px;
  text-align: center;
}

.news-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px 12px;
}

.news-item {
  display: block;
  background: var(--surface-2);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 6px;
  text-decoration: none;
  color: inherit;
  transition: background 0.15s;
}

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

.news-title {
  display: block;
  font-size: 13px;
  line-height: 1.35;
  word-break: break-word;
}

.news-meta {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ============ Browser tab ============ */
#browser-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

#browser-tab.hidden {
  display: none;
}

.browser-search {
  display: flex;
  gap: 6px;
  padding: 10px 12px 6px;
}

.browser-search input {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  min-width: 0;
  transition: border-color 0.15s;
}

.browser-search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.browser-search input::placeholder {
  color: var(--text-muted);
}

#browser-go {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

#browser-go:hover {
  border-color: var(--accent);
  color: var(--accent);
}

#browser-screens {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.browser-screen {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  animation: msg-in 0.2s ease-out;
}

.browser-screen-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 8px 8px 10px;
  border-bottom: 1px solid var(--border);
}

.browser-screen-title {
  font-size: 13px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.browser-screen-x {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  border-radius: 4px;
  line-height: 1;
}

.browser-screen-x:hover {
  color: #e74c3c;
  background: var(--border);
}

.browser-screen-url {
  padding: 5px 10px;
  font-size: 10px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.browser-screen-results {
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.browser-result {
  display: block;
  text-decoration: none;
  color: inherit;
  padding: 6px 8px;
  border-radius: 6px;
  transition: background 0.15s;
}

.browser-result:hover {
  background: var(--border);
}

.browser-result-title {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  line-height: 1.3;
  word-break: break-word;
}

.browser-result-url {
  display: block;
  font-size: 10px;
  color: var(--green);
  margin-top: 2px;
  word-break: break-all;
}

.browser-result-snippet {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  line-height: 1.4;
}

.browser-empty {
  color: var(--text-muted);
  text-align: center;
  padding: 20px 12px;
  font-size: 12px;
}

/* ============ Aero theme ============ */
:root[data-theme="aero"] {
  --bg: rgba(20, 20, 30, 0.55);
  --surface: rgba(255, 255, 255, 0.14);
  --surface-2: rgba(255, 255, 255, 0.18);
  --border: rgba(255, 255, 255, 0.28);
  --text: #ffffff;
  --text-muted: rgba(255, 255, 255, 0.7);
  --accent: #8ab4ff;
  --accent-glow: rgba(138, 180, 255, 0.3);
  --green: #7ce38b;
  --bubble-bot: rgba(255, 255, 255, 0.14);
  --bubble-user: rgba(138, 180, 255, 0.35);
}

body.aero-mode {
  background: linear-gradient(135deg, #23234a 0%, #4a2c63 45%, #1a3a5c 100%) fixed;
  background-size: cover;
}
body.aero-mode::before {
  content: '';
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,0.45) 100%);
  pointer-events: none;
  z-index: 0;
}
body.aero-mode #app { position: relative; }
body.aero-mode #sidebar,
body.aero-mode #chat-header,
body.aero-mode #input-area {
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(var(--intense-blur, 22px)) saturate(var(--intense-saturate, 160%));
  -webkit-backdrop-filter: blur(var(--intense-blur, 22px)) saturate(var(--intense-saturate, 160%));
  border-color: rgba(255, 255, 255, 0.28);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.25);
}
body.aero-mode .memory-item,
body.aero-mode .history-session,
body.aero-mode .bubble,
body.aero-mode #chat-input,
body.aero-mode .input-btn,
body.aero-mode #settings-panel,
body.aero-mode .setting-group select {
  background: rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-color: rgba(255, 255, 255, 0.25);
  box-shadow: 0 8px 24px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.2);
}
body.aero-mode .sidebar-tab {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.22);
}
body.aero-mode .sidebar-tab.active { background: rgba(138,180,255,0.5); }
body.aero-mode .message.user .bubble {
  background: linear-gradient(135deg, rgba(138,180,255,0.55), rgba(138,180,255,0.3));
  border: 1px solid rgba(255,255,255,0.3);
}
body.aero-mode .logo,
body.aero-mode .welcome-inner h1 {
  text-shadow: 0 2px 18px rgba(138,180,255,0.6);
}
body.aero-mode .avatar { box-shadow: 0 0 0 2px rgba(255,255,255,0.25); }

/* ============ DOS theme ============ */
:root[data-theme="dos"] {
  --bg: #000000;
  --surface: #000000;
  --surface-2: #000000;
  --border: #33ff66;
  --text: #33ff66;
  --text-muted: #33ff66;
  --accent: #33ff66;
  --accent-glow: rgba(51, 255, 102, 0.2);
  --green: #33ff66;
  --bubble-bot: #000000;
  --bubble-user: #000000;
}

body.dos-mode {
  background: #000 !important;
  color: #33ff66;
  font-family: 'Courier New', ui-monospace, monospace !important;
  cursor: text;
}
body.dos-mode ::selection { background: #33ff66; color: #000; }
body.dos-mode #sidebar,
body.dos-mode #chat-header,
body.dos-mode #input-area,
body.dos-mode .memory-item,
body.dos-mode .history-session,
body.dos-mode .bubble,
body.dos-mode #chat-input,
body.dos-mode .input-btn,
body.dos-mode #settings-panel,
body.dos-mode .setting-group select,
body.dos-mode .sidebar-tab {
  background: #000 !important;
  border: 1px solid #33ff66 !important;
  border-radius: 0 !important;
  color: #33ff66 !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
}
body.dos-mode #sidebar { border-right: 1px solid #33ff66; }
body.dos-mode #chat-header { border-bottom: 1px solid #33ff66; }
body.dos-mode #input-area { border-top: 1px solid #33ff66; }
body.dos-mode .avatar {
  background: #000 !important;
  color: #33ff66 !important;
  border: 1px solid #33ff66;
  border-radius: 0;
}
body.dos-mode .bubble { border: 1px solid #33ff66; }
body.dos-mode .sidebar-tab.active { background: #33ff66 !important; color: #000 !important; }
body.dos-mode .logo,
body.dos-mode .status-text,
body.dos-mode .welcome-inner h1,
body.dos-mode .welcome-sub { color: #33ff66 !important; text-shadow: none !important; }
body.dos-mode .welcome-inner h1 { font-size: 34px; }
body.dos-mode #welcome-bg { display: none; }
body.dos-mode .icon-btn:hover { background: #33ff66; color: #000; }
body.dos-mode ::-webkit-scrollbar-thumb { background: #33ff66; }
body.dos-mode #input-area.small #chat-input,
body.dos-mode #input-area.small .input-btn {
  background: #000 !important;
  border-color: #33ff66 !important;
  color: #33ff66 !important;
}
body.dos-mode #input-area.small #chat-input::placeholder { color: #33ff66; }
body.dos-mode .hidden { display: none; }

#dos-exit {
  position: fixed;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  display: none;
  padding: 8px 16px;
  background: #000;
  color: #33ff66;
  border: 1px solid #33ff66;
  border-radius: 0;
  font-family: 'Courier New', monospace;
  cursor: pointer;
}
body.dos-mode #dos-exit { display: block; }
body.dos-mode #dos-exit:hover { background: #33ff66; color: #000; }

/* ============ generated image actions ============ */
.gen-image { margin-top: 8px; }
.gen-image img { max-width: 100%; border-radius: 8px; display: block; cursor: pointer; }
.gen-actions { display: flex; gap: 6px; margin-top: 8px; }
.gen-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}
.gen-btn:hover { border-color: var(--accent); color: var(--accent); }

#image-modal .img-modal-inner { text-align: center; }
#image-modal .img-modal-inner img { max-width: 90vw; max-height: 82vh; border-radius: 8px; box-shadow: 0 8px 40px rgba(0,0,0,0.6); }
#image-modal .img-modal-actions { display: flex; justify-content: center; gap: 10px; margin-top: 12px; }
#image-modal .gen-btn { font-size: 14px; padding: 8px 16px; }

/* ============ slider range inputs ============ */
.setting-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}
.setting-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--surface);
  cursor: pointer;
  box-shadow: 0 0 0 2px var(--accent);
}
.setting-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--surface);
  cursor: pointer;
}
.slider-value {
  font-size: 11px;
  color: var(--text-muted);
  text-align: right;
  display: block;
  margin-top: 2px;
}

/* theme intensity */
:root {
  --intense-opacity: calc(var(--theme-intensity, 1));
  --intense-blur: calc(22px * var(--theme-intensity, 1));
  --intense-saturate: calc(100% + 60% * var(--theme-intensity, 1));
}

/* ============ settings uploads ============ */
.pfp-row, .welcomebg-row { display: flex; align-items: center; gap: 12px; }
.pfp-preview, .welcomebg-preview {
  width: 64px; height: 64px; border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  overflow: hidden; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 11px;
}
.welcomebg-preview { border-radius: 8px; width: 88px; }
.pfp-preview img, .welcomebg-preview img { width: 100%; height: 100%; object-fit: cover; }
.pfp-controls { display: flex; flex-direction: column; gap: 6px; }
.upload-btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  text-align: center;
}
.upload-btn.ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }

/* ============ help bubble ============ */
.help-bubble { min-width: 260px; }
.help-title { font-weight: 800; margin-bottom: 8px; letter-spacing: 0.5px; }
.help-row { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; }
.help-row code { font-size: 12px; color: var(--accent); }
.help-row span { color: var(--text-muted); font-size: 12px; }
.help-tip { margin-top: 8px; padding-top: 6px; border-top: 1px solid var(--border); font-size: 11px; color: var(--text-muted); }

/* ============ video modal ============ */
#video-overlay {
  position: fixed; inset: 0; z-index: 210;
  background: rgba(0,0,0,0.75);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(6px);
}
#video-overlay.hidden { display: none; }
#video-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 420px; max-width: 92vw;
  overflow: hidden;
  box-shadow: 0 16px 64px rgba(0,0,0,0.5);
}
.video-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  font-size: 13px; font-weight: 600;
}
#video-stage { height: 500px; max-height: 70vh; }

/* ============ account tab ============ */
#account-tab {
  flex: 1; display: flex; flex-direction: column; padding: 12px; gap: 12px; overflow-y: auto;
}
#account-tab.hidden { display: none; }
.acc-card {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px;
}
.acc-avatar {
  width: 44px; height: 44px; border-radius: 50%;
  background-size: cover; background-position: center;
  border: 1px solid var(--border); flex-shrink: 0;
}
.acc-name { font-weight: 700; }
.acc-role { font-size: 11px; color: var(--text-muted); }
.acc-btns { display: flex; flex-direction: column; gap: 6px; }
.acc-btn {
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); border-radius: 8px; padding: 8px 12px;
  font-size: 13px; cursor: pointer; text-align: left; transition: all 0.15s;
}
.acc-btn:hover { border-color: var(--accent); color: var(--accent); }
#account-sub { display: flex; flex-direction: column; gap: 6px; }
.acc-pick { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.acc-row {
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); border-radius: 6px; padding: 6px 10px;
  font-size: 12px; cursor: pointer; text-align: left;
}
.acc-row:hover { border-color: var(--accent); }
.acc-row.add { border-style: dashed; }
.acc-hint { font-size: 12px; color: var(--text-muted); padding: 4px 0; }
.acc-saved-head { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }
.acc-photos { display: flex; flex-wrap: wrap; gap: 6px; }
.acc-photo { position: relative; width: 64px; height: 64px; cursor: pointer; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.acc-photo img { width: 100%; height: 100%; object-fit: cover; }
.acc-photo-x {
  position: absolute; top: 2px; right: 2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: rgba(0,0,0,0.7); color: #fff; border: none;
  font-size: 10px; line-height: 1; cursor: pointer;
}

/* ============ Classic theme (Windows Classic) ============ */
:root[data-theme="classic"] {
  --bg: #008080;
  --surface: #c0c0c0;
  --surface-2: #d4d0c8;
  --border: #808080;
  --text: #000000;
  --text-muted: #404040;
  --accent: #000080;
  --accent-glow: rgba(0, 0, 128, 0.18);
  --green: #008000;
  --bubble-bot: #d4d0c8;
  --bubble-user: #000080;
  --radius: 0px;
}

body.classic-mode {
  font-family: "Tahoma", "MS Sans Serif", "Segoe UI", system-ui, sans-serif;
  color: #000;
}

body.classic-mode #welcome-bg { background: #008080; }
body.classic-mode .welcome-inner h1,
body.classic-mode .welcome-inner .welcome-sub { color: #fff; }

body.classic-mode #sidebar,
body.classic-mode #chat-header,
body.classic-mode #input-area,
body.classic-mode #settings-panel,
body.classic-mode #video-modal {
  border: 1px solid #808080;
  box-shadow: inset -1px -1px 0 #000, inset 1px 1px 0 #fff;
}
body.classic-mode #chat-header { border-bottom: 1px solid #808080; }
body.classic-mode #input-area { border-top: 1px solid #808080; }
body.classic-mode #sidebar { border-right: 1px solid #808080; }

body.classic-mode .sidebar-tab,
body.classic-mode .input-btn,
body.classic-mode .memory-item,
body.classic-mode .history-session,
body.classic-mode .news-item,
body.classic-mode .acc-btn,
body.classic-mode .acc-row,
body.classic-mode .browser-screen,
body.classic-mode .browser-result {
  border: 1px solid;
  border-color: #fff #000 #000 #fff;
  border-radius: 0;
  box-shadow: none;
}
body.classic-mode .sidebar-tab.active {
  background: #000080;
  color: #fff;
  border-color: #808080;
}
body.classic-mode .memory-item:hover,
body.classic-mode .history-session-head:hover,
body.classic-mode .news-item:hover,
body.classic-mode .browser-result:hover { background: #d4d0c8; }

body.classic-mode .sidebar-tab:hover { color: #000080; }
body.classic-mode .sidebar-tab.active:hover { color: #fff; }

body.classic-mode #chat-input,
body.classic-mode .setting-group select,
body.classic-mode #ai-info-editor,
body.classic-mode .browser-search input {
  border: 2px solid;
  border-color: #000 #fff #fff #000;
  border-radius: 0;
  background: #fff;
  color: #000;
}
body.classic-mode #chat-input::placeholder,
body.classic-mode .browser-search input::placeholder { color: #808080; }
body.classic-mode #chat-input:focus,
body.classic-mode .browser-search input:focus { border-color: #000080; box-shadow: none; }

body.classic-mode .bubble {
  border: 1px solid #808080;
  border-radius: 0;
  box-shadow: inset -1px -1px 0 #000, inset 1px 1px 0 #fff;
}
body.classic-mode .message.user .bubble { background: #000080; color: #fff; }
body.classic-mode .message.user .avatar { background: #808080; color: #fff; }
body.classic-mode .message.bot .avatar { background: #000080; }

body.classic-mode .browser-screen-head,
body.classic-mode .browser-screen-url,
body.classic-mode .history-session.open { border-color: #808080; }
body.classic-mode .browser-result-title { color: #000080; }
body.classic-mode .browser-result-url { color: #008000; }

body.classic-mode #add-memory-btn,
body.classic-mode .icon-btn { border: 1px solid; border-color: #fff #000 #000 #fff; border-radius: 0; }
body.classic-mode .icon-btn:hover { background: #000080; color: #fff; }
body.classic-mode .acc-card { border: 1px solid; border-color: #fff #000 #000 #fff; border-radius: 0; }
body.classic-mode .gen-btn,
body.classic-mode #news-refresh,
body.classic-mode #browser-go {
  border: 1px solid;
  border-color: #fff #000 #000 #fff;
  border-radius: 0;
  background: #c0c0c0;
  color: #000;
}
body.classic-mode ::-webkit-scrollbar-thumb { background: #808080; }

/* ============ Blue theme (everything blue) ============ */
:root[data-theme="blue"] {
  --bg: #0a1f44;
  --surface: #12317a;
  --surface-2: #1a3fa0;
  --border: #2f5bc4;
  --text: #dbe6ff;
  --text-muted: #9db6e8;
  --accent: #3d7bff;
  --accent-glow: rgba(61, 123, 255, 0.3);
  --green: #5ad0ff;
  --bubble-bot: #1a3fa0;
  --bubble-user: #3d7bff;
}

body.blue-mode #welcome-bg { background: #0a1f44; }
body.blue-mode .welcome-inner h1 { color: #dbe6ff; }
body.blue-mode .welcome-inner .welcome-sub { color: #9db6e8; }
body.blue-mode .message.user .avatar { background: #0a1f44; color: #dbe6ff; }
body.blue-mode #welcome-bg { filter: none; }

/* ============ 2016 theme (Vine-like) ============ */
:root[data-theme="vine"] {
  --bg: #000000;
  --surface: #0d0d0d;
  --surface-2: #191919;
  --border: #2e2e2e;
  --text: #f5f5f5;
  --text-muted: #8a8a8a;
  --accent: #00d95f;
  --accent-glow: rgba(0, 217, 95, 0.22);
  --green: #00d95f;
  --bubble-bot: #161616;
  --bubble-user: #00a848;
}

body.vine-mode .logo::before {
  content: 'V ';
  color: #00d95f;
  font-weight: 900;
  font-style: italic;
}
body.vine-mode #welcome-bg { background: #000; filter: none; opacity: 1; }
body.vine-mode .welcome-inner h1 { color: #fff; }
body.vine-mode .welcome-inner .welcome-sub { color: #00d95f; }
body.vine-mode .message.user .avatar { background: #262626; color: #f5f5f5; }
body.vine-mode .sidebar-tab.active { background: #00d95f; border-color: #00d95f; color: #000; }
body.vine-mode .bubble { border: 1px solid #222; }

/* ============ Commodore 64 theme ============ */
:root[data-theme="c64"] {
  --bg: #4034d8;
  --surface: #4034d8;
  --surface-2: #4538e0;
  --border: #b5f5ff;
  --text: #ffffff;
  --text-muted: #b5f5ff;
  --accent: #ffffff;
  --accent-glow: rgba(255, 255, 255, 0.2);
  --green: #b5f5ff;
  --bubble-bot: #2c22a8;
  --bubble-user: #1e1550;
}

body.c64-mode {
  font-family: ui-monospace, "Cascadia Mono", "Consolas", monospace;
  color: #fff;
}
body.c64-mode ::selection { background: #fff; color: #4034d8; }
body.c64-mode #welcome-bg { background: #4034d8; filter: none; opacity: 1; }
body.c64-mode .welcome-inner h1 { color: #fff; text-shadow: none; }
body.c64-mode .welcome-inner .welcome-sub { color: #b5f5ff; }
body.c64-mode .message.user .avatar { background: #1e1550; color: #b5f5ff; }
body.c64-mode .bubble { border: 1px solid #b5f5ff; border-radius: 0; }
body.c64-mode .sidebar-tab { border-radius: 0; }
body.c64-mode .sidebar-tab.active { background: #fff; border-color: #fff; color: #4034d8; }
body.c64-mode .memory-item,
body.c64-mode .history-session,
body.c64-mode .news-item,
body.c64-mode .browser-screen,
body.c64-mode .browser-result { border-radius: 0; }

body.c64-mode::before {
  content: '';
  position: fixed;
  inset: 0;
  border: 12px solid #000;
  box-shadow: inset 0 0 0 3px #b5f5ff;
  pointer-events: none;
  z-index: 1000;
}
body.c64-mode::after {
  content: '';
  position: fixed;
  inset: 7px;
  background:
    repeating-linear-gradient(90deg, #f00 0 12px, #ff8000 12px 24px, #ff0 24px 36px, #0f0 36px 48px, #00f 48px 60px, #f0f 60px 72px) top / 100% 5px no-repeat,
    repeating-linear-gradient(90deg, #f00 0 12px, #ff8000 12px 24px, #ff0 24px 36px, #0f0 36px 48px, #00f 48px 60px, #f0f 60px 72px) bottom / 100% 5px no-repeat;
  pointer-events: none;
  z-index: 1001;
}

/* ============ Windows 11 theme ============ */
:root[data-theme="win11"] {
  --bg: #1c1c1c;
  --surface: #2c2c2c;
  --surface-2: #383838;
  --border: #404040;
  --text: #ffffff;
  --text-muted: #9e9e9e;
  --accent: #60cdff;
  --accent-glow: rgba(96,205,255,0.2);
  --green: #60cdff;
  --bubble-bot: #333333;
  --bubble-user: #60cdff;
  --radius: 8px;
}
body.win11-mode {
  font-family: "Segoe UI Variable","Segoe UI",system-ui,sans-serif;
}
body.win11-mode #sidebar { border-right-color: var(--border); }
body.win11-mode #chat-header { border-bottom-color: var(--border); }
body.win11-mode #input-area { border-top-color: var(--border); }
body.win11-mode .sidebar-tab { border-radius: 6px; }
body.win11-mode .sidebar-tab.active { background: var(--accent); border-color: var(--accent); color: #000; }
body.win11-mode .bubble { border-radius: 8px; }
body.win11-mode .message.user .bubble { background: linear-gradient(135deg,#60cdff,#4db8ff); border-radius: 8px; }
body.win11-mode #welcome-bg { background: linear-gradient(135deg,#1c1c1c 0%,#2c3e50 45%,#34495e 100%); filter: none; }
body.win11-mode .welcome-inner h1 { color: #fff; text-shadow: 0 2px 20px rgba(96,205,255,0.3); }
body.win11-mode .welcome-inner .welcome-sub { color: #9e9e9e; }
body.win11-mode #settings-panel { border-radius: 12px; }
body.win11-mode .avatar { box-shadow: 0 0 0 2px rgba(96,205,255,0.2); }

/* ============ MacX (Mac OS X) theme ============ */
:root[data-theme="macx"] {
  --bg: #333333;
  --surface: rgba(255,255,255,0.08);
  --surface-2: rgba(255,255,255,0.12);
  --border: rgba(255,255,255,0.18);
  --text: #ffffff;
  --text-muted: rgba(255,255,255,0.7);
  --accent: #5ac8fa;
  --accent-glow: rgba(90,200,250,0.25);
  --green: #34c759;
  --bubble-bot: rgba(255,255,255,0.10);
  --bubble-user: #5ac8fa;
  --radius: 10px;
}
body.macx-mode {
  font-family: -apple-system,"Helvetica Neue","Lucida Grande",sans-serif;
  background: linear-gradient(180deg,#4a4a4a 0%,#2a2a2a 100%) fixed;
}
body.macx-mode::before {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(0deg,transparent,transparent 1px,rgba(255,255,255,0.015) 1px,rgba(255,255,255,0.015) 2px);
  pointer-events: none;
  z-index: 0;
}
body.macx-mode #sidebar,
body.macx-mode #chat-header,
body.macx-mode #input-area {
  background: rgba(255,255,255,0.08);
  backdrop-filter: blur(calc(16px * var(--theme-intensity, 1))) saturate(calc(100% + 80% * var(--theme-intensity, 1)));
  -webkit-backdrop-filter: blur(calc(16px * var(--theme-intensity, 1))) saturate(calc(100% + 80% * var(--theme-intensity, 1)));
  border-color: rgba(255,255,255,0.2);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.1);
}
body.macx-mode .memory-item,
body.macx-mode .history-session,
body.macx-mode .bubble,
body.macx-mode #chat-input,
body.macx-mode .input-btn,
body.macx-mode #settings-panel,
body.macx-mode .setting-group select {
  background: rgba(255,255,255,0.08);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-color: rgba(255,255,255,0.2);
  border-radius: 8px;
}
body.macx-mode .sidebar-tab { background: rgba(255,255,255,0.06); }
body.macx-mode .sidebar-tab.active { background: rgba(90,200,250,0.3); border-color: rgba(90,200,250,0.5); }
body.macx-mode .status-dot { background: #34c759; }
body.macx-mode .message.user .bubble { background: linear-gradient(135deg,#5ac8fa,#0892d0); }
body.macx-mode .welcome-inner h1 { text-shadow: 0 4px 30px rgba(90,200,250,0.4); }
body.macx-mode #welcome-bg { background: linear-gradient(135deg,#404040 0%,#555555 45%,#666666 100%); filter: none; }
body.macx-mode ::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 4px; }

/* ============ Glitch theme ============ */
:root[data-theme="glitch"] {
  --bg: #0a0a0a;
  --surface: #111111;
  --surface-2: #1a1a1a;
  --border: #282828;
  --text: #00ff00;
  --text-muted: #00aa00;
  --accent: #ff00ff;
  --accent-glow: rgba(255,0,255,0.3);
  --green: #00ff00;
  --bubble-bot: #0d0d0d;
  --bubble-user: #ff00ff;
}
body.glitch-mode {
  font-family: "Courier New","Consolas",ui-monospace,monospace;
}
body.glitch-mode::before {
  content: '';
  position: fixed;
  inset: 0;
  background: linear-gradient(90deg,rgba(255,0,0,0.03) 0%,transparent 50%),linear-gradient(180deg,rgba(0,255,0,0.03) 0%,transparent 50%);
  pointer-events: none;
  z-index: 999;
  animation: glitch-scan 0.1s linear infinite;
}
@keyframes glitch-scan {
  0% { transform: translateY(0); opacity: 1; }
  25% { transform: translateY(-2px); opacity: 0.8; }
  50% { transform: translateY(2px); opacity: 0.9; }
  75% { transform: translateY(-1px); opacity: 0.7; }
  100% { transform: translateY(0); opacity: 1; }
}
body.glitch-mode::after {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(0deg,transparent,transparent 3px,rgba(0,0,0,0.15) 3px,rgba(0,0,0,0.15) 4px);
  pointer-events: none;
  z-index: 1000;
}
body.glitch-mode .bubble {
  border: 1px solid #ff00ff;
  box-shadow: 2px 0 0 #00ffff,-2px 0 0 #ff00ff;
  animation: glitch-text 0.15s infinite;
}
@keyframes glitch-text {
  0% { transform: translate(0,0); }
  20% { transform: translate(-1px,1px); }
  40% { transform: translate(1px,-1px); }
  60% { transform: translate(-2px,0); }
  80% { transform: translate(2px,0); }
  100% { transform: translate(0,0); }
}
body.glitch-mode .sidebar-tab.active { background: #ff00ff; border-color: #ff00ff; color: #000; }
body.glitch-mode .message.user .bubble { background: linear-gradient(135deg,#ff00ff,#ff0088); }
body.glitch-mode #sidebar,body.glitch-mode #chat-header,body.glitch-mode #input-area { border-color: #ff00ff; }
body.glitch-mode #welcome-bg { background: #000; filter: none; }
body.glitch-mode .welcome-inner h1 { color: #0f0; text-shadow: 0 0 20px #0f0,0 0 40px #0f0; }
body.glitch-mode .welcome-inner .welcome-sub { color: #0a0; }
body.glitch-mode .logo { color: #0f0; text-shadow: 0 0 10px #0f0; }
body.glitch-mode ::selection { background: #ff00ff; color: #000; }
body.glitch-mode .memory-item,body.glitch-mode .history-session { border-color: #ff00ff; }
body.glitch-mode #chat-input { border-color: #0f0; }

/* ============ Royale (Windows XP MCE theme) ============ */
:root[data-theme="royale"] {
  --bg: #1a3654;
  --surface: #2d4c73;
  --surface-2: #3a5e87;
  --border: #4d7eab;
  --text: #ffffff;
  --text-muted: #bbd6f0;
  --accent: #ffcc00;
  --accent-glow: rgba(255,204,0,0.25);
  --green: #00cc44;
  --bubble-bot: #2d4c73;
  --bubble-user: #ffcc00;
  --radius: 8px;
}
body.royale-mode {
  font-family: "Tahoma","Segoe UI","Trebuchet MS",system-ui,sans-serif;
  background: linear-gradient(180deg,#1a3654 0%,#0a1e30 100%) fixed;
}
body.royale-mode #welcome-bg { background: linear-gradient(135deg,#ffcc00 0%,#ff9900 100%); filter: none; opacity: 0.8; }
body.royale-mode .welcome-inner h1 { color: #ffcc00; text-shadow: 0 2px 20px rgba(255,204,0,0.5); }
body.royale-mode .welcome-inner .welcome-sub { color: #bbd6f0; }
body.royale-mode #sidebar { background: linear-gradient(180deg,#2d4c73,#1a3654); border-right: 2px solid #ffcc00; }
body.royale-mode #chat-header { background: linear-gradient(180deg,#3a5e87,#2d4c73); border-bottom: 2px solid #ffcc00; }
body.royale-mode #input-area { background: linear-gradient(180deg,#2d4c73,#1a3654); border-top: 2px solid #ffcc00; }
body.royale-mode .sidebar-tab { background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.1); color: #fff; border-radius: 4px; }
body.royale-mode .sidebar-tab.active { background: #ffcc00; border-color: #ffcc00; color: #000; font-weight: 700; }
body.royale-mode .memory-item { background: rgba(255,255,255,0.06); border: 1px solid rgba(255,204,0,0.15); }
body.royale-mode .history-session { background: rgba(255,255,255,0.06); border: 1px solid rgba(255,204,0,0.15); }
body.royale-mode .history-session.open { border-color: #ffcc00; }
body.royale-mode .bubble { background: rgba(255,255,255,0.08); border: 1px solid rgba(255,204,0,0.15); border-radius: 8px; }
body.royale-mode .message.user .bubble { background: linear-gradient(135deg,#ffcc00,#ff9900); color: #000; }
body.royale-mode .message.user .avatar { background: #1a3654; }
body.royale-mode .message.bot .avatar { background: #ffcc00; color: #000; }
body.royale-mode #chat-input,body.royale-mode .browser-search input { background: rgba(0,0,0,0.2); border: 1px solid rgba(255,204,0,0.3); }
body.royale-mode #chat-input:focus { border-color: #ffcc00; box-shadow: 0 0 0 3px rgba(255,204,0,0.2); }
body.royale-mode .input-btn { background: rgba(0,0,0,0.2); border: 1px solid rgba(255,204,0,0.3); }
body.royale-mode .input-btn:hover { border-color: #ffcc00; color: #ffcc00; }
body.royale-mode .setting-group select { background: rgba(0,0,0,0.2); border: 1px solid rgba(255,204,0,0.3); }
body.royale-mode #settings-panel { background: linear-gradient(180deg,#2d4c73,#1a3654); border: 2px solid #ffcc00; border-radius: 12px; }
body.royale-mode .settings-header { border-bottom: 1px solid rgba(255,204,0,0.2); }
body.royale-mode .logo { color: #ffcc00; font-weight: 800; }
body.royale-mode .icon-btn:hover { background: rgba(255,204,0,0.2); color: #ffcc00; }
body.royale-mode ::-webkit-scrollbar-thumb { background: #ffcc00; border-radius: 2px; }
body.royale-mode .browser-result-url { color: #00cc44; }
body.royale-mode .news-meta { color: #bbd6f0; }

body.win11-mode {
  font-family: "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
}
body.win11-mode #sidebar { border-right-color: var(--border); }
body.win11-mode #chat-header { border-bottom-color: var(--border); }
body.win11-mode #input-area { border-top-color: var(--border); }
body.win11-mode .sidebar-tab { border-radius: 6px; }
body.win11-mode .sidebar-tab.active { background: var(--accent); border-color: var(--accent); color: #000; }
body.win11-mode #chat-input { border-radius: 8px; }
body.win11-mode .bubble { border-radius: 8px; }
body.win11-mode .message.user .bubble { background: linear-gradient(135deg, #60cdff, #4db8ff); border-radius: 8px; }
body.win11-mode #welcome-bg { background: linear-gradient(135deg, #1c1c1c 0%, #2c3e50 45%, #34495e 100%); filter: none; }
body.win11-mode .welcome-inner h1 { color: #fff; text-shadow: 0 2px 20px rgba(96,205,255,0.3); }
body.win11-mode .welcome-inner .welcome-sub { color: #9e9e9e; }
body.win11-mode #settings-panel { border-radius: 12px; }
body.win11-mode .avatar { box-shadow: 0 0 0 2px rgba(96,205,255,0.2); }

/* ============ MacX (Mac OS X) theme ============ */
:root[data-theme="macx"] {
  --bg: #333333;
  --surface: rgba(255,255,255,0.08);
  --surface-2: rgba(255,255,255,0.12);
  --border: rgba(255,255,255,0.18);
  --text: #ffffff;
  --text-muted: rgba(255,255,255,0.7);
  --accent: #5ac8fa;
  --accent-glow: rgba(90, 200, 250, 0.25);
  --green: #34c759;
  --bubble-bot: rgba(255,255,255,0.10);
  --bubble-user: #5ac8fa;
  --radius: 10px;
}

body.macx-mode {
  font-family: -apple-system, "Helvetica Neue", "Lucida Grande", sans-serif;
  background: linear-gradient(180deg, #4a4a4a 0%, #2a2a2a 100%) fixed;
}
body.macx-mode::before {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(0deg, transparent, transparent 1px, rgba(255,255,255,0.015) 1px, rgba(255,255,255,0.015) 2px);
  pointer-events: none;
  z-index: 0;
}
body.macx-mode #app {  }
position: relative;"> position: relative;
}
bodymacx-mode #sidebar,
body.macx-mode #chat-header,
body.macx-mode #input-area {
 -background: rgba(255,255,255,0.08);
  backdrop-filter: blur(16px) saturate180%;
  -webkit-backdrop-filter: blur16px) saturate(180%);
  border-color: rgba(255,255,255,0.2);
  box-shadow: inset 0 05px rgba(255,255,255,0.1);
}
body.macx-mode .memory-item,
body.macx-mode .history-session,
body.macx-mode .bubble,
body.macx-mode #chat-input,
body.macx-mode .input-btn,
body.macx-mode #settings-panel,
body.macx-mode setting-group select {
  background: rgba(255255,255,0.08);
  backdrop-filter: blur(8px);
 -webkit-backdrp-filter: blur8px);
  border-color: rgba(255,255,255,02);
  border-radius: 8px;
}
body.macx-mode .sidebar-tab { background: rgba(255,255,255,0.06); }
body.macx-mode .sidebar-tab.active { background rgba(90,200,250,0.3); border-color: rgba(90,200,250,0.5); }
body.macx-mode .chat-header .status-dt { background #34c759; }
body.macx-mode .messageuser .bubble { background: linear-gradient135deg, $5ac8fa, #8ebd); }
body.macx-mode .welcome-inner h1 { text-shadow: 0 4px 30px rgba90,200,250,0.4); }
body.macx-mode #welcome-bg { background: linear-gradient(135deg #404040 0% #555555 45%, #666666 100%); filter: none; }
body.macx-mode ::-webkit-scrollllbar-thumb { background: rgba255,255,255,0.2); border-radius: 4px; }

/* ============ Glitch theme ============ */
:root[data-theme="glitch"] {
  --bg: #0a0a0a;
  --surfce: #111111;
 --surface-2: #1a1a1a;
 --border: #282828;
  --text: #0f0;
 --text-muted: #0a0;
  --accent: #f0f;
--accent-glow: rgba(255,0,255,0.3);
  --green: #00ff00;
--bubble-bot: #0d0d0d;
  --bubble-user: #ff0ff;
}:root[data-theme="glitch"] {
  --bg: #0a0a0a;
  --surface: #111111;
  --surface-2: #1a1a1a;
  --boder: #282828;
  --text: #00ff00;
  --text-muted: #00aa00;
  --accent: #ff00ff;
  --accent-glow: rgba(255,0,255,0.3);
  --green: #00ff00;
  --bubble-bot: #0d0d0d;
  --bubble-user: #ff00ff;
}

body.glitch-mode {
  font-family: "Courier New", "Consolas", ui-monospace, monospace;
}
body.glitch-mode::before {
  content: '';
  position: fixed;
  inset: 0;
  background: linear-gradient(90deg, rgba(255,0,0,0.03) 0%, transparent 50%), linear-gradient(180deg, rgba(0,255,0,0.03) 0%, transparent 50%);
  pointer-events: none;
  z-index: 999;
  animation: glitch-scan 0.1s linear infinite;
}
@keyframes glitch-scan {
  0% { transform: translateY(0); opacity: 1; }
  25% { transform: translateY(-2px); opacity: 0.8; }
  50% { transform: translateY(2px); opacity: 0.9; }
  75% { transform: translateY(-1px); opacity: 0.7; }
  100% { transform: translateY(0); opacity: 1; }
}
body.glitch-mode::after {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(0deg, transparent, transparent 3px, rgba(0,0,0,0.15) 3px, rgba(0,0,0,0.15) 4px);
  pointer-events: none;
  z-index: 1000;
}
body.glitch-mode .bubble {
  border: 1px solid #ff00ff;
  box-shadow: 2px 0 0 #00ffff, -2px 0 0 #ff00ff;
  animation: glitch-text 0.15s infinite;
}
@keyframes glitch-text {
  0% { transform: translate(0, 0); }
  20% { transform: translate(-1px, 1px); }
  40% { transform: translate(1px, -1px); }
  60% { transform: translate(-2px, 0); }
  80% { transform: translate(2px, 0); }
  100% { transform: translate(0, 0); }
}
body.glitch-mode .sidebar-tab.active { background: #ff00ff; border-color: #ff00ff; color: #000; }
body.glitch-mode .message.user .bubble { background: linear-gradient(135deg, #ff00ff, #ff0088); }
body.glitch-mode #sidebar, body.glitch-mode #chat-header, body.glitch-mode #input-area { border-color: #ff00ff; }
body.glitch-mode #welcome-bg { background: #000; filter: none; }
body.glitch-mode .welcome-inner h1 { color: #0f0; text-shadow: 0 0 20px #0f0, 0 0 40px #0f0;}
body.glitch-mode .welcome-inner .welcome-sub { color: #0a0; }
body.glitch-mode .logo { color: #0f0; text-shadow: 0 0 10px #0f0; }
body.glitch-mode ::selection { background: #ff00ff; color: #000;}
body.glitch-mode .memory-item, body.glitch-mode .history-session { border-color: #ff00ff; }
body.glitch-mode #chat-input { border-color: #0f0; }

/* ============ Royale (Windows XP MCE theme) ============ */
:root[data-theme="royale"] {
  --bg: #1a3654;
  --surface: #2d4c73;
  --surface-2: #3a5e87;
  --border: #4d7eab;
  --text: #ffffff;
  --text-muted: #bbd6f0;
  --accent: #ffcc00;
  --accent-glow: rgba(255,204,0,0.25);
  --green: #00cc44;
  --bubble-bot: #2d4c73;
  --bubble-user: #ffcc00;
  --radius: 8px;
}
body.royale-mode {
  font-family: "Tahoma","Segoe UI","Trebuchet MS",system-ui,sans-serif;
  background: linear-gradient(180deg,#1a3654 0%,#0a1e30 100%) fixed;
}
body.royale-mode #welcome-bg { background: linear-gradient(135deg,#ffcc00 0%,#ff9900 100%); filter: none; opacity: 0.8; }
body.royale-mode .welcome-inner h1 { color: #ffcc00; text-shadow: 0 2px 20px rgba(255,204,0,0.5); }
body.royale-mode .welcome-inner .welcome-sub { color: #bbd6f0; }
body.royale-mode #sidebar { background: linear-gradient(180deg,#2d4c73,#1a3654); border-right: 2px solid #ffcc00; }
body.royale-mode #chat-header { background: linear-gradient(180deg,#3a5e87,#2d4c73); border-bottom: 2px solid #ffcc00; }
body.royale-mode #input-area { background: linear-gradient(180deg,#2d4c73,#1a3654); border-top: 2px solid #ffcc00; }
body.royale-mode .sidebar-tab { background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.1); color: #fff; border-radius: 4px; }
body.royale-mode .sidebar-tab.active { background: #ffcc00; border-color: #ffcc00; color: #000; font-weight: 700; }
body.royale-mode .memory-item { background: rgba(255,255,255,0.06); border: 1px solid rgba(255,204,0,0.15); }
body.royale-mode .history-session { background: rgba(255,255,255,0.06); border: 1px solid rgba(255,204,0,0.15); }
body.royale-mode .history-session.open { border-color: #ffcc00; }
body.royale-mode .bubble { background: rgba(255,255,255,0.08); border: 1px solid rgba(255,204,0,0.15); border-radius: 8px; }
body.royale-mode .message.user .bubble { background: linear-gradient(135deg,#ffcc00,#ff9900); color: #000; }
body.royale-mode .message.user .avatar { background: #1a3654; }
body.royale-mode .message.bot .avatar { background: #ffcc00; color: #000; }
body.royale-mode #chat-input,body.royale-mode .browser-search input { background: rgba(0,0,0,0.2); border: 1px solid rgba(255,204,0,0.3); }
body.royale-mode #chat-input:focus { border-color: #ffcc00; box-shadow: 0 0 0 3px rgba(255,204,0,0.2); }
body.royale-mode .input-btn { background: rgba(0,0,0,0.2); border: 1px solid rgba(255,204,0,0.3); }
body.royale-mode .input-btn:hover { border-color: #ffcc00; color: #ffcc00; }
body.royale-mode .setting-group select { background: rgba(0,0,0,0.2); border: 1px solid rgba(255,204,0,0.3); }
body.royale-mode #settings-panel { background: linear-gradient(180deg,#2d4c73,#1a3654); border: 2px solid #ffcc00; border-radius: 12px; }
body.royale-mode .settings-header { border-bottom: 1px solid rgba(255,204,0,0.2); }
body.royale-mode .logo { color: #ffcc00; font-weight: 800; }
body.royale-mode .icon-btn:hover { background: rgba(255,204,0,0.2); color: #ffcc00; }
body.royale-mode ::-webkit-scrollbar-thumb { background: #ffcc00; border-radius: 2px; }
body.royale-mode .browser-result-url { color: #00cc44; }
body.royale-mode .news-meta { color: #bbd6f0; }
