/* ==========================================================================
   GLOBAL TOOLBAR: app/styles/toolbar.css
   --------------------------------------------------------------------------
   The top bar, its menus (Brand, Create, AI status, Account), the search
   palette, the notifications drawer and the Help panel.
   Reference: docs/design-system/global-toolbar.md.

   - Tokens only (app/styles/tokens.css, docs/DESIGN-CONTRACT.md): no hex,
     no new token names. --header-height is the shell's layout variable
     (styles.css), shared with the sidebar's logo row so the corner lines up.
   - Loaded after styles.css and theme.css. Selectors carry the .gtb /
     .gtb-* scope, so they win over the legacy top-bar rules without
     !important; the two !important lines below answer legacy !important.
   - The signed-out shell hides the bar with display:none !important
     (styles.css SIGNED-OUT-SHELL); nothing here touches that.
   - Motion: transform and opacity only, from the motion tokens, so
     prefers-reduced-motion (which zeroes the durations) makes every reveal
     instant. Nothing loops.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. The bar
   -------------------------------------------------------------------------- */
#app-root header.top-bar.gtb {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  height: var(--header-height, 64px);
  padding: 0 var(--space-lg) 0 var(--space-md);
  background: var(--surface-page);
  border-bottom: 1px solid var(--border-subtle) !important;
  box-shadow: none !important;   /* the legacy glow (styles.css ~23788) */
  font-family: inherit;
  color: var(--text-primary);
}

.gtb-start {
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
  flex: 0 0 auto;
}
.gtb-center {
  flex: 1 1 auto;
  min-width: 160px;
  display: flex;
  justify-content: flex-start;
}
#app-root .gtb .gtb-end {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2xs);
  flex: 0 0 auto;
  min-width: max-content;
  margin-left: auto;
}

/* --------------------------------------------------------------------------
   2. Icon buttons, tooltips, keys
   -------------------------------------------------------------------------- */
#app-root .gtb .gtb-icon-btn,
.gtb-layer .gtb-icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: var(--control-height-md);
  height: var(--control-height-md);
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  box-shadow: none;
  transform: none;
  transition: var(--transition-control);
}
#app-root .gtb .gtb-icon-btn:hover,
.gtb-layer .gtb-icon-btn:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}
#app-root .gtb .gtb-icon-btn:active { background: var(--surface-pressed); }
#app-root .gtb .gtb-icon-btn[aria-expanded="true"]:not(.gtb-collapse) {
  background: var(--surface-selected);
  color: var(--accent-text);
}
.gtb .tb-icon,
.gtb-menu .tb-icon { display: block; flex-shrink: 0; }

/* One focus ring for every toolbar control. */
#app-root .gtb :is(button, a, [tabindex]):focus-visible,
.gtb-menu :is(button, a, [tabindex]):focus-visible,
.gtb-layer :is(button, a, input, [tabindex]):focus-visible {
  outline: var(--focus-outline);
  outline-offset: var(--focus-ring-offset);
  box-shadow: none;
}
#app-root .gtb :is(button, a):focus:not(:focus-visible) { outline: none; box-shadow: none; }

/* Tooltips: icon-only controls carry data-tip as well as an aria-label.
   Pointer hover (after a short pause) and keyboard focus; never on touch,
   never while the control's own menu is open. */
@media (hover: hover) {
  .gtb [data-tip]::after {
    content: attr(data-tip);
    position: absolute;
    top: calc(100% + var(--space-xs));
    left: 50%;
    z-index: var(--z-tooltip);
    width: max-content;
    max-width: 240px;
    padding: var(--space-2xs) var(--space-xs);
    border-radius: var(--radius-badge);
    background: var(--text-primary);
    color: var(--surface-page);
    font-size: var(--font-size-caption);
    font-weight: var(--font-weight-medium);
    line-height: var(--line-height-control);
    letter-spacing: 0;
    text-transform: none;
    white-space: normal;
    pointer-events: none;
    opacity: 0;
    translate: -50% -2px;
    transition: opacity var(--duration-fast) var(--ease-standard), translate var(--duration-fast) var(--ease-standard);
    transition-delay: 0s;
  }
  .gtb [data-tip]:hover::after,
  .gtb [data-tip]:focus-visible::after {
    opacity: 1;
    translate: -50% 0;
    transition-delay: 450ms, 450ms;
  }
  .gtb [data-tip]:focus-visible::after { transition-delay: 0s, 0s; }
  .gtb [data-tip][aria-expanded="true"]::after { display: none; }
  /* The last controls sit at the right edge: anchor their tips there. */
  .gtb .gtb-end > :nth-last-child(-n+3)[data-tip]::after,
  .gtb .gtb-end [data-tip].theme-toggle::after { left: auto; right: 0; translate: 0 -2px; }
  .gtb .gtb-end > :nth-last-child(-n+3)[data-tip]:is(:hover, :focus-visible)::after,
  .gtb .gtb-end [data-tip].theme-toggle:is(:hover, :focus-visible)::after { translate: 0 0; }
  /* The search field already says what it is. */
  .gtb .gtb-search[data-tip]::after,
  .gtb .gtb-brand[data-tip]::after { display: none; }
}

.gtb-kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 var(--space-2xs);
  border: 1px solid var(--border-default);
  border-bottom-width: 2px;
  border-radius: var(--radius-badge);
  background: var(--surface-raised);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: var(--font-size-caption);
  font-weight: var(--font-weight-medium);
  line-height: 1;
  white-space: nowrap;
}

.gtb-tag {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  padding: var(--space-3xs) var(--space-xs);
  border-radius: var(--radius-badge);
  background: var(--neutral-subtle);
  color: var(--neutral-text);
  font-size: var(--font-size-caption);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-control);
  white-space: nowrap;
}
.gtb-tag--accent { background: var(--accent-subtle); color: var(--accent-text); }
.gtb-tag[hidden] { display: none; }

.gtb-eyebrow {
  font-size: var(--font-size-eyebrow);
  font-weight: var(--font-weight-semibold);
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   3. Start: menu, Home mark, collapse
   -------------------------------------------------------------------------- */
#app-root .gtb .mobile-menu-btn { display: none; }
.gtb-home { display: none; }
#app-root .gtb .gtb-collapse { display: inline-flex; margin-right: var(--space-2xs); }

/* --------------------------------------------------------------------------
   4. Center: the search field
   -------------------------------------------------------------------------- */
#app-root .gtb .gtb-search {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  width: 100%;
  max-width: 520px;
  height: var(--control-height-md);
  padding: 0 var(--space-xs) 0 var(--space-sm);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-control);
  background: var(--surface-inset);
  color: var(--text-muted);
  font: inherit;
  font-size: var(--font-size-body);
  text-align: left;
  cursor: text;
  box-shadow: none;
  transition: var(--transition-control);
}
#app-root .gtb .gtb-search:hover { border-color: var(--border-control); color: var(--text-secondary); }
#app-root .gtb .gtb-search[aria-expanded="true"] { border-color: var(--accent-border); }
.gtb-search__text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   5. End: trial chip, AI status, Create, bell, Help, theme, avatar
   -------------------------------------------------------------------------- */
#app-root .gtb .trial-chip {
  height: 32px;
  margin-right: var(--space-2xs);
  border-color: var(--border-default);
  color: var(--text-secondary);
  font-size: var(--font-size-caption);
}
#app-root .gtb .trial-chip:hover { border-color: var(--border-control); color: var(--text-primary); }
#app-root .gtb .trial-chip--soon .trial-chip__dot { background: var(--warning-solid); }

/* AI status */
.gtb-ai-wrap,
.gtb-create-wrap,
.gtb-account-wrap { position: relative; display: flex; }
#app-root .gtb .gtb-ai {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  height: 32px;
  max-width: 220px;
  margin-right: var(--space-2xs);
  padding: 0 var(--space-sm) 0 var(--space-xs);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: var(--font-size-body-sm);
  font-weight: var(--font-weight-medium);
  white-space: nowrap;
  cursor: pointer;
  transition: var(--transition-control);
}
#app-root .gtb .gtb-ai[hidden] { display: none; }
#app-root .gtb .gtb-ai:hover { border-color: var(--border-control); color: var(--text-primary); }
#app-root .gtb .gtb-ai[aria-expanded="true"] { border-color: var(--accent-border); background: var(--surface-selected); color: var(--text-primary); }
#app-root .gtb .gtb-ai[data-tone="warning"] { border-color: var(--warning-border); background: var(--warning-subtle); color: var(--warning-text); }
.gtb-ai__label { overflow: hidden; text-overflow: ellipsis; }
.gtb-ai__dot {
  width: 8px;
  height: 8px;
  flex-shrink: 0;
  border-radius: var(--radius-pill);
  background: var(--success-solid);
}
.gtb-ai[data-tone="warning"] .gtb-ai__dot { background: var(--warning-solid); }
.gtb-ai[data-tone="neutral"] .gtb-ai__dot { background: transparent; box-shadow: inset 0 0 0 1.5px var(--text-muted); }

/* Create: the toolbar's one primary button */
#app-root .gtb .gtb-create {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  height: var(--control-height-md);
  margin: 0 var(--space-xs) 0 var(--space-2xs);
  padding: 0 var(--space-sm) 0 var(--space-sm);
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  background: var(--accent-fill);
  color: var(--on-accent);
  font: inherit;
  font-size: var(--font-size-body);
  font-weight: var(--font-weight-semibold);
  white-space: nowrap;
  cursor: pointer;
  box-shadow: var(--shadow-button);
  transition: var(--transition-control);
}
#app-root .gtb .gtb-create:hover { background: var(--accent-fill-hover); }
#app-root .gtb .gtb-create:active,
#app-root .gtb .gtb-create[aria-expanded="true"] { background: var(--accent-fill-pressed); }
.gtb-create__chev { transition: rotate var(--duration-base) var(--ease-standard); opacity: 0.85; }
.gtb-create[aria-expanded="true"] .gtb-create__chev { rotate: 180deg; }

/* Bell: the count is a pill, not a dot */
#app-root .gtb .notif-bell .notif-dot { display: none; }
.gtb-count {
  position: absolute;
  top: 1px;
  right: 0;
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 var(--space-2xs);
  border: 2px solid var(--surface-page);
  border-radius: var(--radius-pill);
  background: var(--accent-fill);
  color: var(--on-accent);
  font-size: var(--font-size-caption);
  font-weight: var(--font-weight-bold);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  box-sizing: content-box;
  pointer-events: none;
}
.gtb-count[hidden] { display: none; }

/* Theme toggle: show the theme you'd switch to */
#app-root .gtb .theme-toggle .icon-sun { display: none; }
#app-root .gtb .theme-toggle .icon-moon { display: block; }
html.dark #app-root .gtb .theme-toggle .icon-sun { display: block; }
html.dark #app-root .gtb .theme-toggle .icon-moon { display: none; }

/* Avatar: the user's photo, or their initials on the brand fill */
#app-root .gtb .gtb-avatar {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  margin-left: var(--space-xs);
  padding: 0;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--accent-fill);
  color: var(--on-accent);
  font: inherit;
  font-size: var(--font-size-body-sm);
  font-weight: var(--font-weight-bold);
  letter-spacing: 0.02em;
  overflow: hidden;
  cursor: pointer;
  box-shadow: 0 0 0 2px var(--surface-page), 0 0 0 3px var(--border-default);
  transition: var(--transition-control);
}
#app-root .gtb .gtb-avatar:hover,
#app-root .gtb .gtb-avatar[aria-expanded="true"] { box-shadow: 0 0 0 2px var(--surface-page), 0 0 0 3px var(--accent); }
#app-root .gtb .gtb-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }

/* --------------------------------------------------------------------------
   6. Menus (Brand, Create, AI status, Account)
   -------------------------------------------------------------------------- */
:is(#app-root .gtb, body) .gtb-menu {
  position: absolute;
  top: calc(100% + var(--space-xs));
  right: 0;
  left: auto;
  z-index: var(--z-popover);
  display: flex;
  flex-direction: column;
  gap: var(--space-3xs);
  width: max-content;
  min-width: 260px;
  max-width: min(380px, calc(100vw - 2 * var(--space-md)));
  max-height: calc(100dvh - var(--header-height, 64px) - var(--space-xl));
  overflow-y: auto;
  padding: var(--space-xs);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-card);
  background: var(--surface-overlay);
  color: var(--text-primary);
  box-shadow: var(--shadow-overlay);
  font-size: var(--font-size-body);
  text-align: left;
  /* The file-tab reveal: the sheet slides out from under its button. */
  opacity: 0;
  translate: 0 -6px;
  clip-path: inset(0 0 100% 0 round var(--radius-card));
  transition:
    opacity var(--duration-base) var(--ease-enter),
    translate var(--duration-base) var(--ease-enter),
    clip-path var(--duration-slow) var(--ease-enter);
}
:is(#app-root .gtb, body) .gtb-menu[data-state="open"] {
  opacity: 1;
  translate: 0 0;
  clip-path: inset(-8px -8px -24px -8px round var(--radius-card));
}
:is(#app-root .gtb, body) .gtb-menu[hidden] { display: none; }
:is(#app-root .gtb, body) .gtb-menu:focus { outline: none; }
:is(#app-root .gtb, body) .gtb-menu--brand { left: 0; right: auto; min-width: 280px; }

.gtb-menu__heading {
  padding: var(--space-2xs) var(--space-xs) var(--space-3xs);
  color: var(--text-muted);
  font-size: var(--font-size-caption);
  font-weight: var(--font-weight-semibold);
}
:is(#app-root .gtb, body) .gtb-menu .gtb-menu__item,
:is(#app-root .gtb, body) .gtb-menu .workspace-popover-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  width: 100%;
  min-height: 36px;
  padding: var(--space-xs) var(--space-sm) var(--space-xs) var(--space-xs);
  border: 0;
  border-radius: var(--radius-control);
  background: transparent;
  color: var(--text-primary);
  font: inherit;
  font-size: var(--font-size-body);
  font-weight: var(--font-weight-regular);
  line-height: var(--line-height-control);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: var(--transition-control);
}
:is(#app-root .gtb, body) .gtb-menu .gtb-menu__item:hover,
:is(#app-root .gtb, body) .gtb-menu .gtb-menu__item:focus-visible,
:is(#app-root .gtb, body) .gtb-menu .workspace-popover-item:hover { background: var(--surface-hover); }
:is(#app-root .gtb, body) .gtb-menu .gtb-menu__item[aria-disabled="true"] { color: var(--text-disabled); cursor: not-allowed; }
:is(#app-root .gtb, body) .gtb-menu .gtb-menu__item[aria-disabled="true"] :is(.gtb-menu__desc, .gtb-create-item__icon) { color: var(--text-disabled); }
:is(#app-root .gtb, body) .gtb-menu .gtb-menu__item > .tb-icon { color: var(--text-secondary); }
:is(#app-root .gtb, body) .gtb-menu [aria-checked="true"].gtb-menu__item {
  background: var(--accent-subtle);
  color: var(--accent-text);
}
.gtb-menu__label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gtb-menu__text { display: flex; flex-direction: column; gap: var(--space-3xs); flex: 1; min-width: 0; }
.gtb-menu__text .gtb-menu__label { font-weight: var(--font-weight-semibold); white-space: normal; }
.gtb-menu__desc { color: var(--text-secondary); font-size: var(--font-size-body-sm); line-height: var(--line-height-title); }
.gtb-menu__check { color: var(--accent-text); display: inline-flex; }
.gtb-menu__sep { height: 1px; margin: var(--space-2xs) var(--space-xs); background: var(--border-subtle); }
.gtb-menu__note {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  margin: 0 0 var(--space-2xs);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-control);
  background: var(--info-subtle);
  color: var(--info-text);
  font-size: var(--font-size-body-sm);
}

/* Create menu: a folder tab labels the sheet. */
:is(#app-root .gtb, body) .gtb-menu--create { width: 340px; padding-top: var(--space-2xs); }
.gtb-menu__tab {
  align-self: flex-start;
  margin: 0 0 var(--space-2xs) var(--space-xs);
  padding: var(--space-3xs) var(--space-sm);
  border-radius: var(--radius-badge) var(--radius-badge) 0 0;
  background: var(--surface-inset);
  box-shadow: inset 0 -1px 0 var(--border-subtle);
  color: var(--text-muted);
  font-size: var(--font-size-eyebrow);
  font-weight: var(--font-weight-semibold);
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  translate: 0 4px;
  opacity: 0;
  transition: translate var(--duration-slow) var(--ease-enter) 60ms, opacity var(--duration-base) var(--ease-enter) 60ms;
}
.gtb-menu[data-state="open"] .gtb-menu__tab { translate: 0 0; opacity: 1; }
:is(#app-root .gtb, body) .gtb-menu .gtb-create-item { align-items: flex-start; }
.gtb-create-item__icon {
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-control);
  background: var(--surface-raised);
  color: var(--accent-text);
}
.gtb-create-item .gtb-tag { align-self: center; }

/* Brand menu items */
:is(#app-root .gtb, body) .gtb-menu .gtb-brand-item.is-active { background: var(--accent-subtle); color: var(--accent-text); }

/* AI status panel */
:is(#app-root .gtb, body) .gtb-menu--ai { width: 340px; padding: var(--space-md); gap: var(--space-sm); }
.gtb-ai-panel__head { position: relative; padding-right: 96px; }
.gtb-ai-panel__title {
  margin: var(--space-2xs) 0 0;
  font-size: var(--font-size-h3);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-title);
  letter-spacing: var(--tracking-title);
  color: var(--text-primary);
}
.gtb-ai-panel__summary { margin: 0; color: var(--text-secondary); font-size: var(--font-size-body-sm); line-height: var(--line-height-body); }
.gtb-ai-rows { margin: 0; display: grid; gap: var(--space-2xs); }
.gtb-ai-row {
  display: grid;
  gap: var(--space-3xs);
  padding: var(--space-xs) var(--space-sm);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-control);
  background: var(--surface-raised);
}
.gtb-ai-row dt { display: flex; align-items: center; gap: var(--space-xs); font-size: var(--font-size-caption); font-weight: var(--font-weight-semibold); color: var(--text-muted); }
.gtb-ai-row dd { margin: 0; font-size: var(--font-size-body-sm); color: var(--text-primary); }
.gtb-ai-row[data-ok="true"] dt .tb-icon { color: var(--success-text); }
.gtb-ai-panel__actions { display: grid; gap: var(--space-3xs); margin: 0 calc(-1 * var(--space-xs)); }

/* The stamp: lands once when the panel opens on a working connection.
   Its overshoot belongs to the stamp alone (brand-messaging.md §3). */
.gtb-stamp {
  position: absolute;
  top: var(--space-2xs);
  right: 0;
  padding: var(--space-3xs) var(--space-xs);
  border: 2px solid currentColor;
  border-radius: var(--radius-badge);
  color: var(--accent-text);
  font-size: var(--font-size-caption);
  font-weight: var(--font-weight-heavy);
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  rotate: -6deg;
  opacity: 0.85;
  pointer-events: none;
}
.gtb-menu[data-state="open"] .gtb-stamp {
  animation: gtb-stamp-land var(--duration-slow) cubic-bezier(0.2, 0.9, 0.3, 1.25) 120ms backwards;
}
@keyframes gtb-stamp-land {
  from { opacity: 0; scale: 1.35; rotate: -14deg; }
  to   { opacity: 0.85; scale: 1; rotate: -6deg; }
}

/* Account menu (legacy .account-popover parts, restyled) */
:is(#app-root .gtb, body) .gtb-menu--account { width: 300px; padding: var(--space-xs); }
#app-root .gtb .account-popover__user { display: flex; align-items: center; gap: var(--space-sm); padding: var(--space-xs); }
#app-root .gtb .account-popover__avatar {
  display: inline-grid; place-items: center; flex-shrink: 0;
  width: 40px; height: 40px; border-radius: var(--radius-pill); overflow: hidden;
  background: var(--accent-fill); color: var(--on-accent);
  font-size: var(--font-size-body); font-weight: var(--font-weight-bold);
}
#app-root .gtb .account-popover__avatar img { width: 100%; height: 100%; object-fit: cover; }
#app-root .gtb .account-popover__info { min-width: 0; }
#app-root .gtb .account-popover__name { font-size: var(--font-size-body); font-weight: var(--font-weight-semibold); color: var(--text-primary); }
#app-root .gtb .account-popover__email { font-size: var(--font-size-body-sm); color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#app-root .gtb .account-popover__tier {
  align-self: flex-start;
  margin: 0 var(--space-xs) var(--space-2xs);
  padding: var(--space-3xs) var(--space-xs);
  border: 0;
  border-radius: var(--radius-badge);
  background: var(--accent-subtle);
  color: var(--accent-text);
  font-size: var(--font-size-caption);
  font-weight: var(--font-weight-semibold);
  font-family: inherit;
  letter-spacing: 0;
  text-transform: none;
}
#app-root .gtb .account-popover__tier:empty { display: none; }
#app-root .gtb .account-popover__ai-mode {
  margin: 0;
  border: 1px solid var(--border-subtle);
  background: var(--surface-raised);
  font-size: var(--font-size-body-sm);
  color: var(--text-secondary);
}
#app-root .gtb .account-popover__ai-mode[hidden] { display: none; }
#app-root .gtb .account-popover__ai-mode-dot {
  width: 8px; height: 8px; flex-shrink: 0; border-radius: var(--radius-pill); background: var(--success-solid);
}
#app-root .gtb .account-popover__ai-mode[data-tone="warning"] .account-popover__ai-mode-dot { background: var(--warning-solid); }
#app-root .gtb .account-popover__ai-mode[data-tone="neutral"] .account-popover__ai-mode-dot { background: transparent; box-shadow: inset 0 0 0 1.5px var(--text-muted); }
#app-root .gtb .account-popover__divider { height: 1px; margin: var(--space-2xs) var(--space-xs); background: var(--border-subtle); }
#app-root .gtb .account-popover__item--danger { color: var(--danger-text); }
:is(#app-root .gtb, body) .gtb-menu .account-popover__item--danger .tb-icon { color: var(--danger-text); }
#app-root .gtb .account-popover__theme {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-sm);
  padding: var(--space-2xs) var(--space-xs) var(--space-2xs) var(--space-sm);
  font-size: var(--font-size-body);
}
.gtb-seg {
  display: inline-flex;
  padding: var(--space-3xs);
  border-radius: var(--radius-control);
  background: var(--surface-inset);
  box-shadow: inset 0 0 0 1px var(--border-subtle);
}
#app-root .gtb .gtb-seg__item {
  display: inline-flex; align-items: center; gap: var(--space-2xs);
  height: 28px; padding: 0 var(--space-xs);
  border: 0; border-radius: var(--radius-badge);
  background: transparent; color: var(--text-secondary);
  font: inherit; font-size: var(--font-size-caption); font-weight: var(--font-weight-medium);
  cursor: pointer; transition: var(--transition-control);
}
#app-root .gtb .gtb-seg__item:hover { color: var(--text-primary); }
#app-root .gtb .gtb-seg__item[aria-checked="true"] {
  background: var(--surface-overlay);
  color: var(--text-primary);
  box-shadow: 0 0 0 1px var(--border-control), var(--shadow-raised);
}

/* --------------------------------------------------------------------------
   7. Search palette (body-mounted: .cmd-palette-overlay)
   -------------------------------------------------------------------------- */
html body #cmd-palette {
  z-index: var(--z-modal);
  padding: min(12vh, 120px) var(--space-md) var(--space-md);
  background: var(--scrim);
  backdrop-filter: none;
  opacity: 0;
  transition: opacity var(--duration-base) var(--ease-standard);
}
html body #cmd-palette[data-state="open"] { opacity: 1; }
html body #cmd-palette[hidden] { display: none; }
/* Layered paper: two sheets peek out under the card, then settle. */
html body #cmd-palette .cmd-palette-modal {
  position: relative;
  width: 640px;
  max-width: 100%;
  max-height: min(560px, calc(100dvh - 2 * var(--space-2xl)));
  border: 1px solid var(--border-default);
  border-radius: var(--radius-modal);
  background: var(--surface-overlay);
  color: var(--text-primary);
  overflow: hidden;
  box-shadow:
    0 6px 0 -2px var(--surface-raised), 0 6px 0 -1px var(--border-subtle),
    0 12px 0 -4px var(--surface-inset), 0 12px 0 -3px var(--border-subtle),
    var(--shadow-modal);
  translate: 0 -10px;
  scale: 0.985;
  transition: translate var(--duration-slow) var(--ease-enter), scale var(--duration-slow) var(--ease-enter);
}
html body #cmd-palette[data-state="open"] .cmd-palette-modal { translate: 0 0; scale: 1; }
html body #cmd-palette .cmd-palette-input-row {
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-md) var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border-subtle);
  background: transparent;
}
html body #cmd-palette .cmd-search-icon,
html body #cmd-palette .cmd-search-icon svg { color: var(--accent-text); opacity: 1; }
html body #cmd-palette .cmd-input {
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  outline: none;
  color: var(--text-primary);
  font: inherit;
  font-size: var(--font-size-body-lg);
}
/* The field's focus is the caret: the whole card is the focus surface. */
html body #cmd-palette .cmd-input:focus,
html body #cmd-palette .cmd-input:focus-visible { outline: none; box-shadow: none; border: 0; }
html body #cmd-palette .cmd-input::placeholder { color: var(--text-muted); }
html body #cmd-palette .cmd-close-x {
  width: 32px; height: 32px; border-radius: var(--radius-control);
  background: transparent; color: var(--text-secondary);
}
html body #cmd-palette .cmd-close-x:hover { background: var(--surface-hover); color: var(--text-primary); }
html body #cmd-palette .cmd-results { padding: var(--space-xs); scroll-padding: var(--space-xs); }
html body #cmd-palette .cmd-group + .cmd-group { margin-top: var(--space-2xs); }
html body #cmd-palette .cmd-section-label {
  padding: var(--space-xs) var(--space-sm) var(--space-2xs);
  color: var(--text-muted);
  font-size: var(--font-size-eyebrow);
  font-weight: var(--font-weight-semibold);
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
}
html body #cmd-palette .cmd-result-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  min-height: 44px;
  padding: var(--space-xs) var(--space-sm);
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
}
html body #cmd-palette .cmd-result-item.focused {
  background: var(--surface-selected);
  border-color: var(--accent-border);
}
html body #cmd-palette .cmd-result-icon {
  display: inline-grid; place-items: center; flex-shrink: 0;
  width: 32px; height: 32px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-control);
  background: var(--surface-raised);
  color: var(--text-secondary);
}
html body #cmd-palette .cmd-result-item.focused .cmd-result-icon { color: var(--accent-text); border-color: var(--accent-border); }
.cmd-result-main { display: flex; flex-direction: column; gap: var(--space-3xs); flex: 1; min-width: 0; }
html body #cmd-palette .cmd-result-label { font-size: var(--font-size-body); font-weight: var(--font-weight-medium); color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmd-result-desc { font-size: var(--font-size-body-sm); color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
html body #cmd-palette .cmd-result-hint { flex-shrink: 0; font-size: var(--font-size-caption); color: var(--text-muted); white-space: nowrap; }
.cmd-result-enter { display: inline-flex; color: var(--accent-text); opacity: 0; }
.cmd-result-item.focused .cmd-result-enter { opacity: 1; }
.cmd-palette-overlay mark { background: var(--accent-subtle); color: var(--accent-text); border-radius: 2px; padding: 0 1px; }
html body #cmd-palette .cmd-nav-pills { display: flex; flex-wrap: wrap; gap: var(--space-2xs); padding: var(--space-2xs) var(--space-xs) var(--space-xs); }
html body #cmd-palette .cmd-nav-pill {
  display: inline-flex; align-items: center; gap: var(--space-2xs);
  height: 32px; padding: 0 var(--space-sm);
  border: 1px solid var(--border-default); border-radius: var(--radius-pill);
  background: var(--surface-raised); color: var(--text-secondary);
  font-size: var(--font-size-body-sm); font-weight: var(--font-weight-medium);
  cursor: pointer;
}
html body #cmd-palette .cmd-nav-pill.focused { border-color: var(--accent-border); background: var(--accent-subtle); color: var(--accent-text); }
.cmd-searching { display: flex; align-items: center; gap: var(--space-xs); padding: var(--space-sm); color: var(--text-muted); font-size: var(--font-size-body-sm); }
html body #cmd-palette .cmd-empty {
  display: flex; flex-direction: column; align-items: center; gap: var(--space-xs);
  padding: var(--space-2xl) var(--space-md); color: var(--text-secondary); text-align: center;
}
.cmd-empty__hint { color: var(--text-muted); font-size: var(--font-size-body-sm); }
html body #cmd-palette .cmd-footer {
  display: flex; align-items: center; gap: var(--space-md);
  padding: var(--space-xs) var(--space-md);
  border-top: 1px solid var(--border-subtle);
  background: var(--surface-inset);
  color: var(--text-muted);
  font-size: var(--font-size-caption);
}
html body #cmd-palette .cmd-footer-hint { display: inline-flex; align-items: center; gap: var(--space-2xs); }
html body #cmd-palette .cmd-footer-hint kbd { background: var(--surface-raised); }
.cmd-footer-scope { margin-left: auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --------------------------------------------------------------------------
   8. Notifications drawer (body-mounted)
   -------------------------------------------------------------------------- */
html body #notif-backdrop { z-index: calc(var(--z-drawer) - 1); background: var(--scrim); }
html body #notif-drawer {
  top: 0;
  height: 100dvh;
  width: 400px;
  max-width: 100vw;
  z-index: var(--z-drawer);
  border-left: 1px solid var(--border-default);
  border-radius: var(--radius-modal) 0 0 var(--radius-modal);
  background: var(--surface-page);
  box-shadow: var(--shadow-modal);
  color: var(--text-primary);
  visibility: hidden;
  transition: transform var(--duration-slow) var(--ease-enter), visibility 0s linear var(--duration-slow);
}
html body #notif-drawer.open { visibility: visible; transition: transform var(--duration-slow) var(--ease-enter), visibility 0s; }
html body #notif-drawer-header {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-sm);
  padding: var(--space-md) var(--space-md) var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border-subtle);
}
html body #notif-drawer-title { margin: 0; font-size: var(--font-size-h3); font-weight: var(--font-weight-bold); letter-spacing: var(--tracking-title); color: var(--text-primary); }
.notif-drawer-actions { display: flex; align-items: center; gap: var(--space-2xs); }
.gtb-text-btn {
  height: 32px; padding: 0 var(--space-sm);
  border: 0; border-radius: var(--radius-control);
  background: transparent; color: var(--accent-text);
  font: inherit; font-size: var(--font-size-body-sm); font-weight: var(--font-weight-semibold);
  cursor: pointer; transition: var(--transition-control);
}
.gtb-text-btn:hover:not(:disabled) { background: var(--surface-hover); }
.gtb-text-btn:disabled { color: var(--text-disabled); cursor: default; }
.notif-drawer :is(button, a):focus-visible { outline: var(--focus-outline); outline-offset: var(--focus-ring-offset); }
.notif-drawer-body { flex: 1; overflow-y: auto; padding: var(--space-sm) var(--space-md) var(--space-xl); }
.notif-section + .notif-section { margin-top: var(--space-lg); }
.notif-section__title {
  margin: var(--space-2xs) var(--space-2xs) var(--space-xs);
  color: var(--text-muted);
  font-size: var(--font-size-eyebrow);
  font-weight: var(--font-weight-semibold);
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
}
.notif-attn-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-xs); }
.notif-attn { position: relative; }
.notif-attn__link {
  display: flex; align-items: flex-start; gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md) var(--space-sm) var(--space-sm);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-card);
  background: var(--surface-raised);
  color: var(--text-primary);
  text-decoration: none;
  box-shadow: var(--shadow-raised);
  transition: var(--transition-control);
}
.notif-attn__link:hover { border-color: var(--border-control); }
.notif-attn__icon {
  display: inline-grid; place-items: center; flex-shrink: 0;
  width: 36px; height: 36px; border-radius: var(--radius-control);
  background: var(--neutral-subtle); color: var(--neutral-text);
}
.notif-attn--accent .notif-attn__icon { background: var(--accent-subtle); color: var(--accent-text); }
.notif-attn--danger .notif-attn__icon { background: var(--danger-subtle); color: var(--danger-text); }
.notif-attn--warning .notif-attn__icon { background: var(--warning-subtle); color: var(--warning-text); }
.notif-attn__body { display: flex; flex-direction: column; gap: var(--space-3xs); flex: 1; min-width: 0; }
.notif-attn__title { font-weight: var(--font-weight-semibold); font-size: var(--font-size-body); }
.notif-attn__text { color: var(--text-secondary); font-size: var(--font-size-body-sm); line-height: var(--line-height-title); }
.notif-attn__cta {
  display: inline-flex; align-items: center; gap: var(--space-3xs); align-self: center; flex-shrink: 0;
  color: var(--accent-text); font-size: var(--font-size-body-sm); font-weight: var(--font-weight-semibold);
}
.notif-attn__dismiss {
  position: absolute; top: var(--space-2xs); right: var(--space-2xs);
  display: inline-grid; place-items: center; width: 28px; height: 28px;
  border: 0; border-radius: var(--radius-control); background: transparent; color: var(--text-muted); cursor: pointer;
}
.notif-attn__dismiss:hover { background: var(--surface-hover); color: var(--text-primary); }
.notif-attn:has(.notif-attn__dismiss) .notif-attn__cta { margin-right: var(--space-lg); }

/* Updates: correspondence cards. A postmark-style time, a wax-seal dot
   for unread. */
html body #notif-drawer .notif-list { display: grid; gap: var(--space-xs); overflow: visible; }
html body #notif-drawer .notif-item {
  position: relative;
  display: flex;
  align-items: stretch;
  gap: 0;
  padding: 0;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  background: var(--surface-raised);
  cursor: default;
}
html body #notif-drawer .notif-item:hover { background: var(--surface-raised); border-color: var(--border-default); }
html body #notif-drawer .notif-item--unread { border-color: var(--border-default); box-shadow: var(--shadow-raised); }
.notif-item__open {
  display: flex; align-items: flex-start; gap: var(--space-sm); flex: 1; min-width: 0;
  padding: var(--space-sm) var(--space-2xl) var(--space-sm) var(--space-sm);
  border: 0; border-radius: inherit; background: transparent; color: inherit;
  font: inherit; text-align: left; cursor: pointer;
}
html body #notif-drawer .notif-item__icon {
  display: inline-grid; place-items: center; flex-shrink: 0;
  width: 32px; height: 32px; border-radius: var(--radius-control);
  background: var(--neutral-subtle); color: var(--neutral-text);
}
html body #notif-drawer .notif-item--success .notif-item__icon { background: var(--success-subtle); color: var(--success-text); }
html body #notif-drawer .notif-item--danger .notif-item__icon { background: var(--danger-subtle); color: var(--danger-text); }
html body #notif-drawer .notif-item--warning .notif-item__icon { background: var(--warning-subtle); color: var(--warning-text); }
.notif-item__body { display: flex; flex-direction: column; gap: var(--space-3xs); min-width: 0; }
html body #notif-drawer .notif-item__title { font-size: var(--font-size-body); font-weight: var(--font-weight-medium); color: var(--text-primary); }
.notif-item--unread .notif-item__title { font-weight: var(--font-weight-semibold); }
html body #notif-drawer .notif-item__text { font-size: var(--font-size-body-sm); color: var(--text-secondary); line-height: var(--line-height-title); }
.notif-item__meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-xs); margin-top: var(--space-3xs); }
html body #notif-drawer .notif-item__time { font-family: var(--font-mono); font-size: var(--font-size-caption); color: var(--text-muted); }
html body #notif-drawer .notif-brand { font-size: var(--font-size-caption); font-weight: var(--font-weight-semibold); color: var(--accent-text); }
html body #notif-drawer .notif-item__dot {
  position: absolute; top: var(--space-sm); right: var(--space-sm);
  width: 10px; height: 10px; border-radius: var(--radius-pill);
  background: var(--accent-fill); box-shadow: 0 0 0 3px var(--accent-subtle);
}
html body #notif-drawer .notif-item__delete {
  top: auto; bottom: var(--space-2xs); right: var(--space-2xs);
  width: 28px; height: 28px;
  color: var(--text-muted);
}
html body #notif-drawer .notif-item__delete:hover { background: var(--danger-subtle); color: var(--danger-text); }
html body #notif-drawer .notif-empty { padding: var(--space-4xl) var(--space-lg); gap: var(--space-xs); color: var(--text-secondary); }
.notif-empty__icon { color: var(--text-muted); margin-bottom: var(--space-xs); }
.notif-empty__title { font-size: var(--font-size-body-lg); font-weight: var(--font-weight-semibold); color: var(--text-primary); }
.notif-empty__text { font-size: var(--font-size-body-sm); max-width: 32ch; }
.notif-quiet, .notif-loading { padding: var(--space-sm) var(--space-2xs); color: var(--text-muted); font-size: var(--font-size-body-sm); }

/* --------------------------------------------------------------------------
   9. Help panel (ui/helpDrawer.js): beside the page, below the bar
   -------------------------------------------------------------------------- */
html body #help-drawer {
  top: 0;
  right: 0;
  transform: none;
  z-index: var(--z-drawer);
  font-family: inherit;
}
html body #help-drawer .help-drawer__panel {
  position: fixed;
  top: calc(var(--header-height, 64px) + var(--space-xs));
  right: var(--space-sm);
  width: 380px;
  max-width: calc(100vw - 2 * var(--space-sm));
  max-height: calc(100dvh - var(--header-height, 64px) - var(--space-xl));
  gap: var(--space-lg);
  padding: var(--space-md) var(--space-lg) var(--space-lg);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-card);
  background: var(--surface-overlay);
  color: var(--text-primary);
  box-shadow: var(--shadow-overlay);
  transform: translateX(calc(100% + var(--space-xl)));
}
html body #help-drawer[data-open="true"] .help-drawer__panel { transform: translateX(0); }
html body #help-drawer:not([data-open="true"]) .help-drawer__panel { transition: transform var(--duration-slow) var(--ease-exit), visibility 0s linear var(--duration-slow); }
html body #help-drawer[data-open="true"] .help-drawer__panel { transition: transform var(--duration-slow) var(--ease-enter), visibility 0s; }
html body #help-drawer .help-drawer__header { align-items: flex-start; padding-bottom: var(--space-sm); border-bottom: 1px solid var(--border-subtle); }
html body #help-drawer .help-drawer__title { font-size: var(--font-size-h3); font-weight: var(--font-weight-bold); letter-spacing: var(--tracking-title); outline: none; }
.help-drawer__context { color: var(--text-muted); font-size: var(--font-size-body-sm); }
html body #help-drawer .help-drawer__eyebrow {
  display: block; margin-bottom: var(--space-xs);
  color: var(--text-muted); font-size: var(--font-size-eyebrow); font-weight: var(--font-weight-semibold);
  letter-spacing: var(--tracking-eyebrow); text-transform: uppercase;
}
html body #help-drawer .help-drawer__section { display: flex; flex-direction: column; gap: var(--space-xs); }
.help-drawer__search {
  display: flex; align-items: center; gap: var(--space-xs);
  height: var(--control-height-md); padding: 0 var(--space-sm);
  border: 1px solid var(--border-control); border-radius: var(--radius-control);
  background: var(--surface-inset); color: var(--text-muted);
}
.help-drawer__search:focus-within { outline: var(--focus-outline); outline-offset: var(--focus-ring-offset); }
html body #help-drawer .help-drawer__search-input {
  flex: 1; min-width: 0; height: 100%; padding: 0;
  border: 0; background: transparent; box-shadow: none; outline: none;
  color: var(--text-primary); font: inherit; font-size: var(--font-size-body);
}
.help-drawer__search-input::placeholder { color: var(--text-muted); }
.help-drawer__results { display: flex; flex-direction: column; gap: var(--space-3xs); }
.help-drawer__results:empty { display: none; }
.help-drawer__result {
  display: flex; flex-direction: column; gap: var(--space-3xs);
  padding: var(--space-xs) var(--space-sm); border-radius: var(--radius-control);
  color: var(--text-primary); text-decoration: none;
}
.help-drawer__result:hover { background: var(--surface-hover); }
.help-drawer__result-title { font-size: var(--font-size-body); font-weight: var(--font-weight-medium); }
.help-drawer__result-cat { font-size: var(--font-size-caption); color: var(--text-muted); }
.help-drawer__noresult { padding: var(--space-2xs) var(--space-sm); color: var(--text-secondary); font-size: var(--font-size-body-sm); }
html body #help-drawer .help-drawer__link {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-xs);
  width: 100%; min-height: 36px; padding: var(--space-2xs) var(--space-xs);
  border: 0; border-radius: var(--radius-control); background: transparent;
  color: var(--text-primary); font: inherit; font-size: var(--font-size-body); text-align: left; text-decoration: none; cursor: pointer;
}
html body #help-drawer .help-drawer__link:hover { background: var(--surface-hover); color: var(--accent-text); }
html body #help-drawer .help-drawer__link > span:not(.help-drawer__link-icon) { flex: 1; text-align: left; }
html body #help-drawer .help-drawer__link--card { border: 1px solid var(--border-default); background: var(--surface-raised); padding: var(--space-xs) var(--space-sm); }
html body #help-drawer .help-drawer__link > .help-drawer__link-icon { display: inline-flex; flex: 0 0 auto; color: var(--accent-text); }
html body #help-drawer .help-drawer__btn--full {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-xs);
  min-height: var(--control-height-md); border: 1px solid var(--border-control); border-radius: var(--radius-control);
  background: transparent; color: var(--text-primary); font: inherit; font-weight: var(--font-weight-semibold);
}
html body #help-drawer .help-drawer__btn--full:hover { background: var(--surface-hover); }
html body #help-drawer .help-drawer__prompt-card { border: 1px solid var(--border-subtle); border-radius: var(--radius-control); background: var(--surface-raised); }
.help-drawer__keyline { display: flex; align-items: center; gap: var(--space-sm); color: var(--text-secondary); font-size: var(--font-size-body-sm); padding: 0 var(--space-xs); }
.help-drawer :is(a, button, input):focus-visible { outline: var(--focus-outline); outline-offset: var(--focus-ring-offset); }

/* --------------------------------------------------------------------------
   10. Keyboard shortcuts sheet
   -------------------------------------------------------------------------- */
.gtb-sheet-backdrop {
  position: fixed; inset: 0; z-index: var(--z-modal);
  display: grid; place-items: center; padding: var(--space-md);
  background: var(--scrim); opacity: 0;
  transition: opacity var(--duration-base) var(--ease-standard);
}
.gtb-sheet-backdrop[data-state="open"] { opacity: 1; }
.gtb-sheet {
  width: 440px; max-width: 100%;
  padding: var(--space-lg);
  border: 1px solid var(--border-default); border-radius: var(--radius-modal);
  background: var(--surface-overlay); color: var(--text-primary);
  box-shadow: 0 6px 0 -2px var(--surface-raised), 0 6px 0 -1px var(--border-subtle), var(--shadow-modal);
  translate: 0 8px;
  transition: translate var(--duration-slow) var(--ease-enter);
}
.gtb-sheet-backdrop[data-state="open"] .gtb-sheet { translate: 0 0; }
.gtb-sheet:focus { outline: none; }
.gtb-sheet__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-md); }
.gtb-sheet__title { margin: 0; font-size: var(--font-size-h3); font-weight: var(--font-weight-bold); }
.gtb-keys { margin: 0; display: grid; gap: var(--space-2xs); }
.gtb-keys__row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-md); padding: var(--space-xs) 0; border-bottom: 1px solid var(--border-subtle); }
.gtb-keys__row dt { display: flex; gap: var(--space-2xs); }
.gtb-keys__row dd { margin: 0; color: var(--text-secondary); font-size: var(--font-size-body-sm); text-align: right; }
.gtb-sheet__foot { margin: var(--space-md) 0 0; color: var(--text-muted); font-size: var(--font-size-body-sm); }
.gtb-sheet__foot a { color: var(--accent-text); }
.gtb-sheet :is(a, button):focus-visible { outline: var(--focus-outline); outline-offset: var(--focus-ring-offset); }

/* --------------------------------------------------------------------------
   11. The sidebar's half of the shell: Home logo and the Brand selector
   -------------------------------------------------------------------------- */
#app-root .sidebar .sidebar-home-link {
  display: flex; align-items: center; gap: var(--space-sm);
  min-width: 0; flex: 1;
  padding: var(--space-2xs);
  border-radius: var(--radius-control);
  color: inherit; text-decoration: none;
}
#app-root .sidebar .sidebar-home-link:hover { background: var(--nav-hover-bg); }
#app-root .sidebar .sidebar-home-link:focus-visible { outline: var(--focus-outline); outline-offset: var(--focus-ring-offset); }

.sidebar-brand { padding: var(--space-sm) var(--space-sm) var(--space-2xs); flex-shrink: 0; }
.sidebar-brand[hidden] { display: none; }
#app-root .sidebar .gtb-brand {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  width: 100%;
  min-height: 52px;
  padding: var(--space-xs) var(--space-xs) var(--space-xs) var(--space-xs);
  border: 1px solid var(--nav-border);
  border-radius: var(--radius-control);
  background: var(--surface-raised);
  color: var(--nav-text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  box-shadow: var(--shadow-raised);
  transition: var(--transition-control);
}
#app-root .sidebar .gtb-brand:hover { border-color: var(--border-control); }
#app-root .sidebar .gtb-brand[aria-expanded="true"] { border-color: var(--accent-border); background: var(--surface-selected); }
#app-root .sidebar .gtb-brand:focus-visible { outline: var(--focus-outline); outline-offset: var(--focus-ring-offset); }
.gtb-brand__mark,
.gtb-brand-item__mark {
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-control);
  background: var(--accent-fill);
  color: var(--on-accent);
  font-size: var(--font-size-caption);
  font-weight: var(--font-weight-bold);
  letter-spacing: 0.02em;
  box-shadow: var(--shadow-button);
}
.gtb-brand__text { display: flex; flex-direction: column; gap: var(--space-3xs); flex: 1; min-width: 0; }
.gtb-brand__caption {
  display: flex; align-items: center; gap: var(--space-2xs);
  color: var(--nav-text-muted);
  font-size: var(--font-size-caption);
  font-weight: var(--font-weight-medium);
  line-height: 1.2;
}
.gtb-brand__name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-primary);
  font-size: var(--font-size-body);
  font-weight: var(--font-weight-semibold);
  line-height: 1.2;
}
.gtb-brand__tag { padding: 0 var(--space-2xs); }
.gtb-brand__tag .view-only-chip { all: unset; }
.gtb-brand__chev { color: var(--nav-text-muted); flex-shrink: 0; }

/* Collapsed sidebar: the initials only; the name is the button's tooltip. */
#app-root .sidebar.collapsed .sidebar-brand { padding: var(--space-sm) 0 var(--space-2xs); display: flex; justify-content: center; }
#app-root .sidebar.collapsed .gtb-brand { width: auto; min-height: 0; padding: var(--space-2xs); border-color: transparent; background: transparent; box-shadow: none; }
#app-root .sidebar.collapsed .gtb-brand__text,
#app-root .sidebar.collapsed .gtb-brand__chev { display: none; }

/* Its menu is on <body>, placed by script beside the button. */
:is(#app-root .gtb, body) .gtb-menu#workspace-popover { position: fixed; right: auto; min-width: 260px; }
.gtb-brand-item__mark { width: 24px; height: 24px; box-shadow: none; }

/* --------------------------------------------------------------------------
   12. Widths
   -------------------------------------------------------------------------- */
/* Narrow desktop: the AI chip's label shortens. */
@media (max-width: 1180px) {
  #app-root .gtb .gtb-ai { max-width: 150px; }
}
@media (max-width: 1024px) {
  #app-root header.top-bar.gtb { gap: var(--space-xs); padding: 0 var(--space-md) 0 var(--space-sm); }
  /* The AI chip keeps its dot; the account menu spells the state out. */
  #app-root .gtb .gtb-ai .gtb-ai__label { display: none; }
  #app-root .gtb .gtb-ai { padding: 0; width: 32px; justify-content: center; }
}

/* The sidebar is still shown but the bar is short: search becomes its icon
   and the theme icon steps aside (Theme is in the account menu). */
@media (max-width: 880px) {
  .gtb-center { min-width: 0; justify-content: flex-end; }
  #app-root .gtb .gtb-search { width: var(--control-height-md); padding: 0; justify-content: center; border-color: transparent; background: transparent; color: var(--text-secondary); }
  #app-root .gtb .gtb-search .gtb-search__text,
  #app-root .gtb .gtb-search .gtb-search__kbd { display: none; }
  #app-root .gtb .theme-toggle { display: none; }
}

/* Tablets and phones: the sidebar (with the Brand selector) is off-canvas
   below the bar. The bar sits above the sidebar's dimmer so the menu button
   still closes it. */
@media (max-width: 768px) {
  #app-root header.top-bar.gtb { z-index: var(--z-sidebar); padding: 0 var(--space-sm); }
  #app-root .gtb .mobile-menu-btn { display: inline-flex; min-width: 0; min-height: 0; margin: 0; }
  #app-root .gtb .mobile-menu-btn[aria-expanded="true"] { background: var(--surface-selected); color: var(--accent-text); }
  .gtb-home { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: var(--radius-control); }
  .gtb-home:focus-visible { outline: var(--focus-outline); outline-offset: var(--focus-ring-offset); }
  #app-root .gtb .gtb-collapse { display: none; }
  /* Search collapses to an icon beside the other actions; the palette
     opens full width. */
  .gtb-center { flex: 1 1 auto; min-width: 0; justify-content: flex-end; }
  #app-root .gtb .gtb-end { margin-left: 0; }
  #app-root .gtb .gtb-search { width: var(--control-height-md); padding: 0; justify-content: center; border-color: transparent; background: transparent; color: var(--text-secondary); }
  #app-root .gtb .gtb-search:hover { background: var(--surface-hover); }
  .gtb-search__text, .gtb-search__kbd { display: none !important; }
  #app-root .gtb .gtb-ai { display: none; }
  #app-root .gtb .gtb-create { width: var(--control-height-md); padding: 0; justify-content: center; margin: 0 var(--space-2xs); }
  #app-root .gtb .gtb-create .gtb-create__label,
  #app-root .gtb .gtb-create .gtb-create__chev { display: none; }
  #app-root .gtb .gtb-avatar { width: 32px; height: 32px; margin-left: var(--space-2xs); }
  /* Menus become sheets pinned under the bar, full width. */
  :is(#app-root .gtb, body) .gtb-menu:not(#workspace-popover) {
    position: fixed;
    top: calc(var(--header-height, 64px) + var(--space-2xs));
    left: var(--space-sm) !important;
    right: var(--space-sm) !important;
    width: auto !important;
    max-width: none;
  }
  html body #help-drawer .help-drawer__panel { right: var(--space-sm); left: var(--space-sm); width: auto; }
}
@media (max-width: 640px) {
  #app-root .gtb .theme-toggle { display: none; }   /* Theme lives in the account menu */
  html body #notif-drawer { width: 100vw; border-radius: 0; border-left: 0; }
  /* Full-screen palette */
  html body #cmd-palette { padding: 0; }
  html body #cmd-palette .cmd-palette-modal { width: 100%; height: 100dvh; max-height: none; border: 0; border-radius: 0; box-shadow: none; }
  html body #cmd-palette .cmd-result-hint { display: none; }
  .cmd-footer-hint { display: none !important; }
}
@media (max-width: 480px) {
  #app-root header.top-bar.gtb { gap: var(--space-2xs); }
  #app-root .gtb .gtb-end { gap: 0; }
}

/* Touch: 44px hit areas without changing the look. */
@media (pointer: coarse) {
  #app-root .gtb .gtb-icon-btn,
  #app-root .gtb .gtb-create,
  #app-root .gtb .gtb-search { min-height: var(--tap-target-min); min-width: var(--tap-target-min); }
  :is(#app-root .gtb, body) .gtb-menu .gtb-menu__item { min-height: var(--tap-target-min); }
}

/* Reduced motion: the duration tokens are already 0; the stamp and the
   folder tab simply appear. */
@media (prefers-reduced-motion: reduce) {
  .gtb-menu[data-state="open"] .gtb-stamp { animation: none; }
  :is(#app-root .gtb, body) .gtb-menu,
  :is(#app-root .gtb, body) .gtb-menu[data-state="open"] { clip-path: none; translate: none; }
}
