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

:root {
  --bg: #fafaf9;
  --surface: #ffffff;
  --surface-2: #f5f5f4;
  --surface-3: #e7e5e4;
  --border: #d6d3d1;
  --border-subtle: #e7e5e4;
  --text: #1c1917;
  --text-2: #44403c;
  --text-3: #78716c;
  --text-4: #a8a29e;
  --accent: #c2410c;
  --accent-soft: rgba(194,65,12,0.08);
  --accent-hover: #9a3412;
  --green: #16a34a;
  --green-soft: rgba(22,163,74,0.1);
  --green-border: rgba(22,163,74,0.25);
  --amber: #d97706;
  --amber-soft: rgba(217,119,6,0.1);
  --amber-border: rgba(217,119,6,0.25);
  --red: #dc2626;
  --red-soft: rgba(220,38,38,0.08);
  --red-border: rgba(220,38,38,0.25);
  --blue: #2563eb;
  --blue-soft: rgba(37,99,235,0.08);
  --mono: 'JetBrains Mono', ui-monospace, 'Cascadia Code', 'Fira Code', monospace;
  --sans: 'DM Sans', system-ui, -apple-system, sans-serif;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.08);
  --transition: 0.15s ease;
}

:root[data-theme="dark"] {
  --bg: #0c0a09;
  --surface: #1c1917;
  --surface-2: #292524;
  --surface-3: #3f3a36;
  --border: #44403c;
  --border-subtle: #292524;
  --text: #fafaf9;
  --text-2: #d6d3d1;
  --text-3: #a8a29e;
  --text-4: #78716c;
  --accent: #f97316;
  --accent-soft: rgba(249,115,22,0.1);
  --accent-hover: #fb923c;
  --green: #4ade80;
  --green-soft: rgba(74,222,128,0.1);
  --green-border: rgba(74,222,128,0.2);
  --amber: #fbbf24;
  --amber-soft: rgba(251,191,36,0.1);
  --amber-border: rgba(251,191,36,0.2);
  --red: #f87171;
  --red-soft: rgba(248,113,113,0.08);
  --red-border: rgba(248,113,113,0.2);
  --blue: #60a5fa;
  --blue-soft: rgba(96,165,250,0.1);
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
  --shadow: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.4);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; }
html, body { min-height: 100vh; min-height: 100dvh; overflow: hidden; position: fixed; width: 100%; }
body {
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ---- Layout ---- */
.ad-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 320px;
  min-height: 100vh;
  overflow-x: hidden;
}

.ad-sidebar {
  border-right: 1px solid var(--border);
  background: var(--surface);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.ad-main {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-height: 100vh;
  background: var(--bg);
  min-width: 0;
  overflow: hidden;
}

.ad-detail {
  border-left: 1px solid var(--border);
  background: var(--surface);
  overflow-y: auto;
  min-width: 0;
}

/* ---- Sidebar ---- */
.ad-header {
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.ad-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.ad-header h1 {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-top: 8px;
}

.ad-header .ad-subtle {
  margin-top: 4px;
  font-size: 12px;
}

.ad-breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-4);
}

.ad-breadcrumb-link {
  color: var(--text-3);
  text-decoration: none;
}

.ad-breadcrumb-link:hover { color: var(--accent); }

.ad-breadcrumb-sep { color: var(--text-4); }

.ad-breadcrumb-current {
  color: var(--text);
  font-weight: 600;
}

.ad-back {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-3);
  text-decoration: none;
  letter-spacing: 0.02em;
}
.ad-back:hover { color: var(--accent); }

.ad-theme-btn {
  all: unset;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-4);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius);
  transition: var(--transition);
  letter-spacing: 0.03em;
}
.ad-theme-btn:hover {
  color: var(--text-2);
  background: var(--surface-2);
}

/* Autonomy badge */
.ad-autonomy {
  margin: 12px 16px 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 4px 10px;
  background: var(--surface-2);
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
}

.ad-autonomy-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
}

/* Stats strip */
.ad-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  margin: 12px 16px 0;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  overflow: hidden;
}

.ad-stat {
  padding: 10px 8px;
  text-align: center;
  border-right: 1px solid var(--border-subtle);
}
.ad-stat:last-child { border-right: 0; }

.ad-stat-value {
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.ad-stat-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-4);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 2px;
}

/* Sidebar sections */
.ad-section {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.ad-section-title {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-4);
  margin-bottom: 8px;
}

/* Agent cards */
.ad-agent-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
  margin-bottom: 2px;
}
.ad-agent-card:hover { background: var(--surface-2); }
.ad-agent-card.is-selected {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.ad-child-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  background: var(--surface);
  margin-bottom: 8px;
  transition: var(--transition);
}

.ad-child-link:hover {
  border-color: var(--accent);
  background: var(--surface-2);
}

.ad-child-meta {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-3);
}

.ad-child-arrow {
  color: var(--text-4);
  font-weight: 700;
}

.ad-agent-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
  font-weight: 700;
  font-family: var(--mono);
}

.ad-agent-avatar.manager { background: var(--blue-soft); color: var(--blue); }
.ad-agent-avatar.creator { background: var(--accent-soft); color: var(--accent); }
.ad-agent-avatar.researcher { background: var(--green-soft); color: var(--green); }
.ad-agent-avatar.analyst { background: var(--amber-soft); color: var(--amber); }

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

.ad-agent-name {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ad-agent-meta {
  font-size: 12px;
  color: var(--text-4);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ad-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.ad-status-dot.idle { background: var(--green); }
.ad-status-dot.running {
  background: var(--amber);
  animation: adPulse 1.4s infinite ease-in-out;
}

@keyframes adPulse {
  0%, 100% { opacity: 0.4; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.2); }
}

/* Schedule cards */
.ad-sched-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 12px;
}

.ad-sched-row strong {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
}

.ad-sched-note { color: var(--text-4); font-size: 12px; }

/* Toggle switch */
.ad-toggle {
  position: relative;
  width: 32px;
  height: 18px;
  cursor: pointer;
}
.ad-toggle input { display: none; }
.ad-toggle-track {
  position: absolute;
  inset: 0;
  background: var(--surface-3);
  border-radius: 999px;
  transition: var(--transition);
}
.ad-toggle input:checked + .ad-toggle-track {
  background: var(--green);
}
.ad-toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: white;
  border-radius: 50%;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}
.ad-toggle input:checked ~ .ad-toggle-thumb {
  left: 16px;
}

/* Pending review */
.ad-review-card {
  padding: 8px 10px;
  border-radius: var(--radius);
  background: var(--amber-soft);
  border: 1px solid var(--amber-border);
  margin-bottom: 6px;
}

.ad-review-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.ad-review-name {
  font-size: 12px;
  font-weight: 600;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ad-review-id {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-4);
  margin-top: 2px;
}

.ad-review-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

/* Buttons */
.ad-btn {
  all: unset;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  white-space: nowrap;
}
.ad-btn:hover {
  background: var(--surface-2);
  border-color: var(--text-4);
}
.ad-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.ad-btn-primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.ad-btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.ad-btn-danger {
  color: var(--red);
  border-color: var(--red-border);
  background: var(--red-soft);
}
.ad-btn-danger:hover {
  background: var(--red);
  color: white;
  border-color: var(--red);
}

.ad-btn-sm {
  font-size: 12px;
  padding: 4px 8px;
}

.ad-btn-approve {
  background: var(--green);
  color: white;
  border-color: var(--green);
}
.ad-btn-approve:hover {
  background: var(--green);
  opacity: 0.9;
}

/* ---- Main chat area ---- */
.ad-main-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-wrap: wrap;
}

.ad-main-header h2 {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.ad-main-path {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-4);
}

.ad-main-controls {
  display: flex;
  gap: 6px;
  align-items: center;
}

/* Status bar */
.ad-status-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 20px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--surface-2);
  font-size: 12px;
}

.ad-status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
}
.ad-status-indicator.ready { color: var(--green); }
.ad-status-indicator.working { color: var(--amber); }

.ad-status-detail {
  color: var(--text-4);
  font-size: 12px;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Chat messages */
.ad-chat-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}

.ad-messages {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ad-chat-trace {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 4px 0 8px 20px;
  padding-left: 12px;
  border-left: 2px dashed var(--border-subtle);
}

.ad-trace-entry {
  max-width: 88%;
  padding: 8px 10px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-sm);
  font-size: 13px;
}

.ad-trace-entry.running {
  border-color: var(--amber-border);
  background: var(--amber-soft);
}

.ad-trace-entry.done {
  border-color: var(--green-border);
  background: var(--green-soft);
}

.ad-trace-entry.error {
  border-color: var(--red-border);
  background: var(--red-soft);
}

.ad-trace-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.ad-trace-label {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}

.ad-trace-metrics {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-4);
}

.ad-trace-detail {
  margin-top: 4px;
  color: var(--text-2);
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.ad-trace-summary {
  margin-top: 6px;
  color: var(--text-3);
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.ad-message {
  max-width: 85%;
  font-size: 15px;
  line-height: 1.55;
  animation: adFadeIn 0.2s ease;
}

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

.ad-message.user {
  align-self: flex-end;
  background: var(--accent);
  color: white;
  border-radius: var(--radius-lg) var(--radius-lg) 4px var(--radius-lg);
  padding: 8px 12px;
}

.ad-message.assistant {
  align-self: flex-start;
  padding: 2px 0 2px 20px;
  border-left: 2px solid var(--accent);
}

.ad-message.system {
  align-self: center;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-4);
  padding: 4px 12px;
  background: var(--surface-2);
  border-radius: var(--radius);
}

.ad-message-body {
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* Markdown in messages */
.ad-message-body code {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 4px;
}
.ad-message.user .ad-message-body code {
  background: rgba(255,255,255,0.15);
}

.ad-message-body pre {
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 8px 10px;
  margin: 6px 0;
  overflow-x: auto;
  font-size: 12px;
}
.ad-message-body pre code {
  background: none;
  padding: 0;
}

.ad-message-body strong { font-weight: 700; }
.ad-message-body em { font-style: italic; }

.ad-message-body ul, .ad-message-body ol {
  padding-left: 18px;
  margin: 4px 0;
}

.ad-typing-inline {
  display: flex;
  align-items: center;
  gap: 3px;
  margin-bottom: 6px;
}

.ad-typing-inline .ad-typing-dot {
  width: 5px;
  height: 5px;
}

/* Typing indicator */
.ad-typing {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 20px;
  border-left: 2px solid var(--accent);
  animation: adFadeIn 0.2s ease;
}

.ad-typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-4);
  animation: adTypingBounce 1.4s infinite ease-in-out;
}
.ad-typing-dot:nth-child(2) { animation-delay: 0.15s; }
.ad-typing-dot:nth-child(3) { animation-delay: 0.3s; }

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

.ad-empty {
  font-size: 12px;
  color: var(--text-4);
  padding: 20px 0;
  text-align: center;
}

/* Composer */
.ad-composer {
  padding: 12px 20px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.ad-composer-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.ad-hidden-input {
  display: none;
}

.ad-composer-input {
  flex: 1;
  min-width: 0;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  color: var(--text);
  resize: none;
  min-height: 38px;
  max-height: 160px;
  overflow-y: auto;
  transition: border-color var(--transition);
}
.ad-composer-input:focus {
  outline: none;
  border-color: var(--accent);
}
.ad-composer-input::placeholder {
  color: var(--text-4);
}

.ad-send-btn {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: var(--radius-lg);
}

.ad-audio-btn {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: var(--radius-lg);
}

.ad-audio-btn.is-recording {
  background: var(--red-soft);
  color: var(--red);
  border-color: var(--red-border);
}

.ad-composer-note {
  margin-top: 6px;
  min-height: 16px;
  font-size: 12px;
  color: var(--text-4);
  line-height: 1.35;
}

.ad-send-icon {
  width: 16px;
  height: 16px;
}

/* ---- Detail panel ---- */
.ad-detail-section {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.ad-detail-title {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-4);
  margin-bottom: 10px;
}

/* Agent detail header */
.ad-detail-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ad-detail-header-info { flex: 1; }

.ad-detail-name {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 700;
}

.ad-detail-meta {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 2px;
}

/* Detail stats */
.ad-detail-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.ad-detail-stat {
  padding: 8px;
  background: var(--surface-2);
  border-radius: var(--radius);
  border: 1px solid var(--border-subtle);
}

.ad-detail-stat-value {
  font-family: var(--mono);
  font-size: 16px;
  font-weight: 700;
}

.ad-detail-stat-label {
  font-size: 12px;
  color: var(--text-4);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 2px;
}

/* Skills */
.ad-skill-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  padding: 4px 8px;
  background: var(--blue-soft);
  color: var(--blue);
  border-radius: 999px;
  border: 1px solid rgba(37,99,235,0.15);
  margin: 0 4px 4px 0;
}

/* File browser */
.ad-file-tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 8px;
}

.ad-file-tab {
  all: unset;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 5px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text-4);
  transition: var(--transition);
}
.ad-file-tab:hover { color: var(--text-2); background: var(--surface-2); }
.ad-file-tab.is-active {
  color: var(--accent);
  background: var(--accent-soft);
}

.ad-file-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.ad-file-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  transition: var(--transition);
}
.ad-file-row:hover { background: var(--surface-2); }
.ad-file-row.is-active {
  background: var(--accent-soft);
  color: var(--accent);
}

.ad-file-icon {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-4);
  flex-shrink: 0;
  width: 14px;
  text-align: center;
}

.ad-file-name {
  font-family: var(--mono);
  font-size: 12px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ad-file-size {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-4);
  flex-shrink: 0;
}

/* File viewer */
.ad-file-viewer {
  margin-top: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  overflow: hidden;
}

.ad-file-viewer-path {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-4);
  padding: 6px 10px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--surface);
}

.ad-file-viewer pre {
  margin: 0;
  padding: 10px;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.55;
  max-height: 400px;
  overflow-y: auto;
  color: var(--text-2);
}

.ad-preview-image {
  max-width: 100%;
  display: block;
}

/* Activity timeline */
.ad-timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
  position: relative;
  padding-left: 16px;
  max-height: 280px;
  overflow-y: auto;
  padding-right: 6px;
}

.ad-timeline::before {
  content: '';
  position: absolute;
  left: 4px;
  top: 6px;
  bottom: 6px;
  width: 1px;
  background: var(--border);
}

.ad-timeline-item {
  position: relative;
  padding: 4px 0 4px 8px;
  font-size: 12px;
  line-height: 1.4;
}

.ad-timeline-item::before {
  content: '';
  position: absolute;
  left: -13px;
  top: 10px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--border);
  border: 2px solid var(--surface);
}

.ad-timeline-item.running::before { background: var(--amber); }
.ad-timeline-item.done::before { background: var(--green); }
.ad-timeline-item.error::before { background: var(--red); }

.ad-timeline-label {
  font-weight: 600;
  font-size: 12px;
}

.ad-timeline-detail {
  color: var(--text-4);
  font-size: 12px;
}

/* Loading */
.ad-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-4);
  letter-spacing: 0.04em;
}

/* Badges */
.ad-badge {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  letter-spacing: 0.03em;
}
.ad-badge.success { color: var(--green); background: var(--green-soft); }
.ad-badge.warning { color: var(--amber); background: var(--amber-soft); }
.ad-badge.danger { color: var(--red); background: var(--red-soft); }

/* Mobile */
.ad-mobile-tabs { display: none; }

@media (max-width: 1100px) {
  .ad-mobile-tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    padding: 8px 12px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
  }

  .ad-mobile-tab {
    all: unset;
    font-family: var(--mono);
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    padding: 6px;
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--text-3);
    transition: var(--transition);
  }
  .ad-mobile-tab.is-active {
    color: var(--accent);
    background: var(--accent-soft);
  }

  .ad-mobile-tab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 16px;
    height: 16px;
    font-size: 12px;
    background: var(--accent);
    color: white;
    border-radius: 999px;
    padding: 0 4px;
    margin-left: 4px;
  }

  #agent-app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }

  .ad-mobile-tabs {
    flex-shrink: 0;
    position: static;
  }

  .ad-drawer-container { flex-shrink: 0; }

  .ad-shell {
    grid-template-columns: 1fr;
    min-height: 0;
    flex: 1;
    overflow: hidden;
  }

  .ad-main {
    height: auto;
    max-height: none;
    min-height: 0;
    flex: 1;
  }

  .ad-sidebar, .ad-detail { border-right: 0; border-left: 0; overflow-y: auto; }

  .ad-shell.ad-mobile-view-overview .ad-pane-chat,
  .ad-shell.ad-mobile-view-overview .ad-pane-files,
  .ad-shell.ad-mobile-view-chat .ad-pane-overview,
  .ad-shell.ad-mobile-view-chat .ad-pane-files,
  .ad-shell.ad-mobile-view-files .ad-pane-overview,
  .ad-shell.ad-mobile-view-files .ad-pane-chat { display: none; }

  .ad-chat-trace {
    margin-left: 12px;
    padding-left: 10px;
    gap: 6px;
  }

  .ad-trace-entry {
    max-width: 100%;
    padding: 7px 8px;
    font-size: 12px;
  }

  .ad-composer {
    padding: 10px 12px 12px;
  }

  .ad-composer-row {
    gap: 6px;
  }

  .ad-audio-btn,
  .ad-send-btn {
    width: 34px;
    height: 34px;
  }

  .ad-composer-input {
    min-height: 34px;
    padding: 7px 10px;
    font-size: 14px;
  }

  .ad-composer-note {
    margin-top: 4px;
    font-size: 11px;
  }
}

/* Scrollbar styling */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-4); }

/* Hamburger button — hidden on desktop, shown on mobile */
.ad-hamburger {
  all: unset;
  display: none;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text-2);
  flex-shrink: 0;
  transition: var(--transition);
}
.ad-hamburger:hover { background: var(--surface-2); color: var(--accent); }

/* Agent drawer — slide-in from left on mobile */
.ad-drawer-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 90;
}

.ad-drawer {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 280px;
  max-width: 80vw;
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 100;
  overflow-y: auto;
  padding: 0 12px 16px;
  animation: adDrawerSlideIn 0.2s ease;
  box-shadow: var(--shadow-lg);
}

.ad-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 4px 10px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 8px;
}

.ad-drawer-title {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-3);
}

.ad-drawer-close {
  all: unset;
  font-size: 20px;
  line-height: 1;
  color: var(--text-3);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius);
}
.ad-drawer-close:hover { background: var(--surface-2); color: var(--text); }

.ad-drawer-org-link {
  display: block;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-3);
  text-decoration: none;
  padding: 8px 10px;
  border-radius: var(--radius);
  margin-bottom: 6px;
  border: 1px solid var(--border-subtle);
}
.ad-drawer-org-link:hover { color: var(--accent); border-color: var(--accent); }

.ad-drawer-section-title {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-4);
  padding: 10px 4px 4px;
}

@keyframes adDrawerSlideIn {
  from { transform: translateX(-100%); }
  to { transform: translateX(0); }
}

@media (max-width: 1100px) {
  .ad-hamburger { display: flex; }
  .ad-drawer-backdrop { display: block; }
  .ad-drawer { display: block; }
}

/* Subtle */
.ad-subtle { color: var(--text-3); }
.ad-meta { color: var(--text-4); }
