/*!
 * EW UI v2: the app shell (spec approved by Miles, 21 Oct 2026: _docs/ew_ui/v2/20261021_ew_ui_v2_shell_spec.html).
 * Load after v1's ew-ui.css. It only adds classes, all prefixed .ew-shell-, so nothing v1 draws changes look.
 * No inline code is needed anywhere: tools with a strict content security policy (ewproof) keep it as it is.
 *
 * Header:   .ew-header > .ew-header-inner > [.ew-brand][.ew-nav][.ew-head-right > toggle, .ew-shell-um]
 * Menu:     .ew-shell-um[data-ew-shell-menu] > button.ew-shell-user + .ew-shell-menu[hidden][role=menu]
 * Elsewhere: .ew-shell-corner (the toggle on header-less pages), .ew-shell-tabs (admin), .ew-shell-footer,
 *            .ew-shell-state (empty, error, not available, signed out), .ew-shell-bar (expired sign-in).
 */

/* ---- Header: the left side grows, the right side keeps its order (toggle, then the user button) ---- */
.ew-shell-left { display: flex; align-items: center; gap: var(--ew-s3); min-width: 0; }
.ew-shell-left .ew-nav { margin-left: var(--ew-s2); }

/* ---- The user button and menu ---- */
.ew-shell-um { position: relative; }
.ew-shell-user {
  display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px 0 4px;
  border: 1px solid var(--ew-line); border-radius: 999px; background: var(--ew-surface);
  color: var(--ew-ink); font: inherit; font-size: .88rem; font-weight: 700; cursor: pointer;
}
.ew-shell-user:hover { background: var(--ew-surface-2); }
.ew-shell-avatar {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--ew-blue-strong); color: var(--ew-on-strong); font-weight: 900; font-size: .78rem;
}
.ew-shell-who { display: grid; text-align: left; line-height: 1.15; }
.ew-shell-who small { font-weight: 400; font-size: .7rem; color: var(--ew-muted); }
.ew-shell-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 40; min-width: 250px; max-width: min(92vw, 340px);
  background: var(--ew-surface); border: 1px solid var(--ew-line); border-radius: var(--ew-r-md);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .14); padding: 6px; display: grid; gap: 2px;
}
.ew-shell-menu[hidden] { display: none; }
.ew-shell-menu-head {
  padding: 10px 12px; display: grid; gap: 2px; border-bottom: 1px solid var(--ew-line); margin-bottom: 4px;
  overflow-wrap: anywhere;
}
.ew-shell-menu-head small { color: var(--ew-muted); }
.ew-shell-role {
  justify-self: start; margin-top: 4px; font-size: .7rem; font-weight: 700; padding: 1px 8px; border-radius: 999px;
  background: var(--ew-blue-soft); color: var(--ew-link);
}
.ew-shell-menu a, .ew-shell-menu button {
  display: block; width: 100%; text-align: left; padding: 9px 12px; border: 0; border-radius: var(--ew-r-sm);
  background: none; font: inherit; font-size: .94rem; color: var(--ew-ink); text-decoration: none; cursor: pointer;
}
.ew-shell-menu a:hover, .ew-shell-menu a:focus, .ew-shell-menu button:hover, .ew-shell-menu button:focus {
  background: var(--ew-blue-soft); outline: none;
}
.ew-shell-menu a:focus-visible, .ew-shell-menu button:focus-visible { box-shadow: inset 0 0 0 2px var(--ew-focus); }
.ew-shell-menu form { margin: 0; }
.ew-shell-sep { border-top: 1px solid var(--ew-line); margin: 4px 0; }
.ew-shell-screens { display: none; }          /* the tool's screens: only in the menu, only on a phone */

/* ---- The toggle on a page without a header (the sign-in card, the signed-out page) ---- */
.ew-shell-corner { position: fixed; top: calc(env(safe-area-inset-top, 0px) + 12px); right: 12px; z-index: 30; }

/* ---- Admin: one area, a tab per address ---- */
.ew-shell-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--ew-line); overflow-x: auto; margin-bottom: var(--ew-s4); }
.ew-shell-tabs a {
  padding: 9px 14px; font-weight: 700; font-size: .9rem; color: var(--ew-muted); text-decoration: none;
  border-bottom: 2px solid transparent; white-space: nowrap;
}
.ew-shell-tabs a:hover { color: var(--ew-ink); }
.ew-shell-tabs a[aria-current="page"] { color: var(--ew-link); border-color: var(--ew-blue-strong); }

/* ---- Footer: vX.Y.Z · <sha7>, muted, on every page ---- */
.ew-shell-footer { font-size: .72rem; color: var(--ew-muted); padding-top: 8px; padding-bottom: 16px; }

/* ---- The shared states ---- */
.ew-shell-state {
  max-width: 520px; margin: var(--ew-s6, 48px) auto; padding: var(--ew-s5, 32px) var(--ew-s4);
  background: var(--ew-surface); border: 1px solid var(--ew-line); border-radius: var(--ew-r-md);
  display: grid; gap: var(--ew-s2); justify-items: center; text-align: center;
}
.ew-shell-state h1 { margin: 0; font-size: 1.25rem; }
.ew-shell-state p { margin: 0; color: var(--ew-muted); }

/* ---- An expired sign-in: a bar at the top that keeps the page and any typing ---- */
.ew-shell-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 60; display: flex; flex-wrap: wrap; gap: 8px 16px;
  align-items: center; justify-content: center; padding: 10px 16px;
  background: var(--ew-blue-strong); color: var(--ew-on-strong); font-size: .92rem;
}
.ew-shell-bar a { color: var(--ew-on-strong); font-weight: 700; text-decoration: underline; }

/* ---- Phone (<= 760px): the tool's screens move into the user menu; the toggle stays in view ---- */
@media (max-width: 760px) {
  .ew-shell-left .ew-nav, .ew-shell-who { display: none; }
  .ew-shell-user { padding: 0 4px; }
  .ew-shell-screens { display: grid; gap: 2px; }
  .ew-shell-screens a[aria-current="page"] { color: var(--ew-link); font-weight: 700; }
}
