@layer components {
  /* The slot is a zero-height anchor in the flow; the banner overlays what follows, so showing or hiding it never
     shifts the page. Neutral, never red: being offline is no fault. Under a thread's header, or at the bottom of a page. */
  .connection-banner-slot { position: relative; flex: none; height: 0; z-index: 30; }
  .connection-banner {
    position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 10px; min-height: 40px;
    padding: 6px var(--gutter); border-bottom: 1px solid var(--border); background: var(--muted);
    color: var(--foreground); font-size: 0.875rem; box-shadow: 0 2px 8px light-dark(oklch(0 0 0 / 0.08), oklch(0 0 0 / 0.4));
  }
  .connection-banner[hidden] { display: none; }
  .connection-banner-icon { display: flex; flex: none; color: var(--muted-foreground); }
  .connection-banner-icon > svg { width: 17px; height: 17px; }
  /* The clock for a page not synced yet, the cut network for the rest. */
  .connection-banner[data-state="stale"] [data-icon="offline"],
  .connection-banner:not([data-state="stale"]) [data-icon="stale"] { display: none; }
  .connection-banner-text { min-width: 0; }
  .connection-banner-detail { margin-left: auto; color: var(--muted-foreground); font-size: var(--text-meta); }
  .connection-banner-detail[hidden] { display: none; }
  /* Off a thread, the banner is a fixed card at the bottom, above the toasts' spot, so it never covers a page's top. */
  .app-main > .connection-banner-slot > .connection-banner {
    --banner-bottom: calc(96px + var(--safe-bottom));
    position: fixed; top: auto; bottom: var(--banner-bottom); left: 50%; right: auto; translate: -50% 0;
    width: min(480px, calc(100vw - 32px)); box-sizing: border-box; border: 1px solid var(--border);
    border-radius: var(--radius-lg); box-shadow: 0 4px 12px light-dark(oklch(0 0 0 / 0.1), oklch(0 0 0 / 0.5));
  }
  @media (max-width: 1099px) {
    /* Above the tab bar, and above the toasts that sit right over it. */
    .app-main > .connection-banner-slot > .connection-banner {
      --banner-bottom: calc(var(--tab-bar-height) + var(--tab-bar-bottom) + 96px);
    }
  }

  /* A file or document that needs the network says so while a page is shown from its offline copy. */
  .offline-unavailable { margin: 6px 0 0; color: var(--muted-foreground); font-size: var(--text-meta); }
}
