/* OpenWhale Dashboard - Modern Deep Dark Theme */
/* Shakuro-inspired design with bento grid layout */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
  /* Manus 1.6 Deep Dark Theme */
  --bg-void: #09090B;
  /* Zinc 950 */
  --bg-surface: #18181B;
  /* Zinc 900 */
  --bg-elevated: #27272A;
  /* Zinc 800 */
  --bg-hover: #3F3F46;
  /* Zinc 700 */

  /* Borders & Dividers */
  --border-subtle: #27272A;
  --border-default: #3F3F46;
  --border-active: #52525B;

  /* Text */
  --text-primary: #FAFAFA;
  /* Zinc 50 */
  --text-secondary: #A1A1AA;
  /* Zinc 400 */
  --text-muted: #71717A;
  /* Zinc 500 */
  --text-dim: #52525B;
  /* Zinc 600 */

  /* Accents - Retaining Purple/Blue vibe */
  --accent-blue: #3B82F6;
  --accent-indigo: #6366F1;
  --accent-purple: #8B5CF6;
  --accent-pink: #EC4899;
  --accent-orange: #F97316;
  --accent-yellow: #EAB308;
  --accent-green: #10B981;
  --accent-red: #EF4444;

  /* Gradients - Subtle */
  --gradient-primary: linear-gradient(135deg, #3B82F6 0%, #6366F1 100%);
  --gradient-warm: linear-gradient(135deg, #F97316 0%, #EC4899 100%);
  --gradient-cool: linear-gradient(135deg, #06B6D4 0%, #3B82F6 100%);

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.6);
  --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.15);

  /* Layout */
  --nav-width: 72px;
  --sidebar-width: 280px;
  --header-height: 0px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;

  /* Animation */
  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-default: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-void);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ===== LAYOUT ===== */
.app-container {
  display: flex;
  height: 100vh;
}

/* ===== NAVIGATION RAIL ===== */
.sidebar {
  width: var(--nav-width);
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 0;
  flex-shrink: 0;
}

.sidebar-header {
  width: 100%;
  padding: 0 0 20px;
  display: flex;
  justify-content: center;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 20px;
}

.logo {
  font-size: 28px;
  filter: drop-shadow(0 0 8px rgba(99, 102, 241, 0.3));
}

.brand-name {
  display: none;
}

.sidebar-nav {
  flex: 1;
  width: 100%;
  padding: 0 12px;
  overflow-y: auto;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border-subtle);
}

.nav-section {
  margin-bottom: 24px;
}

.nav-section-title {
  display: none;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  margin: 0 auto 8px;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  text-decoration: none;
  transition: var(--transition-default);
  cursor: pointer;
  position: relative;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--gradient-primary);
  color: white;
  box-shadow: var(--shadow-glow);
}

.nav-icon {
  font-size: 20px;
}

.nav-label {
  display: none;
}

.nav-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  min-width: 18px;
  height: 18px;
  background: var(--accent-red);
  color: white;
  font-size: 10px;
  font-weight: 600;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

.nav-badge.success {
  background: var(--accent-green);
}

.nav-badge.warning {
  background: var(--accent-orange);
}

/* ===== MAIN CONTENT ===== */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-void);
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface);
}

.content-area {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
}

/* ===== PAGE HEADER ===== */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.page-title {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.page-subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 4px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ===== BENTO GRID ===== */
.bento-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  grid-auto-rows: minmax(100px, auto);
  gap: 20px;
  max-width: 1400px;
  margin: 0 auto;
}

.bento-item {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: var(--transition-default);
  overflow: visible;
}

.bento-item:hover {
  border-color: var(--border-default);
  box-shadow: var(--shadow-md);
}

/* Bento sizing */
.bento-sm {
  grid-column: span 3;
}

.bento-md {
  grid-column: span 4;
}

.bento-lg {
  grid-column: span 6;
}

.bento-xl {
  grid-column: span 8;
}

.bento-full {
  grid-column: span 12;
}

.bento-tall {
  grid-row: span 2;
}

.bento-short {
  grid-row: span 1;
}

/* ===== WIDGET: WELCOME ===== */
.widget-welcome {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: var(--gradient-primary);
  border: none;
  position: relative;
  overflow: hidden;
}

.widget-welcome::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
  border-radius: 50%;
}

.welcome-greeting {
  font-size: 14px;
  opacity: 0.9;
  margin-bottom: 4px;
}

.welcome-title {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
}

.welcome-time {
  font-size: 48px;
  font-weight: 800;
  letter-spacing: -2px;
  line-height: 1;
}

.welcome-date {
  font-size: 14px;
  opacity: 0.8;
  margin-top: 8px;
}

/* ===== WIDGET: STAT CARD ===== */
.widget-stat {
  display: flex;
  flex-direction: column;
}

.stat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.stat-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.stat-icon.blue {
  background: rgba(59, 130, 246, 0.15);
}

.stat-icon.green {
  background: rgba(34, 197, 94, 0.15);
}

.stat-icon.orange {
  background: rgba(249, 115, 22, 0.15);
}

.stat-icon.purple {
  background: rgba(139, 92, 246, 0.15);
}

.stat-trend {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 20px;
}

.stat-trend.up {
  color: var(--accent-green);
  background: rgba(34, 197, 94, 0.1);
}

.stat-trend.down {
  color: var(--accent-red);
  background: rgba(239, 68, 68, 0.1);
}

.stat-value {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -1px;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 13px;
  color: var(--text-muted);
}

/* ===== WIDGET: ACTIVITY CHART ===== */
.widget-activity {
  display: flex;
  flex-direction: column;
}

.activity-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.activity-title {
  font-size: 16px;
  font-weight: 600;
}

.activity-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-elevated);
  padding: 4px;
  border-radius: var(--radius-sm);
}

.activity-tab {
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition-fast);
  border: none;
  background: none;
}

.activity-tab:hover {
  color: var(--text-secondary);
}

.activity-tab.active {
  background: var(--bg-surface);
  color: var(--text-primary);
}

.activity-chart {
  flex: 1;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding-top: 20px;
}

.activity-bar {
  flex: 1;
  background: var(--bg-elevated);
  border-radius: 4px 4px 0 0;
  position: relative;
  min-height: 20px;
  transition: var(--transition-default);
}

.activity-bar:hover {
  background: var(--accent-indigo);
}

.activity-bar::after {
  content: attr(data-label);
  position: absolute;
  bottom: -24px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  color: var(--text-dim);
}

/* ===== WIDGET: RADIAL PROGRESS ===== */
.widget-progress {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.progress-ring {
  position: relative;
  width: 120px;
  height: 120px;
  margin-bottom: 16px;
}

.progress-ring svg {
  transform: rotate(-90deg);
}

.progress-ring-bg {
  fill: none;
  stroke: var(--bg-elevated);
  stroke-width: 8;
}

.progress-ring-fill {
  fill: none;
  stroke: url(#progressGradient);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 339.292;
  transition: stroke-dashoffset 0.5s ease;
}

.progress-value {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 28px;
  font-weight: 700;
}

.progress-label {
  font-size: 13px;
  color: var(--text-muted);
}

/* ===== WIDGET: CHANNEL LIST ===== */
.widget-channels {
  display: flex;
  flex-direction: column;
}

.channels-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.channels-title {
  font-size: 16px;
  font-weight: 600;
}

.channel-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.channel-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
}

.channel-row:hover {
  background: var(--bg-hover);
}

.channel-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  background: var(--bg-surface);
}

.channel-info {
  flex: 1;
}

.channel-name {
  font-size: 14px;
  font-weight: 500;
}

.channel-desc {
  font-size: 12px;
  color: var(--text-muted);
}

.channel-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
}

.status-dot.online {
  background: var(--accent-green);
  box-shadow: 0 0 8px var(--accent-green);
}

.status-dot.offline {
  background: var(--accent-red);
}

.status-dot.connecting {
  background: var(--accent-orange);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.4;
  }
}

/* ===== TABS ===== */
.tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 0;
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.15s ease;
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  color: var(--accent-blue);
  border-bottom-color: var(--accent-blue);
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  background: var(--accent-blue);
  color: white;
  font-size: 11px;
  font-weight: 600;
  border-radius: 10px;
}

/* ===== CARDS (Legacy support) ===== */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
}

/* ===== STATS GRID (Legacy) ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: var(--transition-default);
}

.stat-card:hover {
  border-color: var(--border-active);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* ===== BUTTONS ===== */
.btn {
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  transition: var(--transition-fast);
  border: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-primary {
  background: var(--gradient-primary);
  color: white;
}

.btn-primary:hover {
  box-shadow: var(--shadow-glow);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
}

.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--accent-indigo);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

/* ===== TOGGLE SWITCH ===== */
.toggle {
  position: relative;
  width: 44px;
  height: 24px;
  cursor: pointer;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--bg-elevated);
  border-radius: 24px;
  transition: var(--transition-default);
}

.toggle-slider:before {
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: var(--transition-default);
}

.toggle input:checked+.toggle-slider {
  background: var(--accent-indigo);
}

.toggle input:checked+.toggle-slider:before {
  transform: translateX(20px);
  background: white;
}

/* ===== FORM ELEMENTS ===== */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.form-input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  transition: var(--transition-fast);
}

.form-input:focus {
  outline: none;
  border-color: var(--accent-indigo);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-input::placeholder {
  color: var(--text-dim);
}

select.form-input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  line-height: 1.2;
}

select.form-input option {
  background: var(--bg-elevated);
  color: var(--text-primary);
  padding: 8px;
}

/* ===== CHAT INTERFACE ===== */
.chat-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
  position: relative;
}

.chat-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat-title {
  font-size: 18px;
  font-weight: 600;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 24px 100px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.message {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  max-width: 85%;
  padding: 12px 0;
  animation: messageIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes messageIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message.user {
  align-self: flex-end;
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 15px;
  border-bottom-right-radius: 4px;
}

.message.user .message-header {
  display: none;
}

.message.assistant {
  align-self: flex-start;
  background: transparent;
  border: none;
  padding: 0;
  width: 100%;
  max-width: 100%;
}

.message.system {
  align-self: center;
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.2);
  font-size: 13px;
  color: var(--accent-blue);
}

.message-content {
  white-space: normal;
  word-wrap: break-word;
  line-height: 1.55;
  font-size: 15px;
  color: #D4D4D8;
  letter-spacing: 0.01em;
  font-weight: 400;
}

.message.user .message-content {
  color: #F0F0F3;
}

.message-author {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
}

.message-time {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
  margin-left: 8px;
}

.message-content pre {
  background: #0d0d10;
  padding: 16px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  overflow-x: auto;
  margin: 12px 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: #e2e8f0;
}

.message-content code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--text-primary);
}

.message-content pre code {
  background: none;
  padding: 0;
  border: none;
  color: inherit;
}

/* ===== MESSAGE CONTENT MARKDOWN ===== */
.message-content h1 {
  font-size: 22px;
  font-weight: 700;
  margin: 16px 0 8px;
  color: var(--text-primary);
  line-height: 1.3;
  white-space: normal;
}

.message-content h2 {
  font-size: 18px;
  font-weight: 600;
  margin: 14px 0 6px;
  color: var(--text-primary);
  line-height: 1.3;
  white-space: normal;
}

.message-content h3 {
  font-size: 15px;
  font-weight: 600;
  margin: 12px 0 4px;
  color: var(--text-primary);
  line-height: 1.3;
  white-space: normal;
}

.message-content h4 {
  font-size: 14px;
  font-weight: 600;
  margin: 10px 0 4px;
  color: var(--text-primary);
  line-height: 1.3;
  white-space: normal;
}

.message-content hr {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin: 12px 0;
}

.message-content li {
  margin-left: 20px;
  margin-bottom: 2px;
  list-style: disc;
}

/* ===== MARKDOWN TABLES ===== */
.md-table-wrap {
  overflow-x: auto;
  margin: 14px 0;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.md-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  line-height: 1.5;
}

.md-table thead {
  background: rgba(99, 102, 241, 0.1);
  border-bottom: 1px solid rgba(99, 102, 241, 0.2);
}

.md-table th {
  padding: 10px 16px;
  text-align: left;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.md-table td {
  padding: 9px 16px;
  color: var(--text-secondary);
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.md-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.md-table tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.015);
}

.md-table tbody tr:nth-child(even):hover {
  background: rgba(255, 255, 255, 0.035);
}

.tool-file-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  margin-top: 10px;
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: 8px;
  transition: all 0.2s ease;
}

.tool-file-chip:hover {
  background: rgba(99, 102, 241, 0.18);
  border-color: rgba(99, 102, 241, 0.4);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.15);
}

.tool-file-chip .file-icon {
  display: flex;
  align-items: center;
  color: var(--accent-indigo);
}

.tool-file-chip .file-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tool-file-chip .file-download-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: var(--accent-indigo);
  color: white;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.15s ease;
}

.tool-file-chip .file-download-btn:hover {
  background: var(--accent-blue);
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

/* ===== STREAMING STEP UI - MANUS STYLE ===== */
.stream-message {
  display: flex;
  gap: 12px;
  align-self: flex-start;
  /* Transparent background for container */
  background: transparent;
  border: none;
  max-width: 100%;
  padding: 0;
  width: 100%;
}

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

.stream-step {
  margin-bottom: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  overflow: hidden;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.stream-step:hover {
  border-color: var(--border-default);
}

.stream-step-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background 0.15s ease;
  user-select: none;
}

.stream-step-header:hover {
  background: rgba(255, 255, 255, 0.02);
}

.stream-step-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  flex-shrink: 0;
  background: rgba(139, 92, 246, 0.1);
  /* Purple tint */
}

.stream-step-icon.spinning {
  color: var(--accent-purple);
  animation: spin 1s linear infinite;
}

.stream-step-icon.done {
  color: var(--accent-purple);
  background: rgba(139, 92, 246, 0.15);
}

.stream-step-icon.error {
  color: var(--accent-red);
  background: rgba(239, 68, 68, 0.15);
}

.stream-step-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stream-step.completed .stream-step-label {
  color: var(--text-muted);
}

.stream-step-chevron {
  color: var(--text-dim);
  transition: transform 0.2s ease;
  display: flex;
  align-items: center;
}

.stream-step.expanded .stream-step-chevron {
  transform: rotate(180deg);
}

.stream-step-body {
  display: none;
  padding: 4px 12px 12px 42px;
}

.stream-step.expanded .stream-step-body {
  display: block;
  animation: fadeIn 0.2s ease;
}

.stream-step-result {
  background: rgba(0, 0, 0, 0.25);
  padding: 10px 12px;
  border-radius: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-muted);
  white-space: pre-wrap;
  overflow-x: auto;
  max-height: 200px;
  overflow-y: auto;
  line-height: 1.5;
}

/* Thinking step pulse */
.stream-step.thinking .stream-step-label {
  color: var(--accent-blue);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

/* ===== PLAN WIDGET — PREMIUM TIMELINE ===== */
.plan-widget {
  background: linear-gradient(135deg, rgba(15, 15, 25, 0.8), rgba(20, 20, 35, 0.9));
  border: 1px solid rgba(99, 102, 241, 0.15);
  border-radius: 16px;
  margin: 12px 0;
  overflow: hidden;
  animation: planSlideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  backdrop-filter: blur(12px);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.plan-widget.plan-done {
  border-color: rgba(34, 197, 94, 0.25);
  box-shadow: 0 4px 24px rgba(34, 197, 94, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

@keyframes planSlideIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Header */
.plan-widget-header {
  padding: 16px 20px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.plan-widget-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.plan-widget-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(165, 180, 252, 0.8);
}

.plan-widget-icon {
  font-size: 14px;
}

.plan-widget-subtitle {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.4;
  margin-bottom: 12px;
}

.plan-widget-badge {
  font-size: 11px;
  font-weight: 700;
  color: rgba(165, 180, 252, 0.9);
  background: rgba(99, 102, 241, 0.12);
  padding: 3px 10px;
  border-radius: 100px;
  border: 1px solid rgba(99, 102, 241, 0.2);
  letter-spacing: 0.02em;
}

.plan-widget-badge.done {
  color: #86efac;
  background: rgba(34, 197, 94, 0.12);
  border-color: rgba(34, 197, 94, 0.2);
}

/* Progress track */
.plan-progress-track {
  height: 3px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.plan-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #6366f1, #818cf8, #a5b4fc);
  border-radius: 4px;
  transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.4);
}

.plan-progress-fill.done {
  background: linear-gradient(90deg, #22c55e, #4ade80, #86efac);
  box-shadow: 0 0 12px rgba(34, 197, 94, 0.4);
}

/* Timeline */
.plan-timeline {
  padding: 16px 20px 12px;
}

.plan-tl-step {
  display: flex;
  gap: 14px;
}

/* Gutter: circle + connector */
.plan-tl-gutter {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  width: 28px;
}

.plan-tl-circle {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
  transition: all 0.3s ease;
  position: relative;
  z-index: 1;
}

/* Pending circle */
.plan-tl-step.pending .plan-tl-circle {
  background: rgba(255, 255, 255, 0.04);
  border: 2px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.25);
}

/* Active circle: gradient with glow */
.plan-tl-step.active .plan-tl-circle {
  background: linear-gradient(135deg, #6366f1, #818cf8);
  border: 2px solid rgba(129, 140, 248, 0.5);
  color: white;
  box-shadow: 0 0 16px rgba(99, 102, 241, 0.5), 0 0 4px rgba(99, 102, 241, 0.8);
  animation: planCirclePulse 2s ease-in-out infinite;
}

.plan-num-spinner {
  display: flex;
  align-items: center;
  color: white;
}

/* Done circle: green */
.plan-tl-step.done .plan-tl-circle {
  background: linear-gradient(135deg, #22c55e, #4ade80);
  border: 2px solid rgba(74, 222, 128, 0.4);
  color: white;
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.3);
}

/* Skipped */
.plan-tl-step.skipped .plan-tl-circle {
  background: rgba(255, 255, 255, 0.04);
  border: 2px solid rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.2);
}

@keyframes planCirclePulse {

  0%,
  100% {
    box-shadow: 0 0 12px rgba(99, 102, 241, 0.3), 0 0 4px rgba(99, 102, 241, 0.6);
  }

  50% {
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.6), 0 0 8px rgba(99, 102, 241, 0.9);
  }
}

/* Vertical connector */
.plan-tl-connector {
  width: 2px;
  flex: 1;
  min-height: 12px;
  background: rgba(255, 255, 255, 0.06);
  margin: 4px 0;
  border-radius: 2px;
  transition: background 0.3s ease;
}

.plan-tl-step.done .plan-tl-connector {
  background: rgba(34, 197, 94, 0.25);
}

.plan-tl-step.active .plan-tl-connector {
  background: linear-gradient(180deg, rgba(99, 102, 241, 0.3), rgba(255, 255, 255, 0.06));
}

/* Content area */
.plan-tl-content {
  flex: 1;
  min-width: 0;
  padding-bottom: 16px;
}

.plan-tl-row {
  display: flex;
  align-items: center;
  min-height: 28px;
  gap: 8px;
}

.plan-tl-row.clickable {
  cursor: pointer;
}

.plan-tl-row.clickable:hover .plan-tl-label {
  color: var(--text-primary);
}

.plan-tl-label {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.5;
  transition: color 0.15s ease;
}

/* Label states */
.plan-tl-step.pending .plan-tl-label {
  color: rgba(255, 255, 255, 0.3);
}

.plan-tl-step.active .plan-tl-label {
  color: var(--text-primary);
  font-weight: 600;
}

.plan-tl-step.done .plan-tl-label {
  color: var(--text-muted);
}

.plan-tl-step.skipped .plan-tl-label {
  color: rgba(255, 255, 255, 0.2);
  text-decoration: line-through;
}

.plan-tl-chevron {
  display: flex;
  align-items: center;
  color: var(--text-dim);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.plan-tl-chevron.open {
  transform: rotate(180deg);
}

/* Expandable details */
.plan-tl-details {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.3s ease, opacity 0.2s ease, margin 0.2s ease;
  margin-top: 0;
}

.plan-tl-details.show {
  max-height: 400px;
  opacity: 1;
  margin-top: 8px;
}

.plan-tl-notes {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  padding: 8px 12px;
  background: rgba(99, 102, 241, 0.06);
  border-radius: 8px;
  border-left: 3px solid rgba(99, 102, 241, 0.3);
  margin-bottom: 8px;
}

.plan-tl-notes svg {
  flex-shrink: 0;
  margin-top: 2px;
  color: rgba(165, 180, 252, 0.6);
}

/* Tool chips inside timeline */
.plan-tl-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.plan-tl-tool {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  font-size: 11px;
  color: var(--text-dim);
  transition: background 0.15s ease;
}

.plan-tl-tool:hover {
  background: rgba(255, 255, 255, 0.06);
}

.plan-tl-tool .tc-status-icon {
  display: flex;
  align-items: center;
}

.plan-tl-tool span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

/* Active step shimmer effect */
.plan-tl-step.active .plan-tl-content {
  position: relative;
}

.plan-tl-step.active .plan-tl-content::before {
  content: '';
  position: absolute;
  top: -2px;
  left: -8px;
  right: -8px;
  bottom: -2px;
  background: linear-gradient(90deg,
      transparent 0%,
      rgba(99, 102, 241, 0.04) 30%,
      rgba(99, 102, 241, 0.08) 50%,
      rgba(99, 102, 241, 0.04) 70%,
      transparent 100%);
  border-radius: 8px;
  pointer-events: none;
  animation: planShimmer 3s ease-in-out infinite;
}

@keyframes planShimmer {

  0%,
  100% {
    opacity: 0;
  }

  50% {
    opacity: 1;
  }
}

/* Footer */
.plan-widget-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  font-size: 13px;
  font-weight: 600;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.plan-widget-footer.done {
  color: #86efac;
  background: rgba(34, 197, 94, 0.06);
}

/* ===== TYPING INDICATOR ===== */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  background: var(--accent-indigo);
  border-radius: 50%;
  animation: typing-bounce 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) {
  animation-delay: -0.32s;
}

.typing-indicator span:nth-child(2) {
  animation-delay: -0.16s;
}

.typing-indicator span:nth-child(3) {
  animation-delay: 0s;
}

@keyframes typing-bounce {

  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.5;
  }

  40% {
    transform: translateY(-5px);
    opacity: 1;
  }
}

/* ===== AGENT WORKING INDICATOR ===== */
.agent-working-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  margin-top: 8px;
  background: rgba(99, 102, 241, 0.06);
  border: 1px solid rgba(99, 102, 241, 0.15);
  border-radius: 12px;
  animation: workingFadeIn 0.3s ease;
  position: relative;
  overflow: hidden;
}

.agent-working-bar::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 200%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent-indigo), var(--accent-blue), transparent);
  animation: workingSlide 2s linear infinite;
}

.agent-working-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-indigo);
  animation: workingPulse 1.5s ease-in-out infinite;
  flex-shrink: 0;
}

.agent-working-text {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.agent-working-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(99, 102, 241, 0.2);
  border-top-color: var(--accent-indigo);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
  margin-left: auto;
}

@keyframes workingFadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes workingSlide {
  0% {
    left: -100%;
  }

  100% {
    left: 100%;
  }
}

@keyframes workingPulse {

  0%,
  100% {
    opacity: 0.4;
    transform: scale(0.85);
  }

  50% {
    opacity: 1;
    transform: scale(1);
  }
}

.thinking-message {
  margin-top: 8px;
  opacity: 1;
}

.thinking-message .message-body {
  min-height: auto;
  padding: 0;
  align-items: flex-end;
  /* Align to right near avatar */
}

/* Specific styling for the thinking bubble */
.thinking-message .typing-indicator {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  padding: 12px 16px;
  border-radius: 20px;
  border-bottom-right-radius: 4px;
  /* Bubble tail effect near avatar */
  box-shadow: var(--shadow-sm);
  gap: 6px;
}

.thinking-message .typing-indicator span {
  background: var(--accent-blue);
  /* Brighter blue */
  width: 6px;
  height: 6px;
}

@keyframes fadeIn {
  to {
    opacity: 1;
  }
}

/* ===== CHAT INPUT ===== */
.chat-input-container {
  padding: 0 24px 24px;
  background: linear-gradient(to top, var(--bg-void) 0%, transparent 100%);
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  z-index: 10;
  pointer-events: none;
  /* Let clicks pass through the gradient area */
}

.chat-input-wrapper {
  display: flex;
  align-items: flex-end;
  position: relative;
  pointer-events: auto;
  /* Re-enable clicks for input */
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 24px;
  box-shadow: var(--shadow-lg);
  transition: border-color 0.2s ease;
}

.chat-input-wrapper:focus-within {
  border-color: var(--accent-indigo);
}

.chat-input {
  flex: 1;
  background: transparent;
  border: none;
  border-radius: 24px;
  padding: 14px 50px 14px 20px;
  /* Right padding for button */
  color: var(--text-primary);
  box-shadow: none;
  font-size: 15px;
  resize: none;
  min-height: 52px;
  max-height: 200px;
  transition: none;
  font-family: inherit;
  line-height: 1.5;
}

.chat-input:focus {
  outline: none;
  box-shadow: none;
  border: none;
}

.chat-input::placeholder {
  color: var(--text-dim);
}

.send-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 0;
  width: 32px;
  height: 32px;
  color: var(--text-muted);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  right: 10px;
  bottom: 10px;
}

.send-btn:hover {
  background: var(--accent-indigo);
  color: white;
  border-color: var(--accent-indigo);
  box-shadow: var(--shadow-glow);
  transform: scale(1.05);
}

.send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.send-btn.stop-mode {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.4);
  color: #ef4444;
  animation: stopPulse 1.5s ease-in-out infinite;
}

.send-btn.stop-mode:hover {
  background: rgba(239, 68, 68, 0.3);
  color: #ff6b6b;
  border-color: rgba(239, 68, 68, 0.6);
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.2);
  transform: scale(1.05);
}

@keyframes stopPulse {

  0%,
  100% {
    opacity: 0.8;
  }

  50% {
    opacity: 1;
  }
}

/* ===== VOICE MODE ===== */
.voice-btn {
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 0;
  width: 32px;
  height: 32px;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  right: 50px;
  bottom: 10px;
  z-index: 2;
}

.voice-btn:hover {
  background: rgba(99, 102, 241, 0.1);
  color: var(--accent-indigo);
  border-color: var(--accent-indigo);
}

.voice-btn.active {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.4);
}

.voice-btn.listening {
  animation: voicePulse 1.5s ease-in-out infinite;
  box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
}

.voice-btn.speaking {
  background: rgba(99, 102, 241, 0.15);
  color: var(--accent-indigo);
  border-color: var(--accent-indigo);
  animation: voiceSpeaking 1s ease-in-out infinite;
}

.chat-input-wrapper.voice-active {
  border-color: rgba(239, 68, 68, 0.3);
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.08);
}

.chat-input-wrapper.voice-active .chat-input {
  padding-right: 90px;
}

@keyframes voicePulse {
  0% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5);
    transform: scale(1);
  }

  50% {
    box-shadow: 0 0 0 8px rgba(239, 68, 68, 0);
    transform: scale(1.08);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    transform: scale(1);
  }
}

@keyframes voiceSpeaking {

  0%,
  100% {
    opacity: 0.8;
    transform: scale(1);
  }

  50% {
    opacity: 1;
    transform: scale(1.05);
  }
}

/* ===== CHANNEL GRID ===== */
.channel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
}

.channel-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: var(--transition-default);
}

.channel-card:hover {
  border-color: var(--border-active);
  box-shadow: var(--shadow-md);
}

.channel-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.channel-stats {
  display: flex;
  gap: 24px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
}

.channel-stat {
  text-align: center;
  flex: 1;
}

.channel-stat-value {
  font-size: 20px;
  font-weight: 600;
}

.channel-stat-label {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
}

/* ===== SETUP WIZARD ===== */
.wizard-container {
  max-width: 700px;
  margin: 0 auto;
  padding: 40px 20px;
  overflow-y: auto;
  max-height: 100vh;
}

.wizard-header {
  text-align: center;
  margin-bottom: 40px;
}

.wizard-logo {
  font-size: 64px;
  margin-bottom: 16px;
  filter: drop-shadow(0 0 20px rgba(99, 102, 241, 0.3));
}

.wizard-title {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -1px;
  margin-bottom: 8px;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.wizard-subtitle {
  color: var(--text-muted);
  font-size: 15px;
}

.wizard-steps {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 40px;
}

.wizard-step {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 2px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  transition: var(--transition-default);
}

.wizard-step.active {
  background: var(--accent-indigo);
  border-color: var(--accent-indigo);
  color: white;
  box-shadow: var(--shadow-glow);
}

.wizard-step.completed {
  background: var(--accent-green);
  border-color: var(--accent-green);
  color: white;
}

.wizard-step-line {
  width: 32px;
  height: 2px;
  background: var(--border-subtle);
  align-self: center;
}

.wizard-step-line.completed {
  background: var(--accent-green);
}

.wizard-content {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 32px;
}

.wizard-section-title {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 8px;
}

.wizard-section-desc {
  color: var(--text-muted);
  margin-bottom: 24px;
  font-size: 14px;
}

.wizard-actions {
  display: flex;
  justify-content: space-between;
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border-subtle);
}

/* ===== PREREQ ITEMS ===== */
.prereq-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.prereq-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  transition: var(--transition-fast);
}

.prereq-item:hover {
  background: var(--bg-hover);
}

.prereq-icon {
  font-size: 18px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface);
  border-radius: 6px;
  flex-shrink: 0;
}

.prereq-info {
  flex: 1;
}

.prereq-name {
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 1px;
}

.prereq-desc {
  font-size: 11px;
  color: var(--text-muted);
}

.prereq-status {
  font-size: 12px;
  white-space: nowrap;
  color: var(--text-secondary);
}

/* ===== SPINNER ===== */
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--bg-elevated);
  border-top-color: var(--accent-indigo);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ===== SKILL EDITOR MODAL ===== */
.skill-editor-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.skill-editor-modal {
  background: var(--bg-surface);
  border-radius: 16px;
  width: 100%;
  max-width: 900px;
  height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  border: 1px solid var(--border-subtle);
}

.skill-editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  border-radius: 16px 16px 0 0;
}

.skill-editor-content {
  flex: 1;
  overflow: hidden;
  padding: 0;
}

.skill-editor-textarea {
  width: 100%;
  height: 100%;
  background: #1a1a2e;
  color: #98d1ce;
  border: none;
  padding: 20px;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 13px;
  line-height: 1.6;
  resize: none;
  outline: none;
  white-space: pre;
  overflow: auto;
}

.skill-editor-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.skill-editor-sidebar {
  width: 220px;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.skill-tree-header {
  padding: 10px 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-tertiary);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.btn-icon {
  padding: 4px;
  border-radius: 4px;
  min-width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.skill-tree {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.skill-tree-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.skill-tree-item.file:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.skill-tree-item.file.active {
  background: var(--accent-blue);
  color: white;
}

.skill-tree-item.folder {
  color: var(--text-tertiary);
  font-weight: 500;
  cursor: default;
  justify-content: space-between;
}

.skill-tree-item.folder span {
  display: flex;
  align-items: center;
  gap: 6px;
}

.skill-tree-folder {
  margin-bottom: 4px;
}

.btn-tree-action {
  opacity: 0;
  padding: 2px 4px;
  background: var(--bg-base);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-tertiary);
  transition: all 0.15s;
  display: flex;
  align-items: center;
}

.skill-tree-item.folder:hover .btn-tree-action {
  opacity: 1;
}

.btn-tree-action:hover {
  background: var(--accent-blue);
  color: white;
  border-color: var(--accent-blue);
}

.skill-editor-content {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ===== MD SKILLS GRID ===== */
.md-skills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}

.md-skill-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.md-skill-card:hover {
  border-color: var(--accent-blue);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.md-skill-header {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.md-skill-icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  flex-shrink: 0;
}

.md-skill-meta {
  flex: 1;
  min-width: 0;
}

.md-skill-meta h3 {
  margin: 0 0 6px 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.md-skill-desc {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-secondary);
  flex: 1;
}

.md-skill-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
}

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

/* Create Skill Modal */
.create-skill-modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  width: 90%;
  max-width: 480px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.4);
}

/* ===== STATUS INDICATOR ===== */
.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--bg-elevated);
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
}

/* ===== SCROLLBARS ===== */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--bg-hover);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-dim);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1200px) {
  .bento-sm {
    grid-column: span 6;
  }

  .bento-md {
    grid-column: span 6;
  }

  .bento-lg {
    grid-column: span 12;
  }

  .bento-xl {
    grid-column: span 12;
  }
}

@media (max-width: 768px) {
  .sidebar {
    width: 60px;
    padding: 16px 0;
  }

  .nav-item {
    width: 40px;
    height: 40px;
  }

  .content-area {
    padding: 16px;
  }

  .bento-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .bento-sm,
  .bento-md,
  .bento-lg,
  .bento-xl,
  .bento-full {
    grid-column: span 1;
  }
}

/* ===== ANIMATION KEYFRAMES ===== */
@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== CHAT REDESIGN ===== */
.chat-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
  background: var(--bg-void);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 40px 20px 120px;
  /* Extra bottom padding for floating input */
  display: flex;
  flex-direction: column;
  gap: 32px;
  scroll-behavior: smooth;
  scrollbar-width: none;
  /* Firefox */
  -ms-overflow-style: none;
  /* IE/Edge */
}

.chat-messages::-webkit-scrollbar {
  display: none;
  /* Chrome/Safari */
}

.chat-messages-inner {
  max-width: 768px;
  /* Standard reading width */
  margin: 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  text-align: center;
  opacity: 0.8;
  animation: fadeIn 0.5s ease;
}

.empty-state-icon {
  font-size: 64px;
  margin-bottom: 24px;
  filter: drop-shadow(0 0 20px rgba(99, 102, 241, 0.4));
  animation: float 6s ease-in-out infinite;
}

@keyframes float {
  0% {
    transform: translateY(0px);
  }

  50% {
    transform: translateY(-10px);
  }

  100% {
    transform: translateY(0px);
  }
}

.empty-state-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}



/* Tool Calls – compact chip design */
.tool-call-group,
.tool-call-group-single {
  margin-top: 8px;
}

.tool-call-group-details {
  border: none;
  background: none;
}

.tool-call-group-details summary::-webkit-details-marker,
.tool-call-group-details summary::marker {
  display: none;
  content: '';
}

.tool-call-group-summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
  user-select: none;
  list-style: none;
}

.tool-call-group-summary:hover {
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.04);
}

.tool-call-group-meta {
  color: var(--text-dim);
  font-size: 11px;
  margin-left: 4px;
}

.tool-call-group-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 0 0 6px;
  border-left: 1px solid var(--border-subtle);
  margin-left: 8px;
  margin-top: 2px;
}

/* Individual tool chip */
.tool-call-chip {
  border-radius: 6px;
  transition: background 0.15s;
  cursor: pointer;
}

.tool-call-chip:hover {
  background: rgba(255, 255, 255, 0.03);
}

.tool-call-chip-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  font-size: 12px;
  color: var(--text-secondary);
}

.tool-call-chip-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tool-call-chip-chevron {
  color: var(--text-dim);
  transition: transform 0.15s;
  flex-shrink: 0;
}

.tool-call-chip.expanded .tool-call-chip-chevron {
  transform: rotate(180deg);
}

/* Status icons */
.tc-status-icon {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.tc-status-icon.done {
  color: var(--accent-green);
}

.tc-status-icon.error {
  color: var(--accent-red);
}

.tc-status-icon.running {
  color: var(--accent-blue);
}

.tc-status-icon.spinning svg {
  animation: spin 0.8s linear infinite;
}

/* Expandable body */
.tool-call-chip-body {
  display: none;
  padding: 4px 8px 6px 26px;
  font-size: 11px;
  color: var(--text-muted);
  max-height: 200px;
  overflow-y: auto;
}

.tool-call-chip-body.expanded,
.tool-call-chip-body.show {
  display: block;
}

.tool-call-args {
  white-space: pre-wrap;
  word-break: break-all;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 11px;
  line-height: 1.4;
  color: var(--text-dim);
  padding: 4px 0;
}

.tool-call-result {
  white-space: pre-wrap;
  word-break: break-all;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 11px;
  line-height: 1.4;
  color: var(--text-dim);
  margin-top: 4px;
  max-height: 160px;
  overflow-y: auto;
}

.tool-file-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  padding: 4px 10px;
  background: var(--bg-elevated);
  border-radius: 6px;
  font-size: 12px;
}

.tool-file-chip .file-icon {
  color: var(--accent-blue);
}

.tool-file-chip .file-name {
  color: var(--text-secondary);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tool-file-chip .file-download-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--accent-blue);
  text-decoration: none;
  font-size: 11px;
  font-weight: 500;
}

.tool-file-chip .file-download-btn:hover {
  text-decoration: underline;
}

/* Streaming chip overrides */
.stream-chip .tool-call-chip-body.show {
  display: block;
}

/* ============================================
   Skills Page Styles
   ============================================ */

.skills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 20px;
}

.skill-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 20px;
  transition: border-color 0.2s;
}

.skill-card:hover {
  border-color: var(--border-hover);
}

.skill-card.enabled {
  border-color: var(--accent-green);
}

.skill-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}

.skill-icon-wrap {
  width: 48px;
  height: 48px;
  background: var(--bg-secondary);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.skill-icon {
  color: var(--accent-indigo);
}

.skill-info {
  flex: 1;
}

.skill-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 4px 0;
}

.skill-desc {
  font-size: 13px;
  color: var(--text-muted);
}

.skill-body {
  border-top: 1px solid var(--border-subtle);
  padding-top: 16px;
}

.skill-status {
  margin-bottom: 12px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

.status-badge.success {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-green);
}

.status-badge.warning {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
}

.skill-help {
  background: var(--bg-secondary);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 16px;
}

.skill-help p {
  margin: 0 0 10px 0;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.skill-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--accent-indigo);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
}

.skill-link:hover {
  text-decoration: underline;
}

.skill-form {
  display: flex;
  gap: 10px;
}

.skill-form .form-input {
  flex: 1;
}

.skill-form .btn {
  white-space: nowrap;
}

/* ===== SIDEBAR USER ===== */
.sidebar-user {
  padding: 12px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #5865f2, #4752c4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  color: white;
  flex-shrink: 0;
}

.user-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.user-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: capitalize;
}

.logout-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
  flex-shrink: 0;
}

.logout-btn:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.3);
  color: var(--accent-red);
}

/* ===== USER MANAGEMENT ===== */
.user-section {
  margin-top: 24px;
}

.user-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.user-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.user-item-avatar {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, #5865f2, #4752c4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 16px;
  color: white;
  flex-shrink: 0;
}

.user-item-info {
  flex: 1;
  min-width: 0;
}

.user-item-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.user-item-meta {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  gap: 12px;
  margin-top: 2px;
}

.user-item-actions {
  display: flex;
  gap: 8px;
}

.role-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-radius: 6px;
}

.role-badge.admin {
  background: rgba(88, 101, 242, 0.15);
  color: #8890f2;
}

.role-badge.user {
  background: rgba(107, 114, 128, 0.15);
  color: var(--text-muted);
}

.add-user-form {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.add-user-form .form-group {
  flex: 1;
  min-width: 150px;
  margin-bottom: 0;
}

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.15s ease;
}

.modal-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 100%;
  max-width: 420px;
  animation: slideUp 0.2s ease;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal-title {
  font-size: 18px;
  font-weight: 600;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--bg-elevated);
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
}

.modal-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: var(--accent-red);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

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

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

/* ===== LIVE LOG STREAMING ===== */
@keyframes livePulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.4;
  }
}

@keyframes logFadeIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}