/* ==========================================================================
   Design System & Variables
   ========================================================================== */
:root {
  /* Fallback Colors (Dynamically updated via engine.js) */
  --color-primary: #635bff;
  --color-primary-rgb: 99, 91, 255;
  --color-background: #0a2540;
  --bg-panel: rgba(26, 30, 43, 0.5);
  --bg-panel-rgb: 26, 30, 43;
  
  /* Constant Colors */
  --color-text-main: #f3f4f6;
  --color-text-muted: #9ca3af;
  --color-text-dark: #4b5563;
  --color-border: var(--tint-8);
  --color-border-glow: rgba(99, 91, 255, 0.3);
  --color-accent-green: #10b981;
  --color-accent-red: #ef4444;

  /* Aliases used throughout inline styles (previously undefined fallbacks) */
  --color-surface: rgba(255, 255, 255, 0.04);
  --color-text: var(--color-text-main);
  --color-bg: var(--color-background);
  --bg-surface: rgba(16, 19, 32, 0.94);
  --library-bg: var(--color-background);
  --color-accent-blue: #3b82f6;
  --color-primary-light: rgba(var(--color-primary-rgb), 0.75);
  --color-text-dim: #6b7280;
  --transition-normal: 0.3s ease;

  /* Overlay tints: white-on-dark by default, flipped to ink-on-light by the
     light theme. Keep hover states / subtle panels visible in both themes. */
  --tint-1: rgba(255, 255, 255, 0.01);
  --tint-2: rgba(255, 255, 255, 0.02);
  --tint-3: rgba(255, 255, 255, 0.03);
  --tint-4: rgba(255, 255, 255, 0.04);
  --tint-5: rgba(255, 255, 255, 0.05);
  --tint-8: rgba(255, 255, 255, 0.08);
  --tint-10: rgba(255, 255, 255, 0.1);
  --tint-15: rgba(255, 255, 255, 0.15);
  --tint-20: rgba(255, 255, 255, 0.2);
  --tint-22: rgba(255, 255, 255, 0.22);
  --tint-25: rgba(255, 255, 255, 0.25);
  --tint-30: rgba(255, 255, 255, 0.3);
  --tint-35: rgba(255, 255, 255, 0.35);
  --tint-40: rgba(255, 255, 255, 0.4);
  --tint-50: rgba(255, 255, 255, 0.5);

  /* Font Families */
  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Shadow & Transitions */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.6);
  --transition-fast: 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-smooth: 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  
  /* Sidebar width state variables */
  --sidebar-width: 320px;
}

/* ==========================================================================
   Base Styles & Reset
   ========================================================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--color-background);
  color: var(--color-text-main);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  -webkit-font-smoothing: antialiased;
}

/* WebGL Background Container */
#webgl-bg-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
  pointer-events: none;
  opacity: 0.15;
  transition: opacity 0.5s ease;
}

/* ==========================================================================
   App Layout Shell
   ========================================================================== */
.app-container {
  display: flex;
  position: relative;
  width: 100vw;
  height: 100vh;
  z-index: 1;
  overflow: hidden;
  transition: padding-left var(--transition-smooth);
}

/* Sidebar Styling */
.sidebar {
  width: var(--sidebar-width);
  height: 100%;
  background: rgba(var(--bg-panel-rgb), 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  z-index: 10;
  transition: width var(--transition-smooth), transform var(--transition-smooth);
  flex-shrink: 0;
  overflow-x: hidden;
}

.sidebar.collapsed {
  width: 80px;
  transform: translateX(0);
  position: relative;
}

.sidebar.collapsed #sidebar-close-btn {
  display: none !important;
}

.sidebar.hidden-sidebar {
  width: 0 !important;
  transform: translateX(-100%) !important;
  opacity: 0 !important;
  border-right: none !important;
  overflow: hidden !important;
  padding: 0 !important;
}

.sidebar.collapsed .brand-name,
.sidebar.collapsed .course-meta h1,
.sidebar.collapsed .course-meta .badge,
.sidebar.collapsed .nav-stage-title,
.sidebar.collapsed #back-to-library-btn,
.sidebar.collapsed .delete-lesson-btn,
.sidebar.collapsed .profile-selector-container select {
  display: none;
}

.sidebar.collapsed .sidebar-header {
  padding: 1.5rem 0.5rem;
  align-items: center;
}

.sidebar.collapsed .logo-box {
  width: 48px;
  height: 48px;
}

.sidebar.collapsed .brand-logo {
  gap: 0;
  margin-bottom: 0.5rem;
}

.sidebar.collapsed .nav-item {
  padding: 1rem 0;
  justify-content: center;
}

.sidebar.collapsed .nav-stage-num {
  font-size: 0;
  margin: 0;
  width: 100%;
  text-align: center;
}

.sidebar.collapsed .nav-stage-num::before {
  content: attr(data-index);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-primary);
}

.sidebar.collapsed .sidebar-footer {
  padding: 1rem 0;
}

.sidebar.collapsed .profile-selector-container {
  padding: 0;
  background: transparent;
  justify-content: center;
}

.sidebar.collapsed .profile-selector-container::after {
  content: '';
  display: block;
  width: 24px;
  height: 24px;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"></path><circle cx="12" cy="7" r="4"></circle></svg>');
  background-size: cover;
  opacity: 0.7;
}

.sidebar-header {
  padding: 2rem 1.5rem;
  border-bottom: 1px solid var(--color-border);
}

.brand-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 1.25rem;
}

.logo-box {
  width: 64px;
  height: 64px;
  position: relative;
}

.brand-name {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: 2px;
  background: linear-gradient(to right, #ffffff, #9ca3af);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.course-meta h1 {
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 0.5rem;
  color: var(--color-text-main);
}

.badge {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 0.25rem 0.6rem;
  background: rgba(var(--color-primary-rgb), 0.15);
  border: 1px solid rgba(var(--color-primary-rgb), 0.3);
  color: var(--color-primary);
  border-radius: 50px;
  display: inline-block;
}

.sidebar-nav {
  flex: 1;
  padding: 1.5rem 1rem;
  overflow-y: auto;
}

.sidebar-nav::-webkit-scrollbar {
  width: 4px;
}
.sidebar-nav::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 2px;
}

.sidebar-nav ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--color-text-muted);
  transition: all var(--transition-fast);
  border: 1px solid transparent;
  position: relative;
  overflow: hidden;
}

.nav-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  width: 3px;
  height: 100%;
  background: var(--color-primary);
  transform: scaleY(0);
  transition: transform var(--transition-fast);
}

/* Sidebar Progress Header */
.course-progress-header {
  padding: 0 1.5rem 1.5rem 1.5rem;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid var(--tint-5);
}

.progress-stats {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.course-progress-bar-bg {
  width: 100%;
  height: 6px;
  background: var(--tint-10);
  border-radius: 3px;
  overflow: hidden;
}

.course-progress-bar-fill {
  height: 100%;
  background: var(--color-primary);
  border-radius: 3px;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.collapsed .course-progress-header {
  display: none;
}

/* Sidebar Nav Icons */
.nav-item-icon {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--tint-20);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-right: 0.75rem;
  transition: all 0.3s ease;
}

.nav-item-icon svg {
  width: 12px;
  height: 12px;
  color: transparent;
  transition: color 0.3s ease;
}

.nav-item:hover .nav-item-icon {
  background: var(--color-primary) !important;
  border-color: var(--color-primary) !important;
}

.nav-item:hover .nav-item-icon .progress-ring,
.nav-item:hover .nav-item-icon [data-lucide="check"] {
  display: none !important;
}

.nav-item:hover .nav-item-icon .hover-play-icon {
  display: block !important;
  width: 10px;
  height: 10px;
  color: #fff !important;
  fill: #fff !important;
}

.nav-item.completed .nav-item-icon {
  background: var(--color-primary);
  border-color: var(--color-primary);
}

.nav-item.completed .nav-item-icon svg {
  color: #fff;
}

.nav-item.active .nav-item-icon {
  border-color: var(--color-primary);
}

.sidebar.collapsed .nav-item-icon {
  display: none;
}

.nav-item:hover {
  background: var(--tint-3);
  color: var(--color-text-main);
}

.nav-item.active {
  background: rgba(var(--color-primary-rgb), 0.08);
  border-color: rgba(var(--color-primary-rgb), 0.15);
  color: var(--color-primary);
}

.nav-item.active::before {
  transform: scaleY(1);
}

.nav-stage-num {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  opacity: 0.6;
}

.nav-stage-title {
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.sidebar-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--color-border);
}

.user-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.status-dot {
  width: 6px;
  height: 6px;
  background-color: var(--color-accent-green);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--color-accent-green);
}

.status-text {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  font-family: var(--font-mono);
}

/* Main Workspace */
.main-workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  position: relative;
  z-index: 2;
}

/* ==========================================================================
   Top Header Bar & Audio Player
   ========================================================================== */
.top-bar {
  height: 52px;
  border-bottom: 1px solid var(--color-border);
  background: rgba(var(--bg-panel-rgb), 0.45);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  gap: 1.5rem;
  z-index: 9;
}

.top-bar-stage-title {
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-text-muted);
  letter-spacing: 0.5px;
  margin-left: 0.5rem;
}

.icon-btn {
  background: none;
  border: 1px solid var(--color-border);
  color: var(--color-text-main);
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.icon-btn:hover {
  background: var(--tint-5);
  border-color: var(--color-primary);
  transform: translateY(-1px);
}

/* Audio Player */
/* Audio Player */
.audio-player {
  flex: 1;
  max-width: 600px;
  background: rgba(26, 30, 43, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--tint-8);
  border-radius: 9999px; /* Pill layout */
  padding: 0.5rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4), inset 0 1px 0 var(--tint-5);
  transition: transform var(--transition-smooth), box-shadow var(--transition-smooth);
}

.audio-player:hover {
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.5), inset 0 1px 0 var(--tint-10);
  transform: translateY(-2px);
}

.player-btn {
  background: var(--color-primary);
  color: #ffffff;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(var(--color-primary-rgb), 0.4);
  transition: all var(--transition-fast);
}

.player-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 16px rgba(var(--color-primary-rgb), 0.6);
}

.player-btn:active {
  transform: scale(0.95);
}

.player-btn .hidden {
  display: none;
}

.player-btn svg {
  width: 14px;
  height: 14px;
  stroke-width: 2px;
}

/* Audio Metadata text */
.audio-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.72rem;
  white-space: nowrap;
}

.track-title {
  font-weight: 500;
  color: var(--color-text-main);
  max-width: 150px;
  text-overflow: ellipsis;
  overflow: hidden;
}

.track-time {
  font-family: var(--font-mono);
  color: var(--color-text-muted);
  opacity: 0.85;
}

/* Seekable Progress Timeline container */
.progress-timeline-container {
  flex: 1;
  min-width: 100px;
  height: 20px;
  display: flex;
  align-items: center;
  cursor: pointer;
  position: relative;
}

.progress-bar-bg {
  width: 100%;
  height: 4px;
  background: var(--tint-10);
  border-radius: 9999px;
  position: relative;
  transition: height var(--transition-fast);
  overflow: hidden;
}

.progress-timeline-container:hover .progress-bar-bg {
  height: 6px;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--color-primary), #a8a5ff);
  border-radius: 9999px;
  position: absolute;
  top: 0;
  left: 0;
  transition: width 0.1s linear;
}

/* Audio speed selector buttons */
.audio-speed-selector {
  display: flex;
  gap: 4px;
  padding-left: 1rem;
  border-left: 1px solid var(--tint-10);
}

.speed-btn {
  background: transparent;
  border: none;
  color: var(--color-text-muted);
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.3rem 0.5rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.speed-btn:hover {
  color: var(--color-text-main);
  background: var(--tint-5);
}

.speed-btn.active {
  color: var(--color-text-main);
  background: var(--tint-10);
}

/* ==========================================================================
   Content Portal (Stage Renderer)
   ========================================================================== */
.content-portal {
  flex: 1;
  overflow-y: auto;
  position: relative;
  padding: 1.5rem 2rem;
  display: flex;
  justify-content: center;
}

.content-portal::-webkit-scrollbar {
  width: 6px;
}
.content-portal::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 3px;
}

.stage-visual-container {
  width: 100%;
  position: relative;
  z-index: 1;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Full HTML pages composited into the stage: keep any overflow scroll
   unobtrusive — thin, dark, theme-matched instead of the default white bar */
.stage-html-page {
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
}
.stage-html-page::-webkit-scrollbar {
  width: 4px;
}
.stage-html-page::-webkit-scrollbar-track {
  background: transparent;
}
.stage-html-page::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 2px;
}

.stage-visual-container.layout-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  align-items: stretch;
}

.stage-visual-container.layout-quad-3 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto auto;
  gap: 2rem;
  align-items: stretch;
}
.stage-visual-container.layout-quad-3 > :first-child {
  grid-column: 1 / -1; /* First component spans full width */
}

.stage-visual-container.layout-quad-4 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto auto;
  gap: 2rem;
  align-items: stretch;
}

.narrative-caption-box {
  position: absolute;
  bottom: 100%; /* Right above the player bar */
  left: 0;
  width: 100%;
  height: 80px; /* Fixed height so it doesn't grow */
  padding: 0 2rem 1rem 2rem;
  color: rgba(255, 255, 255, 0.95);
  font-size: 1.15rem;
  line-height: 1.5;
  text-align: center;
  font-family: var(--font-sans);
  font-weight: 500;
  z-index: 100;
  pointer-events: none;
  display: flex;
  align-items: flex-end; /* Text types along the bottom line */
  justify-content: center;
  text-shadow: 0 2px 8px rgba(0,0,0,0.9); /* Ensures legibility without a box */
}

.parsed-content {
  opacity: 1;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

/* State changes for Routing Animation */
.stage-exit-forward {
  opacity: 0;
  transform: translateY(-80px);
}

.stage-exit-backward {
  opacity: 0;
  transform: translateY(80px);
}

.stage-enter-forward {
  opacity: 0;
  transform: translateY(80px);
}

.stage-enter-backward {
  opacity: 0;
  transform: translateY(-80px);
}

/* Markdown typography and layouts */
.parsed-content h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 0.25rem;
  color: #ffffff;
}

.parsed-content h2 {
  font-size: 1.15rem;
  font-weight: 400;
  color: var(--color-text-muted);
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 0.5rem;
}

.parsed-content p {
  font-size: 1.02rem;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.85);
  margin-bottom: 1rem;
}

.parsed-content blockquote {
  border-left: 4px solid var(--color-primary);
  background: var(--tint-2);
  padding: 1rem 1.25rem;
  border-radius: 0 8px 8px 0;
  margin: 1rem 0;
}

.parsed-content blockquote p {
  margin-bottom: 0;
  font-style: italic;
  color: #ffffff;
}

/* Staggered load support classes */
.fade-in-up {
  animation: fadeInUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  opacity: 0;
}

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

/* ==========================================================================
   WIDGETS LIBRARY
   ========================================================================== */

/* 1. WebGL Hero Canvas Container */
.webgl-hero-container {
  width: 100%;
  height: 150px;
  border-radius: 12px;
  overflow: hidden;
  margin: 1rem 0;
  border: 1px solid var(--color-border);
  position: relative;
  background: radial-gradient(circle at center, rgba(26, 30, 43, 0.6) 0%, rgba(13, 18, 28, 0.8) 100%);
}

.webgl-hero-container canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.webgl-hero-caption {
  position: absolute;
  bottom: 1rem;
  left: 1rem;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--color-primary);
  background: rgba(13, 18, 28, 0.8);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  border: 1px solid rgba(var(--color-primary-rgb), 0.3);
  letter-spacing: 1px;
  pointer-events: none;
}

/* 2. Methodology Tracker */
.methodology-tracker {
  background: rgba(var(--bg-panel-rgb), 0.4);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 1.25rem;
  margin: 1rem 0;
}

.tracker-title {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--color-primary);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 1.5rem;
}

.timeline {
  display: flex;
  justify-content: space-between;
  position: relative;
  margin-bottom: 2rem;
  padding: 0 1rem;
}

.timeline-line {
  position: absolute;
  top: 19px;
  left: 2rem;
  right: 2rem;
  height: 2px;
  background-color: var(--color-border);
  z-index: 1;
}

.timeline-node {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  width: 40px;
}

.node-dot {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: var(--color-background);
  border: 2px solid var(--color-text-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--color-text-muted);
  transition: all var(--transition-smooth);
}

.timeline-node:hover .node-dot {
  border-color: var(--color-primary);
  box-shadow: 0 0 15px var(--color-border-glow);
  color: var(--color-text-main);
  transform: scale(1.1);
}

.timeline-node.active .node-dot {
  border-color: var(--color-primary);
  background-color: var(--color-primary);
  color: white;
  box-shadow: 0 0 20px rgba(var(--color-primary-rgb), 0.4);
}

.timeline-node.completed .node-dot {
  border-color: var(--color-accent-green);
  color: var(--color-accent-green);
  background: rgba(16, 185, 129, 0.05);
}

.node-label {
  font-size: 0.75rem;
  font-weight: 500;
  margin-top: 0.75rem;
  color: var(--color-text-muted);
  transition: color var(--transition-fast);
}

.timeline-node.active .node-label {
  color: var(--color-text-main);
  font-weight: 600;
}

/* Glassmorphic expanded Details panel */
.details-panel {
  background: var(--tint-2);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 1.5rem;
  transition: all var(--transition-smooth);
  opacity: 0;
  transform: translateY(10px);
  display: none;
}

.details-panel.visible {
  opacity: 1;
  transform: translateY(0);
  display: block;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 0.75rem;
  margin-bottom: 1rem;
}

.panel-title {
  font-size: 1.15rem;
  font-weight: 600;
  color: #ffffff;
}

.panel-badge {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  background: var(--tint-5);
  border: 1px solid var(--color-border);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
}

.panel-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.panel-col h4 {
  font-size: 0.85rem;
  color: var(--color-primary);
  text-transform: uppercase;
  margin-bottom: 0.5rem;
  letter-spacing: 1px;
}

.panel-col p, .panel-col ul {
  font-size: 0.95rem;
  color: rgba(255,255,255,0.75);
}

.panel-col ul {
  list-style-position: inside;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

/* 3. Objection Simulator */
.objection-simulator {
  background: rgba(var(--bg-panel-rgb), 0.4);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 1.25rem;
  margin: 1rem 0;
}

.sim-grid {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 2rem;
  align-items: start;
}

.avatar-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  text-align: center;
}

.avatar-circle {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-primary), #ffd43f);
  border: 3px solid var(--color-border);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  position: relative;
}

.avatar-glow {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  box-shadow: 0 0 20px rgba(var(--color-primary-rgb), 0.4);
  animation: pulse-avatar 2s infinite alternate;
  pointer-events: none;
}

@keyframes pulse-avatar {
  0% { transform: scale(1); opacity: 0.3; }
  100% { transform: scale(1.08); opacity: 0.7; }
}

.prospect-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: white;
}

.prospect-role {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.bubble-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.speech-bubble {
  position: relative;
  background: var(--tint-3);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow-md);
}

.speech-bubble::before {
  content: '';
  position: absolute;
  left: -8px;
  top: 35px;
  border-width: 8px 8px 8px 0;
  border-style: solid;
  border-color: transparent var(--color-border) transparent transparent;
}

.speech-bubble::after {
  content: '';
  position: absolute;
  left: -7px;
  top: 35px;
  border-width: 8px 8px 8px 0;
  border-style: solid;
  border-color: transparent rgba(var(--bg-panel-rgb), 0.95) transparent transparent;
}

.speech-text {
  font-size: 1.05rem;
  line-height: 1.5;
  color: white;
  font-style: italic;
}

.choices-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.choice-btn {
  background: var(--tint-2);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  color: var(--color-text-main);
  text-align: left;
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  line-height: 1.4;
  transition: all var(--transition-fast);
  display: flex;
  gap: 1rem;
  align-items: center;
}

.choice-bullet {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: var(--tint-5);
  border: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.choice-btn:hover {
  background: rgba(var(--color-primary-rgb), 0.03);
  border-color: var(--color-primary);
  box-shadow: 0 0 15px rgba(var(--color-primary-rgb), 0.15);
  transform: translateY(-2px);
}

.choice-btn:hover .choice-bullet {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: white;
}

.choice-btn.selected {
  border-color: var(--color-primary);
  background: rgba(var(--color-primary-rgb), 0.08);
}

.choice-btn.selected .choice-bullet {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: white;
}

/* Branching Flowchart Panel */
.flowchart-panel {
  margin-top: 2rem;
  border-top: 1px solid var(--color-border);
  padding-top: 1.5rem;
  display: none;
  opacity: 0;
  transform: translateY(15px);
  transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.flowchart-panel.visible {
  display: block;
  opacity: 1;
  transform: translateY(0);
}

.flowchart-header {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-bottom: 1.25rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Flowchart Nodes Grid with delay transitions */
.flowchart-tree {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  position: relative;
}

.flow-node {
  background: var(--tint-2);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 0.85rem 1.25rem;
  max-width: 450px;
  text-align: center;
  position: relative;
  font-size: 0.9rem;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.3s ease;
}

.flow-node.highlighted {
  border-color: var(--color-primary);
  box-shadow: 0 0 15px rgba(var(--color-primary-rgb), 0.15);
  background: rgba(var(--color-primary-rgb), 0.03);
}

.flow-node.feedback {
  background: rgba(16, 185, 129, 0.03);
  border-color: var(--color-accent-green);
  color: var(--color-text-main);
}

.flow-node.warning {
  background: rgba(239, 68, 68, 0.03);
  border-color: var(--color-accent-red);
}

.flow-arrow {
  width: 2px;
  height: 24px;
  background-color: var(--color-border);
  position: relative;
}

.flow-arrow::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: -3px;
  border-width: 5px 4px 0 4px;
  border-style: solid;
  border-color: var(--color-border) transparent transparent transparent;
}

.flow-arrow.highlighted {
  background-color: var(--color-primary);
}
.flow-arrow.highlighted::after {
  border-color: var(--color-primary) transparent transparent transparent;
}

/* 4. Playbook Battlecard */
.playbook-battlecard {
  background: rgba(var(--bg-panel-rgb), 0.4);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 1.25rem;
  margin: 1rem 0;
  transition: all var(--transition-smooth);
  position: relative;
}

.battlecard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.battlecard-title {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--color-primary);
  text-transform: uppercase;
  letter-spacing: 2px;
}

.fullscreen-toggle-btn {
  background: var(--tint-3);
  border: 1px solid var(--color-border);
  color: var(--color-text-main);
  padding: 0.5rem 0.85rem;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all var(--transition-fast);
}

.fullscreen-toggle-btn:hover {
  background: var(--tint-8);
  border-color: var(--color-primary);
}

.battlecard-table-container {
  overflow-x: auto;
  border-radius: 10px;
  border: 1px solid var(--color-border);
}

.battlecard-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.95rem;
}

.battlecard-table th, .battlecard-table td {
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--color-border);
}

.battlecard-table th {
  background-color: var(--tint-2);
  font-weight: 600;
  color: white;
}

.battlecard-table th:first-child {
  width: 180px;
}

.battlecard-table tr:last-child td {
  border-bottom: none;
}

.battlecard-table td:first-child {
  font-weight: 600;
  color: white;
  background-color: var(--tint-1);
}

.text-highlight-primary {
  color: var(--color-primary);
  font-weight: 500;
}

.text-muted-dark {
  color: var(--color-text-muted);
}

/* Fullscreen Mode styling for Battlecard */
body.fullscreen-battlecard {
  overflow: hidden;
}

body.fullscreen-battlecard .sidebar {
  transform: translateX(-100%);
  opacity: 0;
  pointer-events: none;
}

body.fullscreen-battlecard .app-container {
  padding-left: 0;
}

body.fullscreen-battlecard .playbook-battlecard {
  position: fixed;
  top: 20px;
  left: 20px;
  right: 20px;
  bottom: 20px;
  z-index: 999;
  margin: 0;
  background: rgba(var(--bg-panel-rgb), 0.95);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
}

body.fullscreen-battlecard .battlecard-table-container {
  flex: 1;
  overflow-y: auto;
}

/* Responsive adjustments */
@media (max-width: 1024px) {
  .app-container {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    height: auto;
    max-height: 300px;
    border-right: none;
    border-bottom: 1px solid var(--color-border);
  }
  .sidebar.collapsed {
    transform: translateY(-100%);
  }
}

@media (max-width: 768px) {
  .sim-grid {
    grid-template-columns: 1fr;
  }
  .avatar-container {
    flex-direction: row;
    text-align: left;
  }
  .panel-body {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   SOURCE SELECTOR & PLAYBOOK FORMATTING
   ========================================================================== */
.source-selector {
  margin-top: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.source-selector label {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  text-transform: uppercase;
  color: var(--color-text-muted);
  letter-spacing: 1px;
}

.source-dropdown {
  background: var(--tint-4);
  border: 1px solid var(--color-border);
  color: var(--color-text-main);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  outline: none;
  cursor: pointer;
  width: 100%;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.source-dropdown:hover, .source-dropdown:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 10px rgba(var(--color-primary-rgb), 0.15);
}

/* Vertical Positioning Table Widget */
.widget-verticalpositioningtable {
  background: rgba(var(--bg-panel-rgb), 0.4);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 1.25rem;
  margin: 1rem 0;
}

.positioning-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  margin-top: 1rem;
}

.positioning-card {
  background: var(--tint-2);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  position: relative;
  overflow: hidden;
  transition: transform var(--transition-fast), border-color var(--transition-fast);
}

.positioning-card:hover {
  transform: translateY(-2px);
  border-color: var(--tint-15);
}

.positioning-card.highlight {
  border-color: var(--color-primary);
  background: rgba(var(--color-primary-rgb), 0.04);
  box-shadow: 0 4px 25px rgba(var(--color-primary-rgb), 0.08);
}

.positioning-card.highlight:hover {
  border-color: var(--color-primary);
  box-shadow: 0 4px 30px rgba(var(--color-primary-rgb), 0.15);
}

.positioning-card h4 {
  font-size: 0.75rem;
  font-family: var(--font-mono);
  text-transform: uppercase;
  color: var(--color-text-muted);
  letter-spacing: 1px;
}

.positioning-card.highlight h4 {
  color: var(--color-primary);
}

.positioning-card p {
  font-size: 0.9rem;
  line-height: 1.35;
  color: rgba(255, 255, 255, 0.8);
  margin-bottom: 0 !important;
}

.positioning-card.highlight p {
  color: #ffffff;
}

.positioning-icon {
  font-size: 1.5rem;
  margin-bottom: 0.25rem;
}

/* Badges and special Scenario/Reviewer blocks */
.scenario-badge {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 0.25rem 0.6rem;
  background: rgba(var(--color-primary-rgb), 0.15);
  border: 1px solid rgba(var(--color-primary-rgb), 0.3);
  color: var(--color-primary);
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  vertical-align: middle;
}

.scenario-heading {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
}

.reviewer-quote {
  border-left: 4px solid #8b5cf6 !important;
  background: rgba(139, 92, 246, 0.04) !important;
  padding: 1rem 1.25rem;
  border-radius: 0 8px 8px 0;
  margin: 1rem 0;
}

.reviewer-badge {
  background: rgba(139, 92, 246, 0.15) !important;
  border: 1px solid rgba(139, 92, 246, 0.3) !important;
  color: #a78bfa !important;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 4px;
  padding: 0.2rem 0.5rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
  text-transform: none !important;
}

.scenario-quote {
  border-left: 4px solid var(--color-primary) !important;
  background: rgba(var(--color-primary-rgb), 0.04) !important;
  padding: 1rem 1.25rem;
  border-radius: 0 8px 8px 0;
  margin: 1rem 0;
}

.scenario-quote-badge {
  background: rgba(var(--color-primary-rgb), 0.15) !important;
  border: 1px solid rgba(var(--color-primary-rgb), 0.3) !important;
  color: var(--color-primary) !important;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 4px;
  padding: 0.2rem 0.5rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}

@media (max-width: 768px) {
  .positioning-grid {
    grid-template-columns: 1fr;
  }
}

.bottom-player-bar {
  padding: 1rem 0 2rem 0;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10;
  flex-shrink: 0;
  margin-top: 2rem;
  border-top: 1px solid var(--tint-5);
}

/* MEDDIC 3D Container */
.meddic-3d-container {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  margin: 0.75rem auto 1.25rem auto;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  overflow: hidden;
  background: radial-gradient(circle, rgba(var(--bg-panel-rgb), 0.25) 0%, rgba(var(--bg-panel-rgb), 0.65) 100%);
  border: 1px solid var(--color-border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25), inset 0 0 12px rgba(var(--color-primary-rgb), 0.1);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.meddic-3d-container:hover {
  border-color: rgba(var(--color-primary-rgb), 0.35);
  box-shadow: 0 8px 32px rgba(var(--color-primary-rgb), 0.1), inset 0 0 16px rgba(var(--color-primary-rgb), 0.15);
}

.meddic-3d-container canvas {
  width: 100% !important;
  height: 100% !important;
}

/* Lesson Navigation Footer */
.lesson-nav-container {
  position: absolute;
  bottom: 2rem;
  left: 2rem;
  right: 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 50;
  pointer-events: none; /* Allows clicks to pass through empty space */
}

.lesson-nav-container .nav-btn {
  pointer-events: auto; /* Reactivate clicks on buttons */
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  background: rgba(var(--bg-panel-rgb), 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(var(--color-primary-rgb), 0.1);
  color: var(--color-text-main);
  border: 1px solid rgba(var(--color-primary-rgb), 0.2);
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.nav-btn:hover:not(.disabled-nav) {
  background: rgba(var(--color-primary-rgb), 0.2);
  border-color: rgba(var(--color-primary-rgb), 0.4);
  transform: translateY(-2px);
}

.nav-btn.disabled-nav {
  opacity: 0.3;
  cursor: not-allowed;
  filter: grayscale(1);
}

/* Library View Styles */
.library-view {
  width: 100%;
  height: 100%;
  padding: 4rem;
  overflow-y: auto;
  animation: fadeIn var(--transition-normal);
  background: var(--library-bg, #050505);
}

.library-header {
  margin-bottom: 3rem;
  text-align: center;
}

.library-header h2 {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  background: linear-gradient(135deg, #fff, rgba(255,255,255,0.7));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.library-header p {
  color: var(--color-text-muted);
  font-size: 1.1rem;
}

.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 2rem;
  max-width: 1200px;
  margin: 0 auto;
}

.library-card {
  background: rgba(var(--bg-panel-rgb), 0.4);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 2rem;
  transition: all var(--transition-normal);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.library-card:hover {
  transform: translateY(-5px);
  border-color: rgba(var(--color-primary-rgb), 0.5);
  box-shadow: 0 10px 30px rgba(0,0,0,0.2), 0 0 15px rgba(var(--color-primary-rgb), 0.15);
  background: rgba(var(--bg-panel-rgb), 0.6);
}

.library-card.selected {
  border-color: var(--color-primary);
  box-shadow: 0 0 20px rgba(var(--color-primary-rgb), 0.3);
}

.library-card-type {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--color-primary);
  margin-bottom: 1rem;
  font-weight: 700;
}

.library-card h3 {
  font-size: 1.4rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--color-text-main);
  line-height: 1.3;
}

.library-card p {
  color: var(--color-text-muted);
  font-size: 0.95rem;
  margin-bottom: 2rem;
  flex-grow: 1;
}

.library-card-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--tint-5);
  padding-top: 1rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9rem;
  color: var(--color-text-main);
}

.library-card-action i {
  width: 18px;
  height: 18px;
  color: var(--color-primary);
  transition: transform var(--transition-fast);
}

.library-card:hover .library-card-action i {
  transform: translateX(4px);
}

/* Profile Selector */
.profile-dropdown {
  background: transparent;
  color: var(--color-text-main);
  border: 1px solid var(--tint-10);
  padding: 0.5rem;
  border-radius: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  width: 100%;
  cursor: pointer;
}
.profile-dropdown option {
  background: var(--bg-surface);
}

/* Review Toggle Button */
.review-toggle-btn {
  position: relative;
}
.comment-count-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--color-primary);
  color: #fff;
  font-size: 0.7rem;
  font-weight: bold;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Review Panel (Right Flex Column) */
.review-panel {
  width: 0;
  height: 100%;
  background: var(--bg-surface);
  border-left: 0px solid var(--color-border);
  display: flex;
  flex-direction: column;
  transition: width var(--transition-normal), border-left-width var(--transition-normal);
  overflow: hidden;
}
.review-panel.open {
  width: 350px;
  flex-shrink: 0;
  border-left-width: 1px;
}

.review-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem;
  border-bottom: 1px solid var(--color-border);
}
.review-panel-header h3 {
  margin: 0;
  font-size: 1.1rem;
}

.review-tabs {
  display: flex;
  border-bottom: 1px solid var(--color-border);
  background: var(--bg-panel);
}

.review-tab-btn {
  flex: 1;
  padding: 0.75rem;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  font-weight: 500;
  font-size: 0.9rem;
  transition: all var(--transition-fast);
}

.review-tab-btn:hover {
  color: var(--color-text);
  background: var(--tint-5);
}

.review-tab-btn.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

.review-list {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.review-item {
  background: rgba(var(--bg-panel-rgb), 0.3);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.review-item.resolved {
  opacity: 0.6;
  border-color: var(--tint-5);
  background: transparent;
}
.review-item.resolved .review-text {
  text-decoration: line-through;
}

.review-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
}

.review-role-badge {
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-weight: 600;
  font-size: 0.7rem;
  text-transform: uppercase;
}
.role-id { background: rgba(99, 91, 255, 0.2); color: #8c85ff; }
.role-sme { background: rgba(34, 197, 94, 0.2); color: #4ade80; }
.role-peer { background: rgba(234, 179, 8, 0.2); color: #facc15; }

.review-text {
  font-size: 0.95rem;
  color: var(--color-text-main);
  line-height: 1.4;
}

.review-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.5rem;
}

.resolve-btn {
  background: none;
  border: 1px solid var(--tint-10);
  color: var(--color-text-muted);
  font-size: 0.8rem;
  padding: 0.3rem 0.7rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.resolve-btn:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.request-approval-btn {
  background: none;
  border: 1px solid rgba(234, 179, 8, 0.4);
  color: #facc15;
  font-size: 0.8rem;
  padding: 0.3rem 0.7rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.request-approval-btn:hover {
  background: rgba(234, 179, 8, 0.1);
}

.reopen-btn {
  background: none;
  border: 1px solid rgba(248, 113, 113, 0.4);
  color: #f87171;
  font-size: 0.75rem;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.reopen-btn:hover {
  background: rgba(248, 113, 113, 0.1);
}

.status-badge {
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-weight: 600;
  font-size: 0.7rem;
  text-transform: uppercase;
  margin-left: 0.5rem;
}
.status-badge.pending {
  background: rgba(234, 179, 8, 0.2);
  color: #facc15;
}

.review-input-container {
  padding: 1.5rem;
  border-top: 1px solid var(--color-border);
  background: rgba(var(--bg-panel-rgb), 0.5);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.review-input-container textarea {
  width: 100%;
  background: rgba(0,0,0,0.2);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 0.75rem;
  color: var(--color-text-main);
  font-family: inherit;
  resize: none;
}
.review-input-container textarea:focus {
  outline: none;
  border-color: var(--color-primary);
}
.primary-btn {
  background: var(--color-primary);
  color: #fff;
  border: none;
  padding: 0.6rem;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  transition: opacity var(--transition-fast);
}
.primary-btn:hover {
  opacity: 0.9;
}

/* Transparent outline button (used across editors, e.g. stage editor footer) */
.secondary-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--tint-4);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  padding: 0.5rem 0.9rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}
.secondary-btn:hover {
  background: var(--tint-8);
  border-color: var(--tint-22);
}
.secondary-btn svg {
  width: 15px;
  height: 15px;
}

/* ==========================================================================
   Widget: Interactive Timeline
   ========================================================================== */
.widget-interactivetimeline {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.timeline-wrapper {
  position: relative;
  width: 100%;
  display: flex;
  flex-direction: column;
}

.timeline-track {
  position: absolute;
  top: 70px;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--tint-10);
  border-radius: 2px;
  z-index: 1;
}

.timeline-nodes {
  display: flex;
  justify-content: space-between;
  width: 100%;
  position: relative;
  z-index: 2;
  gap: 2rem;
}

.timeline-node-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 30%;
  opacity: 0;
  animation: fadeInUp 0.6s forwards cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}

.timeline-date {
  font-family: 'JetBrains Mono', monospace;
  color: var(--color-text-muted);
  margin-bottom: 2rem;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(0,0,0,0.5);
  padding: 0.4rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--tint-10);
}

.widget-interactivetimeline .timeline-node {
  width: 12px;
  height: 12px;
  min-width: 12px;
  min-height: 12px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 2px solid var(--color-border);
  position: relative;
  margin-bottom: 2.5rem;
  transition: all 0.3s ease;
  cursor: pointer;
  z-index: 5;
}

.widget-interactivetimeline .timeline-node:hover {
  transform: scale(1.4);
}

.node-pulse {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
  height: 100%;
  border-radius: 50%;
  animation: pulseNode 2s infinite cubic-bezier(0.4, 0, 0.6, 1);
  opacity: 0;
  pointer-events: none;
}

@keyframes pulseNode {
  0% { transform: translate(-50%, -50%) scale(1); opacity: 0.8; }
  100% { transform: translate(-50%, -50%) scale(3); opacity: 0; }
}

.node-past {
  border-color: var(--tint-20);
  background: var(--tint-5);
}
.node-past .node-pulse { display: none; }
.node-past.audio-playing .node-pulse {
  display: block;
  animation: pulseNode 1s infinite cubic-bezier(0.4, 0, 0.6, 1);
  border: 2px solid var(--color-accent-blue);
}

.node-urgent {
  border-color: #f59e0b; /* Amber */
  background: rgba(245, 158, 11, 0.1);
}
.node-urgent .node-pulse {
  background: rgba(245, 158, 11, 0.4);
}
.node-urgent.audio-playing .node-pulse {
  animation: pulseNode 1s infinite cubic-bezier(0.4, 0, 0.6, 1);
  border: 2px solid var(--color-accent-blue);
}

.node-critical {
  border-color: var(--color-accent-red);
  background: rgba(234, 44, 99, 0.1);
}
.node-critical .node-pulse {
  background: rgba(234, 44, 99, 0.4);
  animation-duration: 1s; /* Faster pulse */
}
.node-critical.audio-playing .node-pulse {
  animation: pulseNode 0.5s infinite cubic-bezier(0.4, 0, 0.6, 1);
  border: 2px solid var(--color-accent-blue);
}

.timeline-content {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  flex-grow: 1;
  width: 100%;
}

.timeline-title {
  font-size: 1.3rem;
  color: var(--color-text-main);
  margin-bottom: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.timeline-implication {
  font-size: 1rem;
  color: rgba(255,255,255,0.85);
  padding: 1.5rem;
  border-radius: 12px;
  background: rgba(13, 18, 28, 0.7);
  flex-grow: 1;
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--tint-8);
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  line-height: 1.6;
  opacity: 0.7;
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  transform: translateY(10px);
}

.timeline-node-container:hover .timeline-implication {
  opacity: 1;
  transform: translateY(0);
  border-color: var(--tint-25);
  background: var(--tint-5);
}

.timeline-node-container:hover .node-urgent ~ .timeline-content .timeline-implication {
  border-color: rgba(245, 158, 11, 0.5);
  box-shadow: 0 8px 32px rgba(245, 158, 11, 0.2);
}

.timeline-node-container:hover .node-critical ~ .timeline-content .timeline-implication {
  border-color: rgba(239, 68, 68, 0.5);
  box-shadow: 0 8px 32px rgba(239, 68, 68, 0.25);
}

.fade-in-forward {
  animation: fadeInForward 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  opacity: 0;
}
@keyframes fadeInForward {
  from { opacity: 0; transform: translateY(60px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in-backward {
  animation: fadeInBackward 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  opacity: 0;
}
@keyframes fadeInBackward {
  from { opacity: 0; transform: translateY(-60px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   INTERACTIVE RISK MATRIX
   ========================================================================== */

.widget-interactiveriskmatrix {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
}

.risk-header {
  text-align: center;
}

.risk-header h3 {
  font-size: 2rem;
  margin-bottom: 0.5rem;
  color: var(--color-primary);
}

.risk-header p {
  color: var(--color-text-dim);
}

.risk-matrix-area {
  position: relative;
  width: 100%;
  height: 400px;
  background: var(--tint-2);
  border-radius: 20px;
  border: 1px solid var(--tint-5);
  overflow: hidden;
}

.risk-svg-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

.risk-line {
  stroke: var(--tint-15);
  stroke-width: 2;
  transition: stroke 0.5s ease, stroke-width 0.5s ease;
  stroke-dasharray: 5 5;
  animation: dash 10s linear infinite;
}

@keyframes dash {
  to { stroke-dashoffset: -100; }
}

.risk-node {
  position: absolute;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border-radius: 50%;
  background: rgba(20, 20, 20, 0.8);
  border: 1px solid var(--tint-20);
  backdrop-filter: blur(10px);
  color: white;
  transition: all 0.5s ease;
}

.risk-node svg {
  width: 24px;
  height: 24px;
  color: var(--color-text);
  transition: color 0.5s ease;
}

.risk-node span {
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.org-node {
  width: 100px;
  height: 100px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border-color: var(--color-primary);
  box-shadow: 0 0 20px rgba(234, 44, 99, 0.2);
}

.org-node svg {
  width: 32px;
  height: 32px;
  color: var(--color-primary);
}

.vendor-node {
  width: 80px;
  height: 80px;
}

.vendor-node.pos-1 { top: 15%; left: 20%; transform: translate(-50%, -50%); }
.vendor-node.pos-2 { top: 80%; left: 30%; transform: translate(-50%, -50%); }
.vendor-node.pos-3 { top: 40%; left: 80%; transform: translate(-50%, -50%); }

.lockdown-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  width: 300px;
  height: 300px;
  border-radius: 50%;
  border: 4px solid var(--color-primary);
  opacity: 0;
  transition: all 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 0;
  box-shadow: inset 0 0 50px rgba(234, 44, 99, 0.2), 0 0 50px rgba(234, 44, 99, 0.2);
}

.penalty-counter {
  position: absolute;
  top: 2rem;
  right: 2rem;
  font-size: 2rem;
  font-weight: 800;
  color: var(--color-primary);
  font-variant-numeric: tabular-nums;
  opacity: 0;
  transition: opacity 0.5s ease;
  z-index: 10;
}

/* States */
.state-manual .risk-line {
  stroke: var(--tint-5);
  animation: none;
}
.state-manual .vendor-node {
  opacity: 0.5;
  border-style: dashed;
}

.state-cascade .vendor-node.pos-1 {
  background: rgba(234, 44, 99, 0.2);
  border-color: var(--color-primary);
  box-shadow: 0 0 30px rgba(234, 44, 99, 0.4);
}
.state-cascade .vendor-node.pos-1 svg {
  color: var(--color-primary);
}
.state-cascade .line-1 {
  stroke: var(--color-primary);
  stroke-width: 4;
  filter: drop-shadow(0 0 8px var(--color-primary));
  stroke-dasharray: 1000;
  stroke-dashoffset: 1000;
  animation: drawLine 1s forwards cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes drawLine {
  to { stroke-dashoffset: 0; }
}

.state-weight .lockdown-ring {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
  animation: pulseRing 2s infinite;
}
.state-weight .penalty-counter {
  opacity: 1;
}

@keyframes pulseRing {
  0% { box-shadow: inset 0 0 50px rgba(234, 44, 99, 0.2), 0 0 50px rgba(234, 44, 99, 0.2); }
  50% { box-shadow: inset 0 0 80px rgba(234, 44, 99, 0.5), 0 0 80px rgba(234, 44, 99, 0.5); }
  100% { box-shadow: inset 0 0 50px rgba(234, 44, 99, 0.2), 0 0 50px rgba(234, 44, 99, 0.2); }
}

.risk-controls {
  display: flex;
  justify-content: center;
  gap: 1rem;
}

.risk-state-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  background: var(--tint-5);
  border: 1px solid var(--tint-10);
  border-radius: 8px;
  color: var(--color-text);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.risk-state-btn svg {
  width: 16px;
  height: 16px;
}

.risk-state-btn:hover {
  background: var(--tint-10);
  transform: translateY(-2px);
}

.risk-state-btn.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: white;
}

.timeline-node.next-highlight .node-dot {
  animation: breathingHighlight 2s infinite ease-in-out;
  border-color: var(--color-primary);
  box-shadow: 0 0 10px rgba(var(--color-primary-rgb), 0.5);
}

@keyframes breathingHighlight {
  0% { box-shadow: 0 0 0 0 rgba(var(--color-primary-rgb), 0.7); }
  70% { box-shadow: 0 0 0 15px rgba(var(--color-primary-rgb), 0); }
  100% { box-shadow: 0 0 0 0 rgba(var(--color-primary-rgb), 0); }
}

/* Modal Styles */
.editor-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(5px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.editor-modal {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.editor-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.editor-header h3 {
  margin: 0;
}

.editor-body {
  padding: 1.5rem;
  overflow-y: auto;
  max-height: 70vh;
}

.editor-footer {
  padding: 1.5rem;
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
}

/* ADDIE Timeline */
.addie-timeline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin: 1.5rem 0;
}

.addie-node {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: bold;
  color: var(--color-text-muted);
  position: relative;
  z-index: 2;
  transition: all var(--transition-fast);
}

.addie-line {
  flex: 1;
  height: 2px;
  background: var(--color-border);
  margin: 0 -2px;
  z-index: 1;
}

/* ADDIE Status Colors */
.addie-node.status-green {
  background: #22c55e;
  border-color: #22c55e;
  color: #fff;
  box-shadow: 0 0 10px rgba(34, 197, 94, 0.4);
}

.addie-node.status-yellow {
  background: #eab308;
  border-color: #eab308;
  color: #000;
  box-shadow: 0 0 10px rgba(234, 179, 8, 0.4);
}

.addie-node.status-red {
  background: #ef4444;
  border-color: #ef4444;
  color: #fff;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.4);
}

.addie-node.status-gray {
  background: var(--bg-panel);
  border-color: var(--color-border);
  color: var(--color-text-muted);
}

/* Sidebar Details & Export Buttons */
.export-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--tint-3);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  color: var(--color-text);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  width: 100%;
}

.export-btn i {
  width: 16px;
  height: 16px;
  color: var(--color-text-muted);
}

.export-btn:hover {
  background: var(--tint-8);
  border-color: var(--tint-20);
}

.export-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* --- Advanced Settings Drawer --- */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.drawer-overlay.open {
  opacity: 1;
  pointer-events: auto;
}
.settings-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 380px;
  max-width: 100vw;
  height: 100vh;
  background: rgba(15, 18, 25, 0.85);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-left: 1px solid var(--tint-10);
  box-shadow: -10px 0 40px rgba(0,0,0,0.5);
  z-index: 1000;
  transform: translateX(100%);
  transition: transform 0.4s cubic-bezier(0.19, 1, 0.22, 1);
  display: flex;
  flex-direction: column;
  padding: 32px 24px;
}
.settings-drawer.open {
  transform: translateX(0);
}
.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
}
.drawer-header h3 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: #fff;
}
.drawer-close-btn {
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.6);
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: background 0.2s, color 0.2s;
}
.drawer-close-btn:hover {
  background: var(--tint-10);
  color: #fff;
}
.drawer-section {
  margin-bottom: 32px;
}
.drawer-section h4 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--tint-50);
  margin-bottom: 16px;
  font-weight: 600;
}
.color-swatches-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
.swatch-item {
  display: flex;
  align-items: center;
  gap: 12px;
}
.swatch-input {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--tint-10);
  box-shadow: 0 4px 10px rgba(0,0,0,0.2);
  flex-shrink: 0;
  padding: 0;
  cursor: pointer;
  background: transparent;
}
.swatch-input::-webkit-color-swatch-wrapper {
  padding: 0;
}
.swatch-input::-webkit-color-swatch {
  border: none;
  border-radius: 50%;
}
.swatch-info {
  display: flex;
  flex-direction: column;
}
.swatch-name {
  font-size: 0.85rem;
  font-weight: 500;
  color: #fff;
}
.swatch-hex {
  font-size: 0.75rem;
  color: var(--tint-50);
  font-family: monospace;
  background: transparent;
  border: none;
  outline: none;
  padding: 0;
  margin: 0;
  width: 65px;
  cursor: text;
}
.swatch-hex:focus {
  color: #fff;
  border-bottom: 1px solid var(--tint-30);
}
.translation-row {
  display: flex;
  gap: 12px;
  align-items: center;
}
.drawer-select {
  flex: 1;
  background: var(--tint-5);
  border: 1px solid var(--tint-10);
  color: #fff;
  padding: 10px 12px;
  border-radius: 8px;
  outline: none;
  font-size: 0.9rem;
}
.drawer-select option {
  background: var(--bg-surface);
  color: #fff;
}
.drawer-btn {
  background: var(--color-primary);
  color: #fff;
  border: none;
  padding: 10px 16px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.2s, transform 0.2s;
}
.drawer-btn:hover {
  background: var(--color-primary-light);
  transform: translateY(-2px);
}
.drawer-btn:disabled {
  background: var(--tint-10);
  color: var(--tint-30);
  cursor: not-allowed;
  transform: none;
}


/* --- Kanban Board UI --- */
#addie-status-panel {
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s;
  border-radius: 8px;
}
#addie-status-panel:hover {
  background: var(--tint-3);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.kanban-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  width: 100%;
  height: 60vh;
  min-height: 400px;
  overflow-x: auto;
  padding: 8px 0;
}

.kanban-column {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--tint-5);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  padding: 16px;
}

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

.kanban-col-title {
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #fff;
}

.kanban-col-count {
  background: var(--tint-10);
  color: var(--color-text-muted);
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 12px;
}

.kanban-cards-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  padding-right: 4px;
}

.kanban-cards-container::-webkit-scrollbar {
  width: 4px;
}
.kanban-cards-container::-webkit-scrollbar-thumb {
  background: var(--tint-10);
  border-radius: 4px;
}

.kanban-card {
  background: var(--bg-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  cursor: grab;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}

.kanban-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(0,0,0,0.3);
  border-color: var(--tint-15);
}

.kanban-card:active {
  cursor: grabbing;
}

.kanban-card-title {
  font-size: 0.9rem;
  font-weight: 500;
  color: #fff;
  margin-bottom: 8px;
  line-height: 1.4;
}

.kanban-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.kanban-tag {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
}

.tag-red { background: rgba(239, 68, 68, 0.15); color: #fca5a5; }
.tag-yellow { background: rgba(234, 179, 8, 0.15); color: #fde047; }
.tag-blue { background: rgba(59, 130, 246, 0.15); color: #93c5fd; }
.tag-purple { background: rgba(168, 85, 247, 0.15); color: #d8b4fe; }

.kanban-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--tint-5);
  padding-top: 8px;
}

.kanban-assignee {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  font-weight: bold;
  color: #fff;
  border: 1px solid var(--tint-20);
}

.kanban-date {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

/* WYSIWYG Design Tools Panel */
.design-tools-panel {
  position: absolute;
  top: 60px;
  right: 20px;
  width: 320px;
  background: var(--bg-panel);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: auto;
}

.design-tools-panel.hidden {
  opacity: 0;
  transform: translateY(-10px) scale(0.95);
  pointer-events: none;
}

.dt-header {
  padding: 16px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.dt-body {
  padding: 16px;
  max-height: 400px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.dt-section h4 {
  margin: 0 0 12px 0;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
}

.dt-section label {
  display: block;
  font-size: 0.8rem;
  margin-bottom: 6px;
  color: var(--color-text-main);
}

.dt-section .input-field,
.dt-section .color-picker,
.dt-section .range-slider {
  width: 100%;
  margin-bottom: 12px;
}

.dt-section .color-picker {
  height: 36px;
  padding: 2px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
}

.dt-section .range-slider {
  -webkit-appearance: none;
  background: var(--tint-10);
  height: 4px;
  border-radius: 2px;
  outline: none;
}
.dt-section .range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--color-primary);
  cursor: pointer;
}

.dt-footer {
  padding: 16px;
  border-top: 1px solid var(--color-border);
}

.brand-swatch {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--tint-20);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.brand-swatch:hover {
  transform: scale(1.1);
  box-shadow: 0 0 8px var(--tint-50);
}

/* ---------------------------------------------------------------------- */
/* NEW INTERACTIVE COMPONENTS CSS                                           */
/* ---------------------------------------------------------------------- */

.glass-panel {
  background: var(--tint-3);
  border: 1px solid var(--tint-10);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

/* 1. Text Layout Widget */
.text-layout-widget {
  margin-bottom: 2rem;
}
.text-layout-widget.layout-title h1 {
  font-size: 3rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  background: linear-gradient(90deg, #fff, var(--color-primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.text-layout-widget.layout-dual {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
}
.text-layout-widget.layout-triple {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1.5rem;
}
.text-col {
  padding: 1.5rem;
}

/* 2. Image Carousel */
.image-carousel-widget {
  position: relative;
  width: 100%;
  max-width: 800px;
  margin: 0 auto 2rem;
  overflow: hidden;
  border-radius: 16px;
}
.carousel-track {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.carousel-track::-webkit-scrollbar { display: none; }
.carousel-slide {
  flex: 0 0 100%;
  scroll-snap-align: center;
  position: relative;
}
.carousel-slide img {
  width: 100%;
  height: 400px;
  object-fit: cover;
  display: block;
}
.carousel-caption {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.5rem 1rem;
  color: #fff;
  border-radius: 8px;
}
.carousel-prev, .carousel-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0,0,0,0.5);
  border-radius: 50%;
  color: white;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: 1px solid var(--tint-20);
}
.carousel-prev { left: 10px; }
.carousel-next { right: 10px; }
.carousel-prev:hover, .carousel-next:hover { background: var(--color-primary); }

/* 3. Video Widget */
.video-widget {
  position: relative;
  width: 100%;
  height: 100%;
  margin: auto;
  display: flex;
  align-items: center;
  justify-content: center;
}
.video-widget.size-small { max-width: 600px; }
.video-widget.size-medium { max-width: 800px; }
.video-widget.size-large { max-width: 1200px; }
.video-widget.size-full { max-width: 100%; }
.video-widget iframe {
  width: 100%;
  aspect-ratio: 16/9;
  border-radius: 16px;
}
.local-video-wrapper video {
  width: 100%;
  border-radius: 16px;
  display: block;
}

/* 4. Process Block Widget */
.process-block-widget {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 2rem;
}
.process-step {
  display: flex;
  align-items: flex-start;
  gap: 1.5rem;
  padding: 1.5rem;
}
.step-number {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 1.2rem;
  flex-shrink: 0;
}

/* 5. Flashcards Widget */
.flashcard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 2rem;
  margin-bottom: 2rem;
}
.flashcard-container {
  perspective: 1000px;
  height: 300px;
}
.flashcard {
  width: 100%;
  height: 100%;
  position: relative;
  transition: transform 0.6s cubic-bezier(0.4, 0.2, 0.2, 1);
  transform-style: preserve-3d;
  cursor: pointer;
}
.flashcard.flipped {
  transform: rotateY(180deg);
}
.flashcard-front, .flashcard-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  text-align: center;
}
.flashcard-front {
  z-index: 2;
}
.flashcard-back {
  transform: rotateY(180deg);
  background: var(--tint-5); /* slightly different back */
}
.flashcard-icon {
  width: 48px;
  height: 48px;
  color: var(--color-primary);
  margin-bottom: 1rem;
}

/* 6. Image Hotspot Widget */
.image-hotspot-widget {
  margin-bottom: 2rem;
}
.hotspot-wrapper {
  position: relative;
  display: inline-block;
  padding: 0;
  overflow: visible; /* tooltips might overflow */
}
.hotspot-dot {
  position: absolute;
  width: 24px;
  height: 24px;
  background: var(--color-primary);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  cursor: pointer;
  box-shadow: 0 0 0 0 rgba(var(--color-primary-rgb), 0.7);
  animation: hotspot-pulse 2s infinite;
}
@keyframes hotspot-pulse {
  70% { box-shadow: 0 0 0 10px rgba(var(--color-primary-rgb), 0); }
  100% { box-shadow: 0 0 0 0 rgba(var(--color-primary-rgb), 0); }
}
.hotspot-tooltip {
  position: absolute;
  bottom: 150%;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  width: max-content;
  max-width: 250px;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s;
  z-index: 10;
}
.hotspot-dot.active .hotspot-tooltip {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

/* 7. Before After Slider Widget */
.before-after-widget {
  height: 400px;
  margin-bottom: 2rem;
}

/* 8. Accordion / Tab Widget */
.accordion-tab-widget {
  margin-bottom: 2rem;
}
.tab-header {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
}
.tab-btn {
  background: transparent;
  border: none;
  color: var(--color-text-muted);
  padding: 0.5rem 1rem;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.3s;
}
.tab-btn.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}
.tab-content-container {
  padding: 1.5rem;
}
.tab-pane {
  display: none;
  animation: fadeIn 0.5s;
}
.tab-pane.active {
  display: block;
}
.accordion-item {
  margin-bottom: 1rem;
  overflow: hidden;
}
.accordion-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  cursor: pointer;
}
.accordion-header h4 { margin: 0; }
.accordion-icon {
  transition: transform 0.3s;
}
.accordion-item.active .accordion-icon {
  transform: rotate(180deg);
}
.accordion-body {
  max-height: 0;
  transition: max-height 0.4s ease-out;
  overflow: hidden;
}
.accordion-item.active .accordion-body {
  max-height: 1000px; /* large enough */
}
.accordion-content-inner {
  padding: 0 1.5rem 1.5rem;
}

/* 9. Branching Scenario Widget */
.branching-scenario-widget {
  padding: 2rem;
  text-align: center;
  max-width: 600px;
  margin: 0 auto 2rem;
}
.scenario-text {
  font-size: 1.1rem;
  margin-bottom: 2rem;
  line-height: 1.6;
}
.scenario-choices {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.choice-btn {
  width: 100%;
  padding: 1rem;
  font-size: 1rem;
  text-align: left;
  background: var(--tint-5);
  border: 1px solid var(--tint-10);
  color: #fff;
  cursor: pointer;
}
.choice-btn:hover {
  background: var(--color-primary);
  border-color: var(--color-primary);
}

/* --- Authoring Widget Library Buttons --- */
.authoring-widget-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem;
  background: var(--tint-5);
  border: 1px solid var(--tint-10);
  border-radius: 8px;
  color: var(--color-text);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}
.authoring-widget-btn:hover {
  background: var(--color-primary);
  border-color: var(--color-primary);
  transform: translateY(-2px);
}

.widget-edit-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: flex; /* Always visible */
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  transition: all 0.2s;
  align-items: center;
  gap: 0.5rem;
}

/* --- Stage Editor Drawer --- */
.stage-editor-drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  z-index: 2000;
  display: flex;
  align-items: center;
  pointer-events: none;
}
.stage-editor-handle {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translate(-100%, -50%);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-right: none;
  border-radius: 12px 0 0 12px;
  padding: 1.5rem 0.6rem;
  color: var(--color-text);
  font-weight: 600;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  box-shadow: -4px 0 12px rgba(0,0,0,0.2);
  transition: background 0.2s;
  pointer-events: auto;
  writing-mode: vertical-lr;
  text-orientation: mixed;
}
.stage-editor-handle:hover {
  background: var(--tint-10);
}
.stage-editor-panel {
  background: rgba(20,20,20,0.95);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  width: 1020px;
  max-width: 95vw;
  height: 100vh;
  border-left: 1px solid var(--color-border);
  box-shadow: -10px 0 30px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  padding: 2rem 1.5rem;
  pointer-events: auto;
  transform: translateX(100%);
  transition: transform 0.4s cubic-bezier(0.19, 1, 0.22, 1),
              width 0.35s cubic-bezier(0.19, 1, 0.22, 1);
}
.stage-editor-panel.open {
  transform: translateX(0);
}
/* Shrink when the right column is hidden */
.stage-editor-panel.right-hidden {
  width: 720px;
}
/* Left column hidden = agent-focused mode (settings + ID Assistant):
   keep enough width for the chat and the full action row */
.stage-editor-panel.left-hidden {
  width: 760px;
}
/* Compact when both columns are hidden */
.stage-editor-panel.left-hidden.right-hidden {
  width: 440px;
}
.stage-editor-split {
  display: flex;
  gap: 1.5rem;
  flex: 1;
  min-height: 0;
  margin-top: 1rem;
}
.stage-editor-left {
  flex: 1.5;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 0;
}
.stage-editor-left.hidden {
  display: none !important;
}
.stage-editor-right.hidden {
  display: none !important;
}
.stage-editor-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 0;
}
.stage-editor-left label, .stage-editor-right label {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  font-weight: 600;
}
.stage-editor-textarea {
  flex: 1;
  width: 100%;
  background: #1e1e1e;
  color: #d4d4d4;
  font-family: monospace;
  padding: 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  resize: none;
  font-size: 13px;
  line-height: 1.5;
  outline: none;
  min-height: 0;
}
.stage-editor-components {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  overflow-y: auto;
  padding-right: 0.5rem;
}
.stage-editor-footer {
  display: flex;
  justify-content: flex-end;
  padding-top: 1rem;
  margin-top: 1rem;
  border-top: 1px solid var(--tint-5);
  /* Hiding tool panels narrows the drawer (920 -> 600/520/340px):
     the action row must wrap instead of pushing buttons out of view. */
  flex-wrap: wrap;
  gap: 0.5rem;
}
.stage-editor-footer button {
  flex-shrink: 0;
  white-space: nowrap;
}
/* The header's toggle chips must wrap at narrow widths too */
.stage-editor-header > div {
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* Satori Custom Audio Player */
.audio-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    max-width: 600px;
}

.audio-btn:hover {
    transform: translateY(-2px);
}

.audio-btn.playing {
    /* No border for minimalist */
}

.audio-play-icon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: transparent;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.audio-btn.playing .audio-play-icon {
    background: transparent;
}

.audio-waveform {
    display: flex;
    align-items: center;
    gap: 2px;
    height: 14px;
}

.audio-waveform span {
    display: block;
    width: 2.5px;
    border-radius: 2px;
    background: var(--tint-15);
    height: 3px;
    transition: height 0.2s, background 0.2s;
}

.audio-btn.playing .audio-waveform span {
    background: #EA2C63;
    animation: waveAnim 0.8s ease-in-out infinite;
}

.audio-waveform span:nth-child(1) { animation-delay: 0.00s; }
.audio-waveform span:nth-child(2) { animation-delay: 0.10s; }
.audio-waveform span:nth-child(3) { animation-delay: 0.20s; }
.audio-waveform span:nth-child(4) { animation-delay: 0.15s; }
.audio-waveform span:nth-child(5) { animation-delay: 0.05s; }
.audio-waveform span:nth-child(6) { animation-delay: 0.25s; }
.audio-waveform span:nth-child(7) { animation-delay: 0.10s; }
.audio-waveform span:nth-child(8) { animation-delay: 0.30s; }

@keyframes waveAnim {
    0%, 100% { height: 3px; opacity: 0.5; }
    50% { height: 12px; opacity: 1; }
}

.audio-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--tint-35);
    margin-right: 12px;
    margin-left: 8px;
}

.audio-btn.playing .audio-label {
    color: rgba(255, 255, 255, 0.75);
}

.audio-duration {
    font-size: 11px;
    font-weight: 600;
    color: var(--tint-20);
}

.ap-right {
    margin-left: auto;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex: 1;
    max-width: 250px;
}

.ap-scrub {
    width: 100%;
    height: 6px;
    background: var(--tint-10);
    border-radius: 3px;
    overflow: hidden;
    cursor: pointer;
    position: relative;
}

.ap-fill {
    height: 100%;
    width: 0%;
    background: #EA2C63;
    transition: width 0.1s linear;
}

.ap-time {
    font-size: 10px;
    font-weight: 600;
    color: var(--tint-40);
}

/* Iframe Loading Visualizer */
.iframe-loader-container {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--color-background, #070b14);
    z-index: 100;
    font-family: var(--font-sans, sans-serif);
    color: var(--color-text, #ffffff);
    gap: 1.5rem;
    pointer-events: none;
    transition: opacity 0.4s ease;
    border-radius: inherit;
}

.iframe-loader-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(99, 102, 241, 0.1);
    border-top: 3px solid #6366f1;
    border-radius: 50%;
    animation: iframe-spin 1s linear infinite;
    position: relative;
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.2);
}

.iframe-loader-spinner::before {
    content: '';
    position: absolute;
    inset: -6px;
    border: 3px solid transparent;
    border-top: 3px solid #a855f7;
    border-radius: 50%;
    animation: iframe-spin-reverse 1.5s linear infinite;
}

.iframe-loader-text {
    font-size: 0.95rem;
    font-weight: 500;
    letter-spacing: 0.05em;
    color: var(--color-text-muted, #8a95a5);
    text-transform: uppercase;
    animation: iframe-pulse 2s ease-in-out infinite;
}

@keyframes iframe-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes iframe-spin-reverse {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(-360deg); }
}

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

/* Credentials settings portal styles */
.settings-portal select:focus,
.settings-portal input:focus {
  outline: none;
  border-color: var(--color-primary) !important;
  box-shadow: 0 0 0 2px rgba(var(--color-primary-rgb), 0.2);
}

.provider-form-pane {
  transition: all var(--transition-fast) ease;
}

/* Diagnostic Status Pills */
.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
}
.status-pill.success {
  background: rgba(16, 185, 129, 0.15);
  color: var(--color-accent-green);
  border: 1px solid rgba(16, 185, 129, 0.3);
}
.status-pill.error {
  background: rgba(239, 68, 68, 0.15);
  color: var(--color-accent-red);
  border: 1px solid rgba(239, 68, 68, 0.3);
}
.status-pill.warning {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.3);
}
.status-pill.gray {
  background: var(--tint-5);
  color: var(--color-text-muted);
  border: 1px solid var(--tint-10);
}

/* Design Agent Console Styling */
.stage-editor-agent-panel {
  width: 420px;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--color-border);
  padding-left: 1.5rem;
  min-height: 0;
  height: 100%;
}
.agent-panel-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--tint-5);
  margin-bottom: 1rem;
  flex-shrink: 0;
}
.agent-avatar-glow {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #a855f7, #6366f1);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 12px rgba(168, 85, 247, 0.4);
}
.agent-avatar-icon {
  width: 18px;
  height: 18px;
  color: #fff;
}
.agent-header-text {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.agent-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-text);
}
.agent-subtitle {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}
.agent-status-indicator {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(16, 185, 129, 0.1);
  padding: 0.25rem 0.5rem;
  border-radius: 9999px;
  border: 1px solid rgba(16, 185, 129, 0.2);
}
.agent-status-indicator .status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 6px #10b981;
}
.agent-status-indicator .status-text {
  font-size: 0.7rem;
  color: #10b981;
  font-weight: 500;
}
.agent-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding-right: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: 0;
}
.agent-message {
  display: flex;
  flex-direction: column;
  max-width: 85%;
}
.agent-message.system {
  align-self: flex-start;
}
.agent-message.user {
  align-self: flex-end;
}
.agent-message .message-bubble {
  padding: 0.75rem 1rem;
  border-radius: 12px;
  font-size: 0.85rem;
  line-height: 1.4;
}
.agent-message.system .message-bubble {
  background: var(--tint-5);
  color: var(--color-text);
  border: 1px solid var(--tint-5);
  border-top-left-radius: 2px;
}
.agent-message.user .message-bubble {
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.2), rgba(99, 102, 241, 0.2));
  color: #fff;
  border: 1px solid rgba(168, 85, 247, 0.3);
  border-top-right-radius: 2px;
}
.agent-message .message-bubble p {
  margin: 0 0 0.5rem 0;
}
.agent-message .message-bubble p:last-child {
  margin-bottom: 0;
}
.agent-message .message-bubble ul, .agent-message .message-bubble ol {
  margin: 0.5rem 0;
  padding-left: 1.2rem;
}
.agent-message .message-bubble li {
  margin-bottom: 0.25rem;
}
.agent-message .message-bubble pre {
  background: rgba(0, 0, 0, 0.3);
  padding: 0.5rem;
  border-radius: 4px;
  overflow-x: auto;
  font-family: monospace;
  font-size: 0.75rem;
  margin: 0.5rem 0;
}
.agent-message .message-bubble code {
  font-family: monospace;
  font-size: 0.75rem;
  background: var(--tint-10);
  padding: 0.1rem 0.25rem;
  border-radius: 3px;
}
.agent-suggestion-container {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding: 0.5rem 0;
  margin-top: 0.5rem;
  border-top: 1px solid var(--tint-3);
  flex-shrink: 0;
}
.agent-suggestion-container::-webkit-scrollbar {
  height: 4px;
}
.agent-suggestion-container::-webkit-scrollbar-thumb {
  background: var(--tint-10);
  border-radius: 2px;
}
.suggestion-chip {
  background: var(--tint-3);
  border: 1px solid var(--tint-8);
  color: var(--color-text-muted);
  padding: 0.35rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}
.suggestion-chip:hover {
  background: rgba(168, 85, 247, 0.1);
  border-color: rgba(168, 85, 247, 0.3);
  color: #fff;
  transform: translateY(-1px);
}
.agent-chat-input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 0.5rem;
  margin-top: 0.5rem;
  transition: border-color 0.2s;
  flex-shrink: 0;
}
.agent-chat-input-wrapper:focus-within {
  border-color: rgba(168, 85, 247, 0.5);
}
.agent-chat-input-wrapper textarea {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--color-text);
  font-size: 0.85rem;
  resize: none;
  outline: none;
  padding: 0.25rem;
  max-height: 100px;
  font-family: inherit;
}
.agent-send-btn {
  background: #a855f7;
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  flex-shrink: 0;
}
.agent-send-btn:hover {
  background: #9333ea;
}
.agent-send-btn:active {
  transform: scale(0.95);
}
.agent-send-btn i {
  width: 14px;
  height: 14px;
}
.typing-dots {
  display: inline-flex;
  gap: 3px;
  align-items: center;
  padding: 0.25rem 0.5rem;
}
.typing-dots span {
  width: 6px;
  height: 6px;
  background: var(--color-text-muted);
  border-radius: 50%;
  animation: typingGlow 1.4s infinite both;
}
.typing-dots span:nth-child(2) {
  animation-delay: 0.2s;
}
.typing-dots span:nth-child(3) {
  animation-delay: 0.4s;
}
@keyframes typingGlow {
  0%, 80%, 100% {
    transform: scale(0.6);
    opacity: 0.4;
  }
  40% {
    transform: scale(1);
    opacity: 1;
    background: #a855f7;
  }
}

/* ==========================================================================
   Interactive Scene Widget (Spline + Text)
   ========================================================================== */
.widget-interactivescene {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 500px;
    background: #050505;
    color: #ffffff;
    font-family: Arial, sans-serif;
    overflow: hidden;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
}

.widget-interactivescene::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 200;
    pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.035'/%3E%3C/svg%3E");
    background-size: 180px 180px;
    opacity: 0.45;
}

.widget-interactivescene .ambient {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background:
        radial-gradient(ellipse 60% 50% at 72% 50%, rgba(155, 89, 182, 0.08) 0%, transparent 70%),
        radial-gradient(ellipse 40% 60% at 20% 30%, rgba(155, 89, 182, 0.05) 0%, transparent 60%);
}

.widget-interactivescene .page {
    position: absolute;
    inset: 0;
    z-index: 1;
    width: 100%;
    height: 100%;
    display: flex;
}

.widget-interactivescene .left {
    position: absolute;
    top: 0;
    left: 0;
    width: 46%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: clamp(2rem, 5vw, 5rem);
    z-index: 10;
    overflow-y: auto;
    scrollbar-width: none;
}

.widget-interactivescene .left::-webkit-scrollbar {
    display: none;
}

.widget-interactivescene .eyebrow {
    font-size: 0.65rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: #EA2C63;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    opacity: 1;
}

.widget-interactivescene .eyebrow::before {
    content: '';
    display: inline-block;
    width: 2rem;
    height: 1px;
    background: #EA2C63;
    flex-shrink: 0;
}

.widget-interactivescene .status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #EA2C63;
    display: inline-block;
    margin-left: 0.4rem;
    box-shadow: 0 0 6px #EA2C63;
    animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.7); }
}

.widget-interactivescene .headline {
    font-size: clamp(1.8rem, 3vw, 2.8rem);
    line-height: 1.1;
    letter-spacing: -0.01em;
    color: #ffffff;
    margin-bottom: 1.25rem;
    opacity: 1;
}

.widget-interactivescene .typewriter-wrap {
    position: relative;
    opacity: 1;
}

.widget-interactivescene .typewriter-text {
    font-size: 0.85rem;
    line-height: 1.6;
    color: rgba(245, 242, 236, 0.72);
    white-space: pre-wrap;
}

.widget-interactivescene .cursor {
    display: inline-block;
    width: 2px;
    height: 1.1em;
    background: #EA2C63;
    margin-left: 2px;
    vertical-align: middle;
    animation: blink 0.8s infinite;
}

@keyframes blink {
    50% { opacity: 0; }
}

/* Right Panel (Spline) */
.widget-interactivescene .right {
    position: absolute;
    inset: 0;
    z-index: 1;
    overflow: hidden;
}

.widget-interactivescene .spline-wrap {
    width: 100%;
    height: 100%;
    position: relative;
}

.widget-interactivescene .spotlight {
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: none;
    background: radial-gradient(circle 320px at var(--mx, 60%) var(--my, 50%),
            rgba(201, 168, 76, 0.12) 0%, transparent 70%);
    transition: opacity 0.3s;
    opacity: 0;
}

.widget-interactivescene .right:hover .spotlight {
    opacity: 1;
}

.widget-interactivescene spline-viewer {
    width: 100%;
    height: 100%;
    display: block;
}

/* Nano-bot canvas */
.widget-interactivescene .nano-canvas {
    position: absolute;
    inset: 0;
    z-index: 150;
    pointer-events: none;
    opacity: 0;
    transition: opacity 1.8s ease;
}
.widget-interactivescene .nano-canvas.visible {
    opacity: 1;
}

@media (max-width: 768px) {
    .widget-interactivescene .left {
        width: 100%;
        height: auto;
        bottom: 0;
        top: auto;
        background: linear-gradient(to top, rgba(0,0,0,0.9), transparent);
    }
}

narration {
    display: none !important;
}

/* ==========================================================================
   Light Theme — html[data-theme="light"], toggled from the session chip.
   Dark stays the default; scrollys and the login stage are intentionally
   excluded (cinematic surfaces).
   ========================================================================== */
html[data-theme="light"] {
  --color-background: #eef1f7;
  --bg-panel: rgba(255, 255, 255, 0.78);
  --bg-panel-rgb: 255, 255, 255;

  --color-text-main: #182036;
  --color-text-muted: #5a6478;
  --color-text-dark: #8b93a7;
  --color-border: rgba(24, 32, 54, 0.14);
  --color-border-glow: rgba(99, 91, 255, 0.35);

  --color-surface: #ffffff;
  --bg-surface: #ffffff;
  --color-text-dim: #98a0b3;

  --tint-1: rgba(24, 32, 54, 0.015);
  --tint-2: rgba(24, 32, 54, 0.03);
  --tint-3: rgba(24, 32, 54, 0.04);
  --tint-4: rgba(24, 32, 54, 0.05);
  --tint-5: rgba(24, 32, 54, 0.06);
  --tint-8: rgba(24, 32, 54, 0.1);
  --tint-10: rgba(24, 32, 54, 0.12);
  --tint-15: rgba(24, 32, 54, 0.17);
  --tint-20: rgba(24, 32, 54, 0.22);
  --tint-22: rgba(24, 32, 54, 0.24);
  --tint-25: rgba(24, 32, 54, 0.27);
  --tint-30: rgba(24, 32, 54, 0.32);
  --tint-35: rgba(24, 32, 54, 0.37);
  --tint-40: rgba(24, 32, 54, 0.42);
  --tint-50: rgba(24, 32, 54, 0.52);

  --shadow-sm: 0 2px 8px rgba(24, 32, 54, 0.08);
  --shadow-md: 0 8px 30px rgba(24, 32, 54, 0.12);
  --shadow-lg: 0 12px 40px rgba(24, 32, 54, 0.18);
}

html[data-theme="light"] #webgl-bg-container {
  opacity: 0.05;
}

html[data-theme="light"] .brand-name {
  background: linear-gradient(to right, #182036, #5a6478);
  -webkit-background-clip: text;
}
