/* Dinah AI — DeepSeek-inspired dark theme */

/* Use system fonts — no external font loading needed */

:root {
  --bg-canvas: #0f0f0f;
  --bg-sidebar: #1a1a1a;
  --bg-surface: #1e1e1e;
  --bg-surface-2: #252525;
  --bg-hover: #2a2a2a;
  --bg-active: #333333;
  --bg-input: #1a1a1a;
  --bg-user-bubble: #303030;

  --text-primary: #f0f0f0;
  --text-secondary: #a0a0a0;
  --text-muted: #666666;
  --text-placeholder: #555555;

  --accent: #4d6bfe;
  --accent-hover: #3d5bee;
  --accent-green: #4ade80;
  --accent-amber: #fbbf24;
  --accent-red: #ef4444;

  --border: rgba(255,255,255,0.08);
  --border-strong: rgba(255,255,255,0.12);
  --border-focus: rgba(77,107,254,0.5);

  --radius: 16px;
  --radius-sm: 8px;
  --radius-pill: 100px;

  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, 'Ubuntu', 'Noto Sans', sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--bg-canvas);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

#app {
  display: flex;
  height: 100vh;
}

/* ── Sidebar ──────────────────────────────────────────────── */

#sidebar {
  width: 260px;
  min-width: 260px;
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
}

.sidebar-header {
  padding: 20px 16px 8px;
}

.app-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  padding: 4px 0;
}

.logo-icon {
  width: 24px;
  height: 24px;
  color: var(--accent);
}

.btn-new-task {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 12px 12px 8px;
  padding: 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn-new-task:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}

.btn-new-task svg {
  width: 16px;
  height: 16px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 12px 8px;
  padding: 8px 12px;
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.search-box svg {
  width: 15px;
  height: 15px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.search-box input {
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 13px;
  font-family: var(--font);
  width: 100%;
}

.search-box input::placeholder {
  color: var(--text-placeholder);
}

/* Task list */
.task-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px;
}

.task-group-label {
  padding: 12px 8px 4px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.task-item {
  display: block;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.12s;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.task-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.task-item.active {
  background: var(--bg-active);
  color: var(--text-primary);
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 14px;
  text-decoration: none;
  transition: background 0.12s;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--bg-active);
  color: var(--text-primary);
}

.nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.7;
}

/* Credit display */
.credit-display {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
}

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

.credit-plan {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.credit-count {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.credit-bar {
  height: 4px;
  background: var(--bg-surface-2);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 8px;
}

.credit-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s ease;
  width: 0%;
}

.topup-link {
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
  line-height: 1.4;
  display: block;
}

.topup-link:hover {
  text-decoration: underline;
}

/* ── Main area ────────────────────────────────────────────── */

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-canvas);
}

.main-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-canvas);
}

.task-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  background: var(--bg-surface);
  border-radius: var(--radius-pill);
  font-size: 12px;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
}

.status-dot.online {
  background: var(--accent-green);
  box-shadow: 0 0 6px rgba(74,222,128,0.4);
}

.status-dot.offline {
  background: var(--accent-red);
}

/* Messages container — top-down flow, auto-scroll to bottom */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 24px 0;
  scroll-behavior: smooth;
  max-width: 820px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

/* Welcome message */
.welcome-message {
  display: flex;
  gap: 14px;
  margin-bottom: 24px;
  padding-top: 40px;
}

.ai-avatar {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}

.welcome-text p {
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1.6;
  margin-bottom: 8px;
}

/* User message — small right-aligned grey bubble */
.msg-user {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 24px;
}

.msg-user-bubble {
  max-width: 65%;
  padding: 12px 16px;
  background: var(--bg-user-bubble);
  border-radius: 18px 18px 4px 18px;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-primary);
}

/* AI message — full width, no bubble, no background */
.msg-ai {
  display: flex;
  gap: 14px;
  margin-bottom: 24px;
}

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

.msg-ai-text {
  font-size: 15px;
  line-height: 1.7;
  color: var(--text-primary);
  margin-bottom: 12px;
}
.msg-ai-text p { margin: 0 0 10px; }
.msg-ai-text p:last-child { margin-bottom: 0; }
.msg-ai-text h1, .msg-ai-text h2, .msg-ai-text h3, .msg-ai-text h4 {
  margin: 16px 0 8px;
  line-height: 1.3;
}
.msg-ai-text h1 { font-size: 20px; }
.msg-ai-text h2 { font-size: 17px; }
.msg-ai-text h3 { font-size: 15px; }
.msg-ai-text h4 { font-size: 14px; color: var(--text-secondary); }
.msg-ai-text ul, .msg-ai-text ol {
  margin: 6px 0 10px 20px;
  padding: 0;
}
.msg-ai-text li { margin-bottom: 4px; }
.msg-ai-text strong { font-weight: 600; }
.msg-ai-text em { font-style: italic; }

.msg-ai-text code {
  background: var(--bg-surface-2);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
  font-family: 'SF Mono', 'Fira Code', monospace;
}

/* Fenced code blocks */
.msg-ai-text pre.code-block {
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  margin: 10px 0;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.5;
}
.msg-ai-text pre.code-block code {
  background: none;
  padding: 0;
  border-radius: 0;
  font-size: 13px;
  color: var(--text-primary);
}

.msg-ai-cost {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* Action steps */
.action-steps {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
}

.step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
}

.step + .step {
  border-top: 1px solid var(--border);
}

.steps-collapsed {
  font-size: 12px;
  color: var(--text-muted);
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
}

.step-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.step-icon.done { color: var(--accent-green); }
.step-icon.running { color: var(--text-muted); animation: spin 1s linear infinite; }
.step-icon.pending { color: var(--text-muted); opacity: 0.4; }

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

.step-text {
  flex: 1;
  font-size: 14px;
  color: var(--text-primary);
}

.step-text.running { color: var(--text-secondary); }

.step-undo {
  font-size: 13px;
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 6px;
  font-family: var(--font);
}

.step-undo:hover { text-decoration: underline; }

/* File cards */
.file-cards {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.file-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  flex: 1;
  min-width: 220px;
  cursor: pointer;
  transition: border-color 0.15s;
}

.file-card:hover { border-color: var(--border-strong); }

.file-icon {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 800;
  color: white;
  flex-shrink: 0;
  letter-spacing: 0.5px;
}

.file-icon.xlsx { background: #217346; }
.file-icon.docx { background: #2b579a; }
.file-icon.pptx { background: #d24726; }
.file-icon.pdf { background: #b30b00; }
.file-icon.txt { background: #555; }

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

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

.file-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Permission card */
.permission-card {
  background: rgba(251, 191, 36, 0.06);
  border: 1px solid rgba(251, 191, 36, 0.2);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 12px;
}

.permission-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent-amber);
  margin-bottom: 8px;
}

.permission-title svg { width: 18px; height: 18px; }

.permission-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 14px;
}

.permission-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-allow {
  padding: 8px 20px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.15s;
}

.btn-allow:hover { background: var(--accent-hover); }

.btn-show {
  padding: 8px 18px;
  background: var(--bg-surface-2);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.15s;
}

.btn-show:hover { background: var(--bg-hover); }

.btn-dismiss {
  padding: 8px 12px;
  background: none;
  color: var(--text-muted);
  border: none;
  font-size: 13px;
  font-family: var(--font);
  cursor: pointer;
}

.btn-dismiss:hover { color: var(--text-secondary); }

/* ── Input area — DeepSeek composer style ────────────────── */

.input-area {
  padding: 0 24px 20px;
  max-width: 820px;
  width: 100%;
  margin: 0 auto;
}

.input-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px 6px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  transition: border-color 0.2s;
}

.input-row:focus-within {
  border-color: var(--border-focus);
}

.input-icon-btn {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 50%;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
}

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

.input-icon-btn svg {
  width: 18px;
  height: 18px;
}

#message-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 15px;
  font-family: var(--font);
  padding: 8px 4px;
}

#message-input::placeholder {
  color: var(--text-placeholder);
}

.btn-stop {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  color: var(--text-primary);
  font-size: 13px;
  font-family: var(--font);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
}

.btn-stop:hover:not(:disabled) { background: var(--bg-hover); }
.btn-stop:disabled { opacity: 0.3; cursor: default; }
.btn-stop svg { width: 14px; height: 14px; }

.model-selector {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 8px;
}
.model-selector select {
  background: var(--input-bg);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  cursor: pointer;
  outline: none;
}
.model-selector select:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}

/* Thinking indicator — shown while reasoning streams in */
.thinking-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 13px;
  padding: 4px 0;
  margin-bottom: 8px;
}
.thinking-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.7;
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 0.3; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1); }
}

/* Collapsed reasoning block — like Claude's "Thought for X seconds" */
.reasoning-block {
  border-radius: 6px;
  padding: 2px 0;
  margin-bottom: 10px;
  font-size: 13px;
}
.reasoning-block summary {
  cursor: pointer;
  color: var(--text-muted);
  font-weight: 400;
  font-size: 13px;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.reasoning-block summary::-webkit-details-marker { display: none; }
.reasoning-block summary::before {
  content: '▶';
  font-size: 9px;
  color: var(--text-muted);
  transition: transform 0.15s;
}
.reasoning-block[open] summary::before { transform: rotate(90deg); }
.reasoning-block summary:hover { color: var(--text-secondary); }
.reasoning-content {
  margin-top: 8px;
  padding: 10px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  max-height: 200px;
  overflow-y: auto;
}

.disclaimer {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 10px;
}

/* ── Scrollbar ────────────────────────────────────────────── */

::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ── Pages (non-chat) ─────────────────────────────────────── */

.page {
  flex: 1;
  display: none;
  flex-direction: column;
  min-width: 0;
}

.page.active { display: flex; }

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

.page-desc {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 20px;
}

.section-header {
  margin-top: 32px;
  margin-bottom: 16px;
}

.section-header h2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.empty-state {
  font-size: 13px;
  color: var(--text-muted);
  padding: 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

/* Skills grid */
.skills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
}

.skill-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  transition: border-color 0.15s;
}

.skill-card:hover { border-color: var(--border-strong); }

.skill-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.skill-card-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-right: 10px;
  background: var(--bg-surface-2);
  color: var(--text-secondary);
}

.skill-card-icon svg { width: 18px; height: 18px; }

.skill-card-title-row {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
}

.skill-name { font-size: 14px; font-weight: 600; color: var(--text-primary); }

.skill-rung {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: rgba(77,107,254,0.12);
  color: var(--accent);
  font-weight: 500;
}

/* Rung-specific badge colors */
.rung-badge { font-size: 11px; padding: 2px 8px; border-radius: var(--radius-pill); font-weight: 500; white-space: nowrap; }
.rung-badge.rung-1 { background: rgba(74,222,128,0.12); color: var(--accent-green); }
.rung-badge.rung-2 { background: rgba(77,107,254,0.12); color: var(--accent); }
.rung-badge.rung-3 { background: rgba(251,191,36,0.12); color: var(--accent-amber); }
.rung-badge.rung-4 { background: rgba(239,68,68,0.12); color: var(--accent-red); }

.skill-method {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-style: italic;
}

.skill-desc { font-size: 13px; color: var(--text-secondary); line-height: 1.4; margin-bottom: 10px; }

.skill-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-muted);
}

.skill-toggle {
  appearance: none;
  width: 36px;
  height: 20px;
  background: var(--bg-surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
}

.skill-toggle:checked { background: var(--accent); border-color: var(--accent); }

.skill-toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
}

.skill-toggle:checked::after { transform: translateX(16px); }


/* Folders list */
.folders-list { margin-bottom: 16px; }

.folder-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}

.folder-icon { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; color: var(--accent); }
.folder-icon svg { width: 20px; height: 20px; }
.folder-info { flex: 1; }
.folder-path { font-size: 13px; color: var(--text-primary); }
.folder-perms { font-size: 12px; color: var(--text-muted); }

.folder-remove {
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
}

.folder-remove:hover { color: var(--accent-red); }

/* ── Forms ────────────────────────────────────────────────── */

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

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

.form-group.inline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.form-group.inline label { margin-bottom: 0; flex: 1; }

.form-input,
.form-textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.2s;
}

.form-input:focus,
.form-textarea:focus { border-color: var(--accent); }

.form-input::placeholder,
.form-textarea::placeholder { color: var(--text-placeholder); }

.form-textarea { resize: vertical; min-height: 60px; }

.form-input-sm {
  padding: 7px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  font-family: var(--font);
  outline: none;
  min-width: 140px;
}

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

select.form-input,
select.form-input-sm { cursor: pointer; }

.form-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.4;
}

/* Buttons — DeepSeek style: dark fill, no accent fill on primary */
.btn-primary {
  padding: 10px 24px;
  background: var(--text-primary);
  color: var(--bg-canvas);
  border: none;
  border-radius: var(--radius-pill);
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn-primary:hover { opacity: 0.85; }

.btn-secondary {
  padding: 8px 18px;
  background: var(--bg-surface-2);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.15s;
}

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

.link-code-box {
  display: flex;
  align-items: center;
  gap: 12px;
}

.link-code {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 6px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  color: var(--accent);
}

.status-indicator {
  font-size: 13px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
}

.status-indicator.connected {
  background: rgba(74,222,128,0.1);
  color: var(--accent-green);
}

.status-indicator.disconnected {
  background: rgba(239,68,68,0.1);
  color: var(--accent-red);
}

/* ── Responsive ───────────────────────────────────────────── */

@media (max-width: 800px) {
  #sidebar { width: 56px; min-width: 56px; }
  .sidebar-header span,
  .btn-new-task span:last-child,
  .search-box,
  .task-list,
  .nav-item span:last-child,
  .credit-display { display: none; }
  .btn-new-task { padding: 10px; margin: 8px; }
  .nav-item { justify-content: center; padding: 10px; }
}

.btn-sm { font-size: 12px; padding: 4px 10px; }
.btn-danger { color: var(--accent-red) !important; }
.btn-danger:hover { background: rgba(239,68,68,0.1) !important; }

/* ── Toast ────────────────────────────────────────────────── */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--bg-surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  padding: 10px 24px;
  color: var(--text-primary);
  font-size: 14px;
  z-index: 1000;
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  pointer-events: none;
}

.toast.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ── Top-up dialog ────────────────────────────────────────── */

.topup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

.topup-modal {
  background: var(--bg-sidebar);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 24px;
  width: 440px;
  max-width: 90vw;
  max-height: 85vh;
  overflow-y: auto;
}

.topup-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.topup-header h2 { font-size: 18px; color: var(--text-primary); margin: 0; }

.topup-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
  padding: 0 4px;
}

.topup-close:hover { color: var(--text-primary); }
.topup-desc { font-size: 13px; color: var(--text-muted); margin: 0 0 16px; }

.topup-bundles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.topup-bundle {
  background: var(--bg-surface);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.2s;
}

.topup-bundle:hover { border-color: var(--accent); }
.topup-bundle.selected { border-color: var(--accent); background: rgba(77,107,254,0.08); }

.topup-bundle-name { font-size: 14px; font-weight: 600; color: var(--text-primary); margin-bottom: 4px; }
.topup-bundle-credits { font-size: 20px; font-weight: 700; color: var(--accent); margin-bottom: 2px; }
.topup-bundle-price { font-size: 16px; font-weight: 600; color: var(--accent-green); }
.topup-bundle-validity { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.topup-payment h3 { font-size: 14px; color: var(--text-primary); margin: 0 0 12px; }
.topup-hint { font-size: 13px; color: var(--text-muted); margin-top: 10px; }

/* ── Live stream panel ─────────────────────────────────────── */

.live-stream {
  margin: 0 24px 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-surface);
  overflow: hidden;
  animation: fadeIn 0.3s ease;
}

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

.live-stream-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(0,0,0,0.3);
  border-bottom: 1px solid var(--border);
}

.live-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-red);
  letter-spacing: 0.5px;
}

.live-dot {
  width: 8px;
  height: 8px;
  background: var(--accent-red);
  border-radius: 50%;
  animation: livePulse 1.5s infinite;
}

@keyframes livePulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(239,68,68,0.5); }
  50% { opacity: 0.7; box-shadow: 0 0 0 4px rgba(239,68,68,0); }
}

#live-stream-label {
  flex: 1;
  font-size: 12px;
  color: var(--text-secondary);
}

.live-stream-toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
}

.live-stream-content {
  display: flex;
  gap: 1px;
  max-height: 280px;
}

.live-stream-frame {
  flex: 1;
  max-width: 60%;
  object-fit: contain;
  background: #000;
  border-right: 1px solid var(--border);
}

.live-stream-log {
  flex: 1;
  max-width: 40%;
  padding: 8px 12px;
  overflow-y: auto;
  font-family: 'DM Sans', monospace;
  font-size: 11px;
  line-height: 1.6;
  color: var(--text-secondary);
  max-height: 280px;
}

.live-stream-log .log-entry {
  padding: 2px 0;
  border-bottom: 1px solid var(--border);
}

.live-stream-log .log-entry.tool {
  color: var(--accent);
}

.live-stream-log .log-entry.result {
  color: var(--accent-green);
}

.live-stream-log .log-entry.error {
  color: var(--accent-red);
}

.live-stream.minimized .live-stream-content {
  display: none;
}

/* Safety confirmation dialog */
/* Recording pulse animation on mic button */
.input-icon-btn.recording {
  color: var(--accent-red) !important;
  animation: mic-pulse 1s ease-in-out infinite;
}

@keyframes mic-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(1.15); }
}

.safety-dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  backdrop-filter: blur(4px);
}

.safety-dialog {
  background: var(--bg-surface);
  border: 1px solid #ff6b35;
  border-radius: 12px;
  padding: 24px;
  max-width: 480px;
  width: 90%;
  text-align: center;
}

.safety-dialog-icon {
  font-size: 36px;
  margin-bottom: 8px;
}

.safety-dialog h3 {
  color: #ff6b35;
  font-size: 18px;
  margin: 0 0 12px;
}

.safety-reason {
  color: var(--text-secondary);
  font-size: 14px;
  margin: 0 0 12px;
}

.safety-command {
  background: var(--bg-canvas);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  font-family: monospace;
  font-size: 13px;
  color: #ff6b35;
  white-space: pre-wrap;
  word-break: break-all;
  text-align: left;
  margin: 0 0 16px;
}

.safety-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.safety-btn-deny {
  background: var(--bg-hover);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 24px;
  cursor: pointer;
  font-size: 14px;
}

.safety-btn-deny:hover {
  background: var(--bg-active);
}

.safety-btn-allow {
  background: #ff6b35;
  color: white;
  border: none;
  border-radius: 8px;
  padding: 8px 24px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
}

.safety-btn-allow:hover {
  background: #e55a25;
}

/* ── Audit log ───────────────────────────────────────────────── */

.audit-log {
  max-height: 400px;
  overflow-y: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 0;
}

.audit-log:empty::after {
  content: 'No activity logged yet.';
  display: block;
  padding: 16px;
  font-size: 13px;
  color: var(--text-muted);
}

.audit-entry {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.audit-entry:last-child {
  border-bottom: none;
}

.audit-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  border-radius: 4px;
  color: white;
  font-weight: 700;
}

.audit-icon.shell { background: var(--accent); }
.audit-icon.write { background: var(--accent-green); }
.audit-icon.edit { background: var(--accent-amber); color: #000; }
.audit-icon.undo { background: var(--text-muted); }
.audit-icon.read { background: #666; }

.audit-text {
  flex: 1;
  min-width: 0;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.audit-time {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
  white-space: nowrap;
}

.audit-cost {
  font-size: 11px;
  color: var(--accent);
  flex-shrink: 0;
}

/* Undo button in steps (enhanced) */
.step-undo.undone {
  color: var(--accent-green);
  cursor: default;
}
