/* ==========================================================================
   DESIGN SYSTEM - Inspired by cra.mr
   ========================================================================== */

:root {
  /* Light Theme (Default) */
  --bg: #ffffff;
  --bg-elevated: #f9fafb;
  --bg-card: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --text-secondary: #6b7280;
  --accent: #111827;
  --accent-hover: #000000;
  --shadow: rgba(0, 0, 0, 0.1);

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-serif: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  /* Spacing */
  --spacing-xs: 0.5rem;
  --spacing-sm: 1rem;
  --spacing-md: 1.5rem;
  --spacing-lg: 2rem;
  --spacing-xl: 3rem;

  /* Animation */
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --duration-fast: 0.2s;
  --duration-normal: 0.3s;
  --duration-slow: 0.5s;

  /* Border Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

/* Dark Theme - Gray like cra.mr */
[data-theme="dark"] {
  --bg: #1a1a1a;
  --bg-elevated: #222222;
  --bg-card: #252525;
  --border: #333333;
  --text: #e5e5e5;
  --text-secondary: #999999;
  --accent: #e5e5e5;
  --accent-hover: #ffffff;
  --shadow: rgba(0, 0, 0, 0.3);
}

/* ==========================================================================
   RESET & BASE
   ========================================================================== */

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

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background-color: var(--bg);
  transition: background-color var(--duration-normal) var(--ease),
    color var(--duration-normal) var(--ease),
    padding var(--duration-normal) var(--ease);
  overflow-x: hidden;
}

body.chat-open .container {
  transform: translateX(-180px);
}


a {
  color: inherit;
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease);
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

::selection {
  background-color: var(--accent);
  color: white;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* ==========================================================================
   LAYOUT - Side by Side like cra.mr
   ========================================================================== */

.container {
  display: flex;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  transform: translateX(0);
  will-change: transform;
  transition: transform 0.8s cubic-bezier(0.22, 1, 0.36, 1),
    align-items var(--duration-normal) var(--ease);
}

.container.viewing-content {
  align-items: flex-start;
  padding-top: 4rem;
}

/* Left Panel - Identity & Navigation */
.left-panel {
  background-color: var(--bg);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: var(--spacing-xl);
  flex-shrink: 0;
  transition: background-color var(--duration-normal) var(--ease);
}

.container.viewing-content .left-panel {
  justify-content: flex-start;
  position: sticky;
  top: 4rem;
}

/* Right Panel - Content */
.right-panel {
  flex: 0 1 auto;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.container.viewing-content .right-panel {
  align-items: flex-start;
}

/* Mobile Responsive */
@media (max-width: 900px) {
  .container {
    flex-direction: column;
    gap: 2rem;
    padding: var(--spacing-lg);
  }

  .left-panel {
    padding: var(--spacing-lg);
  }

  .right-panel {
    padding: var(--spacing-lg);
  }

  .logo-text {
    font-size: clamp(3rem, 12vw, 5rem);
  }

  .nav-card span {
    font-size: clamp(1.75rem, 6vw, 2.5rem);
  }
}

/* ==========================================================================
   IDENTITY SECTION (Left Panel)
   ========================================================================== */

.identity {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
}

/* Logo Text - cra.mr style with offset */
.logo-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2.5rem, 5vw, 4rem);
  line-height: 0.85;
  letter-spacing: -0.02em;
  margin-bottom: var(--spacing-md);
  transition: color var(--duration-fast) var(--ease);
}

.logo-text:hover {
  color: var(--accent);
}

.logo-part {
  color: var(--text);
}

/* Offset the second part - p under m in hamza (like m under a in cra.mr) */
.logo-part-offset {
  color: var(--text);
  margin-left: 1.1em;
}



.tagline {
  display: none;
}

.subtitle {
  display: none;
}

/* Social Links */
.social-links {
  display: flex;
  gap: var(--spacing-md);
}

.social-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 0;
  color: var(--text-secondary);
  transition: all var(--duration-fast) var(--ease);
}

.social-icon:hover {
  color: var(--text);
}

.social-icon svg {
  width: 28px;
  height: 28px;
}


/* Theme Toggle (inline with social icons) */
.theme-toggle-inline {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
}

.theme-toggle-inline .sun-icon,
.theme-toggle-inline .moon-icon {
  width: 20px;
  height: 20px;
}

[data-theme="dark"] .theme-toggle-inline .sun-icon {
  display: none;
}

[data-theme="dark"] .theme-toggle-inline .moon-icon {
  display: block;
}

[data-theme="light"] .theme-toggle-inline .sun-icon {
  display: block;
}

[data-theme="light"] .theme-toggle-inline .moon-icon {
  display: none;
}

/* Old Theme Toggle (hidden) */
.theme-toggle {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background-color: var(--bg-elevated);
  color: var(--text);
  transition: all var(--duration-fast) var(--ease);
  margin-top: auto;
}

.theme-toggle:hover {
  border-color: var(--accent);
  background-color: var(--accent);
  color: white;
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
}

.sun-icon {
  display: none;
}

.moon-icon {
  display: block;
}

[data-theme="dark"] .sun-icon {
  display: block;
}

[data-theme="dark"] .moon-icon {
  display: none;
}

/* ==========================================================================
   VIEWS & NAVIGATION
   ========================================================================== */

.view {
  display: none;
  animation: fadeIn var(--duration-normal) var(--ease);
  width: 100%;
  max-width: 700px;
}

.view.active {
  display: block;
}

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

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

/* Back Button */
.back-button {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-xs);
  padding: var(--spacing-xs) var(--spacing-sm);
  margin-bottom: var(--spacing-lg);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--duration-fast) var(--ease);
}

.back-button:hover {
  color: var(--accent);
}

.back-button svg {
  width: 16px;
  height: 16px;
}

/* ==========================================================================
   HOME VIEW
   ========================================================================== */

/* Navigation Cards - on the right side like cra.mr */
.nav-cards {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.nav-card {
  background: transparent;
  border: none;
  text-align: left;
  cursor: pointer;
  padding: 0;
  display: block;
  text-decoration: none;
}

.nav-card span {
  font-family: var(--font-serif);
  font-size: clamp(1.75rem, 3vw, 2.25rem);
  font-weight: 300;
  color: var(--text);
  transition: color var(--duration-fast) var(--ease);
}

.nav-card:hover span {
  color: var(--text-secondary);
}

/* ==========================================================================
   CONTENT SECTIONS
   ========================================================================== */

.content-section {
  max-width: 900px;
}

.section-title {
  font-family: var(--font-serif);
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 400;
  letter-spacing: -0.01em;
  color: var(--text);
  margin-bottom: var(--spacing-lg);
}

/* ==========================================================================
   ABOUT VIEW
   ========================================================================== */

.about-content {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--spacing-xl);
  align-items: start;
}

@media (max-width: 768px) {
  .about-content {
    grid-template-columns: 1fr;
    gap: var(--spacing-lg);
  }
}

.about-text p {
  font-size: 1.0625rem;
  line-height: 1.7;
  color: var(--text-secondary);
  margin-bottom: var(--spacing-md);
}

.about-text a {
  color: var(--accent);
  border-bottom: 1px solid transparent;
  transition: border-color var(--duration-fast) var(--ease);
}

.about-text a:hover {
  border-bottom-color: var(--accent);
}

.about-text h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
  margin-top: var(--spacing-lg);
  margin-bottom: var(--spacing-md);
}

.tech-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: var(--spacing-sm);
}

.tech-tag {
  display: inline-block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--accent);
  background-color: var(--bg-elevated);
  padding: var(--spacing-xs) var(--spacing-sm);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  text-align: center;
  transition: all var(--duration-fast) var(--ease);
}

.tech-tag:hover {
  border-color: var(--accent);
  background-color: var(--accent);
  color: white;
}

.about-image {
  position: relative;
}

.about-image img {
  width: 100%;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  filter: grayscale(20%);
  transition: all var(--duration-normal) var(--ease);
}

.about-image:hover img {
  filter: grayscale(0%);
  border-color: var(--accent);
}

.about-image::after {
  content: '';
  position: absolute;
  top: 12px;
  left: 12px;
  right: -12px;
  bottom: -12px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-md);
  z-index: -1;
  transition: all var(--duration-normal) var(--ease);
}

.about-image:hover::after {
  top: 8px;
  left: 8px;
}

/* ==========================================================================
   EXPERIENCE VIEW
   ========================================================================== */

.experience-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--spacing-lg);
  transition: all var(--duration-normal) var(--ease);
}

.experience-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 12px var(--shadow);
}

.experience-header {
  display: flex;
  align-items: flex-start;
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-md);
}

.company-logo {
  width: 64px;
  height: 64px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.experience-meta h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.company-name {
  font-size: 1rem;
  color: var(--accent);
  margin-bottom: 0.25rem;
}

.date-range {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.experience-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.experience-list li {
  display: flex;
  gap: var(--spacing-sm);
  font-size: 0.9375rem;
  line-height: 1.7;
  color: var(--text-secondary);
}

.experience-list li::before {
  content: '';
  width: 6px;
  height: 6px;
  background-color: var(--accent);
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 0.6rem;
}

/* ==========================================================================
   PROJECTS VIEW
   ========================================================================== */

.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--spacing-lg);
}

.project-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: all var(--duration-normal) var(--ease);
}

.project-card:hover {
  border-color: var(--accent);
  box-shadow: 0 8px 24px var(--shadow);
  transform: translateY(-4px);
}

.project-image {
  width: 100%;
  height: 180px;
  overflow: hidden;
  background-color: var(--bg-elevated);
}

.project-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--duration-slow) var(--ease);
}

.project-card:hover .project-image img {
  transform: scale(1.05);
}

.project-content {
  padding: var(--spacing-lg);
}

.project-label {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--spacing-xs);
}

.project-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: var(--spacing-sm);
}

.project-title a {
  transition: color var(--duration-fast) var(--ease);
}

.project-title a:hover {
  color: var(--accent);
}

.project-description {
  font-size: 0.9375rem;
  line-height: 1.7;
  color: var(--text-secondary);
  margin-bottom: var(--spacing-md);
}

.project-tech {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-xs);
  margin-bottom: var(--spacing-md);
}

.project-tech span {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--accent);
  background-color: var(--bg-elevated);
  padding: 0.375rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.project-link,
.project-links a {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--accent);
  transition: opacity var(--duration-fast) var(--ease);
}

.project-link:hover,
.project-links a:hover {
  opacity: 0.7;
}

.project-link svg,
.project-links a svg {
  width: 14px;
  height: 14px;
}

.project-links {
  display: flex;
  gap: var(--spacing-md);
}

/* ==========================================================================
   CERTIFICATIONS VIEW
   ========================================================================== */

.certs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--spacing-lg);
}

.cert-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--spacing-lg);
  transition: all var(--duration-normal) var(--ease);
}

.cert-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 12px var(--shadow);
  transform: translateY(-4px);
}

.cert-icon {
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: white;
  border-radius: var(--radius-sm);
  margin-bottom: var(--spacing-md);
}

.cert-icon img,
.cert-icon svg {
  width: 40px;
  height: 40px;
  object-fit: contain;
}

.cert-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: var(--spacing-xs);
  line-height: 1.4;
}

.cert-issuer {
  font-size: 0.875rem;
  color: var(--accent);
  margin-bottom: var(--spacing-md);
}

.cert-description {
  font-size: 0.875rem;
  line-height: 1.7;
  color: var(--text-secondary);
  margin-bottom: var(--spacing-md);
}

.cert-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--accent);
  transition: opacity var(--duration-fast) var(--ease);
}

.cert-link:hover {
  opacity: 0.7;
}

.cert-link svg {
  width: 14px;
  height: 14px;
}

/* ==========================================================================
   RESPONSIVE DESIGN
   ========================================================================== */

@media (max-width: 768px) {
  .intro-title {
    font-size: 2rem;
  }

  .nav-cards {
    gap: var(--spacing-sm);
  }

  .nav-card {
    padding: var(--spacing-md);
  }

  .certs-grid {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   AI CHAT FEATURE
   ========================================================================== */

.ai-chat-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 16px;
  pointer-events: none;
  /* Let clicks pass through empty spaces of the container */
}

/* Floating Action Button */
.ai-chat-fab {
  width: auto;
  min-width: 56px;
  height: 56px;
  border-radius: 28px;
  background-color: var(--text);
  color: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 20px;
  box-shadow: 0 8px 24px var(--shadow);
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
  position: relative;
  pointer-events: auto;
  /* Required since parent container has pointer-events: none */
}

[data-theme="dark"] .ai-chat-fab {
  background-color: #ffffff;
  color: #000000;
}

.ai-chat-fab::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transform: translateX(-100%);
  transition: transform 0.6s ease;
}

.ai-chat-fab:hover::before {
  transform: translateX(100%);
}

.ai-chat-fab:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 12px 32px var(--shadow);
}

.sparkle-icon {
  width: 20px;
  height: 20px;
  animation: pulse-sparkle 2s infinite ease-in-out;
}

.fab-text {
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
}

@keyframes pulse-sparkle {
  0% {
    transform: scale(1);
    opacity: 0.8;
  }

  50% {
    transform: scale(1.2);
    opacity: 1;
    filter: drop-shadow(0 0 4px currentColor);
  }

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

/* Chat Window */
.ai-chat-window {
  width: 420px;
  /* Made bigger */
  height: 600px;
  /* Made bigger */
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 16px 48px var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  transform-origin: bottom right;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  z-index: 1000;
}

/* iOS glassmorphism support */
@supports (backdrop-filter: blur(16px)) {
  .ai-chat-window {
    background: rgba(var(--bg-rgb), 0.85);
    /* Requires separate rgb var if possible, else fallback to solid */
  }
}

.ai-chat-window.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

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

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

.chat-avatar {
  position: relative;
  width: 40px;
  height: 40px;
}

.chat-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
}

.status-indicator {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 12px;
  height: 12px;
  background: #10b981;
  border-radius: 50%;
  border: 2px solid var(--bg-elevated);
}

.chat-header h3 {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 2px 0;
}

.chat-header p {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 0;
}

#close-chat-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: background 0.2s, color 0.2s;
}

#close-chat-btn:hover {
  background: var(--border);
  color: var(--text);
}

#close-chat-btn svg {
  width: 18px;
  height: 18px;
}

/* Chat Messages Area */
.chat-messages {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  /* Custom scrollbar */
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.message {
  max-width: 85%;
  animation: messageSlideIn 0.3s ease-out;
}

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

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

.message-content {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
}

.ai-message {
  align-self: flex-start;
}

.ai-message .message-content {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  color: var(--text);
}

.user-message {
  align-self: flex-end;
}

.user-message .message-content {
  background: var(--text);
  color: var(--bg);
  border-bottom-right-radius: 4px;
}

[data-theme="dark"] .user-message .message-content {
  background: #ffffff;
  color: #000000;
}

/* Markdown styling inside AI messages */
.message-content a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.message-content code {
  background: rgba(0, 0, 0, 0.1);
  padding: 2px 4px;
  border-radius: 4px;
  font-family: monospace;
}

[data-theme="dark"] .message-content code {
  background: rgba(255, 255, 255, 0.1);
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 8px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  width: fit-content;
  align-self: flex-start;
}

.typing-dot {
  width: 6px;
  height: 6px;
  background: var(--text-secondary);
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out both;
}

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

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

@keyframes typingBounce {

  0%,
  80%,
  100% {
    transform: scale(0);
  }

  40% {
    transform: scale(1);
  }
}

/* Pipeline Monitor Overlay */
.pipeline-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-card);
  z-index: 10;
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transform: scale(0.98);
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.pipeline-overlay.active {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
}

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

.pipeline-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
}

.pipeline-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-secondary);
  animation: pipelinePulse 2s infinite ease-in-out;
}

@keyframes pipelinePulse {

  0%,
  100% {
    opacity: 0.4;
  }

  50% {
    opacity: 1;
  }
}

.pipeline-latency {
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

/* Stages */
.pipeline-stages {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 20px;
  gap: 0;
}

.pipeline-stage {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  transition: all 0.3s ease;
  opacity: 0.35;
}

.pipeline-stage.active {
  opacity: 1;
  background: var(--bg-elevated);
}

.pipeline-stage.completed {
  opacity: 0.65;
}

.stage-indicator {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stage-ring {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  transition: all 0.3s ease;
}

.pipeline-stage.active .stage-ring {
  border-color: var(--text);
  background: var(--text);
  box-shadow: 0 0 0 3px var(--bg-card), 0 0 0 5px var(--text);
  animation: ringPulse 1.5s infinite ease-in-out;
}

.pipeline-stage.completed .stage-ring {
  border-color: var(--text);
  background: var(--text);
}

@keyframes ringPulse {

  0%,
  100% {
    box-shadow: 0 0 0 3px var(--bg-card), 0 0 0 5px var(--text);
  }

  50% {
    box-shadow: 0 0 0 3px var(--bg-card), 0 0 0 7px var(--text-secondary);
  }
}

.stage-content {
  flex: 1;
  min-width: 0;
}

.stage-label {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}

.stage-meta {
  font-family: var(--font-sans);
  /* Changed for consistency */
  font-size: 10px;
  color: var(--text-secondary);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0.8;
}

.stage-status {
  flex-shrink: 0;
}

.status-badge {
  display: inline-block;
  font-family: var(--font-sans);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 4px;
  transition: all 0.3s ease;
}

.status-badge.waiting {
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--border);
}

.status-badge.running {
  color: var(--bg);
  background: var(--text);
}

.status-badge.done {
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--border);
}

.status-badge.error {
  color: #ef4444;
  border: 1px solid #ef4444;
}

/* Connectors between stages */
.pipeline-connector {
  width: 1px;
  height: 16px;
  margin-left: 30px;
  /* center under the ring */
  background: var(--border);
  position: relative;
  overflow: hidden;
}

.connector-fill {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 0%;
  background: var(--text);
  transition: height 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.connector-fill.filled {
  height: 100%;
}

/* Footer */
.pipeline-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}

.pipeline-model,
.pipeline-endpoint {
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}


/* Input Area */
.chat-input-area {
  padding: 16px;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
}

#chat-form {
  position: relative;
  display: flex;
  align-items: center;
}

#chat-input {
  width: 100%;
  padding: 14px 48px 14px 16px;
  border-radius: 24px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

#chat-input:focus {
  outline: none;
  border-color: var(--text);
  box-shadow: 0 0 0 2px rgba(17, 24, 39, 0.1);
}

[data-theme="dark"] #chat-input:focus {
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.1);
}

#send-msg-btn {
  position: absolute;
  right: 6px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--text);
  color: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, background 0.2s;
}

[data-theme="dark"] #send-msg-btn {
  background: #ffffff;
  color: #000000;
}

#send-msg-btn:hover {
  transform: scale(1.05);
}

#send-msg-btn:active {
  transform: scale(0.95);
}

#send-msg-btn svg {
  width: 16px;
  height: 16px;
  margin-left: -2px;
  /* slight visual balance */
}

@media (max-width: 768px) {
  .ai-chat-container {
    bottom: 12px;
    right: 12px;
    left: 12px;
    gap: 12px;
  }

  .ai-chat-window {
    width: 100%;
    /* Use dvh (dynamic viewport height) which accounts for iOS keyboard.
       Falls back to vh for browsers that don't support dvh. */
    height: calc(100vh - 100px);
    height: calc(100dvh - 100px);
    max-height: calc(100vh - 100px);
    max-height: calc(100dvh - 100px);
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  }

  .chat-messages {
    padding: 12px;
    gap: 10px;
  }

  .message-content {
    font-size: 15px;
    /* Better readability */
    padding: 12px 14px;
    line-height: 1.45;
  }

  .ai-chat-fab {
    min-width: 50px;
    height: 50px;
    border-radius: 25px;
    padding: 0 16px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  }

  .chat-header {
    padding: 14px 16px;
  }

  .chat-header h3 {
    font-size: 16px;
  }

  .chat-input-area {
    padding: 12px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    /* iOS safe area */
  }

  #chat-input {
    font-size: 16px;
    /* Prevents iOS auto-zoom */
    padding: 12px 48px 12px 16px;
  }

  .pipeline-overlay {
    padding: 16px;
    transform: scale(0.9);
    transform-origin: top center;
  }
}

/* Streaming cursor */
.stream-cursor {
  display: inline-block;
  font-weight: 300;
  color: var(--text-secondary);
  animation: cursorBlink 0.6s step-end infinite;
}

@keyframes cursorBlink {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0;
  }
}