/* PHONE layout for the gate pages (home.html, admin.html, dev.html and everything built on signin.html).
   Linked last in <head>; everything is inside max-width:768px, so desktop gets nothing.
   Pattern (same as sales2-mobile.css): top row = avatar/name + Sign out; the .pb2 pills sit in a bar along the BOTTOM;
   the 1600x900 scaled stage is switched off and the tiles flow at device width; the page scrolls.
   No new elements: .pb2 .sc .lm .sr .stp .u .k .n .s .sk only. Pairs with gate-mobile.js (the Access sheet). Home is CSS only. */
@media (max-width:768px){
  /* ================= shell pages: home / admin / dev ================= */
  html:has(body>.nav),body:has(>.nav){height:auto;overflow:visible}
  body:has(>.nav){min-height:100dvh;padding-bottom:calc(76px + env(safe-area-inset-bottom))}
  /* ---- top row: avatar + name, the developer button, Sign out ---- */
  .nav{position:relative;height:auto;gap:8px!important;padding:10px}
  .nav .sp{display:none}
  .nav .u{box-sizing:border-box;height:44px;font-size:13px}
  .nav .u.me{display:block;flex:0 1 auto;min-width:0;margin-right:auto;padding:0 14px 0 7px;line-height:42px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
  .nav .u.me .av{display:inline-grid;vertical-align:middle;margin:-2px 9px 0 0}
  .nav a.dv{width:44px;flex:none}
  .nav #so{flex:none;padding:0 14px}
  /* ---- bottom bar: the pills share the width. Home / Access on admin and dev; Home / Access (admins) / Feedback on home ---- */
  .nav{--n:2}
  .nav::after{content:"";position:fixed;left:0;right:0;bottom:0;height:calc(66px + env(safe-area-inset-bottom));z-index:3;
    background:linear-gradient(0deg,rgba(3,6,10,.96),rgba(3,6,10,.7));border-top:1px solid rgba(255,255,255,.06)}
  .nav .pb2{--w:calc((100vw - 20px - (var(--n) - 1)*6px)/var(--n));position:fixed;z-index:4;bottom:calc(10px + env(safe-area-inset-bottom));
    width:var(--w);left:calc(10px + var(--i)*(var(--w) + 6px));height:46px;padding:0 2px;font-size:12px;white-space:nowrap;
    margin:0!important;transform:none!important}                     /* the desktop dock magnifier writes margin/transform inline */
  .nav .pb2:nth-child(1){--i:0}.nav .pb2:nth-child(2){--i:1}
  /* home: one pill per app does not fit a bar, so the app CARDS are the navigation and their pills are hidden */
  .nav a.pb2{display:none}
  .nav a.pb2[href="/admin"],.nav a.pb2[href="/auth/feedback"]{display:inline-flex;--i:1}
  .nav:has(a.pb2[href="/admin"]){--n:3}
  .nav:has(a.pb2[href="/admin"]) a.pb2[href="/auth/feedback"]{--i:2}
  /* ---- the stage: no scaling, tiles in natural flow ---- */
  .stage{position:relative!important;left:auto;top:auto;z-index:1;transform:none!important;width:auto;height:auto;overflow:visible}   /* z-index: above the fixed vignette */
  .layer{position:static;display:flex;flex-direction:column;gap:10px;padding:10px}
  .layer .lm{position:relative!important;left:auto!important;top:auto!important;width:auto!important;height:auto!important;padding:14px 12px!important;gap:10px!important}
  .layer .lm:hover{transform:none}
  .layer .k{font-size:11px}.layer .s{line-height:1.6}
  .layer .stp{font-size:10px;min-width:0!important;white-space:nowrap}
  /* a tile head: the label on its own line, then the filter chips in equal columns */
  .layer>.lm:not(#pdet)>div:first-child{display:grid!important;grid-template-columns:repeat(auto-fill,minmax(96px,1fr));gap:6px!important}
  .layer>.lm:not(#pdet)>div:first-child>.k{grid-column:1/-1;margin:0 0 2px!important}
  .layer .sc{height:44px;padding:0 10px;font-size:12px;display:inline-flex;align-items:center;justify-content:center}
  /* rows wrap instead of clipping */
  .layer .sr{height:auto;min-height:44px;box-sizing:border-box;flex-wrap:wrap;gap:4px 10px;padding:8px 12px}
  .layer .sr.sk{height:44px!important}
  .layer .sr>*{min-width:0;white-space:normal!important;overflow:visible!important;overflow-wrap:anywhere}
  .layer .sr>.stp,.layer .sr>.sc{white-space:nowrap!important;flex:none}
  .layer .sr>.sj{line-height:1.5}

  /* ================= home =================
     The live carousel (eco-carousel.js) at phone size, untouched. It sizes a card as min(46% of #car's width, 83% of its height),
     so #car is made ~2.2 screens wide and centred: ONE card fills the screen and its neighbours wait just off the edges.
     (body>#car: the page restyles #car in a <style> inside <body>, after this file.)
     Swipe, tap-to-open, Prev/Next and reduced motion are the carousel's own (its canvas already has touch-action:pan-y). */
  html:has(#car){overflow-x:hidden}body:has(>#car){position:relative;overflow-x:clip}   /* #car is wider than the screen on purpose; body clips it so the page never pans sideways */
  body>#car{--cw:min(100vw - 40px,420px);--W:calc(var(--cw)/.46);position:absolute;z-index:1;top:24px;bottom:auto;right:auto;
    left:calc(50vw - var(--W)/2);width:var(--W);height:calc(var(--cw)*1.21)}
  #car .cc-ctl,#car .cc-copy{left:calc(var(--W)/2 - 50vw + 16px);right:auto;width:calc(100vw - 32px);max-width:none;bottom:auto}
  /* under the card: the count and Prev / Next, then the app's name and Open */
  #car .cc-ctl{top:calc(var(--cw)*.87 + 2px);flex-direction:row;align-items:center;justify-content:space-between;min-height:44px}
  #car .cc-copy{top:calc(var(--cw)*.87 + 58px);gap:8px;padding-bottom:calc(92px + env(safe-area-inset-bottom))}
  #car .cc-copy .n{font-size:32px;line-height:1.05;overflow-wrap:anywhere}
  #car .cc-copy .s{line-height:1.4}
  #car .sc{height:44px;padding:0 20px;font-size:12px}
  #car .cc-copy .sc{margin-top:6px}
  #car:has(#ccb[style*="none"]) #ccn{display:none}                      /* one card or none: no count, no Prev / Next, nothing to swipe to */

  /* ================= admin (Access) ================= */
  /* list row: name + role / email / apps + last seen */
  #plist .sr>.sn{order:1;flex:1 1 0}
  #plist .sr>.stp{order:2}
  #plist .sr>.sj:nth-child(2){order:3;flex:1 1 100%;width:auto!important;font-size:12px}
  #plist .sr>.sj:nth-child(4){order:4;flex:1 1 0;width:auto!important}
  #plist .sr>.sd{order:5;width:auto!important;flex:none}
  body:not(.m-det) #plist .sr{border-color:rgba(255,255,255,.06)!important}   /* no "selected" row while the list is the screen */
  /* activity row: age + what happened, the detail under it */
  #alog .sr{min-height:34px}
  #alog .sr>.sj:first-child{flex:none;min-width:26px;width:auto!important}
  #alog .sr>.sn{flex:1 1 0}
  #alog .sr>.sj:last-child{flex:1 1 100%;max-width:none!important;padding-left:36px}
  #alog .sr>.sj:last-child:empty{display:none}
  /* a tap on a person opens the editor as a sheet (body.m-det, set by gate-mobile.js) with a back button */
  #mback{display:none;align-self:flex-start;padding:0 16px}
  body:not(.m-det) #pdet{display:none}
  body.m-det .layer>.lm:not(#pdet){display:none}
  body.m-det #mback{display:inline-flex}
  #pdet{gap:12px!important}
  #pdet>div:first-child{flex-wrap:wrap;align-items:center!important;gap:8px 12px!important}
  #pdet .n{font-size:26px!important;line-height:1.1!important;overflow-wrap:anywhere;min-width:0}
  #pdet>.s{overflow-wrap:anywhere}
  #pdet>div:has(>[data-role]),#pdet>div:has(>[data-app]){display:grid!important;grid-template-columns:repeat(auto-fill,minmax(96px,1fr))}
  #pdet .sr>.sn{flex:1 1 0}
  #pdet .sr:has(>[data-rep])>.sn{flex:1 1 100%}
  #pdet .sr:has(>[data-rep])>.sj{flex:1 1 0}
  #pdet>div:last-child{flex-direction:column;margin-top:4px!important}
  #pdet>div:last-child>span{display:none}

  /* ================= developer settings ================= */
  .layer>.lm:has(#tlist),.layer>.lm:has(#hlist){max-height:70dvh}      /* long lists scroll inside their tile so the next tile stays reachable */
  /* request: kind + who / the text / Done */
  #tlist .sr{align-items:center!important}
  #tlist .sr>.stp{order:1;margin:0!important}
  #tlist .sr>.sj{order:2;flex:1 1 0;max-width:none!important;margin:0!important;text-align:right}
  #tlist .sr>.sn{order:3;flex:1 1 100%;white-space:pre-wrap!important}
  #tlist .sr>.sc{order:4;margin-left:auto;padding:0 18px}
  /* signed in: name + age / address / place + device */
  #hlist .sr>.sn:nth-child(1){order:1;flex:1 1 0!important}
  #hlist .sr>.sd{order:2;width:auto!important;flex:none}
  #hlist .sr>.sn:nth-child(2){order:3;flex:1 1 100%!important}
  #hlist .sr>.sj:nth-child(3){order:4;flex:0 1 auto!important}
  #hlist .sr>.sj:nth-child(4){order:5;flex:1 1 0!important;text-align:right}
  /* traffic: who + address + status / request / place + age */
  #flist .sr>.stp{order:1}
  #flist .sr>.sn:nth-child(2){order:2;flex:1 1 0!important}
  #flist .sr>.sd{order:3;width:auto!important;flex:none}
  #flist .sr>.sn:nth-child(5){order:4;flex:1 1 100%!important}
  #flist .sr>.sj:nth-child(3){order:5;flex:1 1 0!important}
  #flist .sr>.sj:nth-child(1){order:6;flex:none!important}

  /* ================= sign-in shell (sign in, waiting, notices, feedback) ================= */
  .page{grid-template-columns:1fr;grid-template-rows:clamp(120px,24dvh,200px) auto;gap:10px;padding:10px;align-content:start}
  .side{padding:20px 14px 28px;align-items:flex-start}
  .box{max-width:420px}
  .box h1{font-size:30px;line-height:1.05}
  .box .or{margin:22px 0;overflow-wrap:anywhere;text-align:center}
  .box .foot{margin-top:22px}
  .box .gg{height:48px}
  /* feedback: no picture, so the box and both Send buttons stay above the keyboard; 16px stops iOS zooming on focus */
  .page:has(#fbt){grid-template-rows:auto}
  .page:has(#fbt) .stack{display:none}
  .page:has(#fbt) .side{padding-top:14px}
  #fbt{font-size:16px!important;height:128px!important}
}

