/* ══════════════════════════════════════════════════════════
   Lekha AI — Design System (LAHA-inspired)
   ══════════════════════════════════════════════════════════ */

/* ── Reset & Variables ──────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Paper palette (warm off-whites) */
  --paper-100: #F5F3EC;
  --paper-200: #EDEADF;
  --paper-300: #E2DED2;
  --paper-400: #C9C3B0;

  /* Ink palette (dark grays) */
  --ink-900: #101012;
  --ink-800: #1C1C20;
  --ink-700: #2C2C32;
  --ink-600: #4A4A54;
  --ink-500: #62626E;
  --ink-400: #8A8A96;
  --ink-300: #B0B0BA;
  --ink-200: #D4D4DC;
  --ink-100: #EDEDF0;
  --ink-50:  #F7F8F9;

  /* Lime accent */
  --lime-300: #C5E84D;
  --lime-400: #B5D83A;
  --lime-500: #A8CC2A;
  --lime-600: #8FB523;

  /* Semantic colors */
  --green:  #1FAB6F;
  --green-light: #E8F8F0;
  --amber:  #D89224;
  --amber-light: #FEF6E8;
  --red:    #C5462E;
  --red-light: #FEF0ED;
  --blue:   #2563B2;
  --blue-light: #EEF4FB;
  --violet: #7C5BC0;
  --violet-light: #F3EEFB;

  /* Layout */
  --sidebar-w: 260px;
  --agent-panel-w: 280px;
  --topbar-h: 52px;

  /* Rounding */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 18px;
  --r-2xl: 26px;
  --r-full: 9999px;

  /* Shadows */
  --shadow-panel: 0 1px 0 rgba(0,0,0,.04), 0 1px 3px rgba(0,0,0,.06);
  --shadow-elevated: 0 4px 12px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-modal: 0 20px 50px rgba(0,0,0,.18), 0 6px 14px rgba(0,0,0,.08);

  /* Typography */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-serif: 'Instrument Serif', 'Georgia', serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Menlo', monospace;
}

html, body {
  height: 100%;
  font-family: var(--font);
  font-size: 14px;
  color: var(--ink-900);
  background: var(--paper-100);
  -webkit-font-smoothing: antialiased;
}

body { display: flex; overflow: hidden; }

/* ── Utility Classes ────────────────────────────────────── */
.hidden { display: none !important; }

.label {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-400);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
  padding: 2px 8px;
  border-radius: var(--r-full);
}

.display {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
}

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--r-full);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s ease;
  white-space: nowrap;
  text-decoration: none;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary {
  background: var(--lime-300);
  color: var(--ink-900);
}
.btn-primary:hover:not(:disabled) { background: var(--lime-400); }

.btn-secondary {
  background: #fff;
  color: var(--ink-700);
  border: 1px solid var(--ink-200);
}
.btn-secondary:hover:not(:disabled) { background: var(--paper-200); }

.btn-ghost {
  background: none;
  color: var(--ink-500);
}
.btn-ghost:hover:not(:disabled) { background: var(--paper-200); color: var(--ink-700); }

.btn-danger {
  background: none;
  color: var(--ink-500);
}
.btn-danger:hover:not(:disabled) { color: var(--red); }

.btn-sm { padding: 5px 12px; font-size: 12px; }

.btn-icon {
  background: none;
  border: none;
  color: var(--ink-400);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .15s;
}
.btn-icon:hover { background: var(--paper-200); color: var(--ink-700); }

.btn-full { width: 100%; justify-content: center; padding: 12px; font-size: 14px; }

/* ── Cards ──────────────────────────────────────────────── */
.card {
  background: #fff;
  border: 1px solid var(--ink-200);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-panel);
}

/* ══════════════════════════════════════════════════════════
   LOGIN SCREEN
   ══════════════════════════════════════════════════════════ */
.login-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ink-900);
  background-image:
    radial-gradient(ellipse 80% 60% at 50% 40%, rgba(168,204,42,.08) 0%, transparent 70%),
    linear-gradient(160deg, var(--ink-900) 0%, #1a1a22 100%);
  z-index: 100;
}

.login-card {
  background: #fff;
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-modal);
  padding: 44px 40px;
  width: 100%;
  max-width: 400px;
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 36px;
  justify-content: center;
}

.login-logo .logo-mark {
  width: 40px;
  height: 40px;
  background: var(--lime-300);
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 22px;
  font-weight: 400;
  color: var(--ink-900);
}

.login-logo .logo-text {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 28px;
  color: var(--ink-900);
}

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

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-500);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.form-group input[type="text"],
.form-group input[type="password"] {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--ink-200);
  border-radius: var(--r-md);
  font-family: var(--font);
  font-size: 14px;
  color: var(--ink-900);
  background: var(--ink-50);
  transition: all .15s;
}

.form-group input:focus {
  outline: none;
  border-color: var(--lime-500);
  box-shadow: 0 0 0 3px rgba(168,204,42,.15);
  background: #fff;
}

.form-error {
  padding: 10px 14px;
  margin-bottom: 16px;
  background: var(--red-light);
  border: 1px solid rgba(197,70,46,.2);
  border-radius: var(--r-md);
  color: var(--red);
  font-size: 13px;
}

.form-hint-area { margin-bottom: 16px; }

.btn-link {
  background: none;
  border: none;
  color: var(--blue);
  font-size: 13px;
  cursor: pointer;
  text-decoration: underline;
  font-family: var(--font);
  padding: 0;
}

.hint-text {
  margin-top: 8px;
  padding: 10px 14px;
  background: var(--amber-light);
  border: 1px solid rgba(216,146,36,.2);
  border-radius: var(--r-md);
  font-size: 13px;
  color: #7a5a14;
}

.hint-help, .password-rules {
  font-size: 11px;
  color: var(--ink-400);
  margin-top: 4px;
}

/* ══════════════════════════════════════════════════════════
   MODAL
   ══════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(16,16,18,.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-card {
  background: #fff;
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-modal);
  padding: 36px;
  width: 100%;
  max-width: 440px;
  animation: slideInBottom .25s cubic-bezier(.16,1,.3,1);
}

.modal-card h3 { font-size: 18px; font-weight: 700; margin-bottom: 6px; }
.modal-desc { color: var(--ink-500); font-size: 13px; margin-bottom: 20px; line-height: 1.5; }

/* ══════════════════════════════════════════════════════════
   APP LAYOUT — 3-pane grid
   ══════════════════════════════════════════════════════════ */
#app-container {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--agent-panel-w);
  width: 100%;
  height: 100%;
  gap: 0;
}

/* ══════════════════════════════════════════════════════════
   LEFT SIDEBAR — Sessions
   ══════════════════════════════════════════════════════════ */
#sidebar {
  background: var(--ink-900);
  color: var(--ink-300);
  display: flex;
  flex-direction: column;
  transition: margin-left .3s cubic-bezier(.16,1,.3,1);
  z-index: 20;
  overflow: hidden;
}
#sidebar.collapsed { margin-left: calc(-1 * var(--sidebar-w)); }

.sidebar-header {
  padding: 16px 16px 12px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo .logo-mark-sm {
  width: 30px;
  height: 30px;
  background: var(--lime-300);
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 17px;
  font-weight: 400;
  color: var(--ink-900);
}

.logo span {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 18px;
  color: #fff;
}

#btn-new-session {
  background: rgba(255,255,255,.1);
  color: #fff;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: var(--r-full);
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
#btn-new-session:hover { background: rgba(255,255,255,.15); border-color: rgba(255,255,255,.2); }

.sidebar-section {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--ink-500);
  padding: 10px 10px 6px;
}

#session-list { list-style: none; }

#session-list li {
  padding: 10px 12px;
  border-radius: var(--r-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background .15s;
  font-size: 13px;
  color: var(--ink-300);
  position: relative;
}
#session-list li:hover { background: rgba(255,255,255,.06); }
#session-list li.active { background: rgba(255,255,255,.1); color: #fff; }

#session-list li .session-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--r-sm);
  background: rgba(255,255,255,.06);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 13px;
}
#session-list li.active .session-icon { background: var(--lime-500); color: var(--ink-900); }

#session-list li .session-info { flex: 1; min-width: 0; }

#session-list li .session-name {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
  font-size: 13px;
  line-height: 1.3;
}

#session-list li .session-meta {
  display: block;
  font-size: 11px;
  color: var(--ink-500);
  margin-top: 1px;
}

#session-list li .btn-delete-session {
  opacity: 0;
  transition: opacity .15s;
  padding: 4px;
  color: var(--ink-500);
  background: none;
  border: none;
  cursor: pointer;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
#session-list li:hover .btn-delete-session { opacity: 1; }
#session-list li .btn-delete-session:hover { color: var(--red); background: rgba(197,70,46,.15); }

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,.06);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: var(--r-full);
  background: var(--violet);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}

.user-info .user-name {
  font-size: 13px;
  color: #fff;
  font-weight: 500;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.role-badge {
  font-size: 9px;
  padding: 2px 7px;
  border-radius: var(--r-full);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.role-badge.super_admin { background: var(--violet); color: #fff; }
.role-badge.admin { background: var(--blue); color: #fff; }
.role-badge.user { background: var(--green); color: #fff; }

.sidebar-actions {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 10px;
}

.btn-sidebar-link {
  background: none;
  border: none;
  color: var(--ink-400);
  font-size: 12px;
  font-family: var(--font);
  cursor: pointer;
  padding: 5px 0;
  text-align: left;
  text-decoration: none;
  display: block;
  transition: color .15s;
}
.btn-sidebar-link:hover { color: #fff; }
.btn-sidebar-link.danger:hover { color: var(--red); }

.model-badge {
  font-size: 10px;
  font-family: var(--font-mono);
  padding: 5px 10px;
  border-radius: var(--r-full);
  background: rgba(255,255,255,.06);
  color: var(--ink-500);
  text-align: center;
}

/* ══════════════════════════════════════════════════════════
   CENTER — Main Chat Area
   ══════════════════════════════════════════════════════════ */
#main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--paper-100);
  position: relative;
}

/* ── Top Bar ────────────────────────────────────────────── */
#topbar {
  height: var(--topbar-h);
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--ink-200);
  background: #fff;
  flex-shrink: 0;
}

#btn-sidebar-toggle {
  display: none;
}

.topbar-title {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.topbar-title h2 {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 17px;
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--ink-900);
}

.id-badge {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--ink-400);
  background: var(--ink-50);
  padding: 2px 8px;
  border-radius: var(--r-full);
  border: 1px solid var(--ink-200);
  display: none;
}
.id-badge.visible { display: inline-block; }

.topbar-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 4px 10px;
  border-radius: var(--r-full);
}

.topbar-status.idle { background: var(--ink-100); color: var(--ink-400); }
.topbar-status.working { background: var(--lime-300); color: var(--ink-900); }
.topbar-status.done { background: var(--green-light); color: var(--green); }

.topbar-status .pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.topbar-status.working .pulse-dot { animation: pulse 1.5s ease-in-out infinite; }

.topbar-actions { display: flex; gap: 6px; }

/* ── Data Source Bar ────────────────────────────────────── */
#data-source-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 20px;
  background: #fff;
  border-bottom: 1px solid var(--ink-200);
  flex-shrink: 0;
}

#data-source-bar .label { margin-right: 4px; }

.data-source-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1px dashed var(--ink-200);
  border-radius: var(--r-full);
  background: var(--ink-50);
  color: var(--ink-600);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
}
.data-source-btn:hover { border-color: var(--lime-500); background: rgba(168,204,42,.08); color: var(--ink-900); }
.data-source-btn.active { border-style: solid; border-color: var(--green); background: var(--green-light); color: var(--green); }
.data-source-btn svg { flex-shrink: 0; }

.uploaded-files-chips {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  overflow-x: auto;
  min-width: 0;
}

.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  background: var(--green-light);
  border: 1px solid rgba(31,171,111,.2);
  border-radius: var(--r-full);
  font-size: 11px;
  font-weight: 500;
  color: var(--green);
  white-space: nowrap;
}
.file-chip svg { flex-shrink: 0; }

/* ── Chat Container ─────────────────────────────────────── */
#chat-container {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

#chat {
  max-width: 780px;
  margin: 0 auto;
  padding: 24px 24px 16px;
}

/* ── Empty State ────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 80px 24px 40px;
}

.empty-logo {
  width: 64px;
  height: 64px;
  background: var(--lime-300);
  border-radius: var(--r-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 34px;
  color: var(--ink-900);
  margin-bottom: 20px;
}

.empty-state h3 {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 24px;
  font-weight: 400;
  color: var(--ink-900);
  margin-bottom: 8px;
}
.empty-state p {
  max-width: 420px;
  line-height: 1.6;
  color: var(--ink-500);
  margin-bottom: 28px;
  font-size: 14px;
}

.quick-prompts { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }

.quick-prompt {
  padding: 8px 16px;
  border: 1px solid var(--ink-200);
  border-radius: var(--r-full);
  background: #fff;
  color: var(--ink-600);
  font-size: 13px;
  font-family: var(--font);
  cursor: pointer;
  transition: all .15s;
}
.quick-prompt:hover { border-color: var(--lime-500); color: var(--ink-900); background: rgba(168,204,42,.06); }
.quick-prompt:first-child { background: var(--ink-900); color: #fff; border-color: var(--ink-900); }
.quick-prompt:first-child:hover { background: var(--ink-800); }

/* ── Messages ───────────────────────────────────────────── */
.message {
  margin-bottom: 24px;
  display: flex;
  gap: 12px;
  animation: fadeIn .25s ease;
}

.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 2px;
}
.message.user .message-avatar {
  background: var(--ink-800);
  color: #fff;
  border-radius: var(--r-full);
}
.message.assistant .message-avatar {
  background: var(--lime-300);
  color: var(--ink-900);
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  font-size: 17px;
}

.message-body { flex: 1; min-width: 0; }

.message-role {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--ink-400);
  margin-bottom: 4px;
}

.message-content {
  line-height: 1.65;
  color: var(--ink-900);
  word-wrap: break-word;
  overflow-wrap: break-word;
}
.message-content p { margin-bottom: 8px; }
.message-content p:last-child { margin-bottom: 0; }
.message-content pre {
  background: var(--ink-900);
  color: #e0e0e6;
  padding: 14px 16px;
  border-radius: var(--r-md);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 12.5px;
  margin: 10px 0;
  line-height: 1.5;
}
.message-content code {
  font-family: var(--font-mono);
  font-size: 12.5px;
  background: var(--ink-100);
  padding: 1px 6px;
  border-radius: 4px;
}
.message-content pre code { background: none; padding: 0; }
.message-content table {
  border-collapse: collapse;
  width: 100%;
  margin: 10px 0;
  font-size: 13px;
}
.message-content th, .message-content td {
  border: 1px solid var(--ink-200);
  padding: 7px 12px;
  text-align: left;
}
.message-content th { background: var(--ink-50); font-weight: 600; font-size: 12px; }
.message-content ul, .message-content ol { padding-left: 20px; margin: 6px 0; }
.message-content li { margin-bottom: 4px; }
.message-content strong { font-weight: 600; }
.message-content h3, .message-content h4 { margin-top: 14px; margin-bottom: 6px; }

/* ── Thinking Block ─────────────────────────────────────── */
.thinking-block {
  background: linear-gradient(135deg, #f8f7f4 0%, #f3f1ec 100%);
  border: 1px solid var(--ink-200);
  border-radius: var(--r-lg);
  margin-bottom: 10px;
  overflow: hidden;
  transition: all 0.2s ease;
}

.thinking-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
}

.thinking-icon {
  font-size: 14px;
  opacity: 0.6;
}

.thinking-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-500);
  letter-spacing: 0.02em;
}

.thinking-badge {
  font-size: 10px;
  color: var(--ink-400);
  background: var(--ink-100);
  padding: 1px 6px;
  border-radius: 8px;
  margin-left: auto;
}
.thinking-badge:empty { display: none; }

.thinking-toggle {
  background: none;
  border: none;
  color: var(--ink-400);
  cursor: pointer;
  padding: 2px;
  display: grid;
  place-items: center;
  transition: transform 0.2s ease;
}
.thinking-block.collapsed .thinking-toggle {
  transform: rotate(-90deg);
}

.thinking-content {
  padding: 0 14px 12px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--ink-500);
  font-family: var(--font-mono);
  max-height: 200px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.thinking-block.collapsed .thinking-content {
  display: none;
}

/* ── Tool Blocks ────────────────────────────────────────── */
.tool-block {
  background: var(--ink-50);
  border: 1px solid var(--ink-200);
  border-radius: var(--r-md);
  padding: 10px 14px;
  margin-bottom: 10px;
  font-size: 12.5px;
}

.tool-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tool-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.tool-status-dot.running { background: var(--lime-500); animation: pulse 1.5s ease-in-out infinite; }
.tool-status-dot.done { background: var(--green); }
.tool-status-dot.error { background: var(--red); }

.tool-name {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-700);
}

.tool-label {
  font-size: 12px;
  color: var(--ink-400);
}

.tool-args {
  color: var(--ink-400);
  font-size: 11px;
  font-family: var(--font-mono);
  margin-top: 4px;
  word-break: break-all;
  max-height: 40px;
  overflow: hidden;
}

.tool-output {
  margin-top: 8px;
  padding: 8px 10px;
  background: rgba(0,0,0,.03);
  border-radius: var(--r-sm);
  font-size: 11px;
  font-family: var(--font-mono);
  max-height: 180px;
  overflow: auto;
  white-space: pre-wrap;
  display: none;
  color: var(--ink-600);
}
.tool-output.visible { display: block; }

/* ── Status Indicator ───────────────────────────────────── */
.status-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
}
.status-text {
  font-size: 13px;
  color: var(--ink-500);
  font-weight: 500;
}
.loading-dots { display: flex; gap: 4px; }
.loading-dots span {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--lime-500);
  animation: bounce 1.2s infinite;
}
.loading-dots span:nth-child(2) { animation-delay: .15s; }
.loading-dots span:nth-child(3) { animation-delay: .3s; }

/* ── Input Area ─────────────────────────────────────────── */
#input-area {
  border-top: 1px solid var(--ink-200);
  background: #fff;
  padding: 12px 20px 16px;
  flex-shrink: 0;
}

#drop-zone {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px;
  margin-bottom: 10px;
  border: 2px dashed var(--lime-500);
  border-radius: var(--r-lg);
  background: rgba(168,204,42,.06);
  color: var(--lime-600);
  font-size: 13px;
  font-weight: 500;
  animation: fadeIn .15s ease;
}

.upload-progress {
  position: relative;
  height: 28px;
  margin-bottom: 10px;
  border-radius: var(--r-md);
  background: var(--ink-50);
  overflow: hidden;
}
.upload-progress-fill {
  position: absolute;
  top: 0; left: 0; height: 100%;
  background: var(--lime-300);
  opacity: .3;
  border-radius: var(--r-md);
  transition: width .25s ease;
  width: 0%;
}
.upload-progress span {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  height: 100%;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-700);
}

#prompt-bar {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  background: var(--ink-50);
  border: 1px solid var(--ink-200);
  border-radius: var(--r-lg);
  padding: 6px 8px 6px 4px;
  transition: all .15s;
}
#prompt-bar:focus-within { border-color: var(--lime-500); box-shadow: 0 0 0 3px rgba(168,204,42,.1); background: #fff; }

.attach-btn {
  padding: 8px;
  color: var(--ink-400);
  cursor: pointer;
  border-radius: var(--r-full);
  display: flex;
  align-items: center;
  transition: all .15s;
  flex-shrink: 0;
}
.attach-btn:hover { background: rgba(168,204,42,.1); color: var(--lime-600); }

#prompt-input {
  flex: 1;
  border: none;
  outline: none;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  resize: none;
  background: transparent;
  max-height: 150px;
  color: var(--ink-900);
}
#prompt-input::placeholder { color: var(--ink-400); }

#btn-send {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--r-full);
  flex-shrink: 0;
  background: var(--lime-300);
  color: var(--ink-900);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .15s;
}
#btn-send:hover:not(:disabled) { background: var(--lime-400); }
#btn-send:disabled { opacity: .3; cursor: not-allowed; }

.input-meta {
  display: flex;
  justify-content: space-between;
  padding: 6px 4px 0;
  font-size: 11px;
  color: var(--ink-400);
}

/* ── Exports Panel ──────────────────────────────────────── */
.panel {
  position: absolute;
  top: var(--topbar-h);
  right: 0;
  bottom: 0;
  width: 340px;
  background: #fff;
  border-left: 1px solid var(--ink-200);
  box-shadow: var(--shadow-elevated);
  z-index: 15;
  display: flex;
  flex-direction: column;
  animation: slideInRight .2s cubic-bezier(.16,1,.3,1);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--ink-200);
}
.panel-header h3 { font-size: 14px; font-weight: 600; }

#exports-list {
  list-style: none;
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

#exports-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  transition: background .15s;
}
#exports-list li:hover { background: var(--paper-100); }

#exports-list li .file-icon {
  width: 36px; height: 36px;
  border-radius: var(--r-md);
  background: var(--green-light);
  color: var(--green);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
#exports-list li .file-name {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#exports-list li a {
  color: var(--blue);
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
}
#exports-list li a:hover { text-decoration: underline; }

.empty-note {
  text-align: center;
  color: var(--ink-400);
  padding: 32px 20px;
  font-size: 13px;
}

/* ══════════════════════════════════════════════════════════
   RIGHT PANEL — Agent Activity
   ══════════════════════════════════════════════════════════ */
#agent-panel {
  background: var(--ink-50);
  border-left: 1px solid var(--ink-200);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.agent-panel-header {
  padding: 14px 16px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.agent-panel-header h3 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-400);
}

.agent-panel-header .agent-count {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: var(--r-full);
  background: var(--ink-200);
  color: var(--ink-500);
}

.agent-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* ── Agent Card ─────────────────────────────── */
.agent-card {
  padding: 10px 12px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  background: transparent;
  transition: all .2s ease;
}

.agent-card.idle {
  opacity: 0.5;
}

.agent-card.working {
  background: #fff;
  border-color: var(--lime-400);
  box-shadow: 0 0 0 3px rgba(168,204,42,.08);
}

.agent-card.done {
  background: #fff;
  border-color: var(--ink-200);
}

.agent-card.error {
  background: #fff;
  border-color: var(--red);
}

.agent-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.agent-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  transition: all .2s;
}

.agent-card.idle .agent-icon { background: var(--ink-100); }
.agent-card.working .agent-icon { background: var(--lime-300); }
.agent-card.done .agent-icon { background: var(--green-light); }
.agent-card.error .agent-icon { background: var(--red-light); }

.agent-card-info {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.agent-card-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-900);
  line-height: 1;
}

.agent-card-status {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 2px 6px;
  border-radius: var(--r-full);
  line-height: 1;
  margin-left: auto;
  white-space: nowrap;
}
.agent-card.idle .agent-card-status {
  color: var(--ink-400);
  background: var(--ink-100);
}
.agent-card.working .agent-card-status {
  color: var(--lime-600);
  background: rgba(168,204,42,.15);
  animation: status-pulse 2s ease-in-out infinite;
}
.agent-card.done .agent-card-status {
  color: var(--green);
  background: var(--green-light);
}
.agent-card.error .agent-card-status {
  color: var(--red);
  background: var(--red-light);
}

@keyframes status-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.agent-card-detail {
  margin-top: 6px;
  padding-left: 38px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--ink-400);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.agent-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.agent-card.working .agent-status-dot { background: var(--lime-500); animation: pulse 1.5s ease-in-out infinite; }
.agent-card.done .agent-status-dot { background: var(--green); }

/* Session info in agent panel */
.agent-panel-section {
  padding: 12px 16px;
  border-top: 1px solid var(--ink-200);
  background: #fff;
}

.agent-panel-section .label { margin-bottom: 8px; display: block; }

.session-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.stat-card {
  background: var(--ink-50);
  border-radius: var(--r-md);
  padding: 10px 12px;
  text-align: center;
}

.stat-value {
  font-size: 20px;
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  color: var(--ink-900);
  line-height: 1;
}

.stat-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--ink-400);
  margin-top: 4px;
}

/* ══════════════════════════════════════════════════════════
   TALLY CONNECT MODAL
   ══════════════════════════════════════════════════════════ */
.tally-modal-body {
  text-align: center;
  padding: 12px 0;
}

.tally-logo {
  width: 56px;
  height: 56px;
  background: var(--blue-light);
  border-radius: var(--r-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  margin: 0 auto 16px;
}

.tally-steps {
  text-align: left;
  margin: 16px 0;
  padding: 0;
  list-style: none;
}

.tally-steps li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
  font-size: 13px;
  color: var(--ink-600);
  line-height: 1.4;
}

.tally-step-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--ink-100);
  color: var(--ink-600);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

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

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

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

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

@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-6px); }
}

/* ══════════════════════════════════════════════════════════
   SCROLLBARS
   ══════════════════════════════════════════════════════════ */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--ink-200); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-300); }

#sidebar ::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); }
#sidebar ::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.2); }

/* ══════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════ */
@media (max-width: 1100px) {
  #app-container {
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  }
  #agent-panel { display: none; }
}

@media (max-width: 768px) {
  #app-container {
    grid-template-columns: 1fr;
  }
  #sidebar {
    position: fixed;
    inset: 0;
    width: var(--sidebar-w);
    z-index: 30;
  }
  #sidebar.collapsed { margin-left: calc(-1 * var(--sidebar-w)); }
  #btn-sidebar-toggle { display: flex; }
  .login-card { margin: 16px; }
  #agent-panel { display: none; }
}
