/* style.css - Diagram Landing Page Design System */

/* Import Google Fonts & Fontshare */
@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@700;800&display=swap');
@import url('https://api.fontshare.com/v2/css?f[]=general-sans@400;500;600;700&display=swap');

:root {
  /* Colors - Light Mode Tokens (Aligned with SwiftUI app Theme and patinamd) */
  --theme-background: #ededf0;                         /* SwiftUI: Color(nsColor: .windowBackgroundColor) */
  --theme-panel-background: rgba(246, 246, 244, 0.76); /* SwiftUI: opacity 0.76 */
  --theme-header-background: rgba(246, 246, 244, 0.72);/* SwiftUI: opacity 0.72 */
  --theme-surface: rgba(255, 255, 255, 0.92);         /* SwiftUI: Color(nsColor: .textBackgroundColor).opacity(0.92) */
  --theme-surface-hover: rgba(255, 255, 255, 0.98);   /* SwiftUI: opacity 0.98 */
  --theme-glass-hover-tint: rgba(255, 255, 255, 0.24);/* SwiftUI: opacity 0.24 */
  
  --theme-line: rgba(0, 0, 0, 0.08);                  /* SwiftUI: separator opacity 0.26 */
  --theme-line-strong: rgba(0, 0, 0, 0.16);           /* SwiftUI: separator opacity 0.48 */
  
  --theme-text: #111111;                               /* SwiftUI: labelColor */
  --theme-muted: #555552;                              /* SwiftUI: secondaryLabelColor */
  --theme-faint: #8e8e8a;                              /* SwiftUI: tertiaryLabelColor */
  
  --theme-accent: #0a94f5;                             /* Brand Blue accent */
  --theme-accent-soft: rgba(10, 148, 245, 0.12);       /* Brand Blue soft tint */

  --theme-toast-background: rgba(255, 255, 255, 0.82);
  --theme-toast-border: rgba(0, 0, 0, 0.08);
  --theme-toast-progress-track: rgba(0, 0, 0, 0.05);
  
  /* Mesh Gradient Colors */
  --mesh-color-1: rgba(99, 102, 241, 0.09);            /* Soft Indigo */
  --mesh-color-2: rgba(244, 63, 94, 0.07);             /* Soft Rose */
  --mesh-color-3: rgba(14, 165, 233, 0.08);            /* Soft Sky Blue */
  --mesh-color-4: rgba(245, 158, 11, 0.05);            /* Soft Amber */
  
  /* Page Styling Variables with color-mix */
  --page-bg: color-mix(in srgb, var(--theme-background) 78%, #fafaf8);
  --heading-color: var(--theme-text);
  --body-color: color-mix(in srgb, var(--theme-muted) 94%, var(--theme-accent));
  --border-color: color-mix(in srgb, var(--theme-background) 70%, #dcdcd9);
  --border-strong: color-mix(in srgb, var(--theme-background) 90%, #b2b2b0);
  --border-light: rgba(0, 0, 0, 0.03);
  
  /* Typography */
  --font-heading: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", sans-serif;
  --font-body: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", sans-serif;
  --font-ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", sans-serif;
  
  /* Shadows */
  --shadow-sm: 0 2px 7px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 8px 22px rgba(0, 0, 0, 0.06), 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 18px 44px rgba(0, 0, 0, 0.10), 0 6px 18px rgba(0, 0, 0, 0.05);
  
  /* Animations (Calibrated to SwiftUI spring properties) */
  /* Theme.ease = spring(response: 0.24, dampingFraction: 0.82) */
  --spring-ease: cubic-bezier(0.25, 1, 0.5, 1);
  /* Theme.push = interpolatingSpring(mass: 0.85, stiffness: 230, damping: 26) */
  --spring-push: cubic-bezier(0.34, 1.56, 0.64, 1);
  --spring-duration: 0.45s;

  /* Spacing */
  --page-gutter: clamp(1.25rem, 4vw, 2rem);
  --frame-gutter: clamp(1.5rem, 5vw, 3.5rem);
  --section-space: clamp(4rem, 7vw, 5.75rem);
  --section-space-tight: clamp(3rem, 5vw, 4rem);
  --hero-space-top: clamp(1.25rem, 2vw, 1.75rem);
  --hero-space-bottom: clamp(2rem, 3vw, 2.75rem);
}

[data-theme="dark"] {
  /* Colors - Dark Mode Tokens */
  --theme-background: #1a1a18;                         /* SwiftUI: windowBackgroundColor */
  --theme-panel-background: rgba(26, 26, 24, 0.76);     /* panelBackground */
  --theme-header-background: rgba(26, 26, 24, 0.72);    /* headerBackground */
  --theme-surface: rgba(40, 40, 38, 0.92);              /* surface */
  --theme-surface-hover: rgba(40, 40, 38, 0.98);        /* surfaceHover */
  --theme-glass-hover-tint: rgba(40, 40, 38, 0.24);     /* glassHoverTint */
  
  --theme-line: rgba(255, 255, 255, 0.08);            /* line */
  --theme-line-strong: rgba(255, 255, 255, 0.16);     /* lineStrong */
  
  --theme-text: #f5f5f0;                               /* labelColor */
  --theme-muted: #a0a09b;                              /* secondaryLabelColor */
  --theme-faint: #6a6a66;                              /* tertiaryLabelColor */
  
  --theme-accent: #38acf8;                             /* macOS Dark accent blue */
  --theme-accent-soft: rgba(56, 172, 248, 0.14);

  --theme-toast-background: rgba(30, 30, 30, 0.78);
  --theme-toast-border: rgba(255, 255, 255, 0.1);
  --theme-toast-progress-track: rgba(255, 255, 255, 0.1);
  
  /* Mesh Gradient Colors (Glows for Dark Mode) */
  --mesh-color-1: rgba(168, 85, 247, 0.14);           /* Glow Violet */
  --mesh-color-2: rgba(244, 63, 94, 0.11);            /* Glow Rose */
  --mesh-color-3: rgba(56, 172, 248, 0.13);           /* Glow Blue */
  --mesh-color-4: rgba(16, 185, 129, 0.08);           /* Glow Teal */
  
  /* Page Styling Variables with color-mix */
  --page-bg: color-mix(in srgb, var(--theme-background) 30%, #121210);
  --heading-color: color-mix(in srgb, var(--theme-text) 88%, var(--theme-accent));
  --body-color: color-mix(in srgb, var(--theme-muted) 94%, var(--theme-accent));
  --border-color: color-mix(in srgb, var(--theme-background) 70%, #2a2a28);
  --border-strong: color-mix(in srgb, var(--theme-background) 90%, #3a3a38);
  --border-light: rgba(255, 255, 255, 0.03);
}

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

html {
  scroll-behavior: smooth;
  font-size: 16px;
  background-color: var(--page-bg);
  transition: background-color var(--spring-duration) var(--spring-ease);
}

body {
  font-family: var(--font-body);
  color: var(--body-color);
  background-color: var(--page-bg);
  background-image:
    linear-gradient(180deg, color-mix(in srgb, var(--theme-background) 80%, transparent), var(--page-bg) 32rem),
    linear-gradient(90deg, var(--border-light) 1px, transparent 1px),
    linear-gradient(var(--border-light) 1px, transparent 1px);
  background-size: auto, 48px 48px, 48px 48px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: color var(--spring-duration) var(--spring-ease), background-color var(--spring-duration) var(--spring-ease);
}

h1, h2, h3, h4 {
  font-family: var(--font-heading);
  color: var(--heading-color);
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -0.015em;
  text-wrap: balance;
  transition: color var(--spring-duration) var(--spring-ease);
}

a {
  color: var(--theme-accent);
  text-decoration: none;
  transition: color 0.2s ease;
}

/* Skip link for screen reader keyboard accessibility */
.skip-link {
  position: absolute;
  top: -100px;
  left: 16px;
  background-color: var(--theme-accent);
  color: #ffffff;
  padding: 8px 16px;
  border-radius: 6px;
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 600;
  z-index: 1000;
  transition: top 0.2s var(--spring-ease);
}

.skip-link:focus {
  top: 16px;
  outline: 3px solid var(--theme-accent-soft);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Focus visible styling */
button:focus-visible, a:focus-visible, [role="button"]:focus-visible, input:focus-visible {
  outline: 2px solid var(--theme-accent);
  outline-offset: 2px;
}

/* Set scroll margin top for anchor tags to offset sticky header */
section[id] {
  scroll-margin-top: 90px;
}

/* Page Containers */
.container {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 var(--page-gutter);
}

/* Native app frame */
.grid-layout-container {
  border-top: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  background-color: var(--page-bg);
}

.grid-layout-container > .container {
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border-color);
  border-right: 1px solid var(--border-color);
  padding-left: var(--frame-gutter);
  padding-right: var(--frame-gutter);
  transition: padding var(--spring-duration) var(--spring-ease);
}

@media (max-width: 720px) {
  .grid-layout-container > .container {
    padding-left: 1.25rem;
    padding-right: 1.25rem;
  }
}

/* Sticky Navigation Bar */
.sticky-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background-color: var(--theme-surface);
  backdrop-filter: blur(24px) saturate(130%);
  border-bottom: 1px solid var(--border-color);
  transform: translateY(-100%);
  transition: transform 0.4s var(--spring-ease);
  box-shadow: var(--shadow-sm);
}

.sticky-nav.scrolled {
  transform: translateY(0);
}

.nav-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 64px;
}

.logo-group {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  color: var(--theme-text);
  font-family: var(--font-heading);
}

.app-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.app-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.nav-logo-text {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.nav-download-btn {
  padding: 8px 18px;
  font-size: 0.85rem;
}

.nav-menu {
  display: flex;
  gap: 28px;
  list-style: none;
}

.nav-menu a {
  color: var(--theme-muted);
  font-weight: 500;
  font-size: 0.9rem;
  transition: color 0.2s ease;
}

.nav-menu a:hover {
  color: var(--theme-text);
}

/* Theme Toggle Button */
.theme-toggle-btn {
  background: none;
  border: 1px solid var(--border-color);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--theme-muted);
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
  background-color: var(--theme-surface);
}

.theme-toggle-btn:hover {
  background-color: var(--theme-background);
  color: var(--theme-text);
  border-color: var(--theme-muted);
}

.theme-toggle-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.theme-toggle-btn .moon-icon {
  display: block;
}
.theme-toggle-btn .sun-icon {
  display: none;
}

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

/* Header & Inline Nav */
.header-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: clamp(1.75rem, 3vw, 2.5rem) 0 clamp(1.5rem, 3vw, 2rem);
  border-bottom: 1px solid var(--border-color);
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  color: var(--theme-text);
  font-family: var(--font-heading);
  font-size: 1.25rem;
}

/* Hero Section */
.hero {
  order: 1;
  padding: var(--hero-space-top) 0 var(--hero-space-bottom);
  text-align: center;
  position: relative;
  border-bottom: 1px solid var(--border-color);
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  background-color: var(--theme-surface);
  backdrop-filter: blur(18px) saturate(130%);
  border: 1px solid var(--border-color);
  padding: 0 12px;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--theme-muted);
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.hero-badge svg {
  width: 12px;
  height: 12px;
  fill: currentColor;
}

.hero-title {
  font-size: clamp(2.4rem, 4vw, 3.25rem);
  font-weight: 750;
  letter-spacing: -0.025em;
  max-width: 720px;
  margin: 0 auto 1rem;
  color: var(--heading-color);
  line-height: 1.08;
}

.hero-subtitle {
  font-size: clamp(1rem, 1.2vw, 1.12rem);
  color: var(--body-color);
  max-width: 620px;
  margin: 0 auto 1.5rem;
  line-height: 1.55;
}

.hero-actions {
  display: flex;
  justify-content: center;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}

/* Pill CTA Buttons */
.cta-btn-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--theme-text);
  color: var(--page-bg);
  font-weight: 650;
  font-size: 0.95rem;
  min-height: 42px;
  padding: 10px 22px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: background var(--spring-duration) var(--spring-push), transform var(--spring-duration) var(--spring-push), box-shadow var(--spring-duration) var(--spring-push);
}

.cta-btn-pill:hover {
  background: var(--theme-muted);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.cta-btn-pill:disabled {
  cursor: wait;
  opacity: 0.72;
}

.inline-waitlist-form {
  width: min(100%, 460px);
  min-height: 48px;
  margin: 0 auto;
  padding: 4px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--theme-line);
  border-radius: 999px;
  background: var(--theme-surface);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(20px) saturate(130%);
}

.inline-waitlist-input {
  min-width: 0;
  height: 40px;
  padding: 0 16px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--theme-text);
  font-family: var(--font-body);
  font-size: 0.95rem;
}

.inline-waitlist-input::placeholder {
  color: var(--theme-faint);
}

.inline-waitlist-input:focus {
  box-shadow: none;
}

.inline-waitlist-form:focus-within {
  border-color: var(--theme-accent);
  box-shadow: var(--shadow-sm), 0 0 0 3px var(--theme-accent-soft);
}

.inline-waitlist-submit {
  min-height: 40px;
  padding-inline: 18px;
  white-space: nowrap;
}

.inline-waitlist-status {
  min-height: 1.1rem;
  margin-top: 0.75rem;
  font-family: var(--font-ui);
  font-size: 0.82rem;
  line-height: 1.35;
  color: var(--theme-faint);
}

.inline-waitlist-status.is-success {
  color: #17823b;
}

.inline-waitlist-status.is-error {
  color: #d92d20;
}

@media (max-width: 380px) {
  .inline-waitlist-form {
    grid-template-columns: 1fr;
    border-radius: 18px;
    padding: 6px;
  }

  .inline-waitlist-submit {
    width: 100%;
  }
}

/* Shimmer reflection */
.cta-btn-pill::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -60%;
  width: 30%;
  height: 200%;
  background: linear-gradient(
    to right,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.15) 50%,
    rgba(255, 255, 255, 0) 100%
  );
  transform: rotate(25deg);
  animation: shimmer 5s infinite ease-in-out;
}

@keyframes shimmer {
  0% { left: -60%; }
  30% { left: 140%; }
  100% { left: 140%; }
}

.cta-btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--theme-surface);
  backdrop-filter: blur(18px) saturate(130%);
  color: var(--theme-text);
  font-weight: 600;
  font-size: 0.95rem;
  min-height: 42px;
  padding: 10px 22px;
  border-radius: 99px;
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.cta-btn-secondary:hover {
  background: var(--theme-background);
  border-color: var(--border-strong);
}

.cta-subtext {
  font-size: 0.78rem;
  color: var(--theme-faint);
  margin-top: 0.85rem;
}

/* macOS Menu Bar & Panel Container */
.mockup-section {
  order: 2;
  padding: clamp(2rem, 4vw, 3rem) 0 var(--section-space);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.mac-mockup-wrapper {
  width: 100%;
  max-width: 900px;
  position: relative;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.26), rgba(255, 255, 255, 0.02)),
    color-mix(in srgb, var(--theme-background) 88%, var(--theme-surface));
  border: 1px solid var(--border-color);
  border-radius: 18px;
  padding: 0 0 34px;
  box-shadow: var(--shadow-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: background-color var(--spring-duration) var(--spring-ease);
}

/* macOS Menu Bar */
.mac-menubar {
  width: 100%;
  height: 28px;
  background-color: rgba(250, 250, 248, 0.8);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 16px;
  font-family: var(--font-ui);
  font-size: 0.75rem;
  font-weight: 500;
  color: #111111;
  user-select: none;
  z-index: 10;
}

[data-theme="dark"] .mac-menubar {
  background-color: rgba(18, 18, 16, 0.8);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  color: #f5f5f0;
}

.menubar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.menubar-item {
  cursor: pointer;
  display: flex;
  align-items: center;
  height: 100%;
  padding: 0 4px;
}

.menubar-item.active-item {
  background-color: rgba(0, 0, 0, 0.05);
  border-radius: 4px;
  font-weight: 600;
}

[data-theme="dark"] .menubar-item.active-item {
  background-color: rgba(255, 255, 255, 0.08);
}

.menubar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* Diagram Popover Panel (520px x 500px matching real SwiftUI panelSize) */
.diagram-panel {
  width: 520px;
  height: 500px;
  margin-top: 24px;
  border-radius: 18px;
  background-color: var(--theme-panel-background);
  backdrop-filter: blur(30px) saturate(145%);
  border: 1px solid var(--theme-line-strong);
  box-shadow: 0 24px 58px rgba(0, 0, 0, 0.14), 0 8px 22px rgba(0, 0, 0, 0.07);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  transition: background-color var(--spring-duration) var(--spring-ease), border-color var(--spring-duration) var(--spring-ease), box-shadow var(--spring-duration) var(--spring-ease);
  z-index: 5;
}

/* Floating frosted header (swift: DiagramRootView.header over .regularMaterial) */
.panel-header {
  height: 56px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid color-mix(in srgb, var(--theme-line) 72%, transparent);
  background-color: var(--theme-header-background);
  backdrop-filter: blur(24px) saturate(150%);
  user-select: none;
  position: relative;
  z-index: 8;
  transition: background var(--spring-duration) var(--spring-ease);
}

/* Left: app badge (three-strip mark) + wordmark */
.panel-brand {
  display: flex;
  align-items: center;
  gap: 7px;
}

.panel-badge {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.panel-badge svg {
  width: 18px;
  height: 18px;
  fill: var(--theme-text);
}

.panel-wordmark {
  font-family: var(--font-ui);
  font-size: 0.9375rem; /* 15px */
  font-weight: 600;
  color: var(--theme-text);
  letter-spacing: -0.01em;
}

/* Right cluster of header controls */
.panel-header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Workspace pill (swift: ProjectDropdownLabel) — bordered, title + chevrons */
.panel-project-dropdown {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  height: 32px;
  padding: 0 9px 0 11px;
  border-radius: 12px;
  background: transparent;
  border: 1px solid var(--theme-line);
  transition: background-color 0.2s var(--spring-ease), border-color 0.2s var(--spring-ease);
}

.panel-project-dropdown:hover {
  background-color: var(--theme-surface-hover);
  border-color: var(--theme-line-strong);
}

.dropdown-title {
  font-family: var(--font-ui);
  font-size: 0.8125rem; /* 13px */
  font-weight: 600;
  color: var(--theme-text);
  line-height: 1.2;
  white-space: nowrap;
}

.dropdown-chevrons {
  width: 10px;
  height: 12px;
  fill: var(--theme-faint);
  flex-shrink: 0;
}

/* Grouping button (swift: groupingButton — icon only, thin stroke) */
.grouping-control-select {
  position: relative;
}

.grouping-btn {
  border: 1px solid color-mix(in srgb, var(--theme-line) 38%, transparent);
}

.grouping-btn:hover {
  border-color: var(--theme-line);
}

.grouping-icon {
  fill: var(--theme-muted);
  width: 14px;
  height: 14px;
}

.grouping-popover {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 6px;
  background-color: var(--theme-surface);
  border: 1px solid var(--theme-line-strong);
  border-radius: 10px;
  width: 140px;
  padding: 5px;
  box-shadow: var(--shadow-lg);
  display: none;
  flex-direction: column;
  gap: 2px;
  z-index: 50;
  backdrop-filter: blur(24px);
}

.grouping-popover.active {
  display: flex;
  animation: popoverFadeIn 0.2s var(--spring-ease) forwards;
}

@keyframes popoverFadeIn {
  from { opacity: 0; transform: translateY(-5px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.popover-section-title {
  font-family: var(--font-ui);
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--theme-faint);
  text-transform: uppercase;
  padding: 4px 8px;
  letter-spacing: 0.05em;
}

.popover-item {
  font-family: var(--font-ui);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--theme-muted);
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.popover-item:hover {
  background-color: var(--theme-glass-hover-tint);
  color: var(--theme-text);
}

.popover-item.active {
  background-color: var(--theme-accent-soft);
  color: var(--theme-accent);
  font-weight: 600;
}

.header-icons {
  display: flex;
  align-items: center;
}

.header-icon-btn {
  background: none;
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--theme-muted);
  transition: background-color 0.2s;
}

.header-icon-btn:hover {
  background-color: var(--theme-glass-hover-tint);
  color: var(--theme-text);
}

.header-icon-btn svg {
  width: 15px;
  height: 15px;
  fill: currentColor;
}

/* Panel Search Bar UI */
.panel-search-wrapper {
  display: none;
  padding: 10px 16px;
  background-color: var(--theme-header-background);
  border-bottom: 1px solid var(--theme-line);
  align-items: center;
}

.panel-search-wrapper.active {
  display: flex;
}

.panel-search-input {
  flex-grow: 1;
  background-color: var(--theme-background);
  border: 1px solid var(--theme-line);
  padding: 6px 12px;
  border-radius: 8px;
  font-family: var(--font-ui);
  font-size: 0.8rem;
  color: var(--theme-text);
  outline: none;
  transition: border-color 0.2s ease;
}

.panel-search-input:focus {
  border-color: var(--theme-accent);
}

/* Panel Workspace content */
.panel-workspace {
  flex-grow: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

/* ===========================================================================
   OVERVIEW — 2-column grid of self-naming boards (swift: MoodboardClusterGridCard)
   =========================================================================== */
.cluster-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
}

.cluster-card {
  background-color: var(--theme-surface);
  border: 1px solid var(--theme-line);
  border-radius: 12px;
  padding: 10px;
  min-width: 0;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--spring-duration) var(--spring-ease),
              background-color var(--spring-duration) var(--spring-ease),
              transform 0.2s var(--spring-ease);
}

.cluster-card:hover {
  background-color: var(--theme-surface-hover);
  border-color: var(--theme-line-strong);
  transform: translateY(-1px);
}

/* Staggered card entrance in scrollytelling mode */
.scrolly:not(.is-fallback) #scrollyPanel .state-clustered .cluster-card {
  opacity: 0;
  transform: scale(0.92) translateY(16px);
  transition: 
    opacity 0.65s var(--spring-push), 
    transform 0.65s var(--spring-push),
    border-color var(--spring-duration) var(--spring-ease),
    background-color var(--spring-duration) var(--spring-ease);
}

.scrolly:not(.is-fallback) #scrollyPanel.show-clustered .state-clustered .cluster-card {
  opacity: 1;
  transform: scale(1) translateY(0);
}

.scrolly:not(.is-fallback) #scrollyPanel.show-clustered .state-clustered .cluster-card:nth-child(1) { transition-delay: 0.04s; }
.scrolly:not(.is-fallback) #scrollyPanel.show-clustered .state-clustered .cluster-card:nth-child(2) { transition-delay: 0.09s; }
.scrolly:not(.is-fallback) #scrollyPanel.show-clustered .state-clustered .cluster-card:nth-child(3) { transition-delay: 0.14s; }
.scrolly:not(.is-fallback) #scrollyPanel.show-clustered .state-clustered .cluster-card:nth-child(4) { transition-delay: 0.19s; }

/* Staggered internal collage tile pop in scrollytelling mode */
.scrolly:not(.is-fallback) #scrollyPanel .cluster-card .collage-tile {
  opacity: 0;
  transform: scale(0.6) rotate(-8deg);
  transition: 
    opacity 0.5s var(--spring-push), 
    transform 0.5s var(--spring-push);
}

.scrolly:not(.is-fallback) #scrollyPanel.show-clustered .cluster-card .collage-tile {
  opacity: 1;
  transform: scale(1) rotate(0);
}

/* Stagger delays across cards so tiles pop in sequence after parent lands */
.scrolly:not(.is-fallback) #scrollyPanel.show-clustered .cluster-card:nth-child(1) .collage-tile:nth-child(1) { transition-delay: 0.15s; }
.scrolly:not(.is-fallback) #scrollyPanel.show-clustered .cluster-card:nth-child(1) .collage-tile:nth-child(2) { transition-delay: 0.20s; }
.scrolly:not(.is-fallback) #scrollyPanel.show-clustered .cluster-card:nth-child(1) .collage-tile:nth-child(3) { transition-delay: 0.25s; }
.scrolly:not(.is-fallback) #scrollyPanel.show-clustered .cluster-card:nth-child(1) .collage-tile:nth-child(4) { transition-delay: 0.30s; }

.scrolly:not(.is-fallback) #scrollyPanel.show-clustered .cluster-card:nth-child(2) .collage-tile:nth-child(1) { transition-delay: 0.20s; }
.scrolly:not(.is-fallback) #scrollyPanel.show-clustered .cluster-card:nth-child(2) .collage-tile:nth-child(2) { transition-delay: 0.25s; }
.scrolly:not(.is-fallback) #scrollyPanel.show-clustered .cluster-card:nth-child(2) .collage-tile:nth-child(3) { transition-delay: 0.30s; }
.scrolly:not(.is-fallback) #scrollyPanel.show-clustered .cluster-card:nth-child(2) .collage-tile:nth-child(4) { transition-delay: 0.35s; }

.scrolly:not(.is-fallback) #scrollyPanel.show-clustered .cluster-card:nth-child(3) .collage-tile:nth-child(1) { transition-delay: 0.25s; }
.scrolly:not(.is-fallback) #scrollyPanel.show-clustered .cluster-card:nth-child(3) .collage-tile:nth-child(2) { transition-delay: 0.30s; }
.scrolly:not(.is-fallback) #scrollyPanel.show-clustered .cluster-card:nth-child(3) .collage-tile:nth-child(3) { transition-delay: 0.35s; }
.scrolly:not(.is-fallback) #scrollyPanel.show-clustered .cluster-card:nth-child(3) .collage-tile:nth-child(4) { transition-delay: 0.40s; }

.scrolly:not(.is-fallback) #scrollyPanel.show-clustered .cluster-card:nth-child(4) .collage-tile:nth-child(1) { transition-delay: 0.30s; }
.scrolly:not(.is-fallback) #scrollyPanel.show-clustered .cluster-card:nth-child(4) .collage-tile:nth-child(2) { transition-delay: 0.35s; }
.scrolly:not(.is-fallback) #scrollyPanel.show-clustered .cluster-card:nth-child(4) .collage-tile:nth-child(3) { transition-delay: 0.40s; }
.scrolly:not(.is-fallback) #scrollyPanel.show-clustered .cluster-card:nth-child(4) .collage-tile:nth-child(4) { transition-delay: 0.45s; }

/* 2×2 thumbnail collage */
.collage {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: color-mix(in srgb, var(--theme-text) 3%, transparent);
  border-radius: 10px;
  padding: 0;
}

.collage-tile {
  height: 49px;
  border-radius: 6px;
  overflow: hidden;
  position: relative;
  background-color: var(--theme-surface-hover);
}

.collage-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transform: scale(1.14); /* Zoom in to crop out shadow margins */
}

.collage-tile.empty {
  background: color-mix(in srgb, var(--theme-text) 4%, transparent);
  border: 1px solid color-mix(in srgb, var(--theme-line) 70%, transparent);
}

.cluster-card-title {
  font-family: var(--font-ui);
  font-size: 0.8125rem; /* 13px */
  font-weight: 600;
  color: var(--theme-text);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cluster-card-count {
  font-family: var(--font-ui);
  font-size: 0.625rem; /* 10px */
  font-weight: 500;
  color: var(--theme-faint);
  margin-top: -7px;
}

/* ---- Source-art placeholder tile (swift: SourceIconArtwork) -------------- */
.source-art {
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 1px solid var(--theme-line);
  border-radius: inherit;
}

.source-art::after { /* top-left sheen */
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(60px 60px at top left, rgba(255,255,255,0.26), transparent 70%);
  pointer-events: none;
}

.art-figma { background: linear-gradient(135deg, rgba(168,85,247,0.18), rgba(168,85,247,0.42)); }
.art-file  { background: linear-gradient(135deg, rgba(10,148,245,0.16), rgba(10,148,245,0.36)); }
.art-link  { background: linear-gradient(135deg, rgba(34,197,94,0.16), rgba(34,197,94,0.36)); }
.art-dribbble { background: linear-gradient(135deg, #2e0854, #0c021a); }
.art-article    { background: linear-gradient(135deg, rgba(239,68,68,0.16), rgba(239,68,68,0.36)); } /* Coral */
.art-typography { background: linear-gradient(135deg, rgba(99,102,241,0.16), rgba(99,102,241,0.36)); } /* Indigo */
.art-tool       { background: linear-gradient(135deg, rgba(234,179,8,0.16), rgba(234,179,8,0.36)); } /* Yellow/Amber */

.src-glyph {
  width: 40%;
  height: 40%;
  max-width: 18px;
  max-height: 18px;
  fill: color-mix(in srgb, var(--theme-text) 86%, transparent);
  z-index: 1;
}

.art-dribbble .src-glyph { fill: rgba(255,255,255,0.9); }

.src-mono {
  font-family: var(--font-ui);
  font-size: 0.5rem;
  font-weight: 800;
  color: var(--theme-muted);
  z-index: 1;
  line-height: 1;
}

.art-dribbble .src-mono { color: rgba(255,255,255,0.7); }

.source-art.sm .src-mono { font-size: 0.4375rem; }

/* ===========================================================================
   RECENT ADDITIONS RAIL (swift: DiagramRow under "Recent additions")
   =========================================================================== */
.recent-section {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: opacity 0.45s var(--spring-ease), transform 0.45s var(--spring-ease);
}

.recent-section.coalescing {
  opacity: 0;
  transform: translateY(8px) scale(0.98);
}

.recent-label {
  font-family: var(--font-ui);
  font-size: 0.75rem; /* 12px */
  font-weight: 600;
  color: var(--theme-muted);
}

.recent-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.panel-row {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 80px;
  background-color: var(--theme-surface);
  border: 1px solid var(--theme-line);
  border-radius: 16px;
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  animation: rowIn 0.35s var(--spring-ease) both;
  cursor: pointer;
  transition: background-color var(--spring-duration) var(--spring-ease),
              border-color var(--spring-duration) var(--spring-ease),
              transform var(--spring-duration) var(--spring-ease),
              box-shadow var(--spring-duration) var(--spring-ease);
}

.panel-row:hover {
  background-color: var(--theme-surface-hover);
  border-color: var(--theme-line-strong);
  transform: translateY(-1px) scale(1.005);
  box-shadow: var(--shadow-md);
}

.panel-row:active {
  transform: translateY(0) scale(0.995);
  box-shadow: var(--shadow-sm);
  background-color: color-mix(in srgb, var(--theme-surface-hover) 95%, var(--theme-accent-soft));
}

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


.row-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  overflow: hidden;
  flex-shrink: 0;
  position: relative;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
  border: 1px solid var(--theme-line);
  box-sizing: border-box;
}

.row-icon::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: inherit;
  pointer-events: none;
  mix-blend-mode: overlay;
  box-sizing: border-box;
}

.row-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.row-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 1px;
  margin-bottom: 2px;
}

.row-dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--theme-line-strong);
}

.row-title {
  font-family: var(--font-ui);
  font-size: 0.90625rem; /* 14.5px */
  font-weight: 600;
  color: var(--theme-text);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-desc {
  font-family: var(--font-ui);
  font-size: 0.8125rem; /* 13px */
  color: var(--theme-muted);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===========================================================================
   GRID CARD (swift: DiagramGridCard) — full-bleed thumb, source·type, title…
   =========================================================================== */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.panel-card.grid-card {
  background-color: var(--theme-surface);
  border: 1px solid var(--theme-line);
  border-radius: 16px;
  padding: 0;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  position: relative;
  box-shadow: var(--shadow-sm);
  transition: background-color var(--spring-duration) var(--spring-ease),
              border-color var(--spring-duration) var(--spring-ease),
              transform 0.2s var(--spring-ease);
  animation: rowIn 0.35s var(--spring-ease) both;
}

.panel-card.grid-card:hover {
  background-color: var(--theme-surface-hover);
  border-color: var(--theme-line-strong);
  transform: translateY(-1px);
}

.grid-card-thumb {
  padding: 10px 10px 0;
}

.grid-card-thumb .card-visual-thumbnail {
  height: 150px;
  margin: 0;
  border-radius: 12px;
}

.grid-card-meta {
  padding: 8px 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.meta-row {
  display: flex;
  align-items: center;
  gap: 5px;
}

.meta-source {
  font-family: var(--font-ui);
  font-size: 0.6875rem; /* 11px */
  font-weight: 500;
  color: var(--theme-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 0 1 auto;
  min-width: 0;
}

.type-chip {
  font-family: var(--font-ui);
  font-size: 0.5625rem; /* 9px */
  font-weight: 700;
  color: var(--theme-muted);
  background: color-mix(in srgb, var(--theme-text) 7%, transparent);
  padding: 2px 5px;
  border-radius: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}

.meta-title {
  font-family: var(--font-ui);
  font-size: 0.8125rem; /* 13px */
  font-weight: 600;
  color: var(--theme-text);
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.meta-desc {
  font-family: var(--font-ui);
  font-size: 0.71875rem; /* 11.5px */
  color: var(--theme-faint);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tag-row {
  display: flex;
  gap: 4px;
  margin-top: 2px;
  overflow: hidden;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 6px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--theme-text) 5%, transparent);
  font-family: var(--font-ui);
  font-size: 0.59375rem; /* 9.5px */
  font-weight: 600;
  color: var(--theme-muted);
  white-space: nowrap;
}

.tag-hash {
  font-weight: 700;
  color: color-mix(in srgb, var(--theme-accent) 68%, transparent);
  margin-right: 3px;
}



/* Concept-search results */
.search-label {
  font-family: var(--font-ui);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--theme-faint);
  margin-bottom: 12px;
}

.grid-card.search-hit {
  border-color: color-mix(in srgb, var(--theme-accent) 55%, transparent);
  box-shadow: 0 0 0 3px var(--theme-accent-soft);
}

.empty-search {
  font-family: var(--font-ui);
  font-size: 0.8125rem;
  color: var(--theme-muted);
  text-align: center;
  padding: 40px 16px;
}

/* Detail slide-in view inside panel popover */
.panel-detail-view {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--theme-panel-background);
  backdrop-filter: blur(24px) saturate(150%);
  z-index: 12;
  transform: translateX(100%);
  transition: transform var(--spring-duration) var(--spring-ease);
  display: flex;
  flex-direction: column;
}

.panel-detail-view.active {
  transform: translateX(0);
}

.detail-header {
  height: 44px;
  border-bottom: 1px solid var(--theme-line);
  background-color: var(--theme-header-background);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
}

.detail-back-btn {
  background: none;
  border: none;
  color: var(--theme-accent);
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}

.detail-back-btn svg {
  width: 12px;
  height: 12px;
  fill: currentColor;
}

.detail-title {
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--theme-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-grow: 1;
}

.detail-workspace {
  flex-grow: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.similarity-card {
  position: relative;
}

.similarity-badge {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 2;
  background-color: rgba(39, 201, 63, 0.14);
  color: #27c93f;
  font-family: var(--font-ui);
  font-size: 0.625rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 5px;
}

/* Toast Notifications Inside Panel */
.panel-toast {
  position: absolute;
  top: 64px;
  left: 50%;
  transform: translate(-50%, -20px);
  z-index: 15;
  background-color: var(--theme-surface);
  border: 1px solid var(--theme-line-strong);
  border-radius: 20px;
  padding: 6px 14px;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: 6px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--spring-duration) var(--spring-push), transform var(--spring-duration) var(--spring-push);
}

.panel-toast.active {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast-icon {
  color: #27c93f;
  font-weight: 700;
  font-size: 0.9rem;
}

.toast-text {
  font-family: var(--font-ui);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--theme-text);
}

/* Drop Target overlay inside panel */
.panel-dropzone-overlay {
  position: absolute;
  top: 54px;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 12;
  background-color: rgba(250, 250, 248, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

[data-theme="dark"] .panel-dropzone-overlay {
  background-color: rgba(18, 18, 16, 0.85);
}

.panel-dropzone-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.dropzone-border-box {
  width: calc(100% - 32px);
  height: calc(100% - 32px);
  border: 1.5px dashed var(--theme-accent);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.dropzone-icon {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background-color: var(--theme-accent-soft);
  color: var(--theme-accent);
  display: flex;
  align-items: center;
  justify-content: center;
}

.dropzone-icon svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

/* Simulation Control Panel */
.simulation-controls-box {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.simulation-instructions {
  font-size: 0.8rem;
  color: var(--theme-faint);
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.simulation-steps-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.simulation-step-btn {
  background-color: var(--theme-surface);
  backdrop-filter: blur(18px) saturate(130%);
  border: 1px solid var(--theme-line);
  color: var(--theme-muted);
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 600;
  min-height: 40px;
  padding: 8px 16px;
  border-radius: 99px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background-color var(--spring-duration) var(--spring-ease), border-color var(--spring-duration) var(--spring-ease), color var(--spring-duration) var(--spring-ease), box-shadow var(--spring-duration) var(--spring-ease);
  box-shadow: var(--shadow-sm);
}

.simulation-step-btn:hover {
  background-color: var(--theme-background);
  border-color: var(--theme-line-strong);
  color: var(--theme-text);
}

.simulation-step-btn.completed {
  border-color: #27c93f;
  color: #27c93f;
  background-color: rgba(39, 201, 63, 0.05);
}

.simulation-step-btn.active-step {
  border-color: var(--theme-accent);
  color: var(--theme-accent);
  background-color: var(--theme-accent-soft);
  box-shadow: 0 0 0 2px var(--theme-accent-soft);
}

.sim-btn-num {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background-color: var(--theme-text);
  color: var(--page-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
}

.simulation-step-btn.active-step .sim-btn-num {
  background-color: var(--theme-accent);
}

/* Storytelling Flow Sections */
.story-section {
  padding: var(--section-space) 0;
  border-top: 1px solid var(--border-color);
  background-color: var(--page-bg);
  transition: background-color var(--spring-duration) var(--spring-ease), border-color var(--spring-duration) var(--spring-ease);
}

#differentiators {
  order: 4;
}

.story-section.alt-bg {
  background-color: var(--theme-background);
}

.story-number {
  font-family: var(--font-heading);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--theme-accent);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  display: inline-block;
  margin-bottom: 0.5rem;
  opacity: 0.9;
}

.story-feature-row {
  display: flex;
  align-items: center;
  gap: clamp(2.5rem, 6vw, 4rem);
}

.story-feature-row.reverse {
  flex-direction: row-reverse;
}

.story-feature-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.story-feature-info h2 {
  font-size: clamp(1.55rem, 2.4vw, 1.85rem);
  letter-spacing: -0.027em;
  font-family: var(--font-heading);
  color: var(--heading-color);
  font-weight: 700;
  line-height: 1.15;
}

.story-feature-info p {
  font-size: 1rem;
  color: var(--body-color);
  line-height: 1.6;
  max-width: 58ch;
}

.story-feature-graphic {
  flex: 1;
  background-color: var(--theme-surface);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: clamp(1.5rem, 3vw, 2rem);
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(18px) saturate(130%);
  transition: background-color var(--spring-duration) var(--spring-ease), border-color var(--spring-duration) var(--spring-ease);
}

[data-theme="dark"] .story-feature-graphic {
  background-color: var(--theme-panel-background);
}

/* SVG Graphic Styling */
.flow-graphic-svg {
  width: 100%;
  max-width: 320px;
  height: auto;
}

.flow-graphic-svg text {
  font-family: var(--font-ui);
  fill: var(--theme-text);
}

.flow-graphic-svg rect, .flow-graphic-svg circle {
  transition: fill 0.3s, stroke 0.3s;
}

/* Email Signup/Download Modal Overlay */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 200;
  background-color: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.modal-box {
  background-color: var(--theme-surface);
  backdrop-filter: blur(30px);
  border: 1px solid var(--theme-line-strong);
  border-radius: 18px;
  padding: 32px;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px) scale(0.95);
  transition: transform var(--spring-duration) var(--spring-push);
  position: relative;
  text-align: center;
}

.modal-overlay.active .modal-box {
  transform: translateY(0) scale(1);
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: var(--theme-surface);
  border: 1px solid var(--theme-line);
  cursor: pointer;
  color: var(--theme-muted);
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(18px) saturate(130%);
  transition:
    background-color 0.2s var(--spring-ease),
    border-color 0.2s var(--spring-ease),
    color 0.2s var(--spring-ease),
    transform 0.2s var(--spring-ease);
}

.modal-close:hover {
  background-color: var(--theme-surface-hover);
  border-color: var(--theme-line-strong);
  color: var(--theme-text);
}

.modal-close:active {
  transform: scale(0.96);
}

.modal-close svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.modal-brand-lockup {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 1.5rem;
}

.modal-brand-lockup img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.09));
  border-radius: 11px;
}

.modal-brand-name {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  font-weight: 750;
  color: var(--heading-color);
  letter-spacing: -0.025em;
}

.modal-title {
  font-size: 1.5rem;
  margin-bottom: 0.75rem;
  letter-spacing: -0.02em;
}

.modal-subtitle {
  font-size: 0.9rem;
  color: var(--theme-muted);
  margin-bottom: 2rem;
  line-height: 1.55;
}

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-hp {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.modal-input {
  width: 100%;
  padding: 12px 16px;
  border-radius: 8px;
  border: 1px solid var(--theme-line);
  background-color: var(--theme-background);
  color: var(--theme-text);
  font-family: var(--font-body);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.modal-input:focus {
  border-color: var(--theme-accent);
  box-shadow: 0 0 0 3px var(--theme-accent-soft);
}

.modal-submit {
  width: 100%;
  background-color: var(--theme-text);
  color: var(--page-bg);
  border: none;
  padding: 12px;
  border-radius: 8px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.1s ease;
}

.modal-submit:hover {
  background-color: var(--theme-muted);
}

.modal-submit:disabled {
  cursor: wait;
  opacity: 0.72;
}

.modal-submit:active {
  transform: translateY(1px);
}

.modal-error {
  min-height: 1.1rem;
  color: #d92d20;
  font-family: var(--font-ui);
  font-size: 0.78rem;
  line-height: 1.35;
}

/* Success State in Modal */
.modal-success {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.modal-success.active {
  display: flex;
}

.success-checkmark {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background-color: rgba(39, 201, 63, 0.1);
  color: #27c93f;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.5rem;
  font-size: 1.8rem;
}

/* Footer Section */
.footer {
  padding: 4rem 0;
  border-top: 1px solid var(--border-color);
  transition: border-color var(--spring-duration) var(--spring-ease);
}

.footer-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.footer-copyright {
  font-size: 0.85rem;
  color: var(--theme-faint);
}

.footer-actions {
  display: flex;
  align-items: center;
  gap: 20px;
}

.footer-actions a {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--theme-muted);
}

.footer-actions a:hover {
  color: var(--theme-text);
}

/* Honor accessibility screen motion reduction */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001s !important;
    scroll-behavior: auto !important;
  }
}

/* Responsive adjustments */
@media (max-width: 900px) {
  .story-feature-row, .story-feature-row.reverse {
    flex-direction: column;
    gap: 32px;
  }
  .story-feature-graphic {
    width: 100%;
  }
}

@media (max-width: 720px) {
  .hero-title {
    font-size: 2.28rem;
  }
  .hero-subtitle {
    line-height: 1.55;
  }
  .hero-actions {
    align-items: stretch;
  }
  .hero-actions .cta-btn-pill,
  .hero-actions .cta-btn-secondary {
    width: min(100%, 320px);
  }
  .nav-menu {
    display: none;
  }
  .footer-container {
    flex-direction: column;
    gap: 20px;
    text-align: center;
  }
}

@media (max-width: 560px) {
  .header-nav {
    padding-top: 1.5rem;
  }
  .hero {
    padding-top: 3.25rem;
    padding-bottom: 4rem;
  }
  .hero-title {
    font-size: 2.35rem;
  }
  .hero-subtitle {
    font-size: 1rem;
  }
  .diagram-panel {
    width: 100%;
    max-width: calc(100vw - 32px);
    height: 480px;
  }
  .panel-header {
    padding: 0 10px;
  }
  .panel-project-dropdown {
    max-width: 132px;
    padding-inline: 6px;
  }
  .dropdown-title,
  .dropdown-subtitle {
    max-width: 104px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  #groupingLabelText {
    display: none;
  }
  #groupingLabelBtn {
    width: 34px;
    height: 28px;
    justify-content: center;
    padding: 0;
  }
  #groupingLabelBtn svg:last-child {
    display: none;
  }
  .menubar-left .menubar-item:not(.active-item) {
    display: none;
  }
}

/* Card Visual Thumbnails Styles */
.card-visual-thumbnail {
  width: 100%;
  height: 110px;
  border-radius: 8px;
  position: relative;
  overflow: hidden;
  margin-bottom: 8px;
  border: 1px solid var(--theme-line);
  display: flex;
  transition: border-color var(--spring-duration) var(--spring-ease);
}

.figma-thumb, .dribbble-thumb, .screenshot-thumb, .article-thumb, .typography-thumb, .colors-thumb {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border: 1px solid var(--border-color);
}

.mini-phone-content {
  padding: 12px 6px 6px 6px;
  display: flex;
  flex-direction: column;
  height: 100%;
  justify-content: center;
}

.mini-phone-card {
  background: rgba(0, 0, 0, 0.05);
  transition: background-color var(--spring-duration) var(--spring-ease);
}

[data-theme="dark"] .mini-phone-card {
  background: rgba(255, 255, 255, 0.08);
}

/* Scroll Linked Text Highlighting */
.story-section .highlight-target {
  opacity: 0.48;
  transition: opacity 0.5s var(--spring-ease), color 0.5s var(--spring-ease);
}

.story-section .highlight-target.highlight-active {
  opacity: 1;
}

[data-theme="dark"] .story-section .highlight-target {
  opacity: 0.52;
}

[data-theme="dark"] .story-section .highlight-target.highlight-active {
  opacity: 1;
}

/* Masonry Moodboard Section Styles */
.masonry-moodboard-section {
  order: 3;
  padding: var(--section-space-tight) 0;
  border-bottom: 1px solid var(--border-color);
  width: 100%;
}

.moodboard-kicker {
  display: block;
  text-align: center;
  margin-bottom: 2rem;
}

.masonry-grid {
  columns: 3;
  column-gap: 24px;
  width: 100%;
}

.masonry-item {
  break-inside: avoid;
  margin-bottom: 24px;
  border-radius: 16px;
  border: 1px solid var(--border-color);
  background-color: var(--theme-surface);
  backdrop-filter: blur(18px) saturate(130%);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.3s var(--spring-ease), box-shadow 0.3s var(--spring-ease), border-color var(--spring-duration) var(--spring-ease);
}

.masonry-item:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}

.masonry-item.height-short {
  min-height: 140px;
}

.masonry-item.height-medium {
  min-height: 200px;
}

.masonry-item.height-tall {
  min-height: 280px;
}

.card-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  justify-content: space-between;
  gap: 16px;
}

.card-tag {
  align-self: flex-start;
  font-family: var(--font-ui);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 8px;
  border-radius: 99px;
  background-color: var(--theme-background);
  color: var(--theme-muted);
}

@media (max-width: 900px) {
  .masonry-grid {
    columns: 2;
  }
}

@media (max-width: 720px) {
  .masonry-moodboard-section {
    padding: 3.75rem 0;
  }
}

@media (max-width: 560px) {
  .masonry-grid {
    columns: 1;
  }
}

/* ===========================================================================
   SCROLLYTELLING HERO — pinned, scroll-scrubbed (Act 0→3)
   =========================================================================== */
:root { --scroll-vh: 440; }

.scrolly {
  position: relative;
}

.scrolly-track {
  position: relative;
  height: calc(var(--scroll-vh) * 1vh);
}

.scrolly-stage {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
  background:
    radial-gradient(at 20% 20%, var(--mesh-color-3) 0px, transparent 50%),
    radial-gradient(at 80% 10%, var(--mesh-color-1) 0px, transparent 50%),
    radial-gradient(at 15% 80%, var(--mesh-color-2) 0px, transparent 50%),
    radial-gradient(at 85% 85%, var(--mesh-color-4) 0px, transparent 50%),
    var(--page-bg);
}

/* LAYER 1 — scattered inspiration field */
.scrolly-field {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.insp-tile {
  position: absolute;
  left: 50%;
  top: 50%;
  border-radius: 14px;
  overflow: hidden;
  opacity: 0;
  box-shadow: var(--shadow-lg);
  backface-visibility: hidden;
  transform: translate(-50%, -50%);
  background-color: var(--theme-surface);
  border: 1px solid var(--theme-line-strong);
}

.insp-tile-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  display: block;
  border-radius: 0;
}

.row-thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  display: block;
  border-radius: inherit;
  transform: scale(1.18); /* Zoom in to crop out macOS window shadow padding */
}

/* promote compositor layers only while the stage is on screen */
.scrolly.in-view .insp-tile,
.scrolly.in-view .scrolly-panel-layer .diagram-panel {
  will-change: transform, opacity;
}

/* LAYER 2 — the Diagram panel the references drop into */
.scrolly-panel-layer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  top: max(250px, calc(50% - 125px));
  z-index: 3;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  pointer-events: none;
}

.scrolly-panel-layer .diagram-panel {
  height: min(390px, 48vh);
  opacity: 0;
  transform: scale(0.86);
  transform-origin: center center;
  pointer-events: auto;
}

#scrollyPanel .panel-workspace {
  overflow: hidden;
  position: relative;
}

#scrollyPanel .panel-workspace::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 72px;
  background: linear-gradient(to bottom, transparent, var(--theme-panel-background));
  pointer-events: none;
  z-index: 10;
}

/* Floating Glassmorphic Analyzing Toast */
.panel-analysis-toast {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  background-color: var(--theme-toast-background);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--theme-toast-border);
  border-radius: 16px;
  padding: 12px 16px;
  width: calc(100% - 32px);
  max-width: 280px;
  box-shadow: 
    0 10px 30px rgba(0, 0, 0, 0.08), 
    0 1px 3px rgba(0, 0, 0, 0.02),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 20;
  transition: transform 0.4s var(--spring-ease), opacity 0.4s var(--spring-ease);
  box-sizing: border-box;
  overflow: hidden;
}

/* Toast Visibility Trigger */
#scrollyPanel.show-analyzing:not(.tags-in) .panel-analysis-toast {
  opacity: 1;
  transform: translate(-50%, 0);
  pointer-events: auto;
}

/* Spinner */
.toast-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--theme-toast-progress-track);
  border-top-color: var(--theme-accent);
  border-radius: 50%;
  animation: toastSpinnerSpin 0.8s linear infinite;
  flex-shrink: 0;
}

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

/* Text Container */
.toast-text-container {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  gap: 2px;
  min-width: 0;
}

.toast-title {
  font-size: 0.80rem;
  font-weight: 600;
  color: var(--theme-text);
  line-height: 1.2;
}

.toast-subtitle {
  font-size: 0.70rem;
  color: var(--theme-muted);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Micro progress bar along bottom edge of toast */
.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background-color: var(--theme-toast-progress-track);
}

.toast-progress-fill {
  height: 100%;
  width: 0%;
  background-color: var(--theme-accent);
  transition: width 0.1s ease-out;
}

/* Panel content states stacked + crossfaded by act class on #scrollyPanel */
#scrollyPanelContent {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
}

.panel-state {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s var(--spring-ease);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.state-clustered { display: block; }

#scrollyPanel.show-rows .state-rows { opacity: 1; pointer-events: auto; }
#scrollyPanel.show-clustered .state-clustered { opacity: 1; pointer-events: auto; }

/* Clean overrides for landing page panel rows to fit comfortably */
#scrollyPanel .panel-row {
  min-height: auto; /* Hug contents naturally */
  flex-shrink: 0; /* Prevent the browser from squishing the rows inside the constrained panel height */
  padding: 12px; /* Balanced padding hugging the contents */
  border-radius: 14px;
  gap: 14px; /* Balanced spacing between icon and text */
  align-items: flex-start; /* Anchor thumbnail to the top baseline */
  animation: none; /* Disable default load animation */
}
#scrollyPanel .row-body {
  gap: 5px; /* Comfortable breathing room between text lines */
}
/* Act 1 rows hide by default until staggered entry triggers */
#scrollyPanel .state-rows .panel-row {
  opacity: 0;
  transform: translateY(10px); /* Pre-offset for smooth slide-up */
}
#scrollyPanel .row-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  margin-top: 1.5px; /* Align icon top edge to text cap-height baseline */
}
#scrollyPanel .src-mono {
  font-size: 0.58rem;
}
#scrollyPanel .panel-state {
  gap: 8px;
}

#scrollyPanel .row-title {
  font-size: 0.844rem; /* ~13.5px */
  letter-spacing: -0.008em;
  line-height: 1.15;
}
#scrollyPanel .meta-source {
  font-size: 0.6875rem; /* ~11px */
}
#scrollyPanel .row-desc {
  font-size: 0.75rem; /* ~12px */
  line-height: 1.2;
}

/* Staggered row entry animations triggered on active scroll state */
#scrollyPanel.trigger-rows-entry .state-rows .panel-row {
  animation: rowIn 0.55s var(--spring-push) both;
}
#scrollyPanel.trigger-rows-entry .state-rows .panel-row:nth-child(1) { animation-delay: 0.03s; }
#scrollyPanel.trigger-rows-entry .state-rows .panel-row:nth-child(2) { animation-delay: 0.06s; }
#scrollyPanel.trigger-rows-entry .state-rows .panel-row:nth-child(3) { animation-delay: 0.09s; }
#scrollyPanel.trigger-rows-entry .state-rows .panel-row:nth-child(4) { animation-delay: 0.12s; }
#scrollyPanel.trigger-rows-entry .state-rows .panel-row:nth-child(5) { animation-delay: 0.15s; }
#scrollyPanel.trigger-rows-entry .state-rows .panel-row:nth-child(6) { animation-delay: 0.18s; }

#scrollyPanel.show-analyzing .state-rows .panel-row {
  opacity: 1;
  transform: none;
}


/* Active dropzone placeholder with animated marching ants border */
.panel-drop-placeholder {
  position: absolute;
  inset: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  background-color: color-mix(in srgb, var(--theme-surface) 20%, transparent);
  transition: opacity 0.35s var(--spring-ease), transform 0.35s var(--spring-ease);
  pointer-events: none;
  z-index: 2;
  box-sizing: border-box;

  /* Marching Ants using linear gradients */
  background-image: 
    linear-gradient(90deg, var(--theme-line-strong) 50%, transparent 50%),
    linear-gradient(90deg, var(--theme-line-strong) 50%, transparent 50%),
    linear-gradient(0deg, var(--theme-line-strong) 50%, transparent 50%),
    linear-gradient(0deg, var(--theme-line-strong) 50%, transparent 50%);
  background-repeat: repeat-x, repeat-x, repeat-y, repeat-y;
  background-size: 10px 1.5px, 10px 1.5px, 1.5px 10px, 1.5px 10px;
  background-position: 0px 0px, 0px 100%, 0px 0px, 100% 0px;
  animation: marchingAnts 0.6s linear infinite;
}

#scrollyPanel.hide-placeholder .state-rows .panel-drop-placeholder {
  opacity: 0;
  transform: scale(0.96);
}

.drop-icon-box {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: var(--theme-accent-soft);
  color: var(--theme-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
  box-shadow: 0 2px 8px rgba(10, 148, 245, 0.12);
  box-sizing: border-box;
}

.drop-icon-box svg {
  width: 20px;
  height: 20px;
  animation: bounceArrow 1.2s ease-in-out infinite;
}

.drop-title {
  font-family: var(--font-ui);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--theme-text);
  margin-bottom: 4px;
  letter-spacing: -0.01em;
}

.drop-subtitle {
  font-family: var(--font-ui);
  font-size: 0.72rem;
  color: var(--theme-muted);
  text-align: center;
  padding: 0 16px;
  line-height: 1.3;
}

@keyframes marchingAnts {
  0% {
    background-position: 
      0px 0px, 
      0px 100%, 
      0px 0px, 
      100% 0px;
  }
  100% {
    background-position: 
      10px 0px, 
      -10px 100%, 
      0px -10px, 
      100% 10px;
  }
}

@keyframes bounceArrow {
  0%, 100% { transform: translateY(-2px); }
  50%      { transform: translateY(2px); }
}




/* Details stack grid overlay to prevent layout jump when tags slide in */
.row-details-stack {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
  min-height: 18px;
  align-items: center;
}
.row-details-stack .row-desc,
.row-details-stack .row-tags {
  grid-area: 1 / 1 / 2 / 2;
  transition: opacity 0.35s var(--spring-ease), transform 0.35s var(--spring-ease);
}
/* Default visible in Act 1: description is shown, tags are hidden */
.row-details-stack .row-desc {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}
.row-details-stack .row-tags {
  display: flex;
  gap: 4px;
  margin-top: 0;
  opacity: 0;
  transform: translateY(4px);
  pointer-events: none;
}

/* Act 2 finishes: tags pop in, description slides out, tags slide in */
#scrollyPanel.tags-in .row-details-stack .row-desc {
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
}
#scrollyPanel.tags-in .row-details-stack .row-tags {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}


/* LAYER 3 — captions + CTA */
.scrolly-captions {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}

.scrolly-cap {
  position: absolute;
  left: 50%;
  width: min(90vw, 720px);
  transform: translateX(-50%) translateY(8px);
  text-align: center;
  opacity: 0;
  transition: opacity 0.55s var(--spring-ease), transform 0.55s var(--spring-ease);
}

.scrolly-cap.is-active {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Act 0 and 4 sit centered & large over the field; other acts pin to top */
.scrolly-cap[data-act="0"],
.scrolly-cap[data-act="4"] {
  top: 50%;
  transform: translate(-50%, calc(-50% + 8px));
}
.scrolly-cap[data-act="0"].is-active,
.scrolly-cap[data-act="4"].is-active {
  transform: translate(-50%, -50%);
}
.scrolly-cap[data-act="1"],
.scrolly-cap[data-act="2"],
.scrolly-cap[data-act="3"] {
  top: max(80px, calc(50% - 270px));
}

.scrolly-kicker {
  display: inline-block;
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--theme-accent);
  margin-bottom: 0.75rem;
}

.scrolly-logo-badge {
  position: absolute;
  left: 50%;
  top: calc(50% - 150px);
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  z-index: 5;
  transition: top 0.6s var(--spring-ease), transform 0.6s var(--spring-ease), opacity 0.5s var(--spring-ease);
}

.scrolly-logo-badge img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.09));
  border-radius: 10px;
}

.scrolly-logo-text {
  font-family: var(--font-heading);
  font-size: 1.45rem;
  font-weight: 750;
  color: var(--heading-color);
  letter-spacing: -0.025em;
}

/* Acts 1, 2, 3, and 4: slide brand header to the top */
.scrolly-stage[data-act="1"] .scrolly-logo-badge,
.scrolly-stage[data-act="2"] .scrolly-logo-badge,
.scrolly-stage[data-act="3"] .scrolly-logo-badge,
.scrolly-stage[data-act="4"] .scrolly-logo-badge {
  top: max(20px, calc(50% - 330px));
  transform: translate(-50%, 0);
}

/* Fade out the logo badge in Act 4 to avoid duplication with the container app icon */
.scrolly-stage[data-act="4"] .scrolly-logo-badge {
  opacity: 0;
  pointer-events: none;
}

.scrolly-head {
  font-family: var(--font-heading);
  font-weight: 750;
  letter-spacing: -0.025em;
  line-height: 1.04;
  color: var(--heading-color);
  margin: 0;
  font-size: clamp(2.1rem, 5.2vw, 3.6rem);
}

.scrolly-cap[data-act="0"] .scrolly-head { font-size: clamp(2.6rem, 6.4vw, 4.6rem); }

.scrolly-sub {
  font-family: var(--font-body);
  font-size: clamp(1rem, 1.4vw, 1.18rem);
  line-height: 1.5;
  color: var(--theme-muted);
  max-width: 540px;
  margin: 0.9rem auto 0;
}

.scrolly-cta {
  margin-top: 1.5rem;
  pointer-events: auto;
}
.scrolly-cta .cta-subtext { margin-top: 0.7rem; }

/* progress bar + scroll cue */
.scrolly-progress {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 3px;
  z-index: 4;
  background: color-mix(in srgb, var(--theme-line) 60%, transparent);
  transition: opacity 0.5s var(--spring-ease);
}

/* Fade out progress bar in Act 4 */
.scrolly-stage[data-act="4"] .scrolly-progress {
  opacity: 0;
  pointer-events: none;
}

.scrolly-progress span {
  display: block;
  height: 100%;
  width: 100%;
  transform: scaleX(0);
  transform-origin: left center;
  background: linear-gradient(90deg, var(--theme-accent), color-mix(in srgb, var(--theme-accent) 55%, #a855f7));
}

.scrolly-scrollcue {
  position: absolute;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  z-index: 4;
  font-family: var(--font-ui);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--theme-faint);
  animation: cuePulse 1.8s ease-in-out infinite;
  transition: opacity 0.35s ease, transform 0.35s ease;
}
@keyframes cuePulse { 0%,100% { opacity: 0.35; transform: translate(-50%, 0); } 50% { opacity: 0.9; transform: translate(-50%, 4px); } }

/* Hide scroll cue when not in Act 0 */
.scrolly-stage[data-act="1"] .scrolly-scrollcue,
.scrolly-stage[data-act="2"] .scrolly-scrollcue,
.scrolly-stage[data-act="3"] .scrolly-scrollcue {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(10px);
}

/* Closing CTA (unpinned end of page) */
.closing-cta {
  text-align: center;
  padding: clamp(5rem, 14vh, 9rem) 0;
  border-top: none;
}
.closing-title {
  font-family: var(--font-heading);
  font-weight: 750;
  letter-spacing: -0.025em;
  font-size: clamp(1.9rem, 3.6vw, 2.8rem);
  color: var(--heading-color);
  margin: 0 auto 1rem;
  max-width: 700px;
}
.closing-sub {
  font-size: clamp(1rem, 1.2vw, 1.12rem);
  color: var(--theme-muted);
  max-width: 560px;
  margin: 0 auto 1.75rem;
  line-height: 1.5;
}
.closing-cta .cta-subtext { margin-top: 0.9rem; }

/* ---- Fallback: stacked fade-in (mobile / reduced-motion) ----------------- */
.scrolly.is-fallback .scrolly-track { height: auto; }
.scrolly.is-fallback .scrolly-stage {
  position: static;
  height: auto;
  overflow: visible;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(2rem, 6vh, 3.5rem);
  padding: clamp(3.25rem, 8vh, 5rem) 0 3.75rem;
}
.scrolly.is-fallback .scrolly-field,
.scrolly.is-fallback .scrolly-progress,
.scrolly.is-fallback .scrolly-scrollcue { display: none; }

.scrolly.is-fallback .scrolly-captions {
  display: contents;
}
.scrolly.is-fallback .scrolly-logo-badge {
  position: static;
  order: 1;
  transform: none;
  display: flex;
  margin: 0 auto -0.75rem;
  opacity: 1;
  pointer-events: auto;
}
.scrolly.is-fallback .scrolly-logo-badge img {
  width: 38px;
  height: 38px;
}
.scrolly.is-fallback .scrolly-logo-text {
  font-size: 1.35rem;
}
.scrolly.is-fallback .scrolly-cap {
  position: static;
  left: auto;
  top: auto !important;
  width: min(90vw, 640px);
  margin: 0 auto;
  transform: none;
  opacity: 1;
}
.scrolly.is-fallback .scrolly-cap[data-act="0"] {
  order: 2;
  transform: none;
}
.scrolly.is-fallback .scrolly-cap[data-act="1"] { order: 4; }
.scrolly.is-fallback .scrolly-cap[data-act="2"] { order: 5; }
.scrolly.is-fallback .scrolly-cap[data-act="3"] { order: 6; }
.scrolly.is-fallback .scrolly-cap[data-act="4"] { display: none; }

.scrolly.is-fallback .scrolly-panel-layer {
  position: static;
  order: 3;
  width: 100%;
  margin: 0 auto;
  padding-inline: 14px;
  box-sizing: border-box;
}
.scrolly.is-fallback .scrolly-panel-layer .diagram-panel {
  opacity: 1;
  transform: none;
  width: 100%;
  height: min(430px, 72vh);
  max-width: 520px;
  margin-top: 0;
}
.scrolly.is-fallback #scrollyPanel .panel-workspace {
  overflow-y: auto;
}
.scrolly.is-fallback #scrollyPanel .panel-workspace::after {
  display: none;
}
.scrolly.is-fallback .panel-state.state-clustered { opacity: 1; }
.scrolly.is-fallback .panel-state.state-rows,
.scrolly.is-fallback .panel-state.state-analyzing { display: none; }

/* fallback caption fade-in (reuses .highlight-active pattern) */
.scrolly.is-fallback .highlight-target {
  opacity: 0.42;
  transform: translateY(12px);
  transition: opacity 0.5s var(--spring-ease), transform 0.5s var(--spring-ease);
}
.scrolly.is-fallback .scrolly-cap[data-act="0"].highlight-target {
  opacity: 1;
  transform: none;
}
.scrolly.is-fallback .highlight-target.highlight-active {
  opacity: 1;
  transform: none;
}

/* Belt-and-suspenders: force unpinned layout under the fallback width even
   before JS runs (avoids a flash of a broken pinned stage on mobile). */
@media (max-width: 760px) {
  body {
    background-image:
      radial-gradient(110% 38% at 8% 4%, var(--mesh-color-3) 0%, transparent 64%),
      radial-gradient(95% 34% at 92% 0%, var(--mesh-color-1) 0%, transparent 62%),
      radial-gradient(110% 32% at 0% 46%, color-mix(in srgb, var(--mesh-color-2) 74%, transparent) 0%, transparent 66%),
      radial-gradient(115% 34% at 100% 58%, color-mix(in srgb, var(--mesh-color-4) 72%, transparent) 0%, transparent 68%),
      linear-gradient(180deg,
        color-mix(in srgb, var(--theme-background) 70%, var(--theme-surface)) 0%,
        var(--page-bg) 48%,
        color-mix(in srgb, var(--page-bg) 86%, var(--theme-background)) 100%
      );
    background-size: auto;
  }

  .scrolly-track { height: auto; }
  .scrolly-stage {
    position: static;
    height: auto;
    overflow: visible;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(1.85rem, 5.4vh, 3.1rem);
    padding: clamp(3.25rem, 8vh, 5rem) 0 clamp(2.6rem, 7vh, 3.8rem);
    background: transparent;
  }
  .scrolly-field, .scrolly-progress, .scrolly-scrollcue { display: none; }
  .scrolly-captions { display: contents; }
  .scrolly-logo-badge {
    position: static;
    order: 1;
    transform: none;
    display: flex;
    margin: 0 auto -0.75rem;
    opacity: 1;
    pointer-events: auto;
  }
  .scrolly-logo-badge img { width: 38px; height: 38px; }
  .scrolly-logo-text { font-size: 1.35rem; }
  .scrolly-cap {
    position: static;
    transform: none;
    left: auto;
    top: auto;
    opacity: 1;
    width: min(90vw, 640px);
    margin: 0 auto;
  }
  .scrolly-cap[data-act="0"] { order: 2; }
  .scrolly-cap[data-act="1"] { order: 4; }
  .scrolly-cap[data-act="2"] { order: 5; }
  .scrolly-cap[data-act="3"] { order: 6; }
  .scrolly-cap[data-act="4"] { display: none; }
  .scrolly-panel-layer { position: static; order: 3; width: 100%; padding-inline: 14px; box-sizing: border-box; }
  .scrolly-panel-layer .diagram-panel { opacity: 1; transform: none; width: 100%; height: min(430px, 72vh); max-width: 520px; }
  .scrolly.is-fallback .highlight-target,
  .scrolly .highlight-target {
    opacity: 0.74;
  }
  .scrolly.is-fallback .highlight-target.highlight-active,
  .scrolly .highlight-target.highlight-active,
  .scrolly-cap[data-act="0"].highlight-target {
    opacity: 1;
  }
  .closing-cta {
    position: relative;
    padding: clamp(4.25rem, 16vw, 5.5rem) 0 clamp(4.75rem, 18vw, 6.25rem);
    background: transparent;
  }
  .closing-cta::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: -64px;
    height: 96px;
    background: linear-gradient(180deg, transparent, color-mix(in srgb, var(--page-bg) 42%, transparent) 78%, transparent);
    pointer-events: none;
  }
  .closing-title {
    max-width: 340px;
  }
  .closing-sub {
    max-width: 340px;
  }
  .footer {
    background: transparent;
    border-top-color: color-mix(in srgb, var(--border-color) 58%, transparent);
    padding: 3.5rem 0 4rem;
  }
}

@media (max-width: 380px) {
  .panel-header {
    padding: 0 8px;
  }

  .panel-header-controls {
    gap: 4px;
    min-width: 0;
  }

  .panel-project-dropdown {
    max-width: 112px;
    height: 30px;
  }

  .dropdown-title {
    max-width: 82px;
  }

  .panel-header-controls .header-icon-btn:last-child {
    display: none;
  }

  .panel-workspace {
    padding: 14px;
  }

  .cluster-grid {
    gap: 10px;
  }

  .cluster-card {
    padding: 9px;
    gap: 8px;
  }

  .collage {
    gap: 5px;
  }

  .collage-tile {
    height: 44px;
  }

  .cluster-card-title {
    font-size: 0.76rem;
  }
}

/* ===========================================================================
   Act 4 CTA Background Collage Grid
   =========================================================================== */
.scrolly-cta-bg {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  z-index: 2; /* In front of scrolly-field but behind scrolly-panel-layer & captions */
  transition: opacity 0.5s var(--spring-ease), transform 0.5s var(--spring-ease);
  overflow: hidden;
}

.cta-bg-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 16px;
  padding: 24px;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
}

.cta-bg-tile {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background-color: var(--theme-surface-hover);
  border: 1px solid var(--theme-line);
  box-shadow: var(--shadow-sm);
  height: 100%;
  transition: transform 0.4s var(--spring-ease);
}

/* Create an alternating organic collage offset */
.cta-bg-tile:nth-child(odd) {
  transform: translateY(12px);
}
.cta-bg-tile:nth-child(even) {
  transform: translateY(-12px);
}

.cta-bg-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  filter: grayscale(12%) contrast(92%);
}

.cta-bg-overlay {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, transparent 20%, var(--theme-background) 80%);
  pointer-events: none;
  z-index: 3;
}

/* Base theme tint layer to maintain typography legibility */
.scrolly-cta-bg::before {
  content: "";
  position: absolute;
  inset: 0;
  background-color: var(--theme-background);
  opacity: 0.80; /* Slightly lower opacity to let the larger collage pop, while the glass card handles text contrast */
  z-index: 2;
  transition: background-color var(--spring-duration) var(--spring-ease);
}

/* Glassmorphic card container for final CTA (desktop scrollytelling only) */
.scrolly:not(.is-fallback) .scrolly-cap[data-act="4"] {
  background-color: var(--theme-panel-background);
  backdrop-filter: blur(28px) saturate(160%);
  -webkit-backdrop-filter: blur(28px) saturate(160%);
  border: 1px solid var(--theme-line-strong);
  border-radius: 24px;
  padding: 48px 40px;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.12), 0 10px 20px rgba(0, 0, 0, 0.06);
  max-width: 460px;
  width: calc(100% - 32px);
  box-sizing: border-box;
  pointer-events: auto;
}

.cta-app-icon {
  display: inline-flex;
  margin-bottom: 1.5rem;
}

.cta-app-icon img {
  width: 72px;
  height: 72px;
  object-fit: contain;
  border-radius: 16px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.14), 0 3px 8px rgba(0, 0, 0, 0.08);
  display: block;
}

/* Soft feather fade at the bottom of the sticky stage to smooth section transition */
.scrolly:not(.is-fallback) .scrolly-stage::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 140px;
  background: linear-gradient(to top, var(--page-bg) 15%, transparent);
  pointer-events: none;
  z-index: 10;
  transition: background-color var(--spring-duration) var(--spring-ease);
}
