/* TabbedPages · iOS layout (html.pgm). Same app, same address: the early detector in index.html turns this on for iPhone, iPod and
   iPad windows 820 px wide or narrower (add ?mobile=1 to force it, ?mobile=0 to switch it off).
   Structure: the body is one fixed-height column that always equals the visible area (kept in step with the keyboard by
   pages-mobile-r1.js): top bar · scrolling document · writing bar. Nothing is position:fixed against the page, so the writing bar
   cannot drift into the middle of the screen, and the document is the only thing that scrolls. */
html.pgm{--pgm-h:100dvh;--pgm-top:46px;--pgm-bar:48px;height:100%;overflow:hidden!important;overscroll-behavior:none;-webkit-text-size-adjust:100%;text-size-adjust:100%}
html.pgm body{position:fixed!important;left:0!important;top:0!important;right:auto!important;bottom:auto!important;width:100%!important;height:var(--pgm-h)!important;margin:0!important;padding:0!important;overflow:hidden!important;display:flex!important;flex-direction:column!important;overscroll-behavior:none;touch-action:manipulation;-webkit-tap-highlight-color:transparent;background:#ece9e3!important}
html.pgm body>*{min-width:0}

/* desktop chrome that has no place on a phone */
html.pgm.pages-ready body>header#pg-header,html.pgm #pg-word-count,html.pgm #statusbar,html.pgm #tw-chrome,html.pgm body>footer,html.pgm #pg-toggle{display:none!important}

/* top bar */
html.pgm #pgm-top{flex:none;display:flex;align-items:center;gap:4px;height:calc(var(--pgm-top) + env(safe-area-inset-top,0px));padding:env(safe-area-inset-top,0px) max(6px,env(safe-area-inset-right,0px)) 0 max(6px,env(safe-area-inset-left,0px));background:#f2f0ec;border-bottom:1px solid #ddd8ce;z-index:30;box-sizing:border-box}
html.pgm #pgm-top .pgm-ib{flex:none;width:42px;height:42px;display:grid;place-items:center;border:0;border-radius:12px;background:transparent;color:#4a4033;padding:0}
html.pgm #pgm-top .pgm-ib:active,html.pgm #pgm-bar .pgm-key:active{background:#e4ddd0}
html.pgm #pgm-top .pgm-ib svg,html.pgm #pgm-bar svg{width:22px;height:22px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
html.pgm #pgm-top .pgm-ib.pgm-orange{background:#ff9500;color:#fff}
html.pgm #pgm-name{flex:1;min-width:0;height:42px;border:0;background:transparent;text-align:left;font:600 15px/1.2 -apple-system,BlinkMacSystemFont,system-ui,sans-serif;color:#2b2822;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding:0 6px}
html.pgm #pgm-name small{display:block;font:11px/1.2 system-ui;color:#8a8275;font-weight:400}

/* the only scrolling area */
html.pgm.pages-ready body main,html.pgm.pages-ready body main.tw-three.writing-workspace:not(#a):not(#b),html.pgm.pages-ready body.pg-sidebar-open main.tw-three.writing-workspace:not(#a):not(#b){flex:1 1 auto!important;min-height:0!important;height:auto!important;width:100%!important;max-width:none!important;margin:0!important;padding:8px 8px 36px!important;display:block!important;overflow-x:hidden!important;overflow-y:auto!important;-webkit-overflow-scrolling:touch;overscroll-behavior-y:contain;scroll-padding:12px 0 60px;box-sizing:border-box!important;position:relative!important}
html.pgm.pages-ready body main.tw-three.writing-workspace #paper:not(#a):not(#b){width:100%!important;max-width:none!important;margin:0!important;padding:0!important}
html.pgm #docpages{gap:0!important}
html.pgm #docpages .doc-page{width:100%!important;max-width:none!important;min-height:0!important;margin:0 0 8px!important;padding:16px 15px 28px!important;border:0!important;border-radius:10px!important;box-shadow:0 1px 3px #3a2f1a1f!important;box-sizing:border-box!important;background:#fff}
html.pgm{--pgm-fill:calc(var(--pgm-h) - var(--pgm-top) - var(--pgm-bar) - env(safe-area-inset-top,0px) - env(safe-area-inset-bottom,0px) - 52px)}
html.pgm #docpages .doc-page{min-height:var(--pgm-fill)!important;cursor:text}
html.pgm #docpages .doc-surface{font-size:16px;min-height:calc(var(--pgm-fill) - 44px);outline:none;-webkit-user-select:text;user-select:text;-webkit-touch-callout:default}
html.pgm #docpages textarea{font-size:16px!important}
html.pgm .page-number,html.pgm #docxtools,html.pgm #pageview,html.pgm #pagecount{display:none!important}
html.pgm #docpages .empty-state{padding:34px 16px!important}

/* writing bar: a normal flex row at the bottom of the body */
html.pgm #pgm-bar{flex:none;display:flex;align-items:center;gap:2px;height:calc(var(--pgm-bar) + env(safe-area-inset-bottom,0px));padding:0 max(4px,env(safe-area-inset-right,0px)) env(safe-area-inset-bottom,0px) max(4px,env(safe-area-inset-left,0px));background:#f6f4f0;border-top:1px solid #ddd8ce;z-index:30;box-sizing:border-box;overflow:hidden}
html.pgm.pgm-kb #pgm-bar{height:var(--pgm-bar);padding-bottom:0}
html.pgm #pgm-bar .pgm-key{flex:1 1 0;min-width:0;height:42px;display:grid;place-items:center;border:0;border-radius:11px;background:transparent;color:#3a3329;font:600 17px/1 -apple-system,system-ui,sans-serif;padding:0;touch-action:manipulation}
html.pgm #pgm-bar .pgm-key[aria-pressed=true]{background:#ffe6b9;color:#a05d00}
html.pgm #pgm-bar .pgm-key.pgm-b{font-weight:800}html.pgm #pgm-bar .pgm-key.pgm-i{font-style:italic;font-family:Georgia,serif}html.pgm #pgm-bar .pgm-key.pgm-u{text-decoration:underline}
html.pgm #pgm-bar .pgm-key.pgm-dim{opacity:.35}

/* the inspector becomes a bottom sheet */
html.pgm #pgm-backdrop{display:none;position:absolute;inset:0;background:#20180c55;z-index:70}
html.pgm.pgm-sheet #pgm-backdrop{display:block}
html.pgm #pg-inspector:not(#a):not(#b){position:absolute!important;top:auto!important;right:0!important;left:0!important;bottom:0!important;width:100%!important;height:min(74%,calc(var(--pgm-h) - 56px))!important;max-height:none!important;border:0!important;border-radius:18px 18px 0 0!important;box-shadow:0 -10px 34px #20180c40!important;z-index:80;padding-bottom:env(safe-area-inset-bottom,0px);overflow:hidden;box-sizing:border-box}
html.pgm #pgm-handle{flex:none;display:block;width:100%;height:22px;border:0;background:transparent;padding:0;touch-action:none;position:relative}
html.pgm #pgm-handle::after{content:"";position:absolute;left:50%;top:8px;width:38px;height:5px;margin-left:-19px;border-radius:3px;background:#cfc8bb}
html.pgm #pg-inspector-tabs{flex:none}
html.pgm #pg-inspector-content{flex:1 1 auto;min-height:0;overflow-y:auto!important;-webkit-overflow-scrolling:touch;overscroll-behavior:contain;padding-bottom:20px}
html.pgm #pg-inspector button,html.pgm #pg-inspector select,html.pgm #pg-inspector summary{min-height:40px}
html.pgm #pg-inspector input:not([type=checkbox]):not([type=radio]),html.pgm #pg-inspector select,html.pgm #pg-inspector textarea{font-size:16px!important}
html.pgm .pg-pane{max-width:100%;overflow-x:hidden}
html.pgm dialog{max-width:94vw!important;max-height:80dvh!important}
@supports not (height:100dvh){html.pgm{--pgm-h:100vh}}

/* fast scroller and Top chip */
html:not(.pgm) #pgm-fs,html:not(.pgm) #pgm-top-chip{display:none!important}
html.pgm #pgm-fs{position:absolute;right:0;top:calc(var(--pgm-top) + env(safe-area-inset-top,0px) + 8px);bottom:calc(var(--pgm-bar) + env(safe-area-inset-bottom,0px) + 8px);width:30px;z-index:25;pointer-events:none;opacity:0;transition:opacity .25s;display:none}
html.pgm.pgm-kb #pgm-fs{bottom:calc(var(--pgm-bar) + 8px)}
html.pgm #pgm-fs.on{display:block}
html.pgm #pgm-fs.live,html.pgm #pgm-fs.drag{opacity:1}
html.pgm #pgm-fs-thumb{position:absolute;right:2px;top:0;width:26px;min-height:44px;border:0;padding:0;border-radius:13px;background:transparent;pointer-events:auto;touch-action:none}
html.pgm #pgm-fs-thumb::after{content:"";position:absolute;right:4px;top:0;bottom:0;width:5px;border-radius:3px;background:#8b7e68b3;transition:width .15s,background .15s}
html.pgm #pgm-fs.drag #pgm-fs-thumb::after{width:9px;background:#ff9500}
html.pgm #pgm-top-chip{position:absolute;right:12px;bottom:calc(var(--pgm-bar) + env(safe-area-inset-bottom,0px) + 14px);z-index:26;display:none;height:34px;padding:0 14px;border:0;border-radius:17px;background:#2b2822d9;color:#fff;font:600 13px system-ui;box-shadow:0 2px 10px #0003;-webkit-backdrop-filter:blur(6px);backdrop-filter:blur(6px)}
html.pgm #pgm-top-chip.on{display:block}
html.pgm main{scroll-behavior:auto;-webkit-overflow-scrolling:touch;scrollbar-width:none}
html.pgm main::-webkit-scrollbar{display:none}

/* keyboard open with a panel: the panel is anchored to the visible area and fills it, so the field being typed in is never under the keyboard */
html.pgm.pgm-kb.pgm-sheet #pg-inspector:not(#a):not(#b){height:calc(var(--pgm-h) - 10px)!important;padding-bottom:0!important;transition:height .18s ease}
html.pgm.pgm-kb.pgm-sheet #pg-inspector-tabs,html.pgm.pgm-kb.pgm-sheet #shoulder .sh-tabs{display:none}
