/* ══════════════════════════════════════════════
   HEADER BUTTONS, ONE SET OF RULES
   ──────────────────────────────────────────────
   The right side of the desktop header held five controls in four shapes
   and three heights (30 to 38px) with uneven gaps. Same order, same
   colours, same black VERA button; only the frame is made one thing:
     • 36px tall, 9px corners (the app's .btn corner), 8px apart;
     • secondary controls on --bg3 with a 1px --border, like .btn-secondary.
   The search (css/search-seek.css) and "+ Report" (css/report-menu.css)
   already follow this; here the site menu, VERA and the bell join them.
   Desktop only: phones have their own header (mobile.css, field mode).
══════════════════════════════════════════════ */
@media (min-width: 769px) {
  /* VERA keeps its colours; only the height is pinned, so it lines up
     with the 36px controls beside it instead of following its padding. */
  .topbar-right .btn {
    height: 36px;
    box-sizing: border-box;
    padding-top: 0;
    padding-bottom: 0;
    border-radius: 9px;
  }

  /* The site menu: no extra margin (the row's 8px gap does the spacing),
     and the globe now sits inside the button, so it reads as one control. */
  #app-scope { margin-right: 0 !important; }
  .topbar-right .app-scope-btn {
    height: 36px;
    box-sizing: border-box;
    padding: 0 12px !important;
    gap: 7px;
    justify-content: flex-start;
    border-radius: 9px;
    border: 1px solid var(--border);
    background-color: var(--bg3);
  }
  .topbar-right .app-scope-btn > span { flex: 1; }
  .topbar-right .app-scope-btn:hover { border-color: var(--border); background-color: var(--bg2); }
  /* A narrowed scope still shows in orange, as before. */
  .app-scope-active .app-scope-btn {
    border-color: var(--safety-orange) !important;
    background-color: rgba(234, 88, 12, 0.06) !important;
  }
  .app-scope-active .app-scope-btn > .lucide-globe,
  .app-scope-active .app-scope-btn > i[data-lucide="globe"] { color: var(--safety-orange) !important; }

  /* The bell gets the same frame as the search. */
  .topbar-right .notif-bell {
    width: 36px;
    height: 36px;
    box-sizing: border-box;
    border-radius: 9px;
    border: 1px solid var(--border);
    background: var(--bg3);
  }
  .topbar-right .notif-bell:hover,
  .topbar-right .notif-bell.active { background: var(--bg2); }
}

/* ══════════════════════════════════════════════
   NARROW HEADER (desktop layout, small window)
   ──────────────────────────────────────────────
   Below about 900px of app width the five controls no longer fit beside
   the page title. Sized on the header's own width (a container query),
   so it also follows the sidebar width (the numbers below are the header's
   inner width, without its 24px padding). Every control stays; only words
   go, the icon and the tooltip stay:
     • 780px: VERA shows its icon only;
     • 600px: "+ Report" shows its "+" only (js/report-menu.js sizes the
       pill), the site menu name is cut short;
     • 520px: the site menu shows its globe only (name in the tooltip).
   The page title may shrink and wrap to two lines. Phones (768px and
   below) keep their own header and are untouched.
══════════════════════════════════════════════ */
@media (min-width: 769px) {
  .topbar { container: topbar / inline-size; }
  .topbar > :first-child { min-width: 0; }
  .topbar .page-title {
    min-width: 0;
    overflow: hidden;
    line-height: 1.2;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow-wrap: anywhere;
  }
  .topbar-right { flex-shrink: 0; margin-left: 12px; }

  @container topbar (max-width: 780px) {
    .topbar-right .topbar-ai-btn { width: 36px; padding-left: 0; padding-right: 0; justify-content: center; }
    .topbar-right .topbar-ai-btn > svg { margin-right: 0 !important; }
    .topbar-right .topbar-ai-btn > span { display: none; }
  }
  @container topbar (max-width: 600px) {
    .topbar-right .crt-say { display: none; }
    .topbar-right .crt-pill { gap: 0; }
    .topbar-right .app-scope-btn { min-width: 0; max-width: 130px; }
    .topbar-right .app-scope-btn > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  }
  @container topbar (max-width: 520px) {
    .topbar-right .app-scope-btn > span { display: none; }
  }
}
