/* HOUSE RULES: THE SIDE MENU, the same in every Wildcard app.
   Source: wildcardsvc/house-rules (menu/sidebar.css). Apps carry a copy (public/sidebar.css) made by `house-rules sync`:
   never edit the copy. An app may change only its logo, its menu items and its colours, through the --sb-* tokens its own
   stylesheet defines (see README). Every size, space, radius, weight and behaviour here is the same everywhere on purpose. */

:root {
  --snav-w: 272px; --snav-rail: 92px; --topbar-h: 56px; --snav-gap: 12px;
  --sb-font: "Red Hat Text", system-ui, sans-serif;
  --sb-font-display: "Red Hat Display", system-ui, sans-serif;
  --id-top: #2a2a3d; --id-bot: #35354c;
  --staff-top: #33234b; --staff-bot: #3f2c5e;
}
html.rail { --snav-w: var(--snav-rail); }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.ico { display: inline-grid; place-items: center; width: 20px; height: 20px; flex: none; }
.ico svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- the slim top bar (small screens) */
.topbar { position: sticky; top: 0; z-index: 60; height: var(--topbar-h); display: none; align-items: center; gap: 12px; padding: 0 16px; background: var(--sb-topbar); color: var(--sb-on-topbar, #fff); box-shadow: 0 10px 30px -14px rgba(0, 0, 0, .6); font-family: var(--sb-font); }
.topbar .brand { color: inherit; }
.topbar__spacer { flex: 1; }
.topbar__menu { position: relative; display: inline-grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 10px; background: transparent; color: inherit; cursor: pointer; }
.topbar__menu[hidden] { display: none; } /* signed out: the bar is only the logo (the author rule above would otherwise show a hidden button) */
.topbar__menu:hover { background: rgba(240, 238, 245, .12); }
@media (max-width: 899px) { body.has-nav .topbar { display: flex; } }
body:not(.has-nav) .topbar { display: flex; } /* signed out: the bar is all there is */

/* ---------- the frame */
.shell { display: grid; grid-template-columns: calc(var(--snav-w) + var(--snav-gap) * 2) minmax(0, 1fr); min-height: 100vh; }
.shell__content { display: flex; flex-direction: column; min-width: 0; }

/* ---------- the "View as" bar: a Wildcard Admin viewing as a client. Marigold, the loudest thing on the page, because a slip here
   affects a real client. First thing inside .shell__content. */
:root { --vb-bg: #ffb400; --vb-ink: #2a1c00; }
.vbar { position: sticky; top: var(--snav-gap); z-index: 45; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 16px; margin: 12px 24px 0; padding: 10px 16px; border-radius: 14px; background: var(--vb-bg); color: var(--vb-ink); box-shadow: 0 12px 24px -14px rgba(0, 0, 0, .8); font-family: var(--sb-font); font-size: .95rem; line-height: 1.5; }
.vbar[hidden] { display: none; }
.vbar__text b { font-weight: 700; }
.vbar__acts { display: flex; gap: 8px; flex-wrap: wrap; }
.vbar__form { margin: 0; display: contents; }
.vbar__btn { padding: 6px 14px; border: 1px solid var(--vb-ink); border-radius: 999px; background: transparent; color: var(--vb-ink); font: inherit; font-size: .88rem; cursor: pointer; }
.vbar__btn--solid { background: var(--vb-ink); color: var(--vb-bg); font-weight: 700; }
.vbar__btn:hover { filter: brightness(1.15); }
.vbar__btn:focus-visible { outline: 3px solid var(--vb-ink); outline-offset: 2px; }
@media (max-width: 899px) { .vbar { margin-inline: 16px; top: calc(var(--topbar-h) + var(--snav-gap)); } }
@media print { .vbar { display: none !important; } }

/* ---------- the side menu: a floating, rounded panel */
.snav { position: sticky; top: var(--snav-gap); align-self: start; z-index: 50; margin: var(--snav-gap); height: calc(100vh - var(--snav-gap) * 2); display: flex; flex-direction: column; gap: 12px; padding: 16px 14px; border-radius: 30px; background: linear-gradient(180deg, #22222f 0%, #181823 100%); box-shadow: 0 0 0 1px var(--sb-line) inset, 0 30px 60px -30px rgba(0, 0, 0, .9); font-family: var(--sb-font); font-size: .92rem; line-height: 1.65; color: var(--sb-text); scrollbar-width: thin; scrollbar-color: rgba(240, 238, 245, .28) transparent; }
.snav[hidden] { display: none; }
.snav__head { position: relative; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 6px 6px 2px; }
.snav__brand { display: inline-flex; align-items: center; gap: 9px; height: 35px; color: var(--sb-text); text-decoration: none; border-radius: 8px; font: 600 1.25rem/1 var(--sb-font-display); }
.snav__brand:focus-visible { outline: 3px solid var(--sb-accent); outline-offset: 4px; }
.snav__brand img { display: block; width: 35px; height: 35px; }
/* an app whose logo is a wordmark: the wordmark expanded, its small mark when collapsed */
.snav__brand.has-wordmark { gap: 0; }
.snav__brand.has-wordmark img { display: none; }
.snav__close { display: none; position: absolute; right: 0; top: 4px; width: 36px; height: 36px; padding: 0; place-items: center; border: 0; border-radius: 10px; background: transparent; color: var(--sb-text); cursor: pointer; }

/* the account card: who is signed in, and for whom they act. A link to their profile and their organization. */
.snav__id { position: relative; display: grid; margin-inline: -14px; margin-bottom: 6px; box-shadow: 0 1px 0 rgba(255, 255, 255, .07) inset, 0 12px 16px -10px rgba(0, 0, 0, .75), 0 1px 0 rgba(0, 0, 0, .5); }
.snav__id > * { position: relative; }
.ucard { position: relative; display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 0; background: var(--id-top); color: var(--sb-text); text-decoration: none; cursor: pointer; }
.ucard[hidden] { display: none; }
.ucard__text { display: grid; min-width: 0; flex: 1; }
.ucard__name { font-weight: 600; font-size: .92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ucard__email { font-size: .8rem; color: var(--sb-text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avwrap { position: relative; flex: none; display: inline-flex; }
.avatar { flex: none; display: inline-grid; place-items: center; width: 46px; height: 46px; border-radius: 14px; overflow: hidden; background: #e8d6f5; color: #550088; font-weight: 600; font-size: .92rem; letter-spacing: .02em; box-shadow: 0 0 0 2px rgba(255, 255, 255, .14); }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.snav__org { position: relative; display: flex; align-items: center; gap: 22px; padding: 8px 16px 9px 26px; background: var(--id-bot); box-shadow: 0 1px 0 rgba(255, 255, 255, .06) inset; color: var(--sb-text); text-decoration: none; cursor: pointer; } /* the logo sits centred under the avatar: 16 + (46 - 26) / 2 */
.snav__org[hidden] { display: none; }
.snav__org .ucard__name { min-width: 0; flex: 1; }
.ologo-wrap { position: relative; flex: none; display: inline-flex; }
.ologo { flex: none; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; overflow: hidden; background: #e8e2f0; color: #2a1740; font-family: var(--sb-font-display); font-size: .68rem; font-weight: 700; line-height: normal; letter-spacing: .02em; box-shadow: 0 0 0 2px rgba(255, 255, 255, .1); }
.ologo img { width: 100%; height: 100%; display: block; }
.ologo--picture { background: var(--sb-text); }
/* on hover or focus the picture dims and a gear shows where the card leads */
.ovl { position: absolute; inset: 0; display: grid; place-items: center; border-radius: 14px; background: rgba(8, 5, 16, .62); color: #fff; opacity: 0; transition: opacity .15s ease; pointer-events: none; }
.ovl .ico { width: 20px; height: 20px; }
.ologo-wrap .ovl { border-radius: 8px; }
.ologo-wrap .ovl .ico { width: 14px; height: 14px; }
a.ucard, a.snav__org { color: var(--sb-text); text-decoration: none; }
.ucard[href]:hover, .snav__org[href]:hover { filter: brightness(1.12); }
.ucard[href]:focus-visible, .snav__org[href]:focus-visible { outline: 3px solid var(--sb-accent); outline-offset: -3px; }
.ucard:hover .ovl, .ucard:focus-visible .ovl, .snav__org:hover .ovl, .snav__org:focus-visible .ovl { opacity: 1; }
/* Wildcard's staff: purple tint, purple edge, the Wildcard cards as a watermark (the look of their replies in the portal) */
.snav__id.is-staff { --id-top: var(--staff-top); --id-bot: var(--staff-bot); overflow: hidden; background: var(--id-top); box-shadow: 0 0 0 1px rgba(162, 78, 224, .5) inset, 0 12px 16px -10px rgba(0, 0, 0, .75); }
.snav__id.is-staff::before { content: ""; position: absolute; top: -14%; right: -3%; height: 128%; aspect-ratio: 380 / 418; background: #e8d6f5; opacity: .11; transform: rotate(7deg); -webkit-mask: url(cards.svg) no-repeat center / contain; mask: url(cards.svg) no-repeat center / contain; pointer-events: none; }
.snav__id.is-staff .ucard { background: transparent; }
.snav__id.is-staff .snav__org { background: rgba(255, 255, 255, .07); }
/* a Wildcard Admin viewing as someone: that person's own card, with Wildcard's cards faintly behind it and a gold eye; the admin's own card is a button */
:root { --sb-view: #ffb400; --sb-view-ink: #2a1c00; }
.eye { position: absolute; right: -6px; bottom: -6px; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--sb-view); color: var(--sb-view-ink); box-shadow: 0 0 0 2px var(--id-top); }
.eye[hidden] { display: none; }
.eye .ico { width: 13px; height: 13px; }
.snav__id.is-pickable .ucard { cursor: pointer; }
.snav__id.is-pickable .ucard:hover, .snav__id.is-pickable .ucard:focus-visible { filter: brightness(1.12); }
.snav__id.is-pickable .ucard:focus-visible { outline: 3px solid var(--sb-accent); outline-offset: -3px; }
.snav__id.is-viewing { background: var(--id-top); overflow: hidden; }
.snav__id.is-viewing .ucard { background: transparent; }
.snav__id.is-viewing .snav__org { background: rgba(255, 255, 255, .07); }
.snav__id.is-viewing::before { content: ""; position: absolute; top: -14%; right: -3%; height: 128%; aspect-ratio: 380 / 418; background: #e8d6f5; opacity: .11; transform: rotate(7deg); -webkit-mask: url(cards.svg) no-repeat center / contain; mask: url(cards.svg) no-repeat center / contain; pointer-events: none; }
.snav__id.is-viewing .eye { box-shadow: 0 0 0 2px var(--id-top); }

/* the menu itself: two panes side by side that slide (the main menu, and the Wildcard Admin options for staff) */
.snav__nav { display: block; gap: 4px; flex: 1; position: relative; overflow: hidden; min-height: 0; padding-top: 0; border-top: 1px solid var(--sb-line); }
.snav__track { display: flex; width: 200%; height: 100%; transition: transform .28s cubic-bezier(.3, .7, .2, 1); }
.snav__nav.is-admin-pane .snav__track { transform: translateX(-50%); }
.snav__pane { width: 50%; flex: none; height: 100%; overflow-y: auto; padding-top: 12px; display: grid; gap: 4px; align-content: start; scrollbar-width: thin; scrollbar-color: rgba(240, 238, 245, .28) transparent; }
.snav__pane[inert] { visibility: hidden; transition: visibility 0s linear .28s; }
.snav__group + .snav__group { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--sb-line); }
.snav__label { margin: 0 0 6px 10px; font-size: .72rem; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: var(--sb-fog); }
.snav__paneh { margin: 2px 8px 6px; }
/* a labeled group folds shut from its heading (with JavaScript) */
.snav__fold { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; padding: 2px 6px 2px 0; border: 0; border-radius: 8px; background: none; color: inherit; font: inherit; letter-spacing: inherit; text-transform: inherit; text-align: left; cursor: pointer; }
.snav__fold:hover { color: var(--sb-text); }
.snav__fold:focus-visible { outline: 3px solid var(--sb-accent); outline-offset: 2px; }
.snav__fold .snav__chev { width: 16px; height: 16px; transition: transform .2s ease; }
.is-folded > .snav__label { margin-bottom: 0; }
.is-folded .snav__chev { transform: rotate(-90deg); }
.is-folded > .snav__list { display: none; }
html.rail .is-folded > .snav__list { display: grid; } /* the icon rail has no heading to fold */
@media (max-width: 899px) { html.rail .is-folded > .snav__list { display: none; } }
@media (prefers-reduced-motion: reduce) { .snav__fold .snav__chev { transition: none; } }
.snav__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; }
.snav__link { position: relative; display: flex; align-items: center; gap: 11px; width: 100%; padding: 5px 9px 5px 5px; border: 0; border-radius: 16px; background: none; color: var(--sb-text-2); font: inherit; font-size: .92rem; font-weight: 400; text-align: left; text-decoration: none; cursor: pointer; }
.snav__link .ico { width: 34px; height: 34px; padding: 8px; border-radius: 12px; }
.snav__link:hover { background: rgba(240, 238, 245, .06); color: var(--sb-text); }
.snav__link:focus-visible { outline: 3px solid var(--sb-accent); outline-offset: -3px; }
.snav__link[aria-current="page"] { background: color-mix(in srgb, var(--sb-accent) 26%, transparent); color: #fff; font-weight: 600; }
.snav__link[aria-current="page"] .ico { background: var(--sb-accent); color: var(--sb-on-accent); box-shadow: 0 8px 20px -8px var(--sb-accent); }
.snav__link.is-locked { color: #62627a; }
.snav__link.is-locked .ico { opacity: .55; }
.snav__badge { margin-left: -4px; min-width: 22px; padding: 2px 7px; border-radius: 11px; background: var(--sb-badge); color: var(--sb-on-accent); font-size: .72rem; font-weight: 600; text-align: center; box-shadow: 0 0 0 3px color-mix(in srgb, var(--sb-badge) 25%, transparent); }
.snav__gate.is-here { color: #e8d6f5; font-weight: 700; }
.snav__go { margin-left: auto; width: 18px !important; height: 18px !important; padding: 0 !important; opacity: .7; }
.snav__badge ~ .snav__go { margin-left: 6px; }
.snav__back { display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 10px 6px 6px; border: 0; border-radius: 14px; background: none; color: #e8d6f5; font: inherit; font-weight: 700; cursor: pointer; }
.snav__back .ico { width: 34px; height: 34px; padding: 8px; }
.snav__back:hover { background: rgba(240, 238, 245, .06); }
.snav__back:focus-visible { outline: 3px solid var(--sb-accent); outline-offset: -3px; }

/* the buttons at the bottom: Account, Sign out, Collapse */
.snav__bottom { display: flex; gap: 8px; padding-top: 12px; border-top: 1px solid var(--sb-line); }
.snav__bottom .signout { display: flex; flex: 1; margin: 0; }
.snav__tool { position: relative; flex: 1; display: grid; place-items: center; height: 42px; padding: 0; border: 0; border-radius: 16px; background: rgba(240, 238, 245, .06); color: var(--sb-text-2); font: inherit; cursor: pointer; text-decoration: none; }
.snav__tool .ico { width: 22px; height: 22px; }
.snav__tool:hover { background: rgba(240, 238, 245, .12); color: var(--sb-text); }
.snav__tool:focus-visible { outline: 3px solid var(--sb-accent); outline-offset: 2px; }
.snav__tool[aria-current="page"] { background: var(--sb-accent); color: var(--sb-on-accent); }
.snav__rail .ico { transition: transform .2s ease; }
html.rail .snav__rail .ico { transform: rotate(180deg); }

/* collapsed: icons only; names stay for assistive technology, and show as a pill on hover or focus */
html.rail .snav { padding-inline: 12px; }
html.rail .snav__text, html.rail .snav__label { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
html.rail .snav__brand .snav__text { display: none; }
html.rail .snav__brand img { width: 36px; height: 36px; border-radius: 10px; }
html.rail .snav__brand.has-wordmark img { display: block; }
html.rail .snav__head { justify-content: center; padding: 2px 0 0; }
html.rail .snav__brand { height: auto; }
html.rail .snav__id { margin-inline: -12px; }
html.rail .snav__pane { overflow-x: hidden; }
html.rail .snav__list { gap: 2px; }
html.rail .snav__link { justify-content: center; padding: 4px; }
html.rail .snav__link .ico { width: 32px; height: 32px; padding: 8px; }
html.rail .snav__group + .snav__group { margin-top: 6px; padding-top: 6px; }
html.rail .snav__badge { position: absolute; top: 2px; right: 8px; min-width: 18px; margin: 0; padding: 0 4px; font-size: .72rem; line-height: 18px; }
html.rail .snav__bottom { flex-direction: column; align-items: center; }
html.rail .snav__bottom .signout { flex: none; }
html.rail .snav__tool { flex: none; width: 48px; }
html.rail .snav__back { justify-content: center; padding: 4px; }
@media (min-width: 900px) {
  html.rail .ucard { justify-content: center; padding: 12px 0; }
  html.rail .snav__org { justify-content: center; padding-inline: 0; }
}
@media (max-height: 760px) { .snav__link .ico { width: 31px; height: 31px; padding: 7px; } .snav__list { gap: 2px; } }

/* the name pill shown beside an icon when the menu is collapsed (placed by sidebar.js, so scrolling never clips it) */
.snav-tip { position: fixed; z-index: 95; padding: 7px 16px; border-radius: 999px; background: var(--sb-accent); color: var(--sb-on-accent); font-family: var(--sb-font); font-size: .8rem; font-weight: 600; white-space: nowrap; pointer-events: none; box-shadow: 0 10px 24px -10px rgba(0, 0, 0, .8); }

/* ---------- small screens: the menu becomes a drawer */
.snav-backdrop { position: fixed; inset: 0; z-index: 75; background: rgba(8, 5, 16, .7); }
.snav-backdrop[hidden] { display: none; }
@media (max-width: 899px) {
  .shell { grid-template-columns: minmax(0, 1fr); min-height: calc(100vh - var(--topbar-h)); }
  .snav { position: static; margin: var(--snav-gap); height: auto; }
  html.js .snav { position: fixed; top: 0; left: 0; z-index: 80; margin: 0; width: min(310px, 88vw); height: 100%; border-radius: 0 30px 30px 0; transform: translateX(-100%); visibility: hidden; overflow-y: auto; transition: transform .2s ease, visibility 0s linear .2s; box-shadow: 24px 0 48px -16px rgba(0, 0, 0, .7); }
  html.js .snav-open .snav { transform: none; visibility: visible; transition: transform .2s ease; }
  html.js .snav__close { display: inline-grid; }
  html.js .snav__rail { display: none; }
  html.rail .snav__text, html.rail .snav__label { position: static; width: auto; height: auto; margin: 0; overflow: visible; clip: auto; white-space: normal; }
  html.rail .snav__brand .snav__text { display: inline; }
  html.rail .snav__brand img { width: 35px; height: 35px; border-radius: 0; }
  html.rail .snav__brand.has-wordmark img { display: none; }
  html.rail .snav__head { justify-content: flex-start; padding: 6px 6px 2px; }
  html.rail .snav__brand { height: 35px; }
  html.rail .snav__link { justify-content: flex-start; padding: 5px 9px 5px 5px; }
  html.rail .snav__link .ico { width: 34px; height: 34px; padding: 8px; }
  html.rail .snav__list { gap: 3px; }
  html.rail .snav__group + .snav__group { margin-top: 10px; padding-top: 10px; }
  html.rail .snav__id { margin-inline: -14px; }
  html.rail .ucard { justify-content: flex-start; padding: 12px 16px; }
  html.rail .snav__org { justify-content: flex-start; padding: 8px 16px 9px 26px; }
  html.rail .snav__bottom { flex-direction: row; align-items: stretch; }
  html.rail .snav__bottom .signout { flex: 1; }
  html.rail .snav__tool { flex: 1; width: auto; }
  html.rail .snav__badge { position: static; margin-left: -4px; padding: 2px 7px; font-size: .72rem; line-height: normal; }
  html.rail .snav__back { justify-content: flex-start; padding: 6px 10px 6px 6px; }
  .snav__nav { overflow-x: clip; overflow-y: visible; flex: none; }
  .snav__track, .snav__pane { height: auto; }
  .snav__pane { overflow: visible; }
}
@media (prefers-reduced-motion: reduce) { .snav__track, .snav__pane[inert], .snav__rail .ico, .ovl { transition: none; } html.js .snav-open .snav { transition: none; } }
/* the scrollbar in the menu: a slim, quiet thumb */
.snav__pane::-webkit-scrollbar, .snav::-webkit-scrollbar { width: 8px; height: 8px; }
.snav__pane::-webkit-scrollbar-track, .snav::-webkit-scrollbar-track { background: transparent; }
.snav__pane::-webkit-scrollbar-thumb, .snav::-webkit-scrollbar-thumb { background: rgba(240, 238, 245, .28); border-radius: 999px; border: 2px solid transparent; background-clip: content-box; }
.snav__pane::-webkit-scrollbar-button, .snav::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
body.bare .snav, body.bare .topbar { display: none; } /* pages shown bare (no menu) */
html:not(.js) .snav__rail { display: none; } /* collapsing needs JavaScript */
@media print { .snav, .topbar, .snav-backdrop { display: none !important; } }
