:root {
  --bg-primary: #FFFDF8;
  --bg-sidebar: #F7EFE0;
  --bg-card: #FFFDF9;
  --text-primary: #26170B;
  --gold-border: #D4AF37;
  --gold-glow: rgba(212, 175, 55, 0.38);
  --sigil-glow: drop-shadow(0 1px 2px rgba(180, 125, 24, 0.28));
  --list-marker-color: #B47814;
}

html.dark {
  --bg-primary: #030611;
  --bg-sidebar: #060B19;
  --bg-card: #0A1124;
  --text-primary: #E2E8F0;
  --gold-border: rgba(56, 189, 248, 0.45);
  --gold-glow: rgba(79, 70, 229, 0.35);
  --sigil-glow: drop-shadow(0 0 5px rgba(56, 189, 248, 0.35));
  --list-marker-color: #38BDF8;
}

html,
body {
  height: 100dvh;
  max-width: 100vw;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  transition: background-color 0.35s ease, color 0.35s ease;
}

/* Unified Sacred Display Headings */
.cinzel,
.serif-heading,
.sacred-display {
  font-family: 'Marcellus', Georgia, serif !important;
  letter-spacing: 0.06em;
}

/* Tabular Sacred Timer & Clock Numerals */
.font-mono {
  font-family: 'JetBrains Mono', monospace !important;
}

/* Uniform Monoline Sacred Geometric SVG Sigils */
.sacred-sigil {
  display: inline-block;
  vertical-align: -0.16em;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.55;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: var(--sigil-glow);
  transition: transform 0.25s ease, color 0.25s ease, filter 0.25s ease;
}

button:hover .sacred-sigil {
  transform: scale(1.07);
}

/* Outer Sanctuary Frame (Edge-to-Edge on Mobile, Framed on sm+ Tablet/Desktop) */
.sanctuary-frame {
  border: 2px solid var(--gold-border);
  box-shadow: inset 0 0 0 1px rgba(212, 175, 55, 0.25), inset 0 0 32px var(--gold-glow);
}

@media (max-width: 639.98px) {
  .sanctuary-frame {
    border-width: 0 !important;
    border-radius: 0 !important;
  }
}

html.dark .sanctuary-frame {
  background: radial-gradient(circle at 55% 35%, #0B132B 0%, #050814 60%, #020308 100%) !important;
  box-shadow: inset 0 0 0 1px rgba(56, 189, 248, 0.22), inset 0 0 42px rgba(79, 70, 229, 0.28);
}

html.dark main {
  background: transparent !important;
}

html.dark aside#sanctuarySidebar {
  background: rgba(6, 10, 24, 0.94) !important;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

html.dark header,
html.dark footer {
  background: rgba(7, 12, 26, 0.84) !important;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

/* =========================================================================
   UNIVERSAL RESPONSIVE SIDEBAR DRAWER & VIEWPORT BREAKPOINTS
   ========================================================================= */
@media (max-width: 767.98px) {
  #sanctuarySidebar {
    position: fixed !important;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 40 !important;
    width: min(86vw, 336px) !important;
    max-width: 86vw !important;
    transform: translateX(-104%);
    pointer-events: none;
    transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
  }

  #sanctuarySidebar.mobile-open {
    transform: translateX(0) !important;
    pointer-events: auto !important;
  }
}

@media (min-width: 768px) {
  #sanctuarySidebar {
    position: relative !important;
    transform: translateX(0) !important;
    pointer-events: auto !important;
    width: 292px;
  }

  #sanctuarySidebar.desktop-collapsed {
    display: none !important;
  }
}

@media (min-width: 1024px) {
  #sanctuarySidebar {
    width: 336px;
  }
}

@media (min-width: 1536px) {
  #sanctuarySidebar {
    width: 356px;
  }

  #chatContainer > div {
    max-width: 58rem;
    margin-left: auto;
    margin-right: auto;
  }
}

/* Notch & Home-Indicator Safe Areas + Mobile Input Anti-Zoom */
.safe-top-inset {
  padding-top: env(safe-area-inset-top, 0px);
}

.safe-bottom-inset {
  padding-bottom: max(0.75rem, env(safe-area-inset-bottom, 0px));
}

@media (max-width: 639.98px) {
  #messageInput,
  .auth-portal-input,
  .cosmic-input {
    font-size: 16px !important;
  }
}

/* Guruji & Sadhaka Literary Manuscript Typography (Spectral with Full IAST Sanskrit Support) */
.prose-guru {
  font-family: 'Spectral', Georgia, serif;
  font-size: 1.06em;
  font-weight: 400;
  letter-spacing: 0.008em;
  perspective: 750px;
  overflow-wrap: anywhere;
}

.sadhaka-chat-bubble {
  font-family: 'Spectral', Georgia, serif;
  font-size: 1.03em;
  letter-spacing: 0.006em;
  overflow-wrap: anywhere;
}

.prose-guru h1,
.prose-guru h2,
.prose-guru h3,
.prose-guru h4 {
  font-family: 'Marcellus', Georgia, serif;
  letter-spacing: 0.04em;
  margin-top: 1rem;
  margin-bottom: 0.45rem;
  color: #7A4B0A;
}

html.dark .prose-guru h1,
html.dark .prose-guru h2,
html.dark .prose-guru h3,
html.dark .prose-guru h4 {
  color: #BAE6FD;
}

.prose-guru p {
  margin-bottom: 0.88rem;
  line-height: 1.78;
}

.prose-guru p:last-child {
  margin-bottom: 0;
}

.prose-guru em {
  font-style: italic;
  color: #784B10;
}

html.dark .prose-guru em {
  color: #CBD5E1;
}

.prose-guru ul,
.prose-guru ol {
  margin-left: 1.35rem;
  margin-bottom: 0.88rem;
}

.prose-guru ul {
  list-style-type: none;
  margin-left: 0.35rem;
}

.prose-guru ul > li {
  position: relative;
  padding-left: 1.15rem;
}

.prose-guru ul > li::before {
  content: "❖";
  position: absolute;
  left: 0;
  top: 0.05em;
  font-size: 0.72em;
  color: var(--list-marker-color);
  opacity: 0.88;
}

.prose-guru ol {
  list-style-type: decimal;
}

.prose-guru li {
  margin-bottom: 0.42rem;
  line-height: 1.74;
}

.prose-guru strong {
  color: #8C580C;
  font-weight: 600;
}

html.dark .prose-guru strong {
  color: #7DD3FC;
  font-weight: 600;
}

/* Glowing & Dimming Pulse Line for Thinking */
@keyframes pulseGlowLight {
  0% { opacity: 0.25; transform: scaleX(0.92); }
  50% { opacity: 1; transform: scaleX(1); box-shadow: 0 0 14px rgba(180, 115, 18, 0.75), 0 0 6px rgba(212, 175, 55, 0.9); }
  100% { opacity: 0.25; transform: scaleX(0.92); }
}

@keyframes pulseGlowDark {
  0% { opacity: 0.3; transform: scaleX(0.92); }
  50% { opacity: 1; transform: scaleX(1); box-shadow: 0 0 18px rgba(56, 189, 248, 0.9), 0 0 8px rgba(129, 140, 248, 0.85); }
  100% { opacity: 0.3; transform: scaleX(0.92); }
}

.thinking-pulse {
  animation: pulseGlowLight 2s infinite ease-in-out;
}

html.dark .thinking-pulse {
  animation: pulseGlowDark 2s infinite ease-in-out;
}

/* Subtle cursor shimmer while streaming */
.streaming-cursor::after {
  content: " ●";
  color: var(--list-marker-color);
  font-size: 0.75em;
  animation: blinkDot 0.9s infinite;
}

@keyframes blinkDot {
  0%, 100% { opacity: 0.2; }
  50% { opacity: 1; }
}

/* AKṢARA-PRĀKAṬYA: 3D WORD & LETTER EMERGENCE FROM BACKGROUND DEPTH */
.prakatya-word {
  display: inline-block;
  white-space: pre;
  transform-style: preserve-3d;
}

@keyframes aksharaEmergeFromGround {
  0% {
    opacity: 0;
    filter: blur(9px);
    transform: translate3d(0, 10px, -85px) scale(0.72);
    text-shadow: 0 0 18px rgba(212, 175, 55, 0.75);
  }
  55% {
    opacity: 0.82;
    filter: blur(2px);
    transform: translate3d(0, 2px, -15px) scale(0.96);
    text-shadow: 0 0 8px rgba(212, 175, 55, 0.35);
  }
  100% {
    opacity: 1;
    filter: blur(0px);
    transform: translate3d(0, 0, 0) scale(1);
    text-shadow: none;
  }
}

.prakatya-char {
  display: inline-block;
  opacity: 0;
  will-change: transform, opacity, filter;
  animation: aksharaEmergeFromGround 0.68s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes letterEmergeFromDepth {
  0% {
    opacity: 0;
    filter: blur(7px);
    transform: translateY(6px) scale(0.38);
  }
  70% {
    opacity: 0.78;
    filter: blur(1.2px);
    transform: translateY(1px) scale(0.94);
  }
  100% {
    opacity: 1;
    filter: blur(0px);
    transform: translateY(0px) scale(1);
  }
}

.char-emerge {
  display: inline-block;
  will-change: transform, opacity, filter;
  animation: letterEmergeFromDepth 95ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.char-space {
  display: inline;
}

/* =========================================================================
   UNIVERSAL MULTI-SCREEN COMPATIBILITY (320px Ultra-Narrow -> 4K Desktop)
   ========================================================================= */
#sessionStarterChips {
  scrollbar-width: none;
  -ms-overflow-style: none;
}
#sessionStarterChips::-webkit-scrollbar {
  display: none;
}

@media (max-width: 639.98px) {
  #sessionStarterChips {
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    justify-content: flex-start !important;
    padding-bottom: 2px;
  }
  #sessionStarterChips > button {
    flex-shrink: 0 !important;
    font-size: 11px !important;
    padding: 0.28rem 0.65rem !important;
    white-space: nowrap !important;
  }
  .cosmic-modal-card {
    max-height: 92dvh !important;
    overflow-y: auto !important;
    padding: 1rem !important;
    margin: 0.5rem !important;
  }
}

@media (max-width: 374.98px) {
  #sanctuaryBrandTitle {
    font-size: 11px !important;
    letter-spacing: 0.08em !important;
  }
  #sendBtn {
    padding-left: 0.6rem !important;
    padding-right: 0.6rem !important;
  }
  #voiceMicBtn,
  #maharishiModeBtn {
    width: 2.25rem !important;
    height: 2.25rem !important;
  }
}

@media (min-width: 768px) and (max-width: 1023.98px) {
  #sanctuarySidebar {
    width: 280px !important;
  }
}

@media (max-height: 540px) and (orientation: landscape) {
  #sanctuaryTopHeader {
    min-height: 46px !important;
    padding-top: 2px !important;
    padding-bottom: 2px !important;
  }
  #messageInput {
    max-height: 2.4rem;
  }
  .cosmic-modal-card {
    max-height: 94dvh !important;
    overflow-y: auto !important;
  }
}
