/* Touch sizing and viewport behavior, without changing the established visual identity. */
@media (pointer:coarse){
  button,.btn,summary,[role=button]{min-height:44px;min-width:44px}
  .btn.sm,#quick .lrow .btn.lr-b,.toast .btn,.cw-react,.edx-chip,.mapbox .map-loc,.mapbox .leaflet-bar a{min-height:44px;min-width:44px}
  .mapbox .leaflet-bar a{width:44px;height:44px;line-height:44px}
  input:not([type=checkbox]):not([type=radio]),select,.seg span{min-height:44px}
  .cal{grid-template-columns:repeat(7,minmax(44px,1fr));gap:2px;overflow-x:auto}
  .strip,.lcal .strip{grid-template-columns:repeat(7,minmax(44px,1fr));gap:2px;overflow-x:auto}
  .strip .c{min-width:44px;min-height:44px}
  /* The Log calendar can't scroll sideways (a swipe changes the month), so its days get their 44px from the gap instead: on a
     390px phone the 5px gap left them 42.7px wide. The weekday letters share the gap to stay over their columns. */
  #today .lcal .strip,#today .lcal-h{column-gap:clamp(2px,calc((100% - 308px) / 6),calc(5px - 2px * var(--log-s,0)))}
  .who{display:inline-flex;align-items:center;min-height:44px;min-width:44px}
  .nav button,.ls-x{width:44px;height:44px;flex-shrink:0}
}
.lcal,.lcal-h{touch-action:pan-x pinch-zoom}
.vs-feed{touch-action:pan-y pinch-zoom}
.vs-cl{overscroll-behavior:contain}
.safety-acts{display:flex;gap:8px;flex-wrap:wrap}
.vs-c .safety-acts{flex-direction:column;gap:4px}
.vs-ph{touch-action:pan-x pinch-zoom;cursor:grab}
.vs-ph::before{content:"";position:absolute;top:5px;left:calc(50% - 18px);width:36px;height:4px;border-radius:4px;background:var(--ink2);opacity:.4}
body:has(dialog[open]){overflow:hidden}
@media (max-width:700px),(any-pointer:coarse) and (min-height:600px) and (max-width:1400px){
  .sheet,#dayview{max-height:calc(var(--visible-height,100dvh) - 16px);overscroll-behavior:none}  /* no bounce at its top: a pull down past it moves the sheet instead (js/ui/sheet-drag.js) */
  .sheet{margin-bottom:var(--keyboard-inset,0px)}
  #vidsheet{height:var(--visible-height,100dvh);bottom:auto}
  /* Keep the workout review compact and its dismissal within reach. */
  #session-sheet{width:100%;max-height:calc(var(--visible-height,100dvh) - env(safe-area-inset-top,0px) - 12px);padding:12px 16px calc(20px + env(safe-area-inset-bottom,0px));scroll-padding-top:88px}
  #session-sheet .sheet-head{position:sticky;top:-12px;z-index:1;margin:-1px -16px 0;padding:12px 16px;border-bottom:1px solid var(--line)}
  #session-sheet .sheet-head>div{min-width:0}
  #session-sheet .sheet-head .ib{flex:none;min-width:44px;min-height:44px}
  #session-when{margin:0 0 2px;font-size:.75rem}
  #session-heading{font-size:1.5rem;line-height:1.15}
  #session-titleform{margin:12px 0;gap:8px}
  #session-titleform input{font-size:16px;min-height:44px}
  #session-titleform .btn{min-height:44px;padding-inline:12px}
  #session-sheet .session-card{padding:8px 0}
  #session-sheet .session-card h3{margin-bottom:10px}
  #session-sheet .session-stats b{font-size:1.3rem;font-variant-numeric:tabular-nums}
  #session-sheet .session-map{margin-top:12px;padding:10px}
  #session-sheet .session-map .bodymap{max-width:150px;gap:10px}
  #session-sheet .session-lifts>li>div{align-items:flex-start}
  #session-sheet .session-lifts b{flex:1 1 160px;min-width:0}
  #session-sheet .session-lifts .num{white-space:nowrap}
}
@media(max-width:380px){
  #session-titleform{flex-direction:column;align-items:stretch}
  #session-titleform .btn{width:100%}
}
@media(prefers-reduced-motion:reduce){
  .vs-feed{scroll-behavior:auto}
  .pull{transition:none;animation:none}
}
/* Seven 44px day targets still fit a 320px phone; keep the whole month visible. */
@media(pointer:coarse) and (max-width:380px){
  #month{padding-inline:0;margin-inline:-14px}
  #month>:not(.cal){margin-inline:16px}
  #month .cal{gap:1px}
  #statsheet>#month{margin-inline:-17px}  /* the sheet's padding is wider than the page's: seven 44px days need the full width */
}

#history-notice{max-width:1200px;margin:12px auto;flex-wrap:wrap}

/* Tablets: the app layout, scaled to the screen so it fills it. Type follows the short side, so turning the screen keeps the size. */
@media (any-pointer:coarse) and (min-width:701px) and (min-height:600px) and (max-width:1400px){
  html{font-size:calc(clamp(17px,2.2vmin,21px) * var(--ts,1))}
  body{font-size:1rem}
  .wrap{max-width:none}
  svg text{font-size:.75rem}
  .tabbar{left:50%;right:auto;width:min(560px,calc(100vw - 32px));transform:translateX(-50%)}
  /* Installed iOS moves the bar with the visible viewport (css/finish.css); keep the centring too, or the bar sits half off an iPad. */
  .ios-pwa .tabbar{transform:translate(-50%,var(--viewport-shift,0px))}
  .sheet{width:min(600px,100%);margin:auto auto 0}
  .stats{grid-template-columns:repeat(auto-fit,minmax(8rem,1fr))}
  #weight{grid-column:1/-1}
  html:not(.compact) #quick{padding-block:0}
  /* Log: the day cells take the height in step with the number of weeks in the month, the plates what's left. */
  #today{--rows:5}
  #today:has(.lcal .strip:nth-child(6)){--rows:6}
  #today .lcal .strip .c{min-height:clamp(44px,calc(var(--fill-h,0px) * .36 / var(--rows)),120px)}
  #quick .lp{height:calc((7rem - var(--l) * 1rem) * (1 - .45 * var(--log-s,0)))}
  #quick .lbar b{font-size:calc(3rem - .6rem * var(--log-s,0))}
  /* Friends: the podium sits in the middle of the board, not at its top. */
  #cmp-board .cmp-lb{flex:1;display:flex;flex-direction:column}
  #cmp-board .cmp-lb>:is(:first-child,:last-child){margin-bottom:auto}
  @media (orientation:portrait){
    main{grid-template-columns:minmax(0,1fr)}
  }
  @media (orientation:landscape){
    main:has(>#quick:not([hidden])){grid-template-rows:1fr}
    /* The month folded to one week: the week runs across the top, the check-in fills the rest. */
    main:has(>#quick:not([hidden]):not(.cal-big)){grid-template-columns:minmax(0,1fr);grid-template-rows:auto 1fr}
    #today .lcal .strip .c{min-height:clamp(44px,calc((var(--fill-h,0px) - 13rem) / var(--rows)),120px)}
    @media(max-height:800px){#quick:not(.cal-big) .lp{height:calc((5.5rem - var(--l) * .75rem) * (1 - .45 * var(--log-s,0)))}}
  }
}
