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

:root {
  --bg:       #0d0d0f;
  --surface:  #111114;
  --border:   #1e1e26;
  --muted:    #6b6b78;
  --text:     #e2e2e8;
  --accent:   #6366f1;
  --accent2:  #4f46e5;
  --danger:   #f87171;
  --user-bg:  #1a1a2e;
  --ai-bg:    #111114;
  --radius:   12px;
  --font:     -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --max-w:    800px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
}

/* ── Screens ── */
.screen { height: 100vh; display: flex; flex-direction: column; }
.hidden { display: none !important; }

/* ── Auth ── */
#auth-screen {
  align-items: center;
  justify-content: center;
  position: relative;
}

.auth-lang {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  gap: 4px;
}

.auth-wrap {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 0 24px;
}

.auth-logo-svg {
  width: 140px;
  height: auto;
  display: block;
  margin: 0 auto 4px;
  cursor: default;
  opacity: 0.18;
  transition: opacity 0.3s ease, filter 0.3s ease, transform 0.3s ease;
}
.auth-logo-svg:hover {
  opacity: 1;
  filter: drop-shadow(0 0 6px rgba(99,102,241,0.55)) drop-shadow(0 0 18px rgba(99,102,241,0.25));
  transform: scale(1.05);
}

.logo {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.04em;
  color: #fff;
  text-align: center;
  margin-bottom: 4px;
}

.auth-sub {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  margin-bottom: 8px;
}

input[type="email"],
input[type="password"] {
  width: 100%;
  background: #1a1a1e;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  padding: 11px 14px;
  outline: none;
  transition: border-color 0.15s;
}
input:focus { border-color: var(--accent); }

button {
  cursor: pointer;
  border: none;
  font-family: var(--font);
  font-size: 14px;
  transition: background 0.15s, opacity 0.15s;
}

#auth-btn {
  width: 100%;
  background: var(--accent);
  border-radius: 8px;
  color: #fff;
  font-weight: 600;
  padding: 11px;
}
#auth-btn:hover { background: var(--accent2); }
#auth-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.auth-toggle {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}
.auth-toggle a { color: var(--accent); text-decoration: none; margin-left: 4px; }
.auth-toggle a:hover { text-decoration: underline; }

.error {
  color: var(--danger);
  font-size: 12px;
  text-align: center;
  min-height: 16px;
}

.auth-password-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  animation: slideDown 0.18s ease;
}
.auth-password-wrap.hidden { display: none; }

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

.auth-extra { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 100%; }
.auth-extra.hidden { display: none; }

.forgot {
  color: var(--muted);
  font-size: 12px;
  text-decoration: none;
  text-align: right;
  transition: color 0.15s;
  margin-top: -4px;
}
.forgot:hover { color: var(--accent); }

/* ── App layout ── */
#app-screens {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.app-screen {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* ── Topbar ── */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px max(16px, calc(50% - var(--max-w) / 2));
  flex-shrink: 0;
}

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

.logo-sm {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.04em;
  color: #fff;
  white-space: nowrap;
}

#model-select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 12px;
  padding: 4px 8px;
  outline: none;
  cursor: pointer;
  max-width: 180px;
}
#model-select:focus { border-color: var(--accent); }

/* ── Tool buttons ── */
.tool-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: transparent;
  border-radius: 6px;
  color: var(--muted);
  padding: 5px 8px;
  line-height: 1;
}
.tool-btn span { font-size: 10px; line-height: 1; white-space: nowrap; }
.tool-btn:hover { background: var(--border); color: var(--text); }
.tool-btn.active { color: var(--accent); }

/* ── Hamburger dropdown ── */
.menu-wrap { position: relative; }

.dropdown {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: var(--surface);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  min-width: 200px;
  z-index: 200;
  box-shadow: 0 8px 32px rgba(0,0,0,0.7), 0 0 0 1px rgba(99,102,241,0.08);
  overflow: hidden;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 14px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  text-align: left;
  border-radius: 0;
}
.dropdown-item:hover { background: var(--border); }
.dropdown-item--accent { color: var(--accent); }
.dropdown-item--accent svg { stroke: var(--accent); }
.dropdown-item--accent:hover { background: rgba(99,102,241,0.08); }
.dropdown-item--warn { color: #eab308; }
.dropdown-item--warn svg { stroke: #eab308; }
.dropdown-item--warn:hover { background: rgba(234,179,8,0.08); }
.dropdown-item--pack { color: var(--muted); gap: 8px; }
.dropdown-item--pack svg { stroke: #a5b4fc; flex-shrink: 0; }
.dropdown-item--pack:hover { background: rgba(99,102,241,0.06); }
.pack-menu-text { flex: 1; font-size: 12px; color: var(--muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.dropdown-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* ── System prompt panel ── */
.sysprompt-panel {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sysprompt-header {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px max(16px, calc(50% - var(--max-w) / 2));
  cursor: pointer;
  user-select: none;
  transition: background 0.12s;
}
.sysprompt-header:hover { background: rgba(255,255,255,0.035); }

.sysprompt-preview {
  flex: 1;
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sysprompt-preview.has-content { color: var(--text); font-style: normal; }

#sysprompt-chevron { transition: transform 0.2s; color: var(--muted); }
.sysprompt-panel:not(.collapsed) #sysprompt-chevron { transform: rotate(180deg); }

.sysprompt-body { padding: 4px max(16px, calc(50% - var(--max-w) / 2)) 10px; border-top: 1px solid var(--border); }
.sysprompt-panel.collapsed .sysprompt-body { display: none; }

.sysprompt-textarea {
  width: 100%;
  background: #1a1a1e;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.5;
  padding: 8px 10px;
  resize: none;
  outline: none;
  height: 80px;
  transition: border-color 0.15s;
}
.sysprompt-textarea:focus { border-color: var(--accent); }
.sysprompt-row { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.sysprompt-save { background: var(--accent); color: #fff; border-radius: 6px; font-size: 12px; font-weight: 500; padding: 5px 12px; }
.sysprompt-save:hover { background: var(--accent2); }
.sysprompt-clear, .sysprompt-cancel { background: transparent; border: 1px solid var(--border); color: var(--muted); border-radius: 6px; font-size: 12px; padding: 5px 10px; }
.sysprompt-clear:hover, .sysprompt-cancel:hover { background: var(--border); color: var(--text); }
.sysprompt-saved { font-size: 12px; color: #34d399; margin-left: auto; }
#menu-btn.has-sysprompt { color: var(--accent); }

/* ── Messages ── */
#messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

/* Center messages content */
#messages > * {
  max-width: var(--max-w);
  width: 100%;
  margin-left: auto;
  margin-right: auto;
}

#messages::-webkit-scrollbar { width: 4px; }
#messages::-webkit-scrollbar-track { background: transparent; }
#messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.msg {
  display: flex;
  flex-direction: column;
  max-width: 100%;
  animation: fadeIn 0.15s ease;
}

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

.msg-user { align-items: flex-end; }
.msg-ai   { align-items: flex-start; }

.msg-bubble {
  padding: 12px 16px;
  border-radius: var(--radius);
  max-width: 85%;
  word-break: break-word;
  position: relative;
}

.msg-user .msg-bubble {
  background: var(--user-bg);
  border: 1px solid #2a2a4a;
  color: #c7c7f0;
  border-bottom-right-radius: 4px;
}

.user-md > *:first-child { margin-top: 0; }
.user-md > *:last-child  { margin-bottom: 0; }
.user-md p               { margin-bottom: 6px; }
.user-md ul, .user-md ol { padding-left: 18px; margin-bottom: 6px; }
.user-md li              { margin-bottom: 2px; }
.user-md strong          { color: #e0e0ff; }
.user-md code            { background: rgba(255,255,255,0.08); color: #c7c7f0; }

.msg-ai .msg-bubble {
  background: #15151c;
  border: 1px solid rgba(255,255,255,0.07);
  border-left: 3px solid rgba(99,102,241,0.45);
  color: var(--text);
  border-bottom-left-radius: 4px;
  width: 100%;
  max-width: 100%;
  line-height: 1.65;
}

.msg-image {
  max-width: 100%;
  max-height: 300px;
  border-radius: 8px;
  display: block;
  margin-bottom: 6px;
}

/* Markdown inside AI bubble */
.msg-bubble p { margin-bottom: 8px; }
.msg-bubble p:last-child { margin-bottom: 0; }
.msg-bubble h1, .msg-bubble h2, .msg-bubble h3 { font-size: 14px; font-weight: 600; margin: 10px 0 6px; }
.msg-bubble ul, .msg-bubble ol { padding-left: 20px; margin: 4px 0 8px; }
.msg-bubble li { margin-bottom: 3px; }
.msg-bubble ol { list-style-type: decimal; }
.msg-bubble ul { list-style-type: disc; }
.msg-bubble strong { font-weight: 600; color: #fff; }
.msg-bubble em { font-style: italic; color: #b0b0c8; }
.msg-bubble del { text-decoration: line-through; color: var(--muted); }
.msg-bubble a { color: #a78bfa; text-decoration: none; }
.msg-bubble a:hover { color: #c4b5fd; text-decoration: underline; }
.msg-bubble blockquote { border-left: 3px solid #3a3a6a; margin: 6px 0; padding: 4px 12px; color: #9090c0; font-style: italic; }
.msg-bubble table { border-collapse: collapse; margin: 8px 0; font-size: 12px; width: 100%; overflow-x: auto; display: block; }
.msg-bubble th, .msg-bubble td { border: 1px solid var(--border); padding: 5px 10px; text-align: left; white-space: nowrap; }
.msg-bubble th { background: #1a1a2e; font-weight: 600; }
.msg-bubble tr:nth-child(even) td { background: rgba(255,255,255,0.02); }
.msg-bubble code { background: #1a1a2e; border: 1px solid #2a2a4a; border-radius: 4px; font-family: "JetBrains Mono", "Fira Code", monospace; font-size: 12px; padding: 1px 5px; }
.msg-bubble pre { background: #0a0a12; border: 1px solid var(--border); border-radius: 8px; margin: 8px 0; overflow: hidden; }

.pre-header { display: flex; align-items: center; justify-content: space-between; padding: 6px 12px; background: #111118; border-bottom: 1px solid var(--border); }
.pre-lang { color: var(--muted); font-size: 11px; font-family: monospace; }
.copy-btn { background: transparent; color: var(--muted); font-size: 11px; padding: 2px 6px; border-radius: 4px; }
.copy-btn:hover { background: var(--border); color: var(--text); }

.msg-bubble pre code { background: none; border: none; border-radius: 0; display: block; font-size: 12px; line-height: 1.6; overflow-x: auto; padding: 10px 12px; white-space: pre; }

/* Typing indicator */
.typing-dot { display: inline-flex; gap: 4px; align-items: center; padding: 4px 2px; }
.typing-dot span { width: 6px; height: 6px; background: var(--muted); border-radius: 50%; animation: blink 1.2s infinite; }
.typing-dot span:nth-child(2) { animation-delay: 0.2s; }
.typing-dot span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%,80%,100% { opacity: 0.3; } 40% { opacity: 1; } }

/* Msg action buttons */
.msg-actions { display: flex; gap: 4px; margin-top: 4px; padding: 0 2px; opacity: 0; transition: opacity 0.15s; }
.msg-ai:hover   .msg-actions { opacity: 1; }
.msg-user:hover .msg-actions { opacity: 1; }
.msg-user .msg-actions { justify-content: flex-end; }

.msg-action-btn { background: transparent; color: var(--muted); font-size: 11px; padding: 2px 7px; border-radius: 4px; border: 1px solid transparent; }
.msg-action-btn:hover { background: var(--border); color: var(--text); border-color: var(--border); }

/* Image wrap with download btn */
.msg-image-wrap { position: relative; display: inline-block; max-width: 100%; }
.img-download-btn {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(0,0,0,0.65);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 6px;
  color: #fff;
  font-size: 14px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}
.msg-image-wrap:hover .img-download-btn { opacity: 1; }

/* Image generating state */
.img-generating {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  padding: 4px 0;
}

/* Image limit card */
.img-limit-card { display: flex; flex-direction: column; gap: 8px; padding: 2px 0; }
.img-limit-title { font-size: 14px; font-weight: 600; color: var(--text); }
.img-limit-sub { font-size: 12px; color: var(--muted); }
.img-limit-actions { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.img-limit-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--border);
  color: var(--text);
  font-size: 13px;
  border: 1px solid rgba(255,255,255,0.08);
  cursor: pointer;
  transition: background 0.15s;
}
.img-limit-btn:hover { background: #2a2a3a; }
.img-limit-btn.accent { background: var(--accent); color: #fff; }
.img-limit-btn.accent:hover { background: var(--accent2); }

/* ── Welcome ── */
.welcome {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  pointer-events: none;
  min-height: 300px;
}
.welcome-ears {
  width: 160px;
  height: auto;
  display: block;
  color: #fff;
  opacity: 0.12;
}
.welcome .logo-lg {
  font-size: 42px;
  font-weight: 700;
  letter-spacing: -0.04em;
  color: #fff;
  opacity: 0.12;
  margin-top: -8px;
}
.welcome-tagline {
  opacity: 0.55;
  font-size: 15px;
  cursor: pointer;
  pointer-events: auto;
  transition: opacity 0.15s;
}
.welcome-tagline:hover { opacity: 0.85; }

/* ── Limit banner ── */
.limit-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #422006;
  border: 1px solid #92400e;
  border-radius: 8px;
  padding: 7px 10px;
  margin-bottom: 8px;
  font-size: 12px;
  color: #fcd34d;
}
.limit-banner.hidden { display: none; }
.limit-banner span { flex: 1; }
.limit-banner-close { background: transparent; border: none; color: #fcd34d; cursor: pointer; font-size: 12px; padding: 0 2px; opacity: 0.7; flex-shrink: 0; }
.limit-banner-close:hover { opacity: 1; }

/* ── Input area ── */
.input-area {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  flex-shrink: 0;
  position: relative;
}

/* Center specific input elements */
#limit-banner,
#image-badge {
  max-width: var(--max-w);
  margin-left: auto;
  margin-right: auto;
}

.attach-badge {
  background: #1a1a2e;
  border: 1px solid #2a2a4a;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #9090c0;
  padding: 5px 10px;
  margin-bottom: 8px;
}
.attach-badge span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

#image-preview {
  width: 24px;
  height: 24px;
  object-fit: cover;
  border-radius: 3px;
  flex-shrink: 0;
}

.badge-remove { background: transparent; color: var(--muted); font-size: 14px; padding: 0 0 0 4px; line-height: 1; margin-left: auto; flex-shrink: 0; }
.badge-remove:hover { color: var(--danger); }

.input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  max-width: var(--max-w);
  margin: 0 auto;
  width: 100%;
}

#user-input {
  flex: 1;
  background: #1a1a1e;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  max-height: 200px;
  outline: none;
  overflow-y: auto;
  padding: 10px 16px;
  resize: none;
  transition: border-color 0.15s;
}
#user-input:focus { border-color: var(--accent); }
#user-input::placeholder { color: #9494a2; }

#send-btn {
  background: var(--accent);
  border-radius: 10px;
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  height: 42px;
  width: 42px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
#send-btn:hover { background: var(--accent2); }
#send-btn:disabled { opacity: 0.4; cursor: not-allowed; }
#send-btn.stop-mode { background: #374151; font-size: 14px; }
#send-btn.stop-mode:hover { background: #ef4444; }
#user-input:disabled { opacity: 0.5; cursor: not-allowed; }

/* Input tools row */
.input-tools {
  display: flex;
  gap: 6px;
  padding-top: 8px;
  max-width: var(--max-w);
  margin: 0 auto;
  width: 100%;
}

.add-ctx-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px 4px 8px;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.12);
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  white-space: nowrap;
}
.add-ctx-btn:hover { border-color: rgba(255,255,255,0.25); color: var(--text); }
.add-ctx-btn.active { border-color: var(--accent); color: var(--accent); background: rgba(91,91,214,0.1); }

/* ── Scroll-to-bottom button ── */
.scroll-btn {
  position: absolute;
  bottom: 90px;
  right: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text);
  font-size: 16px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 10px rgba(0,0,0,0.55);
  z-index: 10;
  transition: background 0.15s;
  line-height: 1;
}
.scroll-btn:hover { background: var(--border); }

/* ── Slash palette ── */
.slash-palette {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  right: 0;
  max-width: var(--max-w);
  margin: 0 auto;
  background: #1e1e2a;
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 12px;
  padding: 6px;
  z-index: 200;
  box-shadow: 0 -8px 24px rgba(0,0,0,0.5);
}
.slash-palette.hidden { display: none; }
.slash-palette-header { display: flex; align-items: center; justify-content: space-between; padding: 4px 8px 6px; }
.slash-palette-title { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.slash-palette-close { background: transparent; color: var(--muted); font-size: 12px; padding: 2px 6px; border-radius: 4px; }
.slash-palette-close:hover { background: var(--border); color: var(--text); }
.slash-item { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 8px; cursor: pointer; transition: background 0.1s; }
.slash-item:hover, .slash-item.active { background: rgba(255,255,255,0.06); }
.slash-item-cmd { font-size: 13px; font-weight: 600; color: var(--accent); font-family: monospace; min-width: 60px; }
.slash-item-desc { font-size: 12px; color: var(--muted); }

/* ── Drag & Drop overlay ── */
.drop-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  pointer-events: none;
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: dropOverlayIn 0.14s ease;
  background: rgba(8, 8, 16, 0.94);
  border: 2px dashed rgba(99, 102, 241, 0.65);
}
.drop-overlay.drop-mode-text { border-color: rgba(52,211,153,0.65); background: rgba(8,16,12,0.94); }
.drop-overlay.drop-mode-error { border-color: rgba(248,113,113,0.65); background: rgba(16,8,8,0.94); }

.drop-content { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; padding: 0 24px; }
.drop-icon { color: var(--accent); opacity: 0.85; }
.drop-mode-text  .drop-icon { color: #34d399; }
.drop-mode-error .drop-icon { color: var(--danger); }
#drop-label { font-size: 15px; font-weight: 700; color: #e8e8ff; order: -1; }
#drop-hint { font-size: 11px; color: var(--muted); }
@keyframes dropOverlayIn { from { opacity: 0; } to { opacity: 1; } }

/* ── Confirm modal ── */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.confirm-overlay.hidden { display: none; }
.confirm-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  max-width: 320px;
  width: 90%;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.confirm-box p { font-size: 14px; color: var(--text); line-height: 1.5; }
.confirm-btns { display: flex; gap: 8px; justify-content: flex-end; }
.confirm-btns button { padding: 7px 16px; border-radius: 6px; font-size: 13px; font-weight: 500; }
.confirm-btns button:last-child { background: var(--border); color: var(--text); }
.confirm-btns button:last-child:hover { background: #2a2a36; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #ef4444; }

/* ── Toast notifications ── */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: #1e1e2a;
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 13px;
  color: var(--text);
  z-index: 2000;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  white-space: nowrap;
}
.toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast-warn { border-color: #92400e; background: #291500; color: #fcd34d; }
.toast-ok { border-color: #065f46; background: #022c22; color: #34d399; }

/* ── Tooltip ── */
#tt {
  position: fixed;
  background: #18181e;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 6px;
  color: var(--text);
  font-size: 11px;
  font-weight: 400;
  max-width: 220px;
  white-space: normal;
  line-height: 1.4;
  padding: 6px 9px;
  pointer-events: none;
  z-index: 9999;
  box-shadow: 0 4px 16px rgba(0,0,0,0.6);
  display: none;
}

/* ── Syntax highlighting ── */
.hl-kw      { color: #c678dd; }
.hl-str     { color: #98c379; }
.hl-comment { color: #5c6370; font-style: italic; }
.hl-num     { color: #d19a66; }
.hl-fn      { color: #61afef; }
.hl-tag     { color: #e06c75; }
.hl-attr    { color: #e5c07b; }
.hl-prop    { color: #56b6c2; }

/* ── New Chat animation ── */
@keyframes msgsClear {
  0%   { opacity: 1; transform: translateY(0) scale(1); }
  45%  { opacity: 0; transform: translateY(-8px) scale(0.99); }
  46%  { opacity: 0; transform: translateY(4px) scale(0.99); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
.msgs-clearing { animation: msgsClear 0.32s ease; pointer-events: none; }
@keyframes newChatSpin { from { transform: rotate(0deg); } to { transform: rotate(-360deg); } }
#new-chat-btn.spinning svg { animation: newChatSpin 0.38s cubic-bezier(0.4,0,0.2,1); }

/* ── Lang buttons ── */
.lang-picker { display: flex; align-items: center; justify-content: space-between; cursor: default; gap: 8px; }
.lang-label { color: var(--muted); font-size: 12px; }
.lang-btns { display: flex; gap: 4px; }
.lang-btn { background: transparent; border: 1px solid var(--border); border-radius: 4px; color: var(--muted); font-size: 11px; font-weight: 600; padding: 2px 8px; line-height: 1.6; }
.lang-btn:hover { background: var(--border); color: var(--text); }
.lang-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ── Dismiss msg button ── */
.msg-dismiss-btn {
  position: absolute;
  top: 6px; right: 6px;
  background: none; border: none; color: var(--muted);
  font-size: 12px; cursor: pointer; padding: 2px 5px;
  border-radius: 4px; line-height: 1; opacity: 0.6;
}
.msg-dismiss-btn:hover { opacity: 1; background: rgba(255,255,255,0.08); }

/* ── Site footer ── */
.site-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 8px 16px;
  flex-shrink: 0;
}
.site-footer a {
  color: var(--muted);
  font-size: 11px;
  text-decoration: none;
  transition: color 0.15s;
}
.site-footer a:hover { color: var(--text); }
.footer-dot { color: var(--border); font-size: 11px; }

/* ── Responsive ── */
@media (max-width: 600px) {
  .topbar { padding: 6px 12px; }
  #messages { padding: 16px 12px; }
  .input-area { padding: 10px 12px; }
  .sysprompt-header { padding: 7px 12px; }
  .sysprompt-body { padding: 4px 12px 10px 12px; }
  .msg-bubble { padding: 10px 12px; }
  .msg-bubble { max-width: 92%; }
}
