/* Shared sizing comes last, so feature styles cannot create smaller viewports. */
:root{--hub-viewport-height:100vh;--hub-viewport-width:100%;--hub-viewport-top:0px;--hub-viewport-left:0px;--hub-gutter:34px;--modal-gutter:clamp(12px,2.5vmin,28px)}
@supports(height:100dvh){:root{--hub-viewport-height:100dvh}}
html{-webkit-text-size-adjust:100%;scroll-padding-top:20px}
body{min-width:0}
.main{min-width:0;min-height:100svh}
.content{width:100%;min-width:0;padding-left:max(var(--hub-gutter),env(safe-area-inset-left,0px));padding-right:max(var(--hub-gutter),env(safe-area-inset-right,0px))}
.content>*,.stack>*,.card,.modal,.grid2>*,.grid3>*,.form-grid>*,.metric-grid>*,.client-grid>*,.home-layout>*,.balance-stats>*,.identity-facts>*,.feedback-layout>*,.ci-layout>*,.unit-fields>*,.live-set>*,.set-row>*{min-width:0}
.home-quick-grid,.home-actions{grid-template-columns:repeat(2,minmax(0,1fr))}
.home-quick-grid>*,.home-actions>*,.ritual-home>*,.favorite-grid>*,.award-grid>*{min-width:0}
.page-heading,.card-header,.between,.form-actions,.training-summary,.live-state{flex-wrap:wrap}
.page-heading>div,.card-header>div,.between>div,.history-row .row>div,.exercise>div,.exercise-select>label,.journal-invitation>div,.identity-top>div{min-width:0}
.page-heading h1,.modal-header h2,.card h2,.card h3,.identity-top h1,.identity-top h2,.identity-facts b,.history-row h3,.unit-card-name{overflow-wrap:anywhere}
.page-heading .btn{min-width:0;max-width:100%;white-space:normal;text-align:center}
.form-grid input,.form-grid select,.form-grid textarea,.field input,.field select,.field textarea{min-width:0;max-width:100%}
.topbar{height:auto;min-height:98px;flex-wrap:wrap;padding-block:max(12px,env(safe-area-inset-top,0px)) 12px;row-gap:8px}
.top-right{min-width:0;flex-wrap:wrap;justify-content:flex-end}
.topbar .brand-mark{flex-shrink:0}
.table-wrap,.tier-strip{max-width:100%;-webkit-overflow-scrolling:touch}
.login{min-height:var(--hub-viewport-height)}

/* Native dialogs live above the app, independent of cards and their transforms. */
.modal-overlay{position:fixed;inset:auto;top:var(--hub-viewport-top);left:var(--hub-viewport-left);width:var(--hub-viewport-width);height:var(--hub-viewport-height);max-width:none;max-height:none;min-width:0;min-height:0;margin:0;border:0;color:var(--ink);font:inherit;box-sizing:border-box;display:flex;align-items:center;justify-content:center;overflow:hidden;padding:max(var(--modal-gutter),env(safe-area-inset-top,0px)) max(var(--modal-gutter),env(safe-area-inset-right,0px)) max(var(--modal-gutter),env(safe-area-inset-bottom,0px)) max(var(--modal-gutter),env(safe-area-inset-left,0px))}
dialog.modal-overlay:not([open]){display:none}
.modal-overlay::backdrop{background:transparent}
.modal-overlay>.modal{flex:0 1 auto;min-height:0;max-height:100%;overflow:auto;overscroll-behavior:contain;-webkit-overflow-scrolling:touch;scroll-padding-block:18px;overflow-wrap:anywhere}
.modal-overlay>.modal>.modal-header{align-items:flex-start}
.modal-header .icon-btn{flex-shrink:0;min-width:44px;min-height:44px}
.modal-overlay>.modal:has(.ritual-scene){max-height:100%}
html[data-modal-open=true] .bottom-nav{visibility:hidden}
html[data-keyboard-open=true] .bottom-nav{visibility:hidden;pointer-events:none}

/* A reveal fills the screen; only its content scrolls on short displays. */
.modal-overlay.modal-reveal{display:block;padding:0;background:#03070c}
.modal-overlay.modal-reveal:before{position:absolute;inset:0}
.modal-overlay.modal-reveal>.modal{width:100%;max-width:none;height:100%;max-height:100%;display:flex;flex-direction:column;align-items:center;padding:max(12px,env(safe-area-inset-top,0px)) max(clamp(18px,3vw,35px),env(safe-area-inset-right,0px)) max(22px,env(safe-area-inset-bottom,0px)) max(clamp(18px,3vw,35px),env(safe-area-inset-left,0px));border:0;border-radius:0;box-shadow:none;background:radial-gradient(ellipse at 50% 40%,#5a859f16,transparent 65%),#03070c;overflow:auto}
.modal-overlay.modal-reveal>.modal>.modal-header{position:sticky;top:0;width:100%;max-width:900px;min-height:44px;flex-shrink:0;justify-content:flex-end;margin:0;background:#03070ce8;border-radius:12px;z-index:8}
.modal-reveal .award-reveal{width:100%;max-width:840px;flex:0 0 auto;margin-block:auto}
.modal-reveal .award-reveal:before{position:absolute;inset:0;pointer-events:none}
.modal-reveal .reveal-top{width:100%;max-width:none;flex-wrap:wrap;gap:10px;padding:6px 0;margin-bottom:4px}
.modal-reveal .award-reveal .trophy-viewer{width:100%;height:clamp(170px,calc(var(--hub-viewport-height)*.38),460px);min-height:0}
.modal-reveal .award-reveal .reveal-copy{padding-top:18px}
.modal-reveal .reveal-copy p:not(.eyebrow){margin-bottom:16px}
.modal-reveal .reveal-actions .btn{flex:0 1 auto;max-width:100%;white-space:normal;min-height:46px}
.award-detail .trophy-viewer{height:clamp(200px,calc(var(--hub-viewport-height)*.4),400px);max-width:100%}

@media(max-width:1180px){:root{--hub-gutter:25px}}
@media(max-width:1024px){.client-shell .content{padding-bottom:calc(125px + env(safe-area-inset-bottom,0px))}}
@media(max-width:760px){
 :root{--hub-gutter:22px}
 .topbar{min-height:87px;padding-inline:max(17px,env(safe-area-inset-left,0px)) max(17px,env(safe-area-inset-right,0px))}
 .home-aside{display:flex;flex-direction:column;gap:20px}
 .modal-overlay>.modal{padding:22px 18px}
 .modal-overlay>.modal:has(.ritual-scene){padding:12px}
}
@media(max-width:600px){
 .topbar .brand-mark{width:clamp(128px,36vw,172px);height:58px}
 .topbar{gap:8px;justify-content:space-between}
 .top-right{gap:4px}
 .form-grid{grid-template-columns:minmax(0,1fr)}
 .history-row{align-items:flex-start;flex-wrap:wrap}
 .history-row>.btn{max-width:100%;white-space:normal}
 .ritual-meta label{flex-wrap:wrap}
 .ritual-meta input{width:160px;min-height:38px;max-width:100%}
 .ritual-footer{flex-wrap:wrap}
 .ritual-footer .btn{flex:1 1 100px;white-space:normal}
 .journal-invitation{gap:16px;padding:22px 18px}
 .journal-invitation h2{font-size:24px}
 .identity-top>div:not(.identity-avatar){max-width:100%}
 .favorite-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
 .balance-stat{padding:18px 14px}
 .modal-reveal .award-reveal .reveal-copy h2{font-size:clamp(27px,7vw,36px)}
 .modal-reveal .reveal-actions .btn{flex:1 1 150px}
}
@media(max-width:440px){
 :root{--hub-gutter:17px;--modal-gutter:10px}
 .stats-row{grid-template-columns:minmax(0,1fr)}
 .ritual-options{grid-template-columns:repeat(3,minmax(0,1fr))}
 .ritual-options button{min-height:48px;font-size:11px;padding:10px 8px}
 .modal-overlay>.modal{padding:20px 16px}
 .rest-panel{flex-wrap:wrap}
 .rest-buttons{max-width:100%;justify-content:flex-start}
 .view-switch{flex-wrap:wrap}
 .view-switch .btn{white-space:normal}
 .page-footer{overflow-wrap:anywhere}
}
@media(max-width:350px){.topbar{justify-content:center}.topbar .top-right{flex-basis:100%;justify-content:center}.award-grid,.balance-stats,.identity-facts,.favorite-grid{grid-template-columns:minmax(0,1fr)}.metric-grid{grid-template-columns:minmax(0,1fr)!important}}
@media(max-width:760px),(any-pointer:coarse){
 /* iOS otherwise zooms into small fields and leaves a cropped page behind. */
 #app input,#app select,#app textarea,#modal-root input,#modal-root select,#modal-root textarea{font-size:16px}
 #app .live-set input,#modal-root .live-set input{font-size:20px}
}
@media(min-width:700px) and (max-height:600px){
 .modal-reveal .award-reveal{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);column-gap:24px;align-items:center}
 .modal-reveal .reveal-top{grid-column:1/-1}
 .modal-reveal .award-reveal .trophy-viewer{height:clamp(170px,calc(var(--hub-viewport-height)*.58),300px)}
 .modal-reveal .award-reveal .reveal-copy{padding:12px 0}
}
