/* Three-panel chat UI */

:root {
  --bg: #f0f2f5;
  --surface: #ffffff;
  --border: #e4e6eb;
  --text: #1c1e21;
  --text-muted: #65676b;
  --accent: #1877f2;
  --accent-hover: #166fe5;
  --user-bubble: #1877f2;
  --assistant-bubble: #e4e6eb;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --header-h: 48px;
  --panel-width: 260px;
  --panel-collapsed: 40px;
  --transition-speed: 0.25s;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg) url('/static/bg.png') no-repeat center center fixed;
  background-size: cover;
}

/* ================================================================
   APP SHELL  –  full viewport, column: header + workspace
   ================================================================ */
.app {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ================================================================
   HEADER
   ================================================================ */
.header {
  height: var(--header-h);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0 1rem;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  z-index: 200;
}

.logo {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}

.header-sep {
  width: 1px;
  height: 22px;
  background: var(--border);
  flex-shrink: 0;
}

.header-spacer { flex: 1; }

/* ---- View dropdown ---- */
.main-nav {
  display: flex;
  align-items: center;
}

.nav-dropdown { position: relative; }

.nav-dropdown-trigger {
  display: inline-flex;
  align-items: center;
  background: transparent;
  border: 1px solid transparent;
  padding: 0.3rem 0.65rem;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.15s;
}
.nav-dropdown-trigger:hover,
.nav-dropdown.open .nav-dropdown-trigger {
  background: rgba(0, 0, 0, 0.06);
  border-color: var(--border);
  color: var(--text);
}

.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
  min-width: 170px;
  padding: 4px;
  z-index: 500;
}
.nav-dropdown.open .nav-dropdown-menu { display: block; }

.nav-dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.45rem 0.7rem;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.88rem;
  color: var(--text);
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.12s;
}
.nav-dropdown-item:hover:not(:disabled) {
  background: rgba(0, 0, 0, 0.05);
}
.nav-dropdown-item:disabled {
  color: var(--text-muted);
  opacity: 0.45;
  cursor: default;
}

.menu-check {
  display: inline-block;
  width: 16px;
  font-size: 0.8rem;
  color: var(--accent);
}
.nav-dropdown-item:disabled .menu-check { visibility: visible; }
.nav-dropdown-item:not(:disabled) .menu-check { visibility: hidden; }

/* ---- Focus button ---- */
.focus-btn {
  display: inline-flex;
  align-items: center;
  background: transparent;
  border: 1px solid var(--border);
  padding: 0.3rem 0.65rem;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.15s;
  white-space: nowrap;
}
.focus-btn:hover {
  background: rgba(0, 0, 0, 0.06);
  color: var(--text);
}
.focus-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ---- User bar ---- */
.user-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
}

.logout-btn {
  padding: 0.25rem 0.6rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s;
}
.logout-btn:hover {
  background: var(--bg);
  color: var(--text);
}

/* ================================================================
   WORKSPACE – three-panel row filling remaining viewport
   ================================================================ */
.workspace {
  flex: 1;
  display: flex;
  min-height: 0;         /* crucial: lets flex children shrink properly */
  overflow: hidden;
  position: relative;
  z-index: 1;
}

/* ================================================================
   RESIZE HANDLES between panels
   ================================================================ */
.resize-handle {
  width: 5px;
  flex-shrink: 0;
  cursor: col-resize;
  background: transparent;
  position: relative;
  z-index: 10;
  transition: background 0.15s;
}
.resize-handle::after {
  content: '';
  position: absolute;
  top: 0; bottom: 0;
  left: 1px;
  width: 2px;
  background: transparent;
  border-radius: 1px;
  transition: background 0.15s;
}
.resize-handle:hover::after,
.resize-handle.dragging::after {
  background: var(--accent);
}
/* hide handle when its adjacent panel is closed or minimized */
.resize-handle.hidden {
  width: 0;
  cursor: default;
  pointer-events: none;
}
/* overlay to capture mouse events during drag (prevents iframe/text selection issues) */
body.resizing {
  cursor: col-resize !important;
  user-select: none !important;
  -webkit-user-select: none !important;
}
body.resizing * {
  cursor: col-resize !important;
}

/* ================================================================
   SIDE PANELS (Folders / Files)
   ================================================================ */
.panel-side {
  /* width set via inline style, managed by JS */
  flex-shrink: 0;
  flex-grow: 0;
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(8px);
  overflow: hidden;
}
.panel-left  { border-right: 1px solid var(--border); }
.panel-right { border-left:  1px solid var(--border); }

/* panel header */
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0.65rem;
  height: 38px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.5);
}
.panel-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
}
.panel-controls { display: flex; gap: 2px; flex-shrink: 0; }
.panel-btn {
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  border: none; background: transparent;
  font-size: 1rem; color: var(--text-muted);
  cursor: pointer; border-radius: 4px;
  transition: all 0.12s; line-height: 1;
}
.panel-btn:hover { background: rgba(0,0,0,0.08); color: var(--text); }

/* panel body */
.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
}
.panel-placeholder {
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
  margin-top: 2rem;
}

/* --- minimized: JS sets width to 40px --- */
.panel-side.minimized .panel-header {
  flex-direction: column;
  padding: 0.4rem 0;
  height: auto;
  border-bottom: none;
  align-items: center;
}
.panel-side.minimized .panel-title {
  writing-mode: vertical-lr;
  text-orientation: mixed;
  transform: rotate(180deg);
  padding: 0.5rem 0;
  font-size: 0.65rem;
}
.panel-side.minimized .panel-controls { flex-direction: column; }
.panel-side.minimized .panel-body { display: none; }

/* --- closed: JS sets width to 0 --- */
.panel-side.closed {
  border: none;
  overflow: hidden;
}

/* ================================================================
   CENTER PANEL – Chat
   ================================================================ */
.panel-center {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  transition: max-width var(--transition-speed) ease;
}

/* Focus mode: chat at 80% width, centered */
.workspace.focused .panel-center {
  max-width: 80%;
  margin: 0 auto;
}

/* ---- Scrollable message area (mouse, trackpad, keyboard) ---- */
.chat-scroll {
  flex: 1;
  min-height: 0;          /* allow shrink inside flex column */
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1rem 1rem 0.5rem;
  display: flex;
  flex-direction: column;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-gutter: stable;
  scrollbar-color: rgba(0,0,0,0.12) transparent;
  -webkit-overflow-scrolling: touch;  /* momentum on trackpad/touch */
  touch-action: pan-y;                /* allow vertical scroll */
}
.chat-scroll:focus {
  outline: none;
}
.chat-scroll:focus-visible {
  box-shadow: inset 0 0 0 1px var(--accent);
}
.chat-scroll::-webkit-scrollbar { width: 6px; }
.chat-scroll::-webkit-scrollbar-track { background: transparent; }
.chat-scroll::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.12);
  border-radius: 3px;
}
.chat-scroll::-webkit-scrollbar-thumb:hover {
  background: rgba(0,0,0,0.22);
}
.chat-scroll::-webkit-scrollbar-thumb:active {
  background: rgba(0,0,0,0.3);
}

/* ---- Scroll-to-bottom button ---- */
.scroll-bottom-btn {
  position: sticky;
  bottom: 0.75rem;
  align-self: center;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  padding: 0.45rem 1rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 20px;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  z-index: 50;
  transition: opacity 0.2s, transform 0.2s;
  opacity: 0;
  transform: translateY(8px);
}
.scroll-bottom-btn.visible {
  display: flex;
  opacity: 1;
  transform: translateY(0);
}
.scroll-bottom-btn:hover {
  background: var(--accent-hover);
}
.scroll-bottom-btn svg {
  flex-shrink: 0;
}

.messages-inner {
  flex: 1 1 auto;            /* grow/shrink; basis = content so it can overflow */
  min-height: min-content;   /* at least as tall as content → .chat-scroll gets scrollbar */
  display: flex;
  flex-direction: column;
  justify-content: flex-end; /* push messages to bottom when content is short */
  gap: 1rem;
}

/* ---- Sticky input at bottom ---- */
.input-area {
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.90);
  backdrop-filter: blur(6px);
  border-top: 1px solid var(--border);
  padding: 0.75rem 1rem;
}
.form {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
}
.input {
  flex: 1;
  resize: none;
  min-height: 44px;
  max-height: 160px;
  padding: 0.65rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.4;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.15s;
}
.input:focus { outline: none; border-color: var(--accent); }
.input::placeholder { color: var(--text-muted); }

.submit {
  flex-shrink: 0;
  padding: 0.65rem 1.25rem;
  background: var(--accent);
  color: #fff; border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}
.submit:hover:not(:disabled) { background: var(--accent-hover); }
.submit:disabled { opacity: 0.6; cursor: not-allowed; }

/* ================================================================
   WELCOME & MESSAGE BUBBLES
   ================================================================ */
.welcome {
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(6px);
  border-radius: var(--radius);
  padding: 1.5rem;
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.welcome p { margin: 0 0 0.75rem; }
.welcome p:last-child { margin-bottom: 0; }
.welcome .hint { font-size: 0.9rem; }
.welcome code {
  background: var(--bg);
  padding: 0.15rem 0.4rem;
  border-radius: 6px;
  font-size: 0.85em;
}

.msg {
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  gap: 0.75rem;
  align-self: flex-start;
}
.msg.user {
  flex-direction: row-reverse;
}

.msg-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--assistant-bubble);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 0.9rem;
}
.msg-avatar-img {
  object-fit: cover;
  background: none;
}
.msg.user .msg-avatar { background: var(--user-bubble); color: #fff; }
.msg.user .msg-avatar-img { background: none; }

.msg-content {
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(6px);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  min-width: 120px;
  flex: 1;
  min-height: 0;
}
.msg.user .msg-content {
  background: var(--user-bubble);
  color: #fff;
  border-color: var(--user-bubble);
}
.msg-content p {
  margin: 0 0 0.5rem;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg-content p:last-child { margin-bottom: 0; }

.msg-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}
.msg.user .msg-meta { color: rgba(255,255,255,0.85); }

/* ================================================================
   COLLAPSIBLE PANELS (Thinking / Tools)
   ================================================================ */
/* Spinner keyframes */
@keyframes panel-spin {
  to { transform: rotate(360deg); }
}

.think-panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 0.75rem;
  background: rgba(248, 248, 250, 0.92);
  overflow: hidden;
  position: relative;
}

.think-panel-header {
  display: flex;
  align-items: center;
  padding: 0.4rem 0.75rem;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.6);
  border-bottom: 1px solid var(--border);
  user-select: none;
}
.think-panel-header svg {
  margin-right: 0.4rem;
  opacity: 0.5;
}
.model-badge {
  margin-left: auto;
  font-size: 0.65rem;
  padding: 0.1rem 0.45rem;
  border-radius: 3px;
  background: var(--border);
  color: var(--text-secondary, #888);
  font-family: monospace;
  letter-spacing: 0.02em;
}

/* Spinning indicator when panel is still receiving data */
.think-panel.active .think-panel-header::before {
  content: '';
  display: inline-block;
  width: 10px;
  height: 10px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: panel-spin 0.7s linear infinite;
  margin-right: 0.5rem;
  flex-shrink: 0;
}

.think-panel-body {
  position: relative;
  max-height: 5em;
  overflow: hidden;
  transition: max-height 0.35s ease;
}
.think-panel.expanded .think-panel-body {
  max-height: none;
  overflow: visible;
}

/* fade-out gradient at the bottom when expanded but overflowing */
.think-panel-body::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 40px;
  background: linear-gradient(transparent, rgba(248, 248, 250, 0.95));
  pointer-events: none;
  transition: opacity 0.25s;
}
.think-panel.expanded .think-panel-body::after {
  opacity: 0;
}

.think-panel-text {
  padding: 0.6rem 0.75rem;
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--text-muted);
  white-space: pre-wrap;
  word-break: break-word;
}

/* Expand / collapse toggle arrow at bottom */
.think-panel-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 0.2rem 0;
  border: none;
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.75rem;
  transition: background 0.15s, color 0.15s;
}
.think-panel-toggle:hover {
  background: rgba(0, 0, 0, 0.04);
  color: var(--text);
}
.think-panel-toggle svg {
  transition: transform 0.25s;
}
.think-panel.expanded .think-panel-toggle svg {
  transform: rotate(180deg);
}

/* ---- Tool calls inside a panel ---- */
.tool-call {
  font-size: 0.8rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  margin-left: 0.5rem;
}
.tool-call:last-child { border-bottom: none; }
.tool-name { font-weight: 600; color: var(--accent); }
.tool-output {
  margin-top: 0.25rem; color: var(--text-muted);
  white-space: pre-wrap; word-break: break-word;
  max-height: 100px; overflow-y: auto;
  font-size: 0.78rem;
}

/* ================================================================
   PLAN BANNER – numbered list of spawned agents
   ================================================================ */
.plan-banner {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 0.75rem;
  background: rgba(248, 248, 250, 0.92);
  overflow: hidden;
}
.plan-banner-header {
  padding: 0.4rem 0.75rem;
  background: rgba(255, 255, 255, 0.6);
  border-bottom: 1px solid var(--border);
}

/* ---- Analyze row: first phase shown in the header ---- */
.plan-analyze-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  color: var(--text);
  padding: 0.15rem 0;
}
.plan-analyze-row.done {
  color: var(--text-muted);
  opacity: 0.7;
}
.plan-analyze-spinner {
  display: inline-block;
  width: 10px;
  height: 10px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: panel-spin 0.7s linear infinite;
  flex-shrink: 0;
}
.plan-analyze-check {
  color: #2ecc71;
  font-weight: 700;
  font-size: 0.8rem;
  flex-shrink: 0;
}

/* ---- Plan title row: appears below analyze, above task list ---- */
.plan-banner-title {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 0.35rem 0 0.1rem;
  margin-top: 0.25rem;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}
.plan-banner-title svg {
  margin-right: 0.3rem;
  opacity: 0.5;
}
.plan-banner-count {
  margin-left: 0.3rem;
  font-weight: 400;
  opacity: 0.7;
}
.plan-banner-list {
  list-style: none;
  margin: 0;
  padding: 0.4rem 0.75rem;
}
.plan-banner-item {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.25rem 0;
  font-size: 0.82rem;
  color: var(--text-muted);
  transition: color 0.2s;
}
.plan-banner-item + .plan-banner-item {
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}
.plan-banner-item.active {
  color: var(--text);
}
.plan-banner-item.done {
  color: var(--text-muted);
  opacity: 0.7;
}
.plan-banner-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  font-size: 0.68rem;
  font-weight: 700;
  flex-shrink: 0;
  border: 2px solid currentColor;
  transition: all 0.2s;
}
.plan-banner-item.active .plan-banner-num {
  border-color: transparent;
  color: #fff;
}
.plan-banner-item.done .plan-banner-num {
  border-color: transparent;
  background: #2ecc71;
  color: #fff;
}
.plan-banner-item {
  cursor: pointer;
}
.plan-banner-item:hover {
  background: rgba(0, 0, 0, 0.03);
}
.plan-banner-label {
  flex: 1;
}
.plan-banner-spinner {
  width: 10px;
  height: 10px;
  border: 2px solid var(--border);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: panel-spin 0.7s linear infinite;
  flex-shrink: 0;
}

/* ---- Plan header activity: subtle one-line status for main agent tools ---- */
.plan-header-activity {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-left: 0.5rem;
  font-weight: 400;
}

/* ---- Plan peek: last 2 activity lines always visible ---- */
.plan-banner-peek {
  flex-basis: 100%;
  padding-left: 1.8rem;
}
.plan-banner-peek:empty {
  display: none;
}

/* ---- Orchestrator activity area (before plan items exist) ---- */
.plan-orchestrator-activity {
  padding-left: 1.8rem;
  margin-top: 0.2rem;
}
.plan-orchestrator-activity:empty {
  display: none;
}

/* ---- Plan drawer: detailed streaming log per agent ---- */
.plan-banner-activity {
  flex-basis: 100%;
  padding-left: 1.8rem;
  overflow: hidden;
  transition: max-height 0.25s ease;
}
.plan-banner-activity.drawer-collapsed {
  max-height: 3.2em;
  overflow: hidden;
  position: relative;
  scrollbar-width: none;
}
.plan-banner-activity.drawer-done {
  max-height: 0;
  padding: 0;
  overflow: hidden;
}
.plan-banner-activity.drawer-collapsed::-webkit-scrollbar { display: none; }
.plan-banner-activity.drawer-collapsed::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1.2em;
  background: linear-gradient(transparent, var(--bg, #1a1a2e));
  pointer-events: none;
}
.plan-banner-activity.drawer-open {
  max-height: none;
  overflow: visible;
}
.plan-drawer-chevron {
  font-size: 0.55rem;
  color: #999;
  margin-left: auto;
  cursor: pointer;
  transition: transform 0.2s ease;
  user-select: none;
  flex-shrink: 0;
  padding: 0 0.2rem;
}
/* Activity line styles */
.plan-activity-line {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  color: var(--text-muted);
  padding: 0.1rem 0;
  line-height: 1.4;
}
.plan-activity-line.active {
  color: var(--text);
}
.plan-activity-line.done {
  opacity: 0.6;
}
.plan-activity-spinner {
  display: inline-block;
  width: 8px;
  height: 8px;
  border: 1.5px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: panel-spin 0.7s linear infinite;
  flex-shrink: 0;
}
.plan-activity-check {
  color: #2ecc71;
  font-size: 0.72rem;
  font-weight: 700;
  flex-shrink: 0;
  width: 8px;
  text-align: center;
}
.plan-thinking-line .plan-activity-label {
  font-style: italic;
  color: var(--text-muted);
}
.plan-activity-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 350px;
}
/* ---- Drawer log: streaming command/output view per agent ---- */
.plan-drawer-log {
  max-height: 200px;
  overflow-y: auto;
  font-family: inherit;
  font-size: 0.75rem;
  line-height: 1.5;
  color: var(--text-muted);
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
  background: rgba(0, 0, 0, 0.04);
  border: 0.5px solid rgba(255, 255, 255, 0.06);
  border-radius: 4px;
  padding: 0.3rem 0.5rem;
  margin-top: 0.25rem;
}
.plan-drawer-log::-webkit-scrollbar { width: 4px; }
.plan-drawer-log::-webkit-scrollbar-track { background: transparent; }
.plan-drawer-log::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }
.plan-log-entry {
  white-space: pre-wrap;
  word-break: break-all;
}
.plan-log-cmd {
  color: var(--accent);
  font-weight: 500;
  padding: 0.15rem 0 0;
  border-top: 1px solid rgba(0, 0, 0, 0.05);
}
.plan-log-cmd .log-cmd-icon {
  color: #2ecc71;
}
.plan-log-output {
  color: #666;
  padding-left: 0.6rem;
}
.plan-log-stream {
  color: #888;
  font-style: italic;
}

/* ---- Subagent todo checklist (rendered from write_todos) ---- */
.plan-todos {
  list-style: none;
  margin: 0.35rem 0 0.2rem 1.8rem;
  padding: 0;
  font-size: 0.78rem;
  line-height: 1.6;
}
.plan-todo-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.08rem 0;
  transition: opacity 0.3s;
}
.plan-todo-icon {
  display: inline-flex;
  width: 14px;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.8rem;
}
.plan-todo-item.todo-done {
  color: var(--text-muted, #999);
}
.plan-todo-item.todo-done .plan-todo-icon {
  color: #2ecc71;
  font-weight: bold;
}
.plan-todo-item.todo-active {
  color: var(--text);
  font-weight: 500;
}
.plan-todo-item.todo-pending {
  color: var(--text-muted, #999);
}
.plan-todo-item.todo-pending .plan-todo-icon {
  opacity: 0.4;
}
.plan-todo-spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid rgba(0,0,0,0.1);
  border-top-color: var(--accent, #4f46e5);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

/* ================================================================
   AGENT SECTIONS – per-agent grouping for multi-agent output
   ================================================================ */
.agent-section {
  margin-bottom: 0.75rem;
  padding-top: 0.75rem;
  border-top: 2px solid var(--border);
}
.agent-section:first-child {
  border-top: none;
  padding-top: 0;
}
.agent-section-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
  padding: 0.5rem 0.6rem;
  border-left: 3px solid var(--accent);
  margin-bottom: 0.5rem;
  background: rgba(24, 119, 242, 0.04);
  border-radius: 0 6px 6px 0;
}
.agent-section-header svg {
  opacity: 0.7;
}
.agent-section-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 0.72rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

/* ---- Synthesizing indicator while orchestrator merges results ---- */
.synthesizing {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.75rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--accent);
  background: rgba(24, 119, 242, 0.06);
  border: 1px solid rgba(24, 119, 242, 0.18);
  border-radius: 8px;
}
.synthesizing .synth-spinner {
  width: 12px;
  height: 12px;
  border: 2px solid rgba(24, 119, 242, 0.25);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: panel-spin 0.7s linear infinite;
  flex-shrink: 0;
}

/* ---- Activity indicator for long-running tool executions ---- */
.activity-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.75rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
}
.activity-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: activity-pulse 1.4s ease-in-out infinite;
  flex-shrink: 0;
}
.activity-time {
  opacity: 0.6;
  font-variant-numeric: tabular-nums;
}
@keyframes activity-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.3; transform: scale(0.75); }
}

/* ---- Response text below panels ---- */
.msg-response {
  margin-top: 0.25rem;
}
.msg-response.collapsible {
  margin-top: 0.75rem;
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}
.msg-response.collapsible .md-content {
  max-height: 4.5em;
  overflow: hidden;
  position: relative;
}
.msg-response.collapsible.expanded .md-content {
  max-height: none;
}
.msg-response.collapsible .md-content::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2em;
  background: linear-gradient(transparent, rgba(248, 248, 250, 0.95));
  pointer-events: none;
}
.msg-response.collapsible.expanded .md-content {
  max-height: none;
}
.msg-response.collapsible.expanded .md-content::after {
  display: none;
}
.response-toggle {
  display: block;
  margin: 0.3rem 0 0;
  padding: 0.2em 0.6em;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
  font-size: 0.75rem;
  color: var(--text-muted);
}
.response-toggle:hover {
  background: rgba(0, 0, 0, 0.03);
}
.msg-response p {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

/* loading dots */
.msg.loading .msg-content { color: var(--text-muted); }
.typing-dots::after {
  content: "";
  animation: dots 1.2s steps(4, end) infinite;
}
@keyframes dots {
  0%, 20% { content: "."; }
  40%     { content: ".."; }
  60%, 100% { content: "..."; }
}

/* ================================================================
   LOGIN SCREEN
   ================================================================ */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding-bottom: 10vh;
  background: #000 url('/static/20260218_1540_Image%20Generation_remix_01khrk1tsjewm9ytea2mw635g6%20(1).png') center center / contain no-repeat;
}
@media (orientation: portrait) {
  .login-screen {
    background-image: url('/static/20260218_1556_Futuristic%20Robot%20Portrait_remix_01khrm0f16ec68vzthpnajt321.png');
  }
}
.login-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center 40%, transparent 20%, rgba(0,0,0,0.45) 55%, rgba(0,0,0,0.85) 100%);
  pointer-events: none;
}
.login-screen .login-buttons {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}
.btn-login {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  min-height: 44px;
  padding: 0.65rem 1.5rem;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(8px);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  font-family: inherit;
}
.btn-login:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.35);
}
@media (max-width: 480px) {
  .login-screen .login-buttons {
    flex-direction: column;
  }
}
.login-error {
  position: relative;
  z-index: 1;
  margin: 1rem 0 0;
  color: #ff6b6b;
  font-size: 0.9rem;
  text-align: center;
}
.login-muted { color: rgba(255,255,255,0.5); font-size: 0.9rem; }

/* ================================================================
   MARKDOWN RENDERED CONTENT
   ================================================================ */
.msg-response .md-content h1,
.msg-response .md-content h2,
.msg-response .md-content h3,
.msg-response .md-content h4 {
  margin: 0.8em 0 0.4em;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text);
}
.msg-response .md-content h1 { font-size: 1.25rem; }
.msg-response .md-content h2 { font-size: 1.1rem; }
.msg-response .md-content h3 { font-size: 1rem; }

.msg-response .md-content p {
  margin: 0.4em 0;
  line-height: 1.6;
}

.msg-response .md-content ul,
.msg-response .md-content ol {
  margin: 0.4em 0;
  padding-left: 1.4em;
}
.msg-response .md-content li {
  margin: 0.2em 0;
  line-height: 1.5;
}

.msg-response .md-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.6em 0;
  font-size: 0.85rem;
}
.msg-response .md-content th,
.msg-response .md-content td {
  padding: 0.35em 0.6em;
  border: 1px solid rgba(255,255,255,0.12);
  text-align: left;
}
.msg-response .md-content th {
  background: rgba(255,255,255,0.06);
  font-weight: 600;
  white-space: nowrap;
}
.msg-response .md-content tr:nth-child(even) {
  background: rgba(255,255,255,0.03);
}

.msg-response .md-content code {
  background: rgba(255,255,255,0.08);
  padding: 0.15em 0.35em;
  border-radius: 4px;
  font-size: 0.88em;
  font-family: "SF Mono", "Fira Code", monospace;
}
.msg-response .md-content pre {
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  padding: 0.75em 1em;
  overflow-x: auto;
  margin: 0.6em 0;
  font-size: 0.85rem;
  line-height: 1.5;
}
.msg-response .md-content pre code {
  background: none;
  padding: 0;
  border-radius: 0;
  font-size: inherit;
}

.msg-response .md-content blockquote {
  margin: 0.6em 0;
  padding: 0.4em 0.8em;
  border-left: 3px solid var(--accent);
  background: rgba(255,255,255,0.04);
  color: var(--text-muted);
}

.msg-response .md-content strong {
  font-weight: 600;
  color: var(--text);
}

.msg-response .md-content hr {
  border: none;
  border-top: 1px solid rgba(255,255,255,0.1);
  margin: 0.8em 0;
}

.msg-response .md-content a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ================================================================
   INTERRUPT / HUMAN-IN-THE-LOOP
   ================================================================ */
.interrupt-question {
  display: flex;
  gap: 12px;
  margin: 16px 0;
  padding: 16px;
  border-radius: 12px;
  background: rgba(255, 193, 7, 0.08);
  border: 1px solid rgba(255, 193, 7, 0.25);
}
.interrupt-question.answered {
  opacity: 0.6;
  pointer-events: none;
}
.interrupt-icon {
  font-size: 24px;
  line-height: 1;
  flex-shrink: 0;
}
.interrupt-body {
  flex: 1;
  min-width: 0;
}
.interrupt-text {
  margin-bottom: 12px;
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.5;
}
.interrupt-text p { margin: 0; }
.interrupt-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.interrupt-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  background: var(--bg-input, rgba(0,0,0,0.2));
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  resize: vertical;
  min-height: 38px;
}
.interrupt-input:focus {
  outline: none;
  border-color: var(--accent);
}
.interrupt-submit {
  padding: 8px 18px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.interrupt-submit:hover { opacity: 0.9; }
.interrupt-submit:disabled { opacity: 0.5; cursor: not-allowed; }

/* ================================================================
   HUMAN-IN-THE-LOOP INSIDE PLAN BANNER
   ================================================================ */
.plan-hil-item {
  flex-direction: column;
  align-items: stretch;
  padding: 10px 12px;
  background: rgba(255, 193, 7, 0.06);
  border: 1px solid rgba(255, 193, 7, 0.2);
  border-radius: 8px;
  margin-top: 4px;
}
.plan-hil-item .plan-hil-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #b71c1c;
  color: #fff;
  font-size: 12px;
  flex-shrink: 0;
  margin-right: 8px;
}
.plan-hil-item.done .plan-hil-icon {
  background: #27ae60;
}
.plan-hil-body {
  flex: 1;
  min-width: 0;
}
.plan-hil-text {
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--text);
  margin-bottom: 8px;
}
.plan-hil-text p { margin: 0; }
.plan-hil-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.plan-hil-input {
  flex: 1;
  padding: 7px 10px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  background: var(--bg-input, rgba(0,0,0,0.2));
  color: var(--text);
  font-size: 0.85rem;
  font-family: inherit;
  resize: vertical;
  min-height: 34px;
}
.plan-hil-input:focus {
  outline: none;
  border-color: var(--accent);
}
.plan-hil-submit {
  padding: 7px 16px;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.plan-hil-submit:hover { opacity: 0.9; }
.plan-hil-submit:disabled { opacity: 0.5; cursor: not-allowed; }
.plan-hil-answer {
  font-size: 0.82rem;
  color: var(--text-muted, #999);
  font-style: italic;
  margin-top: 4px;
  padding: 4px 0;
}
.plan-hil-item.done {
  background: transparent;
  border-color: rgba(39, 174, 96, 0.2);
}

/* ================================================================
   HIL CONFIRMATION BOX (inline in chat)
   ================================================================ */
.hil-confirm-box {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: rgba(39, 174, 96, 0.08);
  border: 1px solid rgba(39, 174, 96, 0.3);
  border-radius: 10px;
  padding: 14px 16px;
  margin: 8px 0;
}
.hil-confirm-icon {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(39, 174, 96, 0.15);
  border-radius: 50%;
  font-size: 1rem;
  color: #27ae60;
  margin-top: 2px;
}
.hil-confirm-body {
  flex: 1;
  min-width: 0;
}
.hil-confirm-text {
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--text);
}
.hil-confirm-text p { margin: 0; }
.hil-confirm-input-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.hil-confirm-input {
  flex: 1;
  min-width: 0;
  padding: 8px 12px;
  border: 1px solid rgba(39, 174, 96, 0.35);
  border-radius: 8px;
  font-size: 0.88rem;
  background: var(--bg, #fff);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}
.hil-confirm-input:focus {
  border-color: #27ae60;
  box-shadow: 0 0 0 2px rgba(39, 174, 96, 0.12);
}
.hil-confirm-btn {
  padding: 8px 18px;
  border: none;
  border-radius: 8px;
  background: #27ae60;
  color: #fff;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.15s;
}
.hil-confirm-btn:hover { opacity: 0.85; }
.hil-confirm-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.hil-btn-yes {
  background: #27ae60;
  min-width: 80px;
}
.hil-btn-no {
  background: #c0392b;
  min-width: 80px;
}
.plan-banner-item > .hil-confirm-box {
  width: 100%;
  margin-top: 6px;
}

/* ================================================================
   RECONNECT BANNER
   ================================================================ */
.reconnect-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 8px 16px;
  background: #b71c1c;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  animation: reconnBannerIn 0.3s ease;
  z-index: 10;
  flex-shrink: 0;
}
@keyframes reconnBannerIn {
  from { opacity: 0; transform: translateY(-100%); }
  to   { opacity: 1; transform: translateY(0); }
}
.reconnect-banner.reconnect-success {
  background: #27ae60;
  animation: none;
  transition: opacity 0.4s ease;
}
.reconnect-banner.reconnect-stopped {
  background: #7f8c8d;
  animation: none;
}
.reconnect-banner-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.reconnect-banner-stop {
  padding: 3px 14px;
  border: 1.5px solid rgba(255,255,255,0.7);
  border-radius: 6px;
  background: transparent;
  color: #fff;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}
.reconnect-banner-stop:hover {
  background: rgba(255,255,255,0.15);
}

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 768px) {
  .panel-side { width: 200px; }
  .panel-side.minimized { width: 36px; }
  .workspace.focused .panel-center { max-width: 95%; }
}
@media (max-width: 480px) {
  .panel-side { display: none; }
  .focus-btn, .main-nav { display: none; }
}
