/* ============================================================
   Seven Dwarfs Web App — Design System
   ============================================================ */

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

/* ── CSS Variables ──────────────────────────────────────── */
:root {
  /* Colors */
  --bg-base:       #080810;
  --bg-surface:    #0f0f1a;
  --bg-elevated:   #14141f;
  --bg-overlay:    rgba(255,255,255,0.03);
  --bg-hover:      rgba(255,255,255,0.06);

  --accent-violet: #7c3aed;
  --accent-violet-dim: rgba(124,58,237,0.15);
  --accent-violet-border: rgba(124,58,237,0.35);
  --accent-cyan:   #06b6d4;
  --accent-cyan-dim: rgba(6,182,212,0.12);
  --accent-green:  #10b981;
  --accent-orange: #f59e0b;
  --accent-red:    #ef4444;

  --text-primary:  #f0f0ff;
  --text-secondary:#9ca3af;
  --text-muted:    #6b7280;
  --text-accent:   #a78bfa;

  --border:        rgba(255,255,255,0.07);
  --border-accent: rgba(124,58,237,0.4);
  --glass-bg:      rgba(15,15,26,0.8);
  --glass-border:  rgba(255,255,255,0.08);

  /* Spacing */
  --sidebar-w: 260px;
  --notes-w:   280px;
  --navbar-h:  56px;

  /* Radii */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;

  /* Transitions */
  --t-fast: 0.15s ease;
  --t-base: 0.25s ease;
  --t-slow: 0.4s ease;
}

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

html, body {
  height: 100%;
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.6;
  overflow: hidden;
}

/* ── Ambient background orbs ────────────────────────────── */
body::before,
body::after {
  content: '';
  position: fixed;
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
  filter: blur(120px);
  animation: orb-drift 18s ease-in-out infinite alternate;
}
body::before {
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(124,58,237,0.12) 0%, transparent 70%);
  top: -150px; left: -100px;
}
body::after {
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(6,182,212,0.09) 0%, transparent 70%);
  bottom: -100px; right: -80px;
  animation-delay: -9s;
}
@keyframes orb-drift {
  0%   { transform: translate(0, 0) scale(1); }
  50%  { transform: translate(30px, 20px) scale(1.05); }
  100% { transform: translate(-20px, 40px) scale(0.95); }
}

#navbar, #sidebar, #chat-panel, #notes-panel, #page-container,
.modal-overlay, #login-overlay { position: relative; z-index: 1; }

::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(124,58,237,0.3); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(124,58,237,0.5); }

a { color: var(--accent-cyan); text-decoration: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; color: inherit; }
input, textarea, select { font-family: inherit; color: inherit; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--r-md); padding: 8px 12px; font-size: 14px; outline: none; transition: border-color var(--t-fast); }
input:focus, textarea:focus, select:focus { border-color: var(--accent-violet); }

/* ── Layout ─────────────────────────────────────────────── */
#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Navbar ─────────────────────────────────────────────── */
#navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--navbar-h);
  background: rgba(8,8,16,0.85);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-bottom: 1px solid rgba(124,58,237,0.2);
  box-shadow: 0 1px 0 rgba(124,58,237,0.08), 0 8px 32px rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 8px;
  z-index: 100;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.3px;
  margin-right: auto;
}

.nav-logo .logo-icon {
  width: 30px; height: 30px;
  background: linear-gradient(135deg, var(--accent-violet), var(--accent-cyan));
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  box-shadow: 0 0 12px rgba(124,58,237,0.4);
  animation: logo-glow 3s ease-in-out infinite alternate;
}
.nav-logo .logo-img {
  width: 32px;
  height: 32px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
}
@keyframes logo-glow {
  from { box-shadow: 0 0 8px rgba(124,58,237,0.3); }
  to   { box-shadow: 0 0 18px rgba(124,58,237,0.6), 0 0 32px rgba(6,182,212,0.2); }
}

.nav-btn {
  padding: 7px 14px;
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--t-fast);
  display: flex; align-items: center; gap: 6px;
}
.nav-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-btn.active { background: var(--accent-violet-dim); color: var(--text-accent); border: 1px solid var(--accent-violet-border); }
.nav-btn svg { width: 15px; height: 15px; }

/* Right-aligned nav group (Sign in + Settings + Logout) */
.nav-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Guest-mode "sign in" pill */
.nav-signin {
  color: var(--accent-cyan);
  background: var(--accent-cyan-dim);
  border: 1px solid rgba(6,182,212,0.3);
  white-space: nowrap;
}
.nav-signin:hover {
  background: rgba(6,182,212,0.2);
  color: var(--accent-cyan);
}

/* Icon-only nav buttons on desktop; labels reappear in the mobile bottom bar */
.nav-btn.icon-only { padding: 7px 9px; }
.nav-btn.icon-only .nav-label { display: none; }
.nav-btn.icon-only svg { width: 17px; height: 17px; }

.nav-logout {
  color: var(--text-muted);
}
.nav-logout:hover {
  background: rgba(239,68,68,0.1) !important;
  color: var(--accent-red) !important;
  border: 1px solid rgba(239,68,68,0.2);
}

/* ── Main wrapper ────────────────────────────────────────── */
#main {
  display: flex;
  width: 100%;
  margin-top: var(--navbar-h);
  height: calc(100vh - var(--navbar-h));
  overflow: hidden;
}

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

.sidebar-header {
  padding: 16px 14px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sidebar-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.btn-new-topic {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-accent);
  background: var(--accent-violet-dim);
  border: 1px solid var(--accent-violet-border);
  transition: all var(--t-fast);
  width: 100%;
  justify-content: center;
}
.btn-new-topic:hover { background: rgba(124,58,237,0.25); }
.btn-new-topic svg { width: 14px; height: 14px; }

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

.topic-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all var(--t-fast);
  position: relative;
}
.topic-item:hover { background: var(--bg-hover); }
.topic-item.active { background: var(--accent-violet-dim); }
.topic-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 18px;
  background: var(--accent-violet);
  border-radius: 0 3px 3px 0;
}

.topic-icon {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: var(--bg-elevated);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
}

.topic-name {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-secondary);
}
.topic-item.active .topic-name { color: var(--text-primary); }

.topic-delete {
  opacity: 0;
  padding: 2px 4px;
  border-radius: 4px;
  color: var(--text-muted);
  transition: all var(--t-fast);
  font-size: 12px;
}
.topic-item:hover .topic-delete { opacity: 1; }
.topic-delete:hover { color: var(--accent-red); background: rgba(239,68,68,0.1); }

/* ── Chat panel ─────────────────────────────────────────── */
#chat-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-base);
}

.chat-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-surface);
  flex-shrink: 0;
}

.chat-topic-name {
  font-size: 15px;
  font-weight: 600;
}

.chat-topic-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-violet-dim);
  color: var(--text-accent);
  border: 1px solid var(--accent-violet-border);
}

.chat-toggle-notes {
  margin-left: auto;
  padding: 6px 10px;
  border-radius: var(--r-md);
  font-size: 12px;
  color: var(--text-muted);
  transition: all var(--t-fast);
  display: flex; align-items: center; gap: 5px;
}
.chat-toggle-notes:hover { background: var(--bg-hover); color: var(--text-primary); }

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

/* Empty state */
.empty-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
}
.empty-chat .empty-logo {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 16px;
  box-shadow: 0 0 18px rgba(6,182,212,0.16);
}
.empty-chat h3 { font-size: 18px; font-weight: 600; color: var(--text-secondary); }
.empty-chat p { font-size: 13px; color: var(--text-muted); }

/* Message bubbles */
.message {
  display: flex;
  gap: 10px;
  animation: msg-in 0.2s ease;
}
@keyframes msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

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

.msg-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  margin-top: 2px;
}
.message.user .msg-avatar { background: linear-gradient(135deg, var(--accent-violet), #9f67fa); }
.message.assistant .msg-avatar { background: linear-gradient(135deg, var(--accent-cyan), #38bdf8); }
.msg-avatar.assistant-avatar { background: linear-gradient(135deg, var(--accent-cyan), #38bdf8); }
.msg-avatar .avatar-logo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}

.msg-content {
  max-width: 72%;
}

.msg-bubble {
  padding: 10px 14px;
  border-radius: var(--r-lg);
  font-size: 14px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}
.message.user .msg-bubble {
  background: linear-gradient(135deg, var(--accent-violet), #6d28d9);
  color: #fff;
  border-bottom-right-radius: var(--r-sm);
}
.message.assistant .msg-bubble {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-bottom-left-radius: var(--r-sm);
}
.msg-bubble .md-heading {
  font-weight: 700;
  margin: 8px 0 4px;
  color: var(--text-primary);
}
.msg-bubble .md-list-item { margin: 2px 0; }
.msg-bubble .md-quote {
  margin: 6px 0;
  padding-left: 10px;
  border-left: 2px solid var(--accent-cyan);
  color: var(--text-secondary);
}
.msg-bubble .md-separator {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 10px 0;
}

/* Full markdown (marked + DOMPurify) output */
.msg-bubble .md-body > :first-child { margin-top: 0; }
.msg-bubble .md-body > :last-child { margin-bottom: 0; }
.msg-bubble .md-body p { margin: 6px 0; }
.msg-bubble .md-body h1,
.msg-bubble .md-body h2,
.msg-bubble .md-body h3,
.msg-bubble .md-body h4,
.msg-bubble .md-body h5,
.msg-bubble .md-body h6 {
  font-size: 1em;
  font-weight: 700;
  margin: 8px 0 4px;
  color: var(--text-primary);
}
.msg-bubble .md-body h1 { font-size: 1.15em; }
.msg-bubble .md-body h2 { font-size: 1.08em; }
.msg-bubble .md-body ul,
.msg-bubble .md-body ol {
  margin: 6px 0;
  padding-left: 22px;
}
.msg-bubble .md-body li { margin: 2px 0; }
.msg-bubble .md-body blockquote {
  margin: 6px 0;
  padding-left: 10px;
  border-left: 2px solid var(--accent-cyan);
  color: var(--text-secondary);
}
.msg-bubble .md-body hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 10px 0;
}
.msg-bubble .md-body table {
  display: block;
  width: max-content;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  margin: 8px 0;
  font-size: 13px;
}
.msg-bubble .md-body th,
.msg-bubble .md-body td {
  border: 1px solid var(--border);
  padding: 5px 10px;
  text-align: left;
  vertical-align: top;
}
.msg-bubble .md-body th {
  background: var(--bg-base);
  font-weight: 600;
  color: var(--text-primary);
}
.msg-bubble .md-body tr:nth-child(even) td {
  background: rgba(255,255,255,0.03);
}
.message.user .msg-bubble .md-body th,
.message.user .msg-bubble .md-body td {
  border-color: rgba(255,255,255,0.3);
}
.message.user .msg-bubble .md-body th {
  background: rgba(255,255,255,0.12);
  color: #fff;
}

.msg-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  padding: 0 4px;
}
.message.user .msg-meta { text-align: right; }

/* Tool badge */
.tool-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-cyan-dim);
  color: var(--accent-cyan);
  border: 1px solid rgba(6,182,212,0.2);
  margin-bottom: 6px;
  animation: msg-in 0.15s ease;
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  animation: msg-in 0.2s ease;
}
.typing-dots {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  border-bottom-left-radius: var(--r-sm);
  padding: 12px 16px;
  display: flex;
  gap: 4px;
  align-items: center;
}
.typing-dots span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: bounce 1.2s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40%           { transform: translateY(-6px); }
}

/* Code blocks in messages */
.msg-bubble pre {
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 10px 12px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  overflow-x: auto;
  margin: 6px 0;
}
.msg-bubble code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  background: rgba(124,58,237,0.15);
  padding: 1px 5px;
  border-radius: 4px;
}

/* ── Input bar ──────────────────────────────────────────── */
#input-bar {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-surface);
  flex-shrink: 0;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  width: 100%;
  box-sizing: border-box;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 10px 12px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.input-wrapper:focus-within {
  border-color: var(--accent-violet-border);
  box-shadow: 0 0 0 3px rgba(124,58,237,0.1), 0 4px 20px rgba(0,0,0,0.2);
}

.input-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.composer-toggle-btn {
  display: none;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: rgba(255,255,255,0.05);
  color: var(--text-primary);
  font-size: 20px;
  line-height: 1;
  font-weight: 500;
}

.composer-tools {
  display: flex;
  align-items: center;
  gap: 4px;
}

.input-action-btn {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  transition: all var(--t-fast);
  font-size: 14px;
}
.input-action-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.input-action-btn.recording { color: var(--accent-red); animation: pulse-red 1s infinite; }
@keyframes pulse-red {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

.command-menu {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: calc(100% + 10px);
  max-height: 320px;
  overflow-y: auto;
  padding: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: 0 18px 60px rgba(0,0,0,0.45);
  z-index: 20;
}
.command-group {
  padding: 8px 10px 4px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0;
}
.command-item {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(110px, 0.35fr) 1fr;
  gap: 12px;
  align-items: center;
  padding: 9px 10px;
  border-radius: var(--r-md);
  text-align: left;
}
.command-item:hover,
.command-item.active {
  background: var(--accent-violet-dim);
}
.command-name {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--accent-cyan);
}
.command-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.35;
}
.command-empty {
  padding: 14px 10px;
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
}

#message-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  padding: 4px 0;
  font-size: 14px;
  resize: none;
  max-height: 120px;
  min-height: 24px;
  line-height: 1.5;
}
#message-input::placeholder { color: var(--text-muted); }

.send-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-violet), var(--accent-cyan));
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  transition: all var(--t-fast);
  flex-shrink: 0;
  font-size: 14px;
  box-shadow: 0 2px 12px rgba(124,58,237,0.35);
}
.send-btn:hover { transform: scale(1.08); box-shadow: 0 0 22px rgba(124,58,237,0.55), 0 0 12px rgba(6,182,212,0.25); }
.send-btn:active { transform: scale(0.94); }
.send-btn:disabled { opacity: 0.35; cursor: not-allowed; transform: none; box-shadow: none; }

/* ── Identity Verification (Login) ───────────────────────── */
#login-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(4,4,10,0.95);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-xl);
  padding: 40px;
  text-align: center;
  box-shadow: 0 20px 80px rgba(0,0,0,0.5);
  animation: modal-pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.login-logo {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 14px;
  margin-bottom: 18px;
  box-shadow: 0 0 18px rgba(124,58,237,0.35);
}
.login-card h2 {
  font-size: 20px;
  margin-bottom: 6px;
}
.login-tagline {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 20px;
  line-height: 1.6;
}
/* Email / password form */
.login-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}
.login-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.login-form input {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 12px 14px;
  font-size: 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.login-form input[aria-invalid="true"] { border-color: #ef4444; }
.login-details { display: grid; grid-template-rows: 0fr; opacity: 0; transform: translateY(-8px); transition: grid-template-rows 220ms ease-out, opacity 160ms ease-out, transform 220ms ease-out; }
.login-details.is-visible { grid-template-rows: 1fr; opacity: 1; transform: translateY(0); }
.login-details-inner { min-height: 0; overflow: hidden; display: flex; flex-direction: column; gap: 10px; }
.login-name-fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.login-name-fields[hidden] { display: none !important; }
.login-field-hint, .login-field-error, .login-form-error { margin: 0; font-size: 12px; line-height: 1.4; }
.login-field-hint { color: var(--text-muted); }
.login-field-error, .login-form-error { min-height: 0; color: #fca5a5; }
.login-field-error:not(:empty), .login-form-error:not(:empty) { min-height: 17px; }
.login-mode-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--bg-elevated); }
.login-mode-switch button { min-height: 40px; border-radius: calc(var(--r-md) - 3px); color: var(--text-secondary); background: transparent; font-size: 13px; font-weight: 600; transition: background var(--t-fast), color var(--t-fast); }
.login-mode-switch button.active { color: #fff; background: var(--accent-violet); }
.email-verification {
  padding: 10px;
  border: 1px solid var(--border-accent);
  border-radius: var(--r-md);
  background: rgba(124, 58, 237, 0.09);
}
.email-verification p {
  margin: 0 0 8px;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.email-verification input { width: 100%; }
.login-primary-btn {
  width: 100%;
  min-height: 44px;
  padding: 11px;
  border-radius: var(--r-md);
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, var(--accent-violet), var(--accent-cyan));
  box-shadow: 0 4px 15px rgba(124,58,237,0.3);
  transition: all var(--t-fast);
}
.login-primary-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(124,58,237,0.4); }
.login-primary-btn:disabled { opacity: .6; cursor: wait; transform: none; }
.login-ghost-btn {
  padding: 11px 14px;
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  transition: all var(--t-fast);
  white-space: nowrap;
}
.login-ghost-btn:hover { color: var(--text-primary); border-color: var(--border-accent); }
@media (max-width: 420px) { .login-name-fields { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { .login-details { transition: none; } }

/* Google button */
.login-google-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 11px;
  border-radius: var(--r-md);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  transition: all var(--t-fast);
}
.login-google-btn:hover { border-color: var(--border-accent); background: var(--bg-hover); }

/* Divider */
.login-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.login-divider::before, .login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Telegram fold-out */
.login-telegram {
  text-align: left;
  margin-bottom: 14px;
}
.login-telegram summary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 500;
  color: var(--accent-cyan);
  background: var(--accent-cyan-dim);
  border: 1px solid rgba(6,182,212,0.25);
  cursor: pointer;
  user-select: none;
  list-style: none;
  transition: all var(--t-fast);
}
.login-telegram summary::-webkit-details-marker { display: none; }
.login-telegram summary:hover { background: rgba(6,182,212,0.18); }
.login-telegram[open] summary { margin-bottom: 14px; }

/* Guest link */
.login-guest-link {
  width: 100%;
  padding: 8px;
  font-size: 12.5px;
  color: var(--text-muted);
  transition: color var(--t-fast);
}
.login-guest-link:hover { color: var(--text-accent); }

.login-steps {
  text-align: left;
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
  counter-reset: login-step;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.login-steps li {
  counter-increment: login-step;
  position: relative;
  padding-left: 32px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}
.login-steps li::before {
  content: counter(login-step);
  position: absolute;
  left: 0;
  top: 0;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--accent-violet-dim);
  border: 1px solid var(--accent-violet-border);
  color: var(--text-accent);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-steps code {
  background: var(--bg-elevated);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--accent-cyan);
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
}
.login-input-row {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
#login-code {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px;
  font-size: 24px;
  letter-spacing: 0.5em;
  text-align: center;
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
  transition: border-color 0.2s;
}
#login-code:focus {
  outline: none;
  border-color: var(--accent-violet-border);
  box-shadow: 0 0 0 3px rgba(124,58,237,0.1);
}
#login-btn {
  background: linear-gradient(135deg, var(--accent-violet), var(--accent-cyan));
  border: none;
  border-radius: var(--r-md);
  padding: 14px;
  color: white;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 4px 15px rgba(124,58,237,0.3);
}
#login-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(124,58,237,0.4);
}
#login-btn:active {
  transform: translateY(0);
}

/* ── Notes panel ─────────────────────────────────────────── */
#notes-panel {
  width: var(--notes-w);
  flex-shrink: 0;
  border-left: 1px solid var(--border);
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width var(--t-base), opacity var(--t-base);
}
#notes-panel.collapsed {
  width: 0;
  opacity: 0;
  border-left: none;
  pointer-events: none;
}

.notes-header {
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.notes-header h3 { font-size: 13px; font-weight: 600; color: var(--text-secondary); }

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

.note-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.5;
  animation: msg-in 0.2s ease;
}
.note-card .note-time {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 6px;
}

.notes-input-area {
  padding: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.notes-input-area textarea {
  flex: 1;
  border-radius: var(--r-md);
  min-height: 60px;
  resize: none;
  font-size: 13px;
}
.notes-save-btn {
  width: 32px; height: 32px;
  background: var(--accent-violet-dim);
  border: 1px solid var(--accent-violet-border);
  border-radius: var(--r-md);
  color: var(--text-accent);
  display: flex; align-items: center; justify-content: center;
  transition: all var(--t-fast);
  flex-shrink: 0;
  align-self: flex-end;
}
.notes-save-btn:hover { background: rgba(124,58,237,0.25); }

/* ── Full-page views (Reminders / Tasks / Settings) ──────── */
#page-container {
  flex: 1;
  display: none;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-base);
  min-width: 0;
}
#page-container.visible { display: flex; }

/* Inner page wrappers fill their parent */
#page-reminders, #page-tasks, #page-settings {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.page-header {
  padding: 24px 28px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

.page-title {
  font-size: 20px;
  font-weight: 700;
  background: linear-gradient(90deg, var(--text-primary), var(--text-accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

.page-btn {
  margin-left: auto;
  padding: 8px 16px;
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 500;
  background: linear-gradient(135deg, var(--accent-violet), var(--accent-cyan));
  color: #fff;
  transition: all var(--t-fast);
  display: flex; align-items: center; gap: 6px;
}
.page-btn:hover { opacity: 0.9; transform: translateY(-1px); }

.page-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
}

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px;
  transition: border-color var(--t-fast);
}
.card:hover { border-color: var(--accent-violet-border); }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

/* ── Reminder card ───────────────────────────────────────── */
.reminder-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 14px 16px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  transition: border-color var(--t-fast);
  animation: msg-in 0.2s ease;
}
.reminder-card:hover { border-color: var(--accent-violet-border); }

.reminder-card.sent { opacity: 0.5; }

.reminder-status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
}
.reminder-status-dot.pending { background: var(--accent-green); box-shadow: 0 0 6px var(--accent-green); }
.reminder-status-dot.sent { background: var(--text-muted); }

.reminder-body { flex: 1; min-width: 0; }
.reminder-title { font-weight: 600; font-size: 14px; color: var(--text-primary); margin-bottom: 2px; }
.reminder-msg   { font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; }
.reminder-time  { font-size: 11px; color: var(--accent-cyan); display: flex; align-items: center; gap: 4px; }
.reminder-notes { font-size: 12px; color: var(--text-muted); margin-top: 4px; font-style: italic; }

.reminder-actions { display: flex; gap: 4px; }
.reminder-action-btn {
  width: 28px; height: 28px;
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  transition: all var(--t-fast);
  font-size: 13px;
}
.reminder-action-btn:hover { background: var(--bg-hover); }
.reminder-action-btn.delete:hover { color: var(--accent-red); background: rgba(239,68,68,0.1); }

/* ── Task card ───────────────────────────────────────────── */
.task-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 14px 16px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  transition: border-color var(--t-fast);
  animation: msg-in 0.2s ease;
}
.task-card:hover { border-color: var(--accent-cyan-dim); }

.task-recurrence-badge {
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  flex-shrink: 0;
}
.task-recurrence-badge.hourly  { background: rgba(245,158,11,0.15); color: var(--accent-orange); border: 1px solid rgba(245,158,11,0.25); }
.task-recurrence-badge.daily   { background: var(--accent-cyan-dim); color: var(--accent-cyan); border: 1px solid rgba(6,182,212,0.25); }
.task-recurrence-badge.weekly  { background: var(--accent-violet-dim); color: var(--text-accent); border: 1px solid var(--accent-violet-border); }

.task-body { flex: 1; min-width: 0; }
.task-title { font-weight: 600; font-size: 14px; margin-bottom: 2px; }
.task-instruction { font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; }
.task-meta { font-size: 11px; color: var(--text-muted); }

/* ── Settings ────────────────────────────────────────────── */
.settings-section {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px 22px;
  margin-bottom: 16px;
  scroll-margin-top: 56px;
}
.settings-section-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

/* Sticky jump-nav at the top of Settings */
.settings-nav {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 0;
  margin-bottom: 8px;
  background: var(--bg-base);
}
.settings-nav-chip {
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  transition: all var(--t-fast);
  white-space: nowrap;
}
.settings-nav-chip:hover {
  color: var(--text-accent);
  border-color: var(--accent-violet-border);
  background: var(--accent-violet-dim);
}

.subsection-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 16px 0 8px;
}

.model-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  cursor: pointer;
  transition: all var(--t-fast);
  margin-bottom: 8px;
}
.model-option:hover { border-color: var(--accent-violet-border); background: var(--accent-violet-dim); }
.model-option.selected { border-color: var(--accent-violet); background: var(--accent-violet-dim); }
.model-option .model-radio { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border); transition: all var(--t-fast); }
.model-option.selected .model-radio { border-color: var(--accent-violet); background: var(--accent-violet); }
.model-label { font-size: 14px; font-weight: 500; }
.model-desc { font-size: 12px; color: var(--text-muted); }
.model-usage { display: inline-block; margin-left: 4px; font-weight: 600; color: var(--accent-violet); }
.model-usage-wait { color: var(--warning, #b7791f); }
.billing-plans { display: grid; gap: 8px; margin-top: 12px; }
.billing-plan { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--r-md); }
.billing-plan.selected { border-color: var(--accent-violet); background: var(--accent-violet-dim); }

.mcp-server-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px 14px;
  margin-bottom: 8px;
  transition: border-color var(--t-fast);
}
.mcp-server-card:hover { border-color: rgba(16,185,129,0.3); }
.mcp-server-name { font-weight: 600; font-size: 14px; margin-bottom: 6px; display: flex; align-items: center; gap: 8px; }
.mcp-tool-count { font-size: 11px; color: var(--text-muted); font-weight: 400; }
.mcp-disconnect { margin-left: auto; }
.mcp-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent-green); box-shadow: 0 0 6px var(--accent-green); animation: dot-pulse 2s ease-in-out infinite; }
.mcp-dot.dead { background: var(--accent-red); box-shadow: 0 0 6px rgba(239,68,68,0.5); animation: none; }
@keyframes dot-pulse {
  0%, 100% { box-shadow: 0 0 4px var(--accent-green); }
  50%       { box-shadow: 0 0 10px var(--accent-green), 0 0 20px rgba(16,185,129,0.3); }
}
.mcp-tools { font-size: 11px; color: var(--text-muted); word-break: break-word; line-height: 1.8; }

.access-user-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px 14px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.access-user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-violet), var(--accent-cyan));
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; color: #fff;
  flex-shrink: 0;
}
.access-user-info { flex: 1; min-width: 0; }
.access-user-name { font-weight: 600; font-size: 14px; }
.access-user-meta { font-size: 11px; color: var(--text-muted); }
.revoke-btn { padding: 5px 10px; border-radius: var(--r-sm); font-size: 12px; font-weight: 500; color: var(--accent-red); background: rgba(239,68,68,0.08); border: 1px solid rgba(239,68,68,0.2); transition: all var(--t-fast); }
.revoke-btn:hover { background: rgba(239,68,68,0.15); }

/* Pairing badge */
.pairing-code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--accent-cyan);
}

/* ── Modal ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fade-in 0.15s ease;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 24px;
  width: min(480px, 90vw);
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 24px 80px rgba(0,0,0,0.5);
  animation: slide-up 0.2s ease;
}
@keyframes slide-up { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal h3 { font-size: 17px; font-weight: 700; margin-bottom: 16px; }

.form-group {
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-group label { font-size: 12px; font-weight: 500; color: var(--text-secondary); }
.form-group input, .form-group textarea, .form-group select {
  width: 100%;
  background: var(--bg-surface);
}
.form-group textarea { min-height: 80px; resize: vertical; }

.modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
}
.btn-cancel {
  padding: 8px 16px;
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  transition: all var(--t-fast);
}
.btn-cancel:hover { background: var(--bg-hover); }
.btn-primary {
  padding: 8px 20px;
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 500;
  background: linear-gradient(135deg, var(--accent-violet), var(--accent-cyan));
  color: #fff;
  transition: all var(--t-fast);
}
.btn-primary:hover { opacity: 0.9; }
.assistant-limit-dialog { text-align: center; }
.assistant-limit-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  margin: 0 auto 12px;
  border-radius: 50%;
  color: var(--text-accent);
  background: var(--accent-violet-dim);
  border: 1px solid var(--accent-violet-border);
  font-size: 22px;
}
.assistant-limit-dialog p { margin: 0; color: var(--text-secondary); line-height: 1.55; }
.assistant-limit-dialog p strong { color: var(--text-primary); }
.assistant-limit-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 20px; }
.assistant-limit-actions button { min-height: 44px; cursor: pointer; }
.assistant-limit-link {
  display: inline-block;
  margin-top: 14px;
  padding: 6px;
  color: var(--text-accent);
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.assistant-limit-link:focus-visible,
.assistant-limit-actions button:focus-visible { outline: 3px solid var(--accent-violet-border); outline-offset: 2px; }
@media (max-width: 420px) { .assistant-limit-actions { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { .modal-overlay, .modal { animation: none; } }
.context-import-dialog { display: flex; flex-direction: column; gap: 10px; }
.context-import-help { margin: 0; color: var(--text-secondary); line-height: 1.5; }
.context-import-label, .context-import-inline > label { color: var(--text-secondary); font-size: 12px; font-weight: 600; }
.context-import-prompt, .context-import-text {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text-primary);
  background: var(--bg-surface);
  font: 12px/1.5 'JetBrains Mono', monospace;
  padding: 10px;
  resize: vertical;
}
.context-import-prompt { height: 142px; color: var(--text-secondary); }
.context-import-text { min-height: 150px; }
.context-import-copy { align-self: flex-start; min-height: 36px; cursor: pointer; }
.context-import-inline { display: flex; flex-direction: column; gap: 8px; }
.btn-secondary {
  padding: 8px 16px;
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  transition: all var(--t-fast);
}
.btn-secondary:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* ── Toast notifications ─────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 10px 16px;
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 500;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-primary);
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
  animation: toast-in 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 320px;
}
.toast.success { border-color: rgba(16,185,129,0.3); }
.toast.error   { border-color: rgba(239,68,68,0.3); }
@keyframes toast-in { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── Stat pills ──────────────────────────────────────────── */
.stats-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.stat-pill {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}
.stat-pill strong { color: var(--text-primary); font-size: 14px; }

/* ── Empty state for pages ───────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 60px 20px;
  text-align: center;
  opacity: 0.6;
}
.empty-state .empty-state-icon { font-size: 40px; }
.empty-state h3 { font-size: 16px; font-weight: 600; color: var(--text-secondary); }
.empty-state p { font-size: 13px; color: var(--text-muted); max-width: 300px; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
  #sidebar { display: none; }
  #notes-panel { display: none; }
  :root { --sidebar-w: 0px; --notes-w: 0px; }
}

/* ── Page sections ───────────────────────────────────────── */
/* Constrains page content to a readable column */
.page-inner {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
}

/* Section header: title + optional action button on the right */
.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin: 28px 0 14px;
}
.section-head:first-child { margin-top: 0; }
.section-head h2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}
.section-head .section-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}
.section-head .page-btn { margin-left: 0; flex-shrink: 0; }

/* Small group label inside a section (e.g. a date bucket) */
.group-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin: 16px 0 8px;
}

/* Image drop zone */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--r-lg);
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  transition: all var(--t-fast);
  cursor: pointer;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--accent-violet-border);
  background: var(--accent-violet-dim);
  color: var(--text-accent);
}

/* Approve pairing form */
.pairing-form {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.pairing-form input { flex: 1; font-family: 'JetBrains Mono', monospace; font-size: 15px; text-transform: uppercase; letter-spacing: 0.1em; }

.mobile-menu-btn { display: none; margin-right: 12px; color: var(--text-secondary); }
@media (max-width: 768px) {
  .mobile-menu-btn { display: block; }
}

/* ── Responsive Mobile Styling ─────────────────────────── */
@media (max-width: 768px) {
  :root {
    --sidebar-w: 0px;
    --notes-w: 0px;
  }

  body { font-size: 13px; }

  /* Navbar moves to bottom */
  #navbar {
    top: auto;
    bottom: 0;
    height: 64px;
    padding: 0 10px;
    justify-content: space-around;
    border-bottom: none;
    border-top: 1px solid rgba(124,58,237,0.2);
    box-shadow: 0 -8px 32px rgba(0,0,0,0.3);
  }

  .nav-logo { display: none; }
  
  .nav-btn {
    flex-direction: column;
    gap: 3px;
    font-size: 9px;
    padding: 6px 2px;
    min-width: 0;
    flex: 1;
  }
  .nav-btn svg { width: 20px; height: 20px; }

  /* On mobile the bottom bar treats every tab the same — unwrap the right group */
  .nav-right { display: contents; }
  .nav-btn.icon-only { padding: 6px 2px; }
  .nav-btn.icon-only .nav-label { display: block; }
  .nav-btn.icon-only svg { width: 20px; height: 20px; }
  .nav-signin { font-size: 9px; white-space: normal; line-height: 1.2; }

  /* Hide low-priority tabs on mobile to keep bottom bar clean (6 tabs max) */
  #nav-agents, #nav-logout { display: none; }

  /* Main container spacing for bottom navbar */
  #main {
    margin-top: 0;
    padding-top: 0;
    /* The fixed bottom navbar is 64px tall. padding-bottom pushes content above it.
       height must be the full viewport — border-box means padding is included,
       so content area = 100dvh - 64px exactly. No double-subtraction. */
    height: 100dvh;
    padding-bottom: 64px;
  }

  /* Sidebars hidden by default on mobile */
  #sidebar {
    display: none;
    position: fixed;
    top: 0; left: 0; bottom: 64px;
    z-index: 1100;
    width: 82%;
    max-width: 320px;
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    flex-direction: column;
    overflow: hidden;
    box-shadow: 8px 0 32px rgba(0,0,0,0.5);
    transition: transform 0.3s ease;
  }
  #sidebar.mobile-open {
    display: flex;
  }

  /* Backdrop that dims the rest of the screen when sidebar is open */
  #sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    bottom: 64px;
    background: rgba(0,0,0,0.55);
    z-index: 1050;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
  }
  #sidebar-backdrop.active {
    display: block;
  }

  #notes-panel {
    position: fixed;
    top: 0; right: 0; bottom: 64px;
    z-index: 1000;
    width: 85%;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    display: flex; /* Override display:none if set */
  }
  #notes-panel.mobile-visible {
    transform: translateX(0);
    box-shadow: -10px 0 30px rgba(0,0,0,0.5);
  }

  /* Chat Panel adjustment — no extra bottom padding; #input-bar is already inside the panel */
  #chat-panel {
    padding-bottom: 0;
  }

  .chat-header {
    padding: 12px 16px;
  }

  /* Messages full width */
  .message {
    max-width: 92%;
    margin-bottom: 12px;
  }
  .msg-bubble {
    padding: 10px 14px;
    font-size: 14px;
  }

  /* Input Bar adjustment */
  #input-bar {
    padding: 10px;
    margin-bottom: 0;   /* #main already has padding-bottom:64px for the navbar */
    background: var(--bg-surface);
  }
  .input-wrapper {
    padding: 6px;
    border-radius: var(--r-lg);
  }

  /* Page containers */
  .page-header {
    padding: 20px 16px;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .page-title { font-size: 20px; }
  .page-btn { width: 100%; justify-content: center; }

  /* Login Card */
  .login-card {
    padding: 30px 20px;
    margin: 10px;
  }
}

/* ============================================================
   Agent Personalities & Roadmap Styles
   ============================================================ */

/* Agent personalities */
.agent-card {
  transition: all var(--t-base) !important;
}
.agent-card.active-agent {
  border-color: var(--accent-violet) !important;
  background: var(--accent-violet-dim) !important;
  box-shadow: 0 0 16px rgba(124,58,237,0.2);
}
.agent-avatar {
  width: 44px; height: 44px;
  border-radius: var(--r-md);
  background: var(--bg-elevated);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.2);
  flex-shrink: 0;
}
.btn-danger {
  background: rgba(239,68,68,0.15) !important;
  border: 1px solid rgba(239,68,68,0.3) !important;
  color: var(--accent-red) !important;
}
.btn-danger:hover {
  background: rgba(239,68,68,0.25) !important;
}

/* Goal Roadmap / Kanban */
.goals-board {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 12px;
  height: 100%;
}
.goals-column {
  width: 290px;
  flex-shrink: 0;
  background: rgba(255,255,255,0.015);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  display: flex;
  flex-direction: column;
  max-height: 100%;
  overflow: hidden;
}
.goals-column-header {
  padding: 14px 16px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}
.column-count {
  font-size: 11px;
  background: var(--bg-elevated);
  padding: 2px 7px;
  border-radius: 999px;
  margin-left: 6px;
  color: var(--text-muted);
}
.goals-column-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.column-empty {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  padding: 30px 10px;
  font-style: italic;
}

.goal-kanban-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all var(--t-fast);
}
.goal-kanban-card:hover {
  border-color: var(--accent-violet-border);
}
.goal-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.goal-card-header strong {
  font-size: 14px;
  color: var(--text-primary);
}
.goal-delete-btn {
  font-size: 11px;
  color: var(--text-muted);
  padding: 2px;
}
.goal-delete-btn:hover {
  color: var(--accent-red);
}
.goal-card-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
}
.goal-card-date {
  font-size: 11px;
  color: var(--accent-cyan);
}

.goal-milestones-section {
  border-top: 1px dashed var(--border);
  padding-top: 8px;
  margin-top: 4px;
}
.milestones-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.add-m-btn {
  font-size: 10px;
  color: var(--accent-cyan);
  font-weight: 600;
}
.add-m-btn:hover {
  text-decoration: underline;
}
.goal-milestones-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.goal-milestones-list li {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 11px;
}
.goal-milestones-list input[type="checkbox"] {
  width: auto;
  margin-top: 2px;
  padding: 0;
  cursor: pointer;
}
.goal-milestones-list span {
  color: var(--text-secondary);
}
.goal-milestones-list span.completed {
  text-decoration: line-through;
  color: var(--text-muted);
}

.goal-stage-move {
  margin-top: 6px;
}

/* ── Mind page ─────────────────────────────────────────────── */
.page-btn.secondary {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}
.page-btn.secondary:hover { color: var(--text-primary); }
.page-btn:disabled { opacity: 0.55; cursor: wait; transform: none; }

.mind-insights {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.mind-stat {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 14px 16px;
}
.mind-stat-value { font-size: 26px; font-weight: 700; color: var(--text-primary); line-height: 1.2; }
.mind-stat-value.small { font-size: 16px; }
.mind-stat-label { font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-top: 2px; }
.mind-stat-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.mind-insight-rows { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 6px; }
.mind-insight-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.mind-insight-title { font-size: 11px; color: var(--text-muted); min-width: 92px; }
.mind-pill {
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}
.mind-pill.good { border-color: rgba(16,185,129,0.45); color: #34d399; }
.mind-pill.strained { border-color: rgba(239,68,68,0.45); color: #f87171; }

.mind-section { margin-bottom: 26px; }
.mind-section-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.mind-section-head h3 { font-size: 15px; font-weight: 600; }
.mind-section-note { font-size: 12px; color: var(--text-muted); }
.mind-section-head input {
  margin-left: auto;
  font-size: 12px;
  padding: 6px 10px;
  width: 200px;
  max-width: 100%;
}

.mind-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.mind-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--t-fast);
}
.mind-chip:hover { color: var(--text-primary); border-color: var(--border-accent); }
.mind-chip.off { opacity: 0.38; }
.mind-chip.off .mind-chip-dot { background: var(--text-muted) !important; }
.mind-chip-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.mind-chip-count { color: var(--text-muted); }

.mind-graph-wrap {
  position: relative;
  height: 520px;
  max-height: 68vh;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.mind-graph-wrap canvas { display: block; cursor: grab; touch-action: none; }
.mind-graph-wrap .empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
}
.mind-hint { font-size: 11px; color: var(--text-muted); margin-top: 6px; }

.mind-tooltip {
  position: absolute;
  z-index: 5;
  max-width: 240px;
  background: rgba(20,20,31,0.96);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-md);
  padding: 8px 10px;
  font-size: 12px;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.mind-tooltip b { color: var(--text-primary); font-weight: 600; }
.mind-tt-kind { color: var(--text-muted); font-size: 11px; }
.mind-tt-sum { color: var(--text-secondary); font-size: 11px; }

.mind-node-panel {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 265px;
  max-width: calc(100% - 24px);
  max-height: calc(100% - 24px);
  overflow-y: auto;
  background: rgba(15,15,26,0.94);
  backdrop-filter: blur(8px);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-lg);
  padding: 14px;
  z-index: 4;
}
.mind-panel-close {
  position: absolute;
  top: 8px;
  right: 10px;
  color: var(--text-muted);
  font-size: 16px;
}
.mind-panel-kind {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}
.mind-node-panel h4 { font-size: 15px; margin-bottom: 6px; color: var(--text-primary); }
.mind-panel-summary { font-size: 12.5px; color: var(--text-secondary); margin-bottom: 8px; }
.mind-panel-meta { font-size: 11px; color: var(--text-muted); margin: 8px 0; }
.mind-panel-rels-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 10px 0 5px;
}
.mind-rel { font-size: 11.5px; color: var(--text-secondary); padding: 2px 0; }
.mind-rel-arrow { color: var(--text-accent); margin: 0 4px; }
.mind-sentiment { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--text-muted); }
.mind-sentiment-track {
  position: relative;
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent-red), var(--text-muted) 50%, var(--accent-green));
  opacity: 0.75;
}
.mind-sentiment-dot {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-primary);
  border: 2px solid var(--bg-surface);
}
.mind-sentiment .good { color: #34d399; }
.mind-sentiment .bad { color: #f87171; }
.mind-forget-btn {
  margin-top: 12px;
  width: 100%;
  padding: 7px;
  border-radius: var(--r-md);
  border: 1px solid rgba(239,68,68,0.4);
  color: #f87171;
  font-size: 12px;
  background: rgba(239,68,68,0.08);
  transition: background var(--t-fast);
}
.mind-forget-btn:hover { background: rgba(239,68,68,0.18); }

.mind-personality-grid {
  display: grid;
  grid-template-columns: minmax(260px, 380px) 1fr;
  gap: 12px;
}
.mind-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 12px;
  position: relative;
}
#mind-radar-canvas { width: 100%; height: 300px; display: block; }
.mind-evolution-card { height: 280px; }
#mind-evolution-canvas { width: 100%; height: 100%; display: block; touch-action: none; }

.mind-trait-row {
  display: grid;
  grid-template-columns: 168px 1fr 52px;
  align-items: center;
  gap: 10px;
  padding: 6px 4px;
}
.mind-trait-name {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--text-secondary);
}
.mind-trait-track {
  height: 8px;
  border-radius: 4px;
  background: var(--bg-elevated);
  overflow: hidden;
}
.mind-trait-fill { height: 100%; border-radius: 4px; }
.mind-trait-value { font-size: 12.5px; color: var(--text-primary); text-align: right; }
.mind-trait-value em { font-style: normal; font-size: 10px; margin-left: 3px; }
.mind-trait-value em.up { color: #34d399; }
.mind-trait-value em.down { color: #f87171; }

@media (max-width: 760px) {
  .mind-personality-grid { grid-template-columns: 1fr; }
  .mind-graph-wrap { height: 420px; }
  .mind-trait-row { grid-template-columns: 130px 1fr 48px; }
  .mind-section-head input { width: 100%; margin-left: 0; }
  .mind-node-panel { width: calc(100% - 24px); max-height: 55%; top: auto; bottom: 12px; }
}

/* ================================================================
   UX polish layer: onboarding wizard, memory chip, settings rows,
   toggle switches, watcher cards. Additive only.
   ================================================================ */

/* ── Memory-visible chip ── */
.brain-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  margin-right: 10px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-cyan);
  background: var(--accent-cyan-dim);
  border: 1px solid rgba(6,182,212,0.3);
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: transform var(--t-fast), box-shadow var(--t-fast);
}
.brain-chip:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(6,182,212,0.25); }
.brain-chip.pulse { animation: brainPulse 0.9s ease; }
@keyframes brainPulse {
  0%   { transform: scale(1); box-shadow: 0 0 0 0 rgba(6,182,212,0.5); }
  40%  { transform: scale(1.12); box-shadow: 0 0 0 10px rgba(6,182,212,0); }
  100% { transform: scale(1); }
}

/* ── Onboarding wizard ── */
.ob-overlay {
  position: fixed; inset: 0; z-index: 2000;
  display: flex; align-items: center; justify-content: center;
  background: rgba(8,8,16,0.86);
  backdrop-filter: blur(8px);
  animation: obFadeIn 0.25s ease;
}
@keyframes obFadeIn { from { opacity: 0; } to { opacity: 1; } }
.ob-card {
  position: relative;
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  padding: 36px 40px 28px;
  background: linear-gradient(160deg, var(--bg-elevated), var(--bg-surface));
  border: 1px solid var(--border-accent);
  border-radius: var(--r-xl);
  box-shadow: 0 24px 80px rgba(0,0,0,0.55), 0 0 60px rgba(124,58,237,0.12);
}
.ob-card h2 { font-size: 22px; margin-bottom: 8px; color: var(--text-primary); }
.ob-subtitle { font-size: 13.5px; color: var(--text-secondary); line-height: 1.6; margin-bottom: 20px; }
.ob-skip {
  position: absolute; top: 16px; right: 20px;
  background: none; border: none; cursor: pointer;
  font-size: 12.5px; color: var(--text-muted);
  transition: color var(--t-fast);
}
.ob-skip:hover { color: var(--text-primary); }
.ob-progress { display: flex; gap: 8px; margin-bottom: 22px; }
.ob-dot {
  width: 28px; height: 4px; border-radius: 2px;
  background: var(--bg-hover);
  transition: background var(--t-base);
}
.ob-dot.active { background: var(--accent-violet); }
.ob-dot.done   { background: var(--accent-violet-dim); }
.ob-hint { font-size: 11.5px; color: var(--text-muted); margin-top: 6px; }
.ob-optional { font-weight: 400; color: var(--text-muted); font-size: 11.5px; }
.ob-toggle-row {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; margin-bottom: 10px;
  font-size: 13px; line-height: 1.5; color: var(--text-secondary);
  background: var(--bg-overlay);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast);
}
.ob-toggle-row:hover { border-color: var(--border-accent); background: var(--bg-hover); }
.ob-toggle-row input[type="checkbox"] { margin-top: 3px; accent-color: var(--accent-violet); }
.ob-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 24px; }
.ob-done-icon { font-size: 44px; text-align: center; margin-bottom: 10px; }
.ob-facts {
  list-style: none; margin: 14px 0; padding: 0;
}
.ob-facts li {
  padding: 9px 14px; margin-bottom: 8px;
  font-size: 13px; color: var(--text-primary);
  background: var(--accent-cyan-dim);
  border-left: 3px solid var(--accent-cyan);
  border-radius: var(--r-sm);
  animation: obFactIn 0.35s ease both;
}
.ob-facts li:nth-child(2) { animation-delay: 0.1s; }
.ob-facts li:nth-child(3) { animation-delay: 0.2s; }
@keyframes obFactIn { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: none; } }
.ob-extras { font-size: 13px; color: var(--text-secondary); line-height: 2; margin-top: 6px; }

/* ── Settings rows + switches ── */
.setting-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.setting-row:last-child { border-bottom: none; }
.setting-info { flex: 1; min-width: 0; }
.setting-label { font-size: 13.5px; font-weight: 600; color: var(--text-primary); }
.setting-desc { font-size: 12px; color: var(--text-muted); margin-top: 3px; line-height: 1.5; }
.setting-control { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.setting-hint {
  font-size: 12px; color: var(--text-muted);
  padding: 10px 0 4px; line-height: 1.6;
}
.setting-hint.warn { color: var(--accent-orange); }
.setting-hint a { color: var(--accent-cyan); }
.input-sm {
  padding: 6px 10px; font-size: 12.5px;
  background: var(--bg-overlay);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text-primary);
}
.input-sm:focus { outline: none; border-color: var(--accent-violet); }
.btn-sm { font-size: 12px !important; padding: 6px 12px !important; }

.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0; cursor: pointer;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: background var(--t-base), border-color var(--t-base);
}
.switch .slider::before {
  content: ""; position: absolute; left: 3px; top: 50%;
  width: 15px; height: 15px; border-radius: 50%;
  background: var(--text-secondary);
  transform: translateY(-50%);
  transition: transform var(--t-base), background var(--t-base);
}
.switch input:checked + .slider {
  background: var(--accent-violet-dim);
  border-color: var(--accent-violet);
}
.switch input:checked + .slider::before {
  background: var(--accent-violet);
  transform: translate(17px, -50%);
}
.switch input:focus-visible + .slider { box-shadow: 0 0 0 3px var(--accent-violet-dim); }

/* ── Watcher cards ── */
.watcher-card {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  transition: border-color var(--t-fast), transform var(--t-fast);
}
.watcher-card:hover { border-color: var(--border-accent); transform: translateY(-1px); }
.watcher-card.paused { opacity: 0.6; }
.watcher-status-dot {
  width: 9px; height: 9px; margin-top: 5px; border-radius: 50%;
  background: var(--accent-green); flex-shrink: 0;
  box-shadow: 0 0 8px rgba(16,185,129,0.6);
}
.watcher-status-dot.paused { background: var(--text-muted); box-shadow: none; }
.watcher-body { flex: 1; min-width: 0; }
.watcher-query { font-size: 13.5px; font-weight: 600; color: var(--text-primary); }
.watcher-meta { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; }
.watcher-sources { font-size: 11px; color: var(--text-muted); margin-top: 3px; font-family: 'JetBrains Mono', monospace; }

/* Responsive: settings rows stack on small screens */
@media (max-width: 640px) {
  .setting-row { flex-direction: column; align-items: flex-start; gap: 10px; }
  .setting-control { width: 100%; justify-content: flex-end; }
  .ob-card { padding: 28px 22px 22px; }
  .brain-chip { display: none !important; }
}

/* ================================================================
   UI reorganization layer: chat suggestions, status pills,
   integration cards, agent cards, goal board polish.
   ================================================================ */

/* ── Chat empty-state suggestions ── */
.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  max-width: 440px;
}
.chat-suggestion {
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  color: var(--text-secondary);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  transition: all var(--t-fast);
}
.chat-suggestion:hover {
  color: var(--text-accent);
  border-color: var(--accent-violet-border);
  background: var(--accent-violet-dim);
  transform: translateY(-1px);
}

/* ── Status pills (integration state) ── */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.status-pill::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.status-pill.ok   { color: #34d399; background: rgba(16,185,129,0.1);  border: 1px solid rgba(16,185,129,0.25); }
.status-pill.off  { color: var(--text-muted); background: var(--bg-overlay); border: 1px solid var(--border); }
.status-pill.warn { color: var(--accent-orange); background: rgba(245,158,11,0.1); border: 1px solid rgba(245,158,11,0.25); }

/* ── Integration cards ── */
.integration-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px 16px;
  margin-bottom: 12px;
}
.integration-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 6px;
}
.integration-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-right: 4px;
}
.integration-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 10px;
}
.integration-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.integration-setup { margin-top: 12px; }
.integration-setup summary {
  font-size: 12px;
  color: var(--accent-cyan);
  cursor: pointer;
  user-select: none;
}
.integration-setup summary:hover { text-decoration: underline; }
.integration-setup textarea {
  width: 100%;
  margin: 10px 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  background: var(--bg-base);
}

/* ── Agent cards ── */
.agent-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: all var(--t-base);
}
.agent-card:hover { border-color: var(--accent-violet-border); }
.agent-card-head {
  display: flex;
  align-items: center;
  gap: 12px;
}
.agent-card-title { flex: 1; min-width: 0; }
.agent-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.agent-scope {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}
.agent-prompt {
  font-size: 12.5px;
  color: var(--text-secondary);
  font-style: italic;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.agent-assign-btn {
  width: 100%;
  padding: 8px;
  border-radius: var(--r-md);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-accent);
  background: var(--accent-violet-dim);
  border: 1px solid var(--accent-violet-border);
  transition: all var(--t-fast);
}
.agent-assign-btn:hover { background: rgba(124,58,237,0.25); }
.agent-assign-btn.active {
  color: #34d399;
  background: rgba(16,185,129,0.1);
  border-color: rgba(16,185,129,0.3);
}
.agent-assign-btn.active:hover { background: rgba(239,68,68,0.12); color: #f87171; border-color: rgba(239,68,68,0.3); }

/* ── Goal board polish ── */
.goal-stage-select {
  width: 100%;
  font-size: 11px;
  padding: 5px 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text-secondary);
  cursor: pointer;
}
.goal-stage-select:hover { color: var(--text-primary); border-color: var(--border-accent); }
.milestone-date { font-size: 10px; color: var(--text-muted); font-style: normal; }
.milestones-empty { font-size: 11px; color: var(--text-muted); font-style: italic; }

/* ── Composer grouping + mobile overflow guard ── */
.input-actions {
  align-self: flex-end;
  padding: 3px;
  background: var(--bg-overlay);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  gap: 3px;
}
.composer-tool-group {
  display: flex;
  align-items: center;
  gap: 2px;
}
.composer-tool-group + .composer-tool-group {
  padding-left: 5px;
  border-left: 1px solid var(--border);
}
.command-trigger {
  color: var(--text-accent);
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
}

@media (max-width: 768px) {
  .composer-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .composer-tools {
    max-width: 0;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
    transform: translateX(-4px);
    transition: max-width var(--t-base), opacity var(--t-base), transform var(--t-base);
  }

  .input-actions.tools-open .composer-tools {
    max-width: 260px;
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0);
  }
}

@media (max-width: 768px) {
  html,
  body,
  #main,
  #page-container,
  #chat-view,
  #chat-panel {
    max-width: 100vw;
    overflow-x: hidden;
  }

  #page-container.visible,
  #page-reminders,
  #page-tasks,
  #page-settings,
  #page-agents,
  #page-mind {
    min-width: 0;
  }

  .page-content,
  .page-inner,
  #mind-content,
  #tasks-list-container,
  #watchers-list-container {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: hidden;
    padding-left: 14px;
    padding-right: 14px;
  }

  .page-header > div:last-child:not(:first-child) {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
  }

  .page-header > div:last-child:not(:first-child) .page-btn {
    width: auto;
    flex: 1 1 128px;
    min-width: 0;
  }

  .section-head {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    margin: 20px 0 12px;
    min-width: 0;
  }

  .section-head > div {
    min-width: 0;
  }

  .section-head h2 {
    font-size: 16px;
    line-height: 1.35;
  }

  .section-head .section-sub {
    max-width: 100%;
    overflow-wrap: anywhere;
    line-height: 1.45;
  }

  .section-head .page-btn {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    flex-shrink: 1;
    justify-content: center;
    margin-left: 0;
  }

  .card-grid,
  .mind-insights,
  .mind-personality-grid {
    grid-template-columns: minmax(0, 1fr) !important;
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .task-card,
  .watcher-card,
  .reminder-card,
  .mind-card,
  .mind-stat,
  .mind-section,
  .mind-graph-wrap,
  .mind-node-panel {
    max-width: 100%;
    min-width: 0;
  }

  .task-card,
  .watcher-card,
  .reminder-card {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 10px;
    padding: 12px;
  }

  .task-body,
  .watcher-body,
  .reminder-body,
  .task-title,
  .task-instruction,
  .task-meta,
  .watcher-query,
  .watcher-meta,
  .watcher-sources,
  .reminder-title,
  .reminder-msg,
  .reminder-time,
  .reminder-notes {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .task-recurrence-badge {
    max-width: 68px;
    padding: 3px 7px;
    font-size: 10px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .reminder-actions {
    flex-direction: column;
  }

  .mind-graph-wrap {
    height: min(420px, 62vh);
  }

  .mind-section-head {
    align-items: stretch;
  }

  .mind-section-head input {
    width: 100%;
    min-width: 0;
  }

  .mind-trait-row {
    grid-template-columns: minmax(0, 112px) minmax(0, 1fr) minmax(38px, auto);
    gap: 8px;
  }

  .mind-trait-name,
  .mind-trait-value {
    min-width: 0;
  }

  .mind-trait-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .input-wrapper {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "tools tools"
      "text send";
    align-items: end;
    gap: 8px;
  }

  .input-actions {
    grid-area: tools;
    width: max-content;
    max-width: 100%;
  }

  #message-input {
    grid-area: text;
    min-width: 0;
  }

  .send-btn {
    grid-area: send;
  }
}

@media (max-width: 380px) {
  .page-content,
  .page-inner,
  #mind-content {
    padding-left: 10px;
    padding-right: 10px;
  }

  .task-card,
  .watcher-card,
  .reminder-card {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .task-card > div:first-child {
    grid-column: 1 / -1;
  }

  .mind-trait-row {
    grid-template-columns: minmax(0, 1fr) 42px;
  }

  .mind-trait-track {
    grid-column: 1 / -1;
    order: 3;
  }
}

/* ── ChatGPT-style assistant messages ── */
.message.assistant {
  width: 100%;
  justify-content: flex-start;
}

.message.assistant .msg-avatar {
  display: none;
}

.message.assistant .msg-content {
  width: min(880px, 100%);
  max-width: min(880px, 100%);
}

.message.assistant .msg-bubble {
  padding: 4px 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  color: var(--text-primary);
  font-size: 15px;
  line-height: 1.75;
}

.message.assistant .msg-meta {
  padding: 0;
  opacity: 0.58;
}

.message.user {
  justify-content: flex-start;
}

.message.user .msg-content {
  max-width: min(560px, 72%);
}

.message.assistant .msg-bubble .md-heading {
  font-size: 16px;
  margin: 14px 0 6px;
}

.message.assistant .msg-bubble .md-list-item {
  margin: 3px 0;
}

.message.assistant .msg-bubble pre {
  margin: 12px 0;
  padding: 14px 16px;
  background: #070b10;
  border: 1px solid rgba(148,163,184,0.16);
  border-radius: 12px;
  white-space: pre;
}

.message.assistant .msg-bubble code {
  background: rgba(148,163,184,0.22);
  color: var(--text-primary);
}

.typing-indicator {
  width: 100%;
}

.typing-indicator .assistant-avatar {
  display: none;
}

.typing-dots {
  background: transparent;
  border: 0;
  padding: 8px 0;
}

.tool-badge {
  width: max-content;
  max-width: min(880px, 100%);
}

@media (max-width: 768px) {
  .message.assistant {
    max-width: 100%;
  }

  .message.assistant .msg-content {
    width: 100%;
    max-width: 100%;
  }

  .message.assistant .msg-bubble {
    font-size: 14.5px;
    line-height: 1.7;
  }

  .message.user {
    max-width: 100%;
  }

  .message.user .msg-content {
    max-width: min(82%, 520px);
  }

  .message.assistant .msg-bubble pre {
    border-radius: 10px;
    padding: 12px;
  }
}

/* ── Centered conversation lane ── */
#messages {
  align-items: center;
  padding-left: clamp(16px, 5vw, 56px);
  padding-right: clamp(16px, 5vw, 56px);
}

.message,
.typing-indicator {
  width: min(920px, 100%);
  max-width: 920px;
}

.message.assistant {
  width: min(920px, 100%);
  max-width: 920px;
}

.message.user {
  width: min(920px, 100%);
  max-width: 920px;
  justify-content: flex-start;
}

.message.user .msg-content {
  max-width: min(560px, 68%);
}

/* Composer spans the full width of the chat panel (message text stays
   centered/capped above for readability). */
#input-bar {
  display: block;
}

.input-wrapper {
  width: 100%;
}

/* Keep the composer full-width and progressively disclose secondary tools. */
#input-bar {
  width: 100%;
  box-sizing: border-box;
  align-items: center;
}

.input-wrapper {
  align-self: center;
  display: flex;
  align-items: center;
  width: 100%;
  max-width: none;
  min-width: 0;
  height: auto;
  min-height: 0;
}

.input-actions {
  flex: 0 0 auto;
  position: relative;
  z-index: 30;
}

#message-input {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
  min-height: 44px;
  align-self: center;
  padding: 10px 0;
  box-sizing: border-box;
}

.send-btn {
  flex: 0 0 auto;
}

.composer-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
}

.composer-tools {
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  display: flex;
  width: max-content;
  max-width: min(320px, calc(100vw - 32px));
  padding: 4px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.3);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity var(--t-fast), transform var(--t-fast), visibility var(--t-fast);
}

.input-actions.tools-open .composer-tools {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}

/* ── Scroll-to-latest button ── */
/* Sits just above the composer; appears only when scrolled away from bottom
   (including mid-generation) so the user can catch up with one tap. */
#scroll-bottom-btn {
  position: absolute;
  right: 24px;
  bottom: 96px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  box-shadow: 0 6px 20px rgba(0,0,0,0.35);
  opacity: 0;
  transform: translateY(8px) scale(0.9);
  pointer-events: none;
  transition: opacity var(--t-fast), transform var(--t-fast), color var(--t-fast), border-color var(--t-fast);
  z-index: 5;
}
#scroll-bottom-btn.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
#scroll-bottom-btn:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
  border-color: var(--accent-violet-border);
}
@media (max-width: 768px) {
  #scroll-bottom-btn {
    right: 14px;
    bottom: 120px;
  }
}

.tool-badge {
  align-self: center;
  width: min(920px, 100%);
  max-width: 920px;
}

@media (max-width: 768px) {
  #messages {
    padding-left: 14px;
    padding-right: 14px;
  }

  .message,
  .message.assistant,
  .message.user,
  .typing-indicator,
  .tool-badge {
    width: 100%;
    max-width: 100%;
  }

  .message.user .msg-content {
    max-width: min(86%, 520px);
  }
}

/* ── Admin page ─────────────────────────────────────────────── */
.admin-stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}
.admin-stat {
  background: var(--bg-card, rgba(255,255,255,0.04));
  border: 1px solid var(--border, rgba(255,255,255,0.08));
  border-radius: 12px;
  padding: 12px 14px;
}
.admin-stat-num {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent, #8b5cf6);
}
.admin-stat-label {
  font-size: 11px;
  color: var(--text-muted, #9ca3af);
  margin-top: 2px;
}
.admin-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  border-radius: 999px;
  padding: 1px 8px;
  margin-left: 6px;
  vertical-align: middle;
}
