/* ========================================
   MODERN PHILOSOPHICAL POETRY ENGINE
   Pure Black + Abstract Gradient Spheres
   Refined UX/UI - 2024 Standards
   ======================================== */

:root {
  /* Pure black base */
  --void-black: #000000;
  --deep-black: #0a0a0a;
  --soft-black: #141414;
  
  /* Modern abstract colors - refined palette */
  --abstract-purple: #a78bfa;
  --abstract-blue: #60a5fa;
  --abstract-pink: #f472b6;
  --abstract-teal: #5eead4;
  --abstract-lavender: #c4b5fd;
  --abstract-coral: #fb7185;
  
  /* Refined glows */
  --glow-purple: rgba(167, 139, 250, 0.25);
  --glow-blue: rgba(96, 165, 250, 0.25);
  --glow-pink: rgba(244, 114, 182, 0.25);
  --glow-teal: rgba(94, 234, 212, 0.25);
  
  /* Text hierarchy */
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.8);
  --text-tertiary: rgba(255, 255, 255, 0.6);
  --text-disabled: rgba(255, 255, 255, 0.4);
  
  /* Modern spacing scale */
  --space-xs: 8px;
  --space-sm: 12px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --space-3xl: 64px;
}

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

html {
  /* Prevent overscroll bounce on iOS */
  overscroll-behavior-y: none;
}

html, body {
  height: 100%;
  overflow: hidden; /* Desktop: hidden by default */
}

body {
  background: var(--void-black);
  color: var(--text-primary);
  font-family: 'Lora', 'Crimson Text', Georgia, serif;
  overflow-x: hidden;
  overflow-y: hidden; /* Desktop: hidden */
  position: relative;
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Enable smooth scrolling on mobile */
  -webkit-overflow-scrolling: touch;
  /* Note: opacity and animation controlled by opening-animation.css */
}

/* Prevent vertical scroll initially */
body.initial-view {
  overflow-y: hidden;
  height: 100vh;
}

/* Allow scroll after first transform */
body.has-output {
  overflow-y: hidden;
  height: 100vh;
}

/* Mobile: Enable scrolling */
@media (max-width: 768px) {
  html, body {
    height: auto;
    overflow-x: hidden;
    overflow-y: auto; /* Enable vertical scroll on mobile */
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    overscroll-behavior-y: contain; /* Prevent bounce on edges */
  }
  
  body {
    overflow-y: auto; /* Enable vertical scroll on mobile */
    height: auto;
    min-height: 100vh;
    min-height: 100dvh; /* Dynamic viewport height */
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
  }
  
  body.initial-view,
  body.has-output {
    overflow-y: auto; /* Always enable scroll on mobile */
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
  }
  
  /* Prevent modal body scroll when modal is open */
  body.modal-open {
    overflow: hidden !important;
    position: fixed !important;
    width: 100% !important;
  }
}

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

/* Vibrant abstract soft gradient orbs - Flowing & Merging */
.background-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(140px);
  opacity: 0.25; /* Base opacity - float animations control this */
  pointer-events: none;
  z-index: 0;
  will-change: transform, opacity;
  mix-blend-mode: screen;
}

.orb-1 {
  width: 800px;
  height: 800px;
  background: radial-gradient(circle, 
    rgba(167, 139, 250, 0.6) 0%, 
    rgba(196, 181, 253, 0.4) 30%, 
    transparent 70%);
  animation: float-orb-1 35s ease-in-out infinite;
}

.orb-2 {
  width: 700px;
  height: 700px;
  background: radial-gradient(circle, 
    rgba(96, 165, 250, 0.6) 0%, 
    rgba(94, 234, 212, 0.4) 30%, 
    transparent 70%);
  animation: float-orb-2 40s ease-in-out infinite;
}

.orb-3 {
  width: 750px;
  height: 750px;
  background: radial-gradient(circle, 
    rgba(244, 114, 182, 0.6) 0%, 
    rgba(251, 113, 133, 0.4) 30%, 
    transparent 70%);
  animation: float-orb-3 38s ease-in-out infinite;
}

.orb-4 {
  width: 650px;
  height: 650px;
  background: radial-gradient(circle, 
    rgba(94, 234, 212, 0.6) 0%, 
    rgba(96, 165, 250, 0.4) 30%, 
    transparent 70%);
  animation: float-orb-4 42s ease-in-out infinite;
}

/* Original Motion Keyframes with Vivid Colors */

@keyframes float-orb-1 {
  0% {
    transform: translate(-250px, -250px) scale(1);
    opacity: 0.45;
  }
  25% {
    transform: translate(calc(50vw - 400px), -100px) scale(1.1);
    opacity: 0.5;
  }
  50% {
    transform: translate(calc(80vw - 600px), calc(30vh - 150px)) scale(0.95);
    opacity: 0.45;
  }
  75% {
    transform: translate(calc(40vw - 300px), calc(60vh - 200px)) scale(1.05);
    opacity: 0.5;
  }
  100% {
    transform: translate(-250px, -250px) scale(1);
    opacity: 0.45;
  }
}

@keyframes float-orb-2 {
  0% {
    transform: translate(calc(100vw - 200px), calc(40vh - 150px)) scale(1);
    opacity: 0.45;
  }
  25% {
    transform: translate(calc(60vw - 350px), calc(20vh - 100px)) scale(0.9);
    opacity: 0.5;
  }
  50% {
    transform: translate(calc(20vw - 200px), calc(70vh - 300px)) scale(1.1);
    opacity: 0.45;
  }
  75% {
    transform: translate(calc(80vw - 400px), calc(80vh - 400px)) scale(1);
    opacity: 0.4;
  }
  100% {
    transform: translate(calc(100vw - 200px), calc(40vh - 150px)) scale(1);
    opacity: 0.45;
  }
}

@keyframes float-orb-3 {
  0% {
    transform: translate(calc(30vw - 250px), calc(100vh - 250px)) scale(1);
    opacity: 0.45;
  }
  25% {
    transform: translate(calc(70vw - 400px), calc(50vh - 300px)) scale(1.05);
    opacity: 0.5;
  }
  50% {
    transform: translate(-100px, calc(30vh - 200px)) scale(0.95);
    opacity: 0.45;
  }
  75% {
    transform: translate(calc(50vw - 300px), calc(90vh - 400px)) scale(1.08);
    opacity: 0.5;
  }
  100% {
    transform: translate(calc(30vw - 250px), calc(100vh - 250px)) scale(1);
    opacity: 0.45;
  }
}

@keyframes float-orb-4 {
  0% {
    transform: translate(-150px, calc(60vh - 200px)) scale(1);
    opacity: 0.45;
  }
  25% {
    transform: translate(calc(40vw - 250px), calc(80vh - 350px)) scale(1.1);
    opacity: 0.5;
  }
  50% {
    transform: translate(calc(90vw - 500px), calc(20vh - 100px)) scale(0.92);
    opacity: 0.45;
  }
  75% {
    transform: translate(calc(10vw - 100px), calc(45vh - 250px)) scale(1.02);
    opacity: 0.4;
  }
  100% {
    transform: translate(-150px, calc(60vh - 200px)) scale(1);
    opacity: 0.45;
  }
}

/* Main container - Modern spacing */
.app-container {
  position: relative;
  z-index: 2;
  max-width: 920px;
  margin: 0 auto;
  padding: var(--space-3xl) var(--space-xl) 100px;
  transition: max-width 1s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Split-screen layout when output is visible */
.app-container.split-view {
  max-width: none;
  /* Equal symmetric padding on both sides - 85% of 144px = 122px */
  padding: var(--space-3xl) 122px;
  height: 100vh;
  overflow: hidden;
  position: relative;
}

.app-container.split-view .app-header {
  position: absolute;
  top: 57.6px; /* Matches default view top */
  left: 0;
  right: 0;
  margin-bottom: 0;
  padding-bottom: var(--space-2xl);
  border-bottom: none;
  background: none;
  transform: translateZ(0);
  z-index: 100;
}

/* Two-column layout for transform section and right section */
.split-view-content {
  display: block;
  margin-top: 140px;
  backface-visibility: hidden;
  transform: translateZ(0);
}

body.split-view .split-view-content {
  display: flex;
  gap: 0;
  align-items: stretch; /* Both columns same height for button alignment */
  max-height: calc(100vh - var(--space-3xl) * 2 - 140px);
  overflow: visible;
  position: relative;
  padding-top: 0;
  margin-top: 140px;
}

.app-container.split-view .transform-section {
  flex: 0 0 auto;
  max-width: 600px;
  margin-left: 0;
  margin-right: 32px;
  padding-bottom: 0;
  padding-left: 0;
  overflow-y: visible;
  overflow-x: visible;
  align-items: center;
  /* Final position - transition handles the smooth movement */
  transform: translate3d(0, 0, 0);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Match height with output section for button alignment */
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

/* Push button to bottom to align with poem tile bottom edge */
.app-container.split-view .transform-button {
  margin-top: auto;
  margin-bottom: 32px; /* Match poem card padding (space-xl) */
}

/* Custom scrollbar for transform section */
.app-container.split-view .transform-section::-webkit-scrollbar {
  width: 6px;
}

.app-container.split-view .transform-section::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.02);
  border-radius: 3px;
}

.app-container.split-view .transform-section::-webkit-scrollbar-thumb {
  background: rgba(167, 139, 250, 0.3);
  border-radius: 3px;
  transition: background 0.3s ease;
}

.app-container.split-view .transform-section::-webkit-scrollbar-thumb:hover {
  background: rgba(167, 139, 250, 0.5);
}

.app-container.split-view .right-section {
  flex: 1;
  margin-top: 0;
  margin-left: 32px;
  margin-right: 0;
  max-width: none;
  display: flex;
  gap: var(--space-lg);
  align-items: flex-start;
  max-height: 100%;
  overflow: visible;
  padding-left: 0;
  padding-right: 0;
  padding-top: 0;
  will-change: transform, opacity;
  backface-visibility: hidden;
  -webkit-font-smoothing: antialiased;
}

.app-container.split-view .output-container {
  flex: 9.401184 1 auto;
  margin-top: 0;
  padding-top: 0;
  max-width: none;
  overflow: visible;
  transition: opacity 1.5s cubic-bezier(0.2, 0.8, 0.2, 1),
              transform 1.5s cubic-bezier(0.2, 0.8, 0.2, 1); /* Match opening animation */
  will-change: transform, opacity;
  backface-visibility: hidden;
  transform: translateZ(0);
}

.app-container.split-view .capabilities-section {
  flex: 0 0 240px;
  display: flex;
  flex-direction: column;
  gap: 22.12px; /* Match gap between capability tiles */
  overflow: visible;
  will-change: transform, opacity;
  backface-visibility: hidden;
  transform: translateZ(0);
  margin-right: 0 !important;
  margin-left: auto !important;
  padding-right: 0 !important;
  margin-top: 0;
  padding-top: 0;
  align-self: flex-start;
}

.app-container.split-view .action-bar-container {
  padding-right: 0 !important;
  margin-right: 0 !important;
  margin-left: auto !important;
  margin-top: 0;
  padding-top: 0;
  padding-bottom: 0; /* Gap handled by parent .capabilities-section */
  padding-left: 0;
  align-self: flex-start;
  display: flex;
  justify-content: flex-end;
  align-items: flex-start;
  width: 240px;
  gap: 12px;
}

.app-container.split-view .capability-tiles {
  padding-right: 0 !important;
  margin-right: 0 !important;
  gap: 22.12394728px;
}

.app-container.split-view .capability-tile {
  margin-right: 0 !important;
  padding-right: 16px !important;
  padding-left: 28px !important; /* +12px from original 16px */
  width: 100%;
  box-sizing: border-box;
}

/* ========================================
   HEADER - Refined
   ======================================== */
.app-header {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 0 0 var(--space-2xl);
  margin-bottom: var(--space-2xl);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  transition: border-bottom 0.7s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: border-bottom;
  backface-visibility: hidden;
  position: absolute;
  top: 57.6px; /* Reduced from 64px (space-3xl) by 10% */
  left: 0;
  right: 0;
  z-index: 100;
  transform: translateZ(0);
}

.app-title {
  font-family: 'Cinzel', Georgia, serif;
  font-size: 27.612px;
  font-weight: 500;
  letter-spacing: 3px;
  color: var(--text-primary);
  cursor: pointer;
  user-select: none;
  transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  text-align: center;
  margin-bottom: 13px; /* Reduced further (90% of 14.4px) */
  will-change: opacity;
  backface-visibility: hidden;
  transform: translateZ(0);
  overflow: visible;
  text-transform: uppercase;
}

/* Title letter styles for particle effect */
.title-letter {
  display: inline-block;
  will-change: transform, opacity, filter;
  backface-visibility: hidden;
}

.title-particles {
  z-index: 10;
}

.mini-particle {
  will-change: transform, opacity;
  box-shadow: 0 0 6px rgba(167, 139, 250, 0.6);
}

.app-subtitle {
  font-family: 'Crimson Text', Georgia, serif;
  font-size: 18.2px;
  font-weight: 400;
  font-style: italic;
  letter-spacing: 0.5px;
  color: var(--text-tertiary);
  text-align: center;
  margin: 0;
  margin-bottom: 20px; /* A) Gap between tagline and input prompt (+10px more) */
  transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: opacity;
  backface-visibility: hidden;
  transform: translateZ(0);
}

.header-controls {
  display: none;
}

.icon-button {
  display: none;
}

/* ========================================
   MAIN TRANSFORMATION INTERFACE
   ======================================== */
.transform-section {
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3xl);
  max-width: 800px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transform: translate3d(0, 0, 0);
  position: relative;
  will-change: transform, max-width, margin;
}

/* Transition class added by JS for smooth animation */
.transform-section.sliding {
  transition: transform 1.8s cubic-bezier(0.22, 1, 0.36, 1),
              max-width 1.8s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Center vertically on initial view */
body.initial-view .app-container {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  min-height: 100vh;
  padding: var(--space-xl);
  /* Match split-view top padding for consistent vertical position */
  padding-top: var(--space-3xl);
}

body.initial-view .app-header {
  border-bottom: none;
}

/* Landing page - centered layout with vertical spacing */
body.initial-view .transform-section {
  margin-top: 0;
  /* Matches split-view position for seamless transition */
  padding-top: 0;
}

/* Split-view - aligned with right section, vertical change is instant */
body.split-view .transform-section {
  margin-top: 0 !important;
  /* Aligns with output section (both start at split-view-content top) */
  padding-top: 0 !important;
}

.input-container {
  width: 100%;
  position: relative;
  will-change: width;
  transform: translateZ(0);
  backface-visibility: hidden;
  margin-bottom: 10px; /* B) Gap between prompt bar and Lens of Philosophy */
}

.input-label {
  display: none !important;
  opacity: 0 !important;
  height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  border: none !important;
  visibility: hidden !important;
}

/* Animated Placeholder */
.animated-placeholder {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 26px var(--space-xl) var(--space-xl);
  font-family: 'Crimson Text', Georgia, serif;
  font-size: 17px;
  line-height: 1.8;
  color: var(--text-disabled);
  font-style: italic;
  pointer-events: none !important;
  transition: opacity 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  z-index: 1;
  backface-visibility: hidden;
  transform: translateZ(0);
  opacity: 1;
  visibility: visible;
}

.placeholder-static {
  color: var(--text-disabled);
}

.placeholder-dynamic {
  color: transparent;
  background: linear-gradient(135deg, 
    #c4b5fd 0%,  /* Light violet */
    #a78bfa 50%,  /* Medium violet */
    #8b5cf6 100% /* Medium-dark violet - AAA contrast */
  );
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 500;
  position: relative;
}

.text-input {
  width: 100%;
  height: 183.6px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.08); /* Reduced opacity to minimize visibility */
  border-radius: 4px;
  padding: 26px var(--space-xl) var(--space-xl);
  color: var(--text-primary);
  font-family: 'Crimson Text', Georgia, serif;
  font-size: 17px;
  line-height: 1.8;
  resize: none;
  transition: border-color 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              background 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              box-shadow 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              width 0.9s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              height 0.9s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              opacity 0.9s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  will-change: transform, box-shadow, opacity;
  position: relative;
  z-index: 2;
  backface-visibility: hidden;
  transform: translateZ(0);
}

.text-input:hover {
  border-color: rgba(167, 139, 250, 0.5);
  background: rgba(255, 255, 255, 0.03);
  box-shadow: 0 4px 16px rgba(107, 70, 193, 0.12);
  transform: translateY(-1px);
}

.text-input:focus {
  outline: none;
  border-color: var(--abstract-purple);
  background: rgba(255, 255, 255, 0.04);
  box-shadow: 0 0 0 3px var(--glow-purple),
              0 8px 24px rgba(0, 0, 0, 0.4);
  transform: translateY(-2px);
}

.text-input::placeholder {
  color: var(--text-disabled);
  font-style: italic;
}

.text-input::-webkit-scrollbar {
  width: 6px;
}

.text-input::-webkit-scrollbar-thumb {
  background: rgba(167, 139, 250, 0.3);
  border-radius: 3px;
}

.text-input::-webkit-scrollbar-thumb:hover {
  background: var(--abstract-purple);
}

/* ========================================
   LENS SELECTOR - Modern Pills
   ======================================== */
.lens-section {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-lg);
  transition: all 1.4s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform, contents;
  transform: translateZ(0);
  backface-visibility: hidden;
}

.lens-section-title {
  font-family: 'Lora', Georgia, serif;
  font-size: 10.2px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-tertiary);
  text-align: center;
}

.lens-selector {
  width: calc(100% + 12.96px); /* Compensate for horizontal negative margin */
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start; /* Prevent vertical stretching */
  align-content: flex-start; /* Pack rows tightly with consistent margins */
  justify-content: center;
  margin: -7.776px -6.48px; /* Vertical/Horizontal negative margins to offset pill margins */
  padding: 0;
  gap: 0; /* Explicit: no gap - spacing comes from pill margins only */
  row-gap: 0; /* Explicit: no row gap */
  column-gap: 0; /* Explicit: no column gap */
  line-height: 1; /* Prevent line-height from affecting vertical rhythm */
  /* No opacity transition - opening animation controls visibility */
  will-change: contents;
  backface-visibility: hidden;
  transform: translateZ(0);
}

/* Break elements for responsive layout control */
/* Hidden during FLIP animation - pills animate directly to new positions */
.lens-break {
  height: 0;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  flex-basis: 100%;
  max-width: 100%;
  overflow: hidden;
  pointer-events: none;
  line-height: 0;
  font-size: 0;
  visibility: hidden;
  /* Instant transition - FLIP handles the visual animation */
  transition: none;
}

/* Initial View: Break after 6th item (landing-break), hide split-breaks */
.landing-break {
  flex-basis: 100%;
  max-width: 100%;
}

.split-break {
  flex-basis: 0;
  max-width: 0;
}

/* Initial view: Natural width, 6 per row */
/* Vertical gap is 120% of horizontal (7.776px vs 6.48px) */
.lens-selector .lens-pill {
  margin: 7.776px 6.48px; /* Vertical: 15.55px gap, Horizontal: 12.96px gap */
  /* No opacity transition here - let opening animation control it */
  transition: border-color 0.3s ease,
              background 0.3s ease,
              box-shadow 0.3s ease;
  white-space: nowrap;
  flex: 0 0 auto;
  backface-visibility: hidden;
  will-change: transform;
  -webkit-backface-visibility: hidden;
  transform-style: preserve-3d;
}

/* FLIP animation class - applied by JS for smooth position animation */
/* Slower, smoother transition for the layout change */
.lens-pill.flip-animating {
  transition: transform 1.8s cubic-bezier(0.22, 1, 0.36, 1) !important;
}

/* FLIP animation handles all smooth position transitions via JavaScript */
/* No CSS position transitions - they cause jitter with flexbox reflow */

/* Transition to split-view layout: 4 pills per row */
.app-container.split-view .lens-selector {
  justify-content: center;
  align-items: flex-start;
  align-content: flex-start;
  /* Gaps handled by pill margins - 12.96px gap maintained (120% of 10.8px) */
}

/* Split View: Hide landing-break, show split-breaks (after 4th and 8th) */
/* Instant layout change - FLIP animation handles visual transition */
.app-container.split-view .landing-break {
  flex-basis: 0;
  max-width: 0;
}

.app-container.split-view .split-break {
  flex-basis: 100%;
  max-width: 100%;
}

.lens-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-sm);
}

.lens-pill {
  position: relative;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 10px 22px;
  cursor: pointer;
  /* pointer-events controlled by opening-animation.css */
  /* No transform transition here - FLIP and opening animation handle transforms */
  transition: background 0.4s ease-out,
              border-color 0.4s ease-out,
              color 0.3s ease-out,
              box-shadow 0.4s ease-out;
  font-family: 'Lora', Georgia, serif;
  font-size: 11.22px;
  font-weight: 500;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  overflow: visible;
  backdrop-filter: blur(10px);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

/* Interactivity controlled by opening-animation.css phase rules */

.lens-pill::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, 
    var(--abstract-purple), 
    var(--abstract-blue), 
    var(--abstract-pink));
  opacity: 0;
  transition: opacity 0.3s ease;
  border-radius: 999px;
  z-index: -1;
  overflow: hidden;
}

.lens-pill:hover:not(.flip-animating) {
  color: var(--text-primary);
  border-color: var(--abstract-purple);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px var(--glow-purple);
  background: rgba(255, 255, 255, 0.05);
}

.lens-pill:hover::before {
  opacity: 0.1;
}

.lens-pill.active {
  background: linear-gradient(135deg, 
    rgba(167, 139, 250, 0.15), 
    rgba(96, 165, 250, 0.15));
  border-color: var(--abstract-purple);
  color: var(--text-primary);
  box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.3);
  transform: translateY(-1px);
  transition: background 0.4s ease-out,
              border-color 0.4s ease-out,
              color 0.3s ease-out,
              transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.4s ease-out;
}

/* Individual lens active/selected colors with double border - ALL UNIQUE */

/* 1. Existentialist - Purple */
.lens-pill[data-lens="existentialist"].active {
  border-color: #a78bfa;
  box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.35);
  background: linear-gradient(135deg, 
    rgba(167, 139, 250, 0.15), 
    rgba(139, 92, 246, 0.15));
}

/* 2. Stoic - Steel Blue */
.lens-pill[data-lens="stoic"].active {
  border-color: #60a5fa;
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.35);
  background: linear-gradient(135deg, 
    rgba(96, 165, 250, 0.15), 
    rgba(59, 130, 246, 0.15));
}

/* 3. Taoist - Teal */
.lens-pill[data-lens="taoist"].active {
  border-color: #2dd4bf;
  box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.35);
  background: linear-gradient(135deg, 
    rgba(45, 212, 191, 0.15), 
    rgba(20, 184, 166, 0.15));
}

/* 4. Nihilist - Deep Indigo (variant of Mystical's indigo) */
.lens-pill[data-lens="nihilist"].active {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.35);
  background: linear-gradient(135deg, 
    rgba(99, 102, 241, 0.12), 
    rgba(79, 70, 229, 0.12));
}

/* 5. Romantic - Periwinkle (soft blue-purple) */
.lens-pill[data-lens="romantic"].active {
  border-color: #a5b4fc;
  box-shadow: 0 0 0 3px rgba(165, 180, 252, 0.35);
  background: linear-gradient(135deg, 
    rgba(165, 180, 252, 0.15), 
    rgba(129, 140, 248, 0.15));
}

/* 6. Absurdist - Aquamarine (bright teal-green) */
.lens-pill[data-lens="absurdist"].active {
  border-color: #5eead4;
  box-shadow: 0 0 0 3px rgba(94, 234, 212, 0.35);
  background: linear-gradient(135deg, 
    rgba(94, 234, 212, 0.15), 
    rgba(45, 212, 191, 0.15));
}

/* 7. Phenomenological - Sky Blue */
.lens-pill[data-lens="phenomenological"].active {
  border-color: #7dd3fc;
  box-shadow: 0 0 0 3px rgba(125, 211, 252, 0.35);
  background: linear-gradient(135deg, 
    rgba(125, 211, 252, 0.15), 
    rgba(56, 189, 248, 0.15));
}

/* 8. Structuralist - Lavender */
.lens-pill[data-lens="structuralist"].active {
  border-color: #c4b5fd;
  box-shadow: 0 0 0 3px rgba(196, 181, 253, 0.35);
  background: linear-gradient(135deg, 
    rgba(196, 181, 253, 0.15), 
    rgba(167, 139, 250, 0.15));
}

/* 9. Dadaist - Soft Violet (variant of Structuralist's lavender) */
.lens-pill[data-lens="dadaist"].active {
  border-color: #b794f4;
  box-shadow: 0 0 0 3px rgba(183, 148, 244, 0.35);
  background: linear-gradient(135deg, 
    rgba(183, 148, 244, 0.15), 
    rgba(159, 122, 234, 0.15));
}

/* 10. Mystical - Indigo */
.lens-pill[data-lens="mystical"].active {
  border-color: #818cf8;
  box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.35);
  background: linear-gradient(135deg, 
    rgba(129, 140, 248, 0.15), 
    rgba(99, 102, 241, 0.15));
}

/* 11. Materialist - Emerald Green */
.lens-pill[data-lens="materialist"].active {
  border-color: #34d399;
  box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.35);
  background: linear-gradient(135deg, 
    rgba(52, 211, 153, 0.15), 
    rgba(16, 185, 129, 0.15));
}

/* 12. Idealist - Cyan */
.lens-pill[data-lens="idealist"].active {
  border-color: #22d3ee;
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.35);
  background: linear-gradient(135deg, 
    rgba(34, 211, 238, 0.15), 
    rgba(6, 182, 212, 0.15));
}

.lens-pill:active {
  transform: translateY(0);
}

.lens-pill:focus {
  outline: none;
}

.lens-pill:focus-visible {
  outline: 2px solid var(--abstract-purple);
  outline-offset: 2px;
}

@media (hover: hover) {
  .lens-pill:not(:hover):not(.active) {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  }
}

/* Individual lens hover colors */
/* Individual lens hover colors - matching selected state colors */
.lens-pill[data-lens="existentialist"]:hover {
  border-color: #a78bfa;
  box-shadow: 0 4px 16px rgba(167, 139, 250, 0.4);
}

.lens-pill[data-lens="stoic"]:hover {
  border-color: #60a5fa;
  box-shadow: 0 4px 16px rgba(96, 165, 250, 0.4);
}

.lens-pill[data-lens="taoist"]:hover {
  border-color: #2dd4bf;
  box-shadow: 0 4px 16px rgba(45, 212, 191, 0.4);
}

.lens-pill[data-lens="nihilist"]:hover {
  border-color: #6366f1;
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
}

.lens-pill[data-lens="romantic"]:hover {
  border-color: #a5b4fc;
  box-shadow: 0 4px 16px rgba(165, 180, 252, 0.4);
}

.lens-pill[data-lens="absurdist"]:hover {
  border-color: #5eead4;
  box-shadow: 0 4px 16px rgba(94, 234, 212, 0.4);
}

.lens-pill[data-lens="phenomenological"]:hover {
  border-color: #7dd3fc;
  box-shadow: 0 4px 16px rgba(125, 211, 252, 0.4);
}

.lens-pill[data-lens="structuralist"]:hover {
  border-color: #c4b5fd;
  box-shadow: 0 4px 16px rgba(196, 181, 253, 0.4);
}

.lens-pill[data-lens="dadaist"]:hover {
  border-color: #b794f4;
  box-shadow: 0 4px 16px rgba(183, 148, 244, 0.4);
}

.lens-pill[data-lens="mystical"]:hover {
  border-color: #818cf8;
  box-shadow: 0 4px 16px rgba(129, 140, 248, 0.4);
}

.lens-pill[data-lens="materialist"]:hover {
  border-color: #34d399;
  box-shadow: 0 4px 16px rgba(52, 211, 153, 0.4);
}

.lens-pill[data-lens="idealist"]:hover {
  border-color: #22d3ee;
  box-shadow: 0 4px 16px rgba(34, 211, 238, 0.4);
}

/* ========================================
   LENS TOOLTIPS (JavaScript-based)
   ======================================== */

/* Tooltip styles are applied via JavaScript for reliability */

/* ========================================
   ABSTRACTION SLIDER
   ======================================== */
.abstraction-control {
  width: 100%;
  max-width: 500px;
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  margin-top: 31.84px; /* C) Gap between Lens of Philosophy and slider (+10px) */
  transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
  transform: translateZ(0);
}

.abstraction-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 var(--space-xs);
}

.abstraction-label {
  font-family: 'Lora', Georgia, serif;
  font-size: 9.35px;
  font-weight: 500;
  letter-spacing: 1.5px;
  color: var(--text-tertiary);
  text-transform: uppercase;
}

.abstraction-label.active {
  color: var(--abstract-purple);
  font-weight: 600;
}

.slider-container {
  position: relative;
  width: 100%;
  height: 40px;
  display: flex;
  align-items: center;
  cursor: pointer;
}

.abstraction-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 3px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  /* pointer-events controlled by opening-animation.css */
}

.abstraction-slider::-webkit-slider-track {
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, 
    var(--abstract-teal) 0%,
    var(--abstract-blue) 25%,
    var(--abstract-purple) 50%,
    var(--abstract-pink) 75%,
    var(--abstract-coral) 100%);
  border-radius: 2px;
}

.abstraction-slider::-moz-range-track {
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, 
    var(--abstract-teal) 0%,
    var(--abstract-blue) 25%,
    var(--abstract-purple) 50%,
    var(--abstract-pink) 75%,
    var(--abstract-coral) 100%);
  border-radius: 2px;
}

.abstraction-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  background: var(--text-primary);
  border: 2px solid var(--abstract-purple);
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(167, 139, 250, 0.4);
}

.abstraction-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  background: var(--text-primary);
  border: 2px solid var(--abstract-purple);
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(167, 139, 250, 0.4);
}

.abstraction-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  box-shadow: 0 4px 12px rgba(167, 139, 250, 0.6);
}

.abstraction-slider::-moz-range-thumb:hover {
  transform: scale(1.2);
  box-shadow: 0 4px 12px rgba(167, 139, 250, 0.6);
}

.abstraction-value-display {
  position: absolute;
  top: -48px;  /* Adjusted for caret */
  /* left is controlled by JavaScript for thumb tracking */
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Lora', Georgia, serif;
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.3px;
  color: rgba(255, 255, 255, 0.9);
  padding: 8px 12px;
  background: rgba(18, 18, 20, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease, visibility 0.2s ease, left 0.1s ease; /* Smooth thumb following */
  visibility: hidden;
  z-index: 100;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

/* Caret at bottom - exactly like lens tooltips */
.abstraction-value-display::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: 10px;
  height: 10px;
  background: rgba(18, 18, 20, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.slider-container:hover .abstraction-value-display {
  opacity: 1;
  visibility: visible;
}

/* ========================================
   TRANSFORM BUTTON - Animated Gradient
   ======================================== */
.transform-button {
  position: relative;
  /* Elegant moving violet gradient */
  background: linear-gradient(
    90deg,
    #4c1d95 0%,
    #5b21b6 16.66%,
    #7c3aed 33.33%,
    #8b5cf6 50%,
    #7c3aed 66.66%,
    #5b21b6 83.33%,
    #4c1d95 100%
  );
  background-size: 200% 100%;
  background-position: 0% 50%;
  animation: elegantVioletFlow 6s linear infinite;
  border: none;
  border-radius: 999px;
  padding: 17.595px 54.74px;
  font-family: 'Lora', Georgia, serif;
  font-size: 14.6625px;
  font-weight: 600;
  letter-spacing: 1.2px;
  color: var(--text-primary);
  cursor: pointer;
  /* pointer-events controlled by opening-animation.css */
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), 
              box-shadow 0.3s ease,
              filter 0.3s ease,
              background-position 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: visible;
  box-shadow: 0 4px 16px rgba(107, 70, 193, 0.3);
  margin-top: 32px; /* Push down to match split-view position */
  margin-bottom: 32px; /* Match split-view position (same as poem card padding) */
}

/* Interactivity controlled by opening-animation.css phase rules */
.transform-button,
#transformBtn {
  will-change: background-position;
  backface-visibility: hidden;
}

/* Elegant continuous violet flow */
@keyframes elegantVioletFlow {
  0% {
    background-position: 0% 50%;
  }
  100% {
    background-position: 200% 50%;
  }
}

.transform-button::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 999px;
  padding: 2px;
  background: linear-gradient(90deg,
    transparent,
    rgba(167, 139, 250, 0.4),
    rgba(139, 92, 246, 0.6),
    rgba(167, 139, 250, 0.4),
    transparent);
  background-size: 200% 100%;
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  animation: shimmerBorder 3s linear infinite;
  pointer-events: none;
}

@keyframes gradientFlow {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

@keyframes shimmerBorder {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.transform-button:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 8px 32px rgba(139, 92, 246, 0.5), 
              0 4px 16px rgba(107, 70, 193, 0.3);
  filter: brightness(1.1);
  /* Fluid gradient shift - light moves left, dark moves right */
  animation: none;
  background-position: 100% 50%;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), 
              box-shadow 0.3s ease,
              filter 0.3s ease,
              background-position 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.transform-button:active {
  transform: translateY(1px) scale(0.98);
  box-shadow: 0 2px 8px rgba(107, 70, 193, 0.3);
  filter: brightness(0.95);
}

.transform-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  animation: none;
}

/* ========================================
   OUTPUT POETRY DISPLAY - Refined
   ======================================== */
.output-container {
  width: 100%;
  max-width: 761px; /* 120% of 634px */
  margin-top: var(--space-3xl);
  opacity: 0;
  transform: translate3d(80px, 0, 0); /* Start 80px right - inside screen */
  transition: opacity 1.5s cubic-bezier(0.2, 0.8, 0.2, 1),
              transform 1.5s cubic-bezier(0.2, 0.8, 0.2, 1); /* Match opening animation */
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  will-change: transform, opacity;
}

.output-container.visible {
  opacity: 1;
  transform: translate3d(0, 0, 0);
}

/* Horizontal slide for split view */
body.split-view .output-container {
  transform: translate3d(80px, 0, 0); /* Start 80px right - inside screen */
}

body.split-view .output-container.visible {
  opacity: 1;
  transform: translate3d(0, 0, 0);
}

/* Vertical slide for initial centered view */
body:not(.split-view) .output-container {
  transform: translateY(20px);
}

body:not(.split-view) .output-container.visible {
  opacity: 1;
  transform: translateY(0);
}

.poem-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  padding: var(--space-xl) var(--space-lg) calc(var(--space-xl) + 50px) var(--space-lg);
  position: relative;
  min-height: auto;
  backdrop-filter: blur(20px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  overflow: visible;
  display: flex;
  flex-direction: column;
  gap: var(--space-xl);
  transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform, opacity;
  backface-visibility: hidden;
  transform: translateZ(0);
}

/* Auto-generated poem title */
.poem-title {
  font-family: 'Lora', Georgia, serif;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 1px;
  color: #ffffff;
  text-align: center;
  margin: 0;
  padding-bottom: var(--space-xl);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  opacity: 0;
  /* Animation controlled by JavaScript for sequential flow */
  transition: opacity 1.14s cubic-bezier(0.25, 0.46, 0.45, 0.94), color 0.3s ease;
  will-change: opacity;
  backface-visibility: hidden;
  -webkit-font-smoothing: antialiased;
  min-height: 27px;
  border-left: 2px solid transparent;
  border-right: 2px solid transparent;
  border-top: 2px solid transparent;
  border-radius: 6px;
  box-sizing: border-box;
}

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

/* Copy button for poem */
.copy-poem-btn {
  position: absolute;
  bottom: var(--space-lg);
  right: var(--space-lg);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(167, 139, 250, 0.1);
  border: 1px solid rgba(167, 139, 250, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  opacity: 0;
  animation: fadeIn 0.5s ease 1.5s forwards;
  z-index: 10;
}

.copy-poem-btn:hover {
  background: rgba(167, 139, 250, 0.2);
  border-color: rgba(167, 139, 250, 0.5);
  transform: scale(1.1);
}

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

.copy-poem-btn svg {
  width: 18px;
  height: 18px;
  stroke: #ffffff;
  stroke-width: 2;
  fill: none;
}

.copy-poem-btn.copied {
  background: rgba(94, 234, 212, 0.2);
  border-color: rgba(94, 234, 212, 0.5);
}

.copy-poem-btn.copied svg {
  stroke: var(--abstract-teal);
}

/* Edit button for poem */
.edit-poem-btn {
  position: absolute;
  bottom: calc(var(--space-lg) + 52px);
  right: var(--space-lg);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(167, 139, 250, 0.1);
  border: 1px solid rgba(167, 139, 250, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  opacity: 0;
  animation: fadeIn 0.5s ease 1.6s forwards;
  z-index: 10;
}

.edit-poem-btn:hover {
  background: rgba(167, 139, 250, 0.2);
  border-color: rgba(167, 139, 250, 0.5);
  transform: scale(1.1);
}

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

.edit-poem-btn svg {
  width: 18px;
  height: 18px;
  stroke: #ffffff;
  stroke-width: 2;
  fill: none;
}

.edit-poem-btn.active {
  background: rgba(94, 234, 212, 0.2);
  border-color: rgba(94, 234, 212, 0.5);
}

.edit-poem-btn.active svg {
  stroke: var(--abstract-teal);
}

/* Editing state for poem - visible outlines without layout changes */
/* Edit state - NO height changes, colors locked */
.poem-text.editing,
.poem-text.editing:focus {
  /* Body text - ALWAYS teal/green border */
  outline: none !important;
  background: rgba(94, 234, 212, 0.02);
  cursor: text;
  position: relative;
}

.poem-text.editing::before {
  content: '';
  position: absolute;
  top: -20px !important; /* Move top edge up by 20px total */
  left: 0;
  right: 0;
  bottom: -20px !important; /* Move bottom edge down by 20px total */
  border: 2px solid rgba(94, 234, 212, 0.8);
  border-radius: 6px;
  pointer-events: none;
  z-index: 1;
}

.poem-title.editing,
.poem-title.editing:focus {
  /* Heading - ALWAYS purple border using pseudo-element for position control */
  outline: none !important;
  background: rgba(167, 139, 250, 0.03);
  cursor: text;
  border-bottom-color: transparent !important;
  position: relative;
}

.poem-title.editing::before {
  content: '';
  position: absolute;
  top: -19px; /* Shift border up by 2px more */
  left: -8px;
  right: -8px;
  bottom: 12px; /* Move bottom edge up to cut off the padding space */
  border: 2px solid rgba(167, 139, 250, 0.6);
  border-radius: 6px;
  pointer-events: none;
}

/* Subtle glow on focus */
.poem-text.editing:focus::before {
  box-shadow: 0 0 15px rgba(94, 234, 212, 0.12);
}

.poem-title.editing:focus {
  box-shadow: none;
}

.poem-title.editing:focus::before {
  box-shadow: 0 0 15px rgba(167, 139, 250, 0.12);
}

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

/* Transform Modal - Glass card container */
.compression-challenge .glass-card {
  position: relative;
  margin-bottom: var(--space-2xl);
  overflow: hidden;  /* Clips loader to card boundaries */
}

/* Transform Modal Loader - Covers entire glass-card */
.transform-loader {
  position: absolute;
  inset: 0;  /* Covers entire parent glass-card */
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: opacity 0.4s ease;
  background: transparent;
  pointer-events: none;
  z-index: 10;
  margin: 0;
  padding: 0;
}

.transform-loader::before {
  content: '';
  position: absolute;
  inset: 0;  /* Fills loader completely */
  background: linear-gradient(
    110deg,
    rgba(15, 15, 20, 0.98),
    rgba(15, 15, 20, 0.98),
    rgba(91, 33, 182, 0.03),
    rgba(124, 58, 237, 0.04),
    rgba(139, 92, 246, 0.05),
    rgba(124, 58, 237, 0.04),
    rgba(91, 33, 182, 0.03),
    rgba(15, 15, 20, 0.98),
    rgba(15, 15, 20, 0.98)
  );
  background-size: 300% 100%;
  animation: transformGradientFlow 3.5s linear infinite;
  z-index: 1;
  border-radius: 6px;
  pointer-events: none;
}

/* Dynamic heights for glass-card based on format */
.compression-challenge .glass-card[data-format="haiku"] {
  min-height: 138px;   /* 90px content + 48px padding */
}

.compression-challenge .glass-card[data-format="limerick"] {
  height: 198px;  /* Fixed: exactly 5 lines, never 6 */
  min-height: 198px;
}

.compression-challenge .glass-card[data-format="prose"] {
  min-height: 348px;  /* 10 lines for prose loader (10 * 30px line-height + 48px padding) */
}

.compression-challenge .glass-card[data-format="phrase"] {
  min-height: 78px;   /* 30px content (1 line) + 48px padding */
}

.transform-loader.hidden {
  display: none !important;
}

@keyframes transformGradientFlow {
  0% {
    background-position: 0% 0;
  }
  100% {
    background-position: 300% 0;
  }
}

.loader-text {
  font-family: 'Crimson Text', Georgia, serif;
  font-size: 15px;
  font-style: italic;
  letter-spacing: 0.3px;
  color: rgba(255, 255, 255, 0.65);
  text-align: center;
  z-index: 2;
  position: relative;
}

/* Contrast Modal Loader - Consistent with Transform Modal */
.contrast-loader {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: opacity 0.4s ease;
  background: transparent;
  pointer-events: none;
  z-index: 10;
}

.contrast-loader::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    110deg,
    rgba(15, 15, 20, 0.98),
    rgba(15, 15, 20, 0.98),
    rgba(91, 33, 182, 0.03),
    rgba(124, 58, 237, 0.04),
    rgba(139, 92, 246, 0.05),
    rgba(124, 58, 237, 0.04),
    rgba(91, 33, 182, 0.03),
    rgba(15, 15, 20, 0.98),
    rgba(15, 15, 20, 0.98)
  );
  background-size: 300% 100%;
  animation: transformGradientFlow 3.5s linear infinite;
  z-index: 1;
  border-radius: 6px;
  pointer-events: none;
}

.contrast-loader .loader-text {
  font-family: 'Crimson Text', Georgia, serif;
  font-size: 15px;
  font-style: italic;
  letter-spacing: 0.3px;
  color: rgba(255, 255, 255, 0.65);
  text-align: center;
  z-index: 2;
  position: relative;
  padding: 0 20px;
}

.contrast-loader.hidden {
  display: none !important;
}

/* Container for contrast poem needs position relative for loader */
#contrastComparisonPoem {
  position: relative;
  padding: 0 20px;
}

@keyframes poemRegenerate {
  0% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

@keyframes titleGentleFadeIn {
  0% {
    opacity: 0.3;
  }
  100% {
    opacity: 1;
  }
}

.poem-text.regenerating {
  animation: poemRegenerate 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) !important;
  transform: none !important;
  will-change: opacity;
  backface-visibility: hidden;
  -webkit-font-smoothing: antialiased;
}

.poem-title.regenerating {
  animation: poemRegenerate 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) !important;
  will-change: opacity;
  backface-visibility: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Match output height to unfold button bottom in split-view */
.app-container.split-view .poem-card {
  min-height: auto;
  max-height: 100%;
  justify-content: flex-start;
  padding: var(--space-2xl) var(--space-xl);
  overflow: visible;
}

.poem-card::before {
  content: '';
  position: absolute;
  top: -1px;
  left: -1px;
  right: -1px;
  bottom: -1px;
  background: linear-gradient(90deg, 
    var(--abstract-purple),
    var(--abstract-blue),
    var(--abstract-pink),
    var(--abstract-teal),
    var(--abstract-purple)
  );
  background-size: 200% 100%;
  border-radius: 4px;
  opacity: 0;
  z-index: -1;
  transition: opacity 1.2s ease 0.4s;
  animation: poemCardShimmer 4s linear infinite;
}

@keyframes poemCardShimmer {
  0% {
    background-position: 0% 0%;
  }
  100% {
    background-position: 200% 0%;
  }
}

.poem-card::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, 
    rgba(167, 139, 250, 0.03) 0%, 
    transparent 70%);
  opacity: 0;
  transition: opacity 1s ease 0.8s;
  pointer-events: none;
}

.output-container.visible .poem-card::before {
  opacity: 0.2;
}

.output-container.visible .poem-card::after {
  opacity: 1;
}

.poem-text {
  font-family: 'Crimson Text', Georgia, serif;
  font-size: 16px;
  line-height: 1.7;
  color: var(--text-primary);
  font-style: normal;
  text-align: left;
  position: relative;
  letter-spacing: 0.2px;
  transition: opacity 0.4s ease;
  border: 2px solid transparent;
  border-radius: 6px;
  box-sizing: border-box;
  white-space: pre-line;
}

/* Uniform poem line styling - professional */
.poem-line {
  display: block;
  margin: 12px 0;
  padding-left: 0;
  opacity: 0;
  /* Animation controlled by JavaScript for sequential flow */
  transition: opacity 1.14s cubic-bezier(0.25, 0.46, 0.45, 0.94), color 0.3s ease;
  position: relative;
  text-indent: 32px;
  color: var(--text-primary);
  text-align: left;
}

.poem-line:first-child {
  margin-top: 0;
  text-indent: 32px;
}

.poem-line:hover {
  color: var(--abstract-lavender);
}

/* Last line has no bottom margin */
.poem-line:last-child { 
  margin-bottom: 0;
}

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

/* Emphasized words */
.poem-emphasis {
  color: var(--abstract-purple);
  font-style: italic;
}

/* ========================================
   EXPLAIN TOGGLE - Modern Switch
   ======================================== */
/* Action Bar Container (Copy + Explain) */
.action-bar-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  margin: 0;
  padding: var(--space-md);
  opacity: 0;
  transform: translateY(8px);
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  width: 100%;
}

.action-bar-container.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Recompose Action Button (Text Only) */
.recompose-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 12px 24px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.recompose-action-btn:hover {
  border-color: var(--abstract-purple);
  background: rgba(255, 255, 255, 0.05);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px var(--glow-purple);
}

.recompose-action-btn:active {
  transform: translateY(0);
}

.recompose-action-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.recompose-action-btn.regenerating {
  pointer-events: none;
  opacity: 0.7;
}

.recompose-action-label {
  font-family: 'Lora', Georgia, serif;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  user-select: none;
  transition: color 0.3s ease;
}

.recompose-action-btn:hover .recompose-action-label {
  color: var(--text-primary);
}

/* Explain Action Button (Text Only) */
.explain-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 12px 24px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.explain-action-btn:hover {
  border-color: var(--abstract-purple);
  background: rgba(255, 255, 255, 0.05);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px var(--glow-purple);
}

.explain-action-btn:active {
  transform: translateY(0);
}

.explain-action-btn.active {
  background: rgba(167, 139, 250, 0.15);
  border-color: var(--abstract-purple);
}

.explain-action-label {
  font-family: 'Lora', Georgia, serif;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  user-select: none;
  transition: color 0.3s ease;
}

.explain-action-btn:hover .explain-action-label {
  color: var(--text-primary);
}

.explain-action-btn.active .explain-action-label {
  color: var(--abstract-purple);
}

/* Legacy Explain Toggle Styles (Kept for Backwards Compatibility) */
.explain-toggle-container {
  display: none;
}

.explain-switch {
  display: none;
}

.explain-switch-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  background: white;
  border-radius: 50%;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.explain-switch.active .explain-switch-knob {
  transform: translateX(20px);
}

/* ========================================
   EXPLANATION SECTION - Modern Card
   ======================================== */
.explanation-container {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.5s cubic-bezier(0.4, 0, 0.2, 1), 
              opacity 0.5s ease, 
              margin-top 0.5s ease;
  margin-top: 0;
}

.explanation-container.visible {
  max-height: 1000px;
  opacity: 1;
  margin-top: var(--space-xl);
}

.explanation-card {
  background: rgba(255, 255, 255, 0.015);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-left: 2px solid rgba(167, 139, 250, 0.5);
  border-radius: 6px;
  padding: 24px 28px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

.explanation-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 17px;
  font-weight: 600;
  color: var(--abstract-purple);
  margin-bottom: var(--space-lg);
  letter-spacing: 0.5px;
}

.explanation-text {
  font-family: 'Crimson Text', Georgia, serif;
  font-size: 15px;
  line-height: 1.8;
  color: var(--text-secondary);
  margin-bottom: var(--space-md);
}

.explanation-section {
  margin-bottom: var(--space-lg);
}

.explanation-section:last-child {
  margin-bottom: 0;
}

.explanation-subtitle {
  font-family: 'Lora', Georgia, serif;
  font-size: 11px;
  font-weight: 600;
  color: var(--abstract-lavender);
  margin-bottom: var(--space-sm);
  letter-spacing: 2px;
  text-transform: uppercase;
}

/* ========================================
   SIDEBAR - Minimal
   ======================================== */
.sidebar {
  position: fixed;
  left: 32px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 100;
  display: none;
  flex-direction: column;
  gap: var(--space-xl);
}

.entropy-meter {
  display: none;
}

.entropy-fill {
  display: none;
}

.entropy-label {
  display: none;
}

.entropy-value {
  display: none;
}

/* ========================================
   FEATURE PANELS - Modern Cards
   ======================================== */
/* ========================================
   RIGHT SECTION - Output + Capabilities
   ======================================== */
.right-section {
  display: none; /* Hidden initially to prevent layout issues */
  opacity: 0;
  visibility: hidden; 
  transform: translate3d(100px, 0, 0); /* Start 100px right - inside screen */
  /* Match opening animation: 1.5s with smooth easing */
  transition: opacity 1.5s cubic-bezier(0.2, 0.8, 0.2, 1),
              transform 1.5s cubic-bezier(0.2, 0.8, 0.2, 1),
              visibility 0s linear 0s;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  will-change: transform, opacity;
}

.right-section.visible {
  opacity: 1;
  visibility: visible;
  transform: translate3d(0, 0, 0);
}

/* Capability Tiles Grid */
.capability-tiles {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 15.88420449px;
  opacity: 1;
  transform: none;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

/* Individual tiles animate via JS for stagger effect */
.capability-tile {
  opacity: 0;
  transform: translateY(15px);
  transition: opacity 1.5s cubic-bezier(0.2, 0.8, 0.2, 1),
              transform 1.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.right-section.visible .capability-tile {
  opacity: 1;
  transform: translateY(0);
}

.capability-tile {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  padding: var(--space-md) 24.192px var(--space-md) 36.192px; /* +12px left padding */
  transition: all 0.8s cubic-bezier(0.22, 1, 0.36, 1);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  opacity: 0;
  animation: fadeInSlide 1.4s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  will-change: transform, opacity;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transform: translateZ(0);
}

.capability-tile:nth-child(1) { animation-delay: 0.1s; }
.capability-tile:nth-child(2) { animation-delay: 0.15s; }
.capability-tile:nth-child(3) { animation-delay: 0.2s; }
.capability-tile:nth-child(4) { animation-delay: 0.25s; }
.capability-tile:nth-child(5) { animation-delay: 0.3s; }

@keyframes fadeInSlide {
  from {
    opacity: 0;
    transform: translate3d(50px, 0, 0);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

/* Seamless one-directional gradient animation - flows continuously left to right */
.capability-tile::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 4px;
  background: linear-gradient(
    135deg,
    transparent,
    transparent,
    rgba(139, 92, 246, 0.06),
    rgba(167, 139, 250, 0.1),
    rgba(139, 92, 246, 0.06),
    transparent,
    transparent
  );
  background-size: 400% 400%;
  opacity: 0;
  transition: opacity 0.6s ease;
  pointer-events: none;
  z-index: 0;
}

.capability-tile:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-4px) scale(1.02);
}

.capability-tile:hover::before {
  opacity: 1;
  animation: tileGradientDiagonal 4s linear infinite;
}

/* Simple continuous diagonal flow */
@keyframes tileGradientDiagonal {
  0% {
    background-position: 0% 0%;
  }
  100% {
    background-position: 100% 100%;
  }
}

/* Seamless border shine - 1px border to match Recompose/Explain buttons */
.capability-tile::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 4px;
  padding: 1px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(139, 92, 246, 0.4) 12.5%,
    rgba(167, 139, 250, 0.6) 25%,
    rgba(139, 92, 246, 0.4) 37.5%,
    transparent 50%,
    transparent 50%,
    rgba(139, 92, 246, 0.4) 62.5%,
    rgba(167, 139, 250, 0.6) 75%,
    rgba(139, 92, 246, 0.4) 87.5%,
    transparent 100%
  );
  background-size: 200% 100%;
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
  z-index: 1;
}

.capability-tile:hover::after {
  opacity: 1;
  animation: tileBorderShine 3s linear infinite;
}

@keyframes tileBorderShine {
  0% {
    background-position: 0% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

.capability-tile:active {
  transform: translateY(-2px) scale(1.01);
}

.capability-title {
  font-family: 'Lora', Georgia, serif;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--text-primary);
  margin-bottom: var(--space-xs);
  position: relative;
  z-index: 1;
}

.capability-description {
  font-family: 'Crimson Text', Georgia, serif;
  font-size: 16.5px;
  line-height: 1.5;
  color: var(--text-tertiary);
  margin: 0;
  position: relative;
  z-index: 1;
}

.feature-grid {
  display: none;
}

.feature-grid.visible {
  display: grid;
}

.feature-panel {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  padding: var(--space-xl);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.feature-panel::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, 
    transparent,
    var(--abstract-purple),
    transparent);
  transition: left 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.feature-panel:hover::before {
  left: 100%;
}

.feature-panel:hover {
  border-color: var(--abstract-purple);
  transform: translateY(-4px);
  box-shadow: 0 8px 32px var(--glow-purple);
  background: rgba(255, 255, 255, 0.04);
}

.feature-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 22px;
  font-weight: 500;
  margin-bottom: var(--space-md);
  color: var(--text-primary);
  letter-spacing: 0.8px;
  padding-right: 48px; /* Space for close button */
}

.modal-description {
  font-family: 'Crimson Text', Georgia, serif;
  font-size: 16px;
  line-height: 1.7;
  color: var(--text-tertiary);
  margin-bottom: 32px;
  font-style: italic;
  max-width: 90%;
}

.feature-description {
  font-family: 'Crimson Text', Georgia, serif;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-secondary);
  margin-bottom: var(--space-lg);
}

.feature-button {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  padding: 12px 28px;
  font-family: 'Lora', Georgia, serif;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.feature-button:hover {
  border-color: rgba(167, 139, 250, 0.5);
  color: var(--text-primary);
  background: rgba(167, 139, 250, 0.1);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(167, 139, 250, 0.15);
}

.feature-button:active {
  transform: translateY(0);
  background: rgba(167, 139, 250, 0.15);
}

/* ========================================
   MODALS - Consistent Dark UI
   ======================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 5, 8, 0.68); /* Reduced by 20% from 0.85 */
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s cubic-bezier(0.22, 1, 0.36, 1);
  backdrop-filter: blur(16px);
}

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

.modal-content {
  background: linear-gradient(
    145deg,
    rgba(15, 15, 20, 0.98) 0%,
    rgba(8, 8, 12, 0.99) 100%
  );
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  padding: 48px;
  max-width: 90%;
  max-height: 88vh;
  overflow-y: auto;
  position: relative;
  transform: scale(0.95) translateY(20px);
  opacity: 0;
  transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1),
              opacity 0.5s cubic-bezier(0.22, 1, 0.36, 1),
              box-shadow 0.5s ease;
  width: 720px;
  box-shadow: 
    0 0 0 1px rgba(167, 139, 250, 0.08),
    0 24px 80px rgba(0, 0, 0, 0.7),
    0 8px 32px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

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

/* Modal custom scrollbar */
.modal-content::-webkit-scrollbar {
  width: 4px;  /* 60% of 6px = 3.6px, rounded to 4px */
}

.modal-content::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.02);
  border-radius: 2px;
}

.modal-content::-webkit-scrollbar-thumb {
  background: rgba(167, 139, 250, 0.25);  /* Original opacity */
  border-radius: 2px;
  transition: background 0.3s ease;
}

.modal-content::-webkit-scrollbar-thumb:hover {
  background: rgba(167, 139, 250, 0.4);  /* Original opacity */
}

.modal-close {
  position: sticky;
  top: 0;
  float: right;
  margin-top: -8px; /* Align top edge with heading text */
  margin-right: -8px;
  margin-bottom: -36px; /* Pull content up to compensate for sticky element in flow */
  width: 36px;
  height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(15, 15, 20, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  color: var(--text-tertiary);
  font-size: 16px;
  font-weight: 300;
  z-index: 1000;
}

.modal-close:hover {
  border-color: rgba(167, 139, 250, 0.5);
  color: var(--abstract-purple);
  background: rgba(167, 139, 250, 0.08);
  transform: rotate(90deg);
  box-shadow: 0 0 20px rgba(167, 139, 250, 0.15);
}

.modal-content-wide {
  width: 95%;
  max-width: 1400px;
}

/* Fingerprint modal specific adjustments */
#fingerprintModal {
  background: rgba(5, 5, 8, 0.85);
}

/* Envision Modal - Split Panel Layout (No Scroll) */
#fingerprintModal .envision-modal {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 80px);
  max-height: 820px;
  overflow: hidden;
  padding: 48px; /* Match standard modal padding */
}

/* Header Section - Standard modal typography */
.envision-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 32px;
  flex-shrink: 0;
}

.envision-header-text {
  flex: 1;
  padding-right: 48px;
}

.envision-header .feature-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 22px;
  font-weight: 500;
  margin: 0 0 var(--space-md) 0;
  color: var(--text-primary);
  letter-spacing: 0.8px;
}

.envision-header .modal-description {
  font-family: 'Crimson Text', Georgia, serif;
  font-size: 16px;
  line-height: 1.7;
  color: var(--text-tertiary);
  font-style: italic;
  margin: 0;
  max-width: 100%; /* Full width for description */
}

.envision-header .modal-close {
  position: relative;
  flex-shrink: 0;
  margin: -8px -8px 0 0;
}

/* Split Panel Container */
.envision-split-panel {
  display: flex;
  gap: var(--space-xl);
  flex: 1;
  min-height: 0;
}

/* Left Panel - Visualization */
.envision-viz-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
}

.envision-viz-panel .fingerprint-canvas-wrapper {
  flex: 1;
  margin: 0;
  border-radius: 6px;
  min-height: 350px;
  position: relative;
}

.envision-viz-panel .fingerprint-canvas {
  height: 100%;
  border-radius: 6px;
}

/* Right Panel - Index with Actions */
.envision-index-panel {
  flex: 0 0 200px;
  width: 200px;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  min-height: 0;
  overflow: visible; /* Allow tooltips to overflow */
}

.envision-section-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: rgba(167, 139, 250, 0.7);
  margin: 0 0 var(--space-sm) 0;
  font-weight: 600;
}

/* Analysis Section */
.envision-analysis {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 6px;
  padding: var(--space-md);
  flex-shrink: 0;
  overflow: visible;
}

.envision-analysis-grid {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.analysis-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.analysis-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255, 255, 255, 0.4);
  font-weight: 600;
}

.analysis-value {
  font-family: 'Crimson Text', Georgia, serif;
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.4;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* Legend Section */
.envision-legend {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 6px;
  padding: var(--space-md);
  flex: 0 1 auto;
  overflow: visible; /* Allow tooltips to overflow */
}

.envision-legend-items {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.envision-legend-items .legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
  position: relative;
  cursor: pointer;
}

.envision-legend-items .legend-orb {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Threads/Connection element - dashed line instead of orb */
.envision-legend-items .legend-item:last-child .legend-orb {
  width: 18px;
  height: 2px;
  border-radius: 0;
  background: transparent !important;
  border-top: 2px dashed rgba(167, 139, 250, 0.5);
}

.envision-legend-items .legend-label {
  font-family: 'Crimson Text', Georgia, serif;
  color: rgba(255, 255, 255, 0.8);
  font-size: 13px;
  white-space: nowrap;
}

/* Legend Tooltips - Glassmorphic style, positioned to LEFT to avoid cutoff */
.envision-legend-items .legend-item::before {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0; /* Align to right edge of item */
  transform: translateX(0); /* No transform needed */
  padding: 8px 12px;
  background: rgba(18, 18, 20, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  font-family: 'Lora', Georgia, serif;
  font-size: 11px;
  font-weight: 400;
  line-height: 1.4;
  letter-spacing: 0.3px;
  color: rgba(255, 255, 255, 0.9);
  white-space: nowrap;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  pointer-events: none;
  z-index: 10000; /* High z-index to ensure visibility */
}

/* Tooltip caret */
.envision-legend-items .legend-item::after {
  content: '';
  position: absolute;
  bottom: calc(100% + 2px);
  right: 20px;
  width: 8px;
  height: 8px;
  background: rgba(18, 18, 20, 0.95);
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  transform: rotate(45deg);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  z-index: 9999;
}

.envision-legend-items .legend-item:hover::before,
.envision-legend-items .legend-item:hover::after {
  opacity: 1;
  visibility: visible;
}

/* Action Buttons in Right Panel */
.envision-panel-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-top: auto; /* Push to bottom */
  flex-shrink: 0;
}

.envision-panel-btn {
  width: 100%;
  padding: 12px 16px;
  background: rgba(167, 139, 250, 0.12);
  border: 1px solid rgba(167, 139, 250, 0.35);
  border-radius: 6px;
  color: var(--text-primary);
  font-family: 'Crimson Text', Georgia, serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  text-align: center;
}

.envision-panel-btn:hover {
  background: rgba(167, 139, 250, 0.2);
  border-color: rgba(167, 139, 250, 0.5);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(167, 139, 250, 0.2);
}

.envision-panel-btn:active {
  transform: translateY(0);
}

.envision-panel-btn-secondary {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.12);
}

.envision-panel-btn-secondary:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Custom Scrollbar - Consistent with other modals */
#fingerprintModal .modal-content-wide::-webkit-scrollbar {
  width: 4px;  /* 60% of 6px = 3.6px, rounded to 4px */
}

#fingerprintModal .modal-content-wide::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.02);
  border-radius: 2px;
}

#fingerprintModal .modal-content-wide::-webkit-scrollbar-thumb {
  background: rgba(167, 139, 250, 0.25);  /* Original opacity */
  border-radius: 2px;
  transition: background 0.3s ease;
}

#fingerprintModal .modal-content-wide::-webkit-scrollbar-thumb:hover {
  background: rgba(167, 139, 250, 0.4);  /* Original opacity */
}

/* Contrast modal poem scrollbars */
#contrastOriginalPoem::-webkit-scrollbar,
#contrastComparisonPoem::-webkit-scrollbar {
  width: 4px;  /* 60% of 6px = 3.6px, rounded to 4px */
}

#contrastOriginalPoem::-webkit-scrollbar-track,
#contrastComparisonPoem::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.02);
  border-radius: 2px;
}

#contrastOriginalPoem::-webkit-scrollbar-thumb,
#contrastComparisonPoem::-webkit-scrollbar-thumb {
  background: rgba(167, 139, 250, 0.25);  /* Original opacity */
  border-radius: 2px;
  transition: background 0.3s ease;
}

#contrastOriginalPoem::-webkit-scrollbar-thumb:hover,
#contrastComparisonPoem::-webkit-scrollbar-thumb:hover {
  background: rgba(167, 139, 250, 0.4);  /* Original opacity */
}

/* ========================================
   SEMANTIC FINGERPRINT VISUALIZATION
   ======================================== */

/* Info Section - Poem Analysis */
/* Old fingerprint-info - kept for backwards compatibility */
.fingerprint-info {
  display: none; /* Hidden - replaced by envision-analysis */
}

.info-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.info-section h4 {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--abstract-purple);
  margin: 0;
}

.info-value {
  font-family: 'Crimson Text', Georgia, serif;
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Visual Legend/Index */
/* Old fingerprint-legend - kept for backwards compatibility */
.fingerprint-legend {
  display: none; /* Hidden - replaced by envision-legend */
}

/* Canvas Wrapper */
.fingerprint-canvas-wrapper {
  margin-top: var(--space-xl);
  position: relative;
  overflow: hidden;
}

/* CSS Animation Overlay - runs on compositor thread, NEVER pauses during scroll */
.fingerprint-canvas-wrapper::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: 
    radial-gradient(ellipse at 20% 30%, rgba(0, 212, 255, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 70%, rgba(183, 77, 255, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 50%, rgba(57, 255, 20, 0.05) 0%, transparent 40%);
  animation: envisionPulse 8s ease-in-out infinite;
  pointer-events: none;
  z-index: 1;
  border-radius: 4px;
}

/* Secondary animation layer for more movement */
.fingerprint-canvas-wrapper::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: 
    radial-gradient(circle at 30% 40%, rgba(0, 212, 255, 0.1) 0%, transparent 30%),
    radial-gradient(circle at 70% 60%, rgba(183, 77, 255, 0.1) 0%, transparent 30%);
  animation: envisionFloat 6s ease-in-out infinite alternate;
  pointer-events: none;
  z-index: 1;
  border-radius: 4px;
  opacity: 0.7;
}

@keyframes envisionPulse {
  0%, 100% {
    transform: translate(0, 0) rotate(0deg) scale(1);
    opacity: 0.6;
  }
  25% {
    transform: translate(5%, 3%) rotate(2deg) scale(1.02);
    opacity: 0.8;
  }
  50% {
    transform: translate(-3%, 5%) rotate(-1deg) scale(0.98);
    opacity: 0.7;
  }
  75% {
    transform: translate(-5%, -3%) rotate(1deg) scale(1.01);
    opacity: 0.9;
  }
}

@keyframes envisionFloat {
  0% {
    transform: translate(-10px, -10px);
    filter: blur(0px);
  }
  100% {
    transform: translate(10px, 10px);
    filter: blur(1px);
  }
}

.fingerprint-canvas {
  width: 100%;
  height: 600px;
  background: linear-gradient(135deg, 
    rgba(10, 5, 20, 1) 0%,
    rgba(20, 10, 40, 1) 25%,
    rgba(15, 10, 35, 1) 50%,
    rgba(10, 15, 40, 1) 75%,
    rgba(5, 10, 30, 1) 100%
  );
  border-radius: 4px;
  cursor: default !important;
  border: 1px solid rgba(167, 139, 250, 0.15);
  display: block;
  position: relative;
  z-index: 2; /* Canvas above the CSS animation layers */
  /* Mix blend to show CSS animation through canvas dark areas */
  mix-blend-mode: lighten;
}

/* Old Controls Overlay - Hidden (replaced by envision-actions) */
.fingerprint-controls-overlay {
  display: none;
}

.fingerprint-control-btn {
  padding: 10px 20px;
  background: rgba(167, 139, 250, 0.15);
  border: 1px solid rgba(167, 139, 250, 0.4);
  border-radius: 20px;
  color: var(--text-primary);
  font-family: 'Crimson Text', Georgia, serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  backdrop-filter: blur(12px);
  box-shadow: 0 2px 8px rgba(167, 139, 250, 0.2);
}

.fingerprint-control-btn:hover {
  background: rgba(167, 139, 250, 0.25);
  border-color: rgba(167, 139, 250, 0.6);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(167, 139, 250, 0.3);
}

.fingerprint-control-btn:active {
  transform: translateY(0);
  background: rgba(167, 139, 250, 0.3);
}

/* Icon-only buttons */
.fingerprint-icon-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  display: flex;
  border-radius: 50%;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  line-height: 1;
}

/* Ensure consistent icon sizing for play/pause */
#pauseAnimation {
  font-size: 20px !important;
}

.legend-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--abstract-purple);
  margin: 0 0 var(--space-sm) 0;
}

.legend-items {
  display: flex;
  flex-wrap: nowrap;
  gap: calc(var(--space-2xl) * 2);
  justify-content: flex-start;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: calc(var(--space-xs) + 5px);
  position: relative;
  cursor: pointer;
}

/* Old tooltip for legend items - replaced by envision-legend-items styles */
/* Kept for backwards compatibility with non-envision modals */
.fingerprint-legend .legend-item::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.95);
  border: 1px solid var(--abstract-purple);
  padding: var(--space-xs) var(--space-md);
  border-radius: 4px;
  font-family: 'Lora', Georgia, serif;
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  pointer-events: none;
  z-index: 1000;
}

.legend-item:hover::after {
  opacity: 1;
  visibility: visible;
}

.legend-indicator {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  flex-shrink: 0;
  position: relative;
}

/* Glowing orb base style */
.legend-orb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  border: none;
}

/* Heart words - green glow */
.legend-heart {
  background: radial-gradient(circle, 
    rgba(74, 222, 128, 1) 0%, 
    rgba(74, 222, 128, 0.6) 40%,
    rgba(74, 222, 128, 0.2) 70%,
    transparent 100%
  );
  box-shadow: 0 0 8px rgba(74, 222, 128, 0.7), 0 0 16px rgba(74, 222, 128, 0.4);
}

/* Nature words - sky blue glow (more subtle) */
.legend-nature {
  background: radial-gradient(circle, 
    rgba(56, 189, 248, 1) 0%, 
    rgba(56, 189, 248, 0.6) 40%,
    rgba(56, 189, 248, 0.2) 70%,
    transparent 100%
  );
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.7), 0 0 16px rgba(56, 189, 248, 0.4);
}

/* Spirit/Soul words - purple glow */
.legend-soul {
  background: radial-gradient(circle, 
    rgba(167, 139, 250, 1) 0%, 
    rgba(167, 139, 250, 0.6) 40%,
    rgba(167, 139, 250, 0.2) 70%,
    transparent 100%
  );
  box-shadow: 0 0 8px rgba(167, 139, 250, 0.7), 0 0 16px rgba(167, 139, 250, 0.4);
}

/* Verse/Flow words - white glow */
.legend-verse {
  background: radial-gradient(circle, 
    rgba(255, 255, 255, 0.95) 0%, 
    rgba(255, 255, 255, 0.5) 40%,
    rgba(255, 255, 255, 0.15) 70%,
    transparent 100%
  );
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.6), 0 0 12px rgba(255, 255, 255, 0.3);
}

/* Connection threads - subtle stardust */
.legend-connection {
  background: linear-gradient(90deg, 
    rgba(167, 139, 250, 0.3) 0%, 
    rgba(255, 255, 255, 0.4) 50%,
    rgba(96, 165, 250, 0.3) 100%
  );
  width: 24px;
  height: 2px;
  border-radius: 1px;
  box-shadow: 0 0 4px rgba(255, 255, 255, 0.3);
}

/* Lens - Gradient ring representing philosophical perspective */
/* Philosophy - Static ethereal mist orb (color updates dynamically via JS) */
.legend-lens {
  background: radial-gradient(circle at 40% 40%,
    rgba(167, 139, 250, 0.8) 0%,
    rgba(167, 139, 250, 0.4) 50%,
    transparent 100%
  );
  border: 1px solid rgba(167, 139, 250, 0.3);
  box-shadow: 0 0 10px rgba(167, 139, 250, 0.5), 0 0 16px rgba(167, 139, 250, 0.3);
  /* No animation - stays static */
}

/* Abstraction/Depth - Concentric ripple effect */
.legend-abstraction {
  background: radial-gradient(circle at center,
    rgba(255, 255, 255, 0.9) 0%,
    rgba(167, 139, 250, 0.6) 30%,
    rgba(94, 234, 212, 0.4) 60%,
    transparent 80%
  );
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 0 12px rgba(167, 139, 250, 0.4), 0 0 20px rgba(94, 234, 212, 0.2);
  animation: depth-pulse 3s ease-in-out infinite;
}

@keyframes depth-pulse {
  0%, 100% { 
    transform: scale(1);
    box-shadow: 0 0 12px rgba(167, 139, 250, 0.4), 0 0 20px rgba(94, 234, 212, 0.2);
  }
  50% { 
    transform: scale(1.1);
    box-shadow: 0 0 16px rgba(167, 139, 250, 0.6), 0 0 28px rgba(94, 234, 212, 0.3);
  }
}

.legend-label {
  font-family: 'Crimson Text', Georgia, serif;
  font-size: 12px;
  color: var(--text-tertiary);
  line-height: 1.3;
  white-space: nowrap;
}

/* Responsive legend grid */
@media (max-width: 900px) {
  .legend-items {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 600px) {
  .legend-items {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .fingerprint-info {
    grid-template-columns: 1fr;
  }
}

/* ========================================
   TIMELINE
   ======================================== */
.drift-timeline {
  width: 100%;
  margin: 80px 0;
  padding: var(--space-xl) 0;
  overflow-x: auto;
  overflow-y: hidden;
}

.timeline-scroll {
  display: flex;
  gap: var(--space-lg);
  padding: var(--space-md);
  min-width: min-content;
}

.timeline-node {
  min-width: 260px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  padding: var(--space-lg);
  position: relative;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.timeline-node:hover {
  border-color: var(--abstract-purple);
  transform: translateY(-4px);
  box-shadow: 0 8px 24px var(--glow-purple);
}

.timeline-lens-label {
  font-family: 'Lora', Georgia, serif;
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--abstract-purple);
  margin-bottom: var(--space-md);
}

.timeline-excerpt {
  font-family: 'Crimson Text', Georgia, serif;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-secondary);
}

/* ========================================
   HELP BUTTON
   ======================================== */
.help-button {
  display: none;
}

/* ========================================
   TOGGLE CONTROLS
   ======================================== */
.contradiction-toggle {
  display: none; /* Hidden initially */
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-xl);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  margin: var(--space-xl) auto;
  width: fit-content;
}

.contradiction-toggle:hover {
  border-color: var(--abstract-purple);
  box-shadow: 0 4px 12px var(--glow-purple);
  background: rgba(255, 255, 255, 0.04);
}

.toggle-switch {
  width: 42px;
  height: 22px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 11px;
  position: relative;
  transition: background 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.toggle-switch.active {
  background: var(--abstract-purple);
}

.toggle-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  background: white;
  border-radius: 50%;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.toggle-switch.active .toggle-knob {
  transform: translateX(20px);
}

.toggle-label {
  font-family: 'Lora', Georgia, serif;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
}

/* ========================================
   SPLIT SCREEN
   ======================================== */
.split-screen {
  display: grid;
  grid-template-columns: 1fr 1px 1fr;
  gap: 0;
  margin: var(--space-3xl) 0;
  min-height: 500px;
}

.split-panel {
  padding: var(--space-xl);
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.split-divider {
  background: linear-gradient(180deg, 
    transparent,
    var(--abstract-purple),
    var(--abstract-blue),
    transparent);
  opacity: 0.3;
}

.split-label {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 17px;
  font-weight: 500;
  letter-spacing: 1px;
  text-align: center;
  color: var(--abstract-purple);
  margin-bottom: var(--space-md);
}

/* ========================================
   ORACLE MODE
   ======================================== */
.oracle-mode {
  min-height: 70vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl);
}

.oracle-container {
  max-width: 700px;
  width: 100%;
  text-align: center;
}

.oracle-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 42px;
  font-weight: 300;
  margin-bottom: var(--space-3xl);
  color: var(--text-primary);
  letter-spacing: 4px;
}

.oracle-input {
  width: 100%;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  padding: var(--space-lg);
  color: var(--text-primary);
  font-family: 'Crimson Text', Georgia, serif;
  font-size: 19px;
  text-align: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.oracle-input:focus {
  outline: none;
  border-color: var(--abstract-purple);
  box-shadow: 0 0 24px var(--glow-purple);
}

.oracle-reveal {
  margin-top: var(--space-3xl);
  opacity: 0;
  transform: scale(0.96);
  transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.oracle-reveal.visible {
  opacity: 1;
  transform: scale(1);
}

.oracle-lens {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 26px;
  font-weight: 500;
  letter-spacing: 1px;
  margin-bottom: var(--space-xl);
  color: var(--abstract-purple);
}

.oracle-answer {
  font-family: 'Crimson Text', Georgia, serif;
  font-size: 20px;
  line-height: 2;
  font-style: italic;
  color: var(--text-primary);
}

/* ========================================
   LOADING STATE
   ======================================== */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  gap: var(--space-xs);
  position: relative;
  z-index: 1;
}

.loading-text {
  font-family: 'Lora', Georgia, serif;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 1.5px;
  color: var(--text-primary);
  animation: fadeInOut 2s ease-in-out infinite;
}

@keyframes fadeInOut {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

.loading-dots {
  display: flex;
  gap: 6px;
}

.loading-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-primary);
  animation: bounce 1.4s ease-in-out infinite;
}

.loading-dot:nth-child(2) { animation-delay: 0.2s; }
.loading-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-8px); }
}

/* ========================================
   ADDITIONAL COMPONENTS
   ======================================== */
.glass-card {
  background: rgba(255, 255, 255, 0.015);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 6px;
  padding: 24px 28px;
  backdrop-filter: blur(12px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

.resonance-matcher {
  margin: 60px 0;
  text-align: center;
}

.resonance-suggestion {
  font-family: 'Lora', Georgia, serif;
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: var(--space-md);
}

.resonance-suggestion .lens-name {
  color: var(--abstract-purple);
  font-weight: 600;
  letter-spacing: 0.5px;
}

/* Leaderboard */
.leaderboard {
  margin-top: var(--space-xl);
}

.leaderboard-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 19px;
  font-weight: 500;
  margin-bottom: var(--space-lg);
  text-align: center;
  letter-spacing: 1px;
  color: var(--text-primary);
}

.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.leaderboard-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md) var(--space-lg);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.leaderboard-item:hover {
  border-color: var(--abstract-purple);
  transform: translateX(4px);
  background: rgba(255, 255, 255, 0.04);
}

.leaderboard-rank {
  font-size: 18px;
  font-weight: 500;
  color: var(--abstract-purple);
}

.leaderboard-score {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
}

/* Compression Challenge */
.compression-challenge {
  padding: 0;
}

.compression-challenge .glass-card {
  margin-bottom: var(--space-2xl);
}

.constraint-selector {
  display: flex;
  justify-content: center;
  gap: var(--space-md);
  margin-bottom: var(--space-2xl);
  flex-wrap: wrap;
}

.constraint-pill {
  padding: 10px 22px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.22, 1, 0.36, 1);
  font-family: 'Lora', Georgia, serif;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.5px;
  color: var(--text-tertiary);
}

.constraint-pill:hover {
  border-color: rgba(167, 139, 250, 0.4);
  color: var(--text-secondary);
  background: rgba(167, 139, 250, 0.06);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(167, 139, 250, 0.1);
}

.constraint-pill.active {
  background: rgba(167, 139, 250, 0.12);
  border-color: rgba(167, 139, 250, 0.5);
  color: var(--text-primary);
  box-shadow: 0 0 16px rgba(167, 139, 250, 0.1);
}

.score-display {
  text-align: center;
  margin-top: var(--space-xl);
}

.score-value {
  font-size: 44px;
  font-weight: 300;
  color: var(--abstract-purple);
  font-family: 'Playfair Display', Georgia, serif;
}

.format-info-display {
  text-align: center;
  margin-top: var(--space-lg);
  padding: var(--space-lg);
  background: rgba(167, 139, 250, 0.05);
  border-radius: 4px;
  border: 1px solid rgba(167, 139, 250, 0.2);
}

.format-info-text {
  font-size: 15px;
  font-family: 'Crimson Text', Georgia, serif;
  color: var(--text-secondary);
  line-height: 1.7;
}

.score-label {
  font-family: 'Lora', Georgia, serif;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-tertiary);
  margin-top: var(--space-xs);
}

.progress-bar {
  width: 100%;
  height: 2px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 1px;
  overflow: hidden;
  margin-top: var(--space-md);
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, 
    var(--abstract-purple), 
    var(--abstract-blue),
    var(--abstract-pink));
  border-radius: 1px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Glossary */
.glossary-panel {
  max-width: 800px;
  margin: 0 auto;
}

.glossary-search {
  width: 100%;
  padding: var(--space-md) var(--space-lg);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  color: var(--text-primary);
  font-family: 'Lora', Georgia, serif;
  font-size: 15px;
  margin-bottom: var(--space-xl);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.glossary-search:focus {
  outline: none;
  border-color: var(--abstract-purple);
  box-shadow: 0 0 16px var(--glow-purple);
}

.glossary-item {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  margin-bottom: var(--space-md);
  overflow: hidden;
  transition: all 0.3s ease;
}

.glossary-item:hover {
  border-color: rgba(255, 255, 255, 0.15);
}

.glossary-header {
  padding: var(--space-md) var(--space-lg);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.glossary-lens-name {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 0.5px;
  color: var(--text-primary);
}

.glossary-chevron {
  transition: transform 0.3s ease;
  color: var(--abstract-purple);
}

.glossary-item.open .glossary-chevron {
  transform: rotate(180deg);
}

.glossary-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.glossary-item.open .glossary-content {
  max-height: 1000px;
}

.glossary-body {
  padding: 0 var(--space-lg) var(--space-lg);
}

.glossary-description {
  font-family: 'Crimson Text', Georgia, serif;
  font-size: 15px;
  line-height: 1.8;
  color: var(--text-secondary);
  margin-bottom: var(--space-md);
}

.glossary-quote {
  padding: var(--space-md);
  background: rgba(255, 255, 255, 0.02);
  border-left: 2px solid var(--abstract-purple);
  border-radius: 2px;
  font-family: 'Crimson Text', Georgia, serif;
  font-style: italic;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-tertiary);
  margin-bottom: var(--space-md);
}

/* Tour */
.tour-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.97);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

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

.tour-card {
  max-width: 500px;
  background: var(--void-black);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  padding: var(--space-xl);
}

.tour-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 22px;
  font-weight: 500;
  margin-bottom: var(--space-md);
  letter-spacing: 0.5px;
  color: var(--abstract-purple);
}

.tour-description {
  font-family: 'Crimson Text', Georgia, serif;
  font-size: 15px;
  line-height: 1.8;
  color: var(--text-secondary);
  margin-bottom: var(--space-lg);
}

.tour-btn {
  padding: 10px 20px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  cursor: pointer;
  font-family: 'Lora', Georgia, serif;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 1px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  color: var(--text-secondary);
}

.tour-btn:hover {
  border-color: var(--abstract-purple);
  color: var(--abstract-purple);
}

.tour-btn.primary {
  background: var(--abstract-purple);
  border-color: var(--abstract-purple);
  color: var(--void-black);
}

/* Tooltip */
.tooltip {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  background: rgba(0, 0, 0, 0.95);
  border: 1px solid var(--abstract-purple);
  border-radius: 4px;
  padding: var(--space-xs) var(--space-md);
  font-family: 'Lora', Georgia, serif;
  font-size: 11px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 1000;
  color: var(--text-primary);
}

.untranslatable {
  position: relative;
  color: var(--abstract-purple);
  font-style: italic;
}

.untranslatable:hover .tooltip {
  opacity: 1;
}

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

::-webkit-scrollbar-track {
  background: var(--void-black);
}

::-webkit-scrollbar-thumb {
  background: rgba(167, 139, 250, 0.3);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--abstract-purple);
}

/* ========================================
   TEXT SELECTION
   ======================================== */
::selection {
  background: rgba(167, 139, 250, 0.3);
  color: white;
}

/* ========================================
   GLASSMORPHIC TOAST SYSTEM
   ======================================== */

/* Toast container */
.toast-container {
  position: fixed;
  bottom: 32px;
  right: 32px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none;
  align-items: flex-end;
}

/* Individual toast - bottom right positioning */
.toast {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 400px;
  max-width: 800px;
  padding: 14px 20px;
  
  /* Elegant glassmorphic styling with purple highlight */
  background: rgba(18, 18, 20, 0.75);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(167, 139, 250, 0.25);
  border-radius: 12px;
  
  box-shadow: 
    0 8px 32px rgba(0, 0, 0, 0.4),
    0 2px 8px rgba(0, 0, 0, 0.2),
    0 0 0 1px rgba(167, 139, 250, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  
  pointer-events: auto;
  
  /* Animation states - slide in from right - seamless and smooth */
  opacity: 0;
  transform: translateX(120px) scale(0.98);
  transition: all 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.toast-show {
  opacity: 1;
  transform: translateX(0) scale(1);
}

.toast-hide {
  opacity: 0;
  transform: translateX(120px) scale(0.98);
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Toast icon - whitish/glassmorphic and elegant */
.toast-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.7);
  opacity: 0.9;
}

.toast-icon svg {
  width: 100%;
  height: 100%;
}

/* Toast content */
.toast-content {
  flex: 0 1 auto;
  display: flex;
  align-items: center;
  gap: 16px;
}

.toast-message {
  font-family: 'Lora', Georgia, serif;
  font-size: 14px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.95);
  font-weight: 400;
  white-space: nowrap; /* Keep text on single line - NO truncation */
}

/* Vertical divider between content and button */
.toast-divider {
  width: 1.5px;
  height: 24px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 1px;
  flex-shrink: 0;
}

/* Toast action button (e.g., "Surprise Me") - styled like lens pills */
.toast-action-btn {
  flex-shrink: 0;
  padding: 8px 18px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.85);
  font-family: 'Lora', Georgia, serif;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.3px;
  cursor: pointer;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  white-space: nowrap;
}

.toast-action-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, 
    var(--abstract-purple), 
    var(--abstract-blue), 
    var(--abstract-pink));
  opacity: 0;
  transition: opacity 0.3s ease;
  border-radius: 999px;
  z-index: -1;
}

.toast-action-btn:hover {
  color: rgba(255, 255, 255, 1);
  border-color: var(--abstract-purple);
  background: rgba(255, 255, 255, 0.05);
  box-shadow: 0 4px 12px rgba(167, 139, 250, 0.3);
  transform: translateY(-1px);
}

.toast-action-btn:hover::before {
  opacity: 0.1;
}

.toast-action-btn:active {
  transform: translateY(0);
}

/* Toast close button */
.toast-close {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.4);
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: -2px;
}

.toast-close svg {
  width: 16px;
  height: 16px;
}

.toast-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.8);
}

.toast-close:active {
  transform: scale(0.95);
}

/* Respect reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  .toast {
    transition: opacity 0.3s ease;
    transform: none !important;
  }
  
  .toast-show {
    opacity: 1;
    transform: none !important;
  }
  
  .toast-hide {
    opacity: 0;
    transform: none !important;
  }
}

/* Mobile responsive */
@media (max-width: 768px) {
  .toast-container {
    bottom: 20px;
    left: 12px;
    right: 12px;
    align-items: stretch;
  }
  
  .toast {
    min-width: auto;
    max-width: none;
    width: 100%;
    display: flex;
    flex-direction: row; /* Keep horizontal on mobile */
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    font-size: 13px;
  }
  
  .toast-icon {
    flex-shrink: 0;
  }
  
  .toast-message {
    flex: 1;
    white-space: normal; /* Allow wrapping on mobile */
    font-size: 13px;
    line-height: 1.4;
  }
  
  .toast-divider {
    flex-shrink: 0;
    width: 1px;
    height: 20px;
    margin: 0 8px;
  }
  
  .toast-action-btn {
    flex-shrink: 0;
    padding: 8px 12px;
    font-size: 12px;
    white-space: nowrap;
  }
}

/* ========================================
   ACCESSIBILITY
   ======================================== */
*:focus-visible {
  outline: 2px solid var(--abstract-purple);
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ========================================
   TOUCH-FRIENDLY INTERACTIONS
   ======================================== */
/* Apply to all interactive elements for better mobile UX */
button,
a,
input,
textarea,
select,
.lens-pill,
.capability-tile,
.transform-button,
.help-button,
.toast-action-btn,
.recompose-action-btn,
.explain-action-btn {
  /* Enable smooth touch scrolling */
  -webkit-tap-highlight-color: rgba(167, 139, 250, 0.2);
  touch-action: manipulation; /* Prevent double-tap zoom */
}

/* Allow text selection in input fields */
input,
textarea,
.text-input,
.poem-text {
  -webkit-user-select: text;
  user-select: text;
  touch-action: manipulation;
}

/* Prevent text selection on buttons */
button,
.lens-pill,
.capability-tile,
.transform-button {
  -webkit-user-select: none;
  user-select: none;
}

/* ========================================
   TABLET OPTIMIZATION (769px - 1024px)
   ======================================== */
@media (min-width: 769px) and (max-width: 1024px) {
  .app-container {
    padding: var(--space-2xl) var(--space-xl) 60px;
  }
  
  .app-container.split-view {
    padding: var(--space-2xl) 80px;
  }
  
  .split-view-content {
    gap: var(--space-xl);
    max-height: calc(100vh - var(--space-2xl) * 2 - 120px);
  }
  
  /* Touch-friendly tap targets */
  .lens-pill {
    padding: 10px 18px;
    font-size: 13px;
    min-height: 44px;
  }
  
  .capability-tile {
    min-height: 100px;
    padding: var(--space-lg);
  }
  
  .transform-button {
    min-height: 50px;
    padding: 16px var(--space-xl);
  }
  
  /* Optimize text input */
  .text-input {
    min-height: 140px;
    font-size: 15px;
  }
}

/* ========================================
   RESPONSIVE - Mobile First (max-width: 768px)
   ======================================== */
@media (max-width: 768px) {
  .app-container {
    padding: var(--space-xl) var(--space-md) 80px;
    height: auto;
    overflow: visible;
  }
  
  /* Stack vertically on mobile */
  .app-container.split-view {
    flex-direction: column;
    /* Reduced horizontal padding on mobile for better use of space */
    padding: var(--space-xl) var(--space-lg);
    height: auto;
    overflow: visible;
  }
  
  .app-container.split-view .app-header {
    position: relative; /* Changed from absolute for better flow */
    top: 0;
    left: 0;
    right: 0;
    margin-bottom: var(--space-lg); /* Reduced from 0 */
    transform: translateZ(0);
    z-index: 100;
  }
  
  .app-container.split-view .transform-section {
    flex: none;
    width: 100%;
    max-width: none;
    margin-top: 0; /* Reduced from 120px */
    padding-top: 0;
    padding-bottom: var(--space-xl); /* Reduced from 2xl */
    overflow-y: visible;
  }
  
  /* Mobile: Right section hidden initially, appears after Unfold is clicked */
  .right-section {
    flex: none;
    width: 100%;
    margin-top: var(--space-2xl);
    flex-direction: column;
    gap: var(--space-xl);
    display: none; /* Hidden initially */
    opacity: 0;
    visibility: hidden;
    transform: none;
    padding: 0;
    margin-left: 0;
    margin-right: 0;
  }
  
  /* Mobile: Show right section when has-output class is added */
  body.has-output .right-section,
  .right-section.visible {
    display: flex !important;
    opacity: 1 !important;
    visibility: visible !important;
  }
  
  .right-section.visible {
    display: flex !important;
    opacity: 1 !important;
    visibility: visible !important;
  }
  
  /* Mobile: Output container */
  .output-container {
    flex: none;
    width: 100%;
    margin: 0;
    padding: 0;
    opacity: 1 !important;
    visibility: visible !important;
    transform: none !important;
  }
  
  /* Mobile: Capabilities section */
  .capabilities-section {
    flex: none;
    width: 100%;
    margin: 0;
    padding: 0 0 calc(var(--space-2xl) * 3) 0; /* Triple bottom padding for last tile */
    gap: var(--space-md);
  }
  
  .capability-tiles {
    flex: none;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    padding-bottom: calc(var(--space-xl) * 2); /* Extra bottom padding */
  }
  
  /* Center and fix capability tiles - match poem card width */
  .capability-tile {
    width: 100%;
    max-width: 100%; /* Match poem card width */
    margin: 0 auto;
    padding: var(--space-lg);
    box-sizing: border-box;
  }
  
  .capability-tiles {
    width: 100%;
    max-width: 100%;
    padding: 0 var(--space-md); /* Match poem card horizontal padding */
    box-sizing: border-box;
  }
  
  /* Mobile: Action bar - horizontal buttons between poem and capability tiles */
  .action-bar-container {
    width: 100%;
    max-width: calc(100% - var(--space-md) * 2); /* Match poem card width (accounting for container padding) */
    margin: 45px auto var(--space-lg) auto; /* 45px top margin (9x original 5px = TRIPLED from 15px), center horizontally */
    padding: 0 var(--space-md); /* Match poem card horizontal padding */
    display: none; /* Hidden initially */
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: var(--space-sm);
    opacity: 0;
    visibility: hidden;
    box-sizing: border-box;
  }
  
  /* Mobile: Show action bar when visible class is added */
  body.has-output .action-bar-container,
  .action-bar-container.visible {
    display: flex !important;
    opacity: 1 !important;
    visibility: visible !important;
  }
  
  .recompose-action-btn,
  .explain-action-btn {
    flex: 1;
    max-width: 48%;
    display: flex !important;
    opacity: 1 !important;
    visibility: visible !important;
  }
  
  body.initial-view .app-container {
    padding: var(--space-2xl) var(--space-md) var(--space-2xl);
  }
  
  body.initial-view .app-header {
    border-bottom: none;
    margin-bottom: 80px; /* Fixed large spacing to absolutely prevent overlap */
    padding-bottom: var(--space-md);
  }
  
  /* Input container needs EXTRA top margin on mobile to prevent overlap */
  body.initial-view .input-container {
    margin-top: 60px !important; /* FORCE 60px shift down (another 10px) */
    padding-top: 20px !important;
  }
  
  .input-container {
    margin-top: 20px !important; /* Force extra spacing */
  }
  
  /* Additional spacing for the entire input section */
  body.initial-view .transform-section > .input-container:first-child {
    margin-top: 50px !important;
  }
  
  /* Ensure consistent header spacing in split view too */
  body.split-view .app-header,
  body.has-output .app-header {
    margin-bottom: var(--space-xl);
    padding-bottom: var(--space-md);
  }
  
  body.initial-view .transform-section {
    margin-top: 60px !important; /* FORCE extra spacing */
    padding-top: 20px !important;
  }

  .app-header {
    padding-bottom: var(--space-md);
    margin-bottom: var(--space-xl);
  }

  /* Ensure title doesn't overlap with anything */
  .app-title {
    margin-bottom: var(--space-md);
    position: relative;
    z-index: 10;
  }
  
  .app-subtitle {
    margin-bottom: var(--space-lg);
  }
  
  /* Split view header spacing */
  .app-container.split-view .app-header {
    margin-bottom: var(--space-xl);
  }

  .app-title {
    font-size: 26px; /* Slightly larger for better readability */
    letter-spacing: 2px;
    margin-bottom: var(--space-sm);
  }
  
  .app-subtitle {
    font-size: 15px; /* Adjusted for mobile readability */
  }

  .lens-pills {
    gap: var(--space-sm);
  }

  .lens-pill {
    font-size: 13px; /* Slightly larger for readability */
    padding: 12px 16px; /* Touch-friendly */
    min-height: 44px; /* iOS recommended tap target */
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .entry-field,
  .text-input {
    min-height: 154px; /* Adjusted for 44px placeholder top padding */
    padding: 16px;
    font-size: 16px; /* Prevents iOS zoom on focus */
  }

  .transform-btn,
  .transform-button {
    padding: 16px var(--space-xl);
    font-size: 17px; /* Slightly larger for mobile */
    min-height: 54px; /* Touch-friendly */
    position: relative !important; /* Prevent any positioning bugs */
    display: block !important;
    visibility: visible !important;
    /* pointer-events controlled by opening-animation.css */
  }
  
  /* Remove any active/focus states that might cause invisible button bug */
  .transform-button:focus {
    outline: none;
  }
  
  .transform-button:active {
    transform: translateY(1px) scale(0.98) !important;
  }
  
  .animated-placeholder {
    padding: 44px var(--space-xl) var(--space-xl); /* 44px top padding */
    font-size: 17px;
  }
  
  /* Input labels - better spacing on mobile */
  .input-label {
    font-size: 13px;
    margin-bottom: var(--space-sm);
  }
  
  /* Capability tiles - touch-friendly */
  .capability-tile {
    min-height: 100px;
    padding: var(--space-lg);
    cursor: pointer;
  }
  
  .capability-title {
    font-size: 16px;
  }
  
  .capability-description {
    font-size: 13px;
  }
  
  /* Action buttons - touch-friendly */
  .recompose-action-btn,
  .explain-action-btn {
    min-height: 44px;
    padding: 12px 20px;
    font-size: 14px;
  }
  
  /* Help button - larger on mobile */
  .help-button {
    width: 48px;
    height: 48px;
    font-size: 20px;
    bottom: 24px;
    right: 24px;
  }

  /* Mobile: 3 pills per row - smaller margins with 120% vertical increase */
  .lens-selector {
    margin: -5.76px -4.8px; /* Vertical/Horizontal negative margins */
    width: calc(100% + 9.6px);
  }
  
  .lens-selector .lens-pill {
    margin: 5.76px 4.8px; /* Vertical: 11.52px gap, Horizontal: 9.6px gap */
  }
  
  /* Mobile: Hide desktop breaks, let flex wrap naturally */
  
  /* Mobile split-view: Keep same margins */
  .app-container.split-view .lens-selector {
    margin: -5.76px -4.8px;
    width: calc(100% + 9.6px);
  }
  
  .abstraction-slider {
    max-width: 250px;
  }

  .output-container {
    padding: 0 var(--space-md); /* Remove top/bottom padding */
  }

  .poem-card {
    padding: var(--space-xl) var(--space-md);
    font-size: 14px;
    line-height: 1.7;
    width: 100%;
    max-width: 100%; /* Ensure it doesn't exceed container */
    margin: 0 auto;
    opacity: 1 !important;
    visibility: visible !important;
    box-sizing: border-box;
  }
  
  .poem-title {
    text-align: center; /* Center-align title on mobile */
  }
  
  .poem-text {
    color: var(--text-primary) !important;
    opacity: 1 !important;
    text-align: center; /* Center-align poem lines on mobile */
    padding: 0; /* Remove any padding that causes offset */
    text-indent: 0; /* Remove any indentation */
  }
  
  .poem-line {
    display: block;
    margin-bottom: var(--space-xs);
    text-align: center; /* Center-align each line on mobile */
    padding: 0; /* Remove any padding */
    text-indent: 0; /* Remove any indentation */
  }

  .output-action-tile {
    padding: var(--space-lg);
  }

  .background-orb {
    filter: blur(100px);
    opacity: 0.3;
  }

  .orb-1, .orb-2, .orb-3, .orb-4 {
    width: 450px;
    height: 450px;
  }
  
  /* Modal optimizations for mobile - COMPLETELY REBUILT FOR SMOOTH SCROLLING */
  .modal-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important; /* Dynamic viewport height for mobile */
    padding: 0 !important;
    margin: 0 !important;
    overflow-x: hidden !important;
    overflow-y: auto !important; /* Scrollable overlay */
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior: contain !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: flex-start !important;
    z-index: 9999 !important;
  }
  
  .modal-content {
    width: calc(100% - 20px) !important;
    max-width: calc(100% - 20px) !important;
    min-height: auto !important;
    max-height: none !important; /* Allow natural height */
    padding: var(--space-lg) var(--space-md) !important;
    margin: 10px 10px !important;
    box-sizing: border-box !important;
    position: relative !important;
    transform: none !important;
    overflow-y: visible !important; /* No internal scroll */
    overflow-x: hidden !important;
    flex-shrink: 0 !important; /* Prevent compression */
  }
  
  .modal-content-wide {
    width: calc(100% - 20px) !important;
    max-width: calc(100% - 20px) !important;
  }
  
  .modal-close {
    width: 44px !important;
    height: 44px !important;
    font-size: 24px !important;
    top: 12px !important;
    right: 12px !important;
    position: fixed !important;
    z-index: 10001 !important; /* Above modal overlay z-index */
    flex-shrink: 0 !important;
    float: none !important;
    margin: 0 !important;
    background: rgba(15, 15, 20, 0.95) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5) !important;
  }
  
  /* Contrast modal - COMPLETELY REBUILT for perfect mobile scrolling */
  #contrastModal .modal-overlay {
    align-items: flex-start !important;
    justify-content: center !important;
  }
  
  #contrastModal .modal-content {
    width: calc(100% - 20px) !important;
    max-width: calc(100% - 20px) !important;
    padding: var(--space-lg) var(--space-md) !important;
    overflow-y: visible !important;
    overflow-x: hidden !important;
  }
  
  #contrastModal .feature-title {
    font-size: 20px;
    margin-bottom: var(--space-sm);
  }
  
  #contrastModal .modal-description {
    font-size: 13px;
    line-height: 1.6;
    margin-bottom: var(--space-lg);
    color: var(--text-secondary);
  }
  
  /* Force vertical stacking - completely remove grid */
  #contrastModal .modal-content > div[style*="grid"],
  #contrastModal .modal-content > div {
    display: flex !important;
    flex-direction: column !important;
    gap: var(--space-2xl) !important;
    margin-top: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    grid-template-columns: none !important;
  }
  
  /* Each poem panel (Original & Comparison) - no fixed heights */
  #contrastModal .modal-content > div[style*="grid"] > div,
  #contrastModal .modal-content > div > div {
    width: 100% !important;
    height: auto !important;
    max-height: none !important;
    min-height: auto !important;
    display: flex !important;
    flex-direction: column !important;
    gap: var(--space-md) !important;
    position: relative !important;
    overflow: visible !important;
  }
  
  /* Header section - no fixed positioning */
  #contrastModal div[style*="border-bottom"],
  #contrastModal div[style*="padding-bottom"] {
    padding-bottom: var(--space-sm) !important;
    margin-bottom: var(--space-sm) !important;
    flex-shrink: 0 !important;
    position: relative !important;
    display: flex !important;
    width: 100% !important;
  }
  
  /* Poem content - completely fluid height */
  #contrastModal div[id*="Poem"],
  #contrastModal div[id*="contrast"],
  #contrastModal div[id*="Original"],
  #contrastModal div[id*="Comparison"] {
    flex: none !important;
    height: auto !important;
    max-height: none !important;
    min-height: auto !important;
    overflow-y: visible !important;
    overflow-x: hidden !important;
    padding: var(--space-lg) var(--space-md) !important;
    font-size: 14px !important;
    line-height: 1.8 !important;
    position: relative !important;
    white-space: pre-wrap !important;
    word-wrap: break-word !important;
  }
  
  /* Lens selector */
  #contrastModal #contrastSelector {
    flex-wrap: wrap !important;
    gap: var(--space-xs) !important;
    margin-top: var(--space-md) !important;
    display: flex !important;
    width: 100% !important;
  }
  
  #contrastModal #contrastSelector button {
    flex: 1 1 calc(50% - var(--space-xs)) !important;
    min-width: 130px !important;
    min-height: 44px !important;
    font-size: 13px !important;
    padding: 12px 14px !important;
  }
  
  /* Metrics section - no fixed positioning */
  #contrastModal #contrastMetrics {
    margin-top: var(--space-lg) !important;
    padding: var(--space-md) !important;
    background: rgba(255, 255, 255, 0.02) !important;
    border-radius: 8px !important;
    border: 1px solid rgba(255, 255, 255, 0.06) !important;
    position: relative !important;
    overflow: visible !important;
  }
  
  #contrastModal .metric-item {
    margin-bottom: var(--space-sm) !important;
    font-size: 13px !important;
    line-height: 1.6 !important;
  }
  
  /* Copy buttons */
  #contrastModal button[id*="Copy"] {
    min-height: 40px !important;
    min-width: 40px !important;
    padding: 10px !important;
    flex-shrink: 0 !important;
  }
  
  /* Remove any absolute positioning that causes stickiness */
  #contrastModal * {
    position: relative !important;
  }
  
  #contrastModal .modal-close {
    position: fixed !important;
  }
  
  /* Transform/Compression modal - mobile optimized with DYNAMIC HEIGHTS */
  #compressionModal .modal-overlay {
    align-items: flex-start !important; /* Top align for scrolling */
    justify-content: center !important;
  }
  
  #compressionModal .modal-content {
    padding: var(--space-lg) var(--space-md) !important;
    width: calc(100% - 20px) !important;
    max-width: calc(100% - 20px) !important;
  }
  
  #compressionModal .feature-title {
    font-size: 20px;
    margin-bottom: var(--space-sm);
  }
  
  #compressionModal .modal-description {
    font-size: 13px;
    line-height: 1.6;
    margin-bottom: var(--space-lg);
    color: var(--text-secondary);
  }
  
  #compressionModal .constraint-selector {
    flex-wrap: wrap;
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
  }
  
  #compressionModal .constraint-pill {
    flex: 1 1 calc(50% - var(--space-sm));
    min-width: 120px;
    min-height: 44px; /* Touch-friendly */
    font-size: 14px;
    padding: 12px 16px;
  }
  
  /* DYNAMIC HEIGHT BASED ON FORMAT - Match web behavior */
  #compressionModal .glass-card {
    padding: var(--space-lg) var(--space-md);
    min-height: 120px; /* Base height */
    height: auto;
    overflow: visible;
    transition: min-height 0.3s ease;
  }
  
  /* Phrase format - Smallest height (1-2 lines) */
  #compressionModal .glass-card[data-format="phrase"],
  #compressionModal .constraint-pill[data-format="phrase"].active ~ .glass-card {
    min-height: 100px;
  }
  
  /* Haiku format - Short height (3 lines) */
  #compressionModal .glass-card[data-format="haiku"],
  #compressionModal .constraint-pill[data-format="haiku"].active ~ .glass-card {
    min-height: 150px;
  }
  
  /* Limerick format - Medium height (5 lines) */
  #compressionModal .glass-card[data-format="limerick"],
  #compressionModal .constraint-pill[data-format="limerick"].active ~ .glass-card {
    min-height: 200px;
  }
  
  /* Prose format - Largest height (paragraph) */
  #compressionModal .glass-card[data-format="prose"],
  #compressionModal .constraint-pill[data-format="prose"].active ~ .glass-card {
    min-height: 280px;
  }
  
  #compressionModal .poem-text {
    font-size: 15px;
    line-height: 1.8;
    min-height: inherit;
  }
  
  #compressionModal .format-info-display {
    margin-top: var(--space-md);
  }
  
  #compressionModal .format-info-text {
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-secondary);
  }
  
  /* ========================================
     ENVISION MODAL - MOBILE LAYOUT
     Stack vertically with scrolling
     ======================================== */
  #fingerprintModal .envision-modal {
    height: auto !important;
    max-height: none !important;
    overflow-y: auto !important;
    padding: var(--space-lg) var(--space-md) !important;
  }
  
  .envision-header {
    margin-bottom: var(--space-lg);
  }
  
  .envision-header-text {
    padding-right: 40px;
  }
  
  .envision-header .feature-title {
    font-size: 20px;
  }
  
  .envision-header .modal-description {
    font-size: 14px;
    line-height: 1.6;
  }
  
  /* Stack panels vertically on mobile */
  .envision-split-panel {
    flex-direction: column !important;
    gap: var(--space-lg);
  }
  
  .envision-viz-panel {
    flex: none !important;
    width: 100% !important;
  }
  
  .envision-viz-panel .fingerprint-canvas-wrapper {
    height: 55vh;
    min-height: 300px;
    max-height: 450px;
  }
  
  /* On mobile, buttons are in their natural flow in right panel */
  .envision-panel-btn {
    padding: 10px 14px;
    font-size: 13px;
    min-height: 44px;
  }
  
  /* On mobile, legend tooltips hidden (touch shows them differently) */
  .envision-legend-items .legend-item::before,
  .envision-legend-items .legend-item::after {
    display: none;
  }
  
  .envision-index-panel {
    flex: none !important;
    width: 100% !important;
    max-width: none !important;
    min-width: auto !important;
  }
  
  .envision-analysis-grid {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: var(--space-sm);
  }
  
  .analysis-item {
    text-align: center;
  }
  
  .analysis-value {
    font-size: 12px;
  }
  
  .envision-legend-items {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: var(--space-xs);
  }
  
  .envision-legend-items .legend-item {
    font-size: 11px;
  }
  
  .envision-legend-items .legend-orb {
    width: 8px;
    height: 8px;
  }
  
  /* Explain modal - mobile optimized with perfect scrolling */
  #explainModal .modal-overlay {
    align-items: flex-start !important;
    justify-content: center !important;
  }
  
  #explainModal .modal-content {
    padding: var(--space-lg) var(--space-md) !important;
    width: calc(100% - 20px) !important;
    max-width: calc(100% - 20px) !important;
    overflow-y: visible !important;
  }
  
  #explainModal .feature-title {
    font-size: 20px;
    margin-bottom: var(--space-sm);
  }
  
  #explainModal .modal-description {
    font-size: 13px;
    line-height: 1.6;
    margin-bottom: var(--space-lg);
    color: var(--text-secondary);
  }
  
  #explainModal .explanation-card,
  .explanation-container .explanation-card {
    padding: var(--space-md);
    background: rgba(255, 255, 255, 0.02);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    overflow: visible;
  }
  
  #explainModal .explanation-section {
    margin-bottom: var(--space-lg);
    overflow: visible;
  }
  
  #explainModal .explanation-section:last-child {
    margin-bottom: 0;
  }
  
  #explainModal .explanation-subtitle {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--abstract-purple);
    margin-bottom: var(--space-sm);
  }
  
  #explainModal .explanation-text {
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-primary);
    white-space: normal;
    word-wrap: break-word;
  }
  
  /* Oracle Modal - mobile optimized */
  #oracleModal .modal-overlay {
    align-items: flex-start !important;
    justify-content: center !important;
  }
  
  #oracleModal .modal-content {
    width: calc(100% - 20px) !important;
    max-width: calc(100% - 20px) !important;
    overflow-y: visible !important;
  }
  
  /* Alchemy Modal - mobile optimized */
  #alchemyModal .modal-overlay {
    align-items: flex-start !important;
    justify-content: center !important;
  }
  
  #alchemyModal .modal-content {
    width: calc(100% - 20px) !important;
    max-width: calc(100% - 20px) !important;
    overflow-y: visible !important;
  }
  
  /* Loop Modal - mobile optimized */
  #loopModal .modal-overlay {
    align-items: flex-start !important;
    justify-content: center !important;
  }
  
  #loopModal .modal-content {
    width: calc(100% - 20px) !important;
    max-width: calc(100% - 20px) !important;
    overflow-y: visible !important;
  }
  
  /* Split screen adjustments */
  .split-view-content {
    gap: var(--space-lg);
    margin-top: 0; /* Remove margin for better mobile layout */
    max-height: none;
    overflow: visible;
  }
  
  /* Ensure split-view layout displays properly on mobile */
  body.split-view .split-view-content {
    display: flex;
    flex-direction: column;
  }
  
  /* Abstraction slider - touch-friendly */
  .abstraction-slider {
    height: 8px; /* Thicker for easier touch */
    max-width: 100%;
  }
  
  .abstraction-slider::-webkit-slider-thumb {
    width: 24px;
    height: 24px;
  }
  
  .abstraction-slider::-moz-range-thumb {
    width: 24px;
    height: 24px;
  }
  
  /* Prevent slider from stealing focus from lens pills */
  .abstraction-control,
  .slider-container,
  .abstraction-slider {
    -webkit-user-select: none;
    user-select: none;
  }
  
  .abstraction-slider:focus {
    outline: none; /* Prevent visual focus that might trigger blur on pills */
  }
  
  /* Poem text - readable on mobile */
  .poem-text {
    font-size: 16px;
    line-height: 1.8;
  }
  
  /* Toast notifications - mobile optimized */
  .toast {
    font-size: 14px;
    padding: 14px 18px;
  }
  
  .toast-action-btn {
    min-height: 36px;
    padding: 8px 14px;
    font-size: 13px;
  }
  
  /* Entropy meter - smaller on mobile */
  .entropy-meter {
    width: 50px;
    right: 16px;
  }
  
  /* Lens section spacing - reduced top margin */
  .lens-section {
    margin-top: 5px; /* Reduced gap from input bar to 5px */
    margin-bottom: 17px;
  }
  
  .lens-section-title {
    font-size: 12px;
    margin-bottom: var(--space-sm);
  }
  
  /* Abstraction control spacing - reduced */
  .abstraction-control {
    margin: var(--space-lg) 0;
  }
  
  .abstraction-label-row {
    margin-bottom: var(--space-sm);
  }
  
  .abstraction-label {
    font-size: 11px;
  }
  
  /* Input container spacing - remove bottom margin */
  .input-container {
    margin-bottom: 0; /* Gap controlled by lens-section margin-top */
  }
  
  /* Right section spacing - reduced */
  
  
  /* Ensure all content is accessible with touch */
  * {
    -webkit-tap-highlight-color: rgba(167, 139, 250, 0.15);
  }
  
  /* Optimize scrollable areas */
  .app-container,
  .modal-content,
  .output-container {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
  }

}
