/* ===========================================================================
   Mage HQ — the app frame (layout.php render_header; behaviour in shell.js)
   After macOS and iOS. On a computer: a floating glass sidebar with the
   Settings app's coloured tiles, sections that fold and a rail of icons,
   and a toolbar laid over the page that turns to glass once the page
   scrolls. On a tablet the sidebar is a drawer. On a phone: a navigation
   bar whose title appears when the page's own heading scrolls under it, a
   glass tab bar beside a round New button, and sheets for More and New.
   Loaded after style.css and sales.css; colours come from style.css.
   =========================================================================== */

:root {
  --sb-w: 256px;                 /* the sidebar's column, its inset included */
  --sb-gap: 10px;
  --topbar-h: 60px;
  --spring: cubic-bezier(.32, .72, 0, 1);
  --glass: rgba(250, 248, 246, .72);
  --glass-solid: rgba(253, 252, 251, .9);
  --glass-line: rgba(60, 40, 20, .09);
  --glass-edge: inset 0 1px 0 rgba(255, 255, 255, .75);
  --glass-shadow: 0 1px 2px rgba(40, 25, 10, .05), 0 14px 34px -16px rgba(40, 25, 10, .24);
  --glass-blur: saturate(180%) blur(24px);
  --fill-hover: rgba(60, 40, 20, .055);
  --fill-press: rgba(60, 40, 20, .1);
  --select: rgba(188, 80, 10, .12);
  --tab-ink: #857D76;
  --sep: rgba(60, 40, 20, .11);
  --sheet-bg: #F2F0EC;
  --cell: #FFFFFF;
  --seg-on: #FFFFFF;
}
html[data-theme="dark"] {
  --glass: rgba(29, 25, 22, .72);
  --glass-solid: rgba(34, 30, 27, .92);
  --glass-line: rgba(255, 255, 255, .09);
  --glass-edge: inset 0 1px 0 rgba(255, 255, 255, .06);
  --glass-shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 18px 40px -16px rgba(0, 0, 0, .75);
  --fill-hover: rgba(255, 255, 255, .07);
  --fill-press: rgba(255, 255, 255, .12);
  --select: rgba(251, 139, 60, .17);
  --tab-ink: #9C948D;
  --sep: rgba(255, 255, 255, .09);
  --sheet-bg: #0F0D0C;
  --cell: #1D1A17;
  --seg-on: #45403B;
}

/* Buttons in the frame start plain (style.css gives every <button> the orange look). */
:is(.tb-btn, .nav-section, .sb-me, .bnav-item, .bnav-new, .sheet-done, .topbar-search, .topbar-bell, [data-theme-set]) {
  margin: 0; padding: 0; border: 0; border-radius: 10px; background: transparent; color: inherit;
  font: inherit; font-weight: 500; letter-spacing: 0; box-shadow: none; transform: none; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
:is(.tb-btn, .nav-section, .sb-me, .bnav-item, .bnav-new, .sheet-done, .topbar-search, .topbar-bell, [data-theme-set]):hover:not(:disabled) {
  background-color: var(--fill-hover); transform: none; box-shadow: none;
}
:is(.tb-btn, .nav-section, .sb-me, .bnav-item, .bnav-new, .sheet-done, .topbar-search, .topbar-bell, [data-theme-set]):active:not(:disabled) {
  transform: none; box-shadow: none;
}

/* ── Page frame ─────────────────────────────────────────────────────────── */
.content { padding-top: var(--topbar-h); transition: margin-left .4s var(--spring); }
body.has-sidebar .content { margin-left: var(--sb-w); }
html.sheet-open { overflow: hidden; }

/* ── The message after an action (layout.php .flash.toast) ──────────────────
   A solid glass card under the toolbar's right end; on phones a banner that
   drops over the nav bar like an iOS notification. A round icon says how it
   went, long words (emails, links) wrap inside, a thin bar at the foot counts
   down (paused while hovered, focused or touched), and it slides away the
   way it came. */
.flash.toast {
  position: fixed; z-index: 85; top: calc(var(--topbar-h) + 12px); right: 16px;
  width: min(380px, calc(100vw - 32px)); margin: 0;
  display: grid; grid-template-columns: 28px minmax(0, 1fr) 28px; align-items: start; gap: 12px;
  padding: 12px 10px 14px 12px; overflow: hidden;
  border: 1px solid var(--glass-line); border-radius: 16px;
  background: var(--glass-solid); -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
  box-shadow: var(--glass-edge), var(--glass-shadow), 0 24px 48px -24px rgba(30, 18, 8, .35);
  color: var(--ink); font-size: 14px; font-weight: 500; line-height: 1.42;
  touch-action: none;
  transition: opacity .25s ease, transform .4s var(--spring);
  animation: flash-in .55s var(--spring) backwards;
}
.flash.toast.is-dragging { transition: none; }
.flash.toast.hide { opacity: 0; transform: translateX(24px) scale(.97); pointer-events: none; }
.flash-icon {
  width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%;
  background: var(--ok); color: var(--surface);
}
.flash.toast.error .flash-icon { background: var(--danger); }
.flash-text { min-width: 0; padding-top: 4px; overflow-wrap: anywhere; }
.flash.toast .flash-close {
  width: 28px; height: 28px; min-height: 0; display: grid; place-items: center; margin: 0; padding: 0;
  border: 0; border-radius: 50%; background: transparent; box-shadow: none; color: var(--muted);
}
.flash.toast .flash-close:hover:not(:disabled) { background: var(--fill-hover); color: var(--ink); }
.flash.toast .flash-close:active:not(:disabled) { background: var(--fill-press); transform: scale(.92); }
.flash.toast .flash-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.flash-timer {
  position: absolute; left: 0; right: 0; bottom: 0; height: 3px; transform-origin: left;
  background: var(--ok); opacity: .5; animation: flash-timer var(--life, 5s) linear forwards;
}
.flash.toast.error .flash-timer { background: var(--danger); }
.flash.toast.is-paused .flash-timer { animation-play-state: paused; }
@keyframes flash-in { from { opacity: 0; transform: translateX(32px) scale(.96); } }
@keyframes flash-drop { from { opacity: .3; transform: translateY(calc(-100% - 20px)); } }
@keyframes flash-timer { to { transform: scaleX(0); } }

/* ── Sidebar (computer): a floating glass panel ─────────────────────────── */
.sidebar {
  position: fixed; z-index: 40; top: var(--sb-gap); bottom: var(--sb-gap); left: var(--sb-gap);
  width: calc(var(--sb-w) - var(--sb-gap) * 2);
  display: flex; flex-direction: column; overflow: hidden;
  border: 1px solid var(--glass-line); border-radius: 20px;
  background: var(--glass); -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
  box-shadow: var(--glass-edge), var(--glass-shadow);
  transition: width .4s var(--spring), transform .4s var(--spring);
}
.sb-head { padding: 12px 12px 4px; }
.sb-app { display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: 12px; color: var(--ink); text-decoration: none; white-space: nowrap; overflow: hidden; }
.sb-app:hover { background: var(--fill-hover); }
.sb-app img { flex: none; width: 32px; height: 32px; border-radius: 8px; box-shadow: 0 1px 2px rgba(0, 0, 0, .2), 0 0 0 .5px rgba(0, 0, 0, .1); }
html[data-theme="dark"] :is(.sb-app, .tb-app, .tb-brand) img { box-shadow: 0 0 0 1px rgba(255, 255, 255, .14); }
.sb-app-text { display: grid; min-width: 0; line-height: 1.2; transition: opacity .2s; }
.sb-app-text strong { font-size: 15px; font-weight: 750; letter-spacing: -.015em; }
.sb-app-text small { font-size: 11.5px; color: var(--muted); }

.sb-nav { flex: 1; min-height: 0; overflow-x: hidden; overflow-y: auto; padding: 6px 10px 12px; scrollbar-width: thin; scrollbar-color: transparent transparent; }
.sb-nav:hover, .sb-nav:focus-within { scrollbar-color: var(--line-strong) transparent; }
.sb-nav::-webkit-scrollbar { width: 6px; }
.sb-nav::-webkit-scrollbar-thumb { background: transparent; border-radius: 6px; }
.sb-nav:hover::-webkit-scrollbar-thumb { background: var(--line-strong); }
.sb-group + .sb-group { margin-top: 6px; }

.nav-section {
  display: flex; align-items: center; gap: 4px; width: 100%; padding: 9px 8px 5px; border-radius: 7px;
  color: var(--muted); font-size: 11.5px; font-weight: 650; text-align: left; white-space: nowrap;
}
.nav-section:hover:not(:disabled) { background: transparent; color: var(--ink-2); }
.nav-section svg { margin-left: auto; opacity: 0; transition: opacity .15s, transform .3s var(--spring); }
.nav-section:hover svg, .nav-section:focus-visible svg, .sb-group.is-closed .nav-section svg { opacity: .8; }
.sb-group.is-closed .nav-section svg { transform: rotate(-90deg); }
.sb-group.is-closed .sb-items { display: none; }

.nav-item, .sb-recent-item {
  position: relative; display: flex; align-items: center; gap: 10px; height: 34px; margin: 1px 0; padding: 0 8px 0 6px;
  border-radius: 9px; color: var(--ink); font-size: 13.5px; font-weight: 500; line-height: 1; text-decoration: none;
  white-space: nowrap; overflow: hidden; transition: background-color .15s, padding .4s var(--spring);
}
.nav-item:hover, .sb-recent-item:hover { background: var(--fill-hover); }
.nav-item:active, .sb-recent-item:active { background: var(--fill-press); }
.nav-item.active { background: var(--select); font-weight: 650; }
.nav-item > span:not(.nav-ico):not(.nav-count), .sb-recent-item > span:last-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; transition: opacity .2s; }
.nav-ico {
  flex: none; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 7px; color: #fff;
  background: linear-gradient(180deg, rgba(255, 255, 255, .22), rgba(255, 255, 255, 0) 65%), var(--tone, #8A837D);
  box-shadow: inset 0 0 0 .5px rgba(0, 0, 0, .14), 0 1px 1.5px rgba(0, 0, 0, .1);
}
.nav-ico svg { stroke-width: 2; }
.nav-count {
  margin-left: auto; padding: 2px 7px; border-radius: 999px; background: var(--fill-hover);
  color: var(--ink-2); font-size: 11.5px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.nav-item.active .nav-count { background: rgba(255, 255, 255, .55); }
html[data-theme="dark"] .nav-item.active .nav-count { background: rgba(0, 0, 0, .25); }
.sb-recent-item { color: var(--ink-2); font-size: 13px; }
.sb-recent-av {
  flex: none; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%;
  background: color-mix(in srgb, var(--tone, #8A837D) 16%, transparent); color: var(--tone, #8A837D);
  font-size: 9.5px; font-weight: 800; letter-spacing: .02em;
}

.sb-foot { padding: 8px 10px 10px; border-top: 1px solid var(--sep); }
.sb-me { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 8px; border-radius: 12px; text-align: left; white-space: nowrap; overflow: hidden; }
.sb-me[aria-expanded="true"] { background: var(--fill-hover); }
.sb-me > svg { flex: none; margin-left: auto; color: var(--muted); transition: opacity .2s; }
.sb-me-text { display: grid; min-width: 0; line-height: 1.25; transition: opacity .2s; }
.sb-me-text strong { overflow: hidden; text-overflow: ellipsis; font-size: 13.5px; font-weight: 650; }
.sb-me-text small { color: var(--muted); font-size: 11.5px; }
.me-av {
  flex: none; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  color: #fff; font-size: 11.5px; font-weight: 750; letter-spacing: .02em;
  box-shadow: inset 0 0 0 .5px rgba(0, 0, 0, .12);
}

/* Icons only: the sidebar shrinks to its tiles; names show beside them on hover (shell.js). */
@media (min-width: 901px) {
  html.sb-rail { --sb-w: 88px; }
  html.sb-rail .nav-item, html.sb-rail .sb-recent-item { padding-left: 12px; }
  html.sb-rail :is(.sb-app-text, .sb-me-text, .sb-me > svg, .nav-item > span:not(.nav-ico):not(.nav-count), .sb-recent-item > span:last-child) { opacity: 0; }
  html.sb-rail .nav-section { height: 1px; margin: 9px 12px; padding: 0; background: var(--sep); font-size: 0; pointer-events: none; }
  html.sb-rail .nav-section > * { display: none; }
  html.sb-rail .sb-group.is-closed .sb-items { display: block; }
  html.sb-rail .nav-count { position: absolute; top: 4px; left: 32px; width: 9px; height: 9px; padding: 0; overflow: hidden; color: transparent; background: var(--danger); box-shadow: 0 0 0 2px var(--cell); }
  html.sb-rail .sb-me { padding-left: 8px; }
}
.sb-tip {
  position: fixed; z-index: 80; padding: 5px 10px; border-radius: 8px; pointer-events: none;
  background: var(--ink); color: var(--surface); font-size: 12.5px; font-weight: 600; white-space: nowrap;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .18);
}
.sb-tip[hidden] { display: none; }
.sidebar-scrim { display: none; }

/* ── Toolbar (computer): over the page, glass once it scrolls ───────────── */
.topbar {
  position: fixed; z-index: 30; top: 0; right: 0; left: 0; height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px; padding: 0 18px 0 12px;
  transition: left .4s var(--spring), background-color .25s, box-shadow .25s;
}
body.has-sidebar .topbar { left: var(--sb-w); }
html.is-scrolled .topbar {
  background: var(--glass); -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
  box-shadow: 0 1px 0 var(--glass-line);
}
.tb-lead { display: flex; align-items: center; gap: 4px; flex: none; }
.tb-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; color: var(--ink-2); }
.tb-back, .tb-app { display: none; }
.tb-crumbs { flex: 1; min-width: 0; }
.tb-crumbs ol { display: flex; align-items: center; min-width: 0; margin: 0; padding: 0; list-style: none; }
.tb-crumbs li { display: flex; align-items: center; flex: 0 1 auto; min-width: 0; }
.tb-crumbs li:last-child { flex-shrink: 0; max-width: 60%; }
.tb-crumbs li > :is(a, span) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tb-crumbs a, .tb-crumbs li > span { padding: 4px 6px; border-radius: 7px; color: var(--muted); font-size: 13.5px; font-weight: 550; text-decoration: none; }
.tb-crumbs a:hover { background: var(--fill-hover); color: var(--ink); }
.tb-crumbs li[aria-current] > span { color: var(--ink); font-size: 15.5px; font-weight: 750; letter-spacing: -.012em; }
.tb-crumbs li > svg { flex: none; color: var(--muted); opacity: .55; }
.tb-title { display: none; }
.tb-actions { display: flex; align-items: center; gap: 8px; flex: none; margin-left: auto; }

/* Glass controls on the right: Search, New, the bell. */
:is(.topbar-search, .tb-new, .topbar-bell) {
  height: 36px; border: 1px solid var(--glass-line); background: var(--glass-solid); color: var(--ink-2);
  box-shadow: var(--glass-edge), 0 1px 2px rgba(40, 25, 10, .05);
  -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
}
:is(.topbar-search, .tb-new, .topbar-bell):hover:not(:disabled) { background: var(--cell); color: var(--ink); border-color: var(--line-strong); }
:is(.topbar-search, .tb-new, .topbar-bell, .tb-btn):active:not(:disabled) { transform: scale(.96); }
.topbar-search { display: inline-flex; align-items: center; gap: 8px; width: 250px; padding: 0 7px 0 12px; border-radius: 999px; font-size: 13.5px; }
.topbar-search svg { flex: none; color: var(--muted); }
.topbar-search-text { flex: 1; color: var(--muted); text-align: left; }
.topbar-search-kbd { padding: 4px 7px; border: 0; border-radius: 999px; background: var(--fill-hover); color: var(--muted); font: 650 11px/1 var(--font); }
.tb-new { display: inline-flex; align-items: center; gap: 6px; width: auto; padding: 0 14px 0 10px; border-radius: 999px; font-size: 13.5px; font-weight: 650; }
.tb-new[aria-expanded="true"], .topbar-bell[aria-expanded="true"] { background: var(--cell); color: var(--ink); border-color: var(--line-strong); }
.topbar-bell { position: relative; display: inline-grid; place-items: center; width: 36px; padding: 0; border-radius: 50%; }
.topbar-bell-n {
  position: absolute; top: -4px; right: -5px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--danger); color: #fff; font-size: 10.5px; font-weight: 800; line-height: 18px; text-align: center;
  box-shadow: 0 0 0 2px var(--bg);
}
.topbar-bell-n[hidden] { display: none; }
.topbar-streak {
  display: inline-flex; align-items: center; gap: 5px; height: 36px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--glass-line); background: var(--glass-solid); box-shadow: var(--glass-edge);
  color: var(--streak); font-size: 13px; font-weight: 800; text-decoration: none;
}
.topbar-streak:hover { border-color: var(--line-strong); }
.topbar-streak .flame { filter: drop-shadow(0 0 4px var(--streak-glow)); }
body.is-guest .topbar { left: 0; }
.tb-brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); font-size: 16px; font-weight: 750; letter-spacing: -.015em; text-decoration: none; }
.tb-brand img { border-radius: 8px; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); }

/* The bell's list (notifications.js): a panel under the toolbar. */
.notif-panel {
  position: fixed; top: calc(var(--topbar-h) + 2px); right: 14px; z-index: 45;
  width: min(400px, calc(100vw - 24px)); max-height: min(560px, calc(100dvh - var(--topbar-h) - 24px)); overflow-y: auto;
  border: 1px solid var(--glass-line); border-radius: 18px; background: var(--surface); color: var(--ink);
  box-shadow: var(--glass-edge), 0 24px 60px -18px rgba(30, 18, 8, .35), 0 2px 8px rgba(30, 18, 8, .08);
  animation: pop-in .28s var(--spring);
}
.notif-panel-head { background: var(--surface); }

/* ── Menus: account and New (macOS style) ───────────────────────────────── */
.pop-menu {
  position: fixed; z-index: 70; min-width: 250px; max-width: calc(100vw - 16px); padding: 6px;
  border: 1px solid var(--glass-line); border-radius: 14px;
  background: var(--glass-solid); -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
  box-shadow: var(--glass-edge), 0 24px 56px -18px rgba(30, 18, 8, .38), 0 2px 8px rgba(30, 18, 8, .08);
  opacity: 0; transform: scale(.96); transition: opacity .16s ease-out, transform .3s var(--spring);
}
.pop-menu.is-open { opacity: 1; transform: none; }
.pop-menu[hidden] { display: none; }
.pop-item {
  display: flex; align-items: center; gap: 10px; min-height: 32px; padding: 6px 10px; border-radius: 8px;
  color: var(--ink); font-size: 13.5px; font-weight: 500; text-decoration: none; outline: none;
}
.pop-item > svg { flex: none; color: var(--muted); }
.pop-item:is(:hover, :focus-visible) { background: var(--accent); color: var(--accent-ink); }
.pop-item:is(:hover, :focus-visible) > svg { color: inherit; }
.pop-item.is-danger { color: var(--danger); }
.pop-item.is-danger:is(:hover, :focus-visible) { background: var(--danger); color: #fff; }
.pop-item > span { display: grid; gap: 1px; min-width: 0; }
.pop-item small { color: var(--muted); font-size: 11.5px; font-weight: 500; }
.pop-item:is(:hover, :focus-visible) small { color: inherit; opacity: .8; }
.pop-item .nav-ico { width: 26px; height: 26px; }
.pop-item:is(:hover, :focus-visible) .nav-ico { box-shadow: 0 0 0 1.5px rgba(255, 255, 255, .75); }
.pop-new { min-width: 270px; }
.pop-label { padding: 6px 10px 4px; color: var(--muted); font-size: 11.5px; font-weight: 650; }
.pop-sep { height: 1px; margin: 5px 8px; background: var(--sep); }
.pop-me { display: flex; align-items: center; gap: 10px; padding: 8px 10px 6px; }
.pop-me > span:last-child { display: grid; min-width: 0; line-height: 1.3; }
.pop-me strong { font-size: 14px; font-weight: 700; }
.pop-me small { overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.pop-me .me-av { width: 36px; height: 36px; font-size: 13px; }
.pop-theme { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 5px 6px 5px 10px; font-size: 13.5px; }

/* Light / Dark / Auto */
.seg { display: inline-flex; flex: none; gap: 2px; padding: 2px; border-radius: 9px; background: var(--fill-press); }
.seg [data-theme-set] { display: inline-grid; place-items: center; width: 34px; height: 26px; border-radius: 7px; color: var(--muted); }
.seg [data-theme-set] span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.seg [data-theme-set][aria-pressed="true"],
.seg [data-theme-set][aria-pressed="true"]:hover:not(:disabled) { background: var(--seg-on); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .14), 0 0 0 .5px rgba(0, 0, 0, .04); }

@keyframes pop-in { from { opacity: 0; transform: translateY(-4px) scale(.98); } }

/* ── Tablet: the sidebar slides in over the page ─────────────────────────── */
@media (max-width: 900px) {
  body.has-sidebar .content { margin-left: 0; }
  body.has-sidebar .topbar { left: 0; }
  .sidebar { transform: translateX(calc(-100% - 24px)); box-shadow: var(--glass-edge), 0 30px 80px -20px rgba(0, 0, 0, .45); }
  .sidebar.open { transform: none; }
  .sidebar-scrim { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(15, 9, 4, .28); opacity: 0; pointer-events: none; transition: opacity .3s; }
  .sidebar-scrim.show { opacity: 1; pointer-events: auto; }
  .topbar-search { width: 36px; padding: 0; justify-content: center; }
  .topbar-search-text, .topbar-search-kbd { display: none; }
}

/* ── Phone: navigation bar, tab bar, sheets ─────────────────────────────── */
.bnav { display: none; }
dialog.sheet:not([open]) { display: none; }
@media (max-width: 760px) {
  :root { --topbar-h: calc(54px + env(safe-area-inset-top, 0px)); }
  body.has-bnav { --bnav-h: 78px; padding-bottom: calc(var(--bnav-h) + env(safe-area-inset-bottom, 0px)); }
  .sidebar, .sidebar-scrim, .tb-sidebar, .tb-crumbs, .tb-new { display: none !important; }

  .topbar { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 6px; padding: env(safe-area-inset-top, 0px) 12px 0; }
  .tb-lead { min-width: 0; }
  .tb-back { display: inline-flex; align-items: center; min-width: 0; margin-left: -8px; padding: 6px 6px 6px 0; border-radius: 10px; color: var(--accent); font-size: 16.5px; font-weight: 550; text-decoration: none; }
  .tb-back svg { flex: none; stroke-width: 2.2; }
  .tb-back span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tb-back:active { opacity: .5; }
  body.has-back .shell > .back-link { display: none; }   /* the bar's back button does that job */
  .flash.toast {
    top: calc(env(safe-area-inset-top, 0px) + 8px); right: 8px; left: 8px; width: auto;
    padding: 13px 10px 15px 13px; border-radius: 20px; animation-name: flash-drop;
  }
  .flash.toast.hide { transform: translateY(calc(-100% - 20px)); }
  .tb-app { display: inline-flex; }
  .tb-app img { border-radius: 8px; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); }
  .tb-title {
    display: block; max-width: 56vw; overflow: hidden; color: var(--ink); font-size: 16.5px; font-weight: 700; letter-spacing: -.01em;
    text-align: center; text-overflow: ellipsis; white-space: nowrap;
    opacity: 0; transform: translateY(5px); transition: opacity .2s, transform .35s var(--spring);
  }
  html.nav-title .tb-title { opacity: 1; transform: none; }
  .tb-actions { justify-self: end; gap: 8px; }
  :is(.topbar-search, .topbar-bell) { width: 38px; height: 38px; border-radius: 50%; }
  .topbar-search { padding: 0; justify-content: center; }
  .topbar-streak { height: 38px; padding: 0 10px; font-size: 12px; }
  .notif-panel { top: calc(var(--topbar-h) + 4px); right: 8px; left: 8px; width: auto; max-height: calc(100dvh - var(--topbar-h) - var(--bnav-h, 0px) - 24px); }

  /* The tab bar: a glass capsule, the page you're on in a soft pill. */
  .bnav {
    display: flex; align-items: center; gap: 8px; position: fixed; z-index: 18;
    left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom, 0px)); pointer-events: none;
  }
  .bnav-bar {
    flex: 1; min-width: 0; display: flex;
    height: 62px; padding: 4px; border-radius: 31px; pointer-events: auto;
    border: 1px solid var(--glass-line); background: var(--glass-solid);
    -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
    box-shadow: var(--glass-edge), 0 12px 32px -10px rgba(30, 18, 8, .28), 0 1px 3px rgba(30, 18, 8, .08);
  }
  .bnav-item {
    position: relative; display: grid; justify-items: center; align-content: center; gap: 3px;
    flex: 1 1 0; min-width: max-content; padding: 0 4px; border-radius: 27px; color: var(--tab-ink); font-size: 10px; font-weight: 650; letter-spacing: -.01em; line-height: 1.1; text-decoration: none;
    transition: background-color .25s, color .25s;
  }
  .bnav-item:hover:not(:disabled) { background: transparent; }
  .bnav-item svg { width: 24px; height: 24px; transition: transform .3s var(--spring); }
  .bnav-item span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .bnav-item.active, .bnav-item.active:hover:not(:disabled) { background: var(--select); color: var(--accent); }
  .bnav-item.active svg :is(path, rect, circle) { fill: currentColor; fill-opacity: .16; }
  .bnav-item:active:not(:disabled) svg { transform: scale(.86); }
  .bnav-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -3px; }
  .bnav-n {
    position: absolute; top: 3px; left: calc(50% + 5px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
    background: var(--danger); color: #fff; font-size: 10.5px; font-weight: 800; line-height: 18px; text-align: center;
    box-shadow: 0 0 0 2px var(--glass-solid);
  }
  .bnav-new {
    flex: none; display: grid; place-items: center; width: 58px; height: 58px; border-radius: 50%; pointer-events: auto;
    background: var(--accent); color: var(--accent-ink);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 12px 26px -8px rgba(188, 80, 10, .6), 0 1px 3px rgba(0, 0, 0, .12);
    transition: transform .3s var(--spring);
  }
  .bnav-new:hover:not(:disabled) { background: var(--accent); }
  .bnav-new:active:not(:disabled) { transform: scale(.92); }
  .bnav-new svg { stroke-width: 2.4; }
  .bnav-new[aria-expanded="true"] svg { transform: rotate(45deg); transition: transform .3s var(--spring); }
  .action-menu-list { bottom: calc(12px + var(--bnav-h) + env(safe-area-inset-bottom, 0px)); }
}

/* Sheets (More, New): slide up from the bottom, grouped lists like Settings. */
dialog.sheet {
  position: fixed; inset: auto 0 0 0; width: 100%; max-width: 620px; max-height: calc(100dvh - 44px);
  margin: 0 auto; padding: 0; border: 0; border-radius: 24px 24px 0 0; overflow: hidden;
  background: var(--sheet-bg); color: var(--ink); box-shadow: 0 -12px 40px rgba(0, 0, 0, .2);
  transition: transform .35s var(--spring);
}
dialog.sheet[open] { display: flex; flex-direction: column; animation: sheet-up .5s var(--spring); }
dialog.sheet.is-dragging { transition: none; }
dialog.sheet.is-closing { animation: sheet-down .24s cubic-bezier(.4, 0, 1, 1) forwards; }
dialog.sheet::backdrop { background: rgba(15, 9, 4, .34); animation: fade-in .3s ease-out; }
dialog.sheet.is-closing::backdrop { animation: fade-out .24s ease-in forwards; }
@keyframes sheet-up { from { transform: translateY(100%); } }
@keyframes sheet-down { to { transform: translateY(100%); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
.sheet-head { position: relative; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 18px 16px 10px; touch-action: none; }
.sheet-grabber { position: absolute; top: 6px; left: 50%; width: 38px; height: 5px; margin-left: -19px; border-radius: 3px; background: var(--line-strong); }
.sheet-head h2 { grid-column: 2; margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -.01em; outline: none; }
.sheet-done { grid-column: 3; justify-self: end; padding: 6px 8px; color: var(--accent); font-size: 16.5px; font-weight: 650; }
.sheet-done:hover:not(:disabled) { background: transparent; }
.sheet-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 4px 16px calc(28px + env(safe-area-inset-bottom, 0px)); }
.sheet-me { display: flex; align-items: center; gap: 13px; padding: 12px 14px; border-radius: 14px; background: var(--cell); color: var(--ink); text-decoration: none; }
.sheet-me .me-av { width: 52px; height: 52px; font-size: 18px; }
.sheet-me > span:nth-child(2) { display: grid; flex: 1; min-width: 0; line-height: 1.3; }
.sheet-me strong { font-size: 17px; font-weight: 700; }
.sheet-me small { color: var(--muted); font-size: 13px; }
.sheet-me > svg, .sheet-row > svg:last-child { flex: none; color: var(--muted); opacity: .6; }
.sheet-group { margin-top: 22px; }
.sheet-label { margin: 0 0 6px 16px; color: var(--muted); font-size: 13px; font-weight: 600; letter-spacing: 0; text-transform: none; }
.sheet-list { overflow: hidden; border-radius: 14px; background: var(--cell); }
.sheet-row { position: relative; display: flex; align-items: center; gap: 13px; min-height: 48px; padding: 8px 14px; color: var(--ink); font-size: 16px; text-decoration: none; -webkit-tap-highlight-color: transparent; }
.sheet-row + .sheet-row::before { content: ''; position: absolute; top: 0; right: 0; left: 56px; height: 1px; background: var(--sep); }
a.sheet-row:active, .sheet-me:active { background: var(--fill-press); }
.sheet-row .nav-ico { width: 29px; height: 29px; }
.sheet-row .nav-ico svg { width: 17px; height: 17px; }
.sheet-row .sb-recent-av { width: 29px; height: 29px; font-size: 11px; }
.sheet-row-text { display: grid; flex: 1; min-width: 0; line-height: 1.3; }
.sheet-row-text small { color: var(--muted); font-size: 13px; }
.sheet-row-tall { min-height: 60px; }
.sheet-row.is-here .sheet-row-text { color: var(--accent); font-weight: 650; }
.sheet-count { color: var(--muted); font-size: 15px; font-weight: 500; font-variant-numeric: tabular-nums; }
.sheet-row.is-danger { justify-content: center; color: var(--danger); font-weight: 600; }
.sheet-row.is-danger .sheet-row-text { flex: none; }
.sheet-row-theme .seg { margin-left: auto; }
.sheet-row-theme .seg [data-theme-set] { width: 44px; height: 30px; }

/* Moving between pages (browsers that can): the bars stay put, the old page
   fades out quickly and the new one rises in on a spring, and the pill that
   marks the page in the sidebar / tab bar slides to its new item, like iOS. */
@view-transition { navigation: auto; }
.topbar { view-transition-name: mm-topbar; }
.sidebar { view-transition-name: mm-sidebar; }
.bnav { view-transition-name: mm-tabbar; }
::view-transition-old(root) { animation: .16s ease-out both fade-out; }
::view-transition-new(root) { animation: .48s cubic-bezier(.32, .72, 0, 1) both mm-page-in; }
::view-transition-group(mm-topbar), ::view-transition-group(mm-sidebar), ::view-transition-group(mm-tabbar) { animation-duration: .2s; }
::view-transition-group(mm-nav-pill), ::view-transition-group(mm-tab-pill) { animation-duration: .55s; animation-timing-function: cubic-bezier(.32, .72, 0, 1); }
@keyframes mm-page-in { from { opacity: 0; transform: translateY(12px); } }

.nav-item, .bnav-item { isolation: isolate; }
.nav-item.active { background: transparent; }
.nav-pill, .bnav-pill { position: absolute; inset: 0; z-index: -1; border-radius: inherit; background: var(--select); pointer-events: none; }
.nav-pill { view-transition-name: mm-nav-pill; }
.bnav-pill { view-transition-name: mm-tab-pill; }
.bnav-item.active, .bnav-item.active:hover:not(:disabled) { background: transparent; }

/* Touch feedback: tiles and cards give a little under the finger. */
.nav-ico { transition: transform .35s var(--spring); }
.nav-item:active .nav-ico { transform: scale(.88); transition-duration: .12s; }
:is(.ws-client, .kb-card, .esc-card, .ops-stat):active { transform: scale(.985); transition-duration: .15s; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }

@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  dialog.sheet[open], dialog.sheet.is-closing, .pop-menu, .notif-panel { animation: none; transition: none; }
  .flash.toast { animation: none; transition: opacity .2s ease; }
  .flash.toast.hide { transform: none; }
  .flash-timer { display: none; }
}

@media print {
  .topbar, .sidebar, .sidebar-scrim, .bnav, .pop-menu, dialog.sheet, .sb-tip, .flash.toast { display: none !important; }
  .content, body.has-sidebar .content { margin-left: 0 !important; padding-top: 0 !important; }
  body.has-bnav { padding-bottom: 0 !important; }
}
