/* Short phones keep Kilo and the check-in visible; the speech bubble already carries the week's day count. */
@media(max-height:740px) and (orientation:portrait){#quick.tight .lbar{display:none}#today .lhead{row-gap:4px}}
/* iPhone layout: 402pt wide, Dynamic Island, home indicator. Loaded last to override the components. */
/* iPhone: 402pt wide, Dynamic Island on top, home indicator below */
@media (max-width:700px),(any-pointer:coarse) and (min-height:600px) and (max-width:1400px){
  /* No scroll bar down the right edge; the page still scrolls */
  html,body{scrollbar-width:none}
  html::-webkit-scrollbar,body::-webkit-scrollbar{display:none;width:0;height:0}
  body{font-size:calc(16px * var(--ts,1));padding-block:12px 72px;min-height:calc(100lvh + 1px)} /* every page can scroll: installed iOS opens with a short window and only fixes it on a scroll (js/main.js) */
  h1{font-size:2rem}
  h2{font-size:1.35rem}
  main{gap:12px}
  .card{padding:14px}
  .stats{grid-template-columns:repeat(2,1fr);gap:14px 12px}
  .btn{min-height:48px;font-size:1rem}
  .btn.sm{min-height:44px;padding:8px 14px}
  input[type=number],input[type=date],input[type=time],input[type=text],input[type=email],input[type=password],select{min-height:48px}
  .exh{display:none}
  .exr{grid-template-columns:64px minmax(0,1fr) auto;align-items:end;border-top:1px solid var(--line);padding-top:8px}
  .exr .en{grid-column:1/-1}
  .er.skr{grid-template-columns:minmax(0,1fr) auto;border-top:1px solid var(--line);padding-top:8px}
  .skr .en{grid-column:1/-1}
  .skr .sd{grid-row:3;grid-column:1/-1}
  .skr .eb{grid-row:2;grid-column:2}
  .exr .ml{display:block}
  .exr label input{margin-top:4px}
  .ib{width:44px;height:44px}
  .pbar .btn.sm{min-height:48px}
  .seg span{min-height:48px;padding:12px 6px}
  form .grid.three{grid-template-columns:repeat(3,minmax(0,1fr));gap:8px}
  form .grid.three label{font-size:.66rem;letter-spacing:.03em}
  form .grid.three input{padding-inline:8px}
  .nav button{width:44px;height:44px}
  .nav .m{min-width:8ch;font-size:1.15rem}
  .tabs button{min-height:44px;padding:6px 14px}
  .strip{gap:5px}
  .strip .c{min-height:62px}
  .cal .d{aspect-ratio:1/1}
  details.card>summary{min-height:44px}
  .list .r{padding:10px 0}
  svg text{font-size:12px}
  .pr{display:grid;grid-template-columns:1fr auto;column-gap:10px;align-items:center}
  .pr>*{grid-column:1}
  .pr .n{grid-column:1/-1}
  .pr .big{font-size:2.1rem}
  .pr .sp{grid-column:2;grid-row:2/5;margin:0}
  .pr .goal,.pr .pr-sh{grid-column:1/-1}
  .tabbar{display:grid;gap:0;margin:0;border-bottom:0;grid-template-columns:repeat(var(--nav-n,4),1fr);position:fixed;left:0;right:0;bottom:0;z-index:20;background:var(--brand-chrome);border-top:1px solid var(--line);padding:4px max(8px,env(safe-area-inset-right,0px)) max(6px,calc(env(safe-area-inset-bottom,0px) - 14px)) max(8px,env(safe-area-inset-left,0px))}
  .tabbar button{background:none;border:0;border-bottom:0;margin:0;padding:0;min-height:48px;font-weight:700;font-size:.68rem;letter-spacing:.06em;text-transform:uppercase;color:var(--ink2);display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px}
  .tabbar button:active,.tabbar button[aria-current=page]{color:var(--mark);border-bottom:0}
  .tabbar>button:not(.pin),.tabbar>a{display:none}
  .tabbar>[data-page=map]{position:relative}
  .tabbar .nav-n{position:absolute;top:2px;left:calc(50% + 5px);box-shadow:0 0 0 2px var(--surface)}
  .tabbar>.more.pin{display:flex}
  .moremenu{display:grid;position:fixed;right:max(8px,env(safe-area-inset-right,0px));bottom:calc(62px + max(6px,calc(env(safe-area-inset-bottom,0px) - 14px)));z-index:30;min-width:200px;background:var(--surface);border:1px solid var(--line);border-radius:10px;padding:6px;box-shadow:0 8px 24px var(--shadow-c)}
  .moremenu[hidden],.moremenu [hidden]{display:none}
  .moremenu button,.moremenu a{text-decoration:none;display:flex;align-items:center;gap:12px;background:none;border:0;border-radius:6px;min-height:48px;padding:0 14px;font-weight:700;font-size:1rem;color:var(--ink);text-align:left}
  .moremenu button[aria-current=page]{background:var(--surface2);color:var(--mark)}
  body.kb .moremenu{display:none}
  /* Open More menu: dim everything behind it so the menu is the only thing in front. Tapping the dim closes it. */
  body.menuopen::after{content:"";position:fixed;inset:0;z-index:25;background:color-mix(in srgb,#06081c 55%,transparent);animation:dim-in .18s ease both}
  @keyframes dim-in{from{opacity:0}}

  /* Color themes scroll sideways with the third card cut off at the edge, so it's clear there are more */
  .themes{display:flex;gap:10px;overflow-x:auto;scroll-snap-type:x mandatory;scrollbar-width:none;margin-inline:-16px;padding:2px 16px;scroll-padding-inline:16px}
  .themes::-webkit-scrollbar{display:none}
  .theme{flex:0 0 40%;scroll-snap-align:start}
  html.compact .themes{margin-inline:-12px;padding-inline:12px;scroll-padding-inline:12px}
  body.kb .tabbar{display:none}
  html:not(.log-fit) body[data-page=log]{padding-bottom:calc(104px + env(safe-area-inset-bottom,0px))}

  /* Upright phones and tablets either way up: the Cardio card fills the screen, the day card takes the spare room and the speed key sits at the bottom. */
  @media (orientation:portrait),(min-width:701px){
    #running.fill{min-height:var(--fill-h,auto);display:flex;flex-direction:column}
    #running.fill .rday{flex:1;display:flex;flex-direction:column;padding:18px}
    #running.fill .rd-main{margin-block:auto;padding-block:8px}
    #running.fill .rday .rd-t{font-size:1.9rem}
    #running.fill .rday.one .rd-t{font-size:2.6rem}
    #running.fill .rday .rd-d{font-size:1.1rem;margin-top:8px}
    #running.fill .wsd{min-height:76px;justify-content:center}
    #running.fill .rn-speeds{margin-top:auto}
    #running.fill .wlegend{margin-bottom:16px}
    /* Log page: the day card and the check-in fill the screen down to the tab bar. A tall screen gives the spare room to the
       plates; on a shorter one --log-s (0 to 1, from fitLog in js/pages/log.js) eases everything down until it all fits. */
    main:has(>#quick:not([hidden])){min-height:var(--fill-h,auto);grid-template-rows:auto 1fr}
    /* A fitted Log is the full screen plus one pixel: installed iOS opens with the window short by the status bar until
       the page scrolls (js/main.js), and with no scroll room Log alone would keep the short window and a raised tab bar.
       100lvh, not the visible height, so that pixel exists while short. On phones only the bottom safe area is :root
       padding (css/base.css; the top one is body padding, below). */
    html.log-fit body[data-page=log]{min-height:calc(100lvh + 1px - env(safe-area-inset-bottom,0px));padding-bottom:0}
    main:has(>#quick:not([hidden])){gap:calc(12px - 4px * var(--log-s,0))}
    #quick{display:flex;flex-direction:column}
    #quick-in{flex:1;display:flex;flex-direction:column}
    #quick .lh{flex:1;gap:calc(14px - 4px * var(--log-s,0));padding-block:calc(14px - 4px * var(--log-s,0))}
    #quick .lh-go{gap:calc(12px - 4px * var(--log-s,0))}  /* at least 8px between touch targets */
    #quick .lbar{flex:1;min-height:calc(84px - 40px * var(--log-s,0))}
    #quick .lbar b{font-size:calc(2.1rem - .6rem * var(--log-s,0))}
    #quick .lp{height:calc((76px - var(--l) * 14px) * (1 - .45 * var(--log-s,0)))}
    #quick .lh-o b:not(.long){font-size:calc(1.9rem - .3rem * var(--log-s,0))}
    #quick.cal-big.tight .lh-o b:not(.long){font-size:calc(1.5rem - .1rem * var(--log-s,0))}
    #quick .lts{margin-top:calc(12px - 4px * var(--log-s,0))}
    #quick .lt{padding-block:calc(10px - 4px * var(--log-s,0))}
    html:not(.compact) #quick .btn.hero{min-height:calc(72px - 20px * var(--log-s,0))}
    html:not(.compact) :is(#today,#quick){padding-block:calc(16px - 6px * var(--log-s,0))}
    #today .lhead h1{font-size:calc(1.65rem - .15rem * var(--log-s,0))}
    #today .lkilo-b>.lkilo{width:calc(104px - 16px * var(--log-s,0));height:calc(104px - 16px * var(--log-s,0))}
    #today .lcal-bar{margin-top:calc(14px - 6px * var(--log-s,0))}
    #today .lcal-h{margin-top:calc(10px - 6px * var(--log-s,0))}
    #today :is(.lcal-g,.lcal .strip){gap:calc(5px - 2px * var(--log-s,0))}
    /* Leaderboard: under the profile header and its tabs, the board reaches the tab bar, with Invite on its bottom edge. */
    main:has(>#cmp-board:not(.off):not(.lb-out):not([hidden])){min-height:var(--fill-h,auto);grid-template-rows:repeat(3,auto) 1fr}  /* header, stats, tabs, then the board */
    #cmp-board:not(.off):not(.lb-out){display:flex;flex-direction:column}  /* not on Nearby: the id would beat .card.off */
    #cmp-board>.cmp-more{margin-top:auto}
    /* Lifts: under the header, tabs and total, the lifts card fills to the tab bar; Post a PR and PR history sit at the bottom. */
    main:has(>#prlifts:not(.off):not([hidden])){min-height:var(--fill-h,auto);grid-template-rows:repeat(4,auto) 1fr}  /* header, stats, tabs, total, then the lifts */
    #prlifts:not(.off)>.pb-card{flex:1;display:flex;flex-direction:column}
    #prlifts:not(.off)>.pb-card>.pb-row{flex:1}
    /* Stats: under the title, the tiles reach the tab bar. */
    main:has(>#stiles:not([hidden])){min-height:var(--fill-h,auto);grid-template-rows:auto 1fr}
    /* Friends: under Back and the title, the card reaches the tab bar however few friends there are. */
    body[data-page=friends] main{min-height:var(--fill-h,auto);grid-template-rows:1fr}
    body[data-page=friends] #cmp-follow>.fr-card{flex:1}
    /* Activity: the same, its caught-up card reaching the tab bar with Kilo in the middle. */
    body[data-page=notifs] main:has(>#notifs:not(.off)){min-height:var(--fill-h,auto);grid-template-rows:1fr}
    body[data-page=notifs] #notifs>.card:last-child{flex:1;display:flex;flex-direction:column;justify-content:center}
    /* Workout page: its cards fill the screen down to the tab bar, the exercises card taking the spare room. */
    #workout.fill{min-height:var(--fill-h,auto);display:flex;flex-direction:column;gap:12px}
    #workout.fill .wocard{flex:1}
  }

  /* App top bar: compact, pinned under the status bar, full bleed */
  :root{padding-top:0}
  body{padding-top:0}
  :is(body,.peek)[data-page]{padding-top:calc(14px + env(safe-area-inset-top,0px))}  /* no shared header bar, so every page clears the notch the same way */
  /* Settings and Customize: with no header the jump bar pins to the very top, so it covers the notch itself and its chips rest
     14px under it, where Profile's content starts. */
  :is(body,.peek):is([data-page=settings],[data-page=customize]) .czjump{top:0;margin-top:calc(-14px - env(safe-area-inset-top,0px));padding-top:calc(14px + env(safe-area-inset-top,0px))}
  html{scroll-padding-top:114px}
  .top{position:sticky;top:0;z-index:15;flex-wrap:wrap;row-gap:8px;align-items:center;margin:0 calc(-1 * max(16px,env(safe-area-inset-left,0px))) 12px;padding:calc(14px + env(safe-area-inset-top,0px)) max(16px,env(safe-area-inset-right,0px)) 10px max(16px,env(safe-area-inset-left,0px));background:color-mix(in srgb,var(--brand-chrome) 90%,transparent);-webkit-backdrop-filter:blur(14px);backdrop-filter:blur(14px);border-bottom:1px solid var(--line)}
  .sync{font-size:.75rem}
  .brand{text-align:center}
  .tabbar{background:color-mix(in srgb,var(--brand-chrome) 90%,transparent);-webkit-backdrop-filter:blur(14px);backdrop-filter:blur(14px)}

  /* Rounder, app-like surfaces */
  .card{border-radius:12px;padding:16px}
  .btn,.banner,.club,.pr,.plan,.kneedrop,.ib,.empty,input[type=number],input[type=date],input[type=time],input[type=text],input[type=email],input[type=password],select{border-radius:10px}
  button:not(:disabled):active{opacity:.7}

  /* Button rows fill the width evenly instead of wrapping raggedly */
  .actions .btn,.rd-act .btn,.pbar .btn{flex:1 1 0;min-width:max-content}
  .actions .saved{flex:1 1 100%}
  .pbar .grow{flex:1 1 100%}
  .banner .btn{width:100%;border-color:var(--ink2)}
  .rd-act .btn.sm,.pbar .btn.sm{min-height:48px}
  .card-head{margin-bottom:14px}
}
