/* The shell (PLAN 3.12): the app grid, the shell bar, the navigation pane in
   its three modes (open, rail, overlay), the command palette, the company
   picker, the person's menu, notifications and the shortcut sheet - plus the
   sign-in page. Everything around a screen, nothing in it.

   Colours, radii, shadows, layers and motion come from tokens.css (PLAN
   3.2-3.5). Where a token is new in wave 1.1 its value is repeated as the
   var() fallback, so the shell reads the same before and after tokens.css
   gains it; the fallbacks can go once every branch has the new tokens. */

/* ── the frame ────────────────────────────────────────────────────────── */

.app {
  --bar-h: 48px;
  --nav-w: 248px;
  --rail-w: 56px;
  --nav-off: -100%;
  display: grid;
  grid-template-columns: var(--nav-w) minmax(0, 1fr);
  grid-template-rows: var(--bar-h) auto;
  grid-template-areas: "bar bar" "nav main";
  min-height: 100vh;
}
[dir="rtl"] .app { --nav-off: 100%; }
.app.nav-open { grid-template-columns: var(--nav-w) minmax(0, 1fr); }
.app.nav-rail { grid-template-columns: var(--rail-w) minmax(0, 1fr); }
.app.nav-overlay { grid-template-columns: minmax(0, 1fr); grid-template-areas: "bar" "main"; }

.main { grid-area: main; min-width: 0; display: flex; flex-direction: column; }
.main:focus { outline: none; }
.content { padding: var(--s-5); min-width: 0; }
/* Screens stack their blocks (tiles, cards, banners) with no margin of their
   own, so on 88 of 151 screens consecutive cards touched. A screen's root is
   a plain div, and so is the box it repaints; one rule gives both the same
   rhythm. Anything with a class (a grid, a row, a card) spaces its own
   children, so only unclassed wrappers are touched (h() writes class=""
   for an empty class, hence the second form). The page head's own
   bottom margin collapses with this one. */
.content > div:is(:not([class]), [class=""]) > * + *,
.content > div:is(:not([class]), [class=""]) > div:is(:not([class]), [class=""]) > * + * { margin-top: 14px; }

/* The first thing Tab reaches: straight past the bar and the menu. */
.skip-link {
  position: fixed; inset-inline-start: 8px; top: -48px; z-index: var(--z-toast);
  padding: 8px 12px; border-radius: var(--r-md); background: var(--surface); color: var(--accent);
  border: 1px solid var(--border-strong); box-shadow: var(--shadow-2);
  font-weight: 600;
}
.skip-link:focus { top: 8px; text-decoration: none; }

/* One focus ring for everything the shell draws (PLAN 3.2 --focus). */
.shellbar :focus-visible, .sidebar :focus-visible, .shell-pop :focus-visible,
.shell-dialog :focus-visible, .shell-drawer :focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

/* Visually hidden, still read aloud. */
.shell-sr {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ── the shell bar ────────────────────────────────────────────────────── */

.header.shellbar {
  grid-area: bar; position: sticky; top: 0; z-index: var(--z-header);
  height: var(--bar-h); display: flex; align-items: center; gap: var(--s-2);
  padding-inline: var(--s-2) var(--s-3);
  background: var(--surface); border-bottom: 1px solid var(--border);
}

/* Icon buttons in the bar and the panels: 32 px on a desktop (the 24 px
   minimum and a margin), 40 px under a finger. */
.shell-btn {
  position: relative; display: inline-grid; place-items: center; flex: none;
  width: 32px; height: 32px; padding: 0; border: 0; border-radius: var(--r-md);
  background: transparent; color: var(--text-muted); cursor: pointer;
  transition: background-color 120ms cubic-bezier(.2, 0, 0, 1), color 120ms cubic-bezier(.2, 0, 0, 1);
}
.shell-btn:hover { background: var(--surface-3); color: var(--text); }
.shell-btn .ico { width: 18px; height: 18px; }
.shell-btn[aria-expanded="true"] { background: var(--surface-3); color: var(--text); }

/* Only when there is a drawer to open: the rail and the open pane have
   their own button at the foot of the menu. */
#menu-btn { display: none; }
.app.nav-overlay #menu-btn { display: inline-grid; }

.shell-brand {
  display: inline-flex; align-items: center; gap: var(--s-2); flex: none;
  padding: 4px 6px; border-radius: var(--r-md); color: var(--text);
}
.shell-brand:hover { text-decoration: none; background: var(--surface-3); }
.brand-mark {
  width: 24px; height: 24px; border-radius: var(--r-md); flex: none;
  background: var(--accent-solid); color: var(--accent-fg);
  display: grid; place-items: center; font-weight: 700; font-size: 12px;
}
.brand-name { font-weight: 600; letter-spacing: -.01em; white-space: nowrap; }
.brand-name span { color: var(--text-subtle); font-weight: 500; }
/* The page the Blade template paints before the app has booted. */
.brand { height: var(--bar-h, 48px); display: flex; align-items: center; gap: 8px; padding: 0 14px; }

/* The company: code in bold, the name beside it. */
.shell-entity {
  display: inline-flex; align-items: center; gap: var(--s-1h); min-width: 0; max-width: 300px;
  height: 30px; padding-inline: 10px 8px; margin-inline-start: var(--s-1);
  border: 1px solid var(--border-strong); border-radius: var(--r-md);
  background: var(--surface); color: var(--text); font: inherit; font-size: 13px; cursor: pointer;
}
.shell-entity:hover { background: var(--surface-3); }
.shell-entity.static { cursor: default; border-color: transparent; background: transparent; }
.shell-entity-code { font-weight: 700; white-space: nowrap; }
.shell-entity-name { color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.shell-entity .shell-entity-chev { width: 14px; height: 14px; color: var(--text-subtle); }

/* TEST / TRAINING / DEMO: loud on purpose. */
.env-badge {
  flex: none; padding: 2px 8px; border-radius: var(--r-pill);
  font-size: 11px; font-weight: 700; letter-spacing: .06em; line-height: 16px;
}
.env-badge, .env-badge.env-test { background: var(--env-test-bg); color: var(--env-test-fg); }
.env-badge.env-training { background: var(--env-training-bg); color: var(--env-training-fg); }
.env-badge.env-demo { background: var(--env-demo-bg); color: var(--env-demo-fg); }
/* And a stripe along the top of every page, for the screenshot sent to a
   colleague that crops the badge off. */
html[data-env="test"] .shellbar { box-shadow: inset 0 3px 0 var(--env-test-bg); }
html[data-env="training"] .shellbar { box-shadow: inset 0 3px 0 var(--env-training-bg); }
html[data-env="demo"] .shellbar { box-shadow: inset 0 3px 0 var(--env-demo-bg); }

.shell-center { flex: 1; min-width: 0; display: flex; justify-content: center; padding-inline: var(--s-2); }
.shell-search {
  display: flex; align-items: center; gap: var(--s-2); width: min(520px, 100%); height: 32px;
  /* It looks like a field, so it has a field's edge: 3:1 (WCAG 1.4.11). */
  padding-inline: 10px 6px; border: 1px solid var(--border-input); border-radius: var(--r-md);
  background: var(--surface-2); color: var(--text-subtle); font: inherit; font-size: 13px;
  cursor: text; text-align: start;
}
.shell-search:hover { border-color: var(--text-subtle); }
.shell-search .ico { width: 16px; height: 16px; }
.shell-search-text { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.shell-tools { display: flex; align-items: center; gap: 2px; flex: none; }
.shell-btn.star.on { color: var(--warn); }
.shell-btn.star.on .ico { fill: currentColor; }
.bell-count {
  position: absolute; top: 2px; inset-inline-end: 1px; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: var(--r-pill); background: var(--danger); color: var(--surface);
  font-size: 10px; font-weight: 700; line-height: 16px; text-align: center;
  box-shadow: 0 0 0 2px var(--surface);
}

.shell-user {
  display: inline-flex; align-items: center; gap: var(--s-2); height: 32px; margin-inline-start: 4px;
  padding-block: 2px; padding-inline: 2px 8px; border: 0; border-radius: var(--r-pill);
  background: transparent; color: var(--text); font: inherit; font-size: 13px; cursor: pointer;
}
.shell-user:hover, .shell-user[aria-expanded="true"] { background: var(--surface-3); }
.shell-user-name { white-space: nowrap; max-width: 140px; overflow: hidden; text-overflow: ellipsis; }
.avatar {
  display: inline-grid; place-items: center; flex: none; width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent-subtle); color: var(--accent); font-size: 11px; font-weight: 700;
}
.avatar-lg { width: 40px; height: 40px; font-size: 14px; }

.kbd { white-space: nowrap; }
.shell-search .kbd { margin-inline-start: auto; }

/* ── the navigation pane ──────────────────────────────────────────────── */

.sidebar {
  grid-area: nav; position: sticky; top: var(--bar-h); height: calc(100vh - var(--bar-h));
  display: flex; flex-direction: column; min-width: 0;
  background: var(--surface); border-inline-end: 1px solid var(--border);
  z-index: var(--z-sidebar);
}
.sidebar-head { display: none; }
.nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: var(--s-2); scrollbar-width: thin; }
.nav-personal { padding-bottom: 6px; margin-bottom: 6px; border-bottom: 1px solid var(--border); }
.nav-groups > * + * { margin-top: 1px; }

.nav-group-head, .nav-link, .nav-mode-btn {
  display: flex; align-items: center; gap: var(--s-2); width: 100%; min-height: 32px;
  padding: 0 8px; border: 0; border-radius: var(--r-md); background: transparent;
  font: inherit; font-size: 13px; text-align: start; cursor: pointer;
}
.nav-group-head { color: var(--text); font-weight: 600; }
.nav-group-head:hover, .nav-link:hover, .nav-mode-btn:hover {
  background: var(--surface-3); color: var(--text); text-decoration: none;
}
.nav-group-head .ico { color: var(--text-muted); }
.nav-group.current > .nav-group-head .ico:first-child { color: var(--accent); }
.nav-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-chevron { width: 14px; height: 14px; color: var(--text-subtle); transition: transform 120ms cubic-bezier(.2, 0, 0, 1); }
.nav-group-head[aria-expanded="true"] .nav-chevron { transform: rotate(90deg); }
[dir="rtl"] .nav-group-head[aria-expanded="false"] .nav-chevron { transform: rotate(180deg); }
.nav-count { font-size: 11px; font-weight: 600; color: var(--text-subtle); }

.nav-group.collapsed > .nav-group-body { display: none; }
.nav-group-body { padding-bottom: 4px; }
.nav-fly-title { display: none; }
.nav-title {
  padding-block: 8px 2px; padding-inline: 32px 8px; font-size: 11px; line-height: 16px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em; color: var(--text-subtle);
}
.nav-list { list-style: none; margin: 0; padding: 0; }
.nav-section + .nav-section { margin-top: 2px; }
.nav-favs .nav-link { cursor: pointer; }

.nav-link { min-height: 30px; padding-inline-start: 32px; color: var(--text-muted); font-weight: 500; }
/* Items under a group are words: the group carries the icon. */
.nav-group-body .nav-link > .ico { display: none; }
.nav-group-personal .nav-link > .ico { display: inline-block; margin-inline-start: -24px; width: 16px; color: var(--text-subtle); }
.nav-single .nav-link { padding-inline-start: 8px; color: var(--text); font-weight: 600; }
.nav-single .nav-link > .ico { color: var(--text-muted); }
/* The page on screen: one link, marked. The shell scrolls it into view with
   a row of context around it. */
.nav-link.active {
  position: relative; background: var(--accent-subtle); color: var(--accent); font-weight: 600;
}
.nav-link.active::before {
  content: ""; position: absolute; inset-block: 6px; inset-inline-start: 0; width: 3px;
  border-start-end-radius: 3px; border-end-end-radius: 3px; background: var(--accent);
}
.nav-link.active > .ico { color: var(--accent); }
.nav-link.here { color: var(--text); }
.nav-link { scroll-margin-block: 36px; }
.nav-link.planned { color: var(--text-disabled); cursor: default; }
.nav-link.planned:hover { background: none; color: var(--text-disabled); }
.nav-soon {
  font-size: 10px; letter-spacing: .04em; color: var(--text-subtle);
  border: 1px solid var(--border); padding: 0 4px; border-radius: var(--r-sm);
}

.nav-hint { margin: 2px 0 6px; padding-inline: 32px 8px; font-size: 12px; line-height: 18px; color: var(--text-subtle); }
.nav-hint .ico { width: 12px; height: 12px; vertical-align: -1px; }
.nav-more {
  display: block; margin: 2px 0 4px; padding-block: 4px; padding-inline: 32px 8px; border: 0; border-radius: var(--r-md);
  background: none; color: var(--accent); font: inherit; font-size: 12px; cursor: pointer;
}
.nav-more:hover { text-decoration: underline; }

.nav-fav { position: relative; }
.nav-fav .nav-link { padding-inline-end: 30px; }
.nav-unfav {
  position: absolute; inset-inline-end: 4px; top: 50%; transform: translateY(-50%);
  display: grid; place-items: center; width: 24px; height: 24px; border: 0; border-radius: var(--r-sm);
  background: transparent; color: var(--text-subtle); cursor: pointer; opacity: 0;
}
.nav-unfav .ico { width: 14px; height: 14px; }
.nav-fav:hover .nav-unfav, .nav-unfav:focus-visible { opacity: 1; }
.nav-unfav:hover { background: var(--surface-3); color: var(--danger); }
.nav-fav.dragging { opacity: .5; }
.nav-fav.drop { box-shadow: inset 0 2px 0 var(--accent); }

.sidebar-foot { flex: none; padding: 6px var(--s-2); border-top: 1px solid var(--border); }
.nav-mode-btn { color: var(--text-subtle); font-size: 12px; min-height: 28px; }
.nav-mode-btn .ico { width: 16px; height: 16px; }

/* rail: icons only; a group's items fly out beside it, fixed so the pane's
   own scrolling box does not clip them. */
.app.nav-rail .nav { padding-inline: 8px; }
.app.nav-rail .sidebar .nav-label,
.app.nav-rail .sidebar .nav-chevron,
.app.nav-rail .sidebar .nav-count,
.app.nav-rail .nav-personal .nav-hint { display: none; }
.app.nav-rail .nav-group-head, .app.nav-rail .nav-single .nav-link, .app.nav-rail .nav-mode-btn {
  justify-content: center; padding: 0; min-height: 36px;
}
.app.nav-rail .nav-group-body { display: none; }
.app.nav-rail .nav-group.current > .nav-group-head { background: var(--accent-subtle); }
.app.nav-rail .nav-group.fly > .nav-group-body {
  display: block; position: fixed; inset-inline-start: calc(var(--rail-w) + 4px); width: 248px;
  max-height: calc(100vh - 16px); overflow-y: auto; padding: 6px;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--r-lg); box-shadow: var(--shadow-2); z-index: var(--z-popover);
}
.app.nav-rail .nav-group.fly > .nav-group-body .nav-label { display: inline; }
.app.nav-rail .nav-group.fly .nav-link { padding-inline-start: 10px; }
.app.nav-rail .nav-group.fly .nav-title { padding-inline-start: 10px; }
.app.nav-rail .nav-group.fly .nav-fly-title {
  display: block; padding: 6px 10px 4px; font-weight: 600; color: var(--text);
}
.app.nav-rail .nav-group.fly .nav-group-personal .nav-link > .ico,
.app.nav-rail .nav-group-personal.fly .nav-link > .ico { margin-inline-start: 0; }
.app.nav-rail .nav-group-personal.fly .nav-hint { display: block; padding-inline: 10px; }
.app.nav-rail .nav-group-personal.fly .nav-more { padding-inline-start: 10px; }
.app.nav-rail .nav-personal { padding-bottom: 4px; }

/* overlay: a drawer over the page, opened by the ☰ button; the only mode
   under 860 px. The scrim behind it closes it on a tap. */
.nav-scrim { display: none; }
.app.nav-overlay .sidebar {
  position: fixed; top: 0; inset-inline-start: 0; height: 100vh; height: 100dvh;
  width: min(300px, 86vw); transform: translateX(var(--nav-off)); visibility: hidden;
  transition: transform 180ms cubic-bezier(.2, 0, 0, 1), visibility 0s linear 180ms;
  z-index: var(--z-drawer); border-inline-end: 1px solid var(--border);
}
.app.nav-overlay.drawer-open .sidebar {
  transform: none; visibility: visible; box-shadow: var(--shadow-3);
  transition: transform 180ms cubic-bezier(.2, 0, 0, 1);
}
.app.nav-overlay.drawer-open .nav-scrim {
  display: block; position: fixed; inset: 0; z-index: calc(var(--z-drawer) - 1);
  background: var(--scrim);
}
.app.nav-overlay .sidebar-head {
  display: flex; align-items: center; gap: 8px; flex: none; height: var(--bar-h);
  padding-inline: 16px 8px; border-bottom: 1px solid var(--border);
}
.sidebar-title { flex: 1; font-weight: 600; }
.sidebar-close { margin-inline-start: auto; }

/* ── floating layers: popover, dialog, drawer ─────────────────────────── */

.shell-pop {
  position: fixed; z-index: var(--z-popover); min-width: 280px; max-width: calc(100vw - 16px);
  max-height: calc(100vh - 64px); overflow: auto;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--r-lg);
  box-shadow: var(--shadow-2);
}
.shell-pop:focus { outline: none; }

.shell-scrim {
  position: fixed; inset: 0; z-index: var(--z-modal); display: flex; justify-content: center;
  align-items: flex-start; padding: 10vh 16px 16px; background: var(--scrim);
}
.shell-scrim.side { justify-content: flex-end; align-items: stretch; padding: 0; }
.shell-dialog, .shell-drawer {
  display: flex; flex-direction: column; background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); box-shadow: var(--shadow-3);
}
.shell-dialog { width: min(560px, 100%); max-height: 80vh; border-radius: var(--r-xl); overflow: hidden; }
.shell-drawer { width: min(420px, 100vw); height: 100%; border-width: 0; border-inline-start-width: 1px; }
.shell-dialog:focus, .shell-drawer:focus { outline: none; }
.shell-dialog-head {
  display: flex; align-items: center; gap: var(--s-2); flex: none;
  padding-block: 12px; padding-inline: 16px 12px; border-bottom: 1px solid var(--border);
}
.shell-dialog-head h2 { flex: 1; margin: 0; font-size: 15px; line-height: 22px; font-weight: 600; }
.shell-dialog-head .spacer { flex: 1; }
.shell-dialog-head h2 + .spacer { display: none; }
.shell-dialog-hint { color: var(--text-subtle); font-size: 12px; }
.shell-dialog-foot {
  flex: none; padding: 10px 16px; border-top: 1px solid var(--border);
  font-size: 12px; color: var(--text-subtle);
}
@media (prefers-reduced-motion: no-preference) {
  .shell-dialog { animation: shell-in 120ms cubic-bezier(.2, 0, 0, 1); }
  .shell-drawer { animation: shell-slide 180ms cubic-bezier(.2, 0, 0, 1); }
  .shell-pop { animation: shell-in 120ms cubic-bezier(.2, 0, 0, 1); }
}
@keyframes shell-in { from { opacity: 0; transform: translateY(-4px); } }
@keyframes shell-slide { from { transform: translateX(24px); opacity: .6; } }

/* ── the command palette ──────────────────────────────────────────────── */

.shell-dialog.palette { width: min(680px, 100%); }
.palette-field {
  display: flex; align-items: center; gap: 10px; flex: none; height: 52px; padding-inline: 16px 12px;
  border-bottom: 1px solid var(--border); color: var(--text-subtle);
}
.palette-field:focus-within { box-shadow: inset 0 -2px 0 var(--accent); }
.palette-field > .ico { width: 18px; height: 18px; }
.palette-input {
  flex: 1; min-width: 0; height: 100%; border: 0; background: transparent; color: var(--text);
  font: inherit; font-size: 15px;
}
.palette-input:focus, .palette-input:focus-visible { outline: none; box-shadow: none; }
.palette-input::placeholder { color: var(--text-subtle); }
.palette-list { flex: 1; min-height: 0; max-height: min(60vh, 520px); overflow-y: auto; padding: 4px 6px 6px; }
.palette-group + .palette-group { margin-top: 2px; }
.palette-group-label {
  display: flex; align-items: center; gap: 8px; padding: 10px 10px 4px;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-subtle);
}
.palette-opt {
  display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 5px 10px;
  border-radius: var(--r-md); cursor: pointer;
}
.palette-opt.on { background: var(--accent-subtle); box-shadow: inset 0 0 0 1px var(--accent); }
.palette-ico {
  display: grid; place-items: center; flex: none; width: 28px; height: 28px; border-radius: var(--r-md);
  background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border);
}
.palette-ico .ico { width: 15px; height: 15px; }
.palette-opt.on .palette-ico { color: var(--accent); border-color: var(--accent-border); }
.palette-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.palette-label { color: var(--text); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette-label.mono { font-family: var(--mono); font-size: .94em; }
.palette-sub { font-size: 12px; line-height: 18px; color: var(--text-subtle); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette-opt.on .palette-sub { color: var(--text-muted); }
.palette-kind { flex: none; font-size: 12px; color: var(--text-subtle); white-space: nowrap; }
.palette-exact {
  flex: none; padding: 1px 7px; border-radius: var(--r-pill); font-size: 11px; font-weight: 600;
  background: var(--accent-subtle); color: var(--accent); border: 1px solid var(--accent-border);
}
.palette-note { padding: 6px 10px 8px; font-size: 12.5px; color: var(--text-subtle); }
.palette-none { padding: 24px 12px; text-align: center; }
/* Esc in the field is a reminder, not a control. */
.palette-esc { flex: none; color: var(--text-subtle); }
/* ui.js's menu() separates its groups with this (wave 1.0 stub). */
.palette-hint { margin: 4px 0; border-top: 1px solid var(--border); }
.palette-status { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.palette-spin {
  width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--border-strong);
  border-top-color: var(--accent); animation: palette-spin .8s linear infinite;
}
@keyframes palette-spin { to { transform: rotate(360deg); } }
.palette-foot {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; flex: none;
  padding: 8px 14px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-subtle);
}
.palette-foot .kbd + .kbd { margin-inline-start: 2px; }
.palette-prefixes { display: flex; flex-wrap: wrap; gap: 4px; margin-inline-start: auto; }
.palette-prefixes code {
  font: 11px/16px var(--mono); padding: 0 4px; border-radius: var(--r-sm);
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-muted);
}

/* ── the company picker ───────────────────────────────────────────────── */

.shell-dialog.picker { width: min(520px, 100%); }
.picker-search {
  display: flex; align-items: center; gap: 8px; flex: none; padding: 10px 16px;
  border-bottom: 1px solid var(--border); color: var(--text-subtle);
}
.picker-search .input { flex: 1; }
.picker-list { list-style: none; margin: 0; padding: 6px; overflow-y: auto; max-height: 50vh; }
.picker-opt {
  display: flex; align-items: center; gap: 12px; min-height: 36px; padding: 6px 10px;
  border-radius: var(--r-md); cursor: pointer;
}
.picker-opt.on { background: var(--accent-subtle); box-shadow: inset 0 0 0 1px var(--accent); }
.picker-code { flex: none; min-width: 72px; font-family: var(--mono); font-size: .94em; font-weight: 600; }
.picker-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.picker-here { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; color: var(--accent); }
.picker-here .ico { width: 13px; height: 13px; }
.picker-empty { padding: 16px 10px; color: var(--text-subtle); }

/* ── the person's menu ────────────────────────────────────────────────── */

.shell-pop.user-menu { width: 360px; }
.user-card { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.user-name { font-weight: 600; }
.user-mail { font-size: 12px; color: var(--text-subtle); word-break: break-all; }
.pref-grid { display: grid; gap: 10px; padding: 12px 16px; }
.seg { display: grid; grid-template-columns: 88px 1fr; align-items: center; gap: 8px; margin: 0; padding: 0; border: 0; min-width: 0; }
.seg legend { float: inline-start; width: 88px; padding: 0; font-size: 12.5px; color: var(--text-muted); }
.seg-opts {
  display: inline-flex; justify-self: start; border: 1px solid var(--border-input);
  border-radius: var(--r-md); overflow: hidden;
}
.seg-opt { position: relative; display: block; }
.seg-opt + .seg-opt { border-inline-start: 1px solid var(--border-input); }
.seg-opt input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.seg-opt span {
  display: block; padding: 4px 10px; font-size: 12.5px; line-height: 20px; color: var(--text-muted);
  white-space: nowrap;
}
.seg-opt input:checked + span { background: var(--accent-subtle); color: var(--accent); font-weight: 600; }
.seg-opt input:hover + span { color: var(--text); }
.seg-opt input:focus-visible + span { box-shadow: inset 0 0 0 2px var(--accent); }
.pref-row { display: grid; grid-template-columns: 88px 1fr auto; align-items: center; gap: 8px; min-width: 0; }
.pref-row > label, .pref-label { font-size: 12.5px; color: var(--text-muted); }
.pref-row .select { width: 100%; height: 30px; }
.pref-note { grid-column: 1 / -1; font-size: 12px; color: var(--text-muted); }
.pref-note:empty { display: none; }
.pref-value { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-actions { display: grid; gap: 2px; padding: 6px; border-top: 1px solid var(--border); }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 34px; padding: 0 10px;
  border: 0; border-radius: var(--r-md); background: none; color: var(--text); font: inherit; font-size: 13px;
  text-align: start; cursor: pointer;
}
.menu-item:hover { background: var(--surface-3); }
.menu-item .ico { color: var(--text-muted); }
.menu-item .kbd { margin-inline-start: auto; }
.menu-item.danger, .menu-item.danger .ico { color: var(--danger); }

/* ── notifications ────────────────────────────────────────────────────── */

.notif-body { flex: 1; min-height: 0; overflow-y: auto; }
.notif-list { list-style: none; margin: 0; padding: 0; }
.notif {
  display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: start;
  padding-block: 12px; padding-inline: 16px 12px; border-bottom: 1px solid var(--border);
}
.notif.unread { background: var(--surface-2); box-shadow: inset 3px 0 0 var(--accent); }
.notif-ico {
  display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  background: var(--info-subtle); color: var(--info);
}
.notif-ico .ico { width: 15px; height: 15px; }
.notif.tone-ok .notif-ico { background: var(--ok-subtle); color: var(--ok); }
.notif.tone-warn .notif-ico { background: var(--warn-subtle); color: var(--warn); }
.notif.tone-danger .notif-ico { background: var(--danger-subtle); color: var(--danger); }
.notif.tone-info .notif-ico { background: var(--info-subtle); color: var(--info); }
.notif-text { min-width: 0; }
.notif-title { display: block; color: var(--text); font-weight: 500; }
.notif.unread .notif-title { font-weight: 600; }
a.notif-title:hover { color: var(--accent); }
.notif-note { margin-top: 2px; font-size: 12.5px; color: var(--text-muted); }
.notif-meta { margin-top: 4px; font-size: 12px; color: var(--text-subtle); }
.notif-empty { padding: 32px 16px; text-align: center; color: var(--text-muted); }
.notif-empty b { display: block; margin-bottom: 4px; color: var(--text); }
.notif-more { margin: 10px 16px; }
.shell-btn.notif-read { width: 28px; height: 28px; }
.shell-btn.notif-read .ico { width: 15px; height: 15px; }

/* ── the shortcut sheet ───────────────────────────────────────────────── */

.shell-dialog.sheet { width: min(720px, 100%); }
.sheet-body {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px 24px;
  padding: 16px; overflow-y: auto;
}
.sheet-group h3 {
  margin: 0 0 8px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-subtle);
}
.sheet-group dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 12px; margin: 0; align-items: baseline; }
.sheet-group dt { justify-self: end; }
.sheet-group dd { margin: 0; color: var(--text-muted); }
.sheet-help { grid-column: 1 / -1; color: var(--text-muted); }

/* ── sign-in ──────────────────────────────────────────────────────────── */
.login-page { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.login-card { width: min(370px, 100%); }
.login-card .card-body { padding: 22px; }
.login-brand { display: flex; align-items: center; gap: 9px; justify-content: center; margin-bottom: 18px; }

/* ── narrower screens ─────────────────────────────────────────────────── */

@media (max-width: 1180px) {
  .shell-user-name { display: none; }
  .shell-user { padding-inline-end: 2px; }
}
@media (max-width: 1000px) {
  .shell-entity-name { max-width: 120px; }
  .shell-search-text { font-size: 12.5px; }
}
/* A phone: the drawer, 40 px targets, and the bar down to what a thumb
   needs - menu, company, search, the bell and the person. Help and the star
   are in the person's menu and the palette. */
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-areas: "bar" "main"; }
  #menu-btn { display: inline-grid; }
  .header.shellbar { gap: 4px; padding-inline: 4px 8px; }
  .shell-btn { width: 40px; height: 40px; }
  .shell-brand .brand-name, .shell-entity-name, .shell-entity-chev,
  .shell-search-text, .shell-search .kbd, .shell-btn.star, .shell-tools > .shell-btn:not(.bell) { display: none; }
  .shell-entity { max-width: 110px; height: 40px; padding-inline: 8px; margin: 0; }
  .shell-brand { min-width: 40px; min-height: 40px; justify-content: center; }
  .shell-center { justify-content: flex-end; padding: 0; }
  .shell-search { width: 40px; height: 40px; padding: 0; justify-content: center; border: 0; background: transparent; color: var(--text-muted); }
  .shell-search .ico { width: 18px; height: 18px; }
  .shell-user { height: 40px; min-width: 40px; justify-content: center; padding: 0 4px; margin: 0; }
  .nav-link, .nav-group-head { min-height: 40px; }
  .content { padding: var(--s-4); }
  .shell-scrim { padding: 8px; align-items: flex-start; }
  .shell-dialog { max-height: calc(100dvh - 16px); }
  .palette-foot .palette-prefixes, .palette-foot > span:nth-child(3) { display: none; }
  /* A phone has one mode; the button that changes it has nothing to do. */
  .sidebar-foot { display: none; }
  .shell-pop.user-menu { width: calc(100vw - 16px); }
  /* Everything a finger presses in the shell's own layers is 40 px too
     (PLAN 3.15): the menu's choices, its selects and buttons, the
     notifications' buttons, the favourite's remove. */
  .seg-opt span { padding-block: 10px; }
  .pref-row .select { height: 40px; }
  .menu-item, .nav-more { min-height: 40px; }
  .shell-pop .btn-sm, .shell-drawer .btn-sm { height: 40px; padding-inline: 12px; font-size: 13px; }
  .shell-btn.notif-read { width: 40px; height: 40px; }
  /* The title link grows to a finger's height without moving the row. */
  a.notif-title { padding-block: 10px; margin-block: -10px; }
  .nav-fav .nav-link { padding-inline-end: 44px; }
  .nav-unfav { inset-inline-end: 0; width: 40px; height: 40px; }
}
/* A touch screen has no hover to reveal a favourite's remove button. */
@media (hover: none) {
  .nav-unfav { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .app.nav-overlay .sidebar, .app.nav-overlay.drawer-open .sidebar, .nav-chevron, .shell-btn { transition: none; }
  .palette-spin { animation: none; }
}

/* What the router shows for a path no route knows, or a record that is not
   there (app.js notFound). */
.shell-notfound { max-width: 560px; margin-inline: auto; }
.shell-notfound h1 { margin-bottom: 6px; font-size: 18px; }
.shell-notfound .row { justify-content: center; }

/* The notifications drawer: the shared drawer, a little wider for a title and its time on one line. */
.shell-drawer.notif-drawer { width: min(440px, 100vw); }
