/* ERGO-v1: phone and desktop ease of use, from Apple's Designing for iOS and Designing for macOS.
   Extends MOBILE-HIG-v1 in house.css. Loaded last on every page. */

/* the tab bar stays put while pages change: cross-document view transition, the bar is its own named layer and does not animate */
@view-transition{navigation:auto}
.hb-tabbar{view-transition-name:hb-tabbar}
::view-transition-group(hb-tabbar){animation-duration:0s}
::view-transition-old(root),::view-transition-new(root){animation-duration:.12s}
@media (prefers-reduced-motion:reduce){::view-transition-group(*),::view-transition-old(*),::view-transition-new(*){animation:none !important}}

/* every iPhone: small (SE, 320-375), standard (390-402), large (430-440), and all of them on their side */
@media (max-width:374px){
  .hb-tabbar{left:8px;right:8px;gap:6px}
  .hb-tabbar-in{height:58px}
  .hb-tabbar-more{width:58px;height:58px}
  .ta-shell{padding-bottom:calc(100px + var(--hb-safe-b))}
}
@media (max-width:734px),(pointer:coarse) and (orientation:landscape) and (max-height:500px){
  .ta-body{padding-left:env(safe-area-inset-left);padding-right:env(safe-area-inset-right)}
  dialog.hb-sheet[open]{margin:auto auto 0;width:100%;max-width:none;border-radius:22px 22px 0 0;padding-bottom:env(safe-area-inset-bottom);
    max-height:calc(100dvh - var(--ergo-kb,0px) - 16px - env(safe-area-inset-top));animation:ergo-up .26s cubic-bezier(.2,.9,.3,1)}
}
@keyframes ergo-up{from{transform:translateY(36px);opacity:.5}}
@media (prefers-reduced-motion:reduce){dialog.hb-sheet[open]{animation:none !important}}
@media (pointer:coarse) and (orientation:landscape) and (max-height:500px){
  .hb-tabbar{left:max(12px,env(safe-area-inset-left));right:max(12px,env(safe-area-inset-right));bottom:calc(6px + var(--hb-safe-b))}
  .hb-tabbar-in{height:52px}
  .hb-tabbar-more{width:52px;height:52px}
  .ta-shell{padding-bottom:calc(72px + var(--hb-safe-b))}
  .ta-foot{padding-bottom:calc(64px + var(--hb-safe-b))}
  .hb-tabbar a svg,.hb-tabbar-more svg{width:22px;height:22px}
}

/* touch: 44pt targets without moving anything (hit area drawn around the control), 16px fields so iOS never zooms */
@media (pointer:coarse){
  .hb-iact,.hb-check,.hb-notif-pin{position:relative}
  .hb-iact::after,.hb-check::after,.hb-notif-pin::after,.yfx-pin::after{content:"";position:absolute;left:50%;top:50%;width:max(100%,44px);height:max(100%,44px);transform:translate(-50%,-50%)}
  .hb-filebtn,select.hb-select,.hb-task-state,.ta-more{min-height:44px}
  .ta-more{display:inline-flex;align-items:center}
  input:not([type=checkbox]):not([type=radio]):not([type=range]):not(.hb-switch),select,textarea{font-size:max(16px,1em)}
  .yfx-rs,.yfx-r2{font-size:calc(12px * var(--yf-scale,1))}
}

/* wide screens: the content column keeps a readable line length */
@media (min-width:1700px){
  #main{max-width:1320px;margin-inline:auto}
}

/* the one primary action of a page, in thumb reach */
.ergo-fab{display:none}
@media (pointer:coarse) and (max-width:734px){
  .ergo-fab{display:inline-flex;align-items:center;gap:8px;position:fixed;z-index:170;right:16px;bottom:calc(88px + var(--hb-safe-b));height:48px;padding:0 20px;border:0;border-radius:24px;
    background:var(--ta-blue,#0071e3);color:var(--hb-on-blue,#fff);font:inherit;font-size:16px;font-weight:600;box-shadow:0 10px 26px -6px rgba(0,0,0,.45);cursor:pointer;touch-action:manipulation}
  .ergo-fab[hidden]{display:none}
  html.ta-sheet-open .ergo-fab{display:none}
}
@media (pointer:coarse) and (orientation:landscape) and (max-height:500px){.ergo-fab{display:none !important}}

/* swipe a task right to finish it */
.hb-task.ergo-swiping{background-image:linear-gradient(90deg,rgba(31,157,85,.38) calc(var(--ergo-dx,0) * 1px),transparent 0)}
.hb-task.ergo-armed{background-image:linear-gradient(90deg,rgba(31,157,85,.7) calc(var(--ergo-dx,0) * 1px),transparent 0)}

/* keyboard cheat sheet (desktop) */
.ergo-keys{display:grid;grid-template-columns:auto 1fr;gap:8px 18px;margin:12px 0 0;padding:0;font-size:14px;line-height:20px}
.ergo-keys dt{display:flex;gap:4px}
.ergo-keys dd{margin:0;color:var(--hb-mute)}
.ergo-keys kbd{display:inline-grid;place-items:center;min-width:24px;height:24px;padding:0 6px;border-radius:6px;background:var(--hb-fill,rgba(127,127,127,.18));font:600 12px/1 inherit;color:var(--ta-ink)}

/* small iPhones (SE, mini): the top bar holds brand + search + controls + account + menu; the blue Store button moves to the menu so the page is never wider than the phone */
@media (max-width:379px){
  .ta-gn-pill .hb-cta{display:none}
}

/* a wide row or table scrolls inside its own box; it never makes the whole page wider than the phone (grid and flex items default to min-width:auto) */
@media (max-width:734px),(pointer:coarse) and (orientation:landscape) and (max-height:500px){
  #main :is(.hm-cols-wrap,.hb-tscroll){max-width:100%;min-width:0}
  #main :is([class^="hm-g"],[class*=" hm-g"],.hb-col,.hb-wide)>*{min-width:0}
  #main :not(.hb-tscroll)>table.hb-table{display:block;max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch}
  .hb-dsw{flex-wrap:wrap;max-width:100%}
}

@media (max-width:734px),(pointer:coarse) and (orientation:landscape) and (max-height:500px){
  .ta-tickhdr{flex-wrap:wrap;gap:8px 12px}
}

@media (pointer:coarse){
  .hb-tab{min-height:44px}
  .hb-cta,.yf-open{position:relative}
  .hb-cta::after,.yf-open::after{content:"";position:absolute;left:50%;top:50%;width:max(100%,44px);height:max(100%,44px);transform:translate(-50%,-50%)}
  .ta-crumb a{padding-block:13px;margin-block:-13px}
  select,select.hb-select,select.hb-rec-st,input.hb-input,input.hb-text,textarea.hb-text{font-size:max(16px,1em) !important}
}

@media (pointer:coarse){
  .ta-local-links a,.hb-addday{min-height:44px}
  .ta-crumb a{padding-block:14px;margin-block:-14px}
  .hb-btn--ghost{min-width:44px}
}

/* system text size on top of the hub's own zoom */
html{zoom:calc(var(--hb-zoom,1) * var(--ergo-type,1))}

/* a record beside its list (wide screens) */
@media (min-width:1100px) and (hover:hover) and (pointer:fine){
  dialog.hb-sheet.ergo-dock[open]{position:fixed;inset:var(--ins-top,96px) 20px 20px auto;margin:0;width:min(420px,32vw);height:auto;max-height:calc(100vh / var(--hb-zoom,1) - var(--ins-top,96px) - 24px);overflow:auto;z-index:150;animation:ergo-in .2s ease-out}
  html.ergo-docked .ta-shell{padding-right:min(438px,33vw);transition:padding .2s}
}
@keyframes ergo-in{from{transform:translateX(24px);opacity:0}}
@media (prefers-reduced-motion:reduce){dialog.ergo-dock{animation:none !important}html.ergo-docked .ta-shell{transition:none}}

/* right-click menu */
.ergo-menu{position:fixed;z-index:400;min-width:180px;max-width:280px;padding:6px;border-radius:12px;background:var(--hb-sheet,var(--ta-tile,#fff));color:var(--ta-ink);
  box-shadow:0 18px 50px rgba(0,0,0,.35),0 0 0 1px var(--hb-line,rgba(127,127,127,.25));display:flex;flex-direction:column}
.ergo-menu button{font:inherit;font-size:14px;line-height:20px;text-align:left;padding:7px 12px;border:0;border-radius:8px;background:none;color:inherit;cursor:default}
.ergo-menu button:hover,.ergo-menu button:focus-visible{background:var(--ta-blue,#0071e3);color:#fff;outline:none}

/* larger text leaves fewer CSS pixels: the top bar sheds what it can reach elsewhere (Store is in the menu, Control Center in the menu) */
html.ergo-big .ta-gn-pill .hb-cta{display:none}
html.ergo-xl .ta-gn-pill #hb-ccbtn{display:none}
html.ergo-big .hb-tabbar a span{font-size:12px}

/* the layout floor is ~300 CSS px (text size and zoom can push a phone there): these rows wrap or scroll inside themselves instead of widening the page */
@media (max-width:734px),(pointer:coarse) and (orientation:landscape) and (max-height:500px){
  .hb-mp-foot{flex-wrap:wrap}
  .hb-mp-foot .right{max-width:100%;flex-wrap:wrap}
  .hb-todaycard{min-width:0;max-width:100%}
  .hb-tc-grid{grid-template-columns:minmax(0,1fr)}
  .ta-hd{flex-wrap:wrap}
  .hb-st-top .hb-act{flex-wrap:wrap;max-width:100%}
  .hb-st-top .hb-act .hb-seg{max-width:100%;overflow-x:auto;scrollbar-width:none}
}

/* INSPECTOR-v1 */
.hb-ins{position:fixed;z-index:149;display:flex;flex-direction:column;overflow:hidden;color:var(--ta-ink);background:var(--hb-sheet,#0b0b0c);box-shadow:0 20px 50px -18px rgba(0,0,0,.55),inset 0 0 0 1px var(--ta-line,rgba(255,255,255,.14));border-radius:28px;font-size:14px;letter-spacing:-.1px}
.hb-ins[hidden]{display:none}
.hb-ins.is-dock{inset:var(--ins-top,96px) 20px 20px auto;width:min(380px,30vw);max-height:calc(100vh / var(--hb-zoom,1) - var(--ins-top,96px) - 20px);animation:ergo-in .2s cubic-bezier(.2,.8,.3,1)}
.hb-ins:not(.is-dock){inset:auto 8px calc(8px + env(safe-area-inset-bottom)) 8px;max-height:78vh;animation:ergo-in .22s cubic-bezier(.2,.8,.3,1)}
html[data-wp] .hb-ins{background-color:var(--lg-pane,rgba(14,14,17,.7));background-image:var(--mt-sheen);-webkit-backdrop-filter:var(--lg-filter);backdrop-filter:var(--lg-filter);box-shadow:var(--mt-rim),0 24px 56px -20px rgba(0,0,0,.6)}
.hb-ins-hd{display:flex;align-items:center;gap:12px;padding:16px 16px 12px 18px}
.hb-ins-av{flex:none;width:40px;height:40px;border-radius:50%;display:grid;place-items:center;font-weight:600;font-size:15px;color:#fff;background:hsl(var(--h,210) 45% 38%)}
.hb-ins-t{min-width:0;flex:1}.hb-ins-t b{display:block;font-size:17px;line-height:22px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.hb-ins-t small{display:block;color:var(--ta-ink-2);font-size:12.5px;line-height:17px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.hb-ins-x{flex:none;width:30px;height:30px;border-radius:50%;border:0;display:grid;place-items:center;background:var(--hb-fill,rgba(255,255,255,.1));color:var(--ta-ink-2);cursor:pointer}.hb-ins-x svg{width:14px;height:14px}
.hb-ins-body{overflow:auto;padding:2px 0 8px;flex:1;min-height:0;overscroll-behavior:contain}
.hb-ins-gp{margin:0 0 12px}
.hb-ins-gh{display:flex;justify-content:space-between;align-items:baseline;margin:6px 20px 6px;font-size:12px;font-weight:600;color:var(--ta-ink-2);letter-spacing:0}.hb-ins-gh small{font-weight:400;color:var(--ta-ink-3)}
.hb-ins-g{margin:0 14px;border-radius:18px;background:var(--hb-fill,rgba(255,255,255,.08));box-shadow:inset 0 0 0 1px rgba(255,255,255,.08);overflow:hidden}
.hb-ins-r{display:flex;align-items:center;justify-content:space-between;gap:14px;min-height:42px;padding:8px 14px}
.hb-ins-r + .hb-ins-r{border-top:1px solid var(--ta-line-2,rgba(255,255,255,.08))}
.hb-ins-r .l{color:var(--ta-ink-2);flex:none}.hb-ins-r .v,.hb-ins-r a{text-align:right;min-width:0;overflow-wrap:anywhere;font-weight:500}.hb-ins-r a{color:var(--ta-link)}
.hb-ins-long{display:block}.hb-ins-long .l{display:block;margin-bottom:4px;font-size:12px}.hb-ins-long p{margin:0;white-space:pre-wrap;line-height:1.45}
.hb-ins-list{display:flex;flex-wrap:wrap;gap:6px;justify-content:flex-end}
.hb-ins-sw{position:relative;width:38px;height:22px;border-radius:999px;background:var(--hb-off,rgba(255,255,255,.2));flex:none}.hb-ins-sw::after{content:"";position:absolute;top:2px;left:2px;width:18px;height:18px;border-radius:50%;background:#fff;box-shadow:0 1px 3px rgba(0,0,0,.3)}.hb-ins-sw.on{background:var(--ta-blue,#0071e3)}.hb-ins-sw.on::after{left:18px}
.hb-ins-meter{flex:1;height:6px;border-radius:99px;background:var(--hb-off,rgba(255,255,255,.18));overflow:hidden;margin-left:10px}.hb-ins-meter i{display:block;height:100%;border-radius:inherit;background:var(--ta-green,#30d158)}.hb-ins-r b{font-variant-numeric:tabular-nums;min-width:26px;text-align:right}
.hb-ins-ft{display:flex;gap:8px;padding:12px 16px 16px;border-top:1px solid var(--ta-line-2,rgba(255,255,255,.08))}.hb-ins-ft .hb-btn{flex:1}
tr.is-selected > td,.hb-crm-card.is-selected{background:color-mix(in srgb,var(--ta-blue,#0071e3) 22%,transparent) !important}
tr[data-id],.hb-crm-card[data-id]{cursor:pointer}
@media (prefers-reduced-motion:reduce){.hb-ins{animation:none !important}}


/* DOCK-FIT-v1: the panel as a popup when it does not fit, and rows that stack before they are crushed */
.hb-ins-scrim{position:fixed;inset:0;z-index:148;background:rgba(0,0,0,.28);-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px)}
.hb-ins-scrim[hidden]{display:none}
.hb-ins.is-pop{inset:50% auto auto 50%;transform:translate(-50%,-50%);width:min(440px,calc(100vw - 32px));max-height:min(80vh,720px);animation:ergo-pop .22s cubic-bezier(.2,.8,.3,1);z-index:151}
@keyframes ergo-pop{from{opacity:0;transform:translate(-50%,-48%) scale(.96)}}
@media (max-width:734px),(pointer:coarse){.hb-ins.is-pop{inset:auto 8px calc(8px + env(safe-area-inset-bottom)) 8px;transform:none;width:auto;max-height:78vh;animation:ergo-in .22s cubic-bezier(.2,.8,.3,1)}}
@media (prefers-reduced-motion:reduce){.hb-ins.is-pop{animation:none !important}}
html[data-main="s"] .hb-task,html[data-main="xs"] .hb-task{grid-template-columns:28px minmax(0,1fr);gap:8px 12px;padding:14px 16px}
html[data-main="s"] .hb-task > :is(.hb-task-who,.hb-due,.hb-select,.hb-task-act),html[data-main="xs"] .hb-task > :is(.hb-task-who,.hb-due,.hb-select,.hb-task-act){grid-column:2}
html[data-main="s"] .hb-task-act,html[data-main="xs"] .hb-task-act{opacity:1}
.hb-task-t{min-width:12ch;overflow-wrap:anywhere}

/* PHONE-FIX-v1 (Lucas's phone screenshots, 7 Oct): nothing may run off the right edge, and the page is not zoomable */
html{touch-action:pan-x pan-y;-webkit-text-size-adjust:100%;text-size-adjust:100%}
.hb-amt small{font-size:15px;font-weight:500;margin-left:8px;white-space:nowrap;vertical-align:baseline;letter-spacing:0}
.hb-amt,.hb-money{overflow-wrap:anywhere;max-width:100%}
@media (max-width:734px),(pointer:coarse){
  html,body{max-width:100vw;overflow-x:clip}
  .hb-tabs,.hb-seg,.hb-cc-seg{max-width:100%;overflow-x:auto;overflow-y:hidden;scrollbar-width:none;-webkit-overflow-scrolling:touch;overscroll-behavior-x:contain}
  .hb-tabs::-webkit-scrollbar,.hb-seg::-webkit-scrollbar{display:none}
  .hb-tabs .hb-tab,.hb-seg button{flex:none;white-space:nowrap}
  .hb-pal-box input{font-size:16px !important;padding:14px 16px !important}
  #hb-pal{width:calc(100vw - 16px) !important}
  .hb-pal-box{max-width:100%}
  .hb-pal-box *{min-width:0;overflow-wrap:anywhere}
  .ta-main,.ta-shell,#main{min-width:0;max-width:100%}
  img,svg,video,canvas{max-width:100%}
  table.hb-table{display:block;max-width:100%;overflow-x:auto}
}

/* the phone tab bar is opaque enough that page text never shows through it (Lucas's phone screenshots: text ran under the bar) */
.hb-tabbar-in,.hb-tabbar-more{background-color:color-mix(in srgb,var(--hb-sheet,#101012) 84%,transparent) !important;-webkit-backdrop-filter:blur(30px) saturate(170%);backdrop-filter:blur(30px) saturate(170%)}
html[data-wp][data-wp][data-wp] .hb-headblock{padding:20px 22px 22px}
.hb-zoomctl,.hb-zoomctl *{min-width:0;max-width:100%}
@media (max-width:734px){.hb-zoomctl{flex-wrap:wrap}.hb-zoomctl .hb-slider{flex:1 1 140px}}

.hb-ins-act{width:100%;border:0;background:none;color:inherit;font:inherit;text-align:left;cursor:pointer}.hb-ins-act:hover,.hb-ins-act:focus-visible{background:var(--hb-fill,rgba(255,255,255,.08));outline:none}
.hb-ins-act .v{margin-left:auto;color:var(--ta-ink-2);font-size:12.5px;white-space:nowrap}.hb-ins-act .l{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--ta-link,#0a84ff)}
.hb-ins-chev{flex:none;width:8px;height:8px;border-right:2px solid var(--ta-ink-3);border-top:2px solid var(--ta-ink-3);transform:rotate(45deg);margin-left:6px}
tr.is-selected-prof > td{background:color-mix(in srgb,var(--ta-blue,#0071e3) 22%,transparent)}

/* LOADING-v1: the veil and the Apple-style spinner (12 spokes that fade round, ticking like the system one) */
html.hb-loading .ta-main,html.hb-loading .ta-foot,html.hb-loading .ta-me,html.hb-loading .hb-here,html.hb-loading .hb-acctbtn,html.hb-loading .hb-tabbar-in,html.hb-loading .ergo-fab{visibility:hidden}
html.hb-loading .ta-main *{animation:none !important;transition:none !important}
.hb-spin{position:fixed;left:50%;top:46%;width:38px;height:38px;margin:-19px 0 0 -19px;z-index:900;color:var(--ta-ink,#fff);pointer-events:none}
.hb-spin i{position:absolute;left:50%;top:0;width:3px;height:10px;margin-left:-1.5px;border-radius:2px;background:currentColor;transform-origin:50% 19px;transform:rotate(calc(var(--i) * 30deg));opacity:.15;animation:hb-spoke 1s linear infinite;animation-delay:calc(var(--i) * .08333s - 1s)}
@keyframes hb-spoke{from{opacity:1}to{opacity:.15}}
.hb-spin-t{font:13px/1 -apple-system,BlinkMacSystemFont,'SF Pro Text',system-ui,sans-serif;position:absolute;left:50%;top:50px;transform:translateX(-50%);font-size:13px;color:var(--ta-ink-2,#aaa);white-space:nowrap}
@media (prefers-reduced-motion:reduce){.hb-spin i{animation-duration:2.4s}}
