:root {
  --bg: #ffffff;
  --sidebar-bg: #f9f9f9;
  --border: #e5e5e5;
  --text: #0d0d0d;
  --text-muted: #6b6b6b;
  --hover: #ececec;
  --primary: #0d0d0d;
  --primary-fg: #ffffff;
  --radius: 12px;
  --sidebar-width: 260px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
}

a { color: inherit; text-decoration: none; }

/* Login */
.login-body { background: #f3f3f3; min-height: 100vh; }
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  background: var(--bg);
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 4px 24px rgba(0,0,0,.08);
}
.login-brand { margin: 0 0 4px; font-size: 28px; font-weight: 600; }
.login-subtitle { margin: 0 0 24px; color: var(--text-muted); }
.login-hint { margin-top: 20px; font-size: 13px; color: var(--text-muted); text-align: center; }

.field-label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; }
.field-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 15px;
}
.field-input:focus { outline: 2px solid #b4b4b4; border-color: transparent; }

/* App shell */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}

.sidebar-top { padding: 8px; }

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  text-align: left;
  color: var(--text);
}
.sidebar-item:hover { background: var(--hover); }
.sidebar-item-primary { font-weight: 500; }
.sidebar-item-disabled { opacity: .45; cursor: default; pointer-events: none; }
.sidebar-item .icon { width: 18px; text-align: center; opacity: .7; }

.sidebar-search {
  width: calc(100% - 16px);
  margin: 4px 8px 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
}
.sidebar-search.hidden { display: none; }

.sidebar-section {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 0 8px;
}
.sidebar-section-title {
  font-size: 12px;
  color: var(--text-muted);
  padding: 8px 12px 4px;
}
.sidebar-recents {
  overflow-y: auto;
  flex: 1;
}
.sidebar-recent-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 2px;
  border-radius: 8px;
}
.sidebar-recent-row:hover,
.sidebar-recent-row.active { background: var(--hover); }
.sidebar-recent-row:hover .sidebar-recent-menu-btn,
.sidebar-recent-row:focus-within .sidebar-recent-menu-btn,
.sidebar-recent-row.menu-open .sidebar-recent-menu-btn {
  opacity: 1;
}

.sidebar-recent-link {
  flex: 1;
  min-width: 0;
  display: block;
  padding: 8px 4px 8px 12px;
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-recent-link:hover { text-decoration: none; }

.sidebar-recent-menu-btn {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  margin-right: 4px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease;
}
.sidebar-recent-menu-btn:hover,
.sidebar-recent-menu-btn[aria-expanded="true"] {
  background: rgba(0, 0, 0, 0.06);
  color: var(--text);
}

.sidebar-recent-dropdown {
  position: absolute;
  top: calc(100% + 2px);
  right: 4px;
  min-width: 140px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  padding: 4px;
  z-index: 20;
}
.sidebar-recent-dropdown.hidden { display: none; }

.sidebar-delete-form { margin: 0; }
.sidebar-recent-delete {
  display: block;
  width: 100%;
  padding: 8px 12px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #dc2626;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
.sidebar-recent-delete:hover { background: #fee2e2; }

.sidebar-empty { padding: 8px 12px; font-size: 13px; color: var(--text-muted); }

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.user-chip { display: flex; align-items: center; gap: 8px; min-width: 0; }
.user-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: #c4c4c4;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600;
}
.user-name {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-toggle {
  display: none;
  position: fixed;
  top: 12px; left: 12px;
  z-index: 20;
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
}

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

.main-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid transparent;
}
.main-brand {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}
.chevron { font-size: 12px; opacity: .5; }
.icon-btn {
  border: none;
  background: transparent;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
}
.icon-btn:hover { background: var(--hover); }

.main-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
}

.hero-title {
  font-size: 28px;
  font-weight: 500;
  margin: 0 0 24px;
  text-align: center;
}

.hero-input-wrap { width: 100%; }
.hero-input {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 28px;
  padding: 12px 16px;
  box-shadow: 0 2px 12px rgba(0,0,0,.06);
  background: var(--bg);
}
.hero-input-plus { opacity: .5; font-size: 18px; }
.hero-input-field {
  flex: 1;
  border: none;
  font-size: 16px;
  outline: none;
  background: transparent;
  cursor: pointer;
}
.hero-input-mic { opacity: .4; }
.hero-input-send {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: var(--primary-fg);
  cursor: pointer;
  font-size: 12px;
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 20px;
}
.chip {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 13px;
  background: var(--bg);
}
.chip:hover { background: var(--hover); }
.chip-disabled { opacity: .4; pointer-events: none; }

/* Intake */
.intake-panel { width: 100%; }
.intake-panel h2 { margin-top: 0; }
.intake-form textarea, .intake-form input[type="text"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 12px;
  font-family: inherit;
  font-size: 14px;
}
.intake-form label { font-size: 13px; font-weight: 500; }
.intake-back-link {
  display: block;
  text-align: center;
  margin-top: 12px;
}

/* Workspace */
.workspace-panel { position: relative; }
.workspace-content {
  flex: 1;
  overflow-y: auto;
  padding: 0 24px 48px;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}
.workspace-content--wide {
  max-width: min(1180px, calc(100vw - var(--sidebar-width) - 48px));
  padding: 0 36px 56px;
}
.workspace-hero { margin-bottom: 24px; }
.workspace-hero h2 { margin: 0 0 8px; font-size: 26px; font-weight: 600; letter-spacing: -.02em; }
.workspace-intake-preview {
  display: grid;
  gap: 12px;
  margin-top: 12px;
  max-width: 720px;
}
.workspace-intake-item {
  padding: 12px 14px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid #e8ecf1;
}
.workspace-intake-item strong {
  display: block;
  font-size: 13px;
  color: #475569;
  margin-bottom: 6px;
}
.workspace-intake-item p {
  margin: 0;
  font-size: 15px;
  line-height: 1.6;
  color: #334155;
}
.workspace-content--wide .workspace-hero h2 { font-size: 28px; }
.workspace-content--wide .workspace-hero p { font-size: 16px; line-height: 1.6; max-width: 720px; }
.workspace-card {
  background: #fafafa;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.workspace-card h3 { margin: 0 0 12px; font-size: 16px; }
.workspace-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.discovery-question { font-size: 16px; line-height: 1.5; margin-bottom: 16px; }

.text-muted { color: var(--text-muted); font-size: 14px; }
.text-success { color: #0a7; }

.progress-tree { font-size: 14px; }
.progress-node { margin-bottom: 16px; }
.progress-node-header { margin-bottom: 8px; }
.progress-steps { list-style: none; margin: 0; padding-left: 20px; }
.progress-step { margin: 4px 0; }

/* Global loader */
.global-loader {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(6px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}
.global-loader.hidden { display: none; }
.global-loader-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px 36px;
  min-width: min(420px, 92vw);
  box-shadow: 0 16px 48px rgba(0,0,0,.12);
  text-align: center;
}
.loader-ring {
  width: 52px;
  height: 52px;
  margin: 0 auto 14px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(37,99,235,.12), rgba(168,85,247,.08));
  display: flex;
  align-items: center;
  justify-content: center;
}
.loader-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid #e5e7eb;
  border-top-color: #2563eb;
  border-right-color: #a855f7;
  border-radius: 50%;
  animation: spin 0.85s linear infinite;
}
.loader-text { margin: 0; font-size: 15px; font-weight: 600; color: var(--text); }
.loader-subtext {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.45;
}
.loader-subtext.hidden { display: none; }
.loader-progress-wrap {
  margin-top: 16px;
  text-align: left;
}
.loader-progress-wrap.hidden { display: none; }
.loader-progress-track {
  height: 6px;
  background: #eef2f7;
  border-radius: 999px;
  overflow: hidden;
}
.loader-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #2563eb, #22c55e);
  border-radius: 999px;
  transition: width .4s ease;
}
.loader-progress-label {
  display: block;
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-muted);
}
.loader-stage-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-top: 14px;
}
.loader-stage-chips.hidden { display: none; }
.loader-chip {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 4px 10px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #64748b;
}
.loader-chip.on {
  background: rgba(37,99,235,.12);
  color: #1d4ed8;
}
@keyframes spin { to { transform: rotate(360deg); } }

body.orchestrator-running .global-loader:not(.hidden),
body.orchestrator-running #global-loader { display: flex; }

.alert-auto-dismiss { transition: opacity 0.4s ease; }
.alert-auto-dismiss.is-hiding { opacity: 0; }

.status-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #9ca3af;
  flex-shrink: 0;
}
.status-pending { background: #9ca3af; }
.status-blocked { background: #d1d5db; }
.status-ready { background: #2563eb; }
.status-running { background: #f59e0b; }
.status-completed { background: #16a34a; }
.status-waiting_for_user { background: #7c3aed; }
.status-failed { background: #dc2626; }

.status-pill {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: capitalize;
  flex-shrink: 0;
}
.status-pill-pending { background: #f3f4f6; color: #6b7280; }
.status-pill-ready { background: #dbeafe; color: #1d4ed8; }
.status-pill-running { background: #fef3c7; color: #b45309; }
.status-pill-completed { background: #dcfce7; color: #15803d; }
.status-pill-waiting_for_user { background: #ede9fe; color: #6d28d9; }
.status-pill-blocked { background: #f3f4f6; color: #9ca3af; }
.status-pill-failed { background: #fee2e2; color: #b91c1c; }
.status-pill-done, .status-pill-completed { background: #dcfce7; color: #15803d; }
.status-pill-expanded { background: #f3e8ff; color: #7e22ce; }
.status-pill-reducing { background: #ccfbf1; color: #0f766e; }

.progress-step-ready .step-name { font-weight: 600; }
.progress-step-completed .step-name { color: #15803d; }
.progress-step-running .step-name { color: #b45309; }

.step-link {
  display: flex;
  align-items: center;
  gap: 8px;
  border: none;
  background: none;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 13px;
  text-align: left;
  width: 100%;
}
.step-link .step-name { flex: 1; }

.badge {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 12px;
  background: #e5e5e5;
}
.badge-audit { background: #dbeafe; color: #1e40af; }

/* Artifact drawer */
.artifact-drawer {
  position: fixed;
  top: 0; right: 0;
  width: min(560px, 100vw);
  height: 100vh;
  background: var(--bg);
  border-left: 1px solid var(--border);
  box-shadow: -4px 0 24px rgba(0,0,0,.08);
  z-index: 30;
  display: flex;
  flex-direction: column;
}
.artifact-drawer.hidden { display: none; }
.artifact-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.artifact-drawer-header h3 { margin: 0; font-size: 16px; }
.artifact-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
  font-size: 15px;
  line-height: 1.7;
}
.artifact-drawer-body h1 { font-size: 24px; margin-top: 0; }
.artifact-drawer-body h2 { font-size: 20px; margin-top: 1.5em; }
.artifact-drawer-body p { margin: 0 0 1em; color: #334155; }
.artifact-drawer-body pre { white-space: pre-wrap; word-break: break-word; }

/* Buttons */
.btn-primary, .btn-secondary, .btn-ghost {
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
}
.btn-primary { background: var(--primary); color: var(--primary-fg); }
.btn-primary:hover { opacity: .9; }
.btn-secondary { background: var(--bg); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--hover); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-full { width: 100%; margin-top: 8px; }
.btn-sm { padding: 6px 10px; font-size: 12px; }

.messages { padding: 0 20px; }
.alert {
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 8px;
  font-size: 14px;
}
.alert-error, .alert-error { background: #fee2e2; color: #991b1b; }
.alert-success { background: #dcfce7; color: #166534; }
.alert-info { background: #e0f2fe; color: #075985; }

/* Plan engine live view */
:root {
  --s-pending: #94a3b8;
  --s-ready: #3b82f6;
  --s-running: #f59e0b;
  --s-expanded: #a855f7;
  --s-reducing: #14b8a6;
  --s-await: #ef4444;
  --s-done: #22c55e;
}

.plan-hitl {
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid var(--s-await);
  background: rgba(239, 68, 68, .06);
  border-radius: 10px;
}
.plan-hitl h5 { margin: 0 0 6px; font-size: 13px; color: #b91c1c; }
.plan-hitl.hidden { display: none; }

/* Plan workspace — thread feed (AI cofounder style) */
.plan-workspace {
  margin-bottom: 24px;
}
.plan-hero {
  position: relative;
  margin-bottom: 24px;
  padding: 18px 22px;
  border-radius: 14px;
  overflow: hidden;
}
.plan-hero--light {
  background: linear-gradient(180deg, #f8fafc 0%, #fff 100%);
  border: 1px solid #e8ecf1;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .04);
}
.plan-hero-glow { display: none; }
.plan-hero-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}
.plan-hero-title { display: none; }
.plan-hero-sub {
  margin: 6px 0 0;
  font-size: 15px;
  color: #475569;
  max-width: none;
  line-height: 1.6;
}
.plan-phase-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  padding: 4px 10px;
  border-radius: 999px;
  background: #e2e8f0;
  color: #475569;
}
.plan-phase-badge--running {
  background: #fef3c7;
  color: #b45309;
}
.plan-phase-badge--done {
  background: #dcfce7;
  color: #15803d;
}
.plan-phase-badge--active {
  background: #dbeafe;
  color: #1d4ed8;
}
.plan-phase-badge--locked {
  background: #f1f5f9;
  color: #64748b;
}
.plan-hero-stats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.plan-stat {
  min-width: 64px;
  padding: 8px 12px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid #e2e8f0;
  text-align: center;
}
.plan-stat--active { border-color: #93c5fd; background: #eff6ff; }
.plan-stat-value {
  display: block;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.1;
  color: #0f172a;
}
.plan-stat-label {
  display: block;
  margin-top: 2px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #94a3b8;
}
.plan-progress-track {
  margin-top: 14px;
  height: 3px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}
.plan-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #3b82f6, #10b981);
  border-radius: 999px;
  transition: width .5s ease;
}
.plan-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.plan-view-toggle {
  display: inline-flex;
  padding: 3px;
  background: #f1f5f9;
  border-radius: 10px;
  gap: 2px;
}
.plan-view-btn {
  border: none;
  background: transparent;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: .2s;
}
.plan-view-btn.active {
  background: var(--bg);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
}
.plan-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.inline-form { display: inline; margin: 0; }
.plan-view-panel.hidden { display: none; }

/* Plan accordion structure view */
.plan-accordion-hint {
  margin: 0 0 16px;
  font-size: 14px;
}
.plan-accordion { width: 100%; }
.acc-root {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.acc-empty {
  padding: 40px 24px;
  text-align: center;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 14px;
}
.acc-item {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  overflow: hidden;
  transition: border-color .2s, box-shadow .2s;
}
.acc-item--pillar {
  border-color: #cbd5e1;
  box-shadow: 0 1px 4px rgba(15, 23, 42, .04);
}
.acc-item--phase {
  border-left: 3px solid #3b82f6;
}
.acc-item--phase-locked {
  opacity: .82;
  border-left-color: #cbd5e1;
  background: #f8fafc;
}
.acc-item--summary {
  border-color: #86efac;
  background: linear-gradient(180deg, #f0fdf4, #fff);
}
.acc-item.is-open { border-color: #93c5fd; }
.acc-item.is-active { box-shadow: 0 0 0 1px rgba(59, 130, 246, .2); }
.acc-item.is-running { border-color: #fcd34d; }
.acc-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  cursor: default;
}
.acc-item--branch .acc-header { cursor: pointer; }
.acc-toggle {
  border: none;
  background: #f1f5f9;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  cursor: pointer;
  color: #475569;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.acc-toggle:hover { background: #e2e8f0; }
.acc-spacer { width: 28px; flex-shrink: 0; }
.acc-chevron {
  display: inline-block;
  transition: transform .2s;
  font-size: 12px;
}
.acc-item.is-open .acc-chevron { transform: rotate(90deg); }
.acc-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.acc-heading {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.acc-title {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.35;
  color: #0f172a;
}
.acc-item--leaf .acc-title { font-size: 14px; }
.acc-role {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #64748b;
}
.acc-read-btn {
  border: none;
  background: #f1f5f9;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  color: #2563eb;
  flex-shrink: 0;
  font-size: 14px;
}
.acc-read-btn:hover { background: #dbeafe; }
.acc-body {
  padding: 0 16px 16px 54px;
  border-top: 1px solid #f1f5f9;
}
.acc-body.hidden { display: none; }
.acc-objective {
  margin: 14px 0 0;
  font-size: 15px;
  line-height: 1.65;
  color: #64748b;
}
.acc-insight {
  margin-top: 12px;
  padding: 12px 14px;
  background: #f8fafc;
  border-left: 3px solid #3b82f6;
  border-radius: 0 8px 8px 0;
}
.acc-insight--summary {
  border-left-color: #10b981;
  background: #ecfdf5;
}
.acc-insight-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: #64748b;
  margin-bottom: 6px;
}
.acc-insight p {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
  color: #334155;
}
.acc-status-msg {
  margin: 12px 0 0;
  font-size: 13px;
  color: #b45309;
}
.acc-status-msg--locked {
  color: #94a3b8;
  font-style: italic;
}
.acc-read-inline { margin-top: 12px; }
.acc-children {
  margin-top: 12px;
  padding-left: 12px;
  border-left: 2px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.acc-item--leaf .acc-body {
  padding-left: 54px;
  padding-top: 0;
  border-top: none;
}
.acc-depth-1 { margin-left: 0; }
.acc-depth-2 .acc-title { font-size: 13px; }

.plan-views--split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 480px);
  gap: 24px;
  align-items: start;
}
.plan-views--split #plan-thread-view,
.plan-views--split #plan-accordion-view {
  min-width: 0;
}
.plan-views--split #plan-accordion-view {
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
}
.plan-views--split .plan-accordion-hint { display: none; }
.plan-views--accordion #plan-accordion-view {
  width: 100%;
}

.plan-views--json #plan-json-view {
  width: 100%;
}
.plan-json-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.plan-json-hint {
  margin: 0;
  font-size: 0.9rem;
}
.plan-json-pre {
  margin: 0;
  padding: 14px 16px;
  max-height: calc(100vh - 220px);
  overflow: auto;
  border-radius: 10px;
  border: 1px solid #dbe3ee;
  background: #0f172a;
  color: #e2e8f0;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre;
}
.plan-json-pre code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  color: inherit;
  background: transparent;
  padding: 0;
  white-space: inherit;
}

/* Thread feed */
.plan-thread { width: 100%; }
.thread-feed {
  display: flex;
  flex-direction: column;
  gap: 0;
  position: relative;
  padding-left: 28px;
}
.thread-feed::before {
  content: '';
  position: absolute;
  left: 9px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: linear-gradient(180deg, #cbd5e1 0%, #e2e8f0 50%, #cbd5e1 100%);
  border-radius: 999px;
}
.thread-empty {
  padding: 48px 24px;
  text-align: center;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 14px;
}
.thread-empty p { margin: 0 0 8px; font-size: 16px; }

.thread-context {
  margin-bottom: 20px;
  padding: 16px 18px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  position: relative;
}
.thread-context-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #64748b;
  margin-bottom: 10px;
}
.thread-context-chips {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}
.thread-context-chip {
  padding: 12px 14px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
}
.thread-context-chip strong {
  display: block;
  font-size: 13px;
  margin-bottom: 6px;
  color: #334155;
}
.thread-context-chip p {
  margin: 0;
  font-size: 14px;
  line-height: 1.55;
  color: #64748b;
}

.thread-card {
  position: relative;
  margin-bottom: 20px;
}
.thread-card::before {
  content: '';
  position: absolute;
  left: -24px;
  top: 22px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid #94a3b8;
  z-index: 1;
}
.thread-card.is-running::before {
  border-color: #f59e0b;
  box-shadow: 0 0 0 4px rgba(245, 158, 11, .15);
}
.thread-card--pillar::before { border-color: #3b82f6; background: #eff6ff; }
.thread-card--lifecycle-phase::before { border-color: #2563eb; background: #eff6ff; }
.thread-card--phase-locked::before { border-color: #cbd5e1; background: #f8fafc; }
.thread-card--phase-locked .thread-card-inner {
  background: #f8fafc;
}
.thread-card--summary::before { border-color: #10b981; background: #ecfdf5; }
.thread-card-inner {
  background: #fff;
  border: 1px solid #e8ecf1;
  border-radius: 14px;
  padding: 22px 24px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, .04);
  transition: box-shadow .2s, border-color .2s;
}
.thread-card--pillar .thread-card-inner {
  padding: 24px 28px;
}
.thread-card:hover .thread-card-inner {
  border-color: #cbd5e1;
  box-shadow: 0 4px 16px rgba(15, 23, 42, .06);
}
.thread-card.is-active .thread-card-inner {
  border-color: #93c5fd;
  box-shadow: 0 0 0 1px rgba(59, 130, 246, .15);
}
.thread-card-head { margin-bottom: 12px; }
.thread-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.thread-agent-badge {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 4px 10px;
  border-radius: 999px;
  background: #eff6ff;
  color: #1d4ed8;
}
.thread-agent-badge--summary {
  background: #ecfdf5;
  color: #047857;
}
.thread-agent-badge--phase {
  background: #dbeafe;
  color: #1d4ed8;
}
.thread-title {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -.02em;
  color: #0f172a;
}
.thread-card--deliverable .thread-title {
  font-size: 16px;
}
.thread-objective {
  margin: 10px 0 0;
  font-size: 15px;
  line-height: 1.65;
  color: #64748b;
}
.thread-insight {
  margin: 16px 0;
  padding: 14px 16px 14px 18px;
  background: #f8fafc;
  border-left: 3px solid #3b82f6;
  border-radius: 0 10px 10px 0;
}
.thread-insight--summary {
  border-left-color: #10b981;
  background: #f0fdf4;
}
.thread-insight-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: #64748b;
  margin-bottom: 6px;
}
.thread-insight-text {
  margin: 0;
  font-size: 15px;
  line-height: 1.65;
  color: #334155;
}
.thread-status-msg {
  margin: 12px 0 0;
  font-size: 14px;
  color: #b45309;
}
.thread-status-msg--muted { color: #94a3b8; }
.thread-status-msg--locked {
  color: #94a3b8;
  font-style: italic;
}
.thread-card-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid #f1f5f9;
}
.thread-expand-btn {
  border: 1px solid #e2e8f0;
  background: #fff;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  color: #475569;
  cursor: pointer;
  transition: .15s;
}
.thread-expand-btn:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}
.thread-read-btn {
  border: none;
  background: transparent;
  padding: 8px 4px;
  font-size: 14px;
  font-weight: 600;
  color: #2563eb;
  cursor: pointer;
  transition: .15s;
}
.thread-read-btn:hover {
  color: #1d4ed8;
  text-decoration: underline;
}
.thread-children {
  margin-top: 14px;
  padding-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.thread-children-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #64748b;
}
.thread-children.hidden { display: none; }
.thread-card--deliverable .thread-card-inner {
  padding: 16px 18px;
  background: #fafbfc;
  border-style: dashed;
  box-shadow: none;
}
.thread-card--deliverable::before {
  width: 8px;
  height: 8px;
  left: -22px;
  top: 18px;
  border-width: 2px;
}

.plan-clarify.hidden { display: none; }
  display: flex;
  gap: 14px;
  padding: 16px;
  margin-bottom: 16px;
  border-radius: 12px;
  border: 1px solid #c4b5fd;
  background: linear-gradient(135deg, #faf5ff, #eef2ff);
}
.plan-clarify.hidden { display: none; }
.plan-clarify-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #7c3aed;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
}
.plan-clarify-body { flex: 1; }
.plan-clarify-body h4 { margin: 0 0 10px; font-size: 15px; }
.plan-clarify-body .field-input { margin-bottom: 10px; }

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.status-dot.status-pending, .status-pending { background: var(--s-pending); }
.status-dot.status-ready, .status-ready { background: var(--s-ready); }
.status-dot.status-running, .status-running { background: var(--s-running); }
.status-dot.status-expanded, .status-expanded { background: var(--s-expanded); }
.status-dot.status-reducing, .status-reducing { background: var(--s-reducing); }
.status-dot.status-awaiting_approval, .status-awaiting_approval { background: var(--s-await); }
.status-dot.status-done, .status-done, .status-dot.status-completed, .status-completed { background: var(--s-done); }
.status-dot.status-failed, .status-failed { background: var(--s-await); }

@media (max-width: 768px) {
  .workspace-content--wide {
    max-width: 100%;
    padding: 0 16px 32px;
  }
  .plan-views--split {
    grid-template-columns: 1fr;
  }
  .plan-views--split #plan-accordion-view {
    position: static;
    max-height: none;
  }
  .plan-node-inspector {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    transform: translateX(-100%);
    transition: transform .2s;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-toggle { display: block; }
  .sidebar-recent-menu-btn { opacity: 1; }
}
