/* ----------------------------------------------------------------------------
   shell.css — App shell chrome: header, brand, primary nav pills, the sign-out and
   user-email controls, the theme slider, the background-animation switch,
   and the .page / .app-main layout frame.
   Slice 3 of 16 (see css/tokens.css for the full load order).
   ------------------------------------------------------------------------- */
/* ------------------------------------------------------------ shell */
.shell {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

.app-header {
  display: flex;
  align-items: center;
  gap: 22px;
  height: var(--header-h);
  padding: 0 22px;
  flex-shrink: 0;
  /* No backdrop-filter here, deliberately. The old 6px blur re-ran a full
     gaussian over this strip — and forced the compositor through an
     intermediate readback that breaks render-pass batching — on every frame
     the star field drifted beneath it, making it the single biggest GPU item
     on the chat view. At 94% opacity almost none of the moving field shows
     through, so the frosted look survives without any filter pass. */
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 10;
}

.brand {
  font-weight: 700;
  font-size: 17px;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.brand img {
  display: block;
  object-fit: contain;
  height: 28px;
  width: auto;
}

.brand-sub {
  border-left: 1px solid var(--border);
  padding-left: 8px;
  margin-left: 2px;
  font-size: 13px;
  font-weight: 500;
  opacity: 0.8;
}

/* primary nav — styled as clear pill buttons/tabs */
.app-header nav {
  display: flex;
  gap: 8px;
  min-width: 0;
  /* min-width:0 lets the nav shrink below its pills, and nowrap pills then
     PAINT OVER the neighbouring header items (seen live when the admin-only
     third pill appeared). Scroll the overflow instead — invisible when
     everything fits, and never an overlap when it doesn't. */
  overflow-x: auto;
  scrollbar-width: none;
}

.app-header nav::-webkit-scrollbar {
  display: none;
}

.app-header nav a {
  padding: 7px 18px;
  border-radius: var(--radius-pill);
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  background: var(--surface);
  border: 1px solid var(--border);
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.app-header nav a:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border-strong);
}

.app-header nav a:active {
  transform: scale(0.97);
}

.app-header nav a.active {
  background: var(--primary-bg);
  color: var(--primary-text);
  border-color: transparent;
  box-shadow: var(--shadow-soft);
}

.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

/* Desktop shows the "Sign out" text pill; the icon only appears once the header
   collapses on mobile (see the responsive block). */
.signout-ic {
  display: none;
}

.user-email {
  color: var(--muted);
  font-size: 13px;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* With the (admin-only) third nav pill the header no longer fits everything
   at mid widths. Shed the two least load-bearing pieces first — the email
   and the decorative sub-brand — so all three tabs stay fully visible; the
   720px block below handles the rest of the collapse. */
@media (max-width: 940px) {
  .user-email {
    display: none;
  }

  .brand-sub {
    display: none;
  }
}

/* theme slider: moon | sun in the track, thumb slides over the active one */
.theme-switch {
  width: 56px;
  height: 28px;
  border-radius: 20px;
  position: relative;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: border-color 0.25s ease;
}

.theme-switch:hover {
  border-color: var(--accent);
}

.theme-icon {
  width: 28px;
  display: grid;
  place-items: center;
  color: var(--muted);
  position: relative;
  z-index: 1;
  transition: color 0.25s ease;
}

.theme-icon svg {
  display: block;
}

.theme-switch.dark .theme-icon:first-child,
.theme-switch.light .theme-icon:nth-child(2) {
  color: var(--primary-text);
}

.theme-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 24px;
  height: 22px;
  border-radius: 14px;
  background: var(--primary-bg);
  box-shadow: var(--shadow-soft);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.theme-switch.light .theme-thumb {
  transform: translateX(26px);
}

/* background-animation switch: sparkle lit while the dash field runs,
   dimmed with a slash when it's off */
.fx-toggle {
  height: 28px;
  width: 28px;
  padding: 0;
  border-radius: 50%;
  flex-shrink: 0;
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  position: relative;
  transition: color 0.25s ease;
}

.fx-toggle:hover {
  background: var(--surface-2);
  color: var(--text);
}

.fx-toggle svg {
  display: block;
}

.fx-toggle::after {
  content: '';
  position: absolute;
  left: 5px;
  right: 5px;
  top: 50%;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
  transform: rotate(-45deg) scaleX(0);
  transition: transform 0.2s ease;
}

.fx-toggle.off {
  opacity: 0.6;
}

.fx-toggle.off::after {
  transform: rotate(-45deg) scaleX(1);
}

/* ------------------------------------------------------------ layout */
.app-main {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  position: relative;
  display: flex;
  flex-direction: column;
}

.page {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  padding: 30px 22px 40px;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.page-head h1 {
  margin: 0;
}

