/* Phone and touch-tablet composition. Desktop rules remain untouched. */
html.mobile-touch-scroll{scroll-snap-type:none!important}
/* Vertical chapter gestures animate independently; horizontal controls and pinch zoom remain native. */
html.mobile-swipe-chapters main{touch-action:pan-x pinch-zoom}
html.mobile-free-journey main{touch-action:pan-x pan-y pinch-zoom}
@media(max-width:800px),(max-width:1100px) and (pointer:coarse){
 :root{--pad:clamp(20px,5.5vw,36px);--mobile-top:calc(86px + env(safe-area-inset-top,0px));--mobile-bottom:calc(68px + env(safe-area-inset-bottom,0px))}
 /* Match the page canvas Safari uses behind its translucent browser controls. */
 html:has(body[data-page=home]){--bg:#071019;background-color:var(--bg)}
 html:has(body[data-page=quantum]){--bg:#090e13;background-color:var(--bg)}
 html:has(body[data-page=transcendence]){--bg:#0b101b;background-color:var(--bg)}
 html:has(body[data-page=anchor]){--bg:#07131c;background-color:var(--bg)}
 html:has(body[data-page=snowflake]){--bg:#f2f7fa;background-color:var(--bg);color-scheme:light}
 body{overflow-x:clip}
 .site-header,.site-header.scrolled{height:calc(72px + env(safe-area-inset-top,0px));padding-top:env(safe-area-inset-top,0px);padding-left:max(var(--pad),env(safe-area-inset-left,0px));padding-right:max(var(--pad),env(safe-area-inset-right,0px));gap:12px}
 .site-header .brand{width:clamp(110px,32vw,142px);min-width:0}
 .desktop-nav{display:none}.menu-toggle{display:grid}.header-actions{gap:8px;flex-shrink:0}
 .header-actions .dashboard-link{display:none}.language{min-width:44px;min-height:44px;justify-content:center}
 .dropdown-panel{max-width:calc(100vw - 40px)}.dropdown-panel [role=menuitemradio]{min-height:44px}
 #site-menu{padding:calc(18px + env(safe-area-inset-top,0px)) var(--pad) calc(24px + env(safe-area-inset-bottom,0px));height:100dvh;max-height:100dvh;overscroll-behavior:contain;overflow-y:auto}
 #site-menu nav{margin:clamp(20px,5svh,48px) 0 24px;gap:0}
 #site-menu nav a{padding:13px 0;font-size:clamp(1.2rem,5.3vw,1.65rem);min-height:48px}
 .menu-languages a{display:inline-flex;align-items:center;min-width:44px;min-height:44px}
 .chapter-screen,.product-chapter,.sf-chapter{min-height:100svh;padding:var(--mobile-top) var(--pad) var(--mobile-bottom);scroll-margin-top:0}
 .chapter-inner,.world-content,.q-content,.sf-copy{min-width:0;max-width:100%}
 .chapter-next,.sf-chapter .chapter-next{bottom:calc(12px + env(safe-area-inset-bottom,0px))}
 .chapter-link,.world-back,.q-back,.sf-return{min-height:44px}
 .chapter-screen h2,.product-chapter h2{font-size:clamp(1.65rem,6.2vw,2.25rem)}
 .chapter-screen p,.product-chapter p{line-height:1.75}
 /* Keep reading stops stable, but let the visible scenery fill the changing
    viewport. A stable large canvas prevents camera jumps as Safari's UI moves. */
 body[data-page=home] .summit-journey{height:250svh;min-height:0}
 body[data-page=home] .home-hero{height:100svh;height:100dvh;min-height:0!important}
 body[data-page=home] .mountain-scene{bottom:auto;height:100vh;height:100lvh}
 .scene-fallback{pointer-events:none;-webkit-user-drag:none}
 .home-hero .scroll-arrow{bottom:calc(16px + env(safe-area-inset-bottom,0px))}
 .chapter-idea .idea-brand{margin-bottom:24px}
 .chapter-idea h2{font-size:clamp(1rem,4.05vw,1.65rem);margin-bottom:22px}.idea-definition{line-height:1.8!important}
 .idea-path{gap:clamp(6px,2vw,14px);margin-top:30px}.idea-path>a{font-size:clamp(.75rem,3.1vw,.875rem)}
 .idea-path>i{min-width:4px;max-width:28px}
 .chapter-product h2{font-size:clamp(1.6rem,6.8vw,2.15rem);line-height:1.25}
 .chapter-product .chapter-art{height:clamp(160px,27svh,285px);width:calc(100% + 32px)!important;margin:8px -16px 6px}
 .chapter-transcendence .chapter-art{margin-top:16px}
 .chapter-product h3{font-size:1.125rem;margin-bottom:10px}
 .chapter-product-copy>p{font-size:.9375rem;line-height:1.7}
 .chapter-product-copy .chapter-link{margin-top:10px;padding:10px 0}
 .chapter-status{margin-top:8px}.chapter-screen .chapter-audit{margin-top:10px;line-height:1.6}
 .chapter-questions{margin-top:26px}.chapter-questions summary{padding:16px 0;min-height:48px;font-size:.9375rem;line-height:1.65}
 .chapter-questions p{line-height:1.8}.chapter-faq .chapter-contact{margin-top:24px}
 /* The opening object, its title and caption share one actual phone screen. */
 .world-opening{min-height:100svh;padding:var(--mobile-top) 18px var(--mobile-bottom)}
 .world-title h1{font-size:clamp(2.3rem,11vw,3.5rem)}
 .world-transcendence .world-title h1{font-size:clamp(1.75rem,8.5vw,3.4rem)}
 .world-object,.world-transcendence .world-object{height:clamp(190px,42svh,440px);width:100%;min-width:0}
 .world-opening-caption p{font-size:1rem;line-height:1.6}
 .world-opening-caption>span{margin-top:10px}
 .world-introduction h2{margin-bottom:24px}.world-content>p,.world-introduction .world-content>p{margin-top:20px;line-height:1.8}
 .world-relationship{margin-top:34px;gap:10px}
 .migration-stage{min-height:100svh;padding-top:var(--mobile-top);padding-bottom:var(--mobile-bottom)}
 .migration-stage-1{padding-bottom:calc(var(--mobile-bottom) + 15px)}
 .migration-stage-2 .migration-reading{padding:28px 0}.migration-reading p{font-size:.9375rem}
 .world-number{margin-bottom:16px}.migration-reading h2{margin-bottom:16px}
 .migration-field{left:-14%;right:-14%;top:27%;bottom:12%}
 .provenance-instrument{margin-top:28px}.provenance-path{margin-bottom:24px}
 .provenance-instrument .narrative-panel{min-height:0}.narrative-panel{min-height:0}
 .world-closing h2{margin-bottom:26px}.world-next{margin-top:30px;padding-top:25px;gap:12px}
 .world-next>a:not(.world-back){font-size:1.65rem;overflow-wrap:anywhere}
 /* Remove desktop-sized empty panel space, keeping all product content in flow. */
 .q-chapter{padding:var(--mobile-top) var(--pad) var(--mobile-bottom)}
 .q-chapter h2{font-size:clamp(1.55rem,6.2vw,2.15rem);line-height:1.35}
 .q-intro #q-intro-title{font-size:clamp(1.7rem,7.1vw,2.6rem);line-height:1.35}
 .q-intro .q-definition{font-size:.9375rem;line-height:1.8;margin-top:22px}
 .q-shortcuts{gap:4px 20px;margin:22px auto}.q-shortcuts a{min-height:44px}
 .q-heading .q-lead{margin-top:16px;font-size:.9375rem;line-height:1.75}
 .q-spatial{height:clamp(160px,25svh,255px);width:calc(100% + 24px);margin:0 -12px}
 .q-scan .q-tabs{gap:20px;flex-wrap:nowrap;justify-content:flex-start;overflow-x:auto;scrollbar-width:none;max-width:100%;overscroll-behavior-x:contain}
 .q-scan .q-tabs::-webkit-scrollbar{display:none}.q-scan .q-tabs button{flex:none}.q-tabs button{min-height:44px}
 .q-panel-space{min-height:0;margin-top:20px}.q-panel-space p{font-size:.9375rem;line-height:1.75}
 .q-language-instrument{grid-template-columns:1fr;gap:20px;margin-top:24px}
 .q-language-instrument .q-tabs{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:0 10px}
 .q-language-instrument .q-tabs button{font-size:.75rem;min-height:48px;padding:10px 0;text-align:center;overflow-wrap:normal}
 .q-language-result{min-height:0;padding:0 0 20px;border-left:0;border-bottom:1px solid var(--q-line)}.q-language-name{font-size:1.5rem;margin-bottom:12px}
 .q-rule-label{margin-bottom:14px}.q-algorithms{grid-template-columns:repeat(3,minmax(0,1fr));gap:8px 12px;font-size:.8125rem!important}
 .q-risk-reading{gap:20px;margin:24px auto}.q-range>span{font-size:clamp(3.4rem,18vw,5rem)}
 .q-scale{margin-top:14px}.q-risk-explanation p{font-size:.875rem;line-height:1.75}
 .q-factors{gap:16px 20px;padding-top:18px;margin-bottom:0}.q-factors dt{margin-bottom:6px}
 .q-export-instrument{margin-top:24px}.q-export-instrument>.q-tabs button{font-size:1.8rem;min-height:60px;padding:10px 6px 16px}
 .q-outputs .q-export-instrument>.q-tab-panel{min-height:0;padding:24px 0}
 .q-format-copy p{font-size:.9375rem;line-height:1.8}.q-format-meta{margin-top:14px}
 .q-ci.q-disclosure{margin-top:16px}.q-coverage .q-disclosure{margin-top:18px}
 .q-join-options{margin-top:26px;gap:23px}
 .q-join-options h3{font-size:1.45rem;margin-bottom:14px}.q-join-options p{font-size:.875rem;line-height:1.75;margin-bottom:13px}
 .q-join-cta{font-size:1rem;min-height:44px;padding:12px 0}
 .q-faq .chapter-questions{margin-top:24px}.q-faq .chapter-questions summary{font-size:.875rem;padding:16px 0}
 .q-next-world{margin-top:25px;padding-top:24px}
 /* Crystal and narrative keep their own space, even on a short phone. */
 .sf-stage,.migration-sticky{height:100dvh;margin-bottom:-100dvh}
 .sf-title{top:calc(var(--mobile-top) + 8px);left:20px;right:20px}
 .sf-title h1{font-size:clamp(2.8rem,11vw,5rem)}
 .sf-opening>.sf-soon{bottom:calc(var(--mobile-bottom) + 12px)}
 .sf-branches,.sf-unseen{padding-top:max(var(--mobile-top),42svh);padding-bottom:var(--mobile-bottom)}
 .sf-branches,.sf-unseen{align-items:flex-end}
 .sf-copy,.sf-unseen .sf-copy{width:100%;max-width:460px;text-align:center;margin:0 auto!important}
 .sf-copy p{margin-left:auto;margin-right:auto}
 .sf-copy h2{font-size:clamp(1.6rem,6.4vw,2.5rem)}
 .sf-copy p{font-size:.9375rem;line-height:1.75;margin-top:17px}
 .sf-unseen .sf-soon{margin-top:20px}.sf-return{margin-top:6px}
 .sf-crystal,.chapter-art .scene,.world-object .scene{touch-action:pan-y pinch-zoom}
 /* Menus and registration remain reachable above the keyboard and safe areas. */
 .q-signup{width:calc(100% - 24px);max-height:calc(100dvh - 24px - env(safe-area-inset-top,0px) - env(safe-area-inset-bottom,0px));overscroll-behavior:contain}
 .site-footer{padding-bottom:calc(25px + env(safe-area-inset-bottom,0px))}.footer-bottom a{display:inline-flex;min-height:44px;align-items:center}
}
@media(max-width:1100px) and (pointer:coarse) and (min-aspect-ratio:6/5){
 .sf-branches,.sf-unseen{align-items:center;padding-top:var(--mobile-top);padding-bottom:var(--mobile-bottom)}
 .sf-copy,.sf-unseen .sf-copy{width:43%;max-width:500px;text-align:left;margin:0!important}
 .sf-reading-light{background:linear-gradient(90deg,#f2f7faf5,#f2f7facf 27%,#f2f7fa00 61%)}
 .sf-stage:after{background:linear-gradient(270deg,#f2f7faf7,#f2f7facc 26%,#f2f7fa00 64%)}
 .sf-copy h2{font-size:clamp(1.5rem,3.4vw,2.3rem)}.sf-copy p{font-size:.875rem;line-height:1.7}
}
@media(max-width:360px){
 .q-language-instrument .q-tabs{grid-template-columns:repeat(2,minmax(0,1fr));gap:0 22px}
 .q-language-instrument .q-tabs button{font-size:.8125rem;text-align:left}
 .chapter-product .chapter-art{height:clamp(145px,25svh,190px)}
}
@media(max-width:600px){.q-join-options>div+div{padding-top:23px}}
@media(max-height:500px) and (pointer:coarse){
 :root{--mobile-top:76px;--mobile-bottom:58px}
 .world-opening{min-height:100svh}.world-object,.world-transcendence .world-object{height:52svh;min-height:170px}
 .sf-opening{min-height:100svh}.sf-title{top:80px}.sf-title h1{font-size:2.5rem}
 .sf-branches,.sf-unseen{min-height:100svh}
 #site-menu nav{margin-top:12px}#site-menu nav a{padding:9px 0}
}
/* Safari's toolbar changes the visible height on phones AND wide iPads. Keep
   only the painted/sticky surfaces dynamic; chapter lengths stay stable. */
@media(any-pointer:coarse){
 body[data-page=home] .home-hero{height:100dvh;min-height:0!important}
 body[data-page=home] .mountain-scene{bottom:auto;height:100lvh}
 .sf-stage,.migration-sticky{height:100dvh;margin-bottom:-100dvh}
}
html.touch-viewport body[data-page=home] .home-hero{height:var(--touch-viewport-height,100dvh);min-height:0!important}
html.touch-viewport body[data-page=home] .mountain-scene{bottom:auto;height:max(100lvh,var(--touch-scene-height,100lvh))}
html.touch-viewport .sf-stage,html.touch-viewport .migration-sticky{height:var(--touch-viewport-height,100dvh);margin-bottom:calc(-1 * var(--touch-viewport-height,100dvh))}
html.touch-viewport:has(body[data-page=home]){background-color:#071019}
html.touch-viewport:has(body[data-page=quantum]){background-color:#090e13}
html.touch-viewport:has(body[data-page=transcendence]){background-color:#0b101b}
html.touch-viewport:has(body[data-page=anchor]){background-color:#07131c}
html.touch-viewport:has(body[data-page=snowflake]){background-color:#f2f7fa;color-scheme:light}
