@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@300;400;500;600&family=Syne:wght@400;600;700;800&family=Noto+Sans+SC:wght@400;500;600;700&display=swap');

:root {
  --bg:        #0a0a0b;
  --bg2:       #111114;
  --bg3:       #18181d;
  --border:    #2a2a32;
  --border2:   #3a3a45;
  --text:      #e8e8f0;
  --text2:     #8888a0;
  --text3:     #55556a;
  --accent:    #7c6af7;
  --accent2:   #5b4fd4;
  --green:     #3ecf8e;
  --red:       #f87171;
  --yellow:    #fbbf24;
  --mono:      'JetBrains Mono', monospace;
  --sans:      'Syne', sans-serif;
  --ui:        'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --font-size-base: 14px;
  --font-weight-body: 500;
  --font-weight-strong: 600;
  --radius:    6px;
  --radius2:   10px;
}

/* ── Light Theme ── */
[data-theme="light"] {
  --bg:        #f5f5f7;
  --bg2:       #ffffff;
  --bg3:       #ebebef;
  --border:    #d8d8e0;
  --border2:   #c0c0cc;
  --text:      #1a1a2e;
  --text2:     #5a5a78;
  --text3:     #9090a8;
  --accent:    #6c5ce7;
  --accent2:   #5b4fd4;
  --green:     #00b894;
  --red:       #e55353;
  --yellow:    #f0a500;
}

/* ── Pure White Theme ── */
[data-theme="white"] {
  --bg:        #ffffff;
  --bg2:       #ffffff;
  --bg3:       #f5f5f5;
  --border:    #e0e0e0;
  --border2:   #d0d0d0;
  --text:      #000000;
  --text2:     #666666;
  --text3:     #999999;
  --accent:    #6c5ce7;
  --accent2:   #5b4fd4;
  --green:     #00b894;
  --red:       #e55353;
  --yellow:    #f0a500;
}

/* ── Pure Black Theme ── */
[data-theme="black"] {
  --bg:        #000000;
  --bg2:       #0a0a0a;
  --bg3:       #141414;
  --border:    #2a2a2a;
  --border2:   #3a3a3a;
  --text:      #ffffff;
  --text2:     #b0b0b0;
  --text3:     #707070;
  --accent:    #7c6af7;
  --accent2:   #6b5fd4;
  --green:     #3ecf8e;
  --red:       #f87171;
  --yellow:    #fbbf24;
}

[data-theme="light"] .msg.assistant .msg-content,
[data-theme="light"] .msg.assistant .msg-content.markdown {
  background: #ffffff;
  border: 1px solid var(--border);
}

[data-theme="light"] .msg.user .msg-content {
  background: var(--accent);
  color: #fff;
}

[data-theme="light"] .msg-content.markdown pre code {
  background: #f0f0f5;
  color: var(--text);
}

[data-theme="light"] .msg-content.markdown code {
  background: rgba(0,0,0,.06);
  color: #c0392b;
}

[data-theme="light"] .auth-page {
  background: var(--bg);
}

[data-theme="light"] .auth-page::before {
  background: radial-gradient(circle, rgba(108,92,231,.06) 0%, transparent 70%);
}

/* White theme messages */
[data-theme="white"] .msg.assistant .msg-content,
[data-theme="white"] .msg.assistant .msg-content.markdown {
  background: #ffffff;
  border: 1px solid var(--border);
}

[data-theme="white"] .msg.user .msg-content {
  background: var(--accent);
  color: #fff;
}

[data-theme="white"] .msg-content.markdown pre code {
  background: #f5f5f5;
  color: var(--text);
}

[data-theme="white"] .msg-content.markdown code {
  background: rgba(0,0,0,.06);
  color: #c0392b;
}

[data-theme="white"] .auth-page {
  background: var(--bg);
}

/* Black theme messages */
[data-theme="black"] .msg.assistant .msg-content,
[data-theme="black"] .msg.assistant .msg-content.markdown {
  background: #0a0a0a;
  border: 1px solid var(--border);
}

[data-theme="black"] .msg.user .msg-content {
  background: var(--accent);
  color: #fff;
}

[data-theme="black"] .msg-content.markdown pre code {
  background: #141414;
  color: var(--text);
}

[data-theme="black"] .msg-content.markdown code {
  background: rgba(255,255,255,.08);
  color: #ff6b6b;
}

[data-theme="black"] .auth-page {
  background: var(--bg);
}

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

body,
button,
input,
textarea,
select {
  font-weight: 400;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 400;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

/* ── Selection ── */
::selection { background: rgba(124,106,247,.3); }

/* ── Auth Page ── */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  position: relative;
  overflow: hidden;
}

.auth-page::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(124,106,247,.08) 0%, transparent 70%);
  top: -100px; left: -100px;
  pointer-events: none;
}

.auth-page::after {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(62,207,142,.05) 0%, transparent 70%);
  bottom: -50px; right: -50px;
  pointer-events: none;
}

.auth-box {
  width: 380px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius2);
  padding: 40px;
  position: relative;
  z-index: 1;
}

.auth-logo {
  font-family: var(--sans);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 8px;
  color: var(--text);
}

.auth-logo span { color: var(--accent); }

.auth-subtitle {
  color: var(--text3);
  font-size: 11px;
  margin-bottom: 32px;
  letter-spacing: 0.5px;
}

.auth-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--border);
}

.auth-tab {
  padding: 8px 16px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text3);
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all .2s;
  letter-spacing: 0.3px;
}

.auth-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.auth-tab:hover:not(.active) { color: var(--text2); }

.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 10px;
  color: var(--text3);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 400;
  color: var(--text);
  outline: none;
  transition: border-color .2s;
}

.form-input:focus { border-color: var(--accent); }
.form-input::placeholder { color: var(--text3); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all .15s;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  width: 100%;
  padding: 11px;
}

.btn-primary:hover { background: var(--accent2); }
.btn-primary:active { transform: scale(.98); }

.btn-ghost {
  background: transparent;
  color: var(--text2);
  border: 1px solid var(--border);
}

.btn-ghost:hover { border-color: var(--border2); color: var(--text); }

.btn-danger {
  background: transparent;
  color: var(--red);
  border: 1px solid rgba(248,113,113,.3);
}

.btn-danger:hover { background: rgba(248,113,113,.08); }

.btn-sm { padding: 5px 10px; font-size: 11px; }

.btn:disabled { opacity: .4; cursor: not-allowed; }

.auth-error {
  background: rgba(248,113,113,.1);
  border: 1px solid rgba(248,113,113,.3);
  border-radius: var(--radius);
  padding: 10px 12px;
  color: var(--red);
  font-size: 12px;
  margin-bottom: 16px;
  display: none;
}

.auth-error.show { display: block; }

/* ── App Layout ── */
.app {
  display: grid;
  grid-template-columns: 220px 1fr;
  grid-template-rows: 48px 1fr;
  height: 100vh;
  overflow: hidden;
}

/* ── Topbar ── */
.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
  gap: 12px;
}

.topbar-logo {
  font-family: var(--sans);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text);
  margin-right: 8px;
}

.topbar-logo span { color: var(--accent); }

.topbar-sep {
  width: 1px;
  height: 20px;
  background: var(--border);
}

.topbar-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text3);
}

.status-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text3);
}

.status-dot.online { background: var(--green); box-shadow: 0 0 6px rgba(62,207,142,.5); }

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 11px;
  color: var(--text2);
}

.user-tier {
  font-size: 9px;
  padding: 1px 6px;
  border-radius: 10px;
  background: rgba(124,106,247,.2);
  color: var(--accent);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.user-tier.pro {
  background: rgba(62,207,142,.15);
  color: var(--green);
}

/* ── Sidebar ── */
.sidebar {
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-section {
  padding: 12px 8px 4px;
}

.sidebar-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text3);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding: 0 8px;
  margin-bottom: 4px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text2);
  font-family: var(--ui);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.45;
  letter-spacing: 0;
  transition: all .15s;
  border: 1px solid transparent;
  position: relative;
}

.sidebar-item:hover { background: rgba(124,106,247,.05); color: var(--text); }

.sidebar-item.active {
  background: linear-gradient(90deg, rgba(124,106,247,.08) 0%, rgba(124,106,247,.14) 100%);
  color: #5a67ff;
  border-color: rgba(124,106,247,.18);
}

.sidebar-item-icon { font-size: 14px; flex-shrink: 0; }

.sidebar-item-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--ui);
}

.sidebar-item-del {
  opacity: 0;
  font-size: 14px;
  color: var(--text3);
  transition: opacity .15s;
  cursor: pointer;
  padding: 2px;
  line-height: 1;
}

.sidebar-item:hover .sidebar-item-del { opacity: 1; }
.sidebar-item-del:hover { color: var(--red) !important; }

.sidebar-new-btn {
  margin: 4px 8px 8px;
  width: calc(100% - 16px);
  padding: 7px;
  background: transparent;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text3);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.sidebar-new-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(124,106,247,.05);
}

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

.sidebar-nav {
  padding: 8px;
  border-top: 1px solid var(--border);
}

/* ── Main Content ── */
.main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

/* ── Panels ── */
.panel { display: none; flex-direction: column; height: 100%; }
.panel.active { display: flex; }

/* ── Chat Panel ── */
.chat-header {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg2);
  flex-shrink: 0;
}

.chat-title {
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  flex: 1;
}

.chat-meta {
  font-size: 10px;
  color: var(--text3);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.msg {
  display: flex;
  gap: 12px;
  max-width: 800px;
  animation: msgIn .2s ease;
}

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

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

.msg-avatar {
  width: 28px; height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
  margin-top: 2px;
}

.msg.user .msg-avatar {
  background: rgba(124,106,247,.2);
  color: var(--accent);
  border: 1px solid rgba(124,106,247,.3);
}

.msg.assistant .msg-avatar {
  background: rgba(62,207,142,.1);
  color: var(--green);
  border: 1px solid rgba(62,207,142,.2);
}

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

.msg-content {
  padding: 10px 14px;
  border-radius: var(--radius2);
  font-size: 13px;
  line-height: 1.7;
  word-break: break-word;
  white-space: pre-wrap;
}

.msg.user .msg-content {
  background: rgba(124,106,247,.15);
  border: 1px solid rgba(124,106,247,.25);
  color: var(--text);
  border-radius: var(--radius2) var(--radius2) 4px var(--radius2);
}

.msg.assistant .msg-content {
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius2) var(--radius2) var(--radius2) 4px;
}

.msg-time {
  font-size: 10px;
  color: var(--text3);
  margin-top: 4px;
  padding: 0 2px;
}

.msg.user .msg-time { text-align: right; }

.voice-bubble {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 120px;
}

.voice-bubble-icon {
  font-size: 16px;
  line-height: 1;
}

.voice-bubble-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.voice-bubble-title {
  font-size: 13px;
  font-weight: 500;
}

.voice-bubble-duration,
.voice-bubble-transcript {
  font-size: 11px;
  color: var(--text2);
}

.voice-bubble-transcript {
  max-width: 280px;
  white-space: normal;
}

.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 12px 14px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius2) var(--radius2) var(--radius2) 4px;
  width: fit-content;
}

.typing-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text3);
  animation: typingBounce 1.2s infinite;
}

.typing-dot:nth-child(2) { animation-delay: .2s; }
.typing-dot:nth-child(3) { animation-delay: .4s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.chat-input-area {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg2);
  flex-shrink: 0;
}

.chat-input-wrap {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius2);
  padding: 10px 12px;
  transition: border-color .2s;
}

.chat-input-wrap:focus-within { border-color: var(--accent); }

.chat-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 400;
  color: var(--text);
  resize: none;
  max-height: 120px;
  min-height: 20px;
  line-height: 1.6;
}

.chat-input::placeholder { color: var(--text3); }

.chat-voice-btn,
.chat-send-btn {
  border: none;
  border-radius: var(--radius);
  width: 32px; height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #fff;
  font-size: 14px;
  transition: all .15s;
  flex-shrink: 0;
}

.chat-voice-btn {
  background: rgba(124,106,247,.14);
  color: var(--accent);
  border: 1px solid rgba(124,106,247,.25);
}

.chat-voice-btn:hover { background: rgba(124,106,247,.22); }
.chat-voice-btn.recording {
  background: rgba(248,113,113,.16);
  color: var(--red);
  border-color: rgba(248,113,113,.35);
  animation: pulseRecord 1s infinite;
}

.chat-send-btn {
  background: var(--accent);
}

.chat-send-btn:hover { background: var(--accent2); }
.chat-voice-btn:active,
.chat-send-btn:active { transform: scale(.92); }
.chat-voice-btn:disabled,
.chat-send-btn:disabled { opacity: .3; cursor: not-allowed; }

.voice-recording-hint {
  margin-top: 8px;
  font-size: 11px;
  color: var(--accent);
  text-align: center;
}

.chat-hint {
  font-size: 10px;
  color: var(--text3);
  margin-top: 8px;
  text-align: center;
}

@keyframes pulseRecord {
  0%, 100% { box-shadow: 0 0 0 0 rgba(248,113,113,.28); }
  50% { box-shadow: 0 0 0 8px rgba(248,113,113,0); }
}

/* ── Empty State ── */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text3);
}

.empty-icon { font-size: 40px; opacity: .3; }

.empty-title {
  font-family: var(--sans);
  font-size: 18px;
  font-weight: 700;
  color: var(--text2);
}

.empty-sub { font-size: 12px; }

/* ── Files Panel ── */
.panel-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg2);
  flex-shrink: 0;
}

.panel-title {
  font-family: var(--sans);
  font-size: 17px;
  font-weight: 800;
  flex: 1;
}

.upload-zone {
  margin: 20px;
  border: 2px dashed var(--border);
  border-radius: var(--radius2);
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
  color: var(--text3);
  flex-shrink: 0;
}

.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--accent);
  background: rgba(124,106,247,.04);
  color: var(--accent);
}

.upload-zone-icon { font-size: 28px; margin-bottom: 8px; }
.upload-zone-text { font-size: 12px; }
.upload-zone-sub { font-size: 10px; color: var(--text3); margin-top: 4px; }

.files-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 20px 20px;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  background: var(--bg2);
  transition: border-color .15s;
}

.file-item:hover { border-color: var(--border2); }

.file-icon { font-size: 20px; flex-shrink: 0; }

.file-info { flex: 1; min-width: 0; }

.file-name {
  font-size: 12px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-meta {
  font-size: 10px;
  color: var(--text3);
  margin-top: 2px;
}

.file-status {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 10px;
  flex-shrink: 0;
}

.file-status.uploaded { background: rgba(251,191,36,.1); color: var(--yellow); }
.file-status.processing { background: rgba(124,106,247,.1); color: var(--accent); }
.file-status.ready { background: rgba(62,207,142,.1); color: var(--green); }
.file-status.failed { background: rgba(248,113,113,.1); color: var(--red); }

/* ── Reminders Panel ── */
.reminders-list {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.reminder-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  background: var(--bg2);
  transition: border-color .15s;
}

.reminder-item:hover { border-color: var(--border2); }

.reminder-item.inactive { opacity: .5; }

.reminder-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: 5px;
  flex-shrink: 0;
}

.reminder-dot.cron { background: var(--yellow); }
.reminder-dot.inactive { background: var(--text3); }

.reminder-info { flex: 1; }

.reminder-title { font-size: 13px; color: var(--text); }

.reminder-content {
  font-size: 11px;
  color: var(--text2);
  margin-top: 2px;
}

.reminder-time {
  font-size: 10px;
  color: var(--text3);
  margin-top: 4px;
}

/* ── Add Reminder Form ── */
.add-reminder-form {
  margin: 20px;
  padding: 16px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius2);
  flex-shrink: 0;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ── Memories Panel ── */
.memories-list {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.memory-item {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  background: var(--bg2);
  transition: border-color .15s;
}

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

.memory-content { font-size: 12px; color: var(--text); line-height: 1.6; }

.memory-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.memory-importance {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 10px;
  background: rgba(124,106,247,.1);
  color: var(--accent);
}

.memory-time { font-size: 10px; color: var(--text3); }

/* ── Toast ── */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
}

.toast {
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: toastIn .2s ease;
  max-width: 300px;
  border: 1px solid;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

.toast.success {
  background: rgba(62,207,142,.1);
  border-color: rgba(62,207,142,.3);
  color: var(--green);
}

.toast.error {
  background: rgba(248,113,113,.1);
  border-color: rgba(248,113,113,.3);
  color: var(--red);
}

.toast.info {
  background: rgba(124,106,247,.1);
  border-color: rgba(124,106,247,.3);
  color: var(--accent);
}

/* ── Task Status Badge ── */
.task-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 10px;
}

.task-badge.pending { background: rgba(251,191,36,.1); color: var(--yellow); }
.task-badge.running { background: rgba(124,106,247,.1); color: var(--accent); }
.task-badge.done    { background: rgba(62,207,142,.1);  color: var(--green); }
.task-badge.failed  { background: rgba(248,113,113,.1); color: var(--red); }

/* ── Spinner ── */
.spinner {
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,.1);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin .6s linear infinite;
  display: inline-block;
}

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

/* ── Storage Bar ── */
.storage-bar-wrap {
  padding: 8px 16px 12px;
  border-top: 1px solid var(--border);
}

.storage-label {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text3);
  margin-bottom: 5px;
}

.storage-bar {
  height: 3px;
  background: var(--bg3);
  border-radius: 2px;
  overflow: hidden;
}

.storage-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width .3s;
}

/* ── Markdown Content ── */
.msg-content.markdown {
  padding: 10px 14px;
  border-radius: var(--radius2);
  font-size: 13px;
  line-height: 1.7;
  word-break: break-word;
}

.msg-content.markdown p { margin: 0 0 8px; }
.msg-content.markdown p:last-child { margin-bottom: 0; }

.msg-content.markdown h1,
.msg-content.markdown h2,
.msg-content.markdown h3,
.msg-content.markdown h4 {
  font-family: var(--sans);
  font-weight: 700;
  margin: 12px 0 6px;
  color: var(--text);
  line-height: 1.3;
}
.msg-content.markdown h1 { font-size: 16px; }
.msg-content.markdown h2 { font-size: 14px; }
.msg-content.markdown h3 { font-size: 13px; }

.msg-content.markdown ul,
.msg-content.markdown ol {
  padding-left: 18px;
  margin: 6px 0;
}
.msg-content.markdown li { margin: 3px 0; }

.msg-content.markdown blockquote {
  border-left: 3px solid var(--accent);
  padding: 4px 12px;
  margin: 8px 0;
  color: var(--text2);
  background: rgba(124,106,247,.05);
  border-radius: 0 var(--radius) var(--radius) 0;
}

.msg-content.markdown code {
  font-family: var(--mono);
  font-size: 12px;
  background: rgba(255,255,255,.07);
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--green);
}

.msg-content.markdown pre {
  margin: 8px 0;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

.msg-content.markdown pre code {
  display: block;
  padding: 12px 14px;
  background: #1a1a22;
  color: var(--text);
  font-size: 12px;
  overflow-x: auto;
  line-height: 1.6;
}

.msg-content.markdown a {
  color: var(--accent);
  text-decoration: none;
}
.msg-content.markdown a:hover { text-decoration: underline; }

.msg-content.markdown table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0;
  font-size: 12px;
}
.msg-content.markdown th,
.msg-content.markdown td {
  padding: 6px 10px;
  border: 1px solid var(--border);
  text-align: left;
}
.msg-content.markdown th {
  background: var(--bg3);
  color: var(--text2);
  font-weight: 600;
}
.msg-content.markdown tr:nth-child(even) td { background: rgba(255,255,255,.02); }

.msg-content.markdown hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 10px 0;
}

.msg-content.markdown strong { color: var(--text); font-weight: 600; }
.msg-content.markdown em { color: var(--text2); font-style: italic; }

/* ── Modal Overlay ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: fadeIn .15s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-close {
  position: absolute;
  top: 20px;
  right: 24px;
  font-size: 20px;
  color: var(--text2);
  cursor: pointer;
  line-height: 1;
  transition: color .15s;
}
.modal-close:hover { color: var(--text); }

.modal-img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: var(--radius2);
  box-shadow: 0 20px 60px rgba(0,0,0,.6);
  object-fit: contain;
}

/* ── Shortcuts Box ── */
.shortcuts-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius2);
  width: 380px;
  overflow: hidden;
}

.shortcuts-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-family: var(--sans);
  font-weight: 600;
  font-size: 13px;
}

.shortcuts-list {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.shortcut-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text2);
}

kbd {
  font-family: var(--mono);
  font-size: 11px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 4px;
  padding: 2px 7px;
  color: var(--text);
  white-space: nowrap;
}

/* ── Load More Button ── */
.load-more-btn {
  text-align: center;
  padding: 8px 16px;
  font-size: 11px;
  color: var(--text3);
  cursor: pointer;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  margin: 8px 16px;
  transition: color .15s, border-color .15s;
}

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

/* ── Sidebar Search ── */
.sidebar-search-wrap {
  padding: 6px 10px 4px;
}

.sidebar-search {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  padding: 5px 10px;
  outline: none;
  transition: border-color .15s;
}

.sidebar-search::placeholder { color: var(--text3); }
.sidebar-search:focus { border-color: var(--accent); }

/* ── Misc ── */
.divider {
  height: 1px;
  background: var(--border);
  margin: 8px 0;
}

.tag {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 10px;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text3);
}

.hidden { display: none !important; }

/* ── Responsive ── */
@media (max-width: 640px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: 48px auto 1fr;
  }
  .sidebar { display: none; }
}

/* ── Settings Panel ── */
.settings-body {
  padding: 20px 24px;
  max-width: 600px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  overflow-y: auto;
}

.settings-section {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius2);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.settings-section-title {
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 4px;
}

.settings-row {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}

.settings-label {
  color: var(--text2);
  min-width: 100px;
  flex-shrink: 0;
}

.settings-value {
  color: var(--text);
}

.form-hint {
  font-size: 11px;
  color: var(--text3);
  margin-top: 4px;
}

/* ── Feature Center ── */
.feature-tabs {
  display: flex;
  gap: 8px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}

.feature-tabs::-webkit-scrollbar {
  display: none;
}

.feature-tab {
  padding: 6px 14px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text2);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  transition: all .2s;
  white-space: nowrap;
}

.feature-tab:hover {
  border-color: var(--accent);
  color: var(--accent);
}

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

/* Feature Cards Grid */
.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  padding: 20px;
  overflow-y: auto;
  height: calc(100% - 60px);
  align-content: start;
}

/* Feature Card */
.feature-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  transition: all .2s;
  height: auto;
}

.feature-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 16px rgba(124, 106, 247, 0.12);
}

.feature-card-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin-bottom: 12px;
}

.feature-card-name {
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

.feature-card-tag {
  display: inline-block;
  padding: 3px 10px;
  font-size: 11px;
  color: var(--accent);
  background: rgba(124, 106, 247, 0.1);
  border-radius: 10px;
  margin-bottom: 10px;
}

.feature-card-desc {
  font-size: 12px;
  color: var(--text2);
  line-height: 1.5;
  margin-bottom: 12px;
}

.feature-card-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 18px;
  font-family: var(--mono);
  font-size: 12px;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 20px;
  cursor: pointer;
  transition: all .2s;
}

.feature-card-btn:hover {
  background: var(--accent2);
}

/* Theme adjustments */
[data-theme="light"] .feature-card,
[data-theme="white"] .feature-card {
  background: var(--bg2);
}

[data-theme="light"] .feature-card:hover,
[data-theme="white"] .feature-card:hover {
  border-color: var(--accent);
}

[data-theme="black"] .feature-card {
  background: var(--bg2);
}

[data-theme="black"] .feature-card:hover {
  border-color: var(--accent);
}

/* ── Theme Selector ── */
.theme-selector {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.theme-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  background: var(--bg3);
  border: 2px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all .2s;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text2);
}

.theme-option:hover {
  border-color: var(--accent);
}

.theme-option.active {
  border-color: var(--accent);
  background: rgba(124, 106, 247, 0.1);
  color: var(--accent);
}

.theme-preview {
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.theme-preview.dark {
  background: #0a0a0b;
}

.theme-preview.light {
  background: #f5f5f7;
}

.theme-preview.white {
  background: #ffffff;
}

.theme-preview.black {
  background: #000000;
}



/* Chat image preview */
.chat-image-preview {
  max-width: 240px;
  max-height: 240px;
  border-radius: 10px;
  cursor: pointer;
  object-fit: cover;
  display: block;
  margin-bottom: 6px;
  border: 1px solid rgba(255,255,255,0.1);
  transition: transform 0.15s;
}
.chat-image-preview:hover {
  transform: scale(1.03);
}

/* Multi-image grid in chat messages */
.chat-images-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}
.chat-images-grid .chat-image-preview {
  max-width: 160px;
  max-height: 160px;
}

.image-error-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 160px;
  height: 100px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px dashed rgba(255, 255, 255, 0.15);
  margin-bottom: 6px;
  color: rgba(255, 255, 255, 0.35);
  font-size: 12px;
  cursor: default;
}
.image-error-icon {
  font-size: 24px;
  margin-bottom: 4px;
  opacity: 0.6;
}
.image-error-text {
  font-size: 12px;
}

.msg-text {
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}

/* File preview bar (inside input area) */
.file-preview-bar {
  padding: 6px 8px;
  margin-top: 4px;
  background: var(--bg-secondary, #1a1a2e);
  border: 1px solid var(--border, rgba(255,255,255,0.08));
  border-radius: 10px;
  animation: filePreviewIn 0.2s ease;
}
@keyframes filePreviewIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.file-preview-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: flex-end;
}
.file-thumb {
  position: relative;
  width: 52px;
  height: 52px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.05);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.file-thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.file-thumb-icon {
  font-size: 20px;
  line-height: 1;
}
.file-thumb-name {
  font-size: 8px;
  color: var(--muted, #71717a);
  margin-top: 2px;
  max-width: 48px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
}
.file-thumb-remove {
  position: absolute;
  top: 1px;
  right: 1px;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: rgba(0,0,0,0.6);
  color: #fff;
  border-radius: 50%;
  cursor: pointer;
  font-size: 9px;
  line-height: 1;
  padding: 0;
  opacity: 0;
  transition: opacity 0.15s;
}
.file-thumb:hover .file-thumb-remove {
  opacity: 1;
}
.file-thumb-remove:hover {
  background: #ef4444;
}
