/* ==============================================================================
   Namastay Sanctuary · Architectural & Tactile Design System
   Earthy Mineral Ground, High-Contrast Editorial Typography, & White Scroll
   ============================================================================== */

:root {
  --font-serif: 'Cormorant Garamond', Georgia, serif;
  --font-sans: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Grounded Basalt & Mineral Surfaces */
  --bg-ground: #101312;
  --surface-panel: rgba(20, 24, 23, 0.92);
  --surface-solid: #161a19;
  --surface-subtle: #1d2321;
  --line-hairline: rgba(232, 222, 206, 0.15);
  --line-strong: rgba(232, 222, 206, 0.34);

  /* WCAG AAA Typography Tokens on Dark Ground */
  --text-pure: #f8f5ee;
  --text-body: #e2dbd0;
  --text-muted: #b5ac9e;
  --text-dim: #968d7f;

  /* Active Room Mineral Accent (Updated per room; always high-contrast) */
  --room-accent: #dba088;

  /* White Scroll Manuscript Tokens (WCAG AAA on Warm White Paper) */
  --paper-white: #faf8f3;
  --paper-inset: #f3eee3;
  --paper-ink: #191614;
  --paper-body: #2c2520;
  --paper-muted: #5c4f42;
  --paper-rule: rgba(92, 74, 54, 0.16);
  --paper-border: rgba(92, 74, 54, 0.28);
  --cinnabar: #8c2d19;
  --cinnabar-deep: #6e2010;
  --brass-rule: #b58d47;
}

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

[hidden] {
  display: none !important;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-ground);
  color: var(--text-body);
  font-family: var(--font-sans);
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  user-select: none;
}

/* 1. Full-Viewport Tactile Room Canvas */
#sanctuary-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  display: block;
  touch-action: none;
}

/* Subtle Matte Edge Shading (Linear only; zero radial/neon glow) */
.ambient-vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  background: linear-gradient(180deg, rgba(10, 12, 11, 0.42) 0%, transparent 18%, transparent 82%, rgba(10, 12, 11, 0.58) 100%);
}

/* 2. Spatial Architectural Frame */
.sanctuary-hud {
  position: relative;
  z-index: 10;
  width: 100%;
  max-width: 100vw;
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto 1fr auto;
  padding: 1.35rem 2rem;
  pointer-events: none;
}

/* Top Navigation Bar */
.hud-header {
  pointer-events: auto;
  min-width: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line-hairline);
}

.brand-anchor {
  display: inline-flex;
  align-items: baseline;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--text-pure);
  transition: opacity 0.2s ease;
}

.brand-anchor:hover {
  opacity: 0.82;
}

.brand-logo-txt {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 400;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

.brand-badge {
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-left: 1px solid var(--line-hairline);
  padding-left: 0.75rem;
}

.hud-actions {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--line-hairline);
  background: var(--surface-panel);
  border-radius: 2px;
}

.hud-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: transparent;
  border: none;
  border-right: 1px solid var(--line-hairline);
  color: var(--text-body);
  padding: 0.54rem 0.95rem;
  font-family: var(--font-sans);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.hud-btn:last-child {
  border-right: none;
}

.hud-btn:hover {
  background: var(--surface-subtle);
  color: var(--text-pure);
}

.hud-btn.active {
  color: var(--room-accent);
  background: var(--surface-subtle);
}

.hud-btn--scroll {
  color: var(--text-pure);
  font-weight: 600;
}

.scroll-indicator-dot {
  width: 6px;
  height: 6px;
  border-radius: 1px;
  background: var(--line-strong);
  transition: background-color 0.2s ease;
}

.hud-btn--scroll.has-entry .scroll-indicator-dot {
  background: #c84b31;
}

/* Sound Wave Bars */
.sound-waves {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 10px;
}

.sound-bar {
  width: 2px;
  height: 3px;
  background-color: currentColor;
}

.hud-btn.active .sound-bar {
  animation: soundPulse 0.9s ease-in-out infinite alternate;
}
.hud-btn.active .sound-bar:nth-child(2) { animation-delay: 0.2s; }
.hud-btn.active .sound-bar:nth-child(3) { animation-delay: 0.4s; }

@keyframes soundPulse {
  0% { height: 3px; }
  100% { height: 10px; }
}

/* 3. Quiet Museum Wall Plaque (Upper-Left, Leaves Center Stage Open) */
.stage-layer {
  position: relative;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.room-plaque {
  position: absolute;
  top: 1.4rem;
  left: 0;
  max-width: 340px;
  pointer-events: none;
}

.plaque-eyebrow {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--room-accent);
  margin-bottom: 0.45rem;
}

.plaque-heading-row {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.3rem;
}

.room-title {
  font-family: var(--font-serif);
  font-size: clamp(2.1rem, 3.4vw, 2.85rem);
  font-weight: 400;
  letter-spacing: 0.04em;
  color: var(--text-pure);
  line-height: 1.05;
}

/* Zero letter-spacing so Devanagari Shirorekha connects cleanly */
.room-devanagari {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  font-weight: 400;
  letter-spacing: 0;
  color: var(--room-accent);
  line-height: 1;
}

.room-subtitle {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.16rem;
  line-height: 1.4;
  color: var(--text-body);
  margin-bottom: 0.75rem;
}

.room-gesture {
  font-size: 0.78rem;
  line-height: 1.65;
  color: var(--text-muted);
  border-left: 2px solid var(--room-accent);
  padding-left: 0.75rem;
}

.room-reset-btn {
  pointer-events: auto;
  margin-top: 0.85rem;
  background: var(--surface-panel);
  border: 1px solid var(--line-hairline);
  border-radius: 2px;
  color: var(--text-muted);
  padding: 0.38rem 0.75rem;
  font-family: var(--font-sans);
  font-size: 0.66rem;
  font-weight: 500;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.room-reset-btn:hover {
  border-color: var(--room-accent);
  color: var(--text-pure);
}

/* Tactile Unbleached Linen Slip in Room V (Aparigraha) */
.aparigraha-slip-ui {
  pointer-events: auto;
  position: absolute;
  left: 57%;
  top: 52%;
  transform: translate(-50%, -50%);
  width: min(340px, 86vw);
  background: #f5f0e6;
  color: #1c1815;
  border: 1px solid rgba(89, 69, 55, 0.38);
  border-radius: 2px;
  padding: 1.25rem 1.4rem;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
}

.slip-kicker {
  font-size: 0.64rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #6b5846;
  margin-bottom: 0.55rem;
}

.slip-form {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  border-bottom: 1px solid rgba(89, 69, 55, 0.32);
  padding-bottom: 0.35rem;
}

.slip-input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.15rem;
  color: #1c1815;
  outline: none;
}

.slip-input::placeholder {
  color: #877562;
}

.slip-release-btn {
  appearance: none;
  background: #231d18;
  color: #faf8f3;
  border: 1px solid #231d18;
  border-radius: 2px;
  padding: 0.42rem 0.8rem;
  font-family: var(--font-sans);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.slip-release-btn:hover {
  background: var(--cinnabar);
  border-color: var(--cinnabar);
}

/* 4. Single-Line Architectural Bottom Room Index */
.hud-footer {
  pointer-events: auto;
  min-width: 0;
  display: flex;
  justify-content: center;
  width: 100%;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line-hairline);
}

.room-dock {
  display: flex;
  align-items: stretch;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  background: var(--surface-panel);
  border: 1px solid var(--line-hairline);
  border-radius: 2px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.room-dock::-webkit-scrollbar {
  display: none;
}

.dock-arrow {
  appearance: none;
  background: transparent;
  border: none;
  border-right: 1px solid var(--line-hairline);
  color: var(--text-muted);
  width: 38px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.dock-arrow:last-child {
  border-right: none;
  border-left: 1px solid var(--line-hairline);
}

.dock-arrow:hover {
  color: var(--text-pure);
  background: var(--surface-subtle);
}

.dock-divider {
  width: 1px;
  background: var(--line-strong);
  flex-shrink: 0;
}

.dock-item {
  appearance: none;
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 0.5rem 0.65rem;
  background: transparent;
  border: none;
  border-right: 1px solid var(--line-hairline);
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap;
  position: relative;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.dock-item:hover {
  color: var(--text-pure);
  background: var(--surface-subtle);
}

.dock-item.active {
  background: var(--surface-subtle);
  color: var(--room-accent);
  font-weight: 600;
  box-shadow: inset 0 2px 0 var(--room-accent);
}

.dock-item__num {
  font-size: 0.58rem;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  margin-bottom: 2px;
}

.dock-item.active .dock-item__num {
  color: var(--room-accent);
}

.dock-item.written::after {
  content: "";
  position: absolute;
  top: 6px;
  right: 6px;
  width: 4px;
  height: 4px;
  background: #c84b31;
}

/* ==============================================================================
   5. SLIDE-OVER DRAWER: Classical Sūtra & Contemplation
   ============================================================================== */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 10, 9, 0.72);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease;
}

.drawer-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.sanctuary-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(520px, 94vw);
  background: var(--surface-solid);
  border-left: 1px solid var(--line-hairline);
  box-shadow: -24px 0 60px rgba(0, 0, 0, 0.6);
  z-index: 101;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.34s cubic-bezier(0.16, 1, 0.3, 1);
  padding: 2.2rem 2.2rem;
  overflow-y: auto;
  user-select: text;
}

.sanctuary-drawer.open {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.6rem;
  border-bottom: 1px solid var(--line-hairline);
  padding-bottom: 1.1rem;
}

.drawer-title {
  font-family: var(--font-serif);
  font-size: 2.05rem;
  font-weight: 400;
  color: var(--text-pure);
  letter-spacing: 0.04em;
}

.drawer-subtitle {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--room-accent);
  margin-top: 0.28rem;
}

.drawer-close {
  background: transparent;
  border: 1px solid var(--line-hairline);
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 2px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.drawer-close:hover {
  color: var(--text-pure);
  border-color: var(--line-strong);
}

.sutra-card {
  background: var(--surface-subtle);
  border: 1px solid var(--line-hairline);
  border-left: 3px solid var(--room-accent);
  padding: 1.4rem 1.5rem;
  margin-bottom: 1.6rem;
}

.sutra-sanskrit {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  line-height: 1.55;
  letter-spacing: 0;
  color: var(--text-pure);
  margin-bottom: 0.5rem;
}

.sutra-transliteration {
  font-style: italic;
  font-size: 0.86rem;
  color: var(--text-muted);
  margin-bottom: 0.9rem;
  line-height: 1.5;
}

.sutra-translation {
  font-size: 0.92rem;
  line-height: 1.72;
  color: var(--text-body);
  border-top: 1px solid var(--line-hairline);
  padding-top: 0.85rem;
}

.drawer-section-title {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 400;
  color: var(--text-pure);
  letter-spacing: 0.04em;
  margin: 1.3rem 0 0.65rem;
}

.drawer-prose {
  font-size: 0.88rem;
  line-height: 1.82;
  color: var(--text-body);
}

.drawer-list {
  padding-left: 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-bottom: 1.8rem;
}

.drawer-to-scroll-btn {
  margin-top: auto;
  align-self: flex-start;
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  color: var(--text-pure);
  padding: 0.65rem 1.2rem;
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.drawer-to-scroll-btn:hover {
  border-color: var(--room-accent);
  background: var(--surface-subtle);
}

/* ==============================================================================
   6. THE RIGHT-HAND WHITE SCROLL: Subtle Handmade Paper & Romantic Mysticism
   ============================================================================== */
.sacred-scroll-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(580px, 96vw);
  background: var(--paper-white);
  color: var(--paper-ink);
  box-shadow: -28px 0 70px rgba(0, 0, 0, 0.58);
  z-index: 102;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.38s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
  border-left: 1px solid rgba(72, 54, 38, 0.32);
  user-select: text;
}

.sacred-scroll-drawer.open {
  transform: translateX(0);
}

/* Slender Architectural Walnut & Antique-Brass Scroll Trim */
.scroll-edge-bar {
  height: 10px;
  width: 100%;
  background: #261e18;
  border-bottom: 1px solid var(--brass-rule);
  flex-shrink: 0;
  position: relative;
  z-index: 3;
}

.scroll-edge-bar--bottom {
  border-bottom: none;
  border-top: 1px solid var(--brass-rule);
}

/* Unfurled White Cotton-Rag Paper Body with Subtle Top/Bottom Roll Shading */
.scroll-parchment-body {
  flex: 1;
  overflow-y: auto;
  padding: 2rem 2.4rem;
  background-color: var(--paper-white);
  background-image: linear-gradient(
    180deg,
    rgba(62, 46, 30, 0.07) 0px,
    rgba(62, 46, 30, 0) 26px,
    rgba(62, 46, 30, 0) calc(100% - 26px),
    rgba(62, 46, 30, 0.07) 100%
  );
  position: relative;
  display: flex;
  flex-direction: column;
}

/* Blind-Embossed Sacred Lotus Watermark */
.scroll-watermark {
  position: absolute;
  top: 52%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 250px;
  height: 250px;
  pointer-events: none;
  opacity: 0.045;
  color: #7c5c2b;
}

/* Sync & Account Bar */
.vault-sync-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  color: var(--paper-muted);
  text-transform: uppercase;
  border-bottom: 1px solid var(--paper-rule);
  padding-bottom: 0.7rem;
  margin-bottom: 1.35rem;
  position: relative;
  z-index: 2;
}

.vault-badge {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 500;
}

.vault-status-dot {
  width: 5px;
  height: 5px;
  background: #2f6b47;
}

.vault-status-dot.local {
  background: #9a6b24;
}

.vault-user-btn {
  background: transparent;
  border: 1px solid var(--paper-border);
  padding: 0.32rem 0.75rem;
  border-radius: 2px;
  font-family: var(--font-sans);
  font-size: 0.66rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--paper-body);
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.vault-user-btn:hover {
  background: var(--paper-inset);
  border-color: var(--paper-ink);
}

/* Scroll Room Header */
.scroll-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.25rem;
  position: relative;
  z-index: 2;
}

.scroll-kicker-row {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  margin-bottom: 0.15rem;
}

.scroll-realm-caption {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--paper-muted);
}

.scroll-devanagari-subtitle {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  letter-spacing: 0;
  color: var(--cinnabar);
}

.scroll-title {
  font-family: var(--font-serif);
  font-size: 2.15rem;
  font-weight: 400;
  color: var(--paper-ink);
  letter-spacing: 0.03em;
  line-height: 1.08;
}

.scroll-close-btn {
  background: transparent;
  border: 1px solid var(--paper-border);
  color: var(--paper-body);
  width: 30px;
  height: 30px;
  border-radius: 2px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  transition: border-color 0.2s ease, color 0.2s ease, background-color 0.2s ease;
}

.scroll-close-btn:hover {
  border-color: var(--cinnabar);
  color: var(--cinnabar);
  background: var(--paper-inset);
}

/* Double-Hairline Manuscript Frame */
.scroll-filigree-frame {
  flex: 1;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--paper-border);
  padding: 1.45rem 1.55rem;
  border-radius: 2px;
  position: relative;
  background: rgba(255, 254, 250, 0.78);
  margin-bottom: 1.1rem;
  z-index: 2;
}

.scroll-filigree-frame::before {
  content: "";
  position: absolute;
  inset: 3px;
  border: 1px solid rgba(138, 108, 66, 0.14);
  pointer-events: none;
}

.scroll-inquiry-box {
  background: var(--paper-inset);
  border-left: 2px solid var(--cinnabar);
  padding: 0.85rem 1.1rem;
  margin-bottom: 1.15rem;
}

.scroll-inquiry-label {
  font-size: 0.63rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--cinnabar);
  margin-bottom: 0.3rem;
  font-weight: 600;
}

.scroll-inquiry-prompt {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.12rem;
  line-height: 1.55;
  color: var(--paper-ink);
}

/* Hand-Ruled Manuscript Textarea: 36px baseline aligned pixel-for-pixel */
.scroll-textarea {
  flex: 1;
  width: 100%;
  min-height: 252px;
  background-color: transparent;
  border: none;
  color: var(--paper-ink);
  font-family: var(--font-serif);
  font-size: 1.2rem;
  line-height: 36px;
  padding: 0 0.15rem;
  resize: vertical;
  outline: none;
  background-image: linear-gradient(to bottom, transparent 35px, rgba(92, 74, 54, 0.15) 35px, rgba(92, 74, 54, 0.15) 36px);
  background-size: 100% 36px;
  background-attachment: local;
}

.scroll-textarea::placeholder {
  color: #827362;
  font-style: italic;
}

/* Quiet Scroll Footer & Cinnabar Seal */
.scroll-meta-strip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.72rem;
  color: var(--paper-muted);
  letter-spacing: 0.04em;
  margin-bottom: 1rem;
  position: relative;
  z-index: 2;
}

.scroll-save-status {
  color: var(--paper-muted);
  font-weight: 500;
}

.wax-seal-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.85rem;
  flex-wrap: wrap;
  position: relative;
  z-index: 2;
}

.wax-seal-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.68rem 1.35rem;
  background: var(--cinnabar);
  color: #fcfbf7;
  border: 1px solid var(--cinnabar-deep);
  border-radius: 2px;
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.wax-seal-btn:hover {
  background: var(--cinnabar-deep);
}

.wax-seal-btn.sealed {
  background: var(--paper-inset);
  color: var(--cinnabar);
  border-color: var(--cinnabar);
}

.wax-seal-stamp {
  font-family: var(--font-serif);
  font-size: 0.9rem;
  line-height: 1;
}

.btn-view-codex {
  background: transparent;
  border: 1px solid var(--paper-border);
  color: var(--paper-body);
  padding: 0.68rem 1.2rem;
  border-radius: 2px;
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.btn-view-codex:hover {
  border-color: var(--paper-ink);
  background: var(--paper-inset);
}

/* ==============================================================================
   7. PRACTITIONER ACCOUNT MODAL
   ============================================================================== */
.auth-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 10, 9, 0.74);
  z-index: 199;
  display: none;
}

.auth-backdrop.open {
  display: block;
}

.auth-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 200;
  width: min(420px, 92vw);
  background: var(--paper-white);
  color: var(--paper-ink);
  border: 1px solid var(--paper-border);
  border-top: 3px solid var(--cinnabar);
  border-radius: 2px;
  padding: 2rem 2.2rem;
  box-shadow: 0 25px 70px rgba(0, 0, 0, 0.6);
  display: none;
  user-select: text;
}

.auth-modal.open {
  display: block;
}

.auth-header {
  margin-bottom: 1.35rem;
}

.auth-title {
  font-family: var(--font-serif);
  font-size: 1.8rem;
  font-weight: 400;
  color: var(--paper-ink);
}

.auth-subtitle {
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--paper-muted);
  margin-top: 0.25rem;
}

.auth-tabs {
  display: flex;
  border-bottom: 1px solid var(--paper-rule);
  margin-bottom: 1.25rem;
}

.auth-tab {
  flex: 1;
  text-align: center;
  padding: 0.58rem 0;
  font-family: var(--font-sans);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--paper-muted);
  cursor: pointer;
}

.auth-tab.active {
  color: var(--cinnabar);
  border-bottom-color: var(--cinnabar);
  font-weight: 600;
}

.auth-input-group {
  margin-bottom: 1rem;
}

.auth-label {
  display: block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  color: var(--paper-muted);
  margin-bottom: 0.32rem;
  font-weight: 600;
}

.auth-input {
  width: 100%;
  padding: 0.68rem 0.85rem;
  border: 1px solid var(--paper-border);
  border-radius: 2px;
  background: #ffffff;
  color: var(--paper-ink);
  font-family: var(--font-sans);
  font-size: 0.88rem;
  outline: none;
}

.auth-input:focus {
  border-color: var(--cinnabar);
}

.auth-error {
  color: var(--cinnabar);
  font-size: 0.78rem;
  line-height: 1.45;
  margin-bottom: 0.85rem;
}

.auth-btn-primary {
  width: 100%;
  padding: 0.8rem;
  background: var(--paper-ink);
  color: var(--paper-white);
  border: 1px solid var(--paper-ink);
  border-radius: 2px;
  font-family: var(--font-sans);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  margin-top: 0.35rem;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.auth-btn-primary:hover {
  background: var(--cinnabar);
  border-color: var(--cinnabar);
}

.auth-footer-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.9rem;
}

/* ==============================================================================
   8. COMPLETE REFLECTION SCROLL OVERLAY (All 10 Rooms)
   ============================================================================== */
.codex-overlay {
  position: fixed;
  inset: 0;
  z-index: 150;
  background: rgba(10, 12, 11, 0.86);
  display: none;
  justify-content: center;
  align-items: center;
  padding: 1.8rem;
  user-select: text;
}

.codex-overlay.open {
  display: flex;
}

.codex-scroll-container {
  width: min(840px, 96vw);
  max-height: 90vh;
  background: var(--paper-white);
  color: var(--paper-ink);
  border: 1px solid var(--paper-border);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.75);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.codex-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.9rem 2rem;
  background: var(--paper-inset);
  border-bottom: 1px solid var(--paper-rule);
}

.codex-scroll-content {
  overflow-y: auto;
  padding: 2.6rem 3rem;
}

.codex-manuscript-head {
  text-align: center;
  margin-bottom: 2.4rem;
  padding-bottom: 1.6rem;
  border-bottom: 1px solid var(--paper-border);
}

.codex-manuscript-kicker {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--cinnabar);
}

.codex-manuscript-title {
  font-family: var(--font-serif);
  font-size: 2.4rem;
  font-weight: 400;
  color: var(--paper-ink);
  margin: 0.35rem 0;
}

.codex-manuscript-meta {
  font-size: 0.74rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--paper-muted);
}

.codex-entry-card {
  border-bottom: 1px solid var(--paper-rule);
  padding-bottom: 1.8rem;
  margin-bottom: 2rem;
}

.codex-entry-card:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.codex-entry-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.codex-entry-eyebrow {
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--paper-muted);
}

.codex-entry-title {
  font-family: var(--font-serif);
  font-size: 1.85rem;
  font-weight: 400;
  color: var(--paper-ink);
  margin: 0.1rem 0;
}

.codex-entry-devanagari {
  font-size: 1.3rem;
  letter-spacing: 0;
  color: var(--cinnabar);
  margin-left: 0.45rem;
}

.codex-entry-sub {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1rem;
  color: var(--paper-muted);
}

.codex-seal-mark {
  display: inline-block;
  padding: 0.24rem 0.6rem;
  border: 1px solid var(--cinnabar);
  color: var(--cinnabar);
  font-size: 0.64rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
}

.codex-entry-prompt {
  background: var(--paper-inset);
  border-left: 2px solid var(--brass-rule);
  padding: 0.65rem 1rem;
  margin-bottom: 1rem;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.02rem;
  color: var(--paper-body);
}

.codex-entry-body {
  font-family: var(--font-serif);
  font-size: 1.18rem;
  line-height: 1.8;
  color: var(--paper-ink);
  white-space: pre-wrap;
}

.codex-entry-empty {
  font-style: italic;
  color: #877764;
}

/* ==============================================================================
   9. RESPONSIVE & PRINT LAYOUTS
   ============================================================================== */
@media (max-width: 959px) {
  .sanctuary-hud {
    padding: 0.85rem 1rem;
  }

  .brand-logo-txt {
    font-size: 1.02rem;
    letter-spacing: 0.16em;
  }

  .brand-badge {
    display: none;
  }

  .hud-btn {
    padding: 0.44rem 0.56rem;
    font-size: 0.62rem;
    letter-spacing: 0.08em;
    gap: 0.35rem;
  }

  .sound-waves {
    display: none;
  }

  .room-plaque {
    top: 0.7rem;
    max-width: 100%;
  }

  .room-title {
    font-size: 1.75rem;
  }

  .room-subtitle {
    font-size: 0.98rem;
    margin-bottom: 0.4rem;
  }

  .room-gesture {
    font-size: 0.72rem;
  }

  .aparigraha-slip-ui {
    left: 50%;
    top: 60%;
  }

  .dock-arrow {
    display: none;
  }

  .sacred-scroll-drawer,
  .sanctuary-drawer {
    width: 100%;
    max-width: 100vw;
  }

  .scroll-parchment-body {
    padding: 1.35rem 1.15rem;
  }

  .scroll-filigree-frame {
    padding: 1.1rem 1rem;
  }

  .codex-scroll-content {
    padding: 1.4rem 1.15rem;
  }
}

@media (max-width: 480px) {
  .sanctuary-hud {
    padding: 0.75rem 0.8rem;
  }

  .hud-header {
    gap: 0.45rem;
    padding-bottom: 0.75rem;
  }

  .brand-logo-txt {
    font-size: 0.92rem;
    letter-spacing: 0.12em;
  }

  .hud-btn {
    padding: 0.42rem 0.44rem;
    font-size: 0.58rem;
    letter-spacing: 0.05em;
    gap: 0.28rem;
  }

  #user-display-name {
    max-width: 68px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

@media print {
  html, body {
    overflow: visible;
    height: auto;
    background: #ffffff;
    color: #000000;
  }

  #sanctuary-canvas,
  .ambient-vignette,
  .sanctuary-hud,
  .drawer-backdrop,
  .sanctuary-drawer,
  .sacred-scroll-drawer,
  .auth-backdrop,
  .auth-modal,
  .codex-toolbar,
  .scroll-edge-bar {
    display: none !important;
  }

  .codex-overlay {
    position: static;
    display: block !important;
    background: #ffffff;
    padding: 0;
  }

  .codex-scroll-container {
    width: 100%;
    max-height: none;
    border: none;
    box-shadow: none;
  }

  .codex-scroll-content {
    overflow: visible;
    padding: 0;
  }

  .codex-entry-card {
    page-break-inside: avoid;
  }
}
