/* App layout for each kind of screen. Loaded after styles.css, so it decides where the section menu goes:
   phone (under 700px): compact top bar and a bottom tab bar (first four sections, the rest under More)
   tablet (700–1099px): an icon rail down the left
   laptop (1100–1499px): a sidebar with icons and names
   wide (1500px and up): the same sidebar, with room for the content to spread out
   Printing and the Help page are unaffected: the Help page has no section menu. */
@media screen{
  :root{--hdr:60px;--rail:0px;--bar:0px}
  html{-webkit-tap-highlight-color:transparent}
  body{min-height:100dvh}

  /* Top bar: one line, full width, stays in place. */
  header.top{position:sticky;top:0;z-index:12;padding-top:env(safe-area-inset-top,0px);border-bottom:1px solid var(--line)}
  header.top .top-row{min-height:var(--hdr);flex-wrap:nowrap;padding:8px max(16px,env(safe-area-inset-right,0px)) 8px max(16px,env(safe-area-inset-left,0px));gap:10px}
  header.top .brand{min-width:0}
  header.top .logo{height:38px}
  header.top .role{margin-left:auto}
  header.top .role:not([hidden])~#help{margin-left:0}
  header.top #help{margin-left:auto}

  /* Section menu buttons: icon and name. */
  nav.tabs{margin:0;gap:4px;scrollbar-width:none;z-index:11}
  nav.tabs .tab{border:0;background:none;cursor:pointer;color:var(--muted);font-weight:700;display:flex;align-items:center;gap:10px;padding:10px 12px;border-radius:12px;text-align:left;white-space:nowrap;position:relative;min-height:44px}
  nav.tabs .tab:hover{color:var(--ink);background:color-mix(in srgb,var(--sunk) 70%,transparent)}
  nav.tabs .tab[aria-current="page"],nav.tabs .tab.more.on{color:var(--ink);background:var(--accent-soft)}
  nav.tabs .tab[aria-current="page"] .ti svg,nav.tabs .tab.more.on .ti svg{stroke:var(--dim)}
  .tab .ti{position:relative;display:grid;place-items:center;flex:none}
  .tab .ti svg{width:22px;height:22px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
  .tab .count{position:absolute;top:-6px;right:-10px;min-width:18px;height:18px;padding:0 5px;font-size:.66rem;line-height:18px;border-radius:999px}
  .tab .count.dot{min-width:9px;width:9px;height:9px;padding:0;top:-2px;right:-3px}
  nav.tabs .tab.more{display:none}
  .tabname-short{display:none}

  main.wrap{padding-bottom:calc(56px + var(--bar));margin-left:calc(var(--rail) + max(0px,(100% - var(--rail) - 1180px)/2));margin-right:auto;max-width:1180px}
  .sheet{z-index:31}.sheet-back{z-index:30}
  .toast{z-index:40;bottom:calc(16px + var(--bar) + env(safe-area-inset-bottom,0px))}
  #more-host{display:contents}
}

/* ---------- phone ---------- */
@media screen and (max-width:699px){
  :root{--hdr:56px;--bar:64px}
  header.top .logo{height:32px}
  header.top .brand>span{display:none}
  header.top .btn.small{padding:6px 11px}
  header.top .role button{padding:6px 9px;font-size:.68rem}
  nav.tabs{position:fixed;left:0;right:0;bottom:0;display:grid;grid-auto-flow:column;grid-auto-columns:minmax(0,1fr);gap:0;
    padding:4px max(6px,env(safe-area-inset-right,0px)) calc(4px + env(safe-area-inset-bottom,0px)) max(6px,env(safe-area-inset-left,0px));
    background:color-mix(in srgb,var(--surface) 92%,transparent);-webkit-backdrop-filter:blur(14px);backdrop-filter:blur(14px);border-top:1px solid var(--line);overflow:visible}
  nav.tabs .tab{flex-direction:column;gap:3px;padding:7px 2px 6px;border-radius:12px;font-size:.66rem;justify-content:center;min-height:56px;text-align:center}
  nav.tabs .tab .tl{max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
  nav.tabs .tabname-long{display:none}nav.tabs .tabname-short{display:inline}
  nav.tabs .tab.extra{display:none}
  nav.tabs .tab.more{display:flex}
  nav.tabs .tab[aria-current="page"],nav.tabs .tab.more.on{background:none;color:var(--dim)}
  nav.tabs .tab[aria-current="page"] .ti,nav.tabs .tab.more.on .ti{background:var(--accent-soft);border-radius:999px;padding:2px 14px}
  main.wrap{padding-top:16px}
  .more-back{position:fixed;inset:0;background:rgba(10,16,17,.35);z-index:13}
  .more-panel{position:fixed;left:8px;right:8px;bottom:calc(var(--bar) + 8px + env(safe-area-inset-bottom,0px));z-index:14;background:var(--surface);border:1px solid var(--line);border-radius:18px;box-shadow:var(--shadow);padding:8px;display:grid;grid-template-columns:1fr 1fr;gap:4px}
  .more-panel .tab{border:0;background:none;display:flex;align-items:center;gap:10px;padding:12px;border-radius:12px;font-weight:700;color:var(--ink);cursor:pointer;min-height:48px}
  .more-panel .tab[aria-current="page"]{background:var(--accent-soft)}
  .sheet{width:100%;border-radius:0}
}

/* ---------- tablet: icon rail ---------- */
@media screen and (min-width:700px) and (max-width:1099px){
  :root{--rail:88px}
  nav.tabs{position:fixed;top:calc(var(--hdr) + 1px + env(safe-area-inset-top,0px));bottom:0;left:0;width:var(--rail);flex-direction:column;align-items:stretch;padding:10px 8px calc(10px + env(safe-area-inset-bottom,0px)) max(8px,env(safe-area-inset-left,0px));overflow-y:auto;border-right:1px solid var(--line);background:var(--surface)}
  nav.tabs .tab{flex-direction:column;gap:4px;padding:9px 4px;font-size:.66rem;text-align:center;white-space:normal;line-height:1.15}
  main.wrap{padding-left:24px;padding-right:24px}
}

/* ---------- laptop and wide: sidebar ---------- */
@media screen and (min-width:1100px){
  :root{--rail:232px;--hdr:64px}
  nav.tabs{position:fixed;top:calc(var(--hdr) + 1px + env(safe-area-inset-top,0px));bottom:0;left:0;width:var(--rail);flex-direction:column;align-items:stretch;padding:16px 12px;overflow-y:auto;border-right:1px solid var(--line);background:color-mix(in srgb,var(--surface) 70%,transparent)}
  nav.tabs .tab{font-size:.95rem}
  .tab .count{position:static;margin-left:auto}
  nav.tabs .tab .tl{flex:1}
  nav.tabs .tab{justify-content:flex-start}
  main.wrap{padding-left:32px;padding-right:32px;padding-top:24px}
}
@media screen and (min-width:1500px){
  :root{--rail:248px}
  main.wrap{max-width:1560px;margin-left:calc(var(--rail) + max(0px,(100% - var(--rail) - 1560px)/2))}
  .cards{grid-template-columns:repeat(auto-fill,minmax(340px,1fr))}
}
/* The sidebar's count badges sit at the end of the row, so move the count out of the icon there. */
@media screen and (min-width:1100px){nav.tabs .tab .ti .count{position:absolute;top:-6px;right:-10px;margin:0}}
/* Before sign-in there are no sections, so no menu and no space kept for one. */
@media screen{nav.tabs:empty{display:none}body:has(nav.tabs:empty){--rail:0px;--bar:0px}}
