:root {
  --bg: var(--tg-theme-bg-color, #1a1a2e);
  --text: var(--tg-theme-text-color, #e0e0e0);
  --hint: var(--tg-theme-hint-color, #8a8a9a);
  --link: var(--tg-theme-link-color, #6c9bff);
  --button: var(--tg-theme-button-color, #5b6eae);
  --button-text: var(--tg-theme-button-text-color, #ffffff);
  --secondary-bg: var(--tg-theme-secondary-bg-color, #252540);
  --section-header: var(--tg-theme-section-header-text-color, #8a8aaa);
  --destructive: var(--tg-theme-destructive-text-color, #ff5555);
  --border: rgba(255, 255, 255, 0.08);
  --success: #4caf50;
  --warning: #ff9800;
  --radius: 12px;
  --radius-sm: 8px;
  --font-mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { overscroll-behavior-y: contain; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  overscroll-behavior-y: contain;
  -webkit-font-smoothing: antialiased;
}

/* ── Pull-to-refresh ──────────────────── */

.ptr-indicator {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%) translateY(-50px);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--secondary-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  transition: transform 0.25s ease, opacity 0.25s ease;
  opacity: 0;
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}
.ptr-indicator.pulling {
  opacity: 1;
}
.ptr-indicator.refreshing {
  opacity: 1;
  transform: translateX(-50%) translateY(16px);
}
.ptr-spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid var(--hint);
  border-top-color: var(--link);
  border-radius: 50%;
}
.ptr-indicator.pulling .ptr-spinner {
  animation: none;
}
.ptr-indicator.refreshing .ptr-spinner {
  animation: ptr-spin 0.7s linear infinite;
}
@keyframes ptr-spin {
  to { transform: rotate(360deg); }
}

/* ── Connection bar ────────────────────── */

.conn-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 100;
  transition: background 0.3s, opacity 0.5s;
  opacity: 0;
}
.conn-bar.connected { background: var(--success); opacity: 1; }
.conn-bar.connecting { background: var(--warning); opacity: 1; }
.conn-bar.disconnected { background: var(--destructive); opacity: 1; }

/* ── Header ────────────────────────────── */

.header {
  padding: calc(16px + env(safe-area-inset-top, 0px)) 16px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.header h1 { font-size: 18px; font-weight: 600; }
.header .badge {
  background: var(--success);
  color: white;
  font-size: 11px;
  font-weight: 600;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  animation: pulse 1.5s infinite;
}

/* ── Projects bar ──────────────────────── */

.projects-bar {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  overflow-x: auto;
  scrollbar-width: none;
}
.projects-bar::-webkit-scrollbar { display: none; }

/* ── Tab bar ─────────────────────────────────────── */
.tab-bar {
  display: flex;
  gap: 0;
  padding: 0 16px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.tab {
  flex: 1;
  padding: 10px 0;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--hint);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.tab:hover { color: var(--text); }
.tab.active {
  color: var(--link);
  border-bottom-color: var(--link);
}
.tab .badge {
  font-size: 11px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
}
.tab-content { min-height: 100px; }

/* ── Date group headers ──────────────────────────── */
.history-date-group { margin-bottom: 4px; }
.date-header {
  padding: 8px 16px 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--hint);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 1;
}

.project-chip {
  flex-shrink: 0;
  padding: 6px 14px;
  border-radius: 20px;
  background: var(--secondary-bg);
  color: var(--hint);
  font-size: 13px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
}
.project-chip:hover, .project-chip.active {
  background: var(--button);
  color: var(--button-text);
  border-color: var(--button);
}
.project-chip.chip-projects {
  color: var(--link);
  border: 1px solid rgba(108,155,255,0.3);
}

/* ── Agent cards ───────────────────────── */

.agents-list {
  padding: 0 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.agent-card {
  background: var(--secondary-bg);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.25s ease, border-color 0.25s ease;
  border: 1px solid rgba(255,255,255,0.04);
}
.agent-card:hover {
  transform: scale(1.015);
  box-shadow: 0 4px 16px rgba(0,0,0,0.2), 0 0 0 1px rgba(255,255,255,0.06);
}
.agent-card:active { transform: scale(0.98); }
.agent-card .top-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
}
.agent-card .agent-id { font-weight: 600; font-size: 11px; font-family: 'SF Mono', 'Menlo', monospace; letter-spacing: 0.3px; }
.agent-card .agent-project {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(108,155,255,0.15);
  color: var(--link);
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.3px;
}
.agent-card .agent-time { font-size: 11px; color: var(--hint); margin-left: auto; }
.agent-card .agent-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-top: 2px;
}
.agent-card .agent-meta {
  font-size: 10px;
  color: var(--hint);
  margin-left: auto;
  white-space: nowrap;
}
.agent-card .agent-task {
  font-size: 12px;
  color: var(--hint);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
/* ── Complex task progress ── */
.agent-badge-cx { font-size: 12px; margin-left: 2px; }
.cx-bar { margin: 6px 0 2px; }
.cx-track {
  height: 4px;
  background: var(--separator);
  border-radius: 2px;
  overflow: hidden;
}
.cx-fill {
  height: 100%;
  background: var(--success);
  border-radius: 2px;
  transition: width 0.3s ease;
}
.cx-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
  font-size: 11px;
}
.cx-step { opacity: 0.5; }
.cx-step.cx-done { opacity: 1; }
.cx-step.cx-running { opacity: 1; animation: pulse 1.5s infinite; }
.cx-step.cx-failed { opacity: 1; }
.cx-step-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 8px;
  background: rgba(108,155,255,0.08);
  opacity: 0.5;
  white-space: nowrap;
}
.cx-step-pill.cx-done { opacity: 1; background: rgba(52,211,153,0.12); }
.cx-step-pill.cx-running { opacity: 1; background: rgba(108,155,255,0.15); animation: pulse 1.5s infinite; }
.cx-step-pill.cx-failed { opacity: 1; background: rgba(239,68,68,0.12); }
.cx-step-pill-label { max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Complex task child agents list in card */
.cx-children-spoiler { margin: 6px 0 2px; }
.cx-children-summary {
  font-size: 11px;
  color: var(--hint);
  cursor: pointer;
  padding: 2px 0;
  user-select: none;
}
.cx-children-summary:hover { color: var(--text); }
.cx-child-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  font-size: 12px;
  border-top: 1px solid var(--separator);
  cursor: pointer;
}
.cx-child-row:hover { background: rgba(108,155,255,0.08); border-radius: 6px; }
.cx-child-icon { flex-shrink: 0; font-size: 11px; }
.cx-child-id {
  flex-shrink: 0;
  font-family: 'SF Mono', 'Menlo', monospace;
  font-size: 11px;
  color: var(--link);
  opacity: 0.8;
}
.cx-child-task {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}
.cx-child-meta {
  flex-shrink: 0;
  font-size: 10px;
  color: var(--hint);
}

/* Complex task step navigator in chat */
.cx-nav {
  background: var(--card);
  border: 1px solid var(--separator);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.cx-nav .cx-step-block { margin: 0; }
.cx-nav-header {
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 8px;
}
.cx-nav-step {
  padding: 4px 0;
  font-size: 13px;
  border-bottom: 1px solid var(--separator);
}
.cx-nav-step:last-child { border-bottom: none; }
.cx-nav-step.cx-nav-running { color: var(--accent); }
.cx-nav-step.cx-nav-done { opacity: 0.7; }
.cx-nav-step.cx-nav-failed { color: var(--destructive); }
.cx-child-link {
  font-size: 11px;
  color: var(--accent);
  text-decoration: none;
  margin-left: 4px;
}

/* Research phase badge */
.cx-research { font-size: 12px; color: var(--text-secondary, var(--text-2, #888)); padding: 4px 0; }
.cx-research-done { color: var(--accent); }

/* Structured plan: files & verify in step nav */
.cx-files { font-size: 11px; color: var(--text-secondary, var(--text-2, #888)); margin-top: 2px; }
.cx-files code { background: var(--bg-secondary, var(--bg-2, #2a2a2a)); padding: 1px 4px; border-radius: 3px; font-size: 10px; }
.cx-verify { font-size: 11px; color: var(--text-secondary, var(--text-2, #888)); margin-top: 2px; font-style: italic; }
.cx-verify::before { content: '\2713 '; }

/* Context usage bar */
.ctx-bar { height: 2px; background: var(--bg-secondary, var(--bg-2, #2a2a2a)); border-radius: 1px; margin: 4px 0 2px; }
.ctx-fill { height: 100%; border-radius: 1px; transition: width 0.3s ease; }
.cx-child-link:hover { text-decoration: underline; }

/* Preset role tag in step navigator */
.cx-preset-tag {
  display: inline-block;
  font-size: 11px;
  background: rgba(108,155,255,0.12);
  color: var(--accent);
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 500;
  margin-right: 2px;
}

/* Step separator in complex task chat — full agent role block */
.cx-step-sep {
  padding: 8px 20px;
  font-size: 12px;
  color: var(--accent);
  border-top: 1px solid rgba(108,155,255,0.15);
  margin-top: 8px;
  letter-spacing: 0.02em;
}
.cx-step-block {
  margin: 12px 0 4px;
  border: 1px solid rgba(108,155,255,0.2);
  border-radius: 12px;
  overflow: hidden;
  background: var(--card, #1a1a2e);
}
.cx-step-block.cx-step-running {
  border-color: var(--accent);
  box-shadow: 0 0 12px rgba(108,155,255,0.1);
}
.cx-step-block.cx-step-done {
  border-color: var(--success, #34d399);
}
.cx-step-block.cx-step-failed {
  border-color: var(--destructive, #ef4444);
}
.cx-step-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: rgba(108,155,255,0.06);
  border-bottom: 1px solid rgba(108,155,255,0.1);
}
.cx-step-icon {
  font-size: 22px;
  flex-shrink: 0;
  line-height: 1;
}
.cx-step-info {
  flex: 1;
  min-width: 0;
}
.cx-step-role {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
}
.cx-step-role-tag {
  font-size: 11px;
  font-weight: 500;
  background: rgba(108,155,255,0.15);
  color: var(--accent);
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
}
.cx-step-title {
  font-size: 12px;
  color: var(--hint, #888);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cx-step-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  flex-shrink: 0;
  max-width: 90px;
}
.cx-step-status {
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 10px;
}
.cx-step-status.running {
  background: rgba(108,155,255,0.15);
  color: var(--accent);
  animation: pulse 1.5s infinite;
}
.cx-step-status.done {
  background: rgba(52,211,153,0.15);
  color: var(--success, #34d399);
}
.cx-step-status.failed {
  background: rgba(239,68,68,0.15);
  color: var(--destructive, #ef4444);
}
.cx-step-meta {
  font-size: 11px;
  color: #aaa;
}
.cx-step-body {
  padding: 8px 14px 10px;
  font-size: 12px;
  color: var(--hint, #888);
  display: flex;
  align-items: center;
  gap: 8px;
}
.cx-step-child-link {
  color: var(--accent);
  text-decoration: none;
  font-family: 'SF Mono', 'Menlo', monospace;
  font-size: 11px;
}
.cx-step-child-link:hover { text-decoration: underline; }
.cx-step-summary {
  padding: 6px 14px 10px;
  font-size: 12px;
  color: var(--text);
  border-top: 1px solid rgba(108,155,255,0.08);
  line-height: 1.5;
}
.cx-step-summary-label {
  font-size: 11px;
  color: var(--hint, #888);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}
.cx-step-body code {
  background: rgba(108,155,255,0.1);
  color: var(--accent, #6c9bff);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 11px;
}
@media (prefers-reduced-motion: reduce) {
  .cx-step-status.running,
  .cx-step-pill.cx-running {
    animation: none;
  }
}
.cx-parent-link {
  font-size: 13px;
  padding: 6px 0;
}

/* ── Orchestrator Decision Block ── */
.orch-decision {
  margin: 8px 0;
  border: 1px solid rgba(108,155,255,0.25);
  border-radius: 10px;
  padding: 10px 14px;
  background: rgba(108,155,255,0.06);
  font-size: 12px;
  line-height: 1.7;
  color: var(--text);
}
.orch-decision .orch-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 4px;
}
.orch-decision b { color: var(--hint, #aaa); font-weight: 500; }

/* ── Pipeline Timeline (dashboard card) ── */
.cx-timeline {
  margin: 6px 0 2px;
  font-size: 11px;
  color: var(--hint, #888);
}
.cx-timeline-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0;
}
.cx-timeline-icon { width: 16px; text-align: center; flex-shrink: 0; }
.cx-timeline-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cx-timeline-meta { flex-shrink: 0; color: #aaa; font-family: 'SF Mono', 'Menlo', monospace; font-size: 10px; }
.cx-timeline-row.active .cx-timeline-label { color: var(--accent); font-weight: 500; }
.cx-timeline-row.done .cx-timeline-icon { color: var(--success, #34d399); }
.cx-timeline-row.failed .cx-timeline-icon { color: var(--destructive, #ef4444); }

/* ── Resume Warning ── */
.resume-warning {
  margin: 8px 0;
  padding: 10px 14px;
  border: 1px solid rgba(250,204,21,0.3);
  border-radius: 10px;
  background: rgba(250,204,21,0.08);
  font-size: 12px;
  color: var(--text);
  line-height: 1.5;
}
.resume-warning-title {
  font-weight: 600;
  color: var(--warning, #facc15);
  margin-bottom: 4px;
}
.resume-warning .btn-rerun {
  display: inline-block;
  margin-top: 6px;
  padding: 4px 12px;
  font-size: 11px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  color: var(--accent);
  background: transparent;
  cursor: pointer;
}
.resume-warning .btn-rerun:hover { background: rgba(108,155,255,0.1); }

/* ── Files Touched per Step ── */
.cx-step-files {
  padding: 6px 14px 8px;
  font-size: 11px;
  border-top: 1px solid rgba(108,155,255,0.08);
}
.cx-step-file-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 1px 0;
  color: var(--hint, #888);
}
.cx-step-file-row .file-action {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 4px;
  font-weight: 500;
}
.cx-step-file-row .file-action.created {
  background: rgba(52,211,153,0.15);
  color: var(--success, #34d399);
}
.cx-step-file-row .file-action.modified {
  background: rgba(108,155,255,0.15);
  color: var(--accent);
}
.cx-step-file-row .file-path {
  font-family: 'SF Mono', 'Menlo', monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Sub-agent Groups ── */
.subagent-group {
  margin: 4px 0 4px 12px;
  border-left: 2px solid rgba(108,155,255,0.2);
  padding-left: 10px;
}
.subagent-group-header {
  font-size: 11px;
  color: var(--accent);
  font-weight: 500;
  padding: 4px 0;
  cursor: pointer;
  user-select: none;
}
.subagent-group-header::before {
  content: '▶';
  display: inline-block;
  font-size: 9px;
  margin-right: 4px;
  transition: transform 0.15s;
}
.subagent-group.expanded .subagent-group-header::before {
  transform: rotate(90deg);
}
.subagent-group-body {
  display: none;
}
.subagent-group.expanded .subagent-group-body {
  display: block;
}
.subagent-group-footer {
  font-size: 10px;
  color: var(--hint, #888);
  padding: 2px 0 4px;
}

/* ── Status SVG icons ── */
.si {
  display: inline-block;
  width: 16px; height: 16px;
  vertical-align: -2px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  margin-right: 4px;
  flex-shrink: 0;
}
.si-pulse { animation: pulse 1.5s infinite; }
.agent-id .si, .hi-status .si, .dl-item-top .si { color: var(--hint); }
.agent-card.agent-running .si { color: var(--success); }
.agent-card.agent-paused .si { color: var(--warning); }
.agent-card.agent-error .si { color: var(--destructive); }
.agent-card.agent-draft .si { color: var(--link); }
.status-tag-completed .si, .status-tag-stopped .si { color: var(--warning); }
.status-tag-failed .si { color: var(--destructive); }
.s-done .si { color: var(--success); }
.s-cancelled .si { color: var(--hint); }
.s-deferred .si { color: var(--warning); }

/* ── Drafts spoiler ── */
.drafts-spoiler {
  margin-bottom: 4px;
}
.drafts-summary {
  display: flex; align-items: center; gap: 5px;
  padding: 6px 12px;
  font-size: 12px; font-weight: 600;
  color: var(--link);
  cursor: pointer;
  user-select: none;
  list-style: none;
}
.drafts-summary::-webkit-details-marker { display: none; }
.drafts-summary::before {
  content: '▸'; font-size: 12px; transition: transform .2s;
}
details.drafts-spoiler[open] > .drafts-summary::before {
  transform: rotate(90deg);
}
.drafts-badge {
  background: rgba(108,155,255,0.15); color: var(--link);
  font-size: 11px; padding: 1px 7px; border-radius: 10px; font-weight: 600;
}

/* ── Section headers (Active tab) ── */
.active-section-header {
  display: flex; align-items: center; gap: 5px;
  padding: 8px 12px 3px;
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--hint);
  border-top: 1px solid rgba(255,255,255,0.06);
  margin-top: 2px;
}
.active-section-header .si { width: 14px; height: 14px; margin-right: 0; }
.sh-paused { color: var(--warning); }
.sh-paused .si { color: var(--warning); }
.sh-error { color: var(--destructive); }
.sh-error .si { color: var(--destructive); }
.sh-badge-paused {
  background: rgba(255,152,0,0.15); color: var(--warning);
  font-size: 11px; padding: 1px 7px; border-radius: 10px; font-weight: 600;
}
.sh-badge-error {
  background: rgba(244,67,54,0.15); color: var(--destructive);
  font-size: 11px; padding: 1px 7px; border-radius: 10px; font-weight: 600;
}
.sh-interrupted { color: #ff9800; }
.sh-interrupted .si { color: #ff9800; }
.sh-badge-interrupted {
  background: rgba(255,152,0,0.2); color: #ff9800;
  font-size: 11px; padding: 1px 7px; border-radius: 10px; font-weight: 600;
}

/* ── Agent card variants ── */
.agent-card.agent-draft {
  border-left: 3px solid var(--link);
  opacity: 0.85;
}
.agent-card.agent-paused {
  border-color: rgba(255,152,0,0.2);
  background: rgba(255,152,0,0.03);
  opacity: 0.8;
}
.agent-card.agent-paused:hover {
  opacity: 1;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2), 0 0 8px rgba(255,152,0,0.08);
}
.agent-card.agent-interrupted {
  border-color: rgba(255,152,0,0.35);
  background: rgba(255,152,0,0.06);
  border-left: 3px solid #ff9800;
}
.agent-card.agent-interrupted:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.2), 0 0 8px rgba(255,152,0,0.12);
}
.agent-bottom-interrupted {
  display: flex; align-items: center; gap: 8px;
}
.agent-bottom-interrupted .qa-resume {
  background: rgba(255,152,0,0.15); color: #ff9800; border: 1px solid rgba(255,152,0,0.3);
  font-weight: 600;
}
.agent-bottom-interrupted .qa-resume:hover { background: rgba(255,152,0,0.25); }
.agent-bottom-interrupted .qa-dismiss {
  background: transparent; color: var(--hint); border: 1px solid rgba(255,255,255,0.1);
  padding: 4px 8px; min-width: auto;
}
.agent-bottom-interrupted .qa-dismiss:hover { color: var(--destructive); border-color: rgba(244,67,54,0.3); }
.agent-card.agent-error {
  border-color: rgba(244,67,54,0.2);
  background: rgba(244,67,54,0.03);
  opacity: 0.8;
}
.agent-card.agent-error:hover {
  opacity: 1;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2), 0 0 8px rgba(244,67,54,0.08);
}
.agent-card.agent-running:hover {
  box-shadow: 0 4px 20px rgba(0,0,0,0.2), 0 0 12px rgba(76,175,80,0.15);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ── Section title + filter ────────────── */

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 4px;
}
.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--section-header);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.filter-chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.filter-chips::-webkit-scrollbar { display: none; }
.filter-chip {
  padding: 3px 10px;
  border-radius: 12px;
  background: transparent;
  color: var(--hint);
  font-size: 12px;
  border: 1px solid rgba(255,255,255,0.1);
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
  white-space: nowrap;
}
.filter-chip.active {
  background: var(--button);
  color: var(--button-text);
  border-color: var(--button);
}

/* ── Search bar ────────────────────────── */

.search-bar {
  padding: 4px 16px 8px;
}
.search-bar input {
  width: 100%;
  padding: 8px 12px;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.08);
  background: var(--secondary-bg);
  color: var(--text);
  font-size: 13px;
  outline: none;
}
.search-bar input::placeholder { color: var(--hint); }
.search-bar input:focus { border-color: rgba(255,255,255,0.15); }

/* ── History list ──────────────────────── */

.history-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  cursor: pointer;
}
.history-item:active { background: rgba(255,255,255,0.03); }
.history-item .hi-status { flex-shrink: 0; display: flex; align-items: center; }
.history-item .hi-status .si { width: 18px; height: 18px; margin-right: 0; }
.history-item[data-status="done"] .hi-status { color: var(--success); }
.history-item[data-status="cancelled"] .hi-status { color: var(--hint); }
.history-item[data-status="deferred"] .hi-status { color: var(--warning); }
.history-item .hi-body { flex: 1; min-width: 0; }
.history-item .hi-project { font-size: 11px; color: var(--link); }
.history-item .hi-task {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-item .hi-meta {
  font-size: 11px;
  color: var(--hint);
  flex-shrink: 0;
  text-align: right;
}

.load-more {
  text-align: center;
  padding: 12px;
  color: var(--link);
  font-size: 13px;
  cursor: pointer;
}

/* ── Queue items ──────────────────────── */

#queue-list {
  padding: 0 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.queue-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--secondary-bg);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 152, 0, 0.15);
}
.queue-item .qi-pos {
  font-size: 12px;
  font-weight: 600;
  color: var(--warning);
  flex-shrink: 0;
  width: 20px;
  text-align: center;
}
.queue-item .qi-body { flex: 1; min-width: 0; }
.queue-item .qi-project { font-size: 11px; color: var(--link); }
.queue-item .qi-task {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.queue-item .qi-cancel {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 85, 85, 0.12);
  color: var(--destructive);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.queue-item .qi-cancel:active { background: rgba(255, 85, 85, 0.25); }

.queue-badge {
  background: var(--warning) !important;
  font-size: 11px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
}

/* ── FAB ───────────────────────────────── */

.fab {
  position: fixed;
  bottom: calc(60px + env(safe-area-inset-bottom, 0px));
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--button);
  color: var(--button-text);
  font-size: 28px;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  z-index: 50;
  transition: transform 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.fab:active { transform: scale(0.9); }

/* ── Chat header ───────────────────────── */

.chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  position: relative;
}
.chat-header-info { flex: 1; min-width: 0; }
.chat-title { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-meta { font-size: 12px; color: var(--hint); }
.chat-agent-id { font-size: 12px; font-weight: 400; color: var(--hint); margin-left: 4px; }

.btn-icon {
  background: none;
  border: none;
  color: var(--link);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
}
.btn-icon:active { background: rgba(255,255,255,0.05); }

/* ── Chat dropdown menu ────────────────── */

.chat-menu-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  right: 16px;
  background: var(--secondary-bg);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-sm);
  z-index: 60;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  overflow: hidden;
}
.chat-menu-dropdown.open { display: block; }
.chat-menu-dropdown button {
  display: block;
  width: 100%;
  padding: 10px 16px;
  background: none;
  border: none;
  color: var(--text);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}
.chat-menu-dropdown button:hover { background: rgba(255,255,255,0.05); }

/* ── Chat messages ─────────────────────── */

#screen-chat {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow-x: hidden;
  max-width: 100vw;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0;
  /* scroll-behavior: smooth removed — causes visible scroll on chat open.
     Smooth scrolling is applied via JS only for incremental new messages. */
}

/* Base event */
.chat-messages .msg {
  padding: 4px 20px;
  animation: fadeIn 0.15s ease;
  word-break: break-word;
  overflow-wrap: break-word;
  user-select: text;
  -webkit-user-select: text;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}
.chat-messages .msg-step-block {
  padding: 2px 12px;
  background: none;
}

/* User message - right bubble */
.chat-messages .msg-user {
  padding: 10px 20px;
  margin: 8px 16px 8px 60px;
  background: rgba(108, 155, 255, 0.15);
  color: var(--text);
  border: 1px solid rgba(108, 155, 255, 0.2);
  border-radius: 18px 18px 4px 18px;
  font-size: 14px;
  line-height: 1.5;
  overflow-wrap: break-word;
  word-break: break-word;
}

/* Agent text */
.chat-messages .msg-text {
  padding: 10px 20px;
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-wrap;
}
/* Visual gap between different block types */
.chat-messages .msg-text + .msg-tool_use,
.chat-messages .msg-tool_result + .msg-text,
.chat-messages .msg-thinking + .msg-text {
  margin-top: 8px;
}

/* Tool use/result */
.chat-messages .msg-tool_use {
  padding: 6px 20px;
  font-size: 12px;
  color: var(--hint);
  border-left: 2px solid rgba(108,155,255,0.3);
  margin-left: 16px;
  margin-top: 2px;
  margin-bottom: 2px;
  overflow-wrap: break-word;
  word-break: break-word;
}
.chat-messages .msg-tool_result {
  padding: 4px 20px 8px;
  font-size: 12px;
  color: var(--hint);
  border-left: 2px solid rgba(76,175,80,0.3);
  margin-left: 16px;
  margin-bottom: 4px;
  overflow-wrap: break-word;
  word-break: break-word;
}

/* Thinking */
.chat-messages .msg-thinking {
  padding: 4px 20px;
  font-size: 11px;
  color: var(--hint);
  opacity: 0.5;
  font-style: italic;
  border-left: 2px solid rgba(255,255,255,0.08);
  margin-left: 16px;
}

/* Links in messages */
.chat-messages a {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.chat-messages a:hover { opacity: 0.8; }
.chat-messages .file-ref {
  color: var(--link);
  font-family: var(--font-mono);
  font-size: 0.9em;
  opacity: 0.85;
}

/* Status divider — thin line + pill label + thin line */
.chat-messages .msg-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  margin: 0;
  background: none;
  --_c: var(--hint);
}
.chat-messages .msg-status::before,
.chat-messages .msg-status::after {
  content: '';
  flex: 1;
  height: 1px;
  opacity: 0.15;
}
.chat-messages .msg-status::before { background: linear-gradient(90deg, transparent, var(--_c)); }
.chat-messages .msg-status::after  { background: linear-gradient(90deg, var(--_c), transparent); }
.chat-messages .msg-status .status-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--_c);
  opacity: 0.55;
  white-space: nowrap;
  padding: 2px 8px;
  border-radius: 20px;
  border: 1px solid color-mix(in srgb, var(--_c) 25%, transparent);
}
.chat-messages .status-running .status-label {
  opacity: 1;
  animation: status-pulse 2s ease-in-out infinite;
}
@keyframes status-pulse {
  0%, 100% { opacity: 0.6; }
  50%       { opacity: 1; }
}
.chat-messages .status-running   { --_c: var(--link); }
.chat-messages .status-completed { --_c: var(--warning); }
.chat-messages .status-done      { --_c: var(--success); }
.chat-messages .status-failed    { --_c: var(--destructive); }
.chat-messages .status-stopped   { --_c: var(--warning); }

/* Inline code */
.chat-messages .msg code {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 2px 6px;
  background: rgba(0,0,0,0.25);
  border-radius: 4px;
  color: var(--text);
  word-break: break-all;
}

/* Pre blocks (fenced code) */
.chat-messages .msg pre {
  display: block;
  white-space: pre-wrap;
  word-break: break-all;
  overflow-wrap: break-word;
  font-family: var(--font-mono);
  font-size: 12px;
  margin-top: 8px;
  margin-bottom: 8px;
  padding: 10px 14px;
  background: rgba(0,0,0,0.3);
  border-radius: 8px;
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.06);
  max-width: 100%;
  overflow-x: auto;
  line-height: 1.5;
}

/* Code inside pre inherits pre styling */
.chat-messages .msg pre code {
  display: block;
  padding: 0;
  background: none;
  border-radius: 0;
  border: none;
  font-size: inherit;
  white-space: pre-wrap;
}

/* Code inside tool messages is block-level */
.chat-messages .msg-tool_use code,
.chat-messages .msg-tool_result code {
  display: block;
  padding: 6px 10px;
  margin-top: 4px;
  background: rgba(0,0,0,0.2);
  border-radius: 6px;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-messages .msg b { font-weight: 600; }
.chat-messages .msg i { font-style: italic; }

.chat-messages .msg table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0;
  font-size: 13px;
}
.chat-messages .msg th,
.chat-messages .msg td {
  padding: 6px 10px;
  border: 1px solid rgba(255,255,255,0.1);
  text-align: left;
}
.chat-messages .msg th {
  background: rgba(255,255,255,0.05);
  font-weight: 600;
}

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

/* ── Quick actions ─────────────────────── */

.quick-actions {
  display: flex;
  gap: 8px;
  padding: 8px 16px;
  overflow-x: auto;
  scrollbar-width: none;
}
.quick-actions::-webkit-scrollbar { display: none; }

/* ── Primary action button (filled, prominent) ── */
.qa-primary {
  flex-shrink: 0;
  padding: 8px 20px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  color: #fff;
  border: none;
  cursor: pointer;
  transition: filter 0.15s, box-shadow 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.qa-primary:active { transform: scale(0.96); }
.qa-primary:hover { filter: brightness(1.12); }
.qa-primary--green {
  background: #2ea043;
  box-shadow: 0 2px 8px rgba(46,160,67,0.3);
}
.qa-primary--accent {
  background: var(--link);
  box-shadow: 0 2px 8px rgba(108,155,255,0.3);
}

.qa-chip {
  flex-shrink: 0;
  padding: 6px 14px;
  border-radius: 16px;
  background: transparent;
  color: var(--link);
  font-size: 13px;
  border: 1px solid rgba(108,155,255,0.2);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.qa-chip:hover { background: rgba(108,155,255,0.08); border-color: rgba(108,155,255,0.4); }
.qa-chip:active { transform: scale(0.95); }
.qa-chip--muted {
  color: rgba(255,255,255,0.55);
  border-color: rgba(255,255,255,0.1);
  background: transparent;
}
.qa-chip--muted:hover { color: rgba(255,255,255,0.7); border-color: rgba(255,255,255,0.2); }

/* Touch-friendly sizing on mobile */
@media (pointer: coarse) {
  .qa-primary { padding: 10px 22px; }
  .qa-chip { padding: 8px 16px; }
}
.qa-chip.qa-done {
  background: rgba(76,175,80,0.15);
  color: var(--success);
  border-color: rgba(76,175,80,0.3);
}
.quick-actions.poll-mode {
  flex-direction: column;
  overflow-x: visible;
  padding: 8px 16px 4px;
}
.qa-chip.qa-answer {
  background: rgba(108,155,255,0.1);
  color: var(--link);
  border-color: rgba(108,155,255,0.3);
  font-weight: 500;
  text-align: left;
  border-radius: 12px;
  padding: 10px 14px;
}
.poll-mode .qa-chip.qa-answer {
  width: 100%;
}
.qa-chip.qa-answer:active {
  background: rgba(108,155,255,0.35);
  border-color: rgba(108,155,255,0.6);
}

/* ── Chat input bar ────────────────────── */

.chat-input-bar {
  padding: 8px 12px calc(12px + env(safe-area-inset-bottom, 0px));
  background: var(--bg);
  border-top: 1px solid rgba(255,255,255,0.06);
}
.chat-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--secondary-bg);
  border-radius: 24px;
  padding: 8px 8px 8px 14px;
  border: 1px solid rgba(255,255,255,0.08);
  transition: border-color 0.15s, box-shadow 0.15s;
}

/* Issue 5: Links in code blocks must be clickable */
.chat-messages .msg pre a,
.chat-messages .msg code a,
.chat-messages a {
  pointer-events: auto;
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.chat-input-wrapper:focus-within {
  border-color: rgba(255,255,255,0.15);
  box-shadow: 0 0 0 2px rgba(108,155,255,0.1);
}

#chat-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  resize: none;
  outline: none;
  max-height: 120px;
  min-height: 22px;
  line-height: 1.5;
}
#chat-input::placeholder { color: var(--hint); }
#chat-input.voice-processing {
  opacity: 0.5;
  animation: shimmer 1.5s infinite;
}

.btn-send, .btn-voice, .btn-stop-agent {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}
.btn-send {
  background: var(--text);
  color: var(--bg);
}
.btn-send:disabled { opacity: 0.3; cursor: not-allowed; }
.btn-send:active { transform: scale(0.93); }

.btn-voice {
  background: transparent;
  color: var(--hint);
}
.btn-voice.recording {
  background: var(--destructive);
  color: white;
  animation: none;
}
.btn-voice-cancel {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.08);
  color: var(--hint);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.btn-voice-cancel:active {
  background: rgba(239,68,68,0.2);
  color: var(--destructive);
}

/* ── Voice recording bar (WhatsApp-style) ── */
.voice-recording-bar {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 4px;
}

.voice-rec-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--destructive);
  flex-shrink: 0;
  animation: voice-blink 1s ease-in-out infinite;
}

@keyframes voice-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.2; }
}

.voice-waveform {
  flex: 1;
  height: 36px;
  overflow: hidden;
  position: relative;
}
.voice-waveform canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* ── Voice processing indicator ── */
.voice-processing-bar {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
}
.voice-processing-text {
  font-size: 13px;
  color: var(--link);
  font-weight: 500;
}
.voice-dots span {
  animation: dot-bounce 1.4s ease-in-out infinite;
  display: inline-block;
}
.voice-dots span:nth-child(1) { animation-delay: 0s; }
.voice-dots span:nth-child(2) { animation-delay: 0.2s; }
.voice-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dot-bounce {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* ── Voice done flash ── */
.voice-done-bar {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 8px;
  animation: voice-done-flash 1.5s ease-out forwards;
}
.voice-done-icon { font-size: 14px; }
.voice-done-text { font-size: 13px; color: var(--success); font-weight: 500; }
@keyframes voice-done-flash {
  0% { opacity: 0; transform: scale(0.9); }
  20% { opacity: 1; transform: scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

.chat-input-wrapper.is-processing {
  border-color: rgba(108,155,255,0.3);
  box-shadow: 0 0 0 2px rgba(108,155,255,0.1);
}

.voice-timer {
  font-size: 13px;
  color: var(--destructive);
  font-family: var(--font-mono, monospace);
  min-width: 36px;
  text-align: right;
  flex-shrink: 0;
  font-weight: 500;
}

/* (voice-timer-form removed — now in fixed input bar) */

.chat-input-wrapper.is-recording {
  border-color: rgba(239,68,68,0.3);
  box-shadow: 0 0 0 2px rgba(239,68,68,0.1);
}

.btn-stop-agent {
  background: var(--destructive);
  color: white;
}
.btn-stop-agent:active { transform: scale(0.93); }

/* ── Form screens ──────────────────────── */

.form-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.form-header h2 { flex: 1; font-size: 16px; font-weight: 600; }

.form-body {
  padding: 16px;
}
.form-body label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--hint);
  margin-bottom: 6px;
  margin-top: 14px;
}
.form-body label:first-child { margin-top: 0; }
.form-body label .hint { font-weight: 400; opacity: 0.6; }

.form-body input,
.form-body select,
.form-body textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255,255,255,0.1);
  background: var(--secondary-bg);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}
.form-body input:focus,
.form-body select:focus,
.form-body textarea:focus {
  border-color: var(--link);
}
.form-body textarea { resize: vertical; min-height: 60px; }

.form-body input.invalid,
.form-body textarea.invalid {
  border-color: var(--destructive);
}

/* ══════════════════════════════════════════════════════════
   SETTINGS
   ══════════════════════════════════════════════════════════ */

#screen-settings .form-body {
  padding: 8px 16px 100px;
  overflow-y: auto;
}

/* ── Section groups (iOS-style cards) ── */
.st-group {
  background: var(--secondary-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 24px;
  overflow: hidden;
}
.st-group-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--section-header);
  padding: 0 4px 8px;
}

/* ── Setting row (label left, control right) ── */
.st-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  gap: 12px;
  min-height: 46px;
}
.st-row + .st-row {
  border-top: 1px solid var(--border);
}
.st-row-label {
  font-size: 14px;
  color: var(--text);
  flex-shrink: 1;
  min-width: 0;
}
.st-row-hint {
  font-size: 11px;
  color: var(--hint);
  margin-top: 2px;
}

/* ── Compact number input ── */
.st-number-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.st-number {
  width: 72px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  font-family: var(--font-mono);
  text-align: center;
  outline: none;
  transition: border-color 0.15s;
  -moz-appearance: textfield;
}
.st-number::-webkit-inner-spin-button,
.st-number::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.st-number:focus {
  border-color: var(--link);
}
.st-number.changed {
  border-color: var(--link);
  background: rgba(108,155,255,0.06);
}
.st-unit {
  font-size: 12px;
  color: var(--hint);
  white-space: nowrap;
}

/* ── Chip selector (model) ── */
.st-chips-row {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  flex-wrap: wrap;
}
.st-chips {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.st-chip {
  padding: 5px 12px;
  border-radius: 16px;
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--hint);
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.st-chip:active { transform: scale(0.97); }
.st-chip.active {
  border-color: var(--link);
  background: rgba(108,155,255,0.1);
  color: var(--text);
}

/* ── Map group (turns, budgets) ── */
.st-map-rows {
  display: flex;
  flex-direction: column;
}
.st-map-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  gap: 12px;
}
.st-map-row + .st-map-row {
  border-top: 1px solid var(--border);
}
.st-map-label {
  font-size: 14px;
  color: var(--text);
}
.st-map-input {
  width: 80px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  font-family: var(--font-mono);
  text-align: center;
  outline: none;
  transition: border-color 0.15s;
  -moz-appearance: textfield;
}
.st-map-input::-webkit-inner-spin-button,
.st-map-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.st-map-input:focus {
  border-color: var(--link);
}

/* ── Actions ── */
.st-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}
.st-save {
  width: 100%;
  padding: 12px;
  border-radius: var(--radius);
  border: none;
  background: var(--button);
  color: var(--button-text);
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}
.st-save:active { transform: scale(0.98); }
.st-save:disabled {
  opacity: 0.5;
  cursor: default;
  transform: none;
}
.st-reset {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  padding: 10px 0;
  text-align: center;
  width: 100%;
  color: var(--hint);
  transition: color 0.15s;
}
.st-reset:hover { color: var(--destructive); }

/* ── Mobile settings gear in header ── */
.header-settings-btn {
  margin-left: auto;
  color: var(--hint);
  padding: 4px;
  transition: color 0.15s;
  cursor: pointer;
}
.header-settings-btn:hover { color: var(--text); }

@media (min-width: 960px) {
  .header-settings-btn { display: none; }
  #screen-settings .form-body {
    max-width: 520px;
    margin: 0 auto;
  }
  /* Center form screens on desktop when list panel hidden */
  .nt-body,
  .nt-input-bar {
    max-width: 720px;
    margin-left: auto;
    margin-right: auto;
  }
  .nt-project-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  #screen-project-edit .form-body,
  .projects-grid {
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
  }
  #screen-costs .form-body {
    max-width: 720px;
    margin: 0 auto;
  }
}

/* ══════════════════════════════════════════════════════════
   NEW TASK — COMPACT BOTTOM-ALIGNED
   ══════════════════════════════════════════════════════════ */

.nt-body {
  padding: 12px 16px;
  padding-bottom: calc(90px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
}

/* ── Top bar: search + options ────────── */

.nt-topbar {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.nt-search {
  width: 100%;
  padding: 8px 12px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.08);
  background: var(--secondary-bg);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
}
.nt-search::placeholder { color: var(--hint); }
.nt-search:focus { border-color: rgba(255,255,255,0.15); }

.nt-options {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.nt-sep {
  width: 1px;
  height: 20px;
  background: rgba(255,255,255,0.08);
  flex-shrink: 0;
  margin: 0 2px;
}
.nt-chips {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.nt-chip {
  padding: 5px 10px;
  border-radius: 14px;
  border: 1.5px solid rgba(255,255,255,0.08);
  background: var(--secondary-bg);
  color: var(--hint);
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.nt-chip:active { transform: scale(0.97); }
.nt-chip.active {
  border-color: var(--link);
  background: rgba(108,155,255,0.1);
  color: var(--text);
}

/* ── Project cards grid ──────────────── */

.nt-project-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.nt-project-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1.5px solid rgba(255,255,255,0.06);
  background: var(--secondary-bg);
  cursor: pointer;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}
.nt-project-card:active { transform: scale(0.97); }
.nt-project-card.active {
  border-color: var(--link);
  background: rgba(108,155,255,0.1);
}
.nt-project-card .nt-pc-icon {
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
}
.nt-project-card .nt-pc-info {
  flex: 1;
  min-width: 0;
}
.nt-project-card .nt-pc-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nt-project-card .nt-pc-desc {
  font-size: 11px;
  color: var(--hint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

/* ── New Task: fixed bottom input bar (Telegram-style) ── */

.nt-input-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 8px 12px calc(12px + env(safe-area-inset-bottom, 0px));
  background: var(--bg);
  border-top: 1px solid rgba(255,255,255,0.06);
  z-index: 200;
}

.nt-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--secondary-bg);
  border-radius: 24px;
  padding: 8px 8px 8px 14px;
  border: 1px solid rgba(255,255,255,0.08);
  transition: border-color 0.15s, box-shadow 0.15s;
  position: relative;
}
.nt-input-wrapper:focus-within {
  border-color: rgba(255,255,255,0.15);
  box-shadow: 0 0 0 2px rgba(108,155,255,0.1);
}
.nt-input-wrapper.is-recording {
  border-color: rgba(239,68,68,0.3);
  box-shadow: 0 0 0 2px rgba(239,68,68,0.1);
}
.nt-input-wrapper.is-processing {
  border-color: rgba(108,155,255,0.3);
  box-shadow: 0 0 0 2px rgba(108,155,255,0.1);
}

#screen-new-task #nt-task {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  resize: none;
  outline: none;
  max-height: 120px;
  min-height: 22px;
  line-height: 1.5;
}
#screen-new-task #nt-task::placeholder { color: var(--hint); }
#screen-new-task #nt-task.invalid {
  color: var(--destructive);
}

.btn-nt-attach {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--hint);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
  align-self: center;
}
.btn-nt-attach:active { color: var(--link); }

.btn-nt-action {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s, transform 0.1s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.btn-nt-action:active { transform: scale(0.93); }

.btn-nt-mic {
  background: transparent;
  color: var(--hint);
}
.btn-nt-mic.recording {
  background: var(--destructive);
  color: white;
}

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

/* Voice recording overlay inside new task input bar */
.nt-voice-recording {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 4px;
}
.nt-voice-recording .voice-waveform {
  flex: 1;
  height: 36px;
}

/* Voice processing overlay inside new task input bar */
.nt-voice-processing {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
}

/* ── Legacy selectors (kept for JS compat, styled via .nt-chip) ── */

/* (nt-submit removed — now uses fixed bottom input bar) */

/* Plan approval now uses .qa-primary--green */

.btn-primary {
  display: block;
  width: 100%;
  padding: 12px;
  margin-top: 20px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--button);
  color: var(--button-text);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn-primary:active { opacity: 0.7; }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-danger {
  display: block;
  width: 100%;
  padding: 12px;
  margin-top: 10px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--destructive);
  font-size: 14px;
  cursor: pointer;
  border: 1px solid rgba(255,85,85,0.3);
}

/* ── Project info card ─────────────────── */

.project-info-card {
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(108,155,255,0.08);
  border: 1px solid rgba(108,155,255,0.15);
  font-size: 12px;
  color: var(--hint);
  line-height: 1.4;
}

/* ── Projects grid ─────────────────────── */

.projects-grid {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.project-card {
  background: var(--secondary-bg);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  border: 1px solid rgba(255,255,255,0.05);
  transition: transform 0.1s, border-color 0.15s, box-shadow 0.15s;
}
.project-card:hover {
  border-color: rgba(255,255,255,0.1);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.project-card:active { transform: scale(0.98); }
.project-card .pc-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.project-card .pc-name { font-weight: 600; font-size: 14px; }
.pc-ide-btn {
  background: rgba(108,155,255,0.15);
  border: none;
  color: var(--link);
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font-mono);
  padding: 3px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
  flex-shrink: 0;
}
.pc-ide-btn:hover { background: rgba(108,155,255,0.3); }

/* ── IDE Screen ─────────────────────── */
.screen-ide { display: flex; flex-direction: column; height: 100vh; height: 100dvh; padding: 0; }
.ide-header {
  display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
  padding: calc(6px + env(safe-area-inset-top, 0px)) 8px 6px;
  background: var(--bg);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0; min-height: 44px; position: relative;
}
.ide-tabs {
  flex: 1; display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.ide-tabs::-webkit-scrollbar { display: none; }
.ide-tab {
  display: flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 6px; font-size: 12px; font-weight: 500;
  background: transparent; border: none; color: var(--hint);
  cursor: pointer; white-space: nowrap; transition: background 0.15s;
}
.ide-tab:hover { background: rgba(255,255,255,0.06); }
.ide-tab.active { background: rgba(108,155,255,0.15); color: var(--link); }
.ide-tab-close {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; border-radius: 4px; border: none;
  background: transparent; color: var(--hint); font-size: 11px;
  cursor: pointer; padding: 0; line-height: 1;
}
.ide-tab-close:hover { background: rgba(255,80,80,0.3); color: #fff; }
.ide-header-actions {
  display: flex; align-items: center; gap: 2px; flex-shrink: 0;
}
.ide-new-btn {
  font-size: 18px; font-weight: 400; width: 28px; height: 28px;
}
.ide-project-picker {
  position: absolute; top: 100%; right: 8px; z-index: 100;
  background: var(--secondary-bg); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px; padding: 4px; min-width: 200px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}
.ide-project-picker .ide-pp-item {
  display: block; width: 100%; padding: 8px 12px; border: none; background: none;
  color: var(--text); font-size: 13px; text-align: left; cursor: pointer;
  border-radius: 6px; transition: background 0.1s; font-family: inherit;
}
.ide-project-picker .ide-pp-item:hover { background: rgba(255,255,255,0.06); }
.ide-project-picker .ide-pp-item.disabled {
  opacity: 0.4; pointer-events: none;
}
.ide-frames { flex: 1; position: relative; }
.ide-frames iframe {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  border: none; background: #1e1e1e;
}
.ide-frames iframe.hidden { display: none; }
.project-card .pc-path {
  font-size: 11px; color: var(--hint); font-family: var(--font-mono);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  margin-top: 2px;
}
.project-card .pc-desc {
  font-size: 12px; color: var(--hint); margin-top: 6px; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.project-card .pc-model {
  display: inline-block;
  margin-top: 6px;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(108,155,255,0.15);
  color: var(--link);
}

/* ── Author badge ──────────────────────── */

.author-badge {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px 2px 2px;
  background: var(--secondary-bg);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 14px;
  text-decoration: none;
  font-size: 10px;
  color: var(--hint);
  opacity: 0.5;
  transition: opacity 0.2s;
  flex-shrink: 0;
}
.author-badge:hover { opacity: 0.8; }
.author-logo { width: 16px; height: 16px; border-radius: 50%; }

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

.toast-container {
  position: fixed;
  bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 999;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  pointer-events: none;
}
.toast {
  padding: 10px 20px;
  border-radius: 12px;
  font-size: 14px;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  transform: translateY(10px);
  white-space: nowrap;
  pointer-events: auto;
}
.toast.show {
  opacity: 1;
  transform: translateY(0);
}
.toast-success { background: var(--success); color: white; }
.toast-error { background: var(--destructive); color: white; }
.toast-info { background: var(--button); color: var(--button-text); }

/* ── Empty state ───────────────────────── */

.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--hint);
}
.empty-state .icon { font-size: 40px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; line-height: 1.5; }

/* ── Loading skeleton ──────────────────── */

.skeleton {
  background: linear-gradient(90deg, var(--secondary-bg) 25%, rgba(255,255,255,0.05) 50%, var(--secondary-bg) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}
.skeleton-card { height: 80px; margin-bottom: 10px; }
.skeleton-line { height: 14px; margin-bottom: 8px; }

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* ── Load more events ─────────────────── */

.load-more-events {
  padding: 10px 20px;
  text-align: center;
  font-size: 13px;
  color: var(--link);
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  user-select: none;
}
.load-more-events:hover { background: rgba(108,155,255,0.08); }
.load-more-events:active { background: rgba(108,155,255,0.15); }

/* ── Tool group collapsing ────────────── */

.tool-group-collapsed { display: none; }
.tool-group-collapsed.expanded { display: block; }
.tool-group-toggle {
  padding: 6px 20px;
  font-size: 12px;
  color: var(--link);
  cursor: pointer;
  border-left: 2px solid rgba(108,155,255,0.2);
  margin-left: 16px;
}
.tool-group-toggle:hover {
  background: rgba(108,155,255,0.05);
}

/* ── Plan block ───────────────────────── */

.msg-plan-container {
  margin: 12px 16px;
  background: rgba(108,155,255,0.08);
  border-left: 3px solid var(--link);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.msg-plan-header {
  padding: 8px 14px;
  background: rgba(108,155,255,0.15);
  font-size: 13px;
  font-weight: 600;
  color: var(--link);
}
.msg-plan {
  padding: 14px 16px;
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-wrap;
}
.msg-plan pre {
  display: block;
  white-space: pre-wrap;
  word-break: break-all;
  overflow-wrap: break-word;
  font-family: var(--font-mono);
  font-size: 12px;
  margin-top: 8px;
  margin-bottom: 8px;
  padding: 10px 14px;
  background: rgba(0,0,0,0.3);
  border-radius: 8px;
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.06);
  max-width: 100%;
  overflow-x: auto;
  line-height: 1.5;
}
.msg-plan code {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 2px 6px;
  background: rgba(0,0,0,0.25);
  border-radius: 4px;
  color: var(--text);
}
.msg-plan pre code {
  display: block;
  padding: 0;
  background: none;
  border-radius: 0;
  border: none;
  font-size: inherit;
  white-space: pre-wrap;
}

/* ── Cancel chip ──────────────────────── */

.qa-chip.qa-cancel {
  background: rgba(255,85,85,0.1);
  color: var(--destructive);
  border-color: rgba(255,85,85,0.25);
}

/* ── Blockquote (copyable) ────────────── */

.chat-messages .msg pre.quote-block,
.msg-plan pre.quote-block {
  font-family: inherit;
  font-size: 13px;
  line-height: 1.6;
  border-left: 3px solid var(--link);
  background: rgba(108,155,255,0.06);
}

/* ── Copy button on code blocks ───────── */

.code-wrapper {
  position: relative;
}
.copy-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 3px 10px;
  font-size: 11px;
  font-family: inherit;
  background: rgba(255,255,255,0.08);
  color: var(--hint);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 4px;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.2s, color 0.2s, border-color 0.2s;
  z-index: 2;
  line-height: 1.2;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.copy-btn:active {
  opacity: 1;
  background: rgba(255,255,255,0.15);
}
.copy-btn.copied {
  color: var(--success);
  border-color: rgba(76,175,80,0.3);
  opacity: 1;
}
/* Desktop: show on hover */
@media (hover: hover) {
  .copy-btn { opacity: 0; }
  .code-wrapper:hover .copy-btn { opacity: 0.7; }
  .copy-btn:hover { opacity: 1; }
  .copy-btn.copied { opacity: 1; }
}

/* ── Modal ─────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.15s ease;
}
.modal-content {
  background: var(--bg);
  border-radius: 16px 16px 0 0;
  width: 100%;
  max-width: 600px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.2s ease;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  font-size: 15px;
  font-weight: 600;
}
.modal-close {
  background: none;
  border: none;
  color: var(--hint);
  font-size: 22px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}
.modal-close:hover { background: rgba(255,255,255,0.08); }
.modal-body {
  padding: 16px 18px;
  overflow-y: auto;
  font-size: 14px;
  line-height: 1.7;
}
/* Plan modal body renders server HTML — don't use pre-wrap (Issue 11) */
#plan-modal-body {
  white-space: normal;
}
/* Location / other modals may have text content */
.location-modal-body {
  white-space: normal;
}
.modal-body pre {
  background: rgba(0,0,0,0.3);
  border-radius: 8px;
  padding: 10px 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  overflow-x: auto;
  margin: 8px 0;
  border: 1px solid rgba(255,255,255,0.06);
}
.modal-body code {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 2px 6px;
  background: rgba(0,0,0,0.25);
  border-radius: 4px;
}
.modal-body pre code {
  padding: 0;
  background: none;
}
.modal-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0;
  font-size: 13px;
}
.modal-body th, .modal-body td {
  padding: 6px 10px;
  border: 1px solid rgba(255,255,255,0.1);
  text-align: left;
}
.modal-body th { background: rgba(255,255,255,0.04); font-weight: 600; }

/* Issue 11: Plan modal markdown-like heading/list styles */
#plan-modal-body h1, #plan-modal-body h2, #plan-modal-body h3,
#plan-modal-body h4, #plan-modal-body h5, #plan-modal-body h6 {
  margin: 14px 0 6px;
  color: var(--text);
  line-height: 1.4;
}
#plan-modal-body h1 { font-size: 18px; }
#plan-modal-body h2 { font-size: 16px; border-bottom: 1px solid rgba(255,255,255,0.08); padding-bottom: 4px; }
#plan-modal-body h3 { font-size: 15px; }
#plan-modal-body p { margin: 6px 0; }
#plan-modal-body ul, #plan-modal-body ol { padding-left: 20px; margin: 6px 0; }
#plan-modal-body li { margin: 3px 0; }
#plan-modal-body strong { font-weight: 600; }
#plan-modal-body em { font-style: italic; opacity: 0.9; }
#plan-modal-body blockquote {
  margin: 8px 0;
  padding: 6px 12px;
  border-left: 3px solid var(--link);
  background: rgba(108,155,255,0.06);
  border-radius: 0 4px 4px 0;
  opacity: 0.9;
}
#plan-modal-body hr { border: none; border-top: 1px solid rgba(255,255,255,0.1); margin: 12px 0; }

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

/* ── Login modal ──────────────────────── */

.login-modal-content {
  border-radius: 16px;
  max-width: 360px;
  margin: auto;
}
.login-modal-body {
  padding: 20px 18px 24px;
}
.login-modal-body p {
  font-size: 13px;
  color: var(--hint);
  margin-bottom: 14px;
  line-height: 1.5;
}
.login-input {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255,255,255,0.1);
  background: var(--secondary-bg);
  color: var(--text);
  font-size: 14px;
  font-family: var(--font-mono);
  outline: none;
  transition: border-color 0.15s;
}
.login-input:focus { border-color: var(--link); }
.login-input.invalid { border-color: var(--destructive); }
.login-error {
  font-size: 12px;
  color: var(--destructive);
  margin-top: 8px;
}
.login-modal-body .btn-primary {
  margin-top: 14px;
}
.tg-widget-wrap {
  display: flex;
  justify-content: center;
  min-height: 44px;
  margin-bottom: 4px;
}
.login-divider {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0;
  color: var(--hint);
  font-size: 12px;
}
.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(255,255,255,0.1);
}
.login-hint {
  font-size: 13px;
  color: var(--hint);
  margin-bottom: 8px !important;
}

/* ── Project context card ──────────────── */
#nt-project-info {
  background: var(--secondary-bg);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 12px;
  font-size: 13px;
}
.ctx-section { margin-bottom: 8px; }
.ctx-section:last-child { margin-bottom: 0; }
.ctx-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--section-header);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 5px;
}
details.ctx-section summary.ctx-label {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 4px;
}
details.ctx-section summary.ctx-label::before { content: '▸'; font-size: 10px; }
details.ctx-section[open] summary.ctx-label::before { content: '▾'; }
.ctx-session {
  font-size: 12px;
  color: var(--hint);
  padding: 2px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ctx-md {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--hint);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 160px;
  overflow-y: auto;
  margin-top: 6px;
  padding: 6px;
  background: rgba(0,0,0,0.2);
  border-radius: 4px;
}

/* ── Context: browse files button ──────── */
.ctx-files-btn {
  background: none;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: var(--radius-sm);
  color: var(--link);
  font-size: 12px;
  padding: 5px 10px;
  cursor: pointer;
  transition: background 0.15s;
}
.ctx-files-btn:hover { background: rgba(255,255,255,0.05); }

/* ── File Browser ────────────────────────── */
.breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px;
  padding: 8px 16px 4px;
  font-size: 12px;
  color: var(--hint);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.bc-item {
  cursor: pointer;
  color: var(--link);
  padding: 2px 4px;
  border-radius: 4px;
  transition: background 0.15s;
}
.bc-item:hover { background: rgba(255,255,255,0.06); }
.bc-sep { color: var(--hint); padding: 0 2px; }

.files-list {
  padding: 8px 0;
  overflow-y: auto;
  flex: 1;
}
.file-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background 0.1s;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.file-item:hover { background: rgba(255,255,255,0.04); }
.file-item:active { background: rgba(255,255,255,0.08); }
.fi-icon { font-size: 18px; flex-shrink: 0; }
.fi-name { flex: 1; font-size: 14px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fi-size { font-size: 11px; color: var(--hint); flex-shrink: 0; font-family: var(--font-mono); }

/* ── Context window bar (#019) ──────────── */
.context-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  background: var(--secondary-bg);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.ctx-bar-label {
  font-size: 10px;
  color: var(--hint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}
.ctx-bar-track {
  flex: 1;
  height: 4px;
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
  overflow: hidden;
}
.ctx-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.5s ease, background 0.3s;
}
.ctx-bar-text {
  font-size: 10px;
  color: var(--hint);
  font-family: var(--font-mono);
  flex-shrink: 0;
}

/* ── Location Picker ─────────────────────── */
.location-modal-body {
  padding: 0;
  display: flex;
  flex-direction: column;
  max-height: 70vh;
}
.location-modal-body .breadcrumb {
  border-bottom: 1px solid rgba(255,255,255,0.08);
  padding: 8px 12px;
}
.loc-list {
  flex: 1;
  overflow-y: auto;
  min-height: 200px;
}
.loc-current {
  font-size: 11px;
  color: var(--hint);
  font-family: var(--font-mono);
  padding: 6px 12px;
  background: rgba(0,0,0,0.2);
  border-top: 1px solid rgba(255,255,255,0.06);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.location-modal-body .btn-primary {
  margin: 10px 12px 12px;
  width: calc(100% - 24px);
}

/* ── Path input with browse button ─────── */
.path-input-row {
  display: flex;
  gap: 6px;
  align-items: center;
}
.path-input-row input { flex: 1; }
.btn-browse-path {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  font-size: 18px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255,255,255,0.1);
  background: var(--secondary-bg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.btn-browse-path:hover { background: rgba(255,255,255,0.08); }

/* ── Event timestamp badge ──────────────── */
.msg-ts {
  font-size: 10px;
  color: var(--hint);
  opacity: 0.6;
  float: right;
  margin-left: 8px;
  margin-top: 2px;
  font-family: var(--font-mono);
}

/* ── Multi-file attachments list ─────────────── */
.attachments-list {
  display: none;          /* shown via JS when files exist */
  flex-wrap: nowrap;
  align-items: flex-end;
  gap: 10px;
  padding: 10px 14px 6px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.attachments-list::-webkit-scrollbar { display: none; }
#chat-attachments {
  margin-bottom: 4px;
}
#nt-attachments {
  margin-top: 6px;
  padding: 10px 6px 4px;
  flex-shrink: 0;
}
/* ── Plus button (attach + model selector) ── */
.chat-plus-wrap {
  position: relative;
  flex-shrink: 0;
  display: flex;
  align-items: center;
}
.btn-plus-chat {
  background: none;
  border: none;
  color: var(--hint);
  cursor: pointer;
  padding: 2px;
  line-height: 1;
  transition: color 0.15s, transform 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-plus-chat:hover { color: var(--link); }
.btn-plus-chat.has-file { color: var(--link); }
.btn-plus-chat.model-changed { color: var(--link); }

.plus-dropdown {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  min-width: 180px;
  background: var(--secondary-bg);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  padding: 6px 0;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  z-index: 100;
}
.plus-dropdown.open { display: block; }

.plus-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 14px;
  background: none;
  border: none;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.1s;
}
.plus-item:hover { background: rgba(255,255,255,0.06); }

.plus-divider {
  height: 1px;
  background: rgba(255,255,255,0.08);
  margin: 4px 0;
}

.plus-model-section {
  padding: 0;
}
.plus-model-label {
  display: block;
  padding: 4px 14px 2px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--hint);
}
.plus-model-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 7px 14px 7px 22px;
  background: none;
  border: none;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
  position: relative;
}
.plus-model-item:hover { background: rgba(255,255,255,0.06); }
.plus-model-item.active {
  color: var(--link);
}
.plus-model-item.active::before {
  content: '';
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--link);
}

/* ── Model tag in chat header ─────────── */
.model-tag {
  font-size: 11px;
  font-weight: 400;
  color: var(--link);
  opacity: 0.7;
}

/* ── Model label in agent cards ───────── */
.agent-model {
  font-size: 10px;
  color: var(--hint);
}

/* ── Model change event in chat ───────── */
.msg-model-change {
  display: flex;
  justify-content: center;
  padding: 2px 0;
}
.msg-model-change .msg-system {
  font-size: 11px;
  color: var(--hint);
  background: transparent;
  padding: 2px 8px;
}

/* ── File Attachment Badge ─────────────── */
.nt-attach-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}
.attachment-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--tg-theme-secondary-bg-color, var(--secondary-bg, #f0f0f0));
  border-radius: 10px;
  font-size: 12px;
  color: var(--tg-theme-text-color, var(--text, #333));
  margin-top: 0;
  max-width: 200px;
  overflow: hidden;
  flex-shrink: 0;
}
.attachment-badge span {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.attachment-badge .btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  padding: 0 2px;
  color: var(--tg-theme-hint-color, var(--hint, #888));
  line-height: 1;
  flex-shrink: 0;
}

/* ── Attachment image preview ────────────── */
.attach-preview {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
}

/* ── Pasted content cards (override .attachment-badge base) ── */
.attachment-badge.attach-pasted-text,
.attachment-badge.attach-image-card {
  position: relative;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  margin-top: 0;
  padding: 0;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.08);
  background: var(--secondary-bg);
  overflow: hidden;
  flex-shrink: 0;
}
/* ── Pasted long text card ── */
.attachment-badge.attach-pasted-text {
  width: 180px;
  padding: 8px 12px 10px;
}
.attach-pasted-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-bottom: 6px;
}
.attach-pasted-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--hint);
  opacity: 0.8;
}
.attach-pasted-text .attach-remove {
  position: static;
  flex-shrink: 0;
  background: transparent;
  color: var(--hint);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.attach-pasted-text .attach-remove:hover {
  color: var(--text);
  background: rgba(255,255,255,0.08);
}
.attach-pasted-preview {
  font-size: 12px;
  line-height: 1.4;
  color: var(--text);
  opacity: 0.6;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
/* ── Pasted image card ── */
.attachment-badge.attach-image-card {
  width: 72px;
  height: 72px;
  padding: 0;
  border-radius: 12px;
}
.attach-image-card .attach-preview {
  width: 100%;
  height: 100%;
  border-radius: 11px;
  object-fit: cover;
}
/* ── Remove button (shared for absolute-positioned cards) ── */
.attach-remove {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border: none;
  color: rgba(255,255,255,0.85);
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  padding: 0;
  transition: background 0.15s, transform 0.1s, color 0.15s;
}
.attach-remove:hover { background: rgba(0,0,0,0.8); }
.attach-remove:active { transform: scale(0.9); }

/* ── Chat image preview (in user messages) ── */
.chat-img-preview {
  margin-top: 8px;
}
.chat-img-preview img {
  max-width: 240px;
  max-height: 200px;
  border-radius: 10px;
  cursor: pointer;
  transition: opacity 0.15s;
}
.chat-img-preview img:hover {
  opacity: 0.85;
}
.chat-file-badge {
  display: inline-block;
  padding: 2px 8px;
  background: rgba(108,155,255,0.1);
  border-radius: 6px;
  font-size: 12px;
  color: var(--link);
  margin-top: 4px;
}

/* ── File content viewer ───────────────── */
.file-content-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--secondary-bg);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}
.file-content-name {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  font-family: var(--font-mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-size-badge {
  font-size: 11px;
  color: var(--hint);
  white-space: nowrap;
}
.file-content-pre {
  background: var(--secondary-bg);
  border-radius: var(--radius-sm);
  padding: 12px 12px 12px 0;
  overflow-x: auto;
  font-size: 12px;
  line-height: 1.5;
  font-family: var(--font-mono);
  color: var(--text);
  white-space: pre;
  max-height: 72vh;
  overflow-y: auto;
  counter-reset: line;
}
/* Issue 18: line numbers */
.file-content-pre .code-line {
  display: block;
  padding-left: 12px;
  counter-increment: line;
}
.file-content-pre .code-line::before {
  content: counter(line);
  display: inline-block;
  width: 3.5ch;
  margin-right: 16px;
  padding-right: 8px;
  color: var(--hint);
  text-align: right;
  user-select: none;
  opacity: 0.4;
  border-right: 1px solid rgba(255,255,255,0.06);
}
.file-content-pre .code-line:hover {
  background: rgba(255,255,255,0.03);
}
/* Ensure file lines don't wrap unexpectedly */
.file-content-pre code {
  display: block;
  white-space: pre;
}
/* highlight.js: transparent bg so our <pre> controls background */
.file-content-pre code.hljs {
  background: transparent;
  padding: 0;
}

/* ══════════════════════════════════════════════════════════
   VERSION TAG
   ══════════════════════════════════════════════════════════ */

.version-tag {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--link);
  background: rgba(108,155,255,0.1);
  border: 1px solid rgba(108,155,255,0.2);
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
}

/* ══════════════════════════════════════════════════════════
   ANIMATED ORB — EMPTY STATE (canvas-based)
   ══════════════════════════════════════════════════════════ */

.empty-state-orb {
  padding: 40px 20px 30px;
}

.orb-container {
  width: 280px;
  height: 280px;
  margin: 0 auto 16px;
}

.orb-text {
  font-size: 14px;
  color: var(--hint);
  opacity: 0.7;
  animation: orb-text-pulse 3s ease-in-out infinite;
}
@keyframes orb-text-pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 0.8; }
}

/* ══════════════════════════════════════════════════════════
   SCREEN TRANSITIONS
   ══════════════════════════════════════════════════════════ */

.screen {
  animation: screen-enter 0.25s ease-out;
}
.screen-exit {
  animation: screen-exit 0.2s ease-in forwards;
}

@keyframes screen-enter {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes screen-exit {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(-20px); }
}
.screen-back {
  animation: screen-enter-back 0.25s ease-out;
}
@keyframes screen-enter-back {
  from { opacity: 0; transform: translateX(-20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ══════════════════════════════════════════════════════════
   AGENT CARD ANIMATIONS
   ══════════════════════════════════════════════════════════ */

.agent-card {
  animation: card-in 0.3s ease-out both;
}
.agent-card:nth-child(1) { animation-delay: 0s; }
.agent-card:nth-child(2) { animation-delay: 0.06s; }
.agent-card:nth-child(3) { animation-delay: 0.12s; }
.agent-card:nth-child(4) { animation-delay: 0.18s; }
.agent-card:nth-child(5) { animation-delay: 0.24s; }

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

/* Running agent glow */
.agent-card.agent-running {
  border-color: rgba(76,175,80,0.2);
  box-shadow: 0 0 0 1px rgba(76,175,80,0.1);
  animation: card-in 0.3s ease-out both, agent-glow 3s ease-in-out infinite;
}

@keyframes agent-glow {
  0%, 100% { box-shadow: 0 0 0 1px rgba(76,175,80,0.1), 0 0 12px rgba(76,175,80,0.06); }
  50% { box-shadow: 0 0 0 1px rgba(76,175,80,0.2), 0 0 20px rgba(76,175,80,0.12); }
}

.agent-status-tag {
  display: inline-flex; align-items: center; gap: 2px;
  margin-top: 0;
  font-size: 10px;
  font-weight: 500;
  padding: 1px 6px;
  border-radius: 4px;
  flex-shrink: 0;
}
.agent-bottom .agent-status-tag { margin-top: 0; }
.status-tag-completed, .status-tag-stopped { background: rgba(255,152,0,0.12); color: #ff9800; }
.status-tag-failed { background: rgba(244,67,54,0.12); color: #f44336; }
.status-tag-done { background: rgba(76,175,80,0.12); color: #4caf50; }
.status-tag-cancelled { background: rgba(113,113,122,0.12); color: var(--hint); }
.status-tag-deferred { background: rgba(108,155,255,0.12); color: var(--link); }

/* ── Costs dashboard ── */
.costs-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.cost-card {
  background: var(--secondary-bg);
  border-radius: var(--radius);
  padding: 14px 12px;
  text-align: center;
}
.cost-card-label {
  font-size: 11px;
  color: var(--hint);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.cost-card-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}
.cost-card-accent { color: var(--link); }
.costs-section {
  background: var(--secondary-bg);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}
.costs-section-title {
  font-size: 12px;
  color: var(--hint);
  margin-bottom: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* Bar chart */
.costs-chart {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 120px;
  padding-bottom: 20px;
  position: relative;
}
.chart-bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
  position: relative;
  cursor: default;
}
.chart-bar {
  width: 100%;
  min-width: 4px;
  max-width: 14px;
  background: var(--link);
  border-radius: 2px 2px 0 0;
  opacity: 0.7;
  transition: opacity 0.15s;
}
.chart-bar-col:hover .chart-bar { opacity: 1; }
.chart-bar-col.chart-today .chart-bar { opacity: 1; background: var(--success); }
.chart-day {
  font-size: 8px;
  color: var(--hint);
  position: absolute;
  bottom: -16px;
}
.chart-bar-col:nth-child(5n) .chart-day,
.chart-bar-col.chart-today .chart-day,
.chart-bar-col:first-child .chart-day { display: block; }
.chart-day { display: none; }

/* Breakdown rows */
.breakdown-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.breakdown-row:last-child { margin-bottom: 0; }
.breakdown-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  min-width: 70px;
  flex-shrink: 0;
}
.breakdown-bar-track {
  flex: 1;
  height: 6px;
  background: rgba(255,255,255,0.06);
  border-radius: 3px;
  overflow: hidden;
}
.breakdown-bar-fill {
  height: 100%;
  background: var(--link);
  border-radius: 3px;
  min-width: 2px;
}
.breakdown-bar-fill.breakdown-model { background: var(--warning); }
.breakdown-value {
  font-size: 12px;
  color: var(--text);
  font-weight: 600;
  min-width: 65px;
  text-align: right;
  flex-shrink: 0;
  white-space: nowrap;
}
.breakdown-runs {
  font-weight: 400;
  color: var(--hint);
  font-size: 11px;
}


/* Quick-actions slide-up animation */
.quick-actions[data-animate] {
  animation: qaSlideUp 200ms ease-out;
}
@keyframes qaSlideUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 3-dot menu separator */
.chat-menu-dropdown .menu-sep {
  padding: 6px 16px 4px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--hint);
  opacity: 0.5;
  cursor: default;
  border-top: 1px solid rgba(255,255,255,0.06);
  margin-top: 2px;
}
/* ── Message action icons (ChatGPT-style) ── */
.msg-actions {
  display: flex;
  gap: 4px;
  padding: 4px 0 2px;
  margin-top: 4px;
}
.msg-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--hint);
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.msg-action-btn:active {
  background: rgba(255,255,255,0.08);
}
.msg-action-btn.copied {
  color: var(--success);
}
@media (hover: hover) {
  .msg-action-btn:hover {
    color: var(--text);
    background: rgba(255,255,255,0.06);
  }
}

/* History item stagger */
.history-item {
  animation: card-in 0.2s ease-out both;
}

/* ══════════════════════════════════════════════════════════
   FAB GLOW
   ══════════════════════════════════════════════════════════ */

.fab {
  animation: fab-glow 3s ease-in-out infinite;
  transition: transform 0.2s, box-shadow 0.2s;
}

@keyframes fab-glow {
  0%, 100% { box-shadow: 0 4px 12px rgba(0,0,0,0.3), 0 0 0 0 rgba(91,110,174,0); }
  50% { box-shadow: 0 4px 12px rgba(0,0,0,0.3), 0 0 20px 4px rgba(91,110,174,0.25); }
}

.fab:hover {
  transform: scale(1.08);
}
.fab:active { transform: scale(0.92); }

/* Driving mode FAB — left side */
.fab-driving {
  position: fixed;
  bottom: calc(60px + env(safe-area-inset-bottom, 0px));
  left: 20px;
  right: auto;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(76, 175, 80, 0.9);
  color: white;
  font-size: 26px;
  border: none;
  cursor: pointer;
  z-index: 50;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fab-glow-driving 3s ease-in-out infinite;
  -webkit-tap-highlight-color: transparent;
}
.fab-driving:active { transform: scale(0.92); }

@keyframes fab-glow-driving {
  0%, 100% { box-shadow: 0 4px 12px rgba(0,0,0,0.3), 0 0 0 0 rgba(76,175,80,0); }
  50% { box-shadow: 0 4px 12px rgba(0,0,0,0.3), 0 0 20px 4px rgba(76,175,80,0.3); }
}

.fab .fab-icon {
  transition: transform 0.2s;
}
.fab:hover .fab-icon {
  transform: rotate(90deg);
}

/* ══════════════════════════════════════════════════════════
   MESSAGE SEND FEEDBACK
   ══════════════════════════════════════════════════════════ */

.btn-send.sent {
  background: var(--success);
  animation: send-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.btn-send.sent svg path {
  stroke-dasharray: 24;
  stroke-dashoffset: 24;
  animation: check-draw 0.35s ease-out 0.1s forwards;
}
@keyframes send-pop {
  0% { transform: scale(0.8); opacity: 0.6; }
  50% { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes check-draw {
  to { stroke-dashoffset: 0; }
}

.msg-user {
  animation: msg-slide-up 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes msg-slide-up {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Status pill bounce */
.msg-status {
  animation: status-bounce 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes status-bounce {
  0% { opacity: 0; transform: translateY(8px) scale(0.85); }
  60% { opacity: 1; transform: translateY(-2px) scale(1.03); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

/* ══════════════════════════════════════════════════════════
   AGENT WORKING — CRISP NEON PERIMETER BORDER (5-6px)
   ══════════════════════════════════════════════════════════ */

.agent-glow-border {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 90;
  opacity: 0;
  transition: opacity 0.6s ease, background 0.6s ease;
  overflow: hidden;
  border-radius: var(--screen-radius-tl, 0px) var(--screen-radius-tr, 0px) var(--screen-radius-br, 0px) var(--screen-radius-bl, 0px);
}
/* Rotating conic gradient masked to a 5px border — JS drives --glow-angle */
.agent-glow-border::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: conic-gradient(
    from var(--glow-angle, 0deg),
    #6c9bff,
    #a855f7,
    #ec4899,
    #6c9bff,
    #22d3ee,
    #6c9bff
  );
  mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  mask-composite: exclude;
  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  padding: 5px;
}
/* Subtle inner glow for depth */
.agent-glow-border::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow:
    inset 0 0 20px rgba(108, 155, 255, 0.1),
    inset 0 0 40px rgba(168, 85, 247, 0.05);
  opacity: 0;
  transition: opacity 0.6s;
}

/* SVG mask for notch / Dynamic Island — replaces padding-based mask */
.agent-glow-border.has-notch-mask::before {
  mask: var(--notch-border-mask) center / 100% 100% no-repeat;
  -webkit-mask: var(--notch-border-mask) center / 100% 100% no-repeat;
  padding: 0;
}
.agent-glow-border.has-notch-mask::after {
  mask: var(--notch-border-mask) center / 100% 100% no-repeat;
  -webkit-mask: var(--notch-border-mask) center / 100% 100% no-repeat;
}

.agent-glow-border.active {
  opacity: 1;
  animation: glow-dim 30s ease forwards;
}
/* TEMPORARILY DISABLED: screen dimming behind glow border
@keyframes glow-dim {
  0%      { background: rgba(0, 0, 0, 0); }
  0.1%   { background: rgba(0, 0, 0, 0.1); }
  33%     { background: rgba(0, 0, 0, 0.1); }
  34%     { background: rgba(0, 0, 0, 0.3); }
  99%     { background: rgba(0, 0, 0, 0.3); }
  100%    { background: rgba(0, 0, 0, 0.7); }
} */
@keyframes glow-dim {
  0%   { background: transparent; }
  100% { background: transparent; }
}
.agent-glow-border.active::before {
  animation: glow-breathe 2.5s ease-in-out infinite;
}
.agent-glow-border.active::after {
  opacity: 1;
  animation: glow-inner-breathe 3s ease-in-out infinite;
}

@keyframes glow-breathe {
  0%, 100% { opacity: 0.6; filter: brightness(0.9); }
  50%      { opacity: 1;   filter: brightness(1.2); }
}
@keyframes glow-inner-breathe {
  0%, 100% { box-shadow: inset 0 0 15px rgba(108,155,255,0.08), inset 0 0 30px rgba(168,85,247,0.04); }
  50%      { box-shadow: inset 0 0 30px rgba(108,155,255,0.2), inset 0 0 60px rgba(168,85,247,0.1); }
}

/* Completion flash — green */
.agent-glow-border.flash-done {
  opacity: 1;
  animation: none;
}
.agent-glow-border.flash-done::before {
  background: #4caf50;
  filter: none;
  opacity: 1;
  animation: flash-done-fade 1.2s ease-out forwards;
}
.agent-glow-border.flash-done::after {
  opacity: 1;
  box-shadow:
    inset 0 0 30px rgba(76,175,80,0.3),
    inset 0 0 60px rgba(76,175,80,0.1);
  animation: flash-done-fade 1.2s ease-out forwards;
}
@keyframes flash-done-fade {
  0%   { opacity: 1; }
  40%  { opacity: 0.7; }
  100% { opacity: 0; }
}

/* Question flash — purple/amber pulse */
.agent-glow-border.flash-question {
  opacity: 1;
  animation: none;
}
.agent-glow-border.flash-question::before {
  background: linear-gradient(135deg, #a855f7, #f59e0b);
  filter: none;
  opacity: 1;
  animation: flash-question-pulse 2s ease-in-out 3;
}
.agent-glow-border.flash-question::after {
  opacity: 1;
  box-shadow:
    inset 0 0 30px rgba(168,85,247,0.3),
    inset 0 0 60px rgba(245,158,11,0.1);
  animation: flash-question-pulse 2s ease-in-out 3;
}
@keyframes flash-question-pulse {
  0%, 100% { opacity: 0.4; }
  50%      { opacity: 1; }
}

/* ══════════════════════════════════════════════════════════
   REDUCED MOTION
   ══════════════════════════════════════════════════════════ */

/* ══════════════════════════════════════════════════════════
   MOBILE BOTTOM TAB BAR
   ══════════════════════════════════════════════════════════ */

#mobile-tab-bar {
  display: flex;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--secondary-bg, #252540);
  border-top: 1px solid rgba(255,255,255,0.1);
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom, 0px));
  z-index: 100;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}
#mobile-tab-bar .tab-btn {
  flex: 1;
  display: flex; flex-direction: column; align-items: center;
  gap: 2px;
  font-size: 10px;
  color: var(--hint);
  background: none; border: none;
  cursor: pointer;
  padding: 2px 0;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s;
}
#mobile-tab-bar .tab-btn.active { color: var(--link); }
#mobile-tab-bar .tab-btn svg { width: 22px; height: 22px; }
#mobile-tab-bar .tab-btn span { font-weight: 500; }

/* Hide tab bar when IDE or driving mode is open */
body.ide-active #mobile-tab-bar,
body.driving-active #mobile-tab-bar { display: none !important; }

/* ── Mobile: chat view compact spacing ── */
@media (max-width: 959px) {
  /* Reduce horizontal padding on all messages */
  .chat-messages .msg {
    padding: 4px 12px;
  }

  /* User bubble — less left margin = wider bubble */
  .chat-messages .msg-user {
    padding: 8px 14px;
    margin: 8px 12px 8px 40px;
  }

  /* Agent text — tighter padding */
  .chat-messages .msg-text {
    padding: 8px 12px;
  }

  /* Tool use/result — reduce indentation */
  .chat-messages .msg-tool_use {
    padding: 6px 12px;
    margin-left: 12px;
  }
  .chat-messages .msg-tool_result {
    padding: 4px 12px 8px;
    margin-left: 12px;
  }

  /* Thinking — match tool indentation */
  .chat-messages .msg-thinking {
    padding: 4px 12px;
    margin-left: 12px;
  }

  /* Code blocks — smaller font, tighter padding */
  .chat-messages .msg code {
    font-size: 11px;
  }
  .chat-messages .msg pre {
    font-size: 11px;
    padding: 8px 10px;
  }

  /* Quick actions — tighter padding */
  .quick-actions {
    padding: 8px 12px;
  }
}

/* Mobile: offset content above tab bar */
@media (max-width: 959px) {
  /* Chat input bar — sits above tab bar */
  .chat-input-bar {
    padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px));
  }
  /* Chat action buttons (Выполнено, Отложить, etc.) */
  .chat-action-bar {
    padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px));
  }
  /* Scrollable screen content — add bottom padding so last items aren't hidden */
  #screen-dashboard,
  #screen-projects,
  #screen-settings,
  #screen-files {
    padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px));
  }
  /* New task: input bar above tab bar, body needs extra scroll room */
  .nt-input-bar {
    padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px));
  }
  .nt-body {
    padding-bottom: calc(140px + env(safe-area-inset-bottom, 0px));
  }
  /* Toast — above tab bar */
  .toast-container {
    bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  }
}

/* ══════════════════════════════════════════════════════════
   DESKTOP 3-PANEL LAYOUT (Beacon-style)
   ══════════════════════════════════════════════════════════ */

/* ── Mobile: hide desktop-only elements ── */
@media (max-width: 959px) {
  #desktop-sidebar { display: none !important; }
  #desktop-list-panel { display: none !important; }
  #desktop-layout { display: block; }
  #desktop-empty-state { display: none !important; }
}

/* ── Desktop layout ── */
@media (min-width: 960px) {

  /* 3-column grid */
  #desktop-layout {
    display: grid;
    grid-template-columns: 56px 300px 1fr;
    height: 100vh;
    overflow: hidden;
  }

  /* ── Sidebar ── */
  #desktop-sidebar {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: color-mix(in srgb, var(--bg) 85%, black);
    border-right: 1px solid var(--border);
    padding: 12px 0;
    overflow: hidden;
  }

  .sidebar-logo {
    margin-bottom: 20px;
    padding: 4px;
  }
  .sidebar-logo-img {
    width: 32px;
    height: 32px;
    border-radius: 8px;
  }

  .sidebar-nav {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    flex: 1;
  }

  .sidebar-btn {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: none;
    background: transparent;
    color: var(--hint);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
  }
  .sidebar-btn:hover {
    color: var(--text);
    background: rgba(255,255,255,0.06);
  }
  .sidebar-btn.active {
    color: var(--link);
    background: rgba(108,155,255,0.1);
  }

  .sidebar-bottom {
    margin-top: auto;
    padding-top: 8px;
  }
  .sidebar-author {
    display: block;
  }
  .sidebar-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    opacity: 0.6;
    transition: opacity 0.2s;
  }
  .sidebar-avatar:hover { opacity: 1; }

  /* ── List Panel ── */
  #desktop-list-panel {
    display: flex;
    flex-direction: column;
    background: var(--bg);
    border-right: 1px solid var(--border);
    overflow: hidden;
  }

  .dl-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px 16px 12px;
    flex-shrink: 0;
  }
  .dl-header-title {
    font-size: 16px;
    font-weight: 600;
    flex: 1;
  }
  .dl-badge {
    background: var(--success);
    color: white;
    font-size: 11px;
    font-weight: 600;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .dl-new-btn {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: none;
    background: rgba(108,155,255,0.1);
    color: var(--link);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
  }
  .dl-new-btn:hover { background: rgba(108,155,255,0.2); }

  .dl-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    padding: 0 16px;
    flex-shrink: 0;
  }
  .dl-tab {
    flex: 1;
    padding: 8px 0;
    text-align: center;
    font-size: 13px;
    font-weight: 500;
    color: var(--hint);
    cursor: pointer;
    border: none;
    background: none;
    border-bottom: 2px solid transparent;
    transition: all 0.15s;
  }
  .dl-tab:hover { color: var(--text); }
  .dl-tab.active {
    color: var(--link);
    border-bottom-color: var(--link);
  }

  .dl-projects {
    display: flex;
    gap: 6px;
    padding: 8px 16px;
    overflow-x: auto;
    scrollbar-width: none;
    flex-shrink: 0;
  }
  .dl-projects::-webkit-scrollbar { display: none; }
  .dl-projects:empty { display: none; }

  .dl-project-chip {
    flex-shrink: 0;
    padding: 4px 10px;
    border-radius: 12px;
    background: var(--secondary-bg);
    color: var(--hint);
    font-size: 11px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
  }
  .dl-project-chip:hover,
  .dl-project-chip.active {
    background: var(--button);
    color: var(--button-text);
    border-color: var(--button);
  }

  .dl-search {
    padding: 4px 12px 8px;
    flex-shrink: 0;
  }
  .dl-search input {
    width: 100%;
    padding: 7px 12px;
    border-radius: 18px;
    border: 1px solid rgba(255,255,255,0.08);
    background: var(--secondary-bg);
    color: var(--text);
    font-size: 12px;
    outline: none;
    font-family: inherit;
  }
  .dl-search input::placeholder { color: var(--hint); }
  .dl-search input:focus { border-color: rgba(255,255,255,0.15); }

  .dl-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
  }

  /* ── List items ── */
  .dl-item {
    padding: 10px 16px;
    cursor: pointer;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    transition: background 0.15s;
    border-left: 3px solid transparent;
  }
  .dl-item:hover { background: rgba(255,255,255,0.06); }
  .dl-item.active {
    background: rgba(108,155,255,0.08);
    border-left-color: var(--link);
  }
  .dl-item-top {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 3px;
  }
  .dl-item-project {
    font-size: 11px;
    font-weight: 600;
    color: var(--link);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .dl-item-model {
    font-size: 10px;
    color: var(--hint);
  }
  .dl-item-time {
    font-size: 10px;
    color: var(--hint);
    flex-shrink: 0;
  }
  .dl-item-task {
    font-size: 12px;
    color: var(--text);
    opacity: 0.85;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .dl-item-bottom {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
  }
  .dl-item-status {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 4px;
    letter-spacing: 0.02em;
  }
  .dl-item-status.s-running { background: rgba(76,175,80,0.12); color: var(--success); }
  .dl-item-status.s-waiting_input { background: rgba(108,155,255,0.12); color: var(--link); }
  .dl-item-status.s-completed { background: rgba(255,152,0,0.08); color: var(--warning); }
  .dl-item-status.s-done { background: rgba(76,175,80,0.08); color: var(--success); }
  .dl-item-status.s-failed { background: rgba(244,67,54,0.08); color: #f44336; }
  .dl-item-status.s-stopped { background: rgba(255,152,0,0.08); color: var(--warning); }
  .dl-item-status.s-cancelled { background: rgba(255,85,85,0.08); color: var(--destructive); }
  .dl-item-status.s-deferred { background: rgba(255,152,0,0.08); color: var(--warning); }
  .dl-item-cost {
    font-size: 10px;
    color: var(--hint);
    margin-left: auto;
    font-family: var(--font-mono);
    opacity: 0.8;
  }
  .dl-item-id {
    font-size: 10px;
    color: var(--hint);
    font-family: var(--font-mono);
    opacity: 0.7;
  }
  .dl-item-children {
    font-size: 10px;
    color: var(--link);
    margin-left: auto;
    opacity: 0.8;
  }

  /* ── Status dots ── */
  .dl-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
    background: var(--hint);
    opacity: 0.5;
  }
  .dl-running .dl-status-dot {
    background: var(--success);
    opacity: 1;
    box-shadow: 0 0 6px rgba(76,175,80,0.5);
    animation: dot-pulse 1.5s ease-in-out infinite;
  }
  .dl-paused .dl-status-dot {
    background: var(--warning);
    opacity: 0.8;
  }
  .dl-error .dl-status-dot {
    background: var(--destructive);
    opacity: 1;
  }
  .dl-interrupted .dl-status-dot {
    background: #ff9800;
    opacity: 1;
    box-shadow: 0 0 6px rgba(255,152,0,0.4);
  }
  .dl-draft .dl-status-dot {
    background: var(--link);
    opacity: 0.6;
  }

  @keyframes dot-pulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 6px rgba(76,175,80,0.5); }
    50% { opacity: 0.5; box-shadow: 0 0 2px rgba(76,175,80,0.2); }
  }

  /* ── Running item glow ── */
  .dl-item.dl-running {
    border-left-color: var(--success);
    background: rgba(76,175,80,0.04);
    animation: dl-item-glow 3s ease-in-out infinite;
  }
  @keyframes dl-item-glow {
    0%, 100% { box-shadow: inset 3px 0 8px -4px rgba(76,175,80,0.15); }
    50% { box-shadow: inset 3px 0 12px -4px rgba(76,175,80,0.3); }
  }
  .dl-item.dl-running:hover {
    background: rgba(76,175,80,0.08);
  }

  /* ── Interrupted item styling ── */
  .dl-item.dl-interrupted {
    border-left-color: #ff9800;
    background: rgba(255,152,0,0.06);
  }
  .dl-item.dl-interrupted:hover {
    background: rgba(255,152,0,0.1);
  }

  /* ── Paused/error item styling ── */
  .dl-item.dl-paused {
    opacity: 0.7;
  }
  .dl-item.dl-paused:hover {
    opacity: 1;
    background: rgba(255,152,0,0.06);
  }
  .dl-item.dl-error {
    border-left-color: transparent;
    opacity: 0.75;
  }
  .dl-item.dl-error:hover {
    opacity: 1;
    background: rgba(244,67,54,0.06);
  }
  .dl-item.dl-draft {
    opacity: 0.6;
  }
  .dl-item.dl-draft:hover {
    opacity: 1;
  }

  /* ── Section separator for paused group ── */
  .dl-item.dl-paused:first-of-type,
  .dl-item.dl-error:first-of-type {
    margin-top: 2px;
    border-top: 1px solid rgba(255,255,255,0.06);
  }

  .dl-empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--hint);
    font-size: 13px;
  }

  /* ── Main Panel ── */
  #desktop-main-panel {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    background: var(--bg);
  }

  /* Dashboard hidden on desktop — list panel replaces it */
  #screen-dashboard { display: none !important; }

  /* FABs and mobile tab bar hidden on desktop */
  .fab, .fab-driving { display: none !important; }
  #mobile-tab-bar { display: none !important; }

  /* Screens fill main panel — instant, no animation */
  #desktop-main-panel > .screen,
  #desktop-main-panel > .desktop-empty-state {
    height: 100%;
    overflow-y: auto;
    animation: none !important;
    transition: none !important;
    opacity: 1 !important;
    transform: none !important;
  }

  /* Chat fills main panel properly */
  #desktop-main-panel #screen-chat {
    height: 100%;
  }

  /* Fix position:fixed elements inside main panel */
  .nt-input-bar {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
  }

  /* Hide back buttons on desktop — sidebar handles navigation */
  #desktop-main-panel .form-header > .btn-icon:first-child { display: none; }
  #desktop-main-panel .chat-header > #btn-back { display: none; }

  /* Desktop empty state */
  .desktop-empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--hint);
    gap: 8px;
  }
  .des-empty-icon {
    opacity: 0.3;
    margin-bottom: 8px;
  }
  .desktop-empty-state p {
    font-size: 15px;
  }
  .des-empty-hint {
    font-size: 13px !important;
    opacity: 0.6;
  }

  /* Screen transitions disabled on desktop */
  .screen-exit,
  .screen-back {
    animation: none !important;
  }

  /* Pull-to-refresh disabled on desktop */
  .ptr-indicator { display: none !important; }

  /* Modals: center on desktop, not bottom-sheet */
  .modal-overlay {
    align-items: center;
  }
  .modal-content {
    border-radius: 16px;
    max-width: 600px;
  }

  /* Glow border stays full-viewport */

  /* Thin styled scrollbar for desktop */
  .dl-list,
  #desktop-main-panel > .screen {
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.12) transparent;
  }
  .dl-list::-webkit-scrollbar,
  #desktop-main-panel > .screen::-webkit-scrollbar {
    width: 6px;
  }
  .dl-list::-webkit-scrollbar-track,
  #desktop-main-panel > .screen::-webkit-scrollbar-track {
    background: transparent;
  }
  .dl-list::-webkit-scrollbar-thumb,
  #desktop-main-panel > .screen::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.12);
    border-radius: 3px;
  }
  .dl-list::-webkit-scrollbar-thumb:hover,
  #desktop-main-panel > .screen::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.2);
  }
}

/* ══════════════════════════════════════════════════════════
   DRIVING MODE
   ══════════════════════════════════════════════════════════ */

.screen-driving {
  position: fixed !important;
  inset: 0;
  background: #07070c;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  opacity: 0;
  transition: opacity 0.3s ease;
}
.screen-driving.drv-visible {
  opacity: 1;
}

/* ── Ambient gradient background ── */
.screen-driving::before {
  content: '';
  position: absolute;
  inset: -50%;
  width: 200%;
  height: 200%;
  z-index: 0;
  opacity: 0.5;
  filter: blur(120px);
  transition: opacity 0.8s ease;
  background:
    radial-gradient(ellipse at 20% 50%,
      var(--drv-c1, rgba(30, 50, 120, 0.8)) 0%,
      transparent 60%),
    radial-gradient(ellipse at 80% 20%,
      var(--drv-c2, rgba(80, 40, 140, 0.6)) 0%,
      transparent 55%),
    radial-gradient(ellipse at 60% 80%,
      var(--drv-c3, rgba(20, 80, 100, 0.5)) 0%,
      transparent 50%);
  animation: drv-gradient-drift 12s ease-in-out infinite alternate;
}
.screen-driving > * { position: relative; z-index: 1; }

/* State-based gradient colors via CSS vars */
.screen-driving.drv-state-running {
  --drv-c1: rgba(40, 60, 180, 0.8);
  --drv-c2: rgba(100, 50, 200, 0.6);
  --drv-c3: rgba(30, 100, 160, 0.5);
}
.screen-driving.drv-state-waiting {
  --drv-c1: rgba(180, 100, 20, 0.8);
  --drv-c2: rgba(200, 140, 40, 0.6);
  --drv-c3: rgba(160, 80, 30, 0.5);
}
.screen-driving.drv-state-completed {
  --drv-c1: rgba(30, 140, 60, 0.7);
  --drv-c2: rgba(40, 180, 100, 0.5);
  --drv-c3: rgba(20, 120, 80, 0.4);
}
.screen-driving.drv-state-error {
  --drv-c1: rgba(180, 30, 30, 0.8);
  --drv-c2: rgba(200, 50, 80, 0.6);
  --drv-c3: rgba(140, 20, 40, 0.5);
}
.screen-driving.drv-state-idle {
  --drv-c1: rgba(30, 30, 60, 0.5);
  --drv-c2: rgba(40, 30, 60, 0.3);
  --drv-c3: rgba(20, 30, 50, 0.3);
}

@keyframes drv-gradient-drift {
  0% { transform: translate(-5%, -5%) rotate(0deg); }
  33% { transform: translate(5%, 3%) rotate(3deg); }
  66% { transform: translate(-3%, 5%) rotate(-2deg); }
  100% { transform: translate(4%, -4%) rotate(1deg); }
}

/* ── Status bar ── */
.drv-status-bar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px 0;
  position: relative;
  flex-shrink: 0;
}

.drv-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.drv-status-dot.idle { background: var(--hint, #8a8a9a); }
.drv-status-dot.running {
  background: var(--success, #4caf50);
  animation: drv-dot-pulse 1.5s ease-in-out infinite;
}
.drv-status-dot.completed { background: var(--warning, #ff9800); }
.drv-status-dot.waiting {
  background: var(--warning, #ff9800);
  animation: drv-dot-pulse 2s ease-in-out infinite;
}
.drv-status-dot.error { background: var(--destructive, #ff5555); }

@keyframes drv-dot-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(1.4); }
}

.drv-status-text {
  font-size: 13px;
  color: rgba(255,255,255,0.45);
  font-weight: 500;
  letter-spacing: 0.02em;
}

.drv-exit-btn {
  position: absolute;
  right: 16px;
  top: 8px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s;
}
.drv-exit-btn:active { background: rgba(255,255,255,0.12); }

/* ── Refresh button ── */
.drv-refresh-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: all 0.2s ease;
  flex-shrink: 0;
}
.drv-refresh-btn:hover { background: rgba(255,255,255,0.2); color: white; }
.drv-refresh-btn:active { background: rgba(255,255,255,0.15); transform: scale(0.92); }
.drv-refresh-btn:disabled { opacity: 0.5; cursor: default; pointer-events: none; }
.drv-refresh-btn.spinning svg { animation: drv-spin 0.8s linear infinite; }

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

/* ── Stop button ── */
.drv-stop-btn {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: none;
  background: rgba(255, 85, 85, 0.15);
  color: #ff5555;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.drv-stop-btn:active { transform: translateY(-50%) scale(0.9); }
.drv-stop-btn:hover { background: rgba(255, 85, 85, 0.25); }

/* ── Agent Bar ── */
.drv-agent-bar {
  width: 100%;
  display: flex;
  gap: 8px;
  padding: 6px 16px;
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
  justify-content: safe center;
}
.drv-agent-bar::-webkit-scrollbar { display: none; }
.drv-agent-bar:empty { display: none; }

.drv-agent-chip {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 20px;
  background: rgba(255,255,255,0.06);
  border: 1.5px solid transparent;
  color: rgba(255,255,255,0.5);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  max-width: 220px;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.drv-chip-task {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  min-width: 0;
}
.drv-agent-chip.focused {
  background: rgba(108, 155, 255, 0.15);
  border-color: rgba(108, 155, 255, 0.5);
  color: rgba(255,255,255,0.9);
}
.drv-agent-chip.needs-attention {
  animation: drv-chip-pulse 2s ease-in-out infinite;
}
@keyframes drv-chip-pulse {
  0%, 100% { border-color: transparent; }
  50% { border-color: var(--warning, #ff9800); }
}
.drv-agent-chip.focused.needs-attention { animation: none; }
.drv-agent-chip.tts-playing {
  border-color: rgba(108, 155, 255, 0.5);
  background: rgba(108, 155, 255, 0.12);
}
.drv-chip-speaker {
  font-size: 14px;
  animation: drv-speaker-pulse 1s ease-in-out infinite;
  cursor: pointer;
  flex-shrink: 0;
}
@keyframes drv-speaker-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.drv-chip-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.drv-chip-dot.draft { background: var(--link, #6c9bff); animation: drv-dot-pulse 2s ease-in-out infinite; }
.drv-chip-dot.running { background: var(--success, #4caf50); }
.drv-chip-dot.waiting { background: var(--warning, #ff9800); animation: drv-dot-pulse 2s ease-in-out infinite; }
.drv-chip-dot.completed { background: var(--warning, #ff9800); }
.drv-chip-dot.idle { background: var(--hint, #8a8a9a); }
.drv-chip-dot.error { background: var(--destructive, #ff5555); }

.drv-chip-project {
  font-size: 10px;
  text-transform: uppercase;
  opacity: 0.7;
  letter-spacing: 0.5px;
  font-weight: 600;
  color: rgba(108, 155, 255, 0.85);
}

/* ── Karaoke ── */
.drv-karaoke-wrap {
  position: relative;
  flex: 1 1 auto;
  width: 100%;
  max-width: 420px;
  margin-top: auto;
  display: flex;
  min-height: 0;
}
.drv-karaoke {
  flex: 1 1 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  padding: 16px 24px;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
  mask-image: linear-gradient(to bottom, transparent 0%, black 15%, black 100%);
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 15%, black 100%);
}

.drv-line {
  width: 100%;
  text-align: left;
  padding: 8px 0;
  font-size: 14px;
  line-height: 1.5;
  color: rgba(255,255,255,0.25);
  transition: opacity 0.4s ease, transform 0.4s ease, color 0.4s ease;
  word-break: break-word;
}
/* status/thinking/error lines are centered; tool_use shows full detail left-aligned */
.drv-line[data-type="thinking"],
.drv-line[data-type="status"],
.drv-line[data-type="error"] {
  text-align: center;
}

.drv-line.active {
  font-size: 16px;
  color: rgba(255,255,255,0.95);
  opacity: 1;
}
.drv-line.active[data-type="thinking"],
.drv-line.active[data-type="status"] {
  font-weight: 600;
}

/* HTML content inside text/plan lines */
.drv-line b, .drv-line strong { font-weight: 600; }
.drv-line i, .drv-line em { font-style: italic; opacity: 0.85; }
.drv-line code {
  font-family: 'SF Mono', 'Menlo', monospace;
  font-size: 0.88em;
  background: rgba(255,255,255,0.08);
  padding: 1px 5px;
  border-radius: 4px;
}
.drv-line pre {
  background: rgba(255,255,255,0.06);
  padding: 8px 10px;
  border-radius: 6px;
  overflow-x: auto;
  font-size: 13px;
  margin: 6px 0;
}
.drv-line pre code {
  background: none;
  padding: 0;
}
.drv-line a {
  color: var(--link, #6c9bff);
  text-decoration: none;
}
.drv-line ul, .drv-line ol {
  padding-left: 20px;
  margin: 4px 0;
}
.drv-line p { margin: 4px 0; }
.drv-line p:first-child { margin-top: 0; }
.drv-line p:last-child { margin-bottom: 0; }

.drv-line.past {
  font-size: 13px;
  color: rgba(255,255,255,0.2);
}
/* When agent is completed, make past lines readable for result review */
.drv-state-completed .drv-line.past {
  color: rgba(255,255,255,0.55);
  font-size: 14px;
}

.drv-line.far {
  opacity: 0.1;
  font-size: 12px;
}

.drv-line.exit {
  opacity: 0;
  transform: translateY(-16px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.drv-line[data-type="user_message"] {
  color: var(--link, #6c9bff);
}
.drv-line[data-type="user_message"].past {
  color: rgba(108, 155, 255, 0.3);
}

.drv-line[data-type="status"].active {
  color: var(--success, #4caf50);
}

.drv-line[data-type="error"].active {
  color: var(--destructive, #ff5555);
}

@keyframes drv-line-enter {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
.drv-line.entering {
  animation: drv-line-enter 0.35s ease-out;
}

/* ── Question bar (SDK question options / tool approval in driving mode) ── */
.drv-question-bar {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  padding: 0 20px 8px;
  flex-shrink: 0;
  animation: drv-line-enter 0.35s ease-out;
}
.drv-q-option {
  padding: 8px 16px;
  border-radius: 20px;
  border: 1.5px solid rgba(108, 155, 255, 0.35);
  background: rgba(108, 155, 255, 0.1);
  color: rgba(255,255,255,0.9);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  backdrop-filter: blur(8px);
}
.drv-q-option:active { transform: scale(0.95); }
.drv-q-option:hover { background: rgba(108, 155, 255, 0.2); }
.drv-q-option:disabled { opacity: 0.5; pointer-events: none; }

/* ── Resolve bar (Done/Defer/Cancel for completed agents) ── */
.drv-resolve-bar {
  display: flex;
  gap: 12px;
  justify-content: center;
  padding: 0 20px 8px;
  flex-shrink: 0;
  animation: drv-line-enter 0.35s ease-out;
}
.drv-resolve-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.8);
  cursor: pointer;
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  backdrop-filter: blur(8px);
}
.drv-resolve-btn:active { transform: scale(0.95); }
.drv-resolve-btn.done {
  border-color: rgba(76, 175, 80, 0.4);
  background: rgba(76, 175, 80, 0.12);
  color: #4caf50;
}
.drv-resolve-btn.done:hover { background: rgba(76, 175, 80, 0.22); }
.drv-resolve-btn.deferred {
  border-color: rgba(255, 193, 7, 0.3);
  background: rgba(255, 193, 7, 0.08);
  color: rgba(255, 193, 7, 0.85);
}
.drv-resolve-btn.deferred:hover { background: rgba(255, 193, 7, 0.18); }
.drv-resolve-btn.cancelled {
  border-color: rgba(255, 85, 85, 0.3);
  background: rgba(255, 85, 85, 0.08);
  color: rgba(255, 85, 85, 0.85);
}
.drv-resolve-btn.cancelled:hover { background: rgba(255, 85, 85, 0.18); }
.drv-resolve-btn.launch {
  border-color: rgba(108, 155, 255, 0.5);
  background: rgba(108, 155, 255, 0.15);
  color: rgba(108, 155, 255, 0.95);
  width: 56px;
  height: 56px;
}
.drv-resolve-btn.launch:hover { background: rgba(108, 155, 255, 0.25); }
.drv-resolve-btn.tts {
  border-color: rgba(108, 155, 255, 0.35);
  background: rgba(108, 155, 255, 0.1);
  color: rgba(108, 155, 255, 0.9);
}
.drv-resolve-btn.tts:hover { background: rgba(108, 155, 255, 0.2); }
.drv-resolve-btn.tts.playing {
  background: rgba(108, 155, 255, 0.25);
  border-color: rgba(108, 155, 255, 0.6);
  animation: drv-tts-pulse 1.5s ease-in-out infinite;
}
@keyframes drv-tts-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(108, 155, 255, 0.3); }
  50% { box-shadow: 0 0 12px 4px rgba(108, 155, 255, 0.15); }
}

/* ── Mic button ── */
.drv-mic-area {
  position: relative;
  flex-shrink: 0;
  margin-top: auto;
  padding-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 320px;
  height: 200px;
}

/* ── Add task button (far right of mic, subtle) ── */
.drv-add-btn {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: none;
  color: rgba(255,255,255,0.3);
  font-size: 28px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
  transition: color 0.2s, transform 0.2s, opacity 0.25s;
  -webkit-tap-highlight-color: transparent;
}
.drv-add-btn:active { transform: translateY(-50%) scale(0.9); }
.drv-add-btn:hover { color: rgba(255,255,255,0.5); }
.drv-add-btn.hidden { opacity: 0; pointer-events: none; }

/* ── Cancel button (far left, shown during new-task recording) ── */
.drv-cancel-btn {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.6);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, background 0.2s, transform 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.drv-cancel-btn.visible { opacity: 1; pointer-events: auto; }
.drv-cancel-btn:active { transform: translateY(-50%) scale(0.9); }
.drv-cancel-btn:hover { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.3); }

/* ── New-task overlay (blurs karaoke, shows live text) ── */
.drv-karaoke.blurred { filter: blur(8px) brightness(0.4); transition: filter 0.3s ease; }

.drv-newtask-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.drv-newtask-overlay.visible { opacity: 1; pointer-events: auto; }

.drv-newtask-text {
  font-size: 18px;
  font-weight: 500;
  color: rgba(255,255,255,0.9);
  text-align: center;
  line-height: 1.6;
  max-width: 320px;
  word-break: break-word;
}
.drv-newtask-hint {
  font-size: 13px;
  color: rgba(255,255,255,0.4);
  margin-top: 12px;
}

.drv-project-picker {
  display: none;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
  max-width: 340px;
}
.drv-project-picker.visible { display: flex; }

.drv-project-chip {
  padding: 8px 16px;
  border-radius: 20px;
  border: 1.5px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.8);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.drv-project-chip:active { transform: scale(0.93); }
.drv-project-chip:hover { background: rgba(255,255,255,0.14); border-color: rgba(255,255,255,0.3); }
.drv-project-chip.suggested {
  border-color: rgba(99,179,237,0.5);
  background: rgba(99,179,237,0.12);
  color: rgba(255,255,255,0.95);
}
.drv-project-chip.suggested:hover { background: rgba(99,179,237,0.22); border-color: rgba(99,179,237,0.7); }
.drv-picker-divider {
  width: 100%;
  height: 1px;
  background: rgba(255,255,255,0.1);
  margin: 4px 0;
}

/* Waveform canvas behind mic — centered on mic button */
.drv-wave-canvas {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1;
  pointer-events: none;
}

.drv-mic-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: none;
  background: var(--success, #4caf50);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  z-index: 2;
  transition: transform 0.15s, background 0.2s, box-shadow 0.3s, width 0.3s, height 0.3s;
  box-shadow: 0 4px 28px rgba(76, 175, 80, 0.35);
  -webkit-tap-highlight-color: transparent;
}
.drv-mic-btn:active {
  transform: scale(0.92);
}

/* Mic contextual states */
.drv-mic-btn.dimmed {
  opacity: 0.3;
  transform: scale(0.7);
  background: rgba(255,255,255,0.1);
  box-shadow: none;
}
.drv-mic-btn.waiting {
  background: var(--warning, #ff9800);
  box-shadow: 0 4px 28px rgba(255, 152, 0, 0.4);
  animation: drv-mic-waiting 2s ease-in-out infinite;
}
@keyframes drv-mic-waiting {
  0%, 100% { box-shadow: 0 4px 28px rgba(255, 152, 0, 0.4); }
  50% { box-shadow: 0 4px 36px rgba(255, 152, 0, 0.6); }
}

.drv-mic-btn.recording {
  background: var(--destructive, #ff5555);
  box-shadow: 0 4px 28px rgba(255, 85, 85, 0.4);
  animation: drv-mic-pulse 1.2s ease-in-out infinite;
}
.drv-mic-btn.recording.newtask {
  width: 88px;
  height: 88px;
}

.drv-mic-btn.processing {
  background: var(--button, #5b6eae);
  box-shadow: 0 4px 28px rgba(91, 110, 174, 0.35);
  animation: drv-mic-spin 1s linear infinite, drv-mic-pulse 1.4s ease-in-out infinite;
}

@keyframes drv-mic-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

@keyframes drv-mic-spin {
  from { box-shadow: 0 4px 28px rgba(91, 110, 174, 0.35); }
  50% { box-shadow: 0 4px 36px rgba(130, 100, 220, 0.5); }
  to { box-shadow: 0 4px 28px rgba(91, 110, 174, 0.35); }
}

/* Ring expanding behind mic during recording */
.drv-mic-ring {
  position: absolute;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 2px solid rgba(255, 85, 85, 0.25);
  opacity: 0;
  z-index: 1;
  pointer-events: none;
}
.drv-mic-ring.active {
  animation: drv-ring-expand 1.5s ease-out infinite;
}

@keyframes drv-ring-expand {
  0% { transform: scale(1); opacity: 0.5; }
  100% { transform: scale(2); opacity: 0; }
}

/* Processing ring — pulsing sonar ripple */
.drv-mic-ring.processing {
  opacity: 1;
  border: none;
  animation: drv-ring-sonar 2s ease-out infinite;
}
@keyframes drv-ring-sonar {
  0% {
    transform: scale(1);
    box-shadow:
      0 0 0 0 rgba(108, 155, 255, 0.4),
      0 0 0 0 rgba(130, 100, 220, 0.25),
      0 0 0 0 rgba(108, 155, 255, 0.15);
  }
  100% {
    transform: scale(1);
    box-shadow:
      0 0 0 20px rgba(108, 155, 255, 0),
      0 0 0 40px rgba(130, 100, 220, 0),
      0 0 0 60px rgba(108, 155, 255, 0);
  }
}

/* ── Driving mode: desktop wide layout ── */
@media (min-width: 960px) {
  .drv-karaoke-wrap { max-width: 860px; }
  .drv-line { font-size: 16px; }
  .drv-line.active { font-size: 18px; }
  .drv-line.past { font-size: 15px; }
  .drv-state-completed .drv-line.past { font-size: 16px; }
  .drv-mic-area { max-width: 400px; }
  .drv-newtask-text { max-width: 500px; }
  .drv-project-picker { max-width: 500px; }
  .drv-agent-chip { max-width: 280px; }
}

/* ══════════════════════════════════════════════════════════ */

/* ── MCP Servers ─────────────────────────────────── */

.mcp-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.mcp-card:hover { border-color: var(--accent); }
.mcp-card.mcp-disabled { opacity: 0.5; }
.mcp-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.mcp-type-badge {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--bg-secondary, #1a1a1a);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.mcp-card-desc {
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.3;
}
.mcp-card-detail {
  font-size: 12px;
  margin-top: 4px;
  font-family: monospace;
}

/* Project edit: MCP checkboxes */
.pe-section { margin-top: 16px; }
.pe-checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 0;
  font-size: 13px;
  line-height: 1.4;
  cursor: pointer;
}
.pe-checkbox-label.muted { opacity: 0.5; }
.pe-checkbox-label input[type="checkbox"] {
  margin-top: 2px;
  flex-shrink: 0;
}

/* Project edit: Skills */
.pe-skill-pkg {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: 13px;
}
.btn-sm {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
}
.btn-sm:hover { border-color: var(--accent); color: var(--text); }
.btn-sm.btn-danger { color: var(--danger, #e44); border-color: var(--danger, #e44); }
.btn-sm.btn-secondary { color: var(--accent); border-color: var(--accent); }

/* New task: MCP chips bar */
.nt-preset-bar {
  padding: 0 16px;
  margin-top: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.nt-preset-bar::-webkit-scrollbar { display: none; }
.nt-preset-bar .nt-chips { flex-wrap: nowrap; }
.nt-preset-hint {
  font-size: 11px;
  color: var(--link);
  padding: 3px 0 0 2px;
  opacity: 0.8;
}

.nt-mcp-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  margin-top: 4px;
}
.nt-mcp-label {
  font-size: 12px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

/* ── Advanced SDK Settings (new task) ── */
.nt-advanced {
  padding: 0 16px;
  margin-top: 6px;
}
.nt-advanced-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--hint);
  cursor: pointer;
  user-select: none;
  padding: 4px 0;
}
.nt-advanced-arrow {
  font-size: 9px;
  display: inline-block;
  transition: transform 0.15s;
}
.nt-advanced.expanded .nt-advanced-arrow {
  transform: rotate(90deg);
}
.nt-advanced-body {
  display: none;
  padding: 8px 0 4px;
}
.nt-advanced.expanded .nt-advanced-body {
  display: block;
}
.nt-adv-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.nt-adv-label {
  font-size: 12px;
  color: var(--text-secondary);
  min-width: 90px;
  flex-shrink: 0;
}
.nt-adv-input {
  width: 100px;
  padding: 5px 8px;
  border-radius: 8px;
  border: 1.5px solid rgba(255,255,255,0.08);
  background: var(--secondary-bg);
  color: var(--text);
  font-size: 12px;
  font-family: inherit;
  outline: none;
}
.nt-adv-input:focus {
  border-color: var(--link);
}
.nt-adv-input::placeholder {
  color: var(--hint);
}
/* Number input spinner styling */
.nt-adv-input::-webkit-inner-spin-button {
  opacity: 0.5;
}

/* Settings: link row */
.st-row-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  padding: 10px 0;
}
.st-row-link:hover .st-row-label { color: var(--accent); }
.st-row-arrow { color: var(--text-secondary); font-size: 16px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── Skills Dropdown ─────────────────────────────── */
.skills-dropdown {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  max-height: 420px;
  overflow-y: auto;
  background: #1a1d2e;
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 6px;
  box-shadow: 0 -8px 30px rgba(0,0,0,.5);
  z-index: 300;
}
.sd-section-label {
  padding: 8px 14px 4px;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  opacity: .7;
}
.skills-dropdown-item {
  padding: 9px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background .15s;
}
.skills-dropdown-item:hover,
.skills-dropdown-item.active {
  background: var(--bg-hover);
}
.skills-dropdown-item.selected {
  opacity: .6;
}
.skills-dropdown-item .sd-icon {
  font-size: 1.1rem;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}
.skills-dropdown-item .sd-body {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  flex: 1;
}
.skills-dropdown-item .sd-name {
  font-weight: 600;
  font-size: .88rem;
  color: var(--text);
}
.skills-dropdown-item .sd-desc {
  font-size: .76rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.skills-dropdown-item .sd-check {
  color: var(--accent);
  font-weight: 700;
  font-size: .9rem;
  margin-left: auto;
  flex-shrink: 0;
}
.skills-dropdown-empty {
  padding: 14px;
  text-align: center;
  color: var(--text-muted);
  font-size: .85rem;
}

/* Skills bar (selected skill tags) */
.nt-skills-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 16px;
}
.nt-skill-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--accent);
  color: #fff;
  font-size: .78rem;
  font-weight: 600;
  padding: 3px 8px 3px 8px;
  border-radius: 12px;
  white-space: nowrap;
}
.nt-skill-tag-icon {
  font-size: .85rem;
}
.nt-skill-tag-x {
  cursor: pointer;
  opacity: .7;
  font-size: .85rem;
  line-height: 1;
  padding: 0 2px;
  transition: opacity .15s;
}
.nt-skill-tag-x:hover { opacity: 1; }

/* ── Preset Suggestions Overlay ────────────────────── */
.nt-preset-suggest {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 72px;
  z-index: 60;
  animation: psSlideUp .2s ease;
}
@keyframes psSlideUp { from { transform: translateY(12px); opacity: 0 } to { transform: translateY(0); opacity: 1 } }

.ps-content {
  background: var(--secondary-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 14px 12px;
  box-shadow: 0 -4px 24px rgba(0,0,0,.35);
}

.ps-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
}

.ps-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.ps-chips .nt-chip {
  position: relative;
}
.ps-reason {
  display: block;
  font-size: .68rem;
  font-weight: 400;
  color: var(--hint);
  margin-top: 2px;
  line-height: 1.2;
  max-width: 140px;
  white-space: normal;
}
.ps-chips .nt-chip.active .ps-reason {
  color: rgba(255,255,255,.7);
}

.ps-actions {
  display: flex;
  gap: 10px;
}
.ps-btn {
  flex: 1;
  padding: 10px 0;
  border: none;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s;
}
.ps-btn:active { opacity: .7; }
.ps-btn-run {
  background: var(--button);
  color: var(--button-text);
}
.ps-btn-skip {
  background: var(--border);
  color: var(--hint);
}
