@import url("https://fonts.googleapis.com/css2?family=Changa+One:ital@0;1&family=Inter:wght@400;500;600;700&family=Space+Grotesk:wght@500;600;700&display=swap");

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

/* ============ THEME TOKENS — "Nebula" palette ============ */
:root {
  --bg-app: radial-gradient(circle at 50% -10%, #2b1240 0%, #150a24 55%, #0a0614 100%);
  --bg-panel: rgba(255, 255, 255, 0.045);
  --bg-panel-solid: #1c0f30;
  --bg-input: rgba(255, 255, 255, 0.06);
  --bg-btn: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.1);
  --border-soft: rgba(255, 255, 255, 0.08);
  --text-primary: #fbf2ff;
  --text-secondary: rgba(251, 242, 255, 0.65);
  --text-muted: rgba(251, 242, 255, 0.4);
  --accent-1: rgb(217, 70, 239);   /* magenta */
  --accent-2: rgb(129, 140, 248);  /* indigo */
  --accent-3: rgb(251, 191, 36);   /* amber — highlights & motion */
  --accent-gradient: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  --danger: rgb(248, 113, 113);
  --bot-bubble: rgba(255, 255, 255, 0.07);
  --user-bubble: var(--accent-gradient);
  --code-bg: rgba(0, 0, 0, 0.28);
  --code-header-bg: rgba(255, 255, 255, 0.05);
  --inline-code-bg: rgba(255, 255, 255, 0.12);
  --shadow-soft: 0 8px 28px rgba(10, 4, 18, 0.5);
  color-scheme: dark;
}

html[data-theme="light"] {
  --bg-app: radial-gradient(circle at 50% -10%, #fbe8fb 0%, #f7f2fc 55%, #fdfaff 100%);
  --bg-panel: rgba(50, 15, 60, 0.035);
  --bg-panel-solid: #ffffff;
  --bg-input: rgba(50, 15, 60, 0.045);
  --bg-btn: rgba(50, 15, 60, 0.06);
  --border: rgba(50, 15, 60, 0.1);
  --border-soft: rgba(50, 15, 60, 0.08);
  --text-primary: #2c1238;
  --text-secondary: rgba(44, 18, 56, 0.65);
  --text-muted: rgba(44, 18, 56, 0.42);
  --accent-1: rgb(192, 38, 211);
  --accent-2: rgb(79, 70, 229);
  --accent-3: rgb(217, 119, 6);
  --danger: rgb(211, 65, 65);
  --bot-bubble: rgba(50, 15, 60, 0.05);
  --code-bg: rgba(50, 15, 60, 0.05);
  --code-header-bg: rgba(50, 15, 60, 0.04);
  --inline-code-bg: rgba(50, 15, 60, 0.08);
  --shadow-soft: 0 8px 24px rgba(50, 15, 60, 0.12);
  color-scheme: light;
}

body {
  min-height: 100vh;
  width: 100%;
  background: var(--bg-app);
  display: flex;
  justify-content: center;
  font-family: "Inter", sans-serif;
  color: var(--text-primary);
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom) 0;
  transition: background 0.35s ease, color 0.35s ease;
}

.hidden { display: none !important; }

/* ============ AUTH SCREEN ============ */
#authScreen {
  width: 100%;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

#authCard {
  width: 100%;
  max-width: 380px;
  background: var(--bg-panel-solid);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 32px 26px;
  text-align: center;
  box-shadow: var(--shadow-soft);
}

#authLogo {
  width: 56px;
  filter: drop-shadow(0 0 16px rgba(217, 70, 239, 0.45));
  margin-bottom: 10px;
}

#authTitle {
  font-family: "Changa One", sans-serif;
  font-size: 24px;
  margin-bottom: 4px;
}

#authName {
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

#authSubtitle {
  font-size: 13.5px;
  color: var(--text-secondary);
  margin-bottom: 22px;
}

#authTabs {
  display: flex;
  background: var(--bg-input);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 20px;
}

.authTab {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  padding: 9px 0;
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.authTab.active {
  background: var(--accent-gradient);
  color: #fff;
}

#authForm {
  display: flex;
  flex-direction: column;
  text-align: left;
  gap: 4px;
}

#authForm input {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  margin-bottom: 12px;
  font-family: inherit;
}

#authForm input:focus {
  border-color: var(--accent-2);
}

#authError {
  color: var(--danger);
  font-size: 12.5px;
  margin: -4px 0 10px;
}

#authSubmitBtn {
  margin-top: 4px;
  padding: 12px;
  border-radius: 12px;
  border: none;
  background: var(--accent-gradient);
  color: #fff;
  font-weight: 600;
  font-size: 14.5px;
  cursor: pointer;
}

#authNote {
  margin-top: 18px;
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-muted);
}

/* ============ APP SHELL ============ */
#app {
  width: 100%;
  max-width: 640px;
  height: 100vh;
  display: flex;
  position: relative;
  overflow: hidden;
}

#mainCol {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 14px;
  gap: 12px;
  height: 100%;
}

/* ============ SIDEBAR ============ */
#sidebar {
  position: fixed;
  top: 0;
  left: -300px;
  width: 280px;
  max-width: 82vw;
  height: 100%;
  background: var(--bg-panel-solid);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  z-index: 60;
  transition: left 0.28s ease;
}

#sidebar.open { left: 0; }

#sidebarOverlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 3, 12, 0.5);
  z-index: 55;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease;
}

#sidebarOverlay.open {
  opacity: 1;
  pointer-events: auto;
}

#sidebarHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  font-size: 15px;
  padding: 4px 6px 14px;
}

#closeSidebarBtn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 16px;
  cursor: pointer;
}

#newChatSideBtn {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  margin-bottom: 10px;
}

#newChatSideBtn:hover { background: var(--bg-btn); }

#chatSearchInput {
  width: 100%;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 12.5px;
  margin-bottom: 8px;
  outline: none;
  font-family: inherit;
}

#chatSearchInput:focus { border-color: var(--accent-2); }
#chatSearchInput::placeholder { color: var(--text-muted); }

#chatHistoryList {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#chatHistoryList:empty::before {
  content: "No chats yet";
  color: var(--text-muted);
  font-size: 12.5px;
  padding: 10px 8px;
}

.historyItem {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 10px;
  border-radius: 10px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 13px;
}

.historyItem:hover { background: var(--bg-input); }

.historyItem.active {
  background: var(--bg-input);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: inset 2px 0 0 var(--accent-2);
}

.historyItemTitle {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.historyRenameInput {
  flex: 1;
  background: var(--bg-panel-solid);
  border: 1px solid var(--accent-2);
  border-radius: 8px;
  padding: 6px 8px;
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  font-family: inherit;
  min-width: 0;
}

.historyDeleteBtn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  flex-shrink: 0;
}

.historyDeleteBtn:hover {
  color: var(--danger);
  background: rgba(248, 113, 113, 0.12);
}

#clearAllChatsBtn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 11.5px;
  cursor: pointer;
  padding: 8px 6px;
  text-align: left;
}

#clearAllChatsBtn:hover { color: var(--danger); }

#sidebarFooter {
  border-top: 1px solid var(--border-soft);
  padding-top: 10px;
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

#sidebarUsername {
  font-size: 12.5px;
  color: var(--text-secondary);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#logoutBtn {
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.25);
  color: var(--danger);
  font-size: 12px;
  padding: 7px 10px;
  border-radius: 9px;
  cursor: pointer;
  flex-shrink: 0;
}

/* Header */
#header { flex-shrink: 0; }

#headerRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

#menuBtn {
  background: var(--bg-btn);
  border: 1px solid var(--border);
  color: var(--text-primary);
  width: 36px;
  height: 36px;
  border-radius: 10px;
  font-size: 15px;
  cursor: pointer;
  flex-shrink: 0;
}

#headerTitle {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

#logo {
  width: 42px;
  filter: drop-shadow(0 0 14px rgba(217, 70, 239, 0.5));
  flex-shrink: 0;
}

h1 {
  color: var(--text-primary);
  font-family: "Changa One", sans-serif;
  font-size: 19px;
  line-height: 1.2;
}

#name {
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

#status {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
  transition: color 0.3s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#status.listening { color: var(--accent-2); }
#status.thinking { color: var(--accent-3); }
#status.error { color: var(--danger); }

#headerBtns {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

#headerBtns button {
  background: var(--bg-btn);
  border: 1px solid var(--border);
  color: var(--text-primary);
  width: 36px;
  height: 36px;
  border-radius: 10px;
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

#headerBtns button:hover { background: var(--bg-input); }

/* Theme toggle */
#themeToggleBtn {
  position: relative;
  overflow: hidden;
}

.themeIcon {
  width: 18px;
  height: 18px;
  color: var(--text-primary);
}

/* Chat log */
#chatWrap {
  flex: 1;
  min-height: 0;
  width: 100%;
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  border-radius: 18px;
  padding: 8px;
  overflow: hidden;
  position: relative;
}

#chatLog {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 8px;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: var(--accent-1) transparent;
}

#chatLog:empty::before {
  content: "Ask me anything 👋";
  color: var(--text-muted);
  font-size: 14px;
  margin: auto;
}

/* Suggestion chips shown on an empty chat */
#suggestionChips {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.chip {
  background: var(--bg-panel-solid);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 600;
  padding: 9px 14px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
  font-family: inherit;
  transition: all 0.2s;
}

.chip:hover {
  color: var(--text-primary);
  border-color: var(--accent-2);
  transform: translateY(-1px);
}

#scrollBottomBtn {
  position: absolute;
  bottom: 16px;
  right: 16px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-panel-solid);
  color: var(--text-primary);
  font-size: 15px;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
}

/* ============ MESSAGE BUBBLES ============ */
.msg {
  max-width: 82%;
  display: flex;
  flex-direction: column;
  gap: 3px;
  animation: fadeIn 0.28s ease;
}

.msg.user { align-self: flex-end; align-items: flex-end; }
.msg.bot { align-self: flex-start; align-items: flex-start; }

.msgContent {
  padding: 11px 15px;
  border-radius: 18px;
  font-size: 14.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-wrap: break-word;
  max-width: 100%;
}

.msg.user .msgContent {
  background: var(--user-bubble);
  color: #fff;
  border-radius: 18px 18px 4px 18px;
}

.msg.bot .msgContent {
  background: var(--bot-bubble);
  border: 1px solid var(--border-soft);
  color: var(--text-primary);
  border-radius: 18px 18px 18px 4px;
}

.msg.bot.error .msgContent {
  border-color: rgba(248, 113, 113, 0.35);
  color: rgb(255, 140, 140);
}

.msgContent a { color: var(--accent-2); text-decoration: underline; word-break: break-all; }

.msgImage {
  display: block;
  max-width: 220px;
  max-height: 220px;
  border-radius: 14px;
  margin-bottom: 6px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  object-fit: cover;
}

.inlineCode {
  background: var(--inline-code-bg);
  padding: 1px 5px;
  border-radius: 5px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.9em;
}

.codeBlock {
  margin: 6px 0;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border-soft);
  background: var(--code-bg);
  max-width: 100%;
}

.codeBlockHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 10px;
  font-size: 11px;
  color: var(--text-muted);
  background: var(--code-header-bg);
  text-transform: lowercase;
}

.codeCopyBtn {
  background: none;
  border: 1px solid var(--border-soft);
  color: var(--text-secondary);
  font-size: 10.5px;
  padding: 3px 9px;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
}

.codeCopyBtn:hover { color: var(--text-primary); background: var(--bg-input); }

.codeBlock pre {
  margin: 0;
  padding: 10px 12px;
  overflow-x: auto;
}

.codeBlock code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre;
  color: var(--text-primary);
}

/* Typewriter cursor while a bot message is streaming in */
.msgContent.typing::after {
  content: "";
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--accent-3);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: blink 0.9s steps(1) infinite;
}

@keyframes blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

.msgMeta {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 4px;
}

.msg.user .msgMeta { flex-direction: row-reverse; }

.msgTime {
  font-size: 10.5px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.msgActions {
  display: flex;
  gap: 2px;
  opacity: 0.65;
}

.msgActionBtn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  padding: 3px 6px;
  border-radius: 6px;
  line-height: 1;
}

.msgActionBtn:active,
.msgActionBtn:hover {
  color: var(--text-primary);
  background: var(--bg-input);
  opacity: 1;
}

.msgActionBtn.speaking { color: var(--accent-3); }

/* Thinking indicator */
.thinkingBubble {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 13px 16px;
  background: var(--bot-bubble);
  border: 1px solid var(--border-soft);
  border-radius: 18px 18px 18px 4px;
  animation: fadeIn 0.28s ease;
}

.thinkingBubble span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-3);
  animation: bounce 1.1s infinite ease-in-out;
}

.thinkingBubble span:nth-child(2) { animation-delay: 0.15s; }
.thinkingBubble span:nth-child(3) { animation-delay: 0.3s; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-5px); opacity: 1; }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Controls */
#controls {
  flex-shrink: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  position: relative;
}

/* Attachment preview strip */
#attachmentStrip { width: 100%; }

#attachmentChip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-panel-solid);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 6px 10px 6px 6px;
  width: fit-content;
  max-width: 100%;
  box-shadow: var(--shadow-soft);
}

#attachmentThumb {
  width: 38px;
  height: 38px;
  object-fit: cover;
  border-radius: 9px;
  flex-shrink: 0;
}

#attachmentName {
  font-size: 12px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 140px;
}

#removeAttachmentBtn {
  background: var(--bg-input);
  border: none;
  color: var(--text-secondary);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 11px;
  cursor: pointer;
  flex-shrink: 0;
}
#removeAttachmentBtn:hover { color: var(--danger); }

/* Generic file attachment preview strip (mirrors the image chip) */
#fileAttachmentStrip { width: 100%; }

#fileAttachmentChip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-panel-solid);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 8px 10px;
  width: fit-content;
  max-width: 100%;
  box-shadow: var(--shadow-soft);
}

#fileAttachmentIcon { font-size: 18px; flex-shrink: 0; }

#fileAttachmentName {
  font-size: 12px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 200px;
}

#removeFileAttachmentBtn {
  background: var(--bg-input);
  border: none;
  color: var(--text-secondary);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 11px;
  cursor: pointer;
  flex-shrink: 0;
}
#removeFileAttachmentBtn:hover { color: var(--danger); }

/* File chip shown inside a sent chat bubble */
.msgFileChip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-input);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 6px 10px;
  margin-bottom: 6px;
  font-size: 12.5px;
  color: var(--text-secondary);
  max-width: 100%;
}
.msgFileIcon { font-size: 15px; }
.msgFileName {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Emoji picker + voice hint popovers */
#emojiPanel, #voiceHint {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  right: 0;
  max-width: 320px;
  margin: 0 auto;
  background: var(--bg-panel-solid);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-soft);
  padding: 10px;
  z-index: 40;
  animation: fadeIn 0.2s ease;
}

#emojiPanelHeader, #voiceHintHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 2px 4px 8px;
}

#emojiPanelHeader button, #voiceHintHeader button {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
}

#emojiGrid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  max-height: 190px;
  overflow-y: auto;
}

.emojiOption {
  background: none;
  border: none;
  font-size: 20px;
  padding: 6px 0;
  border-radius: 8px;
  cursor: pointer;
  line-height: 1;
}

.emojiOption:hover { background: var(--bg-input); }

#voiceHint ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 2px 4px 4px;
}

#voiceHint li {
  font-size: 12.5px;
  color: var(--text-secondary);
}

#textForm {
  width: 100%;
  display: flex;
  align-items: flex-end;
  gap: 6px;
}

#textForm button[type="button"] {
  flex-shrink: 0;
  background: var(--bg-btn);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  font-size: 15px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-primary);
}

#micBtn { width: 42px; height: 42px; font-size: 17px; }

#micBtn.active {
  animation: pulse 1.2s infinite;
  background: var(--accent-gradient);
}

#micInfoBtn { font-size: 13px; }

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.5); }
  70% { box-shadow: 0 0 0 14px rgba(251, 191, 36, 0); }
  100% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0); }
}

#textInput {
  flex: 1;
  padding: 11px 16px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  min-width: 0;
  font-family: inherit;
  resize: none;
  max-height: 140px;
  overflow-y: auto;
  line-height: 1.4;
}

#textInput:focus { border-color: var(--accent-2); }
#textInput::placeholder { color: var(--text-muted); }

#sendBtn, #stopBtn {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  color: #fff;
  font-size: 16px;
  cursor: pointer;
}

#sendBtn { background: var(--accent-gradient); }
#sendBtn:disabled { opacity: 0.5; cursor: not-allowed; }

#stopBtn { background: var(--danger); }

#modeRow {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

#modelBadge {
  background: var(--bg-input);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  padding: 5px 12px;
  font-family: "Space Grotesk", sans-serif;
  font-weight: 500;
  letter-spacing: 0.2px;
}

/* Settings modal */
#settingsOverlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 3, 12, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 70;
}

#settingsOverlay.hidden { display: none; }

#settingsPanel {
  width: 100%;
  max-width: 420px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--bg-panel-solid);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#settingsHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

#settingsHeader h2 {
  font-family: "Changa One", sans-serif;
  font-size: 20px;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

#closeSettingsBtn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
}

.fieldLabel {
  font-size: 12.5px;
  color: var(--text-secondary);
  margin-top: 6px;
}

#settingsPanel input,
#settingsPanel select,
#settingsPanel textarea {
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 13.5px;
  outline: none;
  font-family: inherit;
}

#settingsPanel input:focus,
#settingsPanel select:focus,
#settingsPanel textarea:focus { border-color: var(--accent-2); }

#settingsPanel textarea { resize: vertical; min-height: 60px; line-height: 1.5; }

.tempRow {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tempRow input[type="range"] {
  flex: 1;
  accent-color: var(--accent-1);
}

#temperatureValue {
  font-size: 12.5px;
  color: var(--text-secondary);
  min-width: 28px;
  text-align: right;
}

/* Toggle rows (auto-read / auto-send-voice) */
.toggleRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 2px;
  border-top: 1px solid var(--border-soft);
  margin-top: 4px;
}

.toggleLabel {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.toggleSub {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 1px;
}

.switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 24px;
  flex-shrink: 0;
}

.switch input { opacity: 0; width: 0; height: 0; }

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: 0.2s;
}

.slider::before {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  top: 3px;
  background: var(--text-secondary);
  border-radius: 50%;
  transition: 0.2s;
}

.switch input:checked + .slider {
  background: var(--accent-gradient);
  border-color: transparent;
}

.switch input:checked + .slider::before {
  transform: translateX(18px);
  background: #fff;
}

#resetSettingsBtn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 12.5px;
  padding: 9px;
  border-radius: 10px;
  cursor: pointer;
  margin-top: 2px;
  font-family: inherit;
}

#resetSettingsBtn:hover { color: var(--text-primary); background: var(--bg-input); }

#settingsNote {
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text-muted);
  margin-top: 4px;
}

#saveSettingsBtn {
  margin-top: 10px;
  padding: 11px;
  border-radius: 10px;
  border: none;
  background: var(--accent-gradient);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}

/* Phones */
@media (max-width: 480px) {
  #mainCol { padding: 10px; }
  h1 { font-size: 17px; }
  #logo { width: 36px; }
  #textForm button[type="button"] { width: 34px; height: 34px; font-size: 13px; }
  #micBtn { width: 38px; height: 38px; font-size: 15px; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .msg, .thinkingBubble, #micBtn.active, .thinkingBubble span, .msgContent.typing::after {
    animation: none !important;
  }
}