/* ═══ App shell: top bar, bottom tab bar, sign-in ════════════════
   Still mobile-first. The desktop sidebar arrives in phase 3, generated
   from the same NAV array that feeds this tab bar.
   ═══════════════════════════════════════════════════════════════ */

#app{min-height:100%}
.app{display:flex;align-items:flex-start;min-height:100vh}
.app-main{flex:1;min-width:0;display:flex;flex-direction:column}

/* ── desktop sidebar ───────────────────────────────────────
   Rendered from the same NAV array as the bottom tab bar and the More
   screen — see js/nav.js. */
.sidebar{width:var(--sidebar-w);flex:none;align-self:stretch;background:var(--surface-1);
  border-right:1px solid var(--border);padding:14px 12px;position:sticky;top:0;
  height:100vh;overflow-y:auto;display:flex;flex-direction:column;gap:1px;z-index:60}
.sb-brand{display:flex;align-items:center;gap:10px;padding:4px 8px 14px}
.sb-mark{width:30px;height:30px;border-radius:8px;overflow:hidden;flex:none;display:block}
.sb-mark img{width:100%;height:100%;display:block;border-radius:inherit}
.sb-brand .nm{font-size:var(--fs-body);font-weight:700;letter-spacing:-.01em}
.sb-brand .co{font-family:var(--font-mono);font-size:var(--fs-label);letter-spacing:.14em;
  color:var(--text-muted);text-transform:uppercase}
.sb-group{font-family:var(--font-mono);font-size:var(--fs-label);letter-spacing:.13em;
  text-transform:uppercase;color:var(--text-muted);padding:14px 12px 6px}
.sb-item{display:flex;align-items:center;gap:10px;width:100%;min-height:38px;padding:0 12px;
  border-radius:var(--r-sm);color:var(--text-sub);font-size:var(--fs-small);font-weight:500;
  position:relative;text-align:left;
  transition:background var(--dur-fast) var(--ease-out),color var(--dur-fast) var(--ease-out)}
.sb-item:hover{background:var(--surface-3);color:var(--text)}
.sb-item.on{background:var(--accent-t10);color:var(--accent);font-weight:600}
/* The 3px left rail is the active marker throughout the app. */
.sb-item.on::before{content:'';position:absolute;left:0;top:7px;bottom:7px;width:3px;
  border-radius:0 2px 2px 0;background:var(--accent)}
.sb-item .ic{width:18px;height:18px;display:grid;place-items:center;flex:none}
.sb-badge{flex:none;font-family:var(--font-mono);font-size:var(--fs-label);font-weight:700;
  min-width:19px;height:18px;padding:0 5px;border-radius:var(--r-pill);
  display:grid;place-items:center;background:var(--accent);color:var(--on-accent)}
.sb-foot{margin-top:auto;padding-top:12px;border-top:1px solid var(--border)}

/* ── mobile sub-tabs: the leaves of the current section ──── */
.sub-tabs{display:flex;gap:6px;align-items:center;padding:8px 16px;
  background:var(--surface-1);border-bottom:1px solid var(--border);
  overflow-x:auto;-webkit-overflow-scrolling:touch;position:sticky;top:52px;z-index:39}
.sub-tabs::-webkit-scrollbar{display:none}

.topbar{
  position:sticky;top:0;z-index:40;background:rgba(9,12,18,.92);
  backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px);
  border-bottom:1px solid var(--border);
  padding:calc(var(--safe-top) + 10px) 16px 10px;
  display:flex;align-items:center;gap:12px;min-height:52px;
}
.topbar h1{font-size:var(--fs-title);font-weight:700;letter-spacing:-.01em;flex:1;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.topbar .sub{font-family:var(--font-mono);font-size:var(--fs-label);color:var(--text-muted);
  font-weight:500;letter-spacing:.09em;text-transform:uppercase;margin-top:-2px;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.back-btn{width:44px;height:44px;display:grid;place-items:center;border-radius:var(--r-sm);
  background:var(--surface-3);color:var(--text-sub);font-size:1.375rem;flex-shrink:0}
.back-btn[hidden]{display:none}

main{flex:1;padding:16px var(--gutter);
  padding-bottom:calc(var(--tabbar-h) + var(--safe-bottom) + 24px);
  max-width:var(--content-max);width:100%;margin:0 auto}

/* ── bottom tab bar ────────────────────────────────────── */
nav.tabs{
  position:fixed;bottom:0;left:0;right:0;z-index:50;
  background:rgba(16,20,29,.96);backdrop-filter:blur(14px);
  -webkit-backdrop-filter:blur(14px);border-top:1px solid var(--border);
  display:flex;padding-bottom:var(--safe-bottom);
}
nav.tabs button{
  flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;
  gap:3px;height:var(--tabbar-h);color:var(--text-muted);font-weight:600;
  letter-spacing:.02em;position:relative;
  /* px on purpose: the bar is a fixed 64px, so its labels do NOT follow the
     Larger text setting — at 130% five labels collide. Content scales; the
     chrome that frames it stays put. 12px is still the floor. */
  font-size:12px;white-space:nowrap;min-width:0;
}
nav.tabs button .ic{width:22px;height:22px;display:grid;place-items:center}
nav.tabs button.on{color:var(--accent)}
nav.tabs button.on::before{content:'';position:absolute;top:0;left:22%;right:22%;height:2px;
  background:var(--accent);border-radius:0 0 3px 3px}
nav.tabs .badge{position:absolute;top:8px;right:calc(50% - 22px);min-width:17px;height:17px;
  padding:0 4px;border-radius:9px;background:var(--danger);color:#2A0808;
  font-family:var(--font-mono);font-size:11px;font-weight:700;display:grid;place-items:center}

/* ── single-colour icons (js/icons.js) ─────────────────────
   Stroke is currentColor, so an icon takes the state of whatever holds it —
   muted at rest, accent when active. Emoji could not. */
svg.icon{width:100%;height:100%;display:block;flex:none}

/* ── who is signed in, on a shared device ──────────────────
   Initials rather than a per-user colour: colour is reserved for stock. */
.who-chip{flex:none;width:36px;height:36px;border-radius:50%;display:grid;place-items:center;
  background:var(--surface-3);border:1px solid var(--border-strong);color:var(--text);
  font-family:var(--font-mono);font-size:var(--fs-label);font-weight:700;letter-spacing:.02em}
.who-chip:active{background:var(--surface-4)}

/* ── connection state ─────────────────────────────────────
   Inverted neutral, NOT amber: amber means "stock running out", and a
   cold-room wifi dead spot is not a stock event. Inverted is still the most
   visible thing on a dark bar. */
.net-pill{flex:none;display:inline-flex;align-items:center;gap:6px;height:26px;padding:0 10px;
  border-radius:var(--r-pill);background:var(--text);color:var(--bg);
  font-family:var(--font-mono);font-size:var(--fs-label);font-weight:700;
  letter-spacing:.05em;text-transform:uppercase}
.net-pill::before{content:'';width:7px;height:7px;border-radius:50%;background:var(--bg)}

/* ── sign in ───────────────────────────────────────────── */
.auth{min-height:100dvh;display:flex;flex-direction:column;align-items:center;
  justify-content:center;padding:28px 20px;gap:8px}
.auth .mark{width:76px;height:76px;border-radius:19px;margin-bottom:6px;
  box-shadow:0 10px 34px var(--accent-t28)}
.auth .mark img{width:100%;height:100%;border-radius:inherit;display:block}
.auth h1{font-size:1.375rem;font-weight:700;letter-spacing:-.02em}
.auth .tag{font-family:var(--font-mono);font-size:var(--fs-label);color:var(--text-muted);
  letter-spacing:.14em;text-transform:uppercase;margin-bottom:24px}
.auth-box{width:100%;max-width:380px}
.pin-dots{display:flex;gap:11px;justify-content:center;margin:18px 0 22px}
.pin-dots i{width:13px;height:13px;border-radius:50%;background:var(--border-strong);
  transition:background var(--dur-fast) var(--ease-out),transform var(--dur-fast) var(--ease-out)}
.pin-dots i.on{background:var(--accent);transform:scale(1.14)}
.keypad{display:grid;grid-template-columns:repeat(3,1fr);gap:11px}
.keypad button{height:62px;border-radius:var(--r-md);background:var(--surface-2);
  border:1px solid var(--border);font-family:var(--font-mono);font-size:1.4375rem;font-weight:600}
.keypad button:active{background:var(--surface-3)}
.keypad button.fn{font-family:var(--font-ui);font-size:var(--fs-small);font-weight:600;color:var(--text-sub)}

/* ═══ Breakpoints ════════════════════════════════════════════════ */

/* Desktop: sidebar leads, the bottom bar and sub-tabs are gone. Zeroing
   --tabbar-h keeps main's padding-bottom and the toast offset correct without
   either of them needing a media query of its own. */
@media (min-width:769px){
  :root{--tabbar-h:0px}
  nav.tabs,.sub-tabs{display:none !important}
  :root{--gutter:20px}
  .topbar{padding:0 20px;min-height:var(--header-h);height:var(--header-h)}
  main{padding:24px var(--gutter) 40px}
}

/* Phone: no sidebar, thumb-friendly bottom bar. */
@media (max-width:768px){
  .sidebar{display:none}
  .app{display:block}
}
