/* ==========================================================================
   Meta Orion Optical AR HUD & Waveguide Simulator Stylesheet
   Designed for Optical See-Through (OST) Smart Glasses & Horizon OS
   ========================================================================== */

:root {
    --orion-gold: #F5D061;
    --orion-gold-glow: rgba(245, 208, 97, 0.55);
    --orion-gold-subtle: rgba(245, 208, 97, 0.2);
    --orion-emerald: #4EBA88;
    --orion-emerald-glow: rgba(78, 186, 136, 0.6);
    --orion-cyan: #38BDF8;
    --orion-hud-bg: #030712;
    --orion-hud-border: rgba(245, 208, 97, 0.35);
    --orion-font-uthmani: 'Scheherazade New', 'Amiri', serif;
}

/* --- Entry Buttons in Main App --- */
.orion-entry-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, rgba(31, 78, 95, 0.95), rgba(15, 39, 48, 0.95));
    color: #F5D061 !important;
    border: 1px solid rgba(245, 208, 97, 0.4);
    border-radius: 999px;
    padding: 8px 16px;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12), 0 0 10px rgba(245, 208, 97, 0.15);
}

.orion-entry-btn ion-icon {
    font-size: 1.15rem;
    color: #F5D061;
}

.orion-entry-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2), 0 0 18px rgba(245, 208, 97, 0.35);
    border-color: #F5D061;
    color: #FFF !important;
}

.orion-entry-btn:active {
    transform: translateY(0);
}

/* Secondary Button (inside Hafiz / Viewer) */
.orion-secondary-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(245, 208, 97, 0.1);
    color: var(--primary-text);
    border: 1px solid rgba(245, 208, 97, 0.3);
    border-radius: 12px;
    padding: 8px 14px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.orion-secondary-btn:hover {
    background: rgba(245, 208, 97, 0.2);
    border-color: #F5D061;
}

/* --- Fullscreen Orion AR Viewport --- */
#orion-ar-view {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    background-color: #030712;
    overflow: hidden;
    user-select: none;
    font-family: 'Scheherazade New', 'Amiri', 'Inter', system-ui, sans-serif;
    color: #F3F4F6;
    direction: rtl;
    text-align: right;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

#orion-ar-view.ltr-mode {
    direction: ltr;
    text-align: left;
    font-family: 'Inter', system-ui, sans-serif;
}

#orion-ar-view.ltr-mode .ar-hud-toolbar,
#orion-ar-view.ltr-mode .ar-meta-header,
#orion-ar-view.ltr-mode .ar-hud-footer {
    direction: ltr;
}

#orion-ar-view.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* --- Simulation Environments (Webcam & Backgrounds) --- */
.ar-sim-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    overflow: hidden;
    background-color: #030712;
}

.ar-sim-background video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1); /* Mirror camera for natural look */
    filter: brightness(0.78) contrast(1.08);
}

.ar-sim-background .sim-bg-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    transition: opacity 0.4s ease;
}

/* Predefined environments */
.ar-sim-background.scene-dark .sim-bg-overlay {
    background: radial-gradient(circle at center, #0B132B 0%, #030712 100%);
    opacity: 1;
}

.ar-sim-background.scene-mosque .sim-bg-overlay {
    background: linear-gradient(rgba(3, 7, 18, 0.65), rgba(3, 7, 18, 0.75)),
                radial-gradient(ellipse at bottom, rgba(46, 125, 50, 0.35) 0%, rgba(3, 7, 18, 0.95) 70%),
                repeating-linear-gradient(45deg, rgba(255,255,255,0.02) 0, rgba(255,255,255,0.02) 2px, transparent 2px, transparent 40px);
    opacity: 1;
}

.ar-sim-background.scene-pure .sim-bg-overlay {
    background: #000000;
    opacity: 1;
}

/* Optical Waveguide Glass Tint */
.ar-glass-vignette {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: none;
    box-shadow: inset 0 0 100px rgba(0, 0, 0, 0.85);
    background: radial-gradient(circle at center, transparent 45%, rgba(0, 0, 0, 0.75) 100%);
}

/* --- HUD Header Toolbar (Auto-hides) --- */
.ar-hud-toolbar {
    position: relative;
    z-index: 10;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 28px;
    direction: rtl;
    background: linear-gradient(180deg, rgba(3, 7, 18, 0.85) 0%, rgba(3, 7, 18, 0) 100%);
    backdrop-filter: blur(8px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.ar-hud-toolbar.auto-dim {
    opacity: 0.15;
    transform: translateY(-8px);
}

.ar-hud-toolbar:hover,
.ar-hud-toolbar:focus-within {
    opacity: 1;
    transform: translateY(0);
}

.ar-badge-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ar-brand-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--orion-gold);
    background: rgba(245, 208, 97, 0.12);
    border: 1px solid rgba(245, 208, 97, 0.3);
    padding: 6px 12px;
    border-radius: 999px;
    text-shadow: 0 0 8px var(--orion-gold-glow);
}

.ar-mode-badge {
    font-size: 0.78rem;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #E2E8F0;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ar-mode-badge:hover {
    background: rgba(245, 208, 97, 0.2);
    border-color: var(--orion-gold);
    color: var(--orion-gold);
}

.ar-hud-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ar-action-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #F3F4F6;
    padding: 8px 14px;
    border-radius: 10px;
    font-size: 0.82rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(6px);
}

.ar-action-btn:hover {
    background: rgba(255, 255, 255, 0.18);
    border-color: #FFF;
    color: #FFF;
}

.ar-action-btn.active {
    background: rgba(78, 186, 136, 0.25);
    border-color: var(--orion-emerald);
    color: #A7F3D0;
    text-shadow: 0 0 8px var(--orion-emerald-glow);
}

.ar-close-btn {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.35);
    color: #FCA5A5;
}

.ar-close-btn:hover {
    background: rgba(239, 68, 68, 0.3);
    border-color: #EF4444;
    color: #FFF;
}

/* --- Pure Optical AR HUD Toggle Button --- */
.ar-pure-toggle-btn {
    position: fixed;
    top: 48px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10005;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 5px 14px;
    border-radius: 999px;
    background: rgba(11, 19, 43, 0.92);
    border: 1px solid rgba(245, 208, 97, 0.4);
    color: var(--orion-gold);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    backdrop-filter: blur(12px);
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.6), 0 0 10px rgba(245, 208, 97, 0.2);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.ar-pure-toggle-btn:hover {
    background: rgba(245, 208, 97, 0.22);
    border-color: var(--orion-gold);
    box-shadow: 0 0 18px var(--orion-gold-glow);
    transform: translateX(-50%) scale(1.04);
}

.ar-pure-toggle-btn.active {
    background: rgba(78, 186, 136, 0.25);
    border-color: var(--orion-emerald);
    color: #A7F3D0;
    box-shadow: 0 0 14px var(--orion-emerald-glow);
}

#orion-ar-view.ar-pure-hud .ar-pure-toggle-btn {
    top: 16px;
    opacity: 0.75;
}

/* Pure Optical Mode (Hides All Menus & Maximizes Immersion) */
#orion-ar-view.ar-pure-hud {
    justify-content: center;
}

#orion-ar-view.ar-pure-hud .ar-hud-toolbar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    transform: translateY(-100%);
    opacity: 0;
    pointer-events: none;
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    margin: 0;
    overflow: hidden;
    visibility: hidden;
}

#orion-ar-view.ar-pure-hud .ar-hud-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    transform: translateY(100%);
    opacity: 0;
    pointer-events: none;
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    margin: 0;
    overflow: hidden;
    visibility: hidden;
}

#orion-ar-view.ar-pure-hud .ar-pure-toggle-btn {
    top: 20px;
    opacity: 0.65;
}

#orion-ar-view.ar-pure-hud .ar-pure-toggle-btn:hover {
    opacity: 1;
}

#orion-ar-view.ar-pure-hud .ar-waveguide-canvas {
    max-height: calc(100vh - 20px);
    height: 100%;
    padding: 46px 20px 16px 20px;
}

/* --- Orion Optical Waveguide HUD Center Canvas --- */
.ar-waveguide-canvas {
    position: relative;
    z-index: 5;
    width: 82%;
    max-width: 980px;
    flex: 1;
    min-height: 0;
    max-height: calc(100vh - 160px);
    display: flex;
    flex-direction: column;
    justify-content: flex-start; /* Fix flex-centering top-clipping bug: always start from beginning */
    align-items: center;
    padding: 20px;
    perspective: 1200px;
    transition: transform 0.3s ease, max-height 0.3s ease;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;
}

.ar-waveguide-canvas::-webkit-scrollbar {
    display: none;
}

/* Holographic Optical Boundary Brackets (Representing ~70° FOV) */
.ar-fov-frame {
    position: relative;
    width: 100%;
    margin: auto 0; /* Auto-centers short verses, starts at top for long verses */
    padding: 36px 42px;
    border-radius: 24px;
    background: rgba(3, 7, 18, 0.35);
    backdrop-filter: blur(4px);
    box-shadow: 0 0 35px rgba(0, 0, 0, 0.6);
    border: 1px dashed rgba(245, 208, 97, 0.18);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.ar-fov-frame::before,
.ar-fov-frame::after {
    content: '';
    position: absolute;
    width: 22px;
    height: 22px;
    border: 2px solid var(--orion-gold);
    pointer-events: none;
    box-shadow: 0 0 10px var(--orion-gold-glow);
}

.ar-fov-frame::before {
    top: -2px;
    left: -2px;
    border-right: none;
    border-bottom: none;
    border-top-left-radius: 14px;
}

.ar-fov-frame::after {
    bottom: -2px;
    right: -2px;
    border-left: none;
    border-top: none;
    border-bottom-right-radius: 14px;
}

/* Surah & Ayah Metadata Line */
.ar-meta-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    direction: rtl;
    margin-bottom: 22px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(245, 208, 97, 0.15);
}

.ar-surah-pill {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--orion-gold);
    text-shadow: 0 0 10px var(--orion-gold-glow);
    display: flex;
    align-items: center;
    gap: 8px;
}

.ar-ayah-counter {
    font-size: 0.85rem;
    color: #94A3B8;
    background: rgba(255, 255, 255, 0.05);
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* --- Quran Text Display (Additive Optical Glow & Calibrated 3-4 Line AR Prompter Window) --- */
.ar-quran-text {
    font-family: var(--orion-font-uthmani);
    font-size: 2.85rem !important;
    line-height: 2.15 !important;
    text-align: center;
    direction: rtl;
    color: #F8FAFC;
    text-shadow: 0 0 14px rgba(248, 250, 252, 0.45);
    margin: 8px 0 16px 0;
    padding: 6px 14px;
    word-spacing: 6px;
    position: relative;
    box-sizing: border-box;
    max-height: 330px; /* Strictly calibrated to 4 readable lines for Meta Orion AR FOV */
    overflow-y: hidden;
    scroll-behavior: smooth;
    scrollbar-width: none;
    transition: opacity 0.4s ease, filter 0.4s ease;
}

.ar-quran-text::-webkit-scrollbar {
    display: none;
}

/* Stable optical size: Never shrink text regardless of verse length */
.ar-quran-text.length-short,
.ar-quran-text.length-medium,
.ar-quran-text.length-long,
.ar-quran-text.length-xl {
    font-size: 2.85rem !important;
    line-height: 2.15 !important;
}

/* Highlighting in Safety-Net & Memorize Modes */
.ar-word {
    display: inline-block;
    padding: 0 4px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

/* Correctly Recited Word */
.ar-word.matched {
    color: var(--orion-emerald);
    text-shadow: 0 0 16px var(--orion-emerald-glow), 0 0 28px rgba(78, 186, 136, 0.4);
    transform: scale(1.02);
}

/* Skipped / Bridged Word in Imam Follower Mode (Uncorrected Imam Mistake or Skip) */
.ar-word.follower-skipped {
    color: rgba(245, 158, 11, 0.72) !important; /* Soft subtle amber glow */
    text-shadow: 0 0 12px rgba(245, 158, 11, 0.45);
    text-decoration: underline dotted rgba(245, 158, 11, 0.6);
    text-underline-offset: 6px;
    opacity: 0.78;
    transform: scale(0.98);
}

/* Fast Recitation Progressive Burst Ripple Wave */
.ar-word.ar-burst-wave {
    animation: arBurstRipple 0.45s ease-out both;
}

@keyframes arBurstRipple {
    0% {
        transform: scale(1.15) translateY(-2px);
        filter: brightness(1.7);
        text-shadow: 0 0 26px var(--orion-emerald), 0 0 40px rgba(16, 185, 129, 0.8);
    }
    100% {
        transform: scale(1.02) translateY(0);
        filter: brightness(1);
    }
}

/* Pending / Active Word to Recite */
.ar-word.pending {
    color: var(--orion-gold);
    text-shadow: 0 0 18px var(--orion-gold-glow);
    font-weight: 700;
    animation: arGlowPulse 2.2s infinite ease-in-out;
}

/* Hidden Word in Blind / Hesitation Mode */
.ar-word.dimmed {
    color: rgba(255, 255, 255, 0.12);
    text-shadow: none;
    filter: blur(2px);
}

.ar-word.hidden-optics {
    visibility: hidden;
    opacity: 0;
}

/* Decorative Quranic Waqf & Sajdah Signs (Attached to words) */
.ar-waqf-sign {
    font-size: 0.62em;
    vertical-align: super;
    color: var(--orion-gold);
    text-shadow: 0 0 10px var(--orion-gold-glow);
    margin: 0 4px;
    opacity: 0.95;
    display: inline-block;
    pointer-events: none;
}

/* Hesitation Prompt Glow (Soft Golden Illumination) */
.ar-prompt-flash {
    animation: arHesitationReveal 1.2s ease-out forwards;
}

@keyframes arHesitationReveal {
    0% {
        opacity: 0;
        transform: translateY(6px);
        filter: blur(8px);
        color: #FFF;
    }
    50% {
        opacity: 1;
        transform: translateY(0);
        filter: blur(0);
        color: var(--orion-gold);
        text-shadow: 0 0 30px var(--orion-gold-glow), 0 0 50px rgba(245, 208, 97, 0.8);
    }
    100% {
        opacity: 1;
        color: var(--orion-gold);
        text-shadow: 0 0 16px var(--orion-gold-glow);
    }
}

@keyframes arGlowPulse {
    0%, 100% {
        text-shadow: 0 0 12px var(--orion-gold-glow);
    }
    50% {
        text-shadow: 0 0 24px var(--orion-gold), 0 0 35px var(--orion-gold-glow);
    }
}

/* Feedback / Live Transcript - Ethereal Smooth Faded Display */
.ar-live-transcript {
    font-size: 1.0rem;
    text-align: center;
    direction: rtl;
    min-height: 28px;
    margin-top: 8px;
    font-weight: 400;
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 480px;
    margin-left: auto;
    margin-right: auto;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0.72;
    transition: opacity 0.4s ease, transform 0.4s ease;
    mask-image: linear-gradient(90deg, transparent 0%, black 15%, black 85%, transparent 100%);
    -webkit-mask-image: linear-gradient(90deg, transparent 0%, black 15%, black 85%, transparent 100%);
    pointer-events: none;
}

.ar-live-transcript.fading {
    opacity: 0 !important;
    transform: translateY(3px);
}

/* Current / incoming spoken words: Soft ethereal white with smooth gentle glow */
.ar-transcript-current {
    color: rgba(248, 250, 252, 0.85);
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
    font-weight: 400;
    font-size: 1.0rem;
    letter-spacing: 0.02em;
}

/* --- Natural Gaze Line (Prayer Floor Anchor) --- */
.ar-gaze-anchor {
    margin-top: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.76rem;
    color: rgba(245, 208, 97, 0.6);
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.ar-gaze-line {
    width: 60px;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(245, 208, 97, 0.4), transparent);
}

/* --- HUD Bottom Controls Bar (Hands-free & Simulated Inputs) --- */
.ar-hud-footer {
    position: relative;
    z-index: 10;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 32px;
    direction: rtl;
    background: linear-gradient(0deg, rgba(3, 7, 18, 0.9) 0%, rgba(3, 7, 18, 0) 100%);
    backdrop-filter: blur(8px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.ar-hud-footer.auto-dim {
    opacity: 0.15;
    transform: translateY(8px);
}

.ar-hud-footer:hover,
.ar-hud-footer:focus-within {
    opacity: 1;
    transform: translateY(0);
}

.ar-mic-status-pill {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.06);
    padding: 8px 18px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    font-size: 0.85rem;
    font-weight: 500;
}

.ar-mic-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #64748B;
    transition: all 0.3s ease;
}

.ar-mic-dot.listening {
    background: var(--orion-emerald);
    box-shadow: 0 0 12px var(--orion-emerald);
    animation: arDotBeat 1.4s infinite ease-in-out;
}

@keyframes arDotBeat {
    0%, 100% { transform: scale(1); opacity: 0.9; }
    50% { transform: scale(1.35); opacity: 1; }
}

/* --- Live ASR Latency Indicator Badge --- */
.ar-asr-latency-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    font-family: monospace, system-ui, sans-serif;
    letter-spacing: 0.02em;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #CBD5E1;
    margin-right: 6px;
    transition: all 0.25s ease;
}

.ar-asr-latency-badge.hidden {
    display: none !important;
}

.ar-asr-latency-badge.fast {
    background: rgba(16, 185, 129, 0.18);
    border-color: rgba(16, 185, 129, 0.5);
    color: #34D399;
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.25);
}

.ar-asr-latency-badge.moderate {
    background: rgba(245, 208, 97, 0.18);
    border-color: rgba(245, 208, 97, 0.5);
    color: #F5D061;
    box-shadow: 0 0 10px rgba(245, 208, 97, 0.2);
}

.ar-asr-latency-badge.laggy {
    background: rgba(239, 68, 68, 0.18);
    border-color: rgba(239, 68, 68, 0.5);
    color: #F87171;
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.25);
}

.ar-controls-cluster {
    display: flex;
    align-items: center;
    gap: 12px;
    direction: rtl;
}

.ar-icon-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #F8FAFC;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(6px);
}

.ar-icon-btn:hover {
    background: rgba(245, 208, 97, 0.25);
    border-color: var(--orion-gold);
    color: var(--orion-gold);
    transform: scale(1.08);
    box-shadow: 0 0 14px var(--orion-gold-glow);
}

.ar-icon-btn.primary {
    background: linear-gradient(135deg, rgba(245, 208, 97, 0.9), rgba(212, 163, 115, 0.9));
    color: #030712;
    border: none;
    box-shadow: 0 0 16px var(--orion-gold-glow);
}

.ar-icon-btn.primary:hover {
    transform: scale(1.12);
    box-shadow: 0 0 24px var(--orion-gold);
}

.ar-hotkey-hints {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.74rem;
    color: #94A3B8;
    direction: rtl;
}

.ar-kbd {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    padding: 2px 6px;
    color: #E2E8F0;
    font-family: monospace;
    font-size: 0.76rem;
}

/* --- Simulation Settings Drawer (Modal Overlay) --- */
.ar-settings-drawer {
    position: absolute;
    top: 84px;
    right: 28px;
    left: auto;
    direction: ltr;
    text-align: left;
    width: 320px;
    background: rgba(11, 19, 43, 0.96);
    border: 1px solid rgba(245, 208, 97, 0.35);
    border-radius: 18px;
    padding: 20px;
    z-index: 10010;
    backdrop-filter: blur(14px);
    box-shadow: 0 10px 35px rgba(0, 0, 0, 0.85);
    display: flex;
    flex-direction: column;
    gap: 16px;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

#orion-ar-view[dir="rtl"] .ar-settings-drawer,
#orion-ar-view:not(.ltr-mode) .ar-settings-drawer,
html[dir="rtl"] .ar-settings-drawer,
body.rtl-mode .ar-settings-drawer {
    right: auto;
    left: 28px;
    direction: rtl;
    text-align: right;
}

.ar-settings-drawer.hidden {
    opacity: 0;
    transform: translateY(-10px) scale(0.95);
    pointer-events: none;
}

.ar-drawer-title {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--orion-gold);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.ar-drawer-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ar-drawer-row.locked-pacing {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

.ar-drawer-row.locked-pacing .ar-drawer-label::after {
    content: ' [🔒 تلقائي مع الإمام]';
    color: var(--orion-gold);
    font-size: 0.72rem;
    font-weight: 600;
}

.ar-drawer-label {
    font-size: 0.78rem;
    color: #94A3B8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.ar-scene-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.ar-scene-pill {
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    color: #E2E8F0;
    font-size: 0.76rem;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s ease;
}

.ar-scene-pill:hover,
.ar-scene-pill.active {
    background: rgba(245, 208, 97, 0.18);
    border-color: var(--orion-gold);
    color: var(--orion-gold);
}

/* Responsive adjustments for Foldables, Tablets & Mobile */
@media (max-width: 920px) {
    .ar-waveguide-canvas {
        width: calc(100% - 56px);
        max-width: calc(100% - 56px);
        margin-right: 50px;
        margin-left: 6px;
        padding: 10px 14px;
        max-height: calc(100vh - 140px);
    }
    #orion-ar-view.ar-pure-hud .ar-waveguide-canvas {
        max-height: calc(100vh - 16px);
        padding: 42px 10px 10px 10px;
        width: calc(100% - 56px);
        max-width: calc(100% - 56px);
        margin-right: 50px;
        margin-left: 6px;
    }
    .ar-fov-frame {
        padding: 16px 20px;
        border-radius: 18px;
    }
    .ar-meta-header {
        margin-bottom: 8px;
        padding-bottom: 6px;
    }
    .ar-quran-text {
        font-size: 2.35rem !important;
        line-height: 2.05 !important;
        margin: 6px 0 14px 0;
    }
    .ar-quran-text.length-short,
    .ar-quran-text.length-medium,
    .ar-quran-text.length-long,
    .ar-quran-text.length-xl {
        font-size: 2.35rem !important;
        line-height: 2.05 !important;
    }
    .ar-transliteration-box {
        margin-top: 6px;
        padding: 8px 16px;
        max-height: 90px;
        overflow-y: auto;
    }
    .ar-translit-line {
        font-size: 0.84rem;
        margin-bottom: 2px;
    }
    .ar-translation-line {
        font-size: 0.78rem;
    }
    .ar-gaze-anchor {
        margin-top: 6px;
    }
    .ar-demo-bar {
        margin-top: 8px;
        padding: 6px 14px;
        gap: 8px;
    }
    .ar-hud-toolbar {
        padding: 8px 12px;
        gap: 8px;
        overflow-x: auto;
        overflow-y: hidden;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }
    .ar-hud-toolbar::-webkit-scrollbar {
        display: none;
    }
    .ar-badge-group {
        gap: 8px;
        flex-shrink: 0;
    }
    .ar-hud-actions {
        gap: 6px;
        flex-shrink: 0;
    }
    /* Hide desktop keyboard simulator buttons only on narrow screens */
    .ar-action-btn.ar-pinch-btn {
        display: none !important;
    }
    /* Compact buttons with reduced padding */
    .ar-action-btn {
        padding: 6px 10px;
        font-size: 0.78rem;
        gap: 5px;
    }
    /* Hide long text strings and show icons for Secondary Actions */
    #arWebcamToggleBtn span,
    #arSettingsToggleBtn span,
    #arCloseBtn span {
        display: none;
    }
    /* Centered, adaptive Settings Drawer on Fold and Mobile */
    .ar-settings-drawer {
        width: calc(100vw - 24px) !important;
        max-width: 330px !important;
        left: 50% !important;
        right: auto !important;
        transform: translateX(-50%) !important;
        top: 84px !important;
        padding: 16px !important;
        z-index: 10010 !important;
    }
    .ar-settings-drawer.hidden {
        transform: translateX(-50%) translateY(-10px) scale(0.95) !important;
    }
    .ar-pure-toggle-btn {
        top: 48px;
        padding: 5px 12px;
        font-size: 0.78rem;
    }
    #orion-ar-view.ar-pure-hud .ar-pure-toggle-btn {
        top: 14px;
    }
    .ar-hud-footer {
        padding: 10px 18px;
    }
    .ar-hotkey-hints {
        display: none;
    }
}

/* Extra narrow screens: Fold Cover screen & compact mobile */
@media (max-width: 640px) {
    .ar-brand-badge span {
        display: none;
    }
    .ar-brand-badge {
        padding: 5px 8px;
    }
    .ar-mode-badge {
        padding: 4px 8px;
        font-size: 0.72rem;
    }
    .ar-context-pill {
        padding: 3px 8px;
        font-size: 0.74rem;
        gap: 4px;
    }
    #arWebXRToggleBtn span {
        display: none;
    }
    .ar-pure-toggle-btn span {
        display: none;
    }
    .ar-temple-touch-strip {
        width: 36px;
        padding: 8px 2px;
        gap: 8px;
    }
    .ar-temple-btn {
        width: 28px;
        height: 28px;
        font-size: 0.85rem;
    }
    .ar-temple-label {
        font-size: 0.52rem;
    }
    .ar-waveguide-canvas {
        width: calc(100% - 44px) !important;
        max-width: calc(100% - 44px) !important;
        margin-right: 40px !important;
        margin-left: 4px !important;
    }
    #orion-ar-view.ar-pure-hud .ar-waveguide-canvas {
        width: calc(100% - 44px) !important;
        max-width: calc(100% - 44px) !important;
        margin-right: 40px !important;
        margin-left: 4px !important;
    }
}

/* ==========================================================================
   PHASE 2: DUAL CONTROLS & HACKATHON DEMO STYLES
   ========================================================================== */

/* --- Phase 2 Header Mode Dropdown (Hifz Study, Imam Salah, Imam Follower, Judge) --- */
.ar-context-dropdown-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
    background: rgba(11, 19, 43, 0.92);
    border: 1px solid rgba(245, 208, 97, 0.4);
    border-radius: 999px;
    padding: 2px 10px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
}

.ar-context-dropdown-wrapper:hover,
.ar-context-dropdown-wrapper:focus-within {
    border-color: var(--orion-gold);
    box-shadow: 0 0 16px var(--orion-gold-glow);
    background: rgba(15, 25, 55, 0.98);
}

.ar-context-select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background: transparent;
    border: none;
    color: var(--orion-gold);
    font-size: 0.82rem;
    font-weight: 700;
    font-family: inherit;
    padding: 5px 22px 5px 6px;
    cursor: pointer;
    outline: none;
    direction: ltr;
}

#orion-ar-view:not(.ltr-mode) .ar-context-select {
    direction: rtl;
    padding: 5px 6px 5px 22px;
}

.ar-context-select option {
    background: #0B132B;
    color: #F8FAFC;
    font-weight: 600;
    font-size: 0.85rem;
    padding: 8px 12px;
}

.ar-context-select-arrow {
    position: absolute;
    right: 8px;
    pointer-events: none;
    color: var(--orion-gold);
    font-size: 0.82rem;
    transition: transform 0.2s ease;
}

#orion-ar-view:not(.ltr-mode) .ar-context-select-arrow {
    right: auto;
    left: 8px;
}

/* Context Badges (Imam Prayer vs Hifz Study vs Judge Demo) */
.ar-context-pill {
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.05);
    color: #E2E8F0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.ar-context-pill.active[data-context="prayer"] {
    background: rgba(245, 208, 97, 0.2);
    border-color: var(--orion-gold);
    color: var(--orion-gold);
    box-shadow: 0 0 12px var(--orion-gold-glow);
}

.ar-context-pill.active[data-context="study"] {
    background: rgba(78, 186, 136, 0.25);
    border-color: var(--orion-emerald);
    color: #A7F3D0;
    box-shadow: 0 0 12px var(--orion-emerald-glow);
}

.ar-context-pill.active[data-context="follower"] {
    background: rgba(245, 158, 11, 0.25);
    border-color: #F59E0B;
    color: #FDE68A;
    box-shadow: 0 0 12px rgba(245, 158, 11, 0.45);
}

.ar-context-pill.active[data-context="demo"] {
    background: rgba(56, 189, 248, 0.25);
    border-color: var(--orion-cyan);
    color: #BAE6FD;
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.4);
}

/* Gaze Dwell Target on Prostration Line (Mawdi' al-Sujud) */
.ar-gaze-target {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 6px 14px;
    border-radius: 20px;
    background: rgba(245, 208, 97, 0.06);
    border: 1px solid rgba(245, 208, 97, 0.2);
    cursor: pointer;
    transition: all 0.3s ease;
    user-select: none;
}

.ar-gaze-target:hover,
.ar-gaze-target.dwelling {
    background: rgba(245, 208, 97, 0.16);
    border-color: var(--orion-gold);
    box-shadow: 0 0 16px var(--orion-gold-glow);
}

.ar-dwell-svg {
    width: 22px;
    height: 22px;
    transform: rotate(-90deg);
}

.ar-dwell-bg-circle {
    fill: none;
    stroke: rgba(245, 208, 97, 0.2);
    stroke-width: 3;
}

.ar-dwell-progress-circle {
    fill: none;
    stroke: var(--orion-gold);
    stroke-width: 3;
    stroke-dasharray: 56.5;
    stroke-dashoffset: 56.5;
    transition: stroke-dashoffset 0.1s linear;
}

.ar-gaze-label {
    font-size: 0.74rem;
    letter-spacing: 0.05em;
    color: rgba(245, 208, 97, 0.85);
}

/* Meta Orion Frame Temple Touch Simulator (Right Arm - Pinned to Frame Border) */
.ar-temple-touch-strip {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    padding: 12px 4px;
    border-top-left-radius: 22px;
    border-bottom-left-radius: 22px;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    background: rgba(3, 7, 18, 0.88);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-right: none;
    backdrop-filter: blur(10px);
    box-shadow: -4px 0 25px rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    z-index: 25;
    transition: all 0.3s ease;
}

.ar-temple-touch-strip.locked {
    opacity: 0.4;
    border-color: rgba(239, 68, 68, 0.3);
}

.ar-temple-touch-strip.locked:hover {
    opacity: 0.8;
}

.ar-temple-label {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: rotate(180deg);
    font-size: 0.6rem;
    letter-spacing: 0.1em;
    color: #94A3B8;
    text-transform: uppercase;
    margin: 4px 0;
}

.ar-temple-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #F8FAFC;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s ease;
}

.ar-temple-btn:hover {
    background: rgba(78, 186, 136, 0.25);
    border-color: var(--orion-emerald);
    color: #A7F3D0;
    transform: scale(1.08);
}

.ar-temple-btn:active {
    transform: scale(0.94);
}

/* Floating Voice Command Toast */
.ar-command-toast {
    position: absolute;
    top: 76px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid var(--orion-cyan);
    box-shadow: 0 0 20px rgba(56, 189, 248, 0.35);
    color: #E0F2FE;
    padding: 8px 18px;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: arToastSlide 0.3s ease;
    pointer-events: none;
}

.ar-command-toast.hidden {
    display: none !important;
}

@keyframes arToastSlide {
    from {
        opacity: 0;
        transform: translate(-50%, -12px);
    }
    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

/* Judge Demo Mode Controller Bar */
.ar-demo-bar {
    margin-top: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 8px 18px;
    border-radius: 20px;
    background: rgba(56, 189, 248, 0.08);
    border: 1px solid rgba(56, 189, 248, 0.25);
}

.ar-demo-play-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px;
    border-radius: 999px;
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.3), rgba(56, 189, 248, 0.1));
    border: 1px solid var(--orion-cyan);
    color: #F0F9FF;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ar-demo-play-btn:hover {
    background: rgba(56, 189, 248, 0.45);
    box-shadow: 0 0 16px rgba(56, 189, 248, 0.5);
    transform: translateY(-1px);
}

.ar-demo-play-btn.playing {
    border-color: var(--orion-gold);
    color: var(--orion-gold);
    box-shadow: 0 0 16px var(--orion-gold-glow);
}

/* Judge Demo Mode Phonetics & Sahih Translation Display */
.ar-transliteration-box {
    margin: 14px auto 0 auto;
    max-width: 860px;
    width: 92%;
    padding: 12px 24px;
    border-radius: 16px;
    background: rgba(3, 7, 18, 0.78);
    border: 1px solid rgba(56, 189, 248, 0.35);
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.6), 0 0 16px rgba(56, 189, 248, 0.18);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    text-align: center;
    direction: ltr;
    position: relative;
    z-index: 20;
    user-select: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: arTranslitFadeIn 0.35s ease;
}

.ar-transliteration-box.hidden {
    display: none !important;
}

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

.ar-translit-line {
    font-size: 1.15rem;
    font-weight: 600;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: #38BDF8;
    text-shadow: 0 0 12px rgba(56, 189, 248, 0.45);
    letter-spacing: 0.025em;
    line-height: 1.5;
}

/* Judge Transliteration Word-by-Word Synchronized Highlights (Crisp, Clean & Legible) */
.ar-translit-word {
    display: inline;
    margin: 0 1px;
    padding: 0 1px;
    color: rgba(224, 242, 254, 0.75);
    transition: color 0.15s ease, border-color 0.15s ease;
}

.ar-translit-word.matched {
    color: rgba(56, 189, 248, 0.42);
    text-shadow: none;
}

.ar-translit-word.pending {
    color: #FDE047 !important;
    font-weight: 600;
    text-shadow: 0 0 6px rgba(245, 208, 97, 0.5);
    border-bottom: 2px solid #F5D061;
}

.ar-translit-word.upcoming {
    color: rgba(224, 242, 254, 0.75);
}

.ar-translation-line {
    font-size: 0.95rem;
    font-weight: 400;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: #CBD5E1;
    font-style: italic;
    letter-spacing: 0.01em;
    line-height: 1.45;
    opacity: 0.92;
}

.ar-translit-line.hidden,
.ar-translation-line.hidden {
    display: none !important;
}

.ar-demo-sub-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #94A3B8;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ar-demo-sub-btn:hover {
    background: rgba(56, 189, 248, 0.2);
    border-color: rgba(56, 189, 248, 0.5);
    color: #E0F2FE;
    transform: translateY(-1px);
}

.ar-demo-sub-btn.active {
    background: rgba(56, 189, 248, 0.25);
    border-color: var(--orion-cyan);
    color: #38BDF8;
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.3);
}

/* ==========================================================================
   Phase 3: Meta Horizon OS WebXR Immersive Session & Hand Micro-Gestures
   ========================================================================== */

/* WebXR Action Button */
.ar-xr-btn {
    background: rgba(6, 182, 212, 0.12);
    border: 1px solid rgba(34, 211, 238, 0.4);
    color: #A5F3FC;
}

.ar-xr-btn:hover {
    background: rgba(6, 182, 212, 0.25);
    border-color: #22D3EE;
    color: #ECFEFF;
    box-shadow: 0 0 14px rgba(34, 211, 238, 0.4);
}

.ar-xr-btn.xr-supported {
    border-color: #06B6D4;
    animation: arPulseCyan 2.5s infinite;
}

.ar-xr-btn.active {
    background: rgba(6, 182, 212, 0.35);
    border-color: #22D3EE;
    color: #FFF;
    box-shadow: 0 0 20px rgba(34, 211, 238, 0.7);
}

/* Micro-Pinch Action Button (Desktop Simulator) */
.ar-pinch-btn {
    background: rgba(168, 85, 247, 0.12);
    border: 1px solid rgba(192, 132, 252, 0.35);
    color: #E9D5FF;
}

.ar-pinch-btn:hover {
    background: rgba(168, 85, 247, 0.25);
    border-color: #C084FC;
    color: #FAF5FF;
    box-shadow: 0 0 14px rgba(192, 132, 252, 0.4);
}

.ar-pinch-btn:active {
    transform: scale(0.95);
    background: rgba(168, 85, 247, 0.4);
}

/* Central Canvas Hand Gesture Indicator Pill */
.ar-gesture-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 3px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.74rem;
    font-weight: 500;
    color: #94A3B8;
    transition: all 0.25s ease;
}

.ar-gesture-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #10B981;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.7);
    transition: all 0.2s ease;
}

/* Pinch Active Animation */
.ar-gesture-pill.pinching {
    border-color: var(--orion-gold);
    color: var(--orion-gold);
    background: rgba(245, 208, 97, 0.15);
    box-shadow: 0 0 18px var(--orion-gold-glow);
    transform: scale(1.06);
}

.ar-gesture-pill.pinching .ar-gesture-dot {
    background: var(--orion-gold);
    box-shadow: 0 0 12px var(--orion-gold);
}

/* XR Session Active */
.ar-gesture-pill.xr-active {
    border-color: #22D3EE;
    color: #A5F3FC;
    background: rgba(6, 182, 212, 0.15);
    box-shadow: 0 0 14px rgba(34, 211, 238, 0.4);
}

.ar-gesture-pill.xr-active .ar-gesture-dot {
    background: #22D3EE;
    box-shadow: 0 0 10px #22D3EE;
}

@keyframes arPulseCyan {
    0%, 100% {
        box-shadow: 0 0 4px rgba(34, 211, 238, 0.2);
    }
    50% {
        box-shadow: 0 0 14px rgba(34, 211, 238, 0.5);
    }
}

/* 3D Spatial Hologram Simulator for Desktop */
.ar-waveguide-canvas.spatial-sim {
    transform: perspective(1000px) rotateX(4deg) translateZ(15px);
    transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.6s ease;
}

.ar-waveguide-canvas.spatial-sim .ar-fov-frame {
    box-shadow: 0 0 40px rgba(6, 182, 212, 0.25), inset 0 0 20px rgba(6, 182, 212, 0.1);
    border: 1px solid rgba(34, 211, 238, 0.35);
    animation: arFloatHolo 4s ease-in-out infinite alternate;
}

@keyframes arFloatHolo {
    0% {
        transform: translateY(0px) rotateX(0deg);
    }
    100% {
        transform: translateY(-8px) rotateX(1deg);
    }
}

/* --- In-HUD Standalone Spatial Surah & Ayah Selector --- */
.ar-surah-pill.interactive,
.ar-ayah-counter.interactive {
    cursor: pointer;
    user-select: none;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.ar-surah-pill.interactive:hover,
.ar-ayah-counter.interactive:hover {
    border-color: var(--orion-gold);
    color: var(--orion-gold);
    background: rgba(245, 208, 97, 0.18);
    box-shadow: 0 0 16px var(--orion-gold-glow);
    transform: translateY(-1px);
}

.ar-surah-pill.interactive:active,
.ar-ayah-counter.interactive:active {
    transform: scale(0.97);
}

/* --- Standalone Fullscreen Spatial Selector Backdrop & Fixes --- */
.ar-spatial-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(3, 7, 18, 0.78);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 99999;
    transition: opacity 0.25s ease;
}

.ar-spatial-backdrop.hidden {
    display: none !important;
}

#orion-ar-view.spatial-modal-open .ar-hud-header,
#orion-ar-view.spatial-modal-open .ar-hud-footer {
    opacity: 0.12;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.ar-spatial-selector-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(92vw, 540px);
    max-height: 80vh;
    background: rgba(11, 17, 32, 0.96);
    backdrop-filter: blur(28px);
    -webkit-backdrop-filter: blur(28px);
    border: 1px solid rgba(245, 208, 97, 0.4);
    border-radius: 20px;
    box-shadow: 0 24px 75px rgba(0, 0, 0, 0.9), 0 0 40px rgba(245, 208, 97, 0.15);
    z-index: 100000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    color: #F8FAFC;
    animation: arModalPop 0.22s cubic-bezier(0.16, 1, 0.3, 1);
    direction: rtl; /* RTL default for Arabic Surah navigation */
    text-align: right;
    font-family: var(--font-ar), 'Inter', sans-serif;
}

.ar-spatial-selector-modal.ltr-mode {
    direction: ltr;
    text-align: left;
    font-family: 'Inter', sans-serif;
}

.ar-spatial-selector-modal.hidden {
    display: none !important;
}

@keyframes arModalPop {
    from {
        opacity: 0;
        transform: translate(-50%, -46%) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

.ar-spatial-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    background: rgba(15, 23, 42, 0.7);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.ar-spatial-modal-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--orion-gold);
    letter-spacing: 0.02em;
}

.ar-spatial-modal-title ion-icon {
    font-size: 1.25rem;
    color: var(--orion-gold);
}

.ar-spatial-close-btn {
    background: transparent;
    border: none;
    color: #94A3B8;
    cursor: pointer;
    font-size: 1.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.ar-spatial-close-btn:hover {
    color: #FFFFFF;
    background: rgba(255, 255, 255, 0.1);
}

.ar-spatial-tip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 18px;
    background: rgba(16, 185, 129, 0.1);
    border-bottom: 1px solid rgba(16, 185, 129, 0.2);
    font-size: 0.76rem;
    color: #6EE7B7;
    line-height: 1.4;
}

.ar-spatial-tip ion-icon {
    font-size: 1.3rem;
    flex-shrink: 0;
    color: #34D399;
}

.ar-spatial-search-row {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 18px 8px;
    direction: rtl;
}

.ar-spatial-selector-modal.ltr-mode .ar-spatial-search-row {
    direction: ltr;
}

.ar-spatial-search-input-wrap {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
}

.ar-spatial-search-input-wrap > ion-icon {
    position: absolute;
    right: 14px;
    left: auto;
    color: #64748B;
    font-size: 1.15rem;
    pointer-events: none;
}

.ar-spatial-selector-modal.ltr-mode .ar-spatial-search-input-wrap > ion-icon {
    right: auto;
    left: 14px;
}

.ar-spatial-search-input {
    width: 100%;
    padding: 10px 40px 10px 36px;
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    color: #F8FAFC;
    font-family: inherit;
    font-size: 0.88rem;
    outline: none;
    transition: all 0.2s ease;
    text-align: right;
    direction: rtl;
}

.ar-spatial-selector-modal.ltr-mode .ar-spatial-search-input {
    padding: 10px 36px 10px 40px;
    text-align: left;
    direction: ltr;
}

.ar-spatial-search-input:focus {
    border-color: var(--orion-gold);
    box-shadow: 0 0 12px rgba(245, 208, 97, 0.25);
    background: rgba(15, 23, 42, 1);
}

.ar-spatial-clear-btn {
    position: absolute;
    left: 12px;
    right: auto;
    background: transparent;
    border: none;
    color: #94A3B8;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px;
}

.ar-spatial-selector-modal.ltr-mode .ar-spatial-clear-btn {
    left: auto;
    right: 12px;
}

.ar-spatial-voice-search-btn {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.16);
    color: #F8FAFC;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.ar-spatial-voice-search-btn:hover {
    background: rgba(245, 208, 97, 0.25);
    border-color: var(--orion-gold);
    color: var(--orion-gold);
    transform: scale(1.05);
}

.ar-spatial-voice-search-btn.listening {
    background: rgba(239, 68, 68, 0.35);
    border-color: #EF4444;
    color: #EF4444;
    box-shadow: 0 0 16px rgba(239, 68, 68, 0.6);
    animation: arDotBeat 1.2s infinite ease-in-out;
}

/* Hide frequent surahs row for now */
.ar-spatial-section-header,
.ar-spatial-chips-scroll {
    display: none !important;
}

/* Redesigned 2-row Selection and Action Bar */
.ar-spatial-picker-row {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px 18px;
    background: rgba(10, 15, 30, 0.96);
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    direction: rtl;
    border-bottom-left-radius: 20px;
    border-bottom-right-radius: 20px;
}

.ar-spatial-selector-modal.ltr-mode .ar-spatial-picker-row {
    direction: ltr;
}

.ar-spatial-picker-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
}

.ar-spatial-target-surah {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--orion-gold);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 0;
}

.ar-spatial-ayah-stepper {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.84rem;
    color: #CBD5E1;
    flex-shrink: 0;
}

.ar-stepper-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    color: #F8FAFC;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 700;
    transition: all 0.15s ease;
}

.ar-stepper-btn:hover {
    background: rgba(245, 208, 97, 0.2);
    border-color: var(--orion-gold);
    color: var(--orion-gold);
}

.ar-spatial-ayah-input {
    width: 50px;
    padding: 4px;
    text-align: center;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    color: #F8FAFC;
    font-family: inherit;
    font-size: 0.85rem;
    outline: none;
}

.ar-spatial-ayah-input:focus {
    border-color: var(--orion-gold);
}

.ar-spatial-picker-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
}

.ar-spatial-jump-btn {
    flex: 1;
    padding: 10px 16px;
    background: linear-gradient(135deg, rgba(245, 208, 97, 0.95) 0%, rgba(217, 119, 6, 0.95) 100%);
    border: none;
    border-radius: 10px;
    color: #030712;
    font-family: inherit;
    font-size: 0.86rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    text-align: center;
    box-shadow: 0 4px 12px rgba(245, 208, 97, 0.3);
}

.ar-spatial-jump-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(245, 208, 97, 0.5);
}

.ar-spatial-salah-btn {
    flex: 1.25;
    padding: 10px 16px;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.95) 0%, rgba(5, 150, 105, 0.95) 100%);
    border: 1px solid rgba(110, 231, 183, 0.4);
    border-radius: 10px;
    color: #FFFFFF;
    font-family: inherit;
    font-size: 0.86rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    text-align: center;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.ar-spatial-salah-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(16, 185, 129, 0.55);
}

.ar-spatial-surahs-list {
    flex: 1;
    min-height: 120px;
    max-height: 44vh;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 10px 18px 16px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 8px;
    scrollbar-width: thin;
    scrollbar-color: rgba(245, 208, 97, 0.3) transparent;
}

.ar-spatial-surahs-list::-webkit-scrollbar {
    width: 6px;
}

.ar-spatial-surahs-list::-webkit-scrollbar-thumb {
    background: rgba(245, 208, 97, 0.3);
    border-radius: 4px;
}

.ar-spatial-surah-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    text-align: right;
    direction: rtl;
    user-select: none;
}

.ar-spatial-selector-modal.ltr-mode .ar-spatial-surah-card {
    direction: ltr;
    text-align: left;
}

.ar-spatial-surah-card:hover {
    background: rgba(245, 208, 97, 0.1);
    border-color: rgba(245, 208, 97, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.ar-spatial-surah-card.selected {
    background: rgba(245, 208, 97, 0.16);
    border-color: var(--orion-gold);
    box-shadow: 0 0 14px rgba(245, 208, 97, 0.25);
}

.ar-surah-card-num {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    font-size: 0.78rem;
    font-weight: 700;
    color: #94A3B8;
    flex-shrink: 0;
}

.ar-spatial-surah-card:hover .ar-surah-card-num,
.ar-spatial-surah-card.selected .ar-surah-card-num {
    background: rgba(245, 208, 97, 0.25);
    color: var(--orion-gold);
}

.ar-surah-card-info {
    flex: 1;
    min-width: 0;
}

.ar-surah-card-ar {
    font-size: 0.92rem;
    font-weight: 700;
    color: #F8FAFC;
    line-height: 1.2;
}

.ar-spatial-surah-card:hover .ar-surah-card-ar,
.ar-spatial-surah-card.selected .ar-surah-card-ar {
    color: var(--orion-gold);
}

.ar-surah-card-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.72rem;
    color: #64748B;
    margin-top: 2px;
}

/* --- Solution 3: Hybrid Smart Salah Flow & Post-Fatiha Transition --- */
.ar-salah-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(16, 185, 129, 0.16);
    border: 1px solid rgba(16, 185, 129, 0.45);
    color: #6EE7B7;
    padding: 5px 12px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    box-shadow: 0 0 14px rgba(16, 185, 129, 0.25);
    animation: arSalahGlow 2.5s infinite ease-in-out;
}

@keyframes arSalahGlow {
    0%, 100% { box-shadow: 0 0 10px rgba(16, 185, 129, 0.2); }
    50% { box-shadow: 0 0 18px rgba(16, 185, 129, 0.45); }
}

.ar-salah-clear-btn {
    background: transparent;
    border: none;
    color: #94A3B8;
    font-size: 1.15rem;
    cursor: pointer;
    line-height: 1;
    padding: 0 2px;
    display: flex;
    align-items: center;
    transition: color 0.2s ease;
}

.ar-salah-clear-btn:hover {
    color: #EF4444;
}

.ar-spatial-salah-btn {
    padding: 7px 14px;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.9) 0%, rgba(5, 150, 105, 0.9) 100%);
    border: 1px solid rgba(110, 231, 183, 0.4);
    border-radius: 8px;
    color: #FFFFFF;
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.ar-spatial-salah-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(16, 185, 129, 0.55);
    background: linear-gradient(135deg, rgba(16, 185, 129, 1) 0%, rgba(5, 150, 105, 1) 100%);
}

.ar-awaiting-passage-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 32px 20px;
    text-align: center;
    direction: ltr;
    unicode-bidi: isolate;
    animation: arAwaitingPulse 2.5s infinite ease-in-out;
}

#orion-ar-view:not(.ltr-mode) .ar-awaiting-passage-container,
.ar-awaiting-passage-container[dir="rtl"] {
    direction: rtl;
}

.ar-awaiting-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(16, 185, 129, 0.18);
    border: 1px solid rgba(16, 185, 129, 0.5);
    color: #34D399;
    padding: 6px 16px;
    border-radius: 999px;
    font-size: 0.88rem;
    font-weight: 600;
    box-shadow: 0 0 16px rgba(16, 185, 129, 0.25);
    direction: inherit;
    unicode-bidi: isolate;
}

.ar-awaiting-main {
    font-size: 1.85rem;
    color: #F5D061;
    font-weight: 700;
    text-shadow: 0 0 20px rgba(245, 208, 97, 0.45);
    font-family: 'Amiri', 'Traditional Arabic', system-ui, sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    direction: inherit;
    unicode-bidi: isolate;
}

.ar-awaiting-primary {
    display: inline-block;
    direction: inherit;
    unicode-bidi: isolate;
}

.ar-awaiting-sub {
    font-size: 1.05rem;
    color: #CBD5E1;
    font-weight: 500;
    font-family: 'Inter', system-ui, sans-serif;
    opacity: 0.9;
    direction: inherit;
    unicode-bidi: isolate;
}

.ar-awaiting-hint {
    font-size: 0.95rem;
    color: #94A3B8;
    max-width: 540px;
    line-height: 1.6;
    direction: inherit;
    unicode-bidi: isolate;
}

/* Full Quran Ayah Search Results in Spatial Modal */
.ar-spatial-searching {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 36px 16px;
    color: var(--orion-gold);
    font-size: 0.95rem;
}

.ar-spatial-search-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid rgba(245, 208, 97, 0.2);
    border-top-color: var(--orion-gold);
    border-radius: 50%;
    animation: arSpin 0.8s linear infinite;
}

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

.ar-spatial-verse-card {
    grid-column: 1 / -1;
    background: linear-gradient(135deg, rgba(245, 208, 97, 0.12) 0%, rgba(15, 23, 42, 0.85) 100%);
    border: 1px solid rgba(245, 208, 97, 0.45);
    border-radius: 14px;
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4), 0 0 20px rgba(245, 208, 97, 0.15);
    margin-bottom: 8px;
    backdrop-filter: blur(12px);
}

.ar-verse-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.ar-verse-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(245, 208, 97, 0.2);
    border: 1px solid rgba(245, 208, 97, 0.6);
    color: var(--orion-gold);
    font-size: 0.78rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ar-verse-ref {
    font-size: 0.9rem;
    font-weight: 700;
    color: #F8FAFC;
}

.ar-verse-text {
    font-family: 'Amiri', 'Traditional Arabic', serif;
    font-size: 1.25rem;
    line-height: 1.8;
    color: #FEF08A;
    background: rgba(0, 0, 0, 0.3);
    padding: 12px 14px;
    border-radius: 10px;
    border-right: 3px solid var(--orion-gold);
    text-shadow: 0 0 12px rgba(245, 208, 97, 0.25);
}

.ar-verse-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ar-verse-jump-btn {
    flex: 1;
    background: linear-gradient(135deg, rgba(245, 208, 97, 0.95) 0%, rgba(217, 119, 6, 0.95) 100%);
    color: #0F172A;
    border: none;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(245, 208, 97, 0.4);
    transition: all 0.2s ease;
}

.ar-verse-jump-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(245, 208, 97, 0.6);
}

.ar-verse-salah-btn {
    flex: 1;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.9) 0%, rgba(5, 150, 105, 0.9) 100%);
    color: #FFFFFF;
    border: none;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.4);
    transition: all 0.2s ease;
}

.ar-verse-salah-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(16, 185, 129, 0.6);
}

.ar-spatial-subheading {
    grid-column: 1 / -1;
    font-size: 0.8rem;
    color: #94A3B8;
    margin: 8px 0 4px;
    font-weight: 600;
}





