/* App shell: fixed top bar, scrolling middle, fixed tab bar. Only #view scrolls, so the bars never move. */
#app{height:100%;max-width:504px;margin:0 auto;display:flex;flex-direction:column}
#top{flex:none;position:relative;z-index:5;background:var(--bg);padding:5px max(13px,env(safe-area-inset-right,0px)) 3px max(13px,env(safe-area-inset-left,0px))}
#view{flex:1;min-height:0;overflow-y:auto;overscroll-behavior:contain;-webkit-overflow-scrolling:touch;padding:6.5px max(13px,env(safe-area-inset-right,0px)) 26px max(13px,env(safe-area-inset-left,0px))}
body.rest-on #view{padding-bottom:118px}
#view{padding-bottom:calc(26px + var(--kb,0px))}
body.rest-on #view{padding-bottom:calc(118px + var(--kb,0px))}
.topbar{display:flex;align-items:center;gap:6.5px;min-height:42.5px}
.topbar h1{flex:1;margin:0;text-align:center;font-size:18px;font-weight:700;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.tb-side{width:35.5px;flex:none}

#nav{flex:none;background:var(--surface);border-top:1px solid var(--line);padding:5px max(8px,env(safe-area-inset-right,0px)) calc(5px + env(safe-area-inset-bottom,0px)*var(--navk,.4)) max(8px,env(safe-area-inset-left,0px))}
#nav .in{display:flex}
#nav button{flex:1;display:flex;flex-direction:column;align-items:center;gap:2px;height:42.5px;justify-content:center;color:var(--muted);font-size:9.5px;font-weight:600;border-radius:11px}
#nav button[aria-current="page"]{color:var(--accent)}
body[data-view="editor"] #nav{display:none}
#nav .jump button{height:42px}
#nav .jump svg.i{width:23px;height:23px}

#restbar{position:fixed;left:max(10px,env(safe-area-inset-left,0px));right:max(10px,env(safe-area-inset-right,0px));bottom:calc(env(safe-area-inset-bottom,0px)*var(--navk,.4) + 58.5px);max-width:434px;margin:0 auto;z-index:20;height:74px;border-radius:18px;background:var(--surface2);border:1px solid var(--accent);box-shadow:var(--shadow);overflow:hidden}
.rest-fill{position:absolute;inset:0 auto 0 0;background:var(--accent-soft);width:0}
.rest-in{position:relative;display:flex;align-items:center;gap:6.5px;height:100%;padding:0 9px 0 16px}
.rest-lbl{color:var(--accent);font-size:10px;letter-spacing:.08em;text-transform:uppercase;font-weight:700}
.rest-main{flex:1;display:flex;flex-direction:column;justify-content:center;min-width:0}
.rest-in b{font-family:var(--display);font-size:38px;line-height:1;font-weight:700;font-variant-numeric:tabular-nums}
.rest-in button{height:42px;min-width:46px;padding:0 10px;border-radius:12px;background:var(--surface);font-weight:600;font-size:13px}
.rest-in .skip{background:var(--accent);color:var(--accent-ink)}

/* Sheets sit above the tab bar on tab pages, full height in workout and editor */
#sheet{position:fixed;inset:0;z-index:50}
#sheet{bottom:var(--kb,0px)}
body:not([data-view="editor"]) #sheet{bottom:max(calc(env(safe-area-inset-bottom,0px)*var(--navk,.4) + 52.5px),var(--kb,0px))}
.scrim{position:absolute;inset:0;background:rgba(2,8,14,.6);touch-action:none}
.panel{position:absolute;left:0;right:0;bottom:0;max-width:504px;margin:0 auto;max-height:90%;overflow-y:auto;overscroll-behavior:contain;background:var(--surface);border-radius:21px 21px 0 0;padding:6.5px max(13px,env(safe-area-inset-left,0px)) calc(env(safe-area-inset-bottom,0px) + 14.5px);border:1px solid var(--line);animation:up .22s ease-out}
body:not([data-view="editor"]) .panel{padding-bottom:14.5px;max-height:100%}
@keyframes up{from{transform:translateY(32.5px);opacity:0}}
.grab{width:32.5px;height:3px;border-radius:2px;background:var(--line);margin:3px auto 10px}
.panel h2{font-size:18px;margin:0 0 3px}
.panel p{margin:0 0 11px;color:var(--muted)}

#toast{position:fixed;left:50%;transform:translateX(-50%);bottom:calc(env(safe-area-inset-bottom,0px) + 113.5px);z-index:60;background:var(--fg);color:var(--bg);padding:8px 13px;border-radius:11px;font-weight:500;display:flex;gap:11px;align-items:center;box-shadow:var(--shadow);max-width:calc(100% - 26px)}
#toast button{color:var(--accent);font-weight:700;filter:brightness(.7)}

/* No pinch or double-tap zoom inside the app; iPhone zooms on focus when an input text is under 16px, so keep inputs at 16px there */
html,body{touch-action:manipulation}
@supports (-webkit-touch-callout:none){input,textarea,select{font-size:16px!important}}

#rotate{display:none}

/* Typing in a sheet: the panel moves to the top, above where the keyboard will be */
#sheet.typing .panel{bottom:auto;top:max(env(safe-area-inset-top,0px),7px);max-height:calc(100% - var(--kbd,44%) - 11px);border-radius:18px;animation:none}

/* The page frame adds its own bottom padding for the home indicator; the tab bar handles that itself */
html{padding-bottom:0!important}

/* The page frame pads the top and bottom for the status bar and home indicator; padding must not add to the height */
html{box-sizing:border-box}

/* Installed (home screen) app on iPhone: the tab bar gets more room below its buttons for the home indicator. */
@media (display-mode:standalone){
 :root{--navk:.7}
 #top{padding-top:11px}
}

/* Keyboard open and reported: the sheet is exactly the visible area, the panel sits at its top and scrolls inside */
#sheet.vv .panel{top:7px;bottom:auto;max-height:calc(100% - 14px);border-radius:18px;padding-bottom:14.5px}
.rest-main{align-items:center;text-align:center}
.rest-in{padding:0 9px}
#sheet.mid{bottom:0!important}
