/* Mobile-lite: the phone-first layer shared by every page (creator, sheet, Home, rosters, campaign, library).
   Loaded with media="(max-width:760px), (hover:none) and (pointer:coarse)", so desktop never downloads or applies it.
   Principles: no pipe frames, no fixed backgrounds, no filters or large shadows, flat parchment, 16px text, 44px targets, slim chrome.
   pipe-frame.js uses the same query and builds nothing while it matches. Page-specific layout stays in each page's own CSS. */
:root{--lite-brass:#aa8650;--lite-parchment:#efe6d1;--lite-dark:#2a1d12;--lite-header:56px;--lite-steps:48px}
html{-webkit-text-size-adjust:100%;text-size-adjust:100%;scroll-padding-top:calc(var(--lite-header) + 12px);scroll-padding-bottom:76px}
html:has(#steps){scroll-padding-top:calc(var(--lite-header) + var(--lite-steps) + 12px)}
body{background:var(--lite-dark)!important;background-attachment:scroll!important;font-size:16px;padding:0!important;min-height:100vh;min-height:100dvh}

/* 1. No pipes, no scenery. */
.pipe-network,.pipe-footer-frame,.dialog-pipe-frame,.pipe-card-frame,.screen-scene,.screen-art,.screen-sidebar,.screen-top-ivy,.site-header-edge,.panel-trim,
header::after,footer::after,.site-header::after,.site-header::before,.frame::before,.frame::after{display:none!important}
.frame{margin:0!important;border:0!important;border-inline:2px solid var(--lite-brass)!important;border-radius:0!important;box-shadow:inset 0 0 0 1px #0003!important;background:var(--lite-parchment);overflow:visible!important}

/* 3. Cheap paint: no shadows, filters or blurs; flat parchment. */
*,*::before,*::after{box-shadow:none!important;text-shadow:none!important;backdrop-filter:none!important}
header,footer,nav,main,aside,section,div,button,a,span{filter:none!important}
.workspace,main,.panel,.public-shell,.account-shell{background-image:none!important}
.workspace,main{background-color:var(--lite-parchment)!important}
.panel{background-color:#f6eedc}
.selection-picker .pick-art,.option-art,.pick-art{decoding:async}
img{max-width:100%;height:auto}

/* 2. Slim header: logo, account, menu in one 56px row. The title and the draft/save line move out of the way. */
body:not(.player-mode):not(.player-rail-layout) header,body:not(.player-mode):not(.player-rail-layout) .site-header{position:sticky!important;top:0;z-index:30;height:var(--lite-header)!important;min-height:var(--lite-header)!important;padding:4px 10px!important;gap:8px!important;flex-wrap:nowrap!important;
 background:linear-gradient(#352414,#2a1d12)!important;border:0!important;border-bottom:2px solid var(--lite-brass)!important;align-items:center}
body:not(.player-mode):not(.player-rail-layout) header .brand,body:not(.player-mode):not(.player-rail-layout) .site-header .brand{flex:1 1 auto;min-width:0;width:auto!important;flex-basis:auto!important;border:0!important;padding:0!important;font-size:13px;gap:8px}
body:not(.player-mode):not(.player-rail-layout) header .brand .brand-logo,body:not(.player-mode):not(.player-rail-layout) .site-header .brand .brand-logo{width:36px!important;height:36px!important}
body:not(.player-mode):not(.player-rail-layout) header .brand b,body:not(.player-mode):not(.player-rail-layout) .site-header .brand b{font-size:14px!important;letter-spacing:1px}
body:not(.player-mode):not(.player-rail-layout) header h1,body:not(.player-mode):not(.player-rail-layout) #campaign-label,body:not(.player-mode):not(.player-rail-layout) .site-header .site-navigation{display:none!important}
body:not(.player-mode):not(.player-rail-layout) #save-status{position:absolute;left:0;right:0;top:100%;margin:0;padding:6px 12px;font-size:14px;background:#7a2a2a;color:#fff;text-align:center;display:none}
body:not(.player-mode):not(.player-rail-layout) #save-status.error{display:block}
body:not(.player-mode):not(.player-rail-layout) .site-header .account-identity{min-height:44px;min-width:44px;padding:0 8px!important;gap:6px;font-size:14px}
body:not(.player-mode):not(.player-rail-layout) .site-header .account-identity .account-avatar{width:30px;height:30px}
body:not(.player-mode):not(.player-rail-layout) .site-header .account-identity span:nth-child(n+2){display:none}
body:not(.player-mode):not(.player-rail-layout) .site-header .site-menu-button{width:44px!important;height:44px!important;flex:none}

/* Creator: slim sticky step bar. Icons only; the current step shows its name and "3 of 8", centred by renderNav. */
body:not(.player-mode):not(.player-rail-layout) #steps{position:sticky!important;top:var(--lite-header)!important;z-index:20;display:flex!important;flex-direction:row!important;align-items:center;gap:4px;height:var(--lite-steps)!important;min-height:var(--lite-steps)!important;max-height:var(--lite-steps)!important;
 padding:2px 8px!important;margin:0!important;overflow-x:auto!important;overflow-y:hidden!important;background:#e4d8bd!important;border-bottom:1px solid var(--lite-brass);scroll-snap-type:x proximity;scrollbar-width:none;-webkit-overflow-scrolling:touch}
body:not(.player-mode):not(.player-rail-layout) #steps::-webkit-scrollbar{display:none}
body:not(.player-mode):not(.player-rail-layout) #steps button{flex:0 0 auto!important;width:auto!important;min-width:44px;max-width:none!important;height:44px!important;min-height:44px;padding:0 6px!important;margin:0!important;display:inline-flex;align-items:center;justify-content:center;gap:6px;border:1px solid transparent!important;border-radius:22px!important;background:transparent!important;scroll-snap-align:center}
body:not(.player-mode):not(.player-rail-layout) #steps button::before,body:not(.player-mode):not(.player-rail-layout) #steps button::after{display:none!important}
body:not(.player-mode):not(.player-rail-layout) #steps button .number{width:32px;height:32px;margin:0}
body:not(.player-mode):not(.player-rail-layout) #steps button small,body:not(.player-mode):not(.player-rail-layout) #steps button strong{display:none}
body:not(.player-mode):not(.player-rail-layout) #steps button.active{background:#72152b!important;color:#fff3dc;border-color:#4e0d1b!important;padding:0 12px 0 6px!important}
body:not(.player-mode):not(.player-rail-layout) #steps button.active strong{display:inline;font-size:15px;color:#fff3dc}
body:not(.player-mode):not(.player-rail-layout) #steps button.active[data-position]::after{display:inline!important;position:static!important;transform:none!important;width:auto!important;height:auto!important;border:0!important;background:none!important;inset:auto!important;color:#fff3dc;content:attr(data-position);font-size:12px;font-weight:400;opacity:.8;margin-left:2px;white-space:nowrap}
body:not(.player-mode):not(.player-rail-layout) .workspace{display:block!important;min-height:0!important}

/* Step content: compact, with long intros folded behind "About this step" (app.js liteIntros). */
body:not(.player-mode):not(.player-rail-layout) main#main{padding:12px 14px 88px!important;min-height:0!important;height:auto!important;overflow:visible!important}
body:not(.player-mode):not(.player-rail-layout) main#main>h2{font-size:24px!important;margin:4px 0 8px!important;line-height:1.2}
body:not(.player-mode):not(.player-rail-layout) main#main .intro,body:not(.player-mode):not(.player-rail-layout) main#main .hint{font-size:15px}
.intro-more{margin:0 0 10px;border:1px solid #bba681;border-radius:6px;background:#faf6eb80}
.intro-more>summary{min-height:44px;display:flex;align-items:center;padding:0 12px;font-size:15px;font-weight:700;color:#5b2a10;cursor:pointer;list-style:none}
.intro-more>summary::-webkit-details-marker{display:none}
.intro-more>summary::after{content:'+';margin-left:auto;font-size:20px}
.intro-more[open]>summary::after{content:'−'}
.intro-more>p{margin:0;padding:0 12px 12px}
aside#summary{content-visibility:auto;contain-intrinsic-size:auto 600px}

/* 4. Readable and tappable. 16px inputs stop iOS zooming; 44px targets. */
input:not([type=checkbox]):not([type=radio]),select,textarea{font-size:16px!important;min-height:44px}
button,.button,[role=button],summary,select{min-height:44px}
label.class-skill,label.check{min-height:44px;display:flex;align-items:center;gap:10px}
input[type=checkbox],input[type=radio]{width:22px;height:22px}
.selection-picker .pick{min-height:92px!important}
.selection-picker .pick-detail-link{min-height:0!important}

/* Footer: slim fixed bar; it steps aside while a text field is focused so the keyboard never hides the field behind it. */
body:not(.player-mode):not(.player-rail-layout) footer{position:fixed!important;left:0;right:0;bottom:0;z-index:25;display:flex!important;flex-wrap:nowrap!important;gap:6px;align-items:center;padding:6px 8px calc(6px + env(safe-area-inset-bottom))!important;min-height:0!important;height:auto!important;margin:0!important;
 background:#2a1d12!important;border:0!important;border-top:2px solid var(--lite-brass)!important}
body:not(.player-mode):not(.player-rail-layout) footer button{flex:0 0 auto!important;grid-column:auto!important;width:auto!important;min-width:0;min-height:44px;height:44px;padding:0 12px;font-size:15px;white-space:nowrap}
body:not(.player-mode):not(.player-rail-layout) footer button svg{width:20px;height:20px}
body:not(.player-mode):not(.player-rail-layout) footer #back,body:not(.player-mode):not(.player-rail-layout) footer #save-exit{font-size:0;width:48px!important;padding:0!important;justify-content:center}  /* icon-only; the text stays for screen readers */
body:not(.player-mode):not(.player-rail-layout) footer #next{flex:1 1 auto!important;min-width:0;overflow:hidden;text-overflow:ellipsis}
body:not(.player-mode):not(.player-rail-layout) footer #footer-note{display:none}
html.keyboard-open body:not(.player-mode) footer{display:none!important}

/* Searches stay put above the list so results sit above the keyboard. */
.search-field{position:static;top:calc(var(--lite-header) + var(--lite-steps));z-index:15;background:var(--lite-parchment);padding:6px 0;margin:0 0 6px}
.search-field:focus-within{position:sticky}  /* pinned only while typing, so results stay in view above the keyboard */
.search-field input{width:100%}
.source-filters{display:flex;gap:6px;overflow-x:auto;padding:2px 0 6px;scrollbar-width:none}
.source-filters::-webkit-scrollbar{display:none}
.source-filters .source-chip{flex:0 0 auto;min-height:44px;white-space:nowrap}

/* Dialogs fit the screen and scroll inside themselves. */
dialog{max-width:calc(100vw - 16px)!important;max-height:calc(100vh - 16px)!important;max-height:calc(100dvh - 16px)!important;overflow:auto;box-sizing:border-box}

/* Popovers (character switcher, language/skill pickers) become a bottom sheet: full width, above the footer, scrolling inside themselves. */
.chars-pop:not([hidden]),.choice-picker-pop:not([hidden]){position:fixed!important;left:8px!important;right:8px!important;top:auto!important;bottom:calc(8px + env(safe-area-inset-bottom))!important;width:auto!important;max-width:none!important;
 max-height:min(78vh,calc(100vh - 90px))!important;
 max-height:min(78dvh,calc(100dvh - 90px))!important;margin:0!important;display:flex!important;flex-direction:column;z-index:200!important;transform:none!important}
.chars-pop .pop-list,.choice-picker-pop .pop-list{flex:1 1 auto;min-height:0;max-height:none!important;overflow-y:auto;overscroll-behavior:contain;-webkit-overflow-scrolling:touch}
.chars-pop .pop-head,.choice-picker-pop .pop-head{flex:none}
.chars-pop .pop-search{font-size:16px}

/* Phone accordions: the open card already shows the art and name, so the class header drops its big portrait, and nested panels lose a border level. */
.selection-detail .class-art-card .class-portrait{display:none}
.selection-detail .class-art-card,.selection-detail .panel{padding:10px!important}
.selection-detail .panel .panel{border-width:0!important;padding:6px 0!important;background:none!important}

/* Abilities: one compact row per score (name, base select, total and modifier) instead of six 360px cards. */
#main[data-step=abilities] .ability-cards{display:grid!important;grid-template-columns:1fr!important;gap:6px!important}
#main[data-step=abilities] .ability-cards>.score{display:grid!important;grid-template-columns:minmax(0,1fr) 112px 56px;grid-template-areas:"head pick total" "name pick mod" "more more more";align-items:center;column-gap:10px;row-gap:0;padding:8px 10px!important;min-height:0!important;text-align:left}
#main[data-step=abilities] .score .ability-heading{grid-area:head;margin:0;justify-content:flex-start;font-size:18px}
#main[data-step=abilities] .score>small:not(:last-of-type){grid-area:name;margin:0;font-size:13px}
#main[data-step=abilities] .score>label{grid-area:pick;font-size:0;margin:0}
#main[data-step=abilities] .score>label select{font-size:16px!important;width:100%}
#main[data-step=abilities] .score .total{grid-area:total;font-size:26px;line-height:1;text-align:center;margin:0}
#main[data-step=abilities] .score .modifier{grid-area:mod;font-size:14px;text-align:center;margin:0}
#main[data-step=abilities] .score .ability-breakdown{grid-area:more;margin:2px 0 0}
#main[data-step=abilities] .score .ability-breakdown summary{min-height:36px;font-size:14px}
#main[data-step=abilities] .score>small:last-of-type,#main[data-step=abilities] .score .ability-final{display:none}
#main[data-step=abilities] .ability-cards>.score *{margin-block:0!important}
#main[data-step=abilities] .score .ability-breakdown,#main[data-step=abilities] .score .ability-breakdown summary{padding-block:0!important;border:0!important;min-height:32px}
#main[data-step=abilities] .score .modifier{padding:0!important;min-height:0!important;border:0!important;background:none!important}
#main[data-step=abilities] .ability-cards>.score::after{display:none}

/* Sheet popovers (hit points with conditions and exhaustion, rests, more options) open as a bottom sheet that always fits and scrolls inside itself. */
.standard-sheet :is(.player-hp,.player-rest,.player-more)[open]>:not(summary){position:fixed!important;left:64px!important;right:8px!important;top:auto!important;bottom:calc(8px + env(safe-area-inset-bottom))!important;width:auto!important;max-width:none!important;
 max-height:min(72vh,calc(100vh - 24px))!important;
 max-height:min(72dvh,calc(100dvh - 24px))!important;overflow-y:auto!important;overscroll-behavior:contain;-webkit-overflow-scrolling:touch;z-index:90!important;margin:0!important;box-sizing:border-box}
/* Sheet tap targets: 44x44 minimum, including the narrow roll chips, tabs and icon buttons. */
.standard-sheet :is(button,summary,[role=tab],a.button){min-width:44px;min-height:44px}
.standard-sheet .identity-edit{min-width:44px;min-height:44px}
.standard-sheet [role=tab]{min-height:44px!important;height:44px!important}
.standard-sheet input:not([type=checkbox]):not([type=radio]):not([type=range]){min-height:44px!important;font-size:16px!important}
.standard-sheet :is(button,button.small,select){min-height:44px!important}
.standard-sheet :is(button.small,select){min-width:44px!important}
html body .standard-sheet select{min-height:44px!important;height:44px!important;font-size:16px!important}
/* Sheet tab bar stays at the top of the scrolling sheet while a tab's content scrolls. */
.standard-sheet .player-workspace .tabs{position:sticky;top:0;z-index:12;background:var(--lite-parchment)}

/* Sheet on a phone scrolls as one page (the desktop "app shell" gave the tab content an 85px-tall window under a 390px header block).
   The site rail stays pinned at the left while the sheet scrolls; the tab bar sticks under the top edge. */
body.player-rail-layout,body.player-mode{height:auto!important;min-height:100vh;min-height:100dvh;overflow:visible!important}
body.player-rail-layout .frame,body.player-mode .frame{height:auto!important;min-height:100vh;min-height:100dvh;overflow:visible!important}
body.player-rail-layout .workspace,body.player-mode main#main,body.player-mode .standard-sheet,body.player-mode .player-workspace,body.player-mode .player-workspace-body,body.player-mode .player-layout{height:auto!important;max-height:none!important;overflow:visible!important}
body.player-rail-layout .player-site-rail{position:sticky!important;top:0;height:100vh;height:100dvh;align-self:start}
body.player-mode .standard-sheet .player-workspace .tabs{position:sticky;top:0;z-index:12;overflow-x:auto}
.site-header .account-identity{width:44px!important;padding:0!important;justify-content:center!important;display:inline-flex!important;align-items:center}
.site-header .account-identity .account-avatar{margin:0!important}
.standard-sheet .slot-pool{flex-wrap:wrap;max-width:100%}
.sheet-action-filters button,.inventory-category-filters button,.feature-category-filters button{min-width:44px;min-height:44px}

/* Inventory on a phone: dialogs are bottom sheets, filters are chips that wrap, rows never push the page sideways. */
dialog.inventory-dialog{position:fixed;inset:auto 0 0 0!important;margin:0!important;width:100%!important;max-width:100vw!important;max-height:92vh!important;max-height:92dvh!important;border-radius:14px 14px 0 0!important;padding:18px 14px calc(14px + env(safe-area-inset-bottom))!important;overflow:auto}
dialog.inventory-dialog .item-use-body{max-height:none}
.inventory-workspace-2024{overflow-x:clip}
.inventory-workspace-2024 .inventory-category-filters{flex-wrap:wrap}
.inventory-workspace-2024 .inventory-find{flex-basis:100%}.inventory-workspace-2024 .inventory-find select{flex:1 1 40%}
.inventory-workspace-2024 .inventory-tools{flex-wrap:wrap}.inventory-workspace-2024 .inventory-tools select{max-width:100%}
.inventory-load-head{font-size:.9375rem}.inventory-recommendation{flex-direction:column;align-items:stretch}.inventory-recommendation button{min-height:44px}
.inventory-qty-stepper{gap:6px}.inventory-qty-stepper .inventory-qty-input{min-height:44px!important;width:4em;font-size:16px!important}
.inventory-row-description{margin-left:0}
.inventory-add-results{max-height:38vh;max-height:38dvh}.inventory-add-detail{padding-left:10px}
.inventory-add-controls select,.inventory-add-controls button{min-height:44px}
.inventory-add-qty input{min-height:44px;font-size:16px}
.inventory-add-bar{padding-bottom:calc(8px + env(safe-area-inset-bottom))}.inventory-add-bar input{min-height:44px;font-size:16px}
.inventory-add-results{max-height:none}
dialog.inventory-add-dialog[open]{display:flex!important;flex-direction:column;overflow:hidden!important}
dialog.inventory-add-dialog .inventory-add-body{flex:1 1 auto;min-height:0;display:flex;flex-direction:column;overflow:hidden}
dialog.inventory-add-dialog .inventory-add-body>*{flex:none}
dialog.inventory-add-dialog .inventory-add-body>.inventory-add-results{flex:1 1 auto;min-height:96px;overflow:auto}
dialog.inventory-add-dialog .inventory-add-chips{flex-wrap:nowrap;overflow-x:auto}dialog.inventory-add-dialog .inventory-add-chips button{flex:none}
dialog.inventory-add-dialog .inventory-add-controls{flex-wrap:nowrap}dialog.inventory-add-dialog .inventory-add-controls select{flex:1 1 0;min-width:0}dialog.inventory-add-dialog .inventory-add-controls button{flex:none}dialog.inventory-add-dialog .inventory-add-count{margin:4px 0}dialog.inventory-add-dialog>h3{margin-bottom:10px}
dialog.inventory-add-dialog .item-use-footer{background:inherit;padding-bottom:env(safe-area-inset-bottom)}
.inventory-play-dialog .play-coin-grid{grid-template-columns:repeat(3,minmax(0,1fr))}.inventory-play-dialog input,.inventory-play-dialog select,.inventory-play-dialog button{min-height:44px;font-size:16px}.inventory-play-dialog .play-dice input{width:3.2em}
.inventory-summary-bar button.inventory-attunement{min-height:44px}
.item-use-footer{position:sticky;bottom:0}
.party-aura-lite{display:grid;margin:0 0 8px}.checks-open~.party-aura-lite{display:none}
/* Adult sheet phone controls stay in their own strip above sticky tabs. */
@media(max-width:640px){
 body.player-mode:not(.kid-friendly-mode) .standard-sheet .player-workspace>.tabs{top:calc(48px + env(safe-area-inset-top));scroll-margin-top:calc(48px + env(safe-area-inset-top))}
 body.player-rail-layout:not(.kid-friendly-mode) .player-site-rail{position:fixed!important;top:calc(48px + env(safe-area-inset-top))!important;height:auto}
 body.player-mode:not(.kid-friendly-mode) .standard-sheet .player-header .player-more{position:fixed;top:env(safe-area-inset-top);right:max(4px,env(safe-area-inset-right));z-index:15}
 body.player-mode:not(.kid-friendly-mode) .standard-sheet .player-header .player-more>summary{display:grid;place-items:center;min-width:44px;min-height:44px;padding:5px}
 body.player-mode:not(.kid-friendly-mode) .standard-sheet .player-more[open]>.player-popover{position:fixed!important;top:calc(48px + env(safe-area-inset-top))!important;right:8px!important;left:auto!important;bottom:auto!important;width:min(310px,calc(100vw - 16px))!important;max-height:calc(100vh - 60px);max-height:calc(100dvh - 60px);overflow:auto}
}
@media(max-width:640px){body.player-mode:not(.kid-friendly-mode) .standard-sheet .player-header .player-more{margin:0;padding:0;border:0}}
@media(max-width:640px){dialog.dialog-journal-popover{max-height:55vh!important;max-height:55dvh!important;overflow:auto!important}}
@media(max-width:640px){dialog.dialog-journal-popover{position:fixed;top:auto;bottom:8px;margin:0 auto}}
