/* ==========================================================================
   ĀTMAN MASCOT ENGINE (Ātmi) — Phase 1: Adaptive Body & Kinematics
   - Precision Obsidian Dart (Active Pointer) ⇄ Living Cephalopod Mascot (Idle Morph)
   - Adheres strictly to ĀTMAN Adaptive Design Language (ADL):
     * Emergence over translation (Z-axis micro-scaling, zero vestibular stress)
     * Respiration luminance state-changes & sacred Vedic geometry
     * Hardware-accelerated 60/120fps (translate3d, will-change, zero layout reflows)
     * Non-interfering: Desktop only, strict pointer-events: none, caret pass-through
   ========================================================================== */

/* 1. Master Mascot Cursor Container */
#atmi-mascot {
  position: fixed;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  transform-origin: 0 0;
  pointer-events: none !important;
  user-select: none !important;
  z-index: 999999;
  will-change: transform;
  transform: translate3d(-100px, -100px, 0);
  opacity: 0;
  transition: opacity 0.24s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Make visible once initialized and coordinates acquired */
#atmi-mascot.atmi-ready {
  opacity: 1;
}

/* 2. Desktop OS Cursor Replacement */
@media (hover: hover) and (pointer: fine) {
  html.atmi-ready:not(.atmi-disabled),
  body.atmi-ready:not(.atmi-disabled),
  body.atmi-ready:not(.atmi-disabled) *:not(input):not(textarea):not([contenteditable]):not(select):not(.allow-system-cursor) {
    cursor: none !important;
  }

  body.atmi-ready:not(.atmi-disabled) input,
  body.atmi-ready:not(.atmi-disabled) textarea,
  body.atmi-ready:not(.atmi-disabled) [contenteditable] {
    cursor: text !important;
  }

  /* Suppress legacy static landing cursor image when Ātmi is active */
  body.atmi-ready #octopus-cursor {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
  }
}

/* 3. Mobile & Touch Screen Absolute Guard */
@media (hover: none), (pointer: coarse) {
  #atmi-mascot {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
  }
}

/* 4. Living Streamlined Swimmer Pointer (Aakriti Moving State) */
.atmi-dart {
  position: absolute;
  top: 0;
  left: 0;
  width: 38px;
  height: 42px;
  pointer-events: none;
  transform-origin: 0 0;
  will-change: transform, opacity;
  transition: opacity 0.12s ease-out, transform 0.14s cubic-bezier(0.16, 1, 0.3, 1);
}

.atmi-dart-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: drop-shadow(0 3px 8px rgba(0, 0, 0, 0.65)) drop-shadow(0 0 6px rgba(201, 178, 124, 0.3));
  transition: filter 0.2s ease;
}


/* Aakriti Living Swimmer Kinematics */
.atmi-swimmer {
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.7)) drop-shadow(0 0 8px rgba(201, 178, 124, 0.45));
}
.atmi-swimmer .aakriti-swimmer-body {
  transition: transform 0.16s ease-out;
}
.atmi-swimmer:hover .aakriti-swimmer-body {
  transform: scale(1.05);
}

/* 5. Living Creature Sub-Element (Idle / Mascot State) */
.atmi-creature {
  position: absolute;
  top: -21px;
  left: -30px;
  width: 60px;
  height: 64px;
  pointer-events: none;
  transform-origin: 30px 21px;
  will-change: transform, opacity;
  transition: opacity 0.34s cubic-bezier(0.16, 1, 0.3, 1), transform 0.38s cubic-bezier(0.16, 1, 0.3, 1);
}

.atmi-creature-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* 6. Dual-Mode State Transitions */

/* --- Mode: Pointer (Moving) --- */
#atmi-mascot.mode-pointer .atmi-dart {
  opacity: 1;
  transform: scale(1) translate3d(0, 0, 0);
  transition-duration: 0.08s;
}

#atmi-mascot.mode-pointer .atmi-creature {
  opacity: 0;
  transform: scale(0.32) translate3d(8px, 8px, 0);
  pointer-events: none;
  transition-duration: 0.08s;
}

/* --- Mode: Mascot (Idle Morph) --- */
#atmi-mascot.mode-mascot .atmi-dart {
  opacity: 0;
  transform: scale(0.35) translate3d(-4px, -4px, 0);
  pointer-events: none;
}

#atmi-mascot.mode-mascot .atmi-creature {
  opacity: 1;
  transform: scale(1) translate3d(0, 0, 0);
}

/* 7. Organic Respiration & Bioluminescent Glow */
@keyframes atmiBreathing {
  0%, 100% {
    transform: scale(1);
    filter: drop-shadow(0 0 10px rgba(201, 178, 124, 0.35)) drop-shadow(0 4px 14px rgba(0, 0, 0, 0.7));
  }
  50% {
    transform: scale(1.045);
    filter: drop-shadow(0 0 18px rgba(201, 178, 124, 0.65)) drop-shadow(0 6px 20px rgba(0, 0, 0, 0.85));
  }
}

#atmi-mascot.mode-mascot .atmi-creature-body {
  animation: atmiBreathing 3.8s ease-in-out infinite;
  transform-origin: 30px 24px;
}

/* Halo Ring Slow Resonance */
@keyframes atmiHaloRotate {
  0% { transform: rotate(0deg); opacity: 0.35; }
  50% { opacity: 0.7; }
  100% { transform: rotate(360deg); opacity: 0.35; }
}

.atmi-halo-ring {
  transform-origin: 30px 24px;
  animation: atmiHaloRotate 28s linear infinite;
}

/* 8. Sentient Eye Kinematics & Eyelid Micro-Blink */
.atmi-eyelid-wrap {
  transform-origin: 30px 21px;
}

@keyframes atmiBlinkAnim {
  0%, 93%, 100% {
    transform: scaleY(0);
    opacity: 0;
  }
  95%, 97% {
    transform: scaleY(1);
    opacity: 1;
  }
}

#atmi-mascot.mode-mascot .atmi-eyelid-wrap {
  animation: atmiBlinkAnim 5.2s ease-in-out infinite;
}

/* Pupil Micro-Glint & Dynamic Aiming */
.atmi-eye-iris-wrap {
  transform-origin: 30px 21px;
  will-change: transform;
  transition: transform 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

/* 9. Interactive Target Anticipation (Buttons / Links) */
#atmi-mascot.mode-interactive .atmi-dart-svg {
  filter: drop-shadow(0 0 14px rgba(201, 178, 124, 0.95)) drop-shadow(0 0 24px rgba(201, 178, 124, 0.5));
}

#atmi-mascot.mode-interactive .atmi-creature-body {
  transform: scale(1.08);
  filter: drop-shadow(0 0 22px rgba(201, 178, 124, 0.9)) drop-shadow(0 0 38px rgba(201, 178, 124, 0.45));
}

#atmi-mascot.mode-interactive .atmi-iris {
  filter: drop-shadow(0 0 4px #ffffff);
}

/* 10. Playful Teasing State (Static > 2.5s) */
@keyframes atmiTeaseMotion {
  0%, 100% {
    transform: rotate(0deg) translate3d(0, 0, 0);
  }
  25% {
    transform: rotate(-7deg) translate3d(-1px, -2px, 0);
  }
  75% {
    transform: rotate(6deg) translate3d(1px, -1px, 0);
  }
}

#atmi-mascot.mode-tease .atmi-creature {
  animation: atmiTeaseMotion 3.2s ease-in-out infinite;
}

/* 11. Caret Pass-Through / Text Input Mode */
#atmi-mascot.mode-input {
  opacity: 0.18 !important;
}

#atmi-mascot.mode-input .atmi-creature,
#atmi-mascot.mode-input .atmi-dart {
  transform: translate3d(24px, -18px, 0) scale(0.68) !important;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

/* 12. Bioluminescent Click Ripple */
.atmi-ripple {
  position: absolute;
  top: 0;
  left: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1.6px solid rgba(201, 178, 124, 0.95);
  pointer-events: none;
  transform: translate(-50%, -50%) scale(1);
  animation: atmiRippleWave 0.52s cubic-bezier(0.1, 0.8, 0.25, 1) forwards;
  will-change: transform, opacity;
}

@keyframes atmiRippleWave {
  0% {
    transform: translate(-50%, -50%) scale(0.8);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) scale(5.8);
    opacity: 0;
    border-width: 0.6px;
  }
}

/* 13. Tendril Bioluminescent Nodes */
.atmi-node {
  filter: drop-shadow(0 0 4px rgba(252, 229, 178, 0.9));
  animation: atmiNodePulse 2.4s ease-in-out infinite alternate;
}

@keyframes atmiNodePulse {
  0% { r: 1.4; opacity: 0.7; }
  100% { r: 2.1; opacity: 1; }
}

/* 14. Ethereal Thought Bubble / Speech Cloud (Phase 2) */
.atmi-thought-bubble {
  position: absolute;
  top: -72px;
  left: 28px;
  min-width: 140px;
  max-width: 250px;
  background: rgba(14, 13, 10, 0.94);
  border: 1px solid rgba(201, 178, 124, 0.38);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8), 0 0 16px rgba(201, 178, 124, 0.2);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-radius: 12px 14px 14px 4px;
  padding: 8px 12px 9px 12px;
  color: var(--text, #ededed);
  font-family: var(--font-body, 'Instrument Sans', sans-serif);
  font-size: 0.78rem;
  line-height: 1.35;
  pointer-events: none;
  opacity: 0;
  transform: scale(0.65) translate3d(0, 8px, 0);
  transform-origin: bottom left;
  transition: opacity 0.24s cubic-bezier(0.16, 1, 0.3, 1), transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 1000000;
  display: flex;
  flex-direction: column;
  gap: 3px;
  will-change: transform, opacity;
}

.atmi-thought-bubble.bubble-visible {
  opacity: 1;
  transform: scale(1) translate3d(0, 0, 0);
  pointer-events: auto;
}

.atmi-thought-bubble.is-intro {
  min-width: 230px;
  max-width: 310px;
  padding: 10px 13px 11px 13px;
  border-color: rgba(201, 178, 124, 0.48);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.85), 0 0 20px rgba(201, 178, 124, 0.22);
}

/* Flipped placement when close to right edge */
.atmi-thought-bubble.bubble-flip-x {
  left: auto;
  right: 28px;
  transform-origin: bottom right;
  border-radius: 14px 12px 4px 14px;
}

/* Flipped placement when close to top edge */
.atmi-thought-bubble.bubble-flip-y {
  top: 36px;
  transform-origin: top left;
  border-radius: 4px 14px 14px 12px;
}
.atmi-thought-bubble.bubble-flip-x.bubble-flip-y {
  transform-origin: top right;
  border-radius: 14px 4px 12px 14px;
}

.atmi-thought-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #c9b27c;
  opacity: 0.95;
}

.atmi-thought-title {
  display: flex;
  align-items: center;
  gap: 5px;
}

.atmi-thought-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.atmi-intro-dismiss {
  background: transparent;
  border: none;
  color: rgba(201, 178, 124, 0.65);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  padding: 1px 4px;
  border-radius: 4px;
  pointer-events: auto !important;
  transition: all 0.16s ease;
  user-select: none;
}

.atmi-intro-dismiss:hover {
  color: #ffffff;
  background: rgba(201, 178, 124, 0.18);
}

.atmi-thought-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 7px;
  padding-top: 5px;
  border-top: 1px solid rgba(201, 178, 124, 0.15);
}

.atmi-intro-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(201, 178, 124, 0.14);
  border: 1px solid rgba(201, 178, 124, 0.45);
  border-radius: 5px;
  padding: 3px 9px;
  font-size: 0.70rem;
  font-weight: 500;
  color: #fce5b2;
  cursor: pointer;
  pointer-events: auto !important;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  font-family: inherit;
}

.atmi-intro-action-btn:hover {
  background: rgba(201, 178, 124, 0.28);
  border-color: rgba(201, 178, 124, 0.85);
  color: #ffffff;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(201, 178, 124, 0.2);
}

.atmi-whisper-cue {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #c9b27c;
  background: rgba(201, 178, 124, 0.12);
  border: 1px solid rgba(201, 178, 124, 0.35);
  border-radius: 4px;
  padding: 1px 5px;
  cursor: pointer;
  pointer-events: auto !important;
  text-transform: none;
  transition: all 0.16s ease;
}

/* Desktop Thought Bubble Hint Badge */
#atmi-mascot .atmi-cue-badge {
  pointer-events: auto !important;
  cursor: pointer !important;
  user-select: none !important;
}

/* Presence State Indicators */
#atmi-mascot[data-presence-state="resting"],
#atmi-mobile-companion[data-presence-state="resting"] {
  opacity: 0.88;
}

#atmi-mascot[data-presence-state="emerging"],
#atmi-mobile-companion[data-presence-state="emerging"] {
  opacity: 1;
  transition: opacity 0.32s cubic-bezier(0.16, 1, 0.3, 1);
}

#atmi-mascot[data-presence-state="introducing"],
#atmi-mobile-companion[data-presence-state="introducing"] {
  opacity: 1;
}

#atmi-mascot[data-presence-state="available"],
#atmi-mobile-companion[data-presence-state="available"] {
  opacity: 0.95;
}

#atmi-mascot[data-presence-state="dismissed"] .atmi-thought-bubble,
#atmi-mobile-companion[data-presence-state="dismissed"] .atmi-thought-bubble {
  opacity: 0;
  transform: scale(0.7) translate3d(0, 8px, 0);
  pointer-events: none;
}

button.atmi-whisper-cue:hover {
  background: rgba(201, 178, 124, 0.28);
  border-color: #c9b27c;
  color: #ffffff;
  box-shadow: 0 0 8px rgba(201, 178, 124, 0.35);
}

.atmi-keycap {
  display: inline-block;
  font-size: 0.56rem;
  font-weight: 700;
  background: rgba(14, 13, 10, 0.85);
  border: 1px solid rgba(201, 178, 124, 0.55);
  border-radius: 3px;
  padding: 0 3px;
  line-height: 1.2;
  color: #fce5b2;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.atmi-whisper-icon {
  display: inline-block;
  font-size: 0.65rem;
  line-height: 1;
}

.atmi-thought-glyph {
  font-size: 0.65rem;
  color: #c9b27c;
  animation: atmiGlyphSpin 6s linear infinite;
  display: inline-block;
}

@keyframes atmiGlyphSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.atmi-thought-text {
  color: #ededed;
  font-weight: 400;
  letter-spacing: 0.01em;
}

/* 15. Poke Squish & Dizzy Shaking Reactions */
@keyframes atmiPokeSquish {
  0% { transform: scale(1, 1); }
  25% { transform: scale(1.24, 0.78) translate3d(0, 4px, 0); }
  55% { transform: scale(0.88, 1.16) translate3d(0, -3px, 0); }
  80% { transform: scale(1.05, 0.97); }
  100% { transform: scale(1, 1); }
}

.atmi-squishing .atmi-creature-body {
  animation: atmiPokeSquish 0.46s cubic-bezier(0.18, 1, 0.3, 1) !important;
}

@keyframes atmiDizzySwirl {
  0% { transform: rotate(0deg); }
  25% { transform: rotate(-30deg) scale(0.92); }
  50% { transform: rotate(30deg) scale(1.08); }
  75% { transform: rotate(-18deg) scale(0.96); }
  100% { transform: rotate(0deg) scale(1); }
}

.atmi-dizzy .atmi-creature {
  animation: atmiDizzySwirl 0.75s ease-in-out !important;
}

/* 16. Poke Bioluminescent Sparkles */
.atmi-sparkle {
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 4px;
  background: #fce5b2;
  border-radius: 50%;
  pointer-events: none;
  box-shadow: 0 0 6px #c9b27c;
  animation: atmiSparkleFly 0.6s cubic-bezier(0.1, 0.8, 0.3, 1) forwards;
}

@keyframes atmiSparkleFly {
  0% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
  100% {
    transform: translate(calc(-50% + var(--dx, 20px)), calc(-50% + var(--dy, -20px))) scale(0);
    opacity: 0;
  }
}

/* 17. Light Theme Harmonization (Phase 3) */
[data-theme="light"] #atmi-mascot .atmi-thought-bubble {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(175, 145, 85, 0.45);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12), 0 0 16px rgba(201, 178, 124, 0.22);
  color: #1a1815;
}

[data-theme="light"] #atmi-mascot .atmi-thought-header {
  color: #8f6e2b;
}

[data-theme="light"] #atmi-mascot .atmi-whisper-cue {
  background: rgba(175, 145, 85, 0.12);
  border-color: rgba(175, 145, 85, 0.35);
  color: #7a5c1e;
}

[data-theme="light"] #atmi-mascot .atmi-keycap {
  background: #ffffff;
  border-color: rgba(175, 145, 85, 0.5);
  color: #5c4310;
}

[data-theme="light"] #atmi-mascot .atmi-thought-text {
  color: #1c1a16;
}

[data-theme="light"] #atmi-mascot .atmi-dart-svg {
  filter: drop-shadow(0 3px 8px rgba(0, 0, 0, 0.35)) drop-shadow(0 0 6px rgba(185, 150, 85, 0.45));
}

/* 18. Cognitive Resonance & Mood States (Phase 3) */

/* Curious Mood: Wider pupil & eager bioluminescent aura */
#atmi-mascot.mood-curious .atmi-creature-body {
  filter: drop-shadow(0 0 16px rgba(201, 178, 124, 0.7)) drop-shadow(0 4px 14px rgba(0, 0, 0, 0.7));
}

#atmi-mascot.mood-curious .atmi-iris {
  transform: scale(1.12);
  transform-origin: 30px 21px;
}

/* Deep Contemplative Mood: Slower breathing & calm indigo-gold shift */
#atmi-mascot.mood-deep .atmi-creature-body {
  animation-duration: 5.2s !important;
  filter: drop-shadow(0 0 14px rgba(160, 140, 200, 0.45)) drop-shadow(0 0 8px rgba(201, 178, 124, 0.4));
}

/* Streaming / AI Generating Mode: Rapid halo resonance & pulsating core */
@keyframes atmiStreamingHalo {
  0% { transform: rotate(0deg); opacity: 0.6; }
  50% { opacity: 1; stroke-width: 1.4px; }
  100% { transform: rotate(360deg); opacity: 0.6; }
}

#atmi-mascot.mood-streaming .atmi-halo-ring {
  animation: atmiStreamingHalo 5s linear infinite !important;
  stroke: rgba(201, 178, 124, 0.85);
}

#atmi-mascot.mood-streaming .atmi-creature-body {
  filter: drop-shadow(0 0 20px rgba(201, 178, 124, 0.85)) drop-shadow(0 0 32px rgba(201, 178, 124, 0.45));
}

/* Focus Mode: When user is typing inside chat */
#atmi-mascot.mood-focus {
  opacity: 0.22 !important;
}

#atmi-mascot.mood-focus .atmi-creature,
#atmi-mascot.mood-focus .atmi-dart {
  transform: translate3d(24px, -18px, 0) scale(0.65) !important;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

/* 19. Neuro-Inclusive: Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
  #atmi-mascot.mode-mascot .atmi-creature-body,
  .atmi-halo-ring,
  #atmi-mascot.mode-mascot .atmi-eyelid-wrap,
  #atmi-mascot.mode-tease .atmi-creature,
  .atmi-node,
  .atmi-thought-glyph,
  .atmi-squishing .atmi-creature-body,
  .atmi-dizzy .atmi-creature,
  #atmi-mascot.mood-streaming .atmi-halo-ring,
  #atmi-mobile-companion .atmi-creature-body {
    animation: none !important;
  }
  .atmi-dart,
  .atmi-creature,
  .atmi-thought-bubble,
  .atmi-intro-action-btn,
  .atmi-intro-dismiss,
  #atmi-mobile-companion {
    transition-duration: 0.01ms !important;
    transform: none !important;
  }
}

/* ==========================================================================
   20. MOBILE TOUCH AMBIENT COMPANION ORB (Phase 4)
   - Exclusively renders on touch devices and mobile viewports
   - Floats cleanly above chat input bar / navigation with zero layout obstruction
   - Tap-to-poke, drag-to-dock, double-tap sleep/wake
   - Safe from mobile drawer and virtual keyboard
   ========================================================================== */

#atmi-mobile-companion {
  display: none;
  position: fixed;
  z-index: 850;
  width: 48px;
  height: 48px;
  right: 18px;
  bottom: max(86px, calc(env(safe-area-inset-bottom, 0px) + 78px));
  border-radius: 50%;
  background: rgba(14, 13, 10, 0.90);
  border: 1px solid rgba(201, 178, 124, 0.45);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.65), 0 0 16px rgba(201, 178, 124, 0.25);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: transform 0.28s cubic-bezier(0.18, 1, 0.3, 1), opacity 0.25s ease, filter 0.2s ease, width 0.24s ease, height 0.24s ease;
  will-change: transform, opacity;
}

/* Activate on Touchscreens or Mobile Viewports */
@media (hover: none), (pointer: coarse), (max-width: 768px) {
  #atmi-mobile-companion {
    display: flex;
  }
}

@media (hover: hover) and (pointer: fine) and (min-width: 769px) {
  #atmi-mobile-companion {
    display: none !important;
    pointer-events: none !important;
  }
}

/* Stacking context safety: hide during open mobile drawer, active modals, tours, and onboarding (Phase 4, 5D, 7 & 8) */
.mobile-backdrop.visible ~ #atmi-mobile-companion,
body:has(#sidebar.mobile-open) #atmi-mobile-companion,
body.drawer-open #atmi-mobile-companion,
body.in-onboarding #atmi-mobile-companion,
body:has(.atmi-whisper-window.whisper-visible) #atmi-mobile-companion,
body:has(.atmi-guide-card.guide-active) #atmi-mobile-companion,
body:has(.atmi-hud-backdrop.hud-open) #atmi-mobile-companion,
body:has(#delete-confirm-modal:not([style*="display: none"]):not([style*="display:none"])) #atmi-mobile-companion,
.mobile-backdrop.visible ~ #atmi-whisper-window,
body:has(#sidebar.mobile-open) #atmi-whisper-window,
body.drawer-open #atmi-whisper-window,
.mobile-backdrop.visible ~ #atmi-fleeing-avatar,
body:has(#sidebar.mobile-open) #atmi-fleeing-avatar,
body.drawer-open #atmi-fleeing-avatar {
  opacity: 0 !important;
  pointer-events: none !important;
  transform: scale(0.6) !important;
  visibility: hidden !important;
}

/* Inner creature container */
.atmi-orb-inner {
  width: 38px;
  height: 40px;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.atmi-orb-inner svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* Mobile Thought Bubble */
#atmi-mobile-companion .atmi-thought-bubble {
  top: auto;
  bottom: 58px;
  right: 0;
  left: auto;
  min-width: 140px;
  max-width: 250px;
  transform-origin: bottom right;
}

#atmi-mobile-companion .atmi-thought-bubble.bubble-dock-left {
  right: auto;
  left: 0;
  transform-origin: bottom left;
  border-radius: 12px 14px 14px 4px;
}

/* Minimized Sleep State */
#atmi-mobile-companion.orb-minimized {
  width: 28px;
  height: 28px;
  opacity: 0.42;
  box-shadow: 0 0 10px rgba(201, 178, 124, 0.4);
}

#atmi-mobile-companion.orb-minimized .atmi-orb-inner {
  transform: scale(0.55);
}

/* Light Theme Harmonization for Mobile Orb */
[data-theme="light"] #atmi-mobile-companion {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(175, 145, 85, 0.5);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12), 0 0 16px rgba(201, 178, 124, 0.25);
}

/* ==========================================================================
   21. TELEPATHIC WHISPER POP-CHAT WINDOW (Phase 5A)
   - Pop-up micro-chat triggered via [K] hotkey or clicking thought cue
   - Glassmorphic frosted obsidian & amber-gold aesthetic
   - Viewport boundary collision clamping & auto-docking
   - Direct pointer-events and system cursor restoration
   ========================================================================== */

.atmi-whisper-window {
  position: fixed;
  z-index: 1000002;
  width: 310px;
  max-width: calc(100vw - 32px);
  background: rgba(14, 13, 10, 0.94);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid rgba(201, 178, 124, 0.45);
  border-radius: 14px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.8), 0 0 24px rgba(201, 178, 124, 0.22);
  font-family: var(--font-body, 'Instrument Sans', sans-serif);
  overflow: hidden;
  opacity: 0;
  pointer-events: none !important;
  transform: scale(0.9) translate3d(0, 10px, 0);
  transform-origin: top left;
  transition: opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1), transform 0.24s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: transform, opacity;
}

.atmi-whisper-window.whisper-visible {
  opacity: 1;
  pointer-events: auto !important;
  transform: scale(1) translate3d(0, 0, 0);
}

/* Ensure mouse pointers are fully active and visible inside whisper window */
body.atmi-active .atmi-whisper-window,
body.atmi-active .atmi-whisper-window * {
  cursor: default !important;
}

body.atmi-active .atmi-whisper-window input {
  cursor: text !important;
}

body.atmi-active .atmi-whisper-window button,
body.atmi-active .atmi-whisper-cue,
body.atmi-active .atmi-whisper-cue * {
  cursor: pointer !important;
}

/* Whisper Header */
.atmi-whisper-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px 9px 14px;
  border-bottom: 1px solid rgba(201, 178, 124, 0.16);
  background: rgba(22, 19, 14, 0.75);
}

.atmi-whisper-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #c9b27c;
  text-transform: uppercase;
}

.atmi-whisper-glyph {
  font-size: 0.75rem;
  color: #fce5b2;
  animation: atmiGlyphSpin 8s linear infinite;
  display: inline-block;
}

.atmi-whisper-tag {
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: #e2cf9f;
  background: rgba(201, 178, 124, 0.16);
  border: 1px solid rgba(201, 178, 124, 0.3);
  border-radius: 10px;
  padding: 1px 6px;
}

.atmi-whisper-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.atmi-whisper-hotkey-hint {
  font-size: 0.58rem;
  color: rgba(201, 178, 124, 0.55);
  letter-spacing: 0.02em;
}

.atmi-whisper-close {
  background: transparent;
  border: none;
  color: rgba(201, 178, 124, 0.7);
  font-size: 1.1rem;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
  transition: all 0.15s ease;
}

.atmi-whisper-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

/* Whisper Voice Toggle Button (Phase 6A) */
.atmi-whisper-voice-toggle {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: rgba(20, 18, 14, 0.7);
  border: 1px solid rgba(201, 178, 124, 0.3);
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 0.62rem;
  font-weight: 600;
  color: rgba(201, 178, 124, 0.75);
  cursor: pointer;
  transition: all 0.18s ease;
  user-select: none;
}

.atmi-whisper-voice-toggle:hover {
  background: rgba(201, 178, 124, 0.15);
  border-color: #c9b27c;
  color: #fce5b2;
}

.atmi-whisper-voice-toggle.voice-active {
  background: rgba(201, 178, 124, 0.24);
  border-color: #c9b27c;
  color: #fff8e7;
  box-shadow: 0 0 10px rgba(201, 178, 124, 0.35);
}

.atmi-voice-icon {
  font-size: 0.65rem;
  line-height: 1;
}

.atmi-voice-label {
  font-size: 0.58rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Light theme override for voice toggle */
[data-theme="light"] .atmi-whisper-voice-toggle {
  background: rgba(255, 255, 255, 0.85);
  border-color: rgba(175, 145, 85, 0.35);
  color: #8a6824;
}

[data-theme="light"] .atmi-whisper-voice-toggle:hover {
  background: rgba(175, 145, 85, 0.15);
  border-color: #8a6824;
  color: #5c4310;
}

[data-theme="light"] .atmi-whisper-voice-toggle.voice-active {
  background: rgba(175, 145, 85, 0.22);
  border-color: #8a6824;
  color: #3d2b07;
  box-shadow: 0 0 8px rgba(175, 145, 85, 0.3);
}

/* Master Intelligent Instructor Subbar & Quick Action Chips */
.atmi-instructor-subbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 14px 6px 14px;
  background: rgba(14, 12, 9, 0.85);
  border-bottom: 1px solid rgba(201, 178, 124, 0.12);
}

.atmi-instructor-space-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #fce5b2;
}

.atmi-instructor-space-badge .atmi-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #52e5a8;
  box-shadow: 0 0 6px rgba(82, 229, 168, 0.7);
  display: inline-block;
}

.atmi-instructor-tour-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(201, 178, 124, 0.16);
  border: 1px solid rgba(201, 178, 124, 0.38);
  border-radius: 12px;
  color: #fce5b2;
  font-size: 0.62rem;
  font-weight: 600;
  padding: 2px 8px;
  cursor: pointer;
  transition: all 0.16s ease;
}

.atmi-instructor-tour-btn:hover {
  background: rgba(201, 178, 124, 0.32);
  border-color: #fce5b2;
  color: #ffffff;
  box-shadow: 0 0 8px rgba(201, 178, 124, 0.3);
}

.atmi-instructor-chips {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(16, 14, 10, 0.55);
  border-bottom: 1px solid rgba(201, 178, 124, 0.1);
  overflow-x: auto;
  scrollbar-width: none;
}

.atmi-instructor-chips::-webkit-scrollbar {
  display: none;
}

.atmi-chip {
  flex-shrink: 0;
  background: rgba(201, 178, 124, 0.1);
  border: 1px solid rgba(201, 178, 124, 0.24);
  border-radius: 12px;
  color: rgba(252, 229, 178, 0.9);
  font-size: 0.62rem;
  font-weight: 500;
  padding: 2px 9px;
  cursor: pointer;
  transition: all 0.16s ease;
  white-space: nowrap;
}

.atmi-chip:hover {
  background: rgba(201, 178, 124, 0.28);
  border-color: #c9b27c;
  color: #ffffff;
  transform: translateY(-1px);
}

[data-theme="light"] .atmi-instructor-subbar {
  background: rgba(245, 240, 230, 0.9);
  border-bottom-color: rgba(175, 145, 85, 0.2);
}

[data-theme="light"] .atmi-instructor-space-badge {
  color: #3d2b07;
}

[data-theme="light"] .atmi-instructor-tour-btn {
  background: rgba(175, 145, 85, 0.18);
  border-color: rgba(175, 145, 85, 0.45);
  color: #2b1d03;
}

[data-theme="light"] .atmi-instructor-chips {
  background: rgba(240, 235, 225, 0.6);
  border-bottom-color: rgba(175, 145, 85, 0.15);
}

[data-theme="light"] .atmi-chip {
  background: rgba(175, 145, 85, 0.12);
  border-color: rgba(175, 145, 85, 0.3);
  color: #3d2b07;
}

[data-theme="light"] .atmi-chip:hover {
  background: rgba(175, 145, 85, 0.25);
  color: #1a1202;
}

/* Whisper Body & Message Log */
.atmi-whisper-body {
  padding: 12px 14px;
  max-height: 170px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(201, 178, 124, 0.3) transparent;
}

.atmi-whisper-body::-webkit-scrollbar {
  width: 4px;
}

.atmi-whisper-body::-webkit-scrollbar-thumb {
  background: rgba(201, 178, 124, 0.3);
  border-radius: 4px;
}

.atmi-whisper-log {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.atmi-whisper-msg {
  display: flex;
  flex-direction: column;
  max-width: 90%;
  animation: atmiMsgIn 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

.atmi-whisper-msg.user {
  align-self: flex-end;
  align-items: flex-end;
}

.atmi-whisper-msg.mascot {
  align-self: flex-start;
  align-items: flex-start;
}

.atmi-whisper-bubble {
  padding: 7px 11px;
  font-size: 0.78rem;
  line-height: 1.38;
  word-break: break-word;
}

.atmi-whisper-msg.user .atmi-whisper-bubble {
  background: rgba(201, 178, 124, 0.18);
  border: 1px solid rgba(201, 178, 124, 0.35);
  color: #f7edd7;
  border-radius: 12px 12px 3px 12px;
}

.atmi-whisper-msg.mascot .atmi-whisper-bubble {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #ededed;
  border-radius: 12px 12px 12px 3px;
}

/* Typing pulse indicator */
.atmi-whisper-typing {
  display: inline-flex;
  gap: 4px;
  padding: 7px 11px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px 12px 12px 3px;
}

.atmi-whisper-typing span {
  width: 5px;
  height: 5px;
  background: #c9b27c;
  border-radius: 50%;
  opacity: 0.4;
  animation: atmiTypingPulse 1.2s infinite ease-in-out;
}

.atmi-whisper-typing span:nth-child(2) { animation-delay: 0.2s; }
.atmi-whisper-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes atmiTypingPulse {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.15); }
}

/* Whisper Input Row */
.atmi-whisper-form {
  padding: 8px 12px 10px 12px;
  border-top: 1px solid rgba(201, 178, 124, 0.15);
  background: rgba(12, 11, 8, 0.7);
}

.atmi-whisper-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.atmi-whisper-input {
  width: 100%;
  padding: 7px 32px 7px 11px;
  background: rgba(20, 18, 14, 0.85);
  border: 1px solid rgba(201, 178, 124, 0.3);
  border-radius: 8px;
  color: #f7edd7;
  font-family: inherit;
  font-size: 0.78rem;
  line-height: 1.3;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.atmi-whisper-input::placeholder {
  color: rgba(201, 178, 124, 0.45);
}

.atmi-whisper-input:focus {
  border-color: #c9b27c;
  box-shadow: 0 0 12px rgba(201, 178, 124, 0.25);
}

.atmi-whisper-send {
  position: absolute;
  right: 6px;
  background: transparent;
  border: none;
  color: #c9b27c;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  padding: 0;
  transition: all 0.15s ease;
}

.atmi-whisper-send:hover {
  background: rgba(201, 178, 124, 0.2);
  color: #ffffff;
}

/* Light Theme Harmonization for Whisper Window */
[data-theme="light"] .atmi-whisper-window {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(175, 145, 85, 0.45);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.14), 0 0 24px rgba(201, 178, 124, 0.2);
}

[data-theme="light"] .atmi-whisper-header {
  background: rgba(246, 242, 233, 0.85);
  border-bottom: 1px solid rgba(175, 145, 85, 0.2);
}

[data-theme="light"] .atmi-whisper-title {
  color: #8a6824;
}

[data-theme="light"] .atmi-whisper-glyph {
  color: #b58d3d;
}

[data-theme="light"] .atmi-whisper-tag {
  color: #7a5c1e;
  background: rgba(175, 145, 85, 0.14);
  border-color: rgba(175, 145, 85, 0.3);
}

[data-theme="light"] .atmi-whisper-hotkey-hint {
  color: rgba(120, 95, 45, 0.7);
}

[data-theme="light"] .atmi-whisper-close {
  color: rgba(120, 95, 45, 0.8);
}

[data-theme="light"] .atmi-whisper-close:hover {
  background: rgba(0, 0, 0, 0.06);
  color: #1a1815;
}

[data-theme="light"] .atmi-whisper-msg.user .atmi-whisper-bubble {
  background: rgba(201, 178, 124, 0.25);
  border-color: rgba(175, 145, 85, 0.4);
  color: #1a1815;
}

[data-theme="light"] .atmi-whisper-msg.mascot .atmi-whisper-bubble {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.08);
  color: #1a1815;
}

[data-theme="light"] .atmi-whisper-form {
  background: rgba(246, 242, 233, 0.8);
  border-top: 1px solid rgba(175, 145, 85, 0.18);
}

[data-theme="light"] .atmi-whisper-input {
  background: #ffffff;
  border-color: rgba(175, 145, 85, 0.35);
  color: #1a1815;
}

[data-theme="light"] .atmi-whisper-input::placeholder {
  color: rgba(120, 95, 45, 0.5);
}

[data-theme="light"] .atmi-whisper-input:focus {
  border-color: #8a6824;
  box-shadow: 0 0 10px rgba(175, 145, 85, 0.25);
}

[data-theme="light"] .atmi-whisper-send {
  color: #8a6824;
}

[data-theme="light"] .atmi-whisper-send:hover {
  background: rgba(175, 145, 85, 0.18);
  color: #5c4310;
}

/* Mobile responsive sheet mode for whisper */
@media (max-width: 768px) {
  .atmi-whisper-window {
    left: 16px !important;
    right: 16px !important;
    bottom: max(78px, calc(env(safe-area-inset-bottom, 0px) + 72px)) !important;
    top: auto !important;
    width: auto !important;
    max-width: 440px !important;
    margin: 0 auto;
    border-radius: 16px;
    transform: scale(0.95) translate3d(0, 16px, 0);
  }
  .atmi-whisper-window.whisper-visible {
    transform: scale(1) translate3d(0, 0, 0);
  }
}

/* ==========================================================================
   22. AUTONOMOUS ESCAPE & HIDE-AND-SEEK ENGINE (Phases 5B & 5C)
   - High-velocity golden particle streak & autonomous fleeing avatar
   - Cloaked peeking state with cyclops eye tracking mouse position
   - Proximity radar re-emergence
   ========================================================================== */

#atmi-fleeing-avatar {
  position: fixed;
  z-index: 999990;
  width: 50px;
  height: 54px;
  pointer-events: none !important;
  user-select: none !important;
  transform-origin: center center;
  transition: transform 0.45s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.35s ease;
  will-change: transform, opacity;
  filter: drop-shadow(0 0 14px rgba(201, 178, 124, 0.65)) drop-shadow(0 4px 12px rgba(0, 0, 0, 0.7));
}

#atmi-fleeing-avatar svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* Cloaked / Peeking state */
#atmi-fleeing-avatar.atmi-peeking {
  opacity: 0.68;
  filter: drop-shadow(0 0 10px rgba(201, 178, 124, 0.45));
}

#atmi-fleeing-avatar.atmi-peeking svg {
  animation: atmiPeekingPulse 2.8s infinite ease-in-out;
  transform-origin: center center;
}

@keyframes atmiPeekingPulse {
  0%, 100% { opacity: 0.52; transform: scale(0.85); }
  50% { opacity: 0.88; transform: scale(0.96); }
}

/* Golden particle streak */
.atmi-streak-particle {
  position: fixed;
  z-index: 999989;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #fce5b2;
  box-shadow: 0 0 10px #c9b27c, 0 0 20px rgba(201, 178, 124, 0.6);
  pointer-events: none;
  animation: atmiStreakFade 0.5s cubic-bezier(0.1, 0.8, 0.3, 1) forwards;
}

@keyframes atmiStreakFade {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(0.2); opacity: 0; }
}

/* ────────────────────────────────────────────────────────────────────────────
 * Phase 6B: Cosmic Incantations & Screen Transformation Canvas
 * ──────────────────────────────────────────────────────────────────────────── */
#atmi-incantation-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 99998;
  opacity: 1;
  transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

#atmi-incantation-canvas.incantation-fading {
  opacity: 0;
}

/* Incantation Ambient Body Filters */
body.incantation-shunya {
  filter: contrast(1.1) brightness(0.6);
  transition: filter 1.2s ease;
}

body.incantation-shunya #atmi-mascot .atmi-iris-wrap {
  transform: scale(0.18) !important;
  opacity: 0.25 !important;
  transition: all 1.2s cubic-bezier(0.16, 1, 0.3, 1);
}

body.incantation-abyss {
  filter: hue-rotate(165deg) brightness(0.88);
  transition: filter 1.2s ease;
}

body.incantation-matrix {
  filter: hue-rotate(85deg) contrast(1.15);
  transition: filter 0.8s ease;
}

body.incantation-matrix #atmi-mascot .atmi-mascot-head {
  fill: #00ff66 !important;
  filter: drop-shadow(0 0 16px #00ff66) !important;
}

body.incantation-matrix #atmi-mascot .atmi-tendril {
  stroke: #00ff66 !important;
  filter: drop-shadow(0 0 10px #00ff66) !important;
}

body.incantation-gold {
  filter: sepia(0.35) saturate(1.8) contrast(1.05);
  transition: filter 0.8s ease;
}

body.incantation-gold #atmi-mascot .atmi-mascot-head {
  fill: #ffd700 !important;
  filter: drop-shadow(0 0 20px #ffcc00) !important;
}

body.incantation-gold #atmi-mascot .atmi-tendril {
  stroke: #ffd700 !important;
  filter: drop-shadow(0 0 14px #ffcc00) !important;
}

@media (prefers-reduced-motion: reduce) {
  #atmi-incantation-canvas {
    opacity: 0.45;
  }
  body[class*="incantation-"] {
    filter: none !important;
  }
}

/* ────────────────────────────────────────────────────────────────────────────
 * Phase 7: Ātmi Ethereal HUD & Secret Incantations Grimoire
 * ──────────────────────────────────────────────────────────────────────────── */
.atmi-whisper-codex-btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: rgba(20, 18, 14, 0.7);
  border: 1px solid rgba(201, 178, 124, 0.3);
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 0.62rem;
  font-weight: 600;
  color: rgba(201, 178, 124, 0.75);
  cursor: pointer;
  transition: all 0.18s ease;
  user-select: none;
}

.atmi-whisper-codex-btn:hover {
  background: rgba(201, 178, 124, 0.18);
  border-color: #c9b27c;
  color: #fff8e7;
  box-shadow: 0 0 10px rgba(201, 178, 124, 0.35);
}

[data-theme="light"] .atmi-whisper-codex-btn {
  background: rgba(255, 255, 255, 0.85);
  border-color: rgba(175, 145, 85, 0.35);
  color: #8a6824;
}

[data-theme="light"] .atmi-whisper-codex-btn:hover {
  background: rgba(175, 145, 85, 0.18);
  border-color: #8a6824;
  color: #3d2b07;
}

/* HUD Backdrop & Centered Modal */
.atmi-hud-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 7, 5, 0.74);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 99990;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.24s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.24s;
}

.atmi-hud-backdrop.hud-open {
  opacity: 1;
  visibility: visible;
}

.atmi-hud-modal {
  width: 92vw;
  max-width: 530px;
  max-height: 85vh;
  overflow-y: auto;
  background: rgba(18, 16, 12, 0.96);
  border: 1px solid rgba(201, 178, 124, 0.4);
  border-radius: 14px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.85), 0 0 30px rgba(201, 178, 124, 0.15);
  color: #f5f0e6;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  transform: scale(0.95) translateY(10px);
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  padding: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(201, 178, 124, 0.35) transparent;
}

.atmi-hud-backdrop.hud-open .atmi-hud-modal {
  transform: scale(1) translateY(0);
}

/* Modal Header */
.atmi-hud-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(201, 178, 124, 0.18);
  background: rgba(26, 22, 16, 0.7);
  position: sticky;
  top: 0;
  z-index: 2;
  backdrop-filter: blur(12px);
}

.atmi-hud-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.atmi-hud-glyph {
  color: #c9b27c;
  font-size: 1.05rem;
}

.atmi-hud-title {
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #fff8e7;
  text-transform: uppercase;
}

.atmi-hud-badge {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(201, 178, 124, 0.2);
  border: 1px solid rgba(201, 178, 124, 0.4);
  color: #fce5b2;
}

.atmi-hud-close {
  background: transparent;
  border: none;
  color: rgba(201, 178, 124, 0.65);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 6px;
  transition: all 0.16s ease;
  line-height: 1;
}

.atmi-hud-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

/* Modal Body */
.atmi-hud-body {
  padding: 16px 18px 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.atmi-hud-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.atmi-hud-section-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #c9b27c;
}

/* Persona Switcher Tabs */
.atmi-hud-tabs {
  display: flex;
  gap: 6px;
  background: rgba(12, 10, 8, 0.6);
  padding: 4px;
  border-radius: 8px;
  border: 1px solid rgba(201, 178, 124, 0.15);
}

.atmi-hud-tab-btn {
  flex: 1;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.72rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.65);
  cursor: pointer;
  transition: all 0.18s ease;
  text-align: center;
}

.atmi-hud-tab-btn:hover {
  color: #fce5b2;
}

.atmi-hud-tab-btn.tab-active {
  background: rgba(201, 178, 124, 0.22);
  color: #fff8e7;
  border-color: rgba(201, 178, 124, 0.45);
  box-shadow: 0 0 10px rgba(201, 178, 124, 0.2);
}

/* Mood Row */
.atmi-hud-mood-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.atmi-hud-mood-btn {
  background: rgba(25, 22, 17, 0.7);
  border: 1px solid rgba(201, 178, 124, 0.22);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 0.66rem;
  font-weight: 600;
  color: rgba(201, 178, 124, 0.75);
  cursor: pointer;
  transition: all 0.18s ease;
}

.atmi-hud-mood-btn:hover {
  border-color: #c9b27c;
  color: #fff;
}

.atmi-hud-mood-btn.mood-active {
  background: rgba(201, 178, 124, 0.28);
  border-color: #c9b27c;
  color: #fff8e7;
  box-shadow: 0 0 10px rgba(201, 178, 124, 0.3);
}

/* Neural Vault Card */
.atmi-hud-vault-card {
  background: rgba(14, 12, 9, 0.75);
  border: 1px solid rgba(201, 178, 124, 0.2);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.atmi-hud-vault-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.atmi-hud-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.atmi-hud-stat-label {
  font-size: 0.6rem;
  text-transform: uppercase;
  color: rgba(201, 178, 124, 0.65);
  letter-spacing: 0.04em;
}

.atmi-hud-stat-value {
  font-size: 0.84rem;
  font-weight: 700;
  color: #fff8e7;
  display: flex;
  align-items: center;
  gap: 6px;
}

.atmi-hud-moniker-edit {
  background: transparent;
  border: none;
  color: #c9b27c;
  cursor: pointer;
  font-size: 0.75rem;
  opacity: 0.8;
  padding: 2px;
}

.atmi-hud-moniker-edit:hover {
  opacity: 1;
}

.atmi-hud-vault-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid rgba(201, 178, 124, 0.12);
  padding-top: 8px;
}

.atmi-hud-reset-btn {
  background: rgba(180, 50, 50, 0.15);
  border: 1px solid rgba(200, 70, 70, 0.4);
  color: #f8a0a0;
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 0.65rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
}

.atmi-hud-reset-btn:hover {
  background: rgba(220, 50, 50, 0.3);
  color: #fff;
  border-color: #ff6666;
}

/* Audio Controls Row */
.atmi-hud-audio-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.atmi-hud-audio-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(20, 18, 14, 0.7);
  border: 1px solid rgba(201, 178, 124, 0.28);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 0.68rem;
  font-weight: 600;
  color: rgba(201, 178, 124, 0.8);
  cursor: pointer;
  transition: all 0.18s ease;
}

.atmi-hud-audio-btn:hover {
  border-color: #c9b27c;
  color: #fff8e7;
}

.atmi-hud-audio-btn.audio-active {
  background: rgba(201, 178, 124, 0.24);
  border-color: #c9b27c;
  color: #fff8e7;
  box-shadow: 0 0 10px rgba(201, 178, 124, 0.3);
}

/* Grimoire Spell Cards */
.atmi-grimoire-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.atmi-spell-card {
  background: rgba(14, 12, 9, 0.75);
  border: 1px solid rgba(201, 178, 124, 0.22);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.atmi-spell-card:hover {
  border-color: #c9b27c;
  background: rgba(201, 178, 124, 0.08);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.atmi-spell-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.atmi-spell-name {
  font-size: 0.75rem;
  font-weight: 700;
  color: #fce5b2;
}

.atmi-spell-glyph {
  font-size: 0.84rem;
}

.atmi-spell-desc {
  font-size: 0.63rem;
  color: rgba(255, 255, 255, 0.62);
  line-height: 1.35;
}

.atmi-spell-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
}

.atmi-spell-keys {
  font-size: 0.58rem;
  color: rgba(201, 178, 124, 0.75);
  font-family: monospace;
}

.atmi-spell-cast-btn {
  background: rgba(201, 178, 124, 0.18);
  border: 1px solid rgba(201, 178, 124, 0.4);
  border-radius: 4px;
  padding: 2px 7px;
  font-size: 0.6rem;
  font-weight: 700;
  color: #fff8e7;
  cursor: pointer;
  transition: all 0.16s ease;
}

.atmi-spell-cast-btn:hover {
  background: rgba(201, 178, 124, 0.35);
  border-color: #c9b27c;
  box-shadow: 0 0 8px rgba(201, 178, 124, 0.4);
}

/* Light Theme Overrides */
[data-theme="light"] .atmi-hud-modal {
  background: rgba(252, 250, 245, 0.96);
  border-color: rgba(175, 145, 85, 0.4);
  color: #2b2416;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.25), 0 0 24px rgba(175, 145, 85, 0.2);
}

[data-theme="light"] .atmi-hud-header {
  background: rgba(245, 240, 230, 0.85);
  border-color: rgba(175, 145, 85, 0.25);
}

[data-theme="light"] .atmi-hud-title {
  color: #3d2b07;
}

[data-theme="light"] .atmi-hud-tabs {
  background: rgba(240, 235, 222, 0.8);
  border-color: rgba(175, 145, 85, 0.25);
}

[data-theme="light"] .atmi-hud-tab-btn {
  color: #68532a;
}

[data-theme="light"] .atmi-hud-tab-btn.tab-active {
  background: rgba(175, 145, 85, 0.25);
  color: #2b1f06;
  border-color: rgba(175, 145, 85, 0.5);
}

[data-theme="light"] .atmi-hud-mood-btn {
  background: rgba(245, 240, 228, 0.85);
  border-color: rgba(175, 145, 85, 0.3);
  color: #5c4310;
}

[data-theme="light"] .atmi-hud-mood-btn.mood-active {
  background: rgba(175, 145, 85, 0.25);
  border-color: #8a6824;
  color: #2b1f06;
}

[data-theme="light"] .atmi-hud-vault-card,
[data-theme="light"] .atmi-spell-card {
  background: rgba(245, 241, 232, 0.85);
  border-color: rgba(175, 145, 85, 0.28);
}

[data-theme="light"] .atmi-hud-stat-value,
[data-theme="light"] .atmi-spell-name {
  color: #2b1f06;
}

[data-theme="light"] .atmi-spell-desc {
  color: #5c4b2e;
}

/* Mobile Responsive Drawer Mode */
@media (max-width: 768px) {
  .atmi-hud-modal {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100vw;
    max-width: 100vw;
    max-height: 85vh;
    border-radius: 16px 16px 0 0;
    transform: translateY(100%);
  }

  .atmi-hud-backdrop.hud-open .atmi-hud-modal {
    transform: translateY(0);
  }

  .atmi-grimoire-grid {
    grid-template-columns: 1fr;
  }
}

/* ────────────────────────────────────────────────────────────────────────────
 * Phase 8: Page Co-Pilot & Architectural Tour Guide Engine
 * ──────────────────────────────────────────────────────────────────────────── */
.atmi-guide-card {
  position: fixed;
  bottom: 24px;
  right: 28px;
  width: 320px;
  max-width: calc(100vw - 32px);
  background: rgba(18, 16, 12, 0.95);
  border: 1px solid rgba(201, 178, 124, 0.45);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.8), 0 0 24px rgba(201, 178, 124, 0.2);
  z-index: 99995;
  color: #fff8e7;
  display: flex;
  flex-direction: column;
  gap: 8px;
  opacity: 0;
  transform: translateY(20px) scale(0.96);
  transition: opacity 0.28s cubic-bezier(0.16, 1, 0.3, 1), transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.atmi-guide-card.guide-active {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.atmi-guide-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.atmi-guide-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #c9b27c;
}

.atmi-guide-close {
  background: transparent;
  border: none;
  color: rgba(201, 178, 124, 0.6);
  font-size: 1.15rem;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: all 0.16s ease;
  line-height: 1;
}

.atmi-guide-close:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.atmi-guide-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: #fff8e7;
}

.atmi-guide-text {
  font-size: 0.74rem;
  color: rgba(255, 255, 255, 0.78);
  line-height: 1.45;
}

.atmi-guide-action-box {
  background: rgba(201, 178, 124, 0.08);
  border-left: 2px solid #c9b27c;
  padding: 6px 10px;
  border-radius: 0 6px 6px 0;
  font-size: 0.7rem;
  color: #fce5b2;
  line-height: 1.4;
  margin: 3px 0 2px 0;
}

.atmi-guide-action-box .action-label {
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: #c9b27c;
  margin-right: 4px;
}

.atmi-guide-action-box .action-text {
  color: #fff8e7;
}

.atmi-guide-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
  border-top: 1px solid rgba(201, 178, 124, 0.15);
  padding-top: 8px;
}

.atmi-guide-step-count {
  font-size: 0.65rem;
  color: rgba(201, 178, 124, 0.7);
  font-weight: 600;
}

.atmi-guide-nav-btns {
  display: flex;
  gap: 6px;
}

.atmi-guide-btn {
  background: rgba(201, 178, 124, 0.2);
  border: 1px solid rgba(201, 178, 124, 0.45);
  border-radius: 6px;
  padding: 3px 9px;
  font-size: 0.68rem;
  font-weight: 700;
  color: #fff8e7;
  cursor: pointer;
  transition: all 0.16s ease;
}

.atmi-guide-btn:hover {
  background: rgba(201, 178, 124, 0.35);
  border-color: #c9b27c;
  box-shadow: 0 0 10px rgba(201, 178, 124, 0.3);
}

.atmi-guide-btn.btn-prev {
  background: transparent;
  border-color: rgba(201, 178, 124, 0.25);
  color: rgba(201, 178, 124, 0.7);
}

.atmi-guide-btn.btn-prev:hover {
  color: #fff8e7;
  border-color: #c9b27c;
}

/* Milestone target spotlight */
.atmi-guide-target {
  position: relative;
  transition: outline 0.4s ease, box-shadow 0.4s ease;
  outline: 2px solid rgba(201, 178, 124, 0.65) !important;
  outline-offset: 6px;
  box-shadow: 0 0 35px rgba(201, 178, 124, 0.35), inset 0 0 25px rgba(201, 178, 124, 0.12) !important;
  border-radius: 10px;
}

/* Light Theme Overrides */
[data-theme="light"] .atmi-guide-card {
  background: rgba(252, 250, 245, 0.96);
  border-color: rgba(175, 145, 85, 0.4);
  color: #2b2416;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.18), 0 0 20px rgba(175, 145, 85, 0.2);
}

[data-theme="light"] .atmi-guide-title {
  color: #2b1f06;
}

[data-theme="light"] .atmi-guide-text {
  color: #5c4b2e;
}

[data-theme="light"] .atmi-guide-action-box {
  background: rgba(175, 145, 85, 0.1);
  border-left-color: #8a6824;
  color: #2b1d03;
}

[data-theme="light"] .atmi-guide-action-box .action-label {
  color: #8a6824;
}

[data-theme="light"] .atmi-guide-action-box .action-text {
  color: #1a1202;
}

[data-theme="light"] .atmi-guide-actions {
  border-top-color: rgba(175, 145, 85, 0.2);
}

[data-theme="light"] .atmi-guide-btn {
  background: rgba(175, 145, 85, 0.2);
  border-color: rgba(175, 145, 85, 0.45);
  color: #3d2b07;
}

@media (max-width: 768px) {
  .atmi-guide-card {
    right: 16px;
    left: 16px;
    bottom: 20px;
    width: auto;
    max-width: 100vw;
  }
}




/* =========================================================================
   PHASE 2: AAKRITI JELLY SQUASH & RECOIL KINEMATICS
   ========================================================================= */

/* Soft Click Compression on Swimmer & Creature */
.atmi-squishing .atmi-dart,
.aakriti-squish .atmi-dart {
  transform: scale3d(1.18, 0.82, 1) translate3d(0.8px, 1.8px, 0) !important;
  transition: transform 0.05s cubic-bezier(0.2, 0.9, 0.3, 1) !important;
}

/* Damped Spring Jelly Recoil on Mouse Release */
.aakriti-recoil .atmi-dart {
  transform: scale3d(0.92, 1.08, 1) translate3d(0, -0.8px, 0) !important;
  transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
}

/* Dizzy Swirl on Swimmer */
.atmi-dizzy .atmi-dart {
  animation: atmiDizzySwirl 0.75s ease-in-out !important;
}

/* Dizzy Spiral Eye Animation */
@keyframes aakritiSpiralEye {
  0% { transform: rotate(0deg) scale(1); }
  50% { transform: rotate(180deg) scale(0.85); }
  100% { transform: rotate(360deg) scale(1); }
}

.atmi-dizzy .aakriti-swimmer-iris,
.atmi-dizzy .atmi-iris {
  animation: aakritiSpiralEye 0.6s linear infinite !important;
  transform-origin: center center;
}

/* Micro Bioluminescent Click Bubble Particle */
.aakriti-click-bubble {
  position: fixed;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: radial-gradient(circle, #ffffff 0%, rgba(201, 178, 124, 0.85) 55%, transparent 100%);
  box-shadow: 0 0 8px rgba(252, 229, 178, 0.95);
  pointer-events: none;
  z-index: 999998;
  transform: translate(-50%, -50%) scale(0.6);
  animation: aakritiBubblePop 0.32s cubic-bezier(0.1, 0.8, 0.3, 1) forwards;
}

@keyframes aakritiBubblePop {
  0% {
    transform: translate(-50%, -50%) scale(0.6);
    opacity: 1;
  }
  50% {
    transform: translate(-50%, -10px) scale(1.3);
    opacity: 0.9;
  }
  100% {
    transform: translate(-50%, -18px) scale(0);
    opacity: 0;
  }
}

/* =========================================================================
   PHASE 3: EMOTIVE GAZE ENGINE, CURIOUS DILATION & MICRO-BLINKS
   ========================================================================= */

/* Transform origin for natural organic eye animations */
.aakriti-swimmer-eye-group {
  transform-origin: 8.5px 13px;
  will-change: transform;
}

.aakriti-swimmer-iris-wrap {
  transform-origin: 8px 12.5px;
  will-change: transform;
  transition: transform 0.08s ease-out;
}

.atmi-eye-group {
  transform-origin: 30px 21px;
  will-change: transform;
}

/* Curious Pupil Dilation & Luminous Golden Iris Glow on Button Hover */
.aakriti-curious .aakriti-swimmer-iris {
  filter: drop-shadow(0 0 3px rgba(252, 229, 178, 0.95));
  transition: filter 0.18s ease;
}

.aakriti-curious .aakriti-swimmer-body {
  stroke: #fce5b2 !important;
  stroke-width: 1.5 !important;
  transition: stroke 0.18s ease, stroke-width 0.18s ease;
}

.aakriti-curious .atmi-halo-ring {
  stroke: rgba(252, 229, 178, 0.7) !important;
}

/* Autonomous Micro-Blink (Rapid 95ms lid close & open) */
.aakriti-blinking .aakriti-swimmer-eye-group {
  transform: scaleY(0.08) !important;
  transition: transform 0.045s ease-in !important;
}

.aakriti-blinking .atmi-eye-group {
  transform: scaleY(0.08) !important;
  transition: transform 0.045s ease-in !important;
}

/* Playful Celebratory Wink on CTA Button Click */
.aakriti-winking .aakriti-swimmer-eye-group {
  transform: scaleY(0.12) rotate(-8deg) !important;
  transition: transform 0.075s cubic-bezier(0.2, 0.8, 0.3, 1) !important;
}

.aakriti-winking .atmi-eye-group {
  transform: scaleY(0.12) rotate(-8deg) !important;
  transition: transform 0.075s cubic-bezier(0.2, 0.8, 0.3, 1) !important;
}

/* =========================================================================
   PHASE 4: PLAYFUL ANTICS, TICKLE WIGGLE & SLEEPY IDLE
   ========================================================================= */

/* Playful Tickle Rubber-Band Wiggle */
@keyframes aakritiTickleWiggle {
  0% { transform: scale(1) rotate(0deg); }
  20% { transform: scale(1.12, 0.9) rotate(-7deg); }
  40% { transform: scale(0.92, 1.1) rotate(7deg); }
  60% { transform: scale(1.06, 0.96) rotate(-4deg); }
  80% { transform: scale(0.98, 1.02) rotate(3deg); }
  100% { transform: scale(1) rotate(0deg); }
}

.aakriti-tickle-wiggle .atmi-dart,
.aakriti-tickle-wiggle .atmi-creature {
  animation: aakritiTickleWiggle 0.44s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
}

/* Sleepy Idle Droopy Lids & Calm Breathing Aura */
.aakriti-sleepy .aakriti-swimmer-eye-group,
.aakriti-sleepy .atmi-eye-group {
  transform: scaleY(0.28) !important;
  opacity: 0.8;
  transition: transform 0.6s cubic-bezier(0.2, 0.8, 0.3, 1), opacity 0.6s ease !important;
}

.aakriti-sleepy .aakriti-swimmer-body {
  filter: brightness(0.85);
  transition: filter 0.8s ease;
}

.aakriti-sleepy .atmi-halo-ring {
  opacity: 0.35 !important;
  transition: opacity 0.8s ease;
}

.aakriti-sleepy .atmi-thought-bubble {
  opacity: 0.88;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.4));
}
