/* ==========================================================================
   CSS Variables
   ========================================================================== */
:root {
  --bg-primary: #0b1120;       /* Dark navy */
  --bg-secondary: #111827;     /* Slate 900 */
  --bg-tertiary: #1e293b;      /* Slate 800 */
  --bg-blur: rgba(11, 17, 32, 0.88);
  --accent: #3b82f6;           /* Blue 500 — corporate blue */
  --accent-hover: #60a5fa;     /* Blue 400 — lighter on hover for dark mode */
  --accent-soft: rgba(59, 130, 246, 0.12);
  --accent-soft-strong: rgba(59, 130, 246, 0.18);
  --text-primary: #f1f5f9;     /* Slate 100 */
  --text-secondary: #94a3b8;   /* Slate 400 */
  --text-tertiary: #64748b;    /* Slate 500 — meets 3:1 on dark */
  --danger: #ef4444;           /* Red 500 */
  --danger-soft: rgba(239, 68, 68, 0.1);
  --danger-hover: #dc2626;
  --success: #22c55e;
  --success-soft: rgba(34, 197, 94, 0.1);
  --warning: #f59e0b;
  --warning-soft: rgba(245, 158, 11, 0.1);
  --code-bg: #0d1424;
  --code-text: #e2e8f0;
  --border: #1e3a5f;           /* Navy-tinted border */
  --border-subtle: rgba(148, 163, 184, 0.08);
  
  --user-bubble: var(--bg-secondary);
  --assistant-bubble: transparent;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.35), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -4px rgba(0, 0, 0, 0.3);

  --app-safe-bottom: env(safe-area-inset-bottom);
}

/* ---------- Light Theme ---------- */
[data-theme="light"] {
  --bg-primary: #f8fafc;         /* Slate 50 */
  --bg-secondary: #ffffff;       /* Pure white */
  --bg-tertiary: #e2e8f0;       /* Slate 200 */
  --bg-blur: rgba(248, 250, 252, 0.92);
  --accent: #2563eb;             /* Blue 600 — darker for light bg */
  --accent-hover: #1d4ed8;       /* Blue 700 */
  --accent-soft: rgba(37, 99, 235, 0.08);
  --accent-soft-strong: rgba(37, 99, 235, 0.14);
  --text-primary: #0f172a;       /* Slate 900 */
  --text-secondary: #475569;     /* Slate 600 */
  --text-tertiary: #64748b;      /* Slate 500 */
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.08);
  --danger-hover: #b91c1c;
  --success: #16a34a;
  --success-soft: rgba(22, 163, 74, 0.08);
  --warning: #d97706;
  --warning-soft: rgba(217, 119, 6, 0.08);
  --code-bg: #f1f5f9;           /* Slate 100 */
  --code-text: #1e293b;         /* Slate 800 */
  --border: #cbd5e1;            /* Slate 300 */
  --border-subtle: rgba(71, 85, 105, 0.1);

  --user-bubble: #eff6ff;        /* Blue 50 */
  --assistant-bubble: transparent;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.05);

  --chat-glow-1: rgba(37, 99, 235, 0.03);
  --chat-glow-2: rgba(99, 102, 241, 0.02);
  --chat-grid-color: rgba(71, 85, 105, 0.06);
  --chat-ring: rgba(37, 99, 235, 0.035);
  --chat-ring-2: rgba(139, 92, 246, 0.025);
  --chat-node: rgba(71, 85, 105, 0.07);
  --chat-line: rgba(71, 85, 105, 0.04);
  --chat-grid: rgba(71, 85, 105, 0.03);
  --user-glass: rgba(37, 99, 235, 0.08);
  --user-glass-border: rgba(37, 99, 235, 0.15);
  --assistant-glass: rgba(255, 255, 255, 0.7);
  --assistant-glass-border: rgba(71, 85, 105, 0.12);
}
[data-theme="light"] .toggle { background: #cbd5e1; }
[data-theme="light"] .toggle::after { box-shadow: 0 1px 2px rgba(0,0,0,0.15); }
[data-theme="light"] .toggle.on { background: var(--accent); }
[data-theme="light"] .login-input { background: var(--bg-tertiary); color: var(--text-primary); }

/* ---------- Theme Selector ---------- */
.theme-selector {
  display: flex;
  gap: 8px;
}
.theme-option {
  flex: 1;
  padding: 8px 4px;
  border-radius: 8px;
  border: 2px solid var(--border-subtle);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.theme-option:hover { border-color: var(--border); }
.theme-option.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

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

button, a, [role="button"], .menu-item, .pill, .chip, .filter, .toggle, .cxo-card, .session-item, .agent-item {
  touch-action: manipulation;
}

html {
  margin: 0;
  width: 100%;
  height: 100%;
  height: -webkit-fill-available;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg-primary);
}

body {
  margin: 0;
  width: 100%;
  height: 100%;
  height: -webkit-fill-available;
  min-height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg-primary);
}

body {
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  color: var(--text-primary);
  line-height: 1.5;
}

.app {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-primary);
}

/* ==========================================================================
   Scrollbar
   ========================================================================== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-tertiary); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }

/* ==========================================================================
   Top Bar
   ========================================================================== */
#top-bar {
  min-height: 56px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  padding-top: env(safe-area-inset-top);
  background: var(--bg-secondary);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-subtle);
  flex: 0 0 auto;
  gap: 12px;
  z-index: 100;
}

#menu-btn {
  min-width: 44px;
  min-height: 44px;
  width: 44px;
  height: 44px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

#menu-btn:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

#menu-btn:active {
  transform: scale(0.95);
}

#header-title {
  flex: 1;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
  color: var(--text-primary);
}

/* ==========================================================================
   Message Area
   ========================================================================== */
#chat-messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  background-color: var(--bg-primary);
  background-image:
    /* Orbital rings */
    radial-gradient(ellipse 600px 600px at 15% 30%, var(--chat-ring, rgba(59,130,246,0.045)) 0%, transparent 70%),
    radial-gradient(ellipse 400px 400px at 85% 70%, var(--chat-ring-2, rgba(139,92,246,0.035)) 0%, transparent 70%),
    /* Circuit-style grid with crosses at intersections */
    radial-gradient(circle 1.5px at center, var(--chat-node, rgba(148,163,184,0.08)) 0%, transparent 100%),
    /* Hex-ish diagonal lines */
    linear-gradient(30deg, var(--chat-line, rgba(148,163,184,0.03)) 1px, transparent 1px),
    linear-gradient(150deg, var(--chat-line, rgba(148,163,184,0.03)) 1px, transparent 1px),
    /* Base subtle grid */
    linear-gradient(var(--chat-grid, rgba(148,163,184,0.025)) 1px, transparent 1px),
    linear-gradient(90deg, var(--chat-grid, rgba(148,163,184,0.025)) 1px, transparent 1px);
  background-size:
    100% 100%, 100% 100%,
    48px 48px,
    28px 48px, 28px 48px,
    48px 48px, 48px 48px;
}

.message {
  max-width: 90%;
  border-radius: 12px;
  padding: 14px 18px;
  line-height: 1.45;
  word-wrap: break-word;
  overflow-wrap: break-word;
  animation: fadeIn 0.25s ease-out;
  font-size: 15px;
  letter-spacing: -0.01em;
}

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

.message.user {
  margin-left: auto;
  background: var(--user-glass, rgba(59,130,246,0.1));
  border: 1px solid var(--user-glass-border, rgba(59,130,246,0.2));
  color: var(--text-primary);
  border-bottom-right-radius: 4px;
  box-shadow: var(--shadow-sm);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  backdrop-filter: blur(16px) saturate(1.4);
}

.message.assistant {
  margin-right: auto;
  background: var(--assistant-glass, rgba(30,41,59,0.65));
  border: 1px solid var(--assistant-glass-border, rgba(148,163,184,0.1));
  border-bottom-left-radius: 4px;
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  backdrop-filter: blur(16px) saturate(1.4);
}

/* Markdown Styles inside Messages */
.message h1, .message h2, .message h3,
.message h4, .message h5, .message h6 {
  margin: 1.2em 0 0.6em;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-primary);
}
.message h1 { font-size: 1.5em; letter-spacing: -0.02em; }
.message h2 { font-size: 1.3em; letter-spacing: -0.01em; }
.message h3 { font-size: 1.1em; }

.message p { margin-bottom: 12px; }
.message p:last-child { margin-bottom: 0; }

.message ul, .message ol { margin: 12px 0 12px 24px; padding-left: 4px; }
.message li { margin-bottom: 4px; }

.message blockquote {
  border-left: 3px solid var(--accent);
  margin: 12px 0;
  padding: 4px 0 4px 16px;
  color: var(--text-secondary);
  background: rgba(255,255,255,0.02);
  border-radius: 0 8px 8px 0;
}

.message a { color: var(--accent); text-decoration: none; font-weight: 500; transition: color 0.2s; }
.message a:hover { color: var(--accent-hover); text-decoration: underline; }
.message strong { font-weight: 600; color: var(--text-primary); }

.message table { width: max-content; min-width: 100%; border-collapse: collapse; margin: 16px 0; font-size: 14px; }
.message .table-wrap { display: block; overflow-x: auto; margin: 16px 0; }
.message .table-wrap table { margin: 0; }
.message th, .message td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; white-space: nowrap; }
.message th { background: var(--bg-tertiary); font-weight: 500; color: var(--text-primary); }

/* Inline code */
.message :not(pre) > code {
  background: var(--bg-tertiary);
  padding: 3px 6px;
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.85em;
  color: var(--accent);
  border: 1px solid var(--border-subtle);
}

/* ==========================================================================
   Input Bar
   ========================================================================== */
#input-bar {
  padding: 12px 16px;
  padding-bottom: calc(12px + var(--app-safe-bottom));
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  background: var(--bg-secondary);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-top: 1px solid var(--border-subtle);
  flex: 0 0 auto;
  /* Extend background into bottom safe area for iOS standalone PWA */
  position: relative;
}
#input-bar::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(-1 * var(--app-safe-bottom));
  height: var(--app-safe-bottom);
  background: var(--bg-secondary);
  pointer-events: none;
}

.input-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
}

#message-input {
  flex: 1;
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 16px;
  max-height: 120px;
  resize: none;
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
  font-family: inherit;
  line-height: 1.5;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.15);
}

#message-input::placeholder { color: var(--text-tertiary); }
#message-input:focus { 
  border-color: var(--accent); 
  background: var(--bg-primary);
  box-shadow: 0 0 0 1px var(--accent);
}

#attach-btn,
#send-btn {
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  border-radius: 10px;
  border: none;
  transition: transform 0.15s, opacity 0.15s, background 0.15s;
}

#attach-btn {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
}

#attach-btn:hover:not(:disabled) {
  background: var(--bg-secondary);
  color: var(--text-primary);
  transform: translateY(-1px);
}

#attach-btn:active:not(:disabled) {
  transform: translateY(1px);
}

#send-btn {
  background: var(--text-primary);
  color: var(--bg-primary);
}

#send-btn:hover:not(:disabled) {
  background: var(--text-secondary);
  transform: translateY(-1px);
}

#send-btn:active:not(:disabled) {
  transform: translateY(1px);
}

#send-btn:disabled { 
  opacity: 0.3; 
  cursor: not-allowed; 
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

.file-preview-strip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 2px 0 4px;
  scrollbar-width: thin;
}

.file-preview-strip[hidden] {
  display: none;
}

.file-preview-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 8px 34px 8px 8px;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-tertiary);
  box-shadow: var(--shadow-sm);
}

.file-preview-image {
  width: auto;
  height: 48px;
  border-radius: 8px;
  display: block;
  object-fit: cover;
  border: 1px solid var(--border-subtle);
}

.file-preview-file {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.file-preview-file svg {
  color: var(--text-secondary);
  flex-shrink: 0;
}

.file-preview-meta {
  min-width: 0;
}

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

.file-preview-size {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.file-preview-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  padding: 10px;
  box-sizing: content-box;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  background: rgba(11, 17, 32, 0.8);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.file-preview-remove:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.message-attachment {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.message-attachment:last-child {
  margin-bottom: 0;
}

.message-attachment-image {
  display: block;
  max-width: 100%;
  max-height: 280px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-sm);
}

.message-attachment-file {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 8px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border-subtle);
}

.message-attachment-file svg {
  color: var(--text-secondary);
  flex-shrink: 0;
}

.message-attachment-file strong {
  display: block;
  font-size: 13px;
  line-height: 1.4;
}

.message-attachment-file span {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ==========================================================================
   Sidebar & Overlay
   ========================================================================== */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 999;
}

.sidebar-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

#sidebar {
  position: fixed;
  left: 0;
  top: 0;
  width: 200px;
  max-width: 60%;
  height: 100%;
  background: var(--bg-secondary);
  transform: translateX(-100%);
  transition: transform 0.25s ease-out;
  z-index: 1000;
  will-change: transform;
  display: flex;
  box-shadow: var(--shadow-lg);
  border-right: 1px solid var(--border-subtle);
  padding-top: env(safe-area-inset-top);
}

#sidebar.open { transform: translateX(0); }

/* Agent List — Full Width */
.agent-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  overflow-y: auto;
  padding: 12px 8px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  gap: 4px;
  background: var(--bg-primary);
}

/* --- CXO Agent Cards --- */
.agent-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}

.agent-card:hover {
  background: var(--accent-soft);
}

.agent-card.active {
  background: var(--accent-soft-strong);
}

.agent-avatar {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--bg-tertiary, #1e293b);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.agent-name {
  font-size: 13px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.agent-card.settings-card {
  color: var(--text-secondary);
}
.agent-card.manage-card {
  margin-top: auto;
  color: var(--text-secondary);
}
.agent-card.manage-card .agent-avatar,
.agent-card.settings-card .agent-avatar {
  background: transparent;
  color: var(--text-tertiary);
}

.add-agent-btn {
  width: 52px;
  height: 52px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px dashed var(--text-tertiary);
  color: var(--text-secondary);
  cursor: pointer;
  margin-top: auto;
  flex-shrink: 0;
  transition: all 0.15s;
}

.add-agent-btn:hover { border-color: var(--text-primary); color: var(--text-primary); }

/* Session styles removed — single session per agent */

/* ==========================================================================
   Modals
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 2000;
  padding: 16px;
}

.modal-overlay.active { display: flex; animation: fadeIn 0.2s ease-out; }

.modal-content {
  background: var(--bg-secondary);
  border-radius: 14px;
  padding: 28px;
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.25s ease-out;
}

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

.modal-content h2 { 
  margin-bottom: 24px; 
  font-size: 20px; 
  font-weight: 600;
  letter-spacing: -0.01em;
}

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

.form-group label {
  display: block;
  color: var(--text-secondary);
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 500;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 14px;
  outline: none;
  font-family: inherit;
  transition: all 0.2s;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.08);
}

.form-group input:focus,
.form-group textarea:focus { 
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 32px;
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  padding: 10px 20px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
}

.btn:active { transform: scale(0.97); }

.btn-primary { 
  background: var(--text-primary); 
  color: var(--bg-primary); 
}
.btn-primary:hover { background: var(--text-secondary); }

.btn-danger { 
  background: var(--danger); 
  color: white; 
}
.btn-danger:hover { background: var(--danger-hover); }

.btn-cancel { 
  background: transparent; 
  color: var(--text-secondary); 
  border: 1px solid var(--border); 
}
.btn-cancel:hover { background: var(--bg-tertiary); color: var(--text-primary); }

.btn-delete-agent {
  width: 100%;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--danger-soft);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  margin-top: 12px;
  transition: all 0.15s;
}

.btn-delete-agent:hover { 
  background: var(--danger);
  color: white;
}

/* ==========================================================================
   Code Blocks
   ========================================================================== */
.code-block-wrapper {
  position: relative;
  margin: 16px 0;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  background: var(--code-bg);
}

.code-block-wrapper pre {
  background: transparent;
  padding: 16px;
  padding-top: 44px;
  overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
  color: var(--code-text);
  margin: 0;
}

.code-block-wrapper code { font-family: inherit; }

.code-block-wrapper::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 34px;
  background: rgba(128,128,128,0.06);
  border-bottom: 1px solid var(--border-subtle);
}

.copy-btn {
  position: absolute;
  top: 6px;
  right: 8px;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  z-index: 10;
}

.copy-btn:hover { 
  background: rgba(255,255,255,0.1); 
  color: var(--text-primary); 
}

.lang-label {
  position: absolute;
  top: 9px;
  left: 14px;
  color: var(--text-secondary);
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.5px;
  z-index: 10;
}

/* ==========================================================================
   Typing Indicator
   ========================================================================== */
.typing-indicator {
  display: inline-flex;
  gap: 4px;
  padding: 8px 12px;
  align-items: center;
  height: 32px;
}

.typing-indicator span {
  width: 6px;
  height: 6px;
  background-color: var(--text-secondary);
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}

/* Tool progress indicator */
.tool-progress {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-secondary);
}
.tool-progress-emoji {
  margin-right: 4px;
}
.tool-progress .typing-indicator {
  padding: 0;
  height: auto;
}

/* ==========================================================================
   Empty State & Error
   ========================================================================== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-secondary);
  text-align: center;
  padding: 24px;
  animation: fadeIn 0.4s ease;
}

.empty-state .icon {
  margin-bottom: 20px;
  color: var(--text-tertiary);
}

.empty-state .icon svg {
  width: 48px;
  height: 48px;
}

.error-message {
  background: var(--danger-soft);
  border: 1px solid rgba(239, 68, 68, 0.2);
  padding: 12px 16px;
  margin: 12px 0;
  border-radius: 8px;
  color: var(--danger);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.error-message::before {
  content: '⚠';
  font-size: 16px;
}

/* ==========================================================================
   Streaming State
   ========================================================================== */
.streaming #message-input { opacity: 0.6; }
.streaming .sidebar-overlay { pointer-events: none; }

/* ==========================================================================
   Notification Toasts
   ========================================================================== */
#notification-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 360px;
  pointer-events: none;
}

.notification-toast {
  pointer-events: auto;
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 12px 14px;
  cursor: pointer;
  animation: notif-slide-in 0.3s ease-out;
  backdrop-filter: blur(12px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.notification-toast.notification-error {
  border-left-color: var(--danger);
}

.notification-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.notification-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notification-status {
  font-size: 12px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.notification-body {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.notification-fade-out {
  animation: notif-fade-out 0.3s ease-in forwards;
}

@keyframes notif-slide-in {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes notif-fade-out {
  from { opacity: 1; }
  to { opacity: 0; transform: translateY(-10px); }
}

/* --------------------------------------------------------------------------
   Onboarding
   -------------------------------------------------------------------------- */
#onboarding-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-primary, #0b1120);
  z-index: 1000;
  display: none;
  flex-direction: column;
  opacity: 0;
  transition: opacity 0.3s;
}
#onboarding-overlay:not([hidden]) {
  display: flex;
}
#onboarding-overlay.visible {
  opacity: 1;
}
.onboarding-content {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}
#onboarding-step1,
#onboarding-step2 {
  display: none;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}
#onboarding-step1:not([hidden]),
#onboarding-step2:not([hidden]) {
  display: flex;
}

/* Step Indicator */
.step-indicator {
  padding: 20px 16px 4px;
  padding-top: calc(20px + env(safe-area-inset-top));
  flex-shrink: 0;
}
.step-text {
  font-size: 13px;
  color: var(--text-secondary, #94a3b8);
}
.step-text strong {
  color: var(--accent, #3b82f6);
  font-weight: 600;
}
.step-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary, #f1f5f9);
  margin-top: 4px;
}
.step-bar {
  display: flex;
  gap: 6px;
  margin-top: 12px;
}
.step-bar span {
  flex: 1;
  height: 3px;
  border-radius: 2px;
  background: var(--bg-tertiary, #1e293b);
}
.step-bar span.active {
  background: var(--accent, #3b82f6);
}

/* Hint */
.onboarding-hint {
  padding: 8px 16px;
  font-size: 13px;
  color: var(--text-secondary, #94a3b8);
  flex-shrink: 0;
}

/* CXO Selection Grid */
.cxo-selection-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 12px 16px;
  overflow-y: auto;
  flex: 1;
  padding-bottom: 100px;
}
.cxo-card {
  background: var(--bg-secondary, #111827);
  border: 1px solid var(--border, #1e3a5f);
  border-radius: 10px;
  padding: 14px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.cxo-card:active {
  background: var(--bg-tertiary, #1e293b);
}
.cxo-card.selected {
  border-color: var(--accent, #3b82f6);
  background: var(--accent-soft);
}
.cxo-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.cxo-card-emoji {
  font-size: 28px;
  line-height: 1.2;
}
.cxo-check-icon {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  border: 2px solid var(--border, #1e3a5f);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 11px;
  color: transparent;
  transition: all 0.15s;
}
.cxo-card.selected .cxo-check-icon {
  background: var(--accent, #3b82f6);
  border-color: var(--accent, #3b82f6);
  color: var(--bg-primary, #0b1120);
}
.cxo-card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary, #f1f5f9);
  margin-top: 2px;
}
.cxo-card-subtitle {
  font-size: 12px;
  color: var(--text-secondary, #94a3b8);
  line-height: 1.3;
}
.cxo-card-desc {
  font-size: 12px;
  color: var(--text-tertiary, #64748b);
  line-height: 1.3;
}

/* Onboarding Bottom Bar */
.onboarding-bottom-bar {
  position: sticky;
  bottom: 0;
  background: var(--bg-secondary, #111827);
  border-top: 1px solid rgba(255,255,255,0.05);
  padding: 12px 16px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  z-index: 10;
}
.onboarding-count {
  font-size: 14px;
  color: var(--text-secondary, #94a3b8);
}
.onboarding-count strong {
  color: var(--text-primary, #f1f5f9);
  font-weight: 600;
}

/* Privacy Notice */
.privacy-notice {
  margin: 8px 16px;
  padding: 8px 12px;
  background: var(--bg-tertiary, #1e293b);
  border-radius: 8px;
  font-size: 12px;
  color: var(--text-secondary, #94a3b8);
  line-height: 1.5;
  flex-shrink: 0;
}

/* Onboarding Form */
.onboarding-form {
  flex: 1;
  overflow-y: auto;
  padding: 8px 16px 100px;
}
.onboarding-form .section {
  margin-top: 24px;
}
.onboarding-form .section:first-child {
  margin-top: 16px;
}
.onboarding-form .section-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary, #f1f5f9);
  margin-bottom: 14px;
}
.onboarding-form .section-title .emoji {
  margin-right: 6px;
}
.onboarding-form .field {
  margin-bottom: 14px;
}
.onboarding-form .field-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary, #94a3b8);
  margin-bottom: 6px;
}
.onboarding-form input[type="text"],
.onboarding-form textarea,
.onboarding-form select {
  width: 100%;
  background: var(--bg-tertiary, #1e293b);
  border: 1px solid var(--border, #1e293b);
  border-radius: 8px;
  padding: 12px;
  font-size: 15px;
  color: var(--text-primary, #f1f5f9);
  font-family: inherit;
  line-height: 1.5;
  outline: none;
  transition: border-color 0.15s;
  -webkit-appearance: none;
  appearance: none;
  box-sizing: border-box;
}
.onboarding-form input::placeholder,
.onboarding-form textarea::placeholder {
  color: var(--text-tertiary, #64748b);
}
.onboarding-form input:focus,
.onboarding-form textarea:focus,
.onboarding-form select:focus {
  border-color: var(--accent, #3b82f6);
}
.onboarding-form textarea {
  resize: vertical;
  min-height: 56px;
}
.onboarding-form select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23a1a1aa' viewBox='0 0 16 16'%3E%3Cpath d='M4.5 6l3.5 4 3.5-4z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}
.onboarding-form select option {
  background: var(--bg-tertiary, #1e293b);
  color: var(--text-primary, #f1f5f9);
}

/* Pill Group */
.pill-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary, #94a3b8);
  background: var(--bg-tertiary, #1e293b);
  border: 1px solid var(--border, #1e293b);
  border-radius: 18px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  min-height: 44px;
  user-select: none;
  -webkit-user-select: none;
}
.pill:active {
  background: var(--bg-tertiary);
  transform: scale(0.98);
}
.pill.active {
  background: var(--accent-soft);
  border-color: var(--accent, #3b82f6);
  color: var(--accent, #3b82f6);
}

/* Chip Group */
.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary, #94a3b8);
  background: var(--bg-secondary, #111827);
  border: 1px solid var(--border, #1e293b);
  border-radius: 18px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  min-height: 44px;
  user-select: none;
  -webkit-user-select: none;
}
.chip:active {
  background: var(--bg-tertiary, #1e293b);
  transform: scale(0.97);
}
.chip.active {
  background: var(--accent-soft);
  border-color: var(--accent, #3b82f6);
  color: var(--accent, #3b82f6);
}

/* Btn text (skip) */
.btn-text {
  background: none;
  border: none;
  color: var(--text-secondary, #94a3b8);
  font-size: 14px;
  cursor: pointer;
  padding: 8px;
  font-family: inherit;
}
.btn-text:active {
  color: var(--text-primary, #f1f5f9);
}

/* --- Manage Agents Modal --- */
.manage-agents-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.25s;
}
.manage-agents-overlay.visible {
  opacity: 1;
}
.manage-agents-modal {
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  background: var(--bg-secondary);
  border-radius: 16px 16px 0 0;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.manage-agents-overlay.visible .manage-agents-modal {
  transform: translateY(0);
}
.manage-agents-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border-subtle);
}
.manage-agents-header h3 {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}
.manage-agents-close {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 4px;
}
.manage-agents-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.manage-agents-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-subtle);
}
.manage-agents-save {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.manage-agents-save:active {
  opacity: 0.85;
}

/* --- Agent Profile Page --- */
.profile-hero {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  gap: 12px;
  border-bottom: 1px solid var(--border, #1e293b);
}
.profile-avatar {
  font-size: 36px;
  line-height: 1;
  flex-shrink: 0;
}
.profile-hero-text {
  flex: 1;
  min-width: 0;
}
.profile-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary, #f1f5f9);
}
.profile-subtitle {
  font-size: 13px;
  color: var(--text-secondary, #94a3b8);
  margin-top: 2px;
}
.profile-sections {
  flex: 1;
  overflow-y: auto;
  padding: 0 16px 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  -webkit-overflow-scrolling: touch;
}
.btn-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: var(--bg-tertiary, #1e293b);
  color: var(--text-secondary, #94a3b8);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Lucide Icon Sizing */
.view-header-icon, .section-icon, .inline-icon {
  width: 18px;
  height: 18px;
  vertical-align: -3px;
  display: inline-block;
  flex-shrink: 0;
}
.menu-icon svg {
  width: 20px;
  height: 20px;
  color: var(--accent);
}

/* Panel Common */
.panel-loading, .panel-error, .panel-empty {
  text-align: center;
  padding: 40px 16px;
  color: var(--text-secondary, #94a3b8);
  font-size: 14px;
}
.panel-error { color: var(--danger); }

/* Skeleton Loading */
.skeleton {
  background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-secondary) 50%, var(--bg-tertiary) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: 8px;
}
@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton-text { height: 14px; margin-bottom: 8px; width: 100%; }
.skeleton-text.short { width: 40%; }
.skeleton-text.medium { width: 70%; }
.skeleton-card { height: 56px; margin-bottom: 8px; border-radius: 12px; }
.skeleton-loader { padding: 16px; }

/* Overview Tab */
/* Overview Tab — hero now in HTML, only menu+snapshot here */
.overview-menu {
  background: var(--bg-secondary, #111827);
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 16px;
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border, #1e293b);
  cursor: pointer;
  transition: background 0.15s, transform 0.1s ease-out;
}
.menu-item:last-child { border-bottom: none; }
.menu-item:active { background: rgba(255,255,255,0.03); }
.agent-item {
  transition: background 0.15s;
}
.agent-item:active { background: rgba(255,255,255,0.03); }
.menu-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--bg-tertiary, #1e293b);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.menu-text { flex: 1; min-width: 0; }
.menu-title { font-size: 14px; font-weight: 500; }
.menu-subtitle { font-size: 12px; color: var(--text-secondary, #94a3b8); margin-top: 1px; }
.menu-chevron { color: var(--text-tertiary, #64748b); font-size: 16px; flex-shrink: 0; }
.overview-snapshot {
  background: var(--bg-secondary, #111827);
  border-radius: 12px;
  padding: 14px;
}
.snapshot-title { font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.snapshot-content { font-size: 13px; color: var(--text-secondary, #94a3b8); line-height: 1.6; }

/* Toggle */
.toggle {
  position: relative;
  width: 48px;
  height: 28px;
  min-width: 48px;
  border-radius: 14px;
  background: var(--bg-tertiary);
  cursor: pointer;
  transition: background 0.2s;
}
.toggle::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.25s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.5);
}
.toggle.on { background: #3b82f6; }
.toggle.on::after { transform: translateX(20px); }

/* Soul Tab */
.soul-view {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.soul-toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-shrink: 0;
}
.btn-sm {
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 8px;
  border: 1px solid var(--border, #1e293b);
  background: var(--bg-secondary, #111827);
  color: var(--text-primary, #f1f5f9);
  cursor: pointer;
}
.btn-sm.btn-primary {
  background: var(--accent, #3b82f6);
  color: #ffffff;
  border-color: var(--accent, #3b82f6);
}
.btn-sm.btn-danger-sm {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger);
}
.soul-preview {
  background: var(--bg-secondary, #111827);
  border-radius: 12px;
  padding: 16px;
  font-size: 14px;
  line-height: 1.7;
  overflow-y: auto;
}
.soul-editor {
  width: 100%;
  min-height: 60vh;
  background: var(--bg-tertiary, #1e293b);
  border: 1px solid var(--border, #1e293b);
  border-radius: 8px;
  padding: 12px;
  color: var(--text-primary, #f1f5f9);
  font-family: monospace;
  font-size: 14px;
  line-height: 1.6;
  resize: vertical;
  outline: none;
}
.soul-editor:focus { border-color: var(--accent, #3b82f6); }

/* Persona Sub-Tabs */
.persona-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  flex-shrink: 0;
  overflow-x: auto;
}
.persona-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid var(--border, #1e293b);
  background: var(--bg-secondary, #111827);
  color: var(--text-secondary, #94a3b8);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.persona-tab .persona-tab-desc {
  font-size: 10px;
  font-weight: 400;
  opacity: 0.7;
  margin-top: 2px;
}
.persona-tab:hover {
  background: var(--bg-tertiary, #1e293b);
  color: var(--text-primary, #f1f5f9);
}
.persona-tab.active {
  background: var(--accent, #3b82f6);
  color: #ffffff;
  border-color: var(--accent, #3b82f6);
}
.persona-tab.active .persona-tab-desc { opacity: 0.9; }
.persona-filename {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary, #94a3b8);
  padding: 6px 0;
  margin-right: auto;
}

/* Tools Tab */
.tools-desc {
  font-size: 13px;
  color: var(--text-secondary, #94a3b8);
  margin-bottom: 12px;
}
.tool-list { display: flex; flex-direction: column; gap: 8px; }
.tool-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-secondary, #111827);
  border-radius: 12px;
  padding: 14px;
}
.tool-icon {
  width: 40px;
  height: 40px;
  min-width: 40px;
  background: var(--bg-tertiary, #1e293b);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}
.tool-info { flex: 1; min-width: 0; }
.tool-name { font-size: 14px; font-weight: 600; }
.tool-desc { font-size: 12px; color: var(--text-secondary, #94a3b8); margin-top: 2px; }

/* Skill Tab */
.skill-list { display: flex; flex-direction: column; gap: 8px; }
.skill-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-secondary, #111827);
  border-radius: 12px;
  padding: 14px;
}
.skill-card.compact {
  padding: 10px 14px;
  background: transparent;
  border-bottom: 1px solid var(--border-subtle, rgba(255,255,255,0.06));
  border-radius: 0;
}
.skill-card.compact .skill-icon {
  width: 28px;
  height: 28px;
  font-size: 14px;
  background: transparent;
}
.skills-group-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary, #e2e8f0);
  padding: 8px 4px 6px;
}
.skill-category {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary, #94a3b8);
  padding: 8px 4px 4px;
  text-transform: capitalize;
}
.skill-icon {
  width: 36px;
  height: 36px;
  background: var(--bg-tertiary, #1e293b);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.skill-info { flex: 1; min-width: 0; }
.skill-name { font-size: 14px; font-weight: 600; }
.skill-desc { font-size: 12px; color: var(--text-secondary, #94a3b8); margin-top: 2px; }

/* Heartbeat Tab */
.heartbeat-desc {
  background: var(--bg-secondary, #111827);
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 13px;
  color: var(--text-secondary, #94a3b8);
  line-height: 1.7;
  margin-bottom: 16px;
}
.hb-section { margin-bottom: 24px; }
.hb-section-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
}
.interval-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.interval-pill {
  flex: 1;
  min-width: 60px;
  padding: 8px 0;
  text-align: center;
  font-size: 13px;
  font-weight: 500;
  border-radius: 20px;
  background: var(--bg-secondary, #111827);
  color: var(--text-secondary, #94a3b8);
  border: 1px solid var(--border, #1e293b);
  cursor: pointer;
  transition: all 0.2s;
}
.interval-pill.selected {
  background: var(--accent, #3b82f6);
  color: var(--bg-primary, #0b1120);
  border-color: var(--accent, #3b82f6);
  font-weight: 600;
}
.custom-interval {
  display: flex;
  align-items: center;
  gap: 8px;
}
.custom-interval label {
  font-size: 13px;
  color: var(--text-secondary, #94a3b8);
  white-space: nowrap;
}
.custom-interval input {
  width: 80px;
  padding: 8px 12px;
  background: var(--bg-secondary, #111827);
  border: 1px solid var(--border, #1e293b);
  border-radius: 8px;
  color: var(--text-primary, #f1f5f9);
  font-size: 14px;
  outline: none;
}
.custom-interval input:focus { border-color: var(--accent, #3b82f6); }
.custom-interval .suffix { font-size: 13px; color: var(--text-secondary, #94a3b8); }
.time-row { display: flex; gap: 12px; margin-bottom: 8px; }
.time-group { flex: 1; }
.time-label { font-size: 12px; color: var(--text-secondary, #94a3b8); margin-bottom: 6px; }
.time-input {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-secondary, #111827);
  border: 1px solid var(--border, #1e293b);
  border-radius: 8px;
  color: var(--text-primary, #f1f5f9);
  font-size: 15px;
  outline: none;
  -webkit-appearance: none;
}
.time-input:focus { border-color: var(--accent, #3b82f6); }
.time-note { font-size: 12px; color: var(--text-tertiary, #64748b); margin-top: 8px; }
.checklist-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-secondary, #111827);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 8px;
}
.checklist-text { flex: 1; font-size: 13px; }
.delete-btn {
  color: var(--text-tertiary, #64748b);
  font-size: 18px;
  cursor: pointer;
  min-width: 44px;
  min-height: 44px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  border: none;
  background: none;
}
.delete-btn:active { color: var(--danger); }
.add-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 12px;
  border: 1px dashed var(--border, #1e293b);
  border-radius: 10px;
  background: transparent;
  color: var(--accent, #3b82f6);
  font-size: 13px;
  cursor: pointer;
}
.hb-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  background: var(--bg-secondary, #111827);
  border-radius: 12px;
}
.hb-toggle-row span { font-size: 14px; font-weight: 500; }
.hb-actions { margin-top: 16px; }
.hb-actions .btn { width: 100%; }

/* Knowledge Tab */
.knowledge-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.knowledge-count { font-size: 14px; color: var(--text-secondary, #94a3b8); }
.knowledge-actions { display: flex; gap: 8px; }
.wiki-list { display: flex; flex-direction: column; gap: 4px; }
.wiki-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-secondary, #111827);
  border-radius: 10px;
  cursor: pointer;
}
.wiki-item:active { background: var(--bg-tertiary, #1e293b); }
.wiki-icon { font-size: 18px; flex-shrink: 0; }
.wiki-name { flex: 1; font-size: 14px; }
.wiki-detail-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.wiki-detail-title { flex: 1; font-size: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wiki-detail-btns { display: flex; gap: 6px; flex-shrink: 0; }
.wiki-detail-content {
  background: var(--bg-secondary, #111827);
  border-radius: 12px;
  padding: 16px;
  font-size: 14px;
  line-height: 1.7;
  max-height: 60vh;
  overflow-y: auto;
}
.empty-state {
  text-align: center;
  color: var(--text-tertiary, #64748b);
  padding: 32px 16px;
  font-size: 14px;
}

/* Memory Tab */
.memory-section { margin-bottom: 20px; }
.memory-header {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
}
.memory-content {
  background: var(--bg-secondary, #111827);
  border-radius: 12px;
  padding: 14px;
  font-size: 13px;
  line-height: 1.7;
  max-height: 200px;
  overflow-y: auto;
}
.text-muted { color: var(--text-tertiary, #64748b); }
.memory-actions { margin-top: 16px; text-align: center; }

/* --- Todos View --- */
.topbar-icon-btn:not([hidden]) {
  position: relative;
  background: none;
  border: none;
  color: var(--text-primary, #f1f5f9);
  cursor: pointer;
  padding: 4px;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.todo-badge {
  position: absolute;
  top: -2px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  line-height: 1;
}
.todo-badge:not([hidden]) {
  display: flex;
}

.fullscreen-view {
  position: fixed;
  inset: 0;
  background: var(--bg-primary, #0b1120);
  z-index: 800;
  display: none;
  flex-direction: column;
  opacity: 0;
  transform: translateY(8%);
  will-change: transform, opacity;
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1),
              opacity 0.2s ease-out;
}
.fullscreen-view.view-entering:not([hidden]),
.fullscreen-view.view-active:not([hidden]) {
  display: flex;
}
.fullscreen-view.view-active:not([hidden]) {
  opacity: 1;
  transform: translateY(0);
}
.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top));
  background: var(--bg-secondary, #111827);
  border-bottom: 1px solid var(--border, #1e293b);
  flex-shrink: 0;
}
.view-header h2 {
  font-size: 16px;
  font-weight: 600;
}
.btn-back {
  background: none;
  border: none;
  color: var(--accent, #3b82f6);
  font-size: 14px;
  cursor: pointer;
  padding: 4px;
  font-family: inherit;
}

.todo-filters {
  display: flex;
  gap: 0;
  padding: 0 16px;
  border-bottom: 1px solid var(--border, #1e293b);
  background: var(--bg-primary, #0b1120);
  flex-shrink: 0;
  overflow-x: auto;
}
.todo-filters .filter {
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary, #94a3b8);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.1s ease-out;
}
.todo-filters .filter:active {
  transform: scale(0.97);
}
.todo-filters .filter.active {
  color: var(--accent, #3b82f6);
  border-bottom-color: var(--accent, #3b82f6);
}

.todo-list-container {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  -webkit-overflow-scrolling: touch;
}

.todo-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 16px 0 10px;
  font-size: 15px;
  font-weight: 600;
}
.todo-section-header:first-child { margin-top: 4px; }
.todo-section-header.danger { color: var(--danger); }
.todo-section-header.warning { color: var(--warning); }
.todo-section-header.muted { color: var(--text-secondary, #94a3b8); }
.todo-count {
  font-size: 11px;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 999px;
  min-width: 22px;
  text-align: center;
}
.todo-section-header.danger .todo-count { background: rgba(255,71,87,0.15); color: var(--danger); }
.todo-section-header.warning .todo-count { background: rgba(251,191,36,0.15); color: var(--warning); }

.todo-card {
  background: var(--bg-secondary, #111827);
  border-radius: 12px;
  padding: 14px 14px 14px 18px;
  margin-bottom: 10px;
  position: relative;
  overflow: hidden;
}
.todo-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
}
.todo-card.stripe-red::before { background: var(--danger); }
.todo-card.stripe-yellow::before { background: var(--warning); }
.todo-card.stripe-green::before { background: var(--success); }
.todo-card.stripe-default::before { background: var(--border, #1e293b); }

.todo-card-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.cxo-tag {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
  flex-shrink: 0;
  background: var(--accent-soft);
  color: var(--accent, #3b82f6);
}
.todo-card-title {
  font-size: 14px;
  font-weight: 500;
  flex: 1;
}
.todo-card-desc {
  font-size: 12px;
  color: var(--text-secondary, #94a3b8);
  margin-bottom: 4px;
  line-height: 1.5;
}
.todo-card-time {
  font-size: 12px;
  color: var(--text-tertiary, #64748b);
  margin-top: 2px;
}
.todo-card.completed {
  opacity: 0.5;
}
.todo-card.completed .todo-card-title {
  text-decoration: line-through;
  color: var(--text-tertiary, #64748b);
}

.todo-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.btn-todo {
  font-size: 12px;
  font-weight: 500;
  padding: 5px 14px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
}
.btn-todo-primary {
  background: var(--accent, #3b82f6);
  color: #ffffff;
}
.btn-todo-secondary {
  background: var(--bg-tertiary, #1e293b);
  color: var(--text-secondary, #94a3b8);
}
.btn-todo-muted {
  background: transparent;
  color: var(--text-tertiary, #64748b);
  border: 1px solid var(--border, #1e293b);
}

/* --- Daily Report View --- */
.report-date-label {
  font-size: 12px;
  color: var(--text-secondary, #94a3b8);
  white-space: nowrap;
}

.report-date-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border, #1e293b);
  background: var(--bg-primary, #0b1120);
  flex-shrink: 0;
  position: relative;
}
.date-nav-btn {
  min-width: 44px;
  min-height: 44px;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  border: 1px solid var(--border, #1e293b);
  background: var(--bg-secondary, #111827);
  color: var(--text-primary, #f1f5f9);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.report-date-input {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary, #f1f5f9);
  background: var(--bg-tertiary, #1e293b);
  border: 1px solid var(--border-subtle, rgba(148,163,184,0.1));
  border-radius: 8px;
  padding: 6px 12px;
  text-align: center;
  -webkit-appearance: none;
  appearance: none;
  color-scheme: dark;
  min-width: 140px;
}
[data-theme="light"] .report-date-input {
  color-scheme: light;
}

.report-content-area {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  -webkit-overflow-scrolling: touch;
}

.report-date-badge {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
}
.report-date-badge span {
  background: var(--bg-tertiary, #1e293b);
  color: var(--text-secondary, #94a3b8);
  font-size: 12px;
  padding: 4px 14px;
  border-radius: 999px;
}

.report-section-header {
  font-size: 15px;
  font-weight: 600;
  margin: 20px 0 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.report-section-header:first-child { margin-top: 0; }
.report-section-header.danger { color: var(--danger); }
.report-section-header.accent { color: var(--accent, #3b82f6); }

.report-card {
  background: var(--bg-secondary, #111827);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
}
.report-card-body {
  font-size: 13px;
  color: var(--text-secondary, #94a3b8);
  line-height: 1.7;
}

.cxo-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.cxo-row:last-child { border-bottom: none; }
.cxo-emoji { font-size: 18px; flex-shrink: 0; width: 28px; text-align: center; padding-top: 1px; }
.cxo-name { font-size: 13px; font-weight: 600; white-space: nowrap; flex-shrink: 0; }
.cxo-status { font-size: 13px; color: var(--text-secondary, #94a3b8); }

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .skeleton { animation: none; background: var(--bg-tertiary); }
  .fullscreen-view { transition: none; }
}

/* Settings */
.settings-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  -webkit-overflow-scrolling: touch;
}
.settings-section {
  margin-bottom: 24px;
}
.settings-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}
.settings-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--border-subtle);
}
.settings-item-label {
  font-size: 15px;
  color: var(--text-primary);
}
.settings-item-desc {
  font-size: 13px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

/* --------------------------------------------------------------------------
   Login Screen
   -------------------------------------------------------------------------- */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
}

.login-screen[hidden] {
  display: none;
}

.login-card {
  width: 100%;
  max-width: 360px;
  padding: 40px 32px;
  text-align: center;
}

.login-logo {
  margin-bottom: 16px;
}

.login-title {
  font-size: 22px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 6px;
}

.login-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0 0 28px;
}

.login-input {
  width: 100%;
  padding: 12px 16px;
  font-size: 15px;
  color: var(--text-primary);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.15s;
}

.login-input:focus {
  border-color: var(--accent);
}

.login-error {
  margin-top: 12px;
  font-size: 13px;
  color: #ef4444;
}

.login-error[hidden] {
  display: none;
}

.login-btn {
  width: 100%;
  margin-top: 20px;
  padding: 12px;
  font-size: 15px;
  font-weight: 500;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: opacity 0.15s;
}

.login-btn:hover {
  opacity: 0.9;
}

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