/* ByBookBot 1.4.1 · phone and tablet layer. Loaded last on every page.
   Fixes found by testing every dashboard page at 360, 390 and 768 px wide. */

html{-webkit-text-size-adjust:100%;text-size-adjust:100%}
img,svg,video,canvas{max-width:100%}
.app{overflow-x:clip}
.mainc{min-width:0}

/* Long words (emails, links, IDs) must wrap instead of pushing cards off the screen */
.card,.pg>*{min-width:0}
.pg :where(.stack,.row,.split,.grid2,.grid3,.two-col,.home-grid,.fd-grid,.ps,.card-head,.savebar)>*{min-width:0}
.pg :where(p,li,dd,dt,td,th,small,strong,code,label,.hint,.callout){overflow-wrap:anywhere}

/* Installed app (home-screen): respect the notch and the home bar */
@media (display-mode:standalone){
  .topbar{padding-top:calc(14px + env(safe-area-inset-top,0px))}
  .side{padding-top:calc(20px + env(safe-area-inset-top,0px))}
}

@media (max-width:860px){
  /* iPhone zooms into any field with text under 16px; keep fields at 16px */
  input:not([type=checkbox]):not([type=radio]):not([type=range]),select,textarea{font-size:16px}
  .toolbar select,.toolbar input,.pg select,.pg textarea,.pg input:not([type=checkbox]):not([type=radio]):not([type=range]){font-size:16px}
  .pg-title{flex-wrap:wrap;gap:10px}
  .pg-title>.row,.pg-title>div:last-child{flex-wrap:wrap}
  .mainc{padding-bottom:calc(100px + env(safe-area-inset-bottom,0px))}
  /* Section tabs scroll sideways in one line */
  .tabs{flex-wrap:nowrap;overflow-x:auto;-webkit-overflow-scrolling:touch;scrollbar-width:none;margin-left:-16px;margin-right:-16px;padding:0 12px}
  .tabs::-webkit-scrollbar{display:none}
  .tabs a,.tabs button{flex:none}
  .split .tabs{flex-wrap:nowrap;overflow-x:auto;row-gap:0}
  /* Keep the round help button clear of sticky save bars and the poster action bar */
  body:has(.savebar) .helpbot{bottom:calc(140px + env(safe-area-inset-bottom,0px))}
  /* Wide tables scroll inside their card, not the whole page */
  .pg table{display:block;max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch}
  /* Help button: a round "?" that stays out of the way */
  .helpbot-btn{width:48px;height:48px;padding:0;justify-content:center;font-size:0;gap:0}
  .helpbot-btn span{font-size:20px}
  /* Save bars stick to the bottom above the tab bar */
  .savebar{position:sticky;bottom:calc(66px + env(safe-area-inset-bottom,0px));z-index:30;flex-wrap:wrap;background:var(--sheet);padding:10px;border-radius:14px;box-shadow:0 -6px 20px -12px rgba(24,32,51,.35)}
  .dialog{max-height:92dvh}
}

@media (max-width:640px){
  /* Confirm boxes become a sheet at the bottom of the screen */
  .confirm-box{position:fixed;left:12px;right:12px;top:auto;bottom:calc(76px + env(safe-area-inset-bottom,0px));width:auto;z-index:70;box-shadow:0 -10px 40px -10px rgba(24,32,51,.45)}
  /* Front desk rows: token, name and time on one line, the button below */
  .qrow{grid-template-columns:auto minmax(0,1fr) auto;row-gap:8px}
  .qrow>:nth-child(n+4){grid-column:2 / -1;justify-self:end}
  .qrow .tok.ghost{min-width:58px}
  .row{flex-wrap:wrap}
  .btn{max-width:100%}
  .card{padding-left:16px;padding-right:16px}
}

@media (max-width:380px){
  .pg{padding-left:12px;padding-right:12px}
  .tabs{margin-left:-12px;margin-right:-12px}
  .pse-head{margin-left:-12px!important;margin-right:-12px!important;padding-left:12px!important;padding-right:12px!important}
  .tabbar a{font-size:10px}
  .pg-title h1{font-size:22px}
}

/* Touch screens: comfortable tap targets */
@media (pointer:coarse){
  .btn-sm{min-height:40px}
  .seg button{min-height:40px}
}

/* Landscape phones: slimmer tab bar so content keeps its height */
@media (max-width:860px) and (max-height:500px){
  .tabbar a{min-height:46px;flex-direction:row;gap:6px}
}
