/* ==========================================================================
   YouTube Studio Assistant — Ultra-Premium Dark Theme Design System
   ========================================================================== */

:root {
  /* Color Tokens */
  --bg-primary: #09090b;
  --bg-secondary: #121215;
  --bg-tertiary: #18181c;
  --bg-elevated: #1f1f24;
  --bg-glass: rgba(18, 18, 22, 0.75);
  --bg-glass-card: rgba(24, 24, 28, 0.65);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.16);
  --border-focus: rgba(255, 0, 0, 0.5);

  /* YouTube Brand Accents */
  --yt-red: #ff0000;
  --yt-red-dark: #cc0000;
  --yt-red-deep: #800000;
  --yt-red-glow: rgba(255, 0, 0, 0.35);
  --yt-red-soft: rgba(255, 0, 0, 0.12);

  /* Status Accents */
  --accent-emerald: #10b981;
  --accent-emerald-glow: rgba(16, 185, 129, 0.3);
  --accent-blue: #3b82f6;
  --accent-purple: #8b5cf6;
  --accent-amber: #f59e0b;

  /* Typography Colors */
  --text-primary: #f4f4f5;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;
  --text-inverse: #09090b;

  /* Font Families */
  --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Outfit', var(--font-sans);
  --font-mono: 'JetBrains Mono', monospace;

  /* Transitions */
  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Custom Sleek Dark Scrollbar */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

/* Base Styles */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Background Atmospheric Glow */
body::before {
  content: '';
  position: fixed;
  top: -150px;
  right: -100px;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, var(--yt-red-soft) 0%, transparent 70%);
  z-index: 0;
  pointer-events: none;
  filter: blur(60px);
}

body::after {
  content: '';
  position: fixed;
  bottom: -150px;
  left: 10%;
  width: 450px;
  height: 450px;
  background: radial-gradient(circle, rgba(59, 130, 246, 0.06) 0%, transparent 70%);
  z-index: 0;
  pointer-events: none;
  filter: blur(80px);
}

/* App Container */
.app-container {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100vh;
  z-index: 1;
}

/* ==========================================================================
   Header Bar
   ========================================================================== */
.app-header {
  height: 68px;
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  flex-shrink: 0;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.logo-wrapper {
  position: relative;
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, #ff1a1a 0%, #cc0000 100%);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px var(--yt-red-glow);
}

.yt-logo-icon {
  width: 22px;
  height: 22px;
  color: #ffffff;
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-title-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand-title-row h1 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #ffffff;
}

.badge-ai {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 2px 7px;
  background: var(--yt-red-soft);
  color: var(--yt-red);
  border: 1px solid rgba(255, 0, 0, 0.25);
  border-radius: 12px;
}

.brand-subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Connection Status Pill */
.connection-status-pill {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 6px 12px;
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--accent-emerald);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--accent-emerald);
  transition: background-color var(--transition-fast), box-shadow var(--transition-fast);
}

.status-dot.online {
  background-color: var(--accent-emerald);
}

.status-dot.offline {
  background-color: #ef4444 !important;
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.6) !important;
  animation: none !important;
}

.status-dot.pulsing {
  box-shadow: 0 0 0 0 var(--accent-emerald-glow);
  animation: pulse-emerald 2s infinite;
}

@keyframes pulse-emerald {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.latency-badge {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  background: rgba(16, 185, 129, 0.15);
  padding: 1px 6px;
  border-radius: 4px;
}

/* Icon Buttons */
.icon-button {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 8px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.icon-button:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border-color: var(--border-hover);
  transform: translateY(-1px);
}

.icon-button svg {
  width: 16px;
  height: 16px;
}

.icon-button.icon-only {
  padding: 8px;
}

/* ==========================================================================
   Workspace Layout (Sidebar + Chat Viewport)
   ========================================================================== */
.app-workspace {
  display: flex;
  flex: 1;
  overflow: hidden;
  height: calc(100vh - 68px);
}

/* Sidebar Panel */
.sidebar-panel {
  width: 320px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0.85rem;
  overflow-y: auto;
  overflow-x: hidden;
  flex-shrink: 0;
}

/* Glass Card */
.glass-card {
  background: var(--bg-glass-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  backdrop-filter: blur(12px);
  padding: 0.75rem 0.85rem;
}

/* Channel Identity Card */
.channel-card {
  position: relative;
  overflow: hidden;
}

.channel-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--yt-red) 0%, #ff4d4d 100%);
}

.channel-header {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.55rem;
}

.channel-avatar {
  position: relative;
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, #1f1f25 0%, #2b2b35 100%);
  border: 1.5px solid rgba(255, 0, 0, 0.4);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--yt-red);
}

.online-indicator {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-emerald);
  border: 2px solid var(--bg-secondary);
}

.channel-name-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.channel-name {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  color: #ffffff;
}

.verified-icon {
  width: 14px;
  height: 14px;
  color: var(--accent-blue);
}

.channel-handle {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.btn-refresh-stats {
  margin-left: auto;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.btn-refresh-stats:hover {
  color: var(--text-primary);
  background: var(--bg-card);
  border-color: var(--border-subtle);
}

.btn-refresh-stats svg {
  width: 14px;
  height: 14px;
}

.btn-refresh-stats.spinning svg {
  animation: spin-stats 1s linear infinite;
}

@keyframes spin-stats {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.channel-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.45rem;
}

.stat-box {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-subtle);
  border-radius: 7px;
  padding: 0.45rem 0.5rem;
  display: flex;
  flex-direction: column;
}

.stat-label {
  font-size: 0.62rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 600;
  color: #ffffff;
  margin-top: 1px;
}

.stat-value.text-accent {
  color: var(--yt-red);
}

/* Quick Actions Section */
.quick-actions-section {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.section-title {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding-left: 0.2rem;
}

.action-buttons-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.action-btn {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.45rem 0.65rem;
  background: var(--bg-glass-card);
  border: 1px solid var(--border-subtle);
  border-radius: 9px;
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.action-btn:hover {
  background: var(--bg-elevated);
  border-color: var(--border-hover);
  transform: translateX(2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.action-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.action-icon svg {
  width: 15px;
  height: 15px;
}

.action-icon.red { background: var(--yt-red-soft); color: var(--yt-red); }
.action-icon.blue { background: rgba(59, 130, 246, 0.12); color: var(--accent-blue); }
.action-icon.purple { background: rgba(139, 92, 246, 0.12); color: var(--accent-purple); }
.action-icon.green { background: rgba(16, 185, 129, 0.12); color: var(--accent-emerald); }

.action-text strong {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: #ffffff;
}

.action-text small {
  display: block;
  font-size: 0.68rem;
  color: var(--text-muted);
}

/* Workflow Info Card */
.workflow-info-card {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.72rem;
  padding: 0.55rem 0.75rem;
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.info-label {
  color: var(--text-muted);
}

.info-value {
  color: var(--text-secondary);
  font-weight: 500;
}

.text-emerald {
  color: var(--accent-emerald) !important;
}

/* ==========================================================================
   Chat Viewport
   ========================================================================== */
.chat-viewport {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at top, rgba(255, 0, 0, 0.03) 0%, transparent 60%);
  overflow: hidden;
  position: relative;
}

.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 1.75rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  scroll-behavior: smooth;
}

/* Welcome Hero */
.welcome-hero {
  max-width: 680px;
  margin: auto;
  text-align: center;
  padding: 2rem 0;
  animation: fade-in-up 0.5s ease-out;
}

@keyframes fade-in-up {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 4px 12px;
  background: var(--yt-red-soft);
  border: 1px solid rgba(255, 0, 0, 0.25);
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--yt-red);
  margin-bottom: 1rem;
}

.hero-title {
  font-family: var(--font-display);
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #ffffff;
  margin-bottom: 0.6rem;
}

.hero-description {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 2rem;
}

.starter-cards-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
  text-align: left;
}

.starter-card {
  background: var(--bg-glass-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 1rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.starter-card:hover {
  background: var(--bg-elevated);
  border-color: rgba(255, 0, 0, 0.35);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.starter-icon {
  font-size: 1.4rem;
  margin-bottom: 0.4rem;
}

.starter-card h4 {
  font-size: 0.9rem;
  font-weight: 600;
  color: #ffffff;
  margin-bottom: 0.25rem;
}

.starter-card p {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ==========================================================================
   Chat Message Bubbles
   ========================================================================== */
.message-row {
  display: flex;
  gap: 0.85rem;
  max-width: 82%;
  animation: message-slide-in 0.3s ease-out;
}

@keyframes message-slide-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.message-row.user {
  margin-left: auto;
  flex-direction: row-reverse;
}

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.85rem;
  font-weight: 700;
}

.message-row.assistant .message-avatar {
  background: linear-gradient(135deg, #cc0000 0%, #800000 100%);
  color: #ffffff;
  border: 1px solid rgba(255, 0, 0, 0.3);
  box-shadow: 0 2px 10px var(--yt-red-glow);
}

.message-row.user .message-avatar {
  background: #27272a;
  color: #f4f4f5;
  border: 1px solid var(--border-subtle);
}

.message-content-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.message-bubble {
  padding: 1rem 1.25rem;
  border-radius: 16px;
  font-size: 0.95rem;
  line-height: 1.6;
  position: relative;
  word-break: break-word;
}

.message-row.user .message-bubble {
  background: linear-gradient(135deg, #e60000 0%, #b30000 100%);
  color: #ffffff;
  border-top-right-radius: 4px;
  box-shadow: 0 4px 16px var(--yt-red-glow);
}

.message-row.assistant .message-bubble {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-top-left-radius: 4px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

.message-time {
  font-size: 0.72rem;
  color: var(--text-muted);
  padding: 0 0.4rem;
}

.message-row.user .message-time {
  text-align: right;
}

/* Rendered Markdown Styles inside Assistant Bubble */
.message-bubble p {
  margin-bottom: 0.65rem;
}
.message-bubble p:last-child {
  margin-bottom: 0;
}

.message-bubble strong {
  color: #ffffff;
  font-weight: 600;
}

.message-bubble ul, .message-bubble ol {
  margin: 0.5rem 0 0.75rem 1.4rem;
}

.message-bubble li {
  margin-bottom: 0.35rem;
}

.message-bubble a {
  color: #ff4d4d;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.message-bubble a:hover {
  color: #ff8080;
}

.message-bubble code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: rgba(0, 0, 0, 0.4);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
  color: #ff9999;
}

.message-bubble pre {
  margin: 0.65rem 0;
  background: #0d0d10;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 0.85rem;
  overflow-x: auto;
}

.message-bubble pre code {
  background: transparent;
  padding: 0;
  border: none;
  color: #e4e4e7;
}

/* Typing Indicator */
.typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0.5rem 0.75rem;
}

.typing-indicator span {
  width: 7px;
  height: 7px;
  background-color: var(--yt-red);
  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; }

@keyframes typing-bounce {
  0%, 80%, 100% { transform: scale(0); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; box-shadow: 0 0 8px var(--yt-red-glow); }
}

/* ==========================================================================
   Chat Input Dock
   ========================================================================== */
.chat-input-dock {
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-subtle);
  padding: 0.85rem 2rem 1.25rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Suggestion Chips */
.suggestion-chips {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 2px;
}

.chip {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  white-space: nowrap;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.chip:hover {
  background: rgba(255, 0, 0, 0.1);
  border-color: rgba(255, 0, 0, 0.35);
  color: #ffffff;
  transform: translateY(-1px);
}

/* Input Form */
.input-form {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
}

.input-wrapper {
  position: relative;
  flex: 1;
}

#chatInput {
  width: 100%;
  min-height: 52px;
  max-height: 180px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 14px 16px;
  color: #ffffff;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  line-height: 1.5;
  resize: none;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

#chatInput:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--yt-red-soft);
}

#chatInput::placeholder {
  color: var(--text-muted);
}

.send-button {
  width: 52px;
  height: 52px;
  background: linear-gradient(135deg, #ff0000 0%, #cc0000 100%);
  border: none;
  border-radius: 14px;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 16px var(--yt-red-glow);
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.send-button:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(255, 0, 0, 0.5);
}

.send-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.send-icon {
  width: 20px;
  height: 20px;
}

.btn-spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.send-button.loading .send-icon { display: none; }
.send-button.loading .btn-spinner { display: block; }

@keyframes spin {
  to { transform: rotate(360deg); }
}

.input-footer-hint {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.73rem;
  color: var(--text-muted);
  padding: 0 0.35rem;
}

/* ==========================================================================
   Settings Modal
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fade-in 0.2s ease-out;
}

.modal-backdrop.open {
  display: flex;
}

.modal-dialog {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  width: 90%;
  max-width: 520px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  animation: scale-up 0.2s ease-out;
}

@keyframes scale-up {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-header h3 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  color: #ffffff;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}
.modal-close:hover { color: #ffffff; }

.modal-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-control {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 10px 14px;
  color: #ffffff;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  outline: none;
}
.form-control:focus {
  border-color: var(--border-focus);
}

.input-with-action {
  display: flex;
  gap: 0.5rem;
}

.btn-subtle {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  color: var(--text-secondary);
  padding: 0 12px;
  font-size: 0.8rem;
  cursor: pointer;
  white-space: nowrap;
}
.btn-subtle:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.form-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.form-hint code {
  color: var(--yt-red);
}

.modal-actions-row {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.btn-primary {
  flex: 1;
  background: var(--yt-red);
  color: #ffffff;
  border: none;
  border-radius: 10px;
  padding: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.btn-primary:hover { background: var(--yt-red-dark); }

.btn-secondary {
  flex: 1;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 10px;
  font-weight: 500;
  cursor: pointer;
}
.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #ffffff;
}

.test-result-box {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.8rem;
  line-height: 1.4;
}
.test-result-box.success {
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #34d399;
}
.test-result-box.error {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #f87171;
}

/* Toast Notification */
.toast-notification {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(24, 24, 28, 0.95);
  border: 1px solid rgba(255, 0, 0, 0.4);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 15px rgba(255, 0, 0, 0.2);
  backdrop-filter: blur(12px);
  color: #ffffff;
  padding: 8px 18px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast-notification.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ==========================================================================
   Thought Process & Live Action Trail
   ========================================================================== */
.thought-trail-card {
  margin-bottom: 0.65rem;
  background: rgba(20, 20, 26, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  overflow: hidden;
  transition: all var(--transition-smooth);
}

.thought-trail-card.active {
  border-color: rgba(59, 130, 246, 0.35);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25), 0 0 12px rgba(59, 130, 246, 0.1);
}

.thought-trail-card.completed {
  border-color: rgba(16, 185, 129, 0.2);
}

.thought-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.9rem;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  cursor: pointer;
  text-align: left;
  transition: background var(--transition-fast);
}

.thought-header:hover {
  background: rgba(255, 255, 255, 0.04);
}

.thought-header-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.thought-brain-icon {
  font-size: 0.95rem;
  animation: pulse-slow 2s infinite ease-in-out;
}

@keyframes pulse-slow {
  0%, 100% { transform: scale(1); opacity: 0.85; }
  50% { transform: scale(1.15); opacity: 1; }
}

.thought-title {
  font-weight: 600;
  color: #e4e4e7;
}

.thought-header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.thought-duration-badge {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 2px 6px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 4px;
  color: var(--text-muted);
}

.thought-chevron {
  width: 14px;
  height: 14px;
  transition: transform var(--transition-smooth);
}

.thought-trail-card.collapsed .thought-chevron {
  transform: rotate(-90deg);
}

.thought-body {
  padding: 0.5rem 0.9rem 0.85rem 0.9rem;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  transition: all var(--transition-smooth);
}

.thought-trail-card.collapsed .thought-body {
  display: none;
}

/* Individual Action Steps */
.action-step-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  transition: all var(--transition-fast);
}

.action-step-item.running {
  color: #ffffff;
  font-weight: 500;
}

.action-step-item.done {
  color: #a1a1aa;
}

.step-indicator {
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.step-spinner {
  width: 12px;
  height: 12px;
  border: 2px solid rgba(59, 130, 246, 0.2);
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.step-check {
  width: 14px;
  height: 14px;
  color: var(--accent-emerald);
}

.step-pending-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
}

.thought-reasoning-snippet {
  margin-top: 0.4rem;
  padding: 0.6rem 0.75rem;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: #a1a1aa;
  line-height: 1.5;
  white-space: pre-wrap;
  border-left: 2px solid var(--accent-purple);
}

/* ==========================================================================
   Schedule & Pipeline Controller Card Styles (Compact & Integrated)
   ========================================================================== */
.schedule-control-card {
  padding: 0.75rem 0.85rem;
  background: rgba(18, 18, 24, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

.schedule-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.55rem;
}

.schedule-title-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.schedule-icon {
  width: 16px;
  height: 16px;
  color: #ff3333;
  filter: drop-shadow(0 0 6px rgba(255, 0, 0, 0.4));
  flex-shrink: 0;
}

.schedule-title-text h4 {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1.2;
}

.schedule-status-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 1px;
}

.schedule-badge {
  display: inline-block;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 1px 5px;
  border-radius: 4px;
  text-transform: uppercase;
}

.schedule-badge.active {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.schedule-badge.paused {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.schedule-display-time {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  color: #ff4d4d;
}

/* Modern Toggle Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 32px;
  height: 18px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.15);
  transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 20px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 12px;
  width: 12px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 50%;
}

input:checked + .slider {
  background-color: #ff2222;
  box-shadow: 0 0 8px rgba(255, 34, 34, 0.5);
}

input:checked + .slider:before {
  transform: translateX(14px);
}

/* Schedule Controls Body */
.schedule-controls-body {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.schedule-time-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.time-input-wrap {
  flex: 1;
}

.schedule-time-input {
  width: 100%;
  height: 30px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  color: var(--text-primary);
  padding: 0 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  outline: none;
  transition: border-color 0.2s;
}

.schedule-time-input:focus {
  border-color: #ff3333;
  box-shadow: 0 0 0 2px rgba(255, 51, 51, 0.2);
}

.btn-sm {
  padding: 0 0.65rem !important;
  font-size: 0.75rem !important;
  height: 30px !important;
  line-height: 30px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

.schedule-topic-wrap {
  width: 100%;
}

.pipeline-topic-input {
  width: 100%;
  height: 28px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  color: var(--text-primary);
  padding: 0 0.55rem;
  font-size: 0.72rem;
  outline: none;
  transition: border-color 0.2s;
}

.pipeline-topic-input:focus {
  border-color: rgba(255, 255, 255, 0.25);
}

.pipeline-topic-input::placeholder {
  color: rgba(255, 255, 255, 0.3);
}

/* Run Pipeline Now Button */
.btn-run-now {
  width: 100%;
  height: 32px;
  background: linear-gradient(135deg, #cc0000 0%, #990000 100%);
  color: #ffffff;
  border: 1px solid rgba(255, 50, 50, 0.4);
  border-radius: 7px;
  font-size: 0.76rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 3px 10px rgba(204, 0, 0, 0.25);
}

.btn-run-now:hover {
  background: linear-gradient(135deg, #e60000 0%, #b30000 100%);
  box-shadow: 0 4px 14px rgba(230, 0, 0, 0.4);
}

.btn-run-now:active {
  transform: translateY(0);
}

.btn-run-now:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-run-now .play-icon {
  width: 12px;
  height: 12px;
}

.run-spinner {
  width: 12px;
  height: 12px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ==========================================================================
   Live Pipeline Progress Tracker Card
   ========================================================================== */
.pipeline-progress-card {
  background: linear-gradient(135deg, rgba(26, 26, 36, 0.95) 0%, rgba(18, 18, 24, 0.98) 100%);
  border: 1px solid rgba(255, 60, 60, 0.3);
  border-radius: 12px;
  padding: 1rem 1.15rem;
  margin: 0.85rem 0;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 15px rgba(255, 0, 0, 0.1);
  animation: fadeIn 0.3s ease;
}

.pipeline-progress-header {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.85rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.pulse-dot-pipeline {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background-color: #ff3333;
  box-shadow: 0 0 8px rgba(255, 51, 51, 0.8);
  animation: pulse-red 1.5s infinite;
}

@keyframes pulse-red {
  0% { transform: scale(0.9); box-shadow: 0 0 0 0 rgba(255, 51, 51, 0.7); }
  70% { transform: scale(1.1); box-shadow: 0 0 0 8px rgba(255, 51, 51, 0); }
  100% { transform: scale(0.9); box-shadow: 0 0 0 0 rgba(255, 51, 51, 0); }
}

.pipeline-progress-header .pipeline-title {
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 0.02em;
}

.pipeline-status-badge {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.pipeline-status-badge.running {
  background: rgba(245, 158, 11, 0.18);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.pipeline-status-badge.completed {
  background: rgba(16, 185, 129, 0.18);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.pipeline-status-badge.failed {
  background: rgba(239, 68, 68, 0.18);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.35);
}

.pipeline-steps-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.pipeline-step-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.45rem 0.65rem;
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid transparent;
  transition: all 0.25s ease;
  font-size: 0.8rem;
}

.pipeline-step-item.waiting {
  opacity: 0.45;
  color: var(--text-muted);
}

.pipeline-step-item.running {
  background: rgba(59, 130, 246, 0.1);
  border-color: rgba(59, 130, 246, 0.3);
  color: #93c5fd;
  font-weight: 500;
}

.pipeline-step-item.completed {
  background: rgba(16, 185, 129, 0.08);
  border-color: rgba(16, 185, 129, 0.2);
  color: #d1fae5;
}

.pipeline-step-item.failed {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

.step-icon {
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
}

.step-text {
  flex: 1;
}

.step-status-indicator {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.step-spinner {
  width: 11px;
  height: 11px;
  border: 2px solid rgba(147, 197, 253, 0.3);
  border-top-color: #93c5fd;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

/* Completion Banner Inside Progress Card */
.pipeline-completed-banner {
  margin-top: 0.85rem;
  padding: 0.85rem 1rem;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.12) 0%, rgba(5, 150, 105, 0.15) 100%);
  border: 1px solid rgba(16, 185, 129, 0.35);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.completed-header-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.9rem;
  color: #34d399;
}

.completed-video-title {
  font-size: 0.82rem;
  color: #ffffff;
  font-weight: 500;
  line-height: 1.4;
}

.completed-actions-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.25rem;
}

.btn-watch-yt {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: #ff0000;
  color: #ffffff;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.76rem;
  font-weight: 600;
  text-decoration: none;
  transition: all var(--transition-fast);
  box-shadow: 0 2px 8px rgba(255, 0, 0, 0.35);
}

.btn-watch-yt:hover {
  background: #cc0000;
  box-shadow: 0 4px 14px rgba(255, 0, 0, 0.5);
}

.btn-watch-yt svg {
  width: 14px;
  height: 14px;
}

.completed-email-note {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* ==========================================================================
   Responsive Adaptations
   ========================================================================== */
@media (max-width: 900px) {
  .sidebar-panel {
    display: none;
  }
  .messages-container {
    padding: 1.25rem;
  }
  .starter-cards-grid {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   Agent Graceful Error & Retry Card
   ========================================================================== */
.agent-error-card {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.08) 0%, rgba(245, 158, 11, 0.06) 100%);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  margin: 0.5rem 0;
  box-shadow: 0 4px 16px rgba(239, 68, 68, 0.08);
}

.agent-error-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
}

.error-badge-icon {
  font-size: 1.1rem;
  line-height: 1;
}

.error-card-title {
  font-weight: 700;
  font-size: 0.92rem;
  color: #fca5a5;
  letter-spacing: -0.01em;
}

.agent-error-desc {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0 0 0.85rem 0;
}

.agent-error-desc code {
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
  color: #fbbf24;
  font-size: 0.8rem;
}

.agent-error-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.btn-retry-message {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: #ffffff;
  border: none;
  padding: 7px 16px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.35);
}

.btn-retry-message:hover {
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.5);
}

.btn-retry-message:active {
  transform: translateY(0);
}

