/* ============================================
   Camp Teapunk — Portal (member pages)
   Inherits tokens from styles.css (--bg, --accent, etc.)
   ============================================ */

.portal-body {
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- Nav ---------- */
.portal-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--nav-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.portal-nav-inner {
  max-width: var(--container);
  margin: 0 auto;
  padding: 1rem var(--gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.portal-nav-logo {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  letter-spacing: 0.02em;
  color: var(--text);
}

.portal-nav-links {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  font-size: var(--text-base);
}

.portal-nav-toggle {
  display: none;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  width: 44px;
  height: 44px;
  position: relative;
}

.portal-nav-toggle span {
  position: absolute;
  left: 10px;
  width: 24px;
  height: 1.5px;
  background: var(--text);
  transition: transform 0.25s var(--ease-out), top 0.25s var(--ease-out), opacity 0.25s var(--ease-out);
}

.portal-nav-toggle span:nth-child(1) { top: 16px; }
.portal-nav-toggle span:nth-child(2) { top: 21.5px; }
.portal-nav-toggle span:nth-child(3) { top: 27px; }

.portal-nav-toggle[aria-expanded="true"] span:nth-child(1) {
  top: 21.5px;
  transform: rotate(45deg);
}

.portal-nav-toggle[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
}

.portal-nav-toggle[aria-expanded="true"] span:nth-child(3) {
  top: 21.5px;
  transform: rotate(-45deg);
}

@media (max-width: 720px) {
  .portal-nav-toggle { display: block; }

  /* On mobile we want a fully solid nav so page content doesn't ghost
     through. Desktop keeps the translucent + blur effect via the default
     value on .portal-nav. */
  .portal-nav { --nav-bg: var(--bg); }

  .portal-nav-links {
    /* Explicit T/R/B/L (not `inset` shorthand) + an explicit height with a
       dvh fallback: WebKit/Blink collapse a flex column on `position: fixed`
       to content height when only `inset` is set, leaving the menu items
       overflowing the panel background — the original "text overlays the
       page" bug. */
    position: fixed;
    top: var(--portal-nav-h);
    right: 0;
    bottom: 0;
    left: 0;
    height: calc(100vh - var(--portal-nav-h));
    height: calc(100dvh - var(--portal-nav-h));
    background: var(--bg);
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    padding: 2rem var(--gutter);
    gap: 1.5rem;
    font-size: var(--text-lg);
    overflow-y: auto;
    transform: translateX(100%);
    /* Keep the panel inert when closed: visibility flips after the slide-
       out completes; on open it flips instantly. Without this pairing the
       panel briefly pops in/out instead of sliding. */
    visibility: hidden;
    transition:
      transform 0.3s var(--ease-out),
      visibility 0s linear 0.3s;
    border-left: 1px solid var(--border);
    z-index: 40;
  }

  .portal-nav-links.open {
    transform: translateX(0);
    visibility: visible;
    transition:
      transform 0.3s var(--ease-out),
      visibility 0s;
  }

  .portal-nav-links a,
  .portal-nav-links button {
    padding: 0.6rem 0;
    text-align: left;
  }

  .portal-nav-name {
    order: 10;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
  }

  .portal-nav-form {
    order: 11;
  }

  /* Theme toggle inside the burger panel — sits last so it's out of the way
     of the primary nav links. Avoids adding a third element to the cramped
     375px mobile nav row. */
  .portal-theme-form {
    order: 12;
    margin-top: 0.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
  }
}

/* ---------- Theme toggle ---------- */
/* Form has no chrome — the button is the entire affordance. */
.portal-theme-form {
  margin: 0;
}

.portal-theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 0.45rem 0.9rem;
  color: var(--text-muted);
  cursor: pointer;
  font: inherit;
  font-size: var(--text-sm);
  transition: color 0.2s var(--ease-out), border-color 0.2s var(--ease-out), background 0.2s var(--ease-out);
}

.portal-theme-toggle:hover {
  color: var(--text);
  border-color: var(--accent);
  background: var(--accent-bg-soft);
}

.portal-theme-toggle-icon {
  font-size: 1.05em;
  line-height: 1;
  color: var(--accent);
}

.portal-nav-links a {
  color: var(--text-muted);
  transition: color 0.2s var(--ease-out);
}

.portal-nav-links a:hover,
.portal-nav-links a.active {
  color: var(--text);
}

.portal-nav-name {
  color: var(--text-muted);
  font-size: var(--text-sm);
  letter-spacing: 0.05em;
}

.portal-nav-form {
  display: inline;
  margin: 0;
}

.portal-link-btn {
  background: none;
  border: 0;
  color: var(--text-muted);
  padding: 0;
  cursor: pointer;
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-thickness: 1px;
  text-decoration-color: var(--border);
  transition: color 0.2s var(--ease-out), text-decoration-color 0.2s var(--ease-out);
}

.portal-link-btn:hover {
  color: var(--text);
  text-decoration-color: var(--accent);
}

/* ---------- Main layout ---------- */
/* The page had one gap value — up to 5rem — between every top-level block,
   so a filter row sat as far from its own search box as one section sits from
   the next. Everything was equally far apart, which reads as no rhythm at all
   and is most of what made the portal feel loose.

   Two tiers now: adjacent control rows (filters, a search box, a result
   count, a legend) sit close enough to read as one toolbar, and a <section>
   — the markup already distinguishes them — gets the full air on either
   side. The gap and the margin compound, so section spacing lands near the
   old value while everything else tightens. */
.portal-main {
  flex: 1;
  max-width: var(--container);
  width: 100%;
  margin: 0 auto;
  padding: clamp(3rem, 6vw, 5rem) var(--gutter) clamp(4rem, 8vw, 6rem);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.portal-main > section + *,
.portal-main > * + section {
  margin-top: clamp(1.5rem, 3vw, 2.5rem);
}

/* ---------- Hero ---------- */
.portal-hero {
  max-width: 820px;
}

.portal-eyebrow {
  display: inline-block;
  font-size: var(--text-2xs);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1.2rem;
}

.portal-heading-xl {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 5.5vw, 4rem);
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: -0.015em;
  margin-bottom: 1.2rem;
}

.portal-heading-lg {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 400;
  line-height: 1.1;
  margin-bottom: 1rem;
}

.portal-heading-md {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 400;
  line-height: 1.2;
  margin-bottom: 0.8rem;
}

.portal-heading-sm {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 400;
  line-height: 1.25;
  margin-bottom: 0.3rem;
}

.portal-heading-xl em,
.portal-heading-lg em {
  font-style: italic;
  color: var(--accent);
}

.portal-lead {
  font-size: clamp(1rem, 1.4vw, 1.15rem);
  color: var(--text-muted);
  max-width: 62ch;
  margin-bottom: 1.5rem;
}

.portal-muted {
  color: var(--text-muted);
}

.portal-small {
  font-size: var(--text-sm);
}

/* ---------- Cards ---------- */
.portal-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
}

.portal-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

@media (max-width: 720px) {
  .portal-split {
    grid-template-columns: 1fr;
  }
}

.portal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  /* Resting elevation. Every surface in the portal used to be a flat fill
     plus a 1px border, so nothing could be brought forward and a page of
     eight cards read as eight equals. */
  box-shadow: var(--shadow-1), var(--edge-top);
  transition: box-shadow 0.2s var(--ease-out), border-color 0.2s var(--ease-out),
    transform 0.2s var(--ease-out);
}

/* A card that is also a link lifts on hover; a static one must not, or the
   page twitches under the cursor for no reason. */
/* --accent, not a faint accent wash (the old --accent-dim, an 8–10% alpha meant for
   backgrounds). As a border it composites to within a couple of points of
   --border on the dark theme (invisible), and on light it lands LIGHTER than
   the resting border, so hovering made the outline fade into the page. */
a.portal-card:hover {
  box-shadow: var(--shadow-2), var(--edge-top);
  border-color: var(--accent);
  transform: translateY(-2px);
}

.portal-card-accent {
  border-color: rgba(var(--accent-rgb), 0.35);
  background: linear-gradient(180deg, rgba(var(--accent-rgb), 0.05), var(--surface) 60%);
}

.portal-card p {
  color: var(--text-muted);
}

.portal-card .portal-btn {
  align-self: flex-start;
  margin-top: 0.5rem;
}

/* ---------- Schedule agenda (day/event/shift grouping) ---------- */
.portal-schedule-day {
  margin-bottom: 0;
}

.portal-schedule-day + .portal-schedule-day {
  border-top: 1px solid var(--border);
  padding-top: 0.15rem;
}

.portal-schedule-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem 1.2rem;
  margin-bottom: 0.75rem;
  box-shadow: var(--shadow-1), var(--edge-top);
  scroll-margin-top: calc(var(--portal-nav-h, 56px) + var(--space-3));
}

.portal-schedule-item {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  margin-bottom: 0.6rem;
  display: flex;
  flex-flow: row wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.6rem;
  scroll-margin-top: calc(var(--portal-nav-h, 56px) + var(--space-3));
}

.portal-schedule-item-main {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  flex: 1 1 220px;
  min-width: 0;
}

.portal-schedule-group-row {
  display: flex;
  flex-flow: row wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.6rem;
}

.portal-schedule-group-main {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  flex: 1 1 220px;
  min-width: 0;
}

/* Right-side avatar+name list — attendees on a shift row, leads on an
   event card. Uses the same personAvatar() as the people roster, just at
   list-compact size rather than roster-card size. */
.portal-schedule-people {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.35rem;
  flex: 0 0 auto;
}

.portal-schedule-people-label {
  font-size: var(--text-2xs);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.portal-schedule-person {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.portal-schedule-people .portal-person-avatar {
  width: 26px;
  height: 26px;
}

.portal-schedule-people .portal-person-avatar-empty {
  font-size: var(--text-3xs);
}

.portal-schedule-nested {
  margin-left: 1rem;
  padding-left: 0.75rem;
  border-left: 2px solid rgba(var(--accent-rgb), 0.5);
}

.portal-schedule-nested .portal-schedule-item {
  margin-bottom: 0.5rem;
}

.portal-schedule-nested .portal-schedule-item:last-child {
  margin-bottom: 0;
}

/* Compact eyebrow/heading and reused .portal-form/.portal-form-actions —
   those base rules assume a full page-level form (1.5rem + 1rem of margin
   before the button row), which reads as a lot of dead air when reused for
   a single small Sign up/Cancel button inside a densely repeated list. */
.portal-schedule-item .portal-eyebrow,
.portal-schedule-group .portal-eyebrow {
  margin-bottom: 0.3rem;
}

.portal-schedule-item .portal-form,
.portal-schedule-group .portal-form {
  margin-top: 0.2rem;
  gap: 0.5rem;
}

.portal-schedule-item .portal-form-actions,
.portal-schedule-group .portal-form-actions {
  margin-top: 0;
  justify-content: flex-start;
}

/* ---------- Open-shifts shortcut (above the schedule agenda) ---------- */
.portal-open-shifts {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem 1.2rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-1), var(--edge-top);
}

.portal-open-shifts-head {
  display: flex;
  flex-flow: row wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.portal-open-shifts-title {
  font-size: var(--text-md);
  margin: 0;
}

/* Rows inside a day are separated by a 1px hairline, so a day break needs to
   read as the heavier boundary of the two — hence the accent-tinted 2px rule
   plus more air than the gap between rows. */
.portal-open-shifts-day + .portal-open-shifts-day {
  margin-top: 1.1rem;
  padding-top: 0.85rem;
  border-top: 2px solid rgba(var(--accent-rgb), 0.3);
}

/* Full --text rather than --text-muted: the gold belongs to the links and
   badges, so structure labels earn their weight from contrast instead. At
   --text-3xs muted this was the faintest thing on the card despite being the
   one line that segments it. */
.portal-open-shifts-daylabel {
  font-size: var(--text-2xs);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text);
  margin: 0 0 0.45rem;
}

/* Wraps rather than switching layout at a breakpoint — same approach as
   .portal-schedule-item, so the badge drops below the meta line on narrow
   screens without a media query. */
.portal-open-shifts-row {
  display: flex;
  flex-flow: row wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.45rem 0;
  border-top: 1px solid var(--border);
}

/* :first-of-type, not :first-child — when day labels are shown, the <p> label
   is the first child of the day container and the first row is not. */
.portal-open-shifts-row:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.portal-open-shifts-main {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  flex: 1 1 220px;
  min-width: 0;
}

.portal-open-shifts-main .portal-eyebrow {
  margin-bottom: 0;
}

.portal-open-shifts-main p {
  margin: 0;
}

.portal-open-shifts-link {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--accent);
}

.portal-open-shifts-link:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.portal-open-shifts-badge {
  flex: none;
  white-space: nowrap;
  font-size: var(--text-2xs);
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-bg-soft);
  border: 1px solid rgba(var(--accent-rgb), 0.28);
  border-radius: var(--radius-pill);
  padding: 0.15rem 0.6rem;
}

/* The fragment jump is instant, so mark what was landed on. Pairs with the
   scroll-margin-top on .portal-schedule-group / .portal-schedule-item above
   (the schedule-agenda section) — that rule keeps the landed-on row clear of
   the sticky nav, this rule is what makes it visible once it's there. */
.portal-schedule-group:target,
.portal-schedule-item:target {
  border-color: var(--accent);
  background: var(--accent-bg-soft);
}

/* ---------- Shelter tally (admin roster) ---------- */
.portal-shelter-tally {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.3rem;
}

/* ---------- People picker (who else is in your shelter) ---------- */
/* .portal-check was built for a handful of short fixed labels in a row. These
   are however many camp names, of any length, so they need their own rules:
   a flex item shrinks below its content by default, which squeezed each chip
   narrower than the name inside it and spilled the text across its neighbours.
   flex-shrink: 0 keeps every chip as wide as the name it holds. */
.portal-person-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.6rem;
  padding: 0.85rem;
  max-height: 16rem;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-alt);
}

.portal-person-check {
  flex: 0 0 auto;
  max-width: 100%;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  cursor: pointer;
  font-size: var(--text-sm);
  line-height: 1.3;
  /* A playa name can be one long unbroken string; without this it would push
     past the chip (which doesn't shrink) and out of the box. */
  overflow-wrap: anywhere;
  transition: border-color 0.2s var(--ease-out), background 0.2s var(--ease-out);
}

/* The name deliberately carries no overflow or min-width rule: either one
   resolves a flex item's automatic minimum size to zero and collapses the name
   to nothing. Long names wrap inside the chip, which flex-shrink: 0 allows. */

/* The picker sits inside a .portal-field, for its uppercase label and its
   full-width slot in the form grid. That means `.portal-field input` applies:
   full width, padding, border, its own background — which turns each checkbox
   into a panel the size of the chip and shoves the name out past the edge.
   Undo it for these checkboxes specifically. */
.portal-person-check input[type="checkbox"] {
  flex: 0 0 auto;
  width: auto;
  padding: 0;
  border: none;
  border-radius: 0;
  background: none;
  accent-color: var(--accent);
}

.portal-person-check:hover {
  border-color: var(--accent);
}

.portal-person-check:has(input:checked) {
  border-color: var(--accent);
  background: rgba(var(--accent-rgb), 0.1);
}

.portal-mini-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.4rem;
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin: 0.2rem 0;
}

.portal-mini-stats strong {
  color: var(--text);
  font-weight: 500;
}

.portal-list {
  list-style: none;
  padding: 0;
  margin: 0;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.portal-linked-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
}

/* Season history on /me. Year, standing, and a way back into that card.
   Wraps rather than squashing on a phone — the year must stay readable. */
.portal-season-list li {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border);
}

.portal-season-list li:last-child {
  border-bottom: 0;
}

.portal-season-list li strong {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  min-width: 3.5rem;
}

.portal-season-list li a {
  margin-left: auto;
}

/* Who was at a past burn. Initials rather than photos: servePhoto only
   serves the current season's roster, so a face here would 404. */
.portal-cohort-list li {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border);
}

.portal-cohort-list li:last-child {
  border-bottom: 0;
}

.portal-cohort-initials {
  flex: 0 0 auto;
  width: 2.2rem;
  height: 2.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-circle);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  font-size: var(--text-2xs);
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.portal-cohort-name {
  flex: 1 1 auto;
  min-width: 0;
}

/* Shared contact details. Wraps under the name on a phone rather than
   squeezing an email address into a few characters. */
/* ---------- Photo gallery ---------- */

.portal-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-4);
  list-style: none;
  margin: 0;
  padding: 0;
}

.portal-gallery-item {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

/* aspect-ratio + max-width so a tile never forces the page wider than the
   screen on a phone. */
.portal-gallery-link {
  display: block;
  aspect-ratio: 1;
  max-width: 100%;
  overflow: hidden;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
}

.portal-gallery-link img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s ease;
}

.portal-gallery-link:hover img {
  transform: scale(1.04);
}

.portal-gallery-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2);
}

.portal-gallery-actions {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
}

.portal-cohort-contact {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-3);
  font-size: var(--text-sm);
}

/* Season switcher on /admin/seasons. Years need real space between them —
   run together they read as one number. */
.portal-season-years {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
}

/* The old div-based progress bar lived here. It was replaced by .portal-meter
   (a native <progress>) because its width had to be set with an inline style,
   which the CSP strips — so it always rendered full. Nothing consumes these
   class names any more. */

/* ---------- Narrow (forms, prose) ---------- */
.portal-narrow {
  max-width: var(--container-narrow);
  margin: 0 auto;
  width: 100%;
}

.portal-prose h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4.5vw, 2.8rem);
  font-weight: 400;
  line-height: 1.1;
  margin-bottom: 1rem;
}

.portal-prose h2 {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 400;
  margin: 2rem 0 0.6rem;
}

.portal-prose h3 {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 400;
  margin: 1.4rem 0 0.4rem;
}

.portal-prose p,
.portal-prose li {
  color: var(--text-muted);
  line-height: 1.75;
}

.portal-prose ul {
  padding-left: 1.2rem;
  margin-bottom: 1rem;
}

.portal-prose a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--border);
}

.portal-prose a:hover {
  text-decoration-color: var(--accent);
}

.portal-prose hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

/* ---------- Forms ---------- */
.portal-form {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  margin-top: 1.5rem;
}

.portal-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.2rem;
}

@media (max-width: 640px) {
  .portal-form-grid {
    grid-template-columns: 1fr;
  }
}

.portal-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

/* `.portal-field`'s explicit display would otherwise override the UA
   `[hidden]{display:none}` rule (author beats UA in the cascade), leaving a
   [hidden]-toggled field visible. This higher-specificity rule restores it —
   used by the schedule form's kind-based field toggling. */
.portal-field[hidden] {
  display: none;
}

.portal-field-full {
  grid-column: 1 / -1;
}

.portal-field > span {
  font-size: var(--text-xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.portal-field input,
.portal-field select,
.portal-field textarea {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.85rem;
  color: var(--text);
  font: inherit;
  line-height: 1.4;
  width: 100%;
  box-sizing: border-box;
  transition: border-color 0.2s var(--ease-out), background-color 0.2s var(--ease-out);
}

.portal-field input:focus,
.portal-field select:focus,
.portal-field textarea:focus {
  outline: none;
  border-color: var(--accent);
  /* background-color (not the `background` shorthand) so the custom select
     chevron background-image survives the focus state. */
  background-color: var(--bg-alt);
}

.portal-field textarea {
  resize: vertical;
  min-height: 6rem;
  line-height: 1.6;
}

.portal-fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem 1.2rem 1.2rem;
  background: var(--surface);
}

.portal-fieldset > legend {
  padding: 0 0.5rem;
  font-size: var(--text-xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.portal-radio-row,
.portal-check-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-top: 0.6rem;
}

.portal-radio,
.portal-check {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  cursor: pointer;
  background: var(--bg-alt);
  transition: border-color 0.2s var(--ease-out), background 0.2s var(--ease-out);
  font-size: var(--text-base);
}

.portal-radio input,
.portal-check input {
  accent-color: var(--accent);
}

.portal-radio:has(input:checked),
.portal-check:has(input:checked) {
  border-color: var(--accent);
  background: rgba(var(--accent-rgb), 0.08);
}

.portal-form-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
}

.portal-form-actions .portal-link-btn {
  color: var(--text-muted);
}

/* ---------- Buttons ---------- */
.portal-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.75rem 1.3rem;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: var(--text-base);
  cursor: pointer;
  transition: transform 0.2s var(--ease-out), background 0.2s var(--ease-out), border-color 0.2s var(--ease-out), color 0.2s var(--ease-out), box-shadow 0.2s var(--ease-out);
  border: 1px solid transparent;
  text-align: center;
}

.portal-btn-primary {
  background: var(--accent);
  color: var(--on-accent);
  border-color: var(--accent);
}

.portal-btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(var(--accent-rgb), 0.15);
}

.portal-btn-outline {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}

.portal-btn-outline:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}

.portal-btn-danger {
  background: var(--danger-strong);
  color: #fff;
  border-color: var(--danger-strong);
}

.portal-btn-danger:hover {
  background: var(--danger-strong);
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(var(--danger-rgb), 0.25);
}

/* Owner-only destructive section on the member detail page. */
.portal-danger-zone {
  border: 1px solid rgba(var(--danger-rgb), 0.4);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  background: rgba(var(--danger-rgb), 0.05);
}

.portal-danger-zone h3 {
  color: var(--danger-strong);
}

/* ---------- Status messages ---------- */
.portal-success,
.portal-error {
  padding: 0.7rem 1rem;
  border-radius: var(--radius-sm);
  font-size: var(--text-base);
}

.portal-success {
  background: rgba(var(--success-rgb), 0.08);
  border: 1px solid rgba(var(--success-rgb), 0.3);
  color: var(--success);
}

.portal-error {
  background: rgba(var(--danger-rgb), 0.08);
  border: 1px solid rgba(var(--danger-rgb), 0.3);
  color: var(--danger);
}

/* ---------- Fine print ---------- */
.portal-fine-print {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.4rem 1.6rem;
  color: var(--text-muted);
  font-size: var(--text-base);
  line-height: 1.7;
}

.portal-fine-print strong {
  color: var(--text);
  font-weight: 500;
}

/* ---------- Check (stacked variant) ---------- */
.portal-check-stack {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.8rem 1rem;
  border-radius: var(--radius-md);
  background: var(--bg-alt);
  border: 1px solid var(--border);
  cursor: pointer;
  margin-bottom: 0.6rem;
}

.portal-check-stack:has(input:checked) {
  border-color: var(--accent);
  background: rgba(var(--accent-rgb), 0.06);
}

.portal-check-stack input {
  margin-top: 0.25rem;
  accent-color: var(--accent);
}

.portal-check-stack span {
  color: var(--text);
  line-height: 1.55;
}

.portal-check-stack a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.portal-visually-hidden {
  position: absolute !important;
  clip: rect(0 0 0 0);
  width: 1px;
  height: 1px;
  overflow: hidden;
  white-space: nowrap;
}

/* ---------- Field errors ---------- */
.portal-field-invalid input,
.portal-field-invalid select,
.portal-field-invalid textarea {
  border-color: rgba(var(--danger-rgb), 0.6);
  /* background-color (not the `background` shorthand) so an invalid <select>
     keeps its custom chevron background-image. */
  background-color: rgba(var(--danger-rgb), 0.04);
}

.portal-field-error {
  color: var(--danger);
  font-size: var(--text-xs);
  margin-top: 0.2rem;
}

/* ---------- File upload + preview ---------- */
.portal-field input[type="file"] {
  padding: 0.55rem 0.7rem;
  font-size: var(--text-sm);
  cursor: pointer;
}

.portal-field input[type="file"]::-webkit-file-upload-button {
  background: var(--bg-alt);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.8rem;
  margin-right: 0.8rem;
  cursor: pointer;
  font: inherit;
  transition: border-color 0.2s var(--ease-out);
}

.portal-field input[type="file"]::-webkit-file-upload-button:hover {
  border-color: var(--accent);
}

.portal-photo-preview {
  margin-top: 0.9rem;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-alt);
  max-width: 260px;
}

.portal-photo-preview img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 320px;
  object-fit: cover;
}

/* ---------- Chips (suggestion buttons) ---------- */
.portal-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.8rem 0 1rem;
}

.portal-chip {
  background: var(--bg-alt);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 0.4rem 0.9rem;
  font: inherit;
  font-size: var(--text-sm);
  cursor: pointer;
  transition: border-color 0.2s var(--ease-out), background 0.2s var(--ease-out), color 0.2s var(--ease-out);
}

.portal-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.portal-chip.selected {
  border-color: var(--accent);
  background: rgba(var(--accent-rgb), 0.1);
  color: var(--accent);
}

/* ---------- Autocomplete ---------- */
.portal-autocomplete {
  position: relative;
}

.portal-autocomplete-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 20;
  margin: 0;
  padding: 0.4rem 0;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  /* The one surface in the portal that genuinely floats over other content,
     so it takes the top elevation step. It used to carry a hand-rolled
     30%-black shadow, which on the light theme is exactly the "reads as dirt"
     failure the token comments warn about — the tokens are theme-aware. */
  box-shadow: var(--shadow-3);
  max-height: 280px;
  overflow-y: auto;
}

.portal-autocomplete-item,
.portal-autocomplete-empty {
  padding: 0.6rem 0.9rem;
  font-size: var(--text-base);
  cursor: pointer;
  color: var(--text);
}

.portal-autocomplete-item:hover,
.portal-autocomplete-item.active {
  background: rgba(var(--accent-rgb), 0.08);
  color: var(--accent);
}

.portal-autocomplete-sub {
  color: var(--text-muted);
  font-size: var(--text-xs);
  margin-left: 0.5rem;
}

.portal-autocomplete-empty {
  color: var(--text-muted);
  cursor: default;
}

/* ---------- Review list ---------- */
.portal-review-group {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* --text-xl, not --text-lg: this is the section heading above a list whose
   applicant names are themselves --text-lg in the same display face. Mapping
   both to the same step erased the hierarchy between "Pending" and the people
   listed under it. */
.portal-review-heading {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 400;
  color: var(--text);
  margin-bottom: 0.4rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.portal-review-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-body);
  font-size: var(--text-2xs);
  letter-spacing: 0.1em;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 0.15rem 0.6rem;
  color: var(--text-muted);
}

.portal-review-list {
  display: grid;
  gap: 0.8rem;
}

.portal-review-card {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 1rem;
  padding: 0.9rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  align-items: center;
  transition: border-color 0.2s var(--ease-out), transform 0.2s var(--ease-out);
}

.portal-review-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.portal-review-photo {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-alt);
  display: flex;
  align-items: center;
  justify-content: center;
}

.portal-review-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.portal-review-photo-placeholder {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  color: var(--accent);
}

.portal-review-meta {
  min-width: 0;
}

.portal-review-name {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  line-height: 1.2;
  color: var(--text);
  margin-bottom: 0.15rem;
}

.portal-review-sub {
  font-size: var(--text-xs);
  color: var(--text-muted);
  line-height: 1.5;
}

.portal-review-tally {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.portal-review-status {
  text-align: right;
}

@media (max-width: 640px) {
  .portal-review-card {
    grid-template-columns: 56px 1fr;
    grid-template-rows: auto auto;
  }
  .portal-review-status {
    grid-column: 1 / -1;
    text-align: left;
  }
  .portal-review-photo {
    width: 56px;
    height: 56px;
  }
}

.portal-vote-pill {
  display: inline-block;
  padding: 0.25rem 0.7rem;
  border-radius: var(--radius-pill);
  font-size: var(--text-2xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 1px solid transparent;
}
.portal-vote-yes-text     { color: var(--success); }
.portal-vote-discuss-text { color: var(--accent); }
.portal-vote-no-text      { color: var(--danger); }
.portal-vote-yes      { background: rgba(var(--success-rgb), 0.12); color: var(--success); border-color: rgba(var(--success-rgb), 0.35); }
.portal-vote-discuss  { background: rgba(var(--accent-rgb), 0.12); color: var(--accent); border-color: rgba(var(--accent-rgb), 0.35); }
.portal-vote-no       { background: rgba(var(--danger-rgb), 0.12); color: var(--danger); border-color: rgba(var(--danger-rgb), 0.35); }
.portal-vote-pending  { background: var(--bg-alt); color: var(--text-muted); border-color: var(--border); }

/* ---------- Review detail ---------- */
.portal-review-detail {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Camp-ops detail/form pages: wider than the application-review reading column. */
.portal-ops-detail {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Ops pages reuse the review hero but have no photo, so collapse its
   120px-photo grid to a single full-width column (otherwise the title and
   description get crammed into the empty photo column). */
/* Ops detail pages are text-only except the person page, which now leads with
   an avatar like the admin member detail does. */
.portal-ops-detail .portal-review-hero {
  grid-template-columns: 1fr;
}

.portal-ops-detail .portal-review-hero:has(.portal-person-detail-photo) {
  grid-template-columns: 96px 1fr;
}

@media (max-width: 560px) {
  .portal-ops-detail .portal-review-hero:has(.portal-person-detail-photo) {
    grid-template-columns: 1fr;
  }
}

.portal-ops-counts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.portal-ops-count {
  display: inline-flex;
  align-items: baseline;
  gap: 0.25rem;
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-pill);
  background: var(--bg-alt);
  color: var(--text-muted);
  border: 1px solid var(--border);
  font-size: var(--text-xs);
}

.portal-ops-count strong {
  color: var(--text);
}

.portal-ops-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.portal-ops-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.portal-ops-list li:last-child {
  border-bottom: 0;
}

.portal-ops-section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.portal-review-back {
  color: var(--text-muted);
  font-size: var(--text-sm);
  text-decoration: none;
}

.portal-review-back:hover {
  color: var(--accent);
}

.portal-review-hero {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 1.2rem;
  align-items: center;
}

.portal-review-hero-photo {
  width: 120px;
  height: 120px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-alt);
  display: flex;
  align-items: center;
  justify-content: center;
}

.portal-review-hero-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.portal-review-facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem 1.2rem;
}

@media (max-width: 600px) {
  .portal-review-facts {
    grid-template-columns: 1fr;
  }
}

.portal-review-facts div { display: flex; flex-direction: column; gap: 0.15rem; }
.portal-review-facts dt {
  font-size: var(--text-2xs);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.portal-review-facts dd {
  color: var(--text);
  font-size: var(--text-base);
  word-break: break-word;
}
.portal-review-facts dd a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }

.portal-review-block h3 {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 400;
  margin-bottom: 0.6rem;
}

.portal-review-block p {
  color: var(--text);
  line-height: 1.7;
  white-space: pre-wrap;
}

.portal-tag {
  display: inline-block;
  padding: 0.3rem 0.8rem;
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: rgba(var(--accent-rgb), 0.1);
  color: var(--accent);
  border: 1px solid rgba(var(--accent-rgb), 0.3);
  margin-top: 0.3rem;
}

/* ---------- Vote form ---------- */
.portal-review-vote {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 1.2rem 1.4rem 1.4rem;
  box-shadow: var(--shadow-1), var(--edge-top);
}

.portal-review-vote h3 {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 400;
  margin-bottom: 0.8rem;
}

.portal-vote-choices {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
  margin-bottom: 1rem;
}

@media (max-width: 480px) {
  .portal-vote-choices {
    grid-template-columns: 1fr;
  }
}

.portal-vote-choice {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.9rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-alt);
  cursor: pointer;
  font-weight: 500;
  transition: border-color 0.2s var(--ease-out), background 0.2s var(--ease-out), color 0.2s var(--ease-out);
}

.portal-vote-choice input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 1px;
  height: 1px;
}

.portal-vote-choice span {
  pointer-events: none;
}

.portal-vote-choice:has(input:checked) {
  color: var(--text);
}

.portal-vote-choice-yes:has(input:checked) {
  border-color: rgba(var(--success-rgb), 0.6);
  background: rgba(var(--success-rgb), 0.1);
  color: var(--success);
}
.portal-vote-choice-discuss:has(input:checked) {
  border-color: var(--accent);
  background: rgba(var(--accent-rgb), 0.1);
  color: var(--accent);
}
.portal-vote-choice-no:has(input:checked) {
  border-color: rgba(var(--danger-rgb), 0.6);
  background: rgba(var(--danger-rgb), 0.1);
  color: var(--danger);
}

.portal-vote-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.portal-vote-item {
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--border);
  background: var(--bg-alt);
  border-radius: var(--radius-md);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
}

.portal-vote-item p {
  flex-basis: 100%;
  margin-top: 0.2rem;
}

/* ---------- Admin ---------- */
/* Deliberately does NOT try to force any particular row count.

   An earlier version of this rule claimed a 158px floor would fit "the seven
   slots" of the dashboards on one row. That was wrong twice over: the shelter
   grids emit one tile per shelter type in USE (src/lib/shelter.ts
   shelterBreakdown), so they range from 3 to 9 slots depending on what the
   camp has recorded, and 158px only yields seven tracks above a ~1274px
   viewport anyway — leaving the original stranded tile on every laptop
   between 1096 and 1273px. Fitting a fixed number of tracks is not something
   this grid can promise.

   What it does promise is that the tiles are all one size and the row packs
   from the left, so a wrapped row reads as a continuation rather than an
   accident. The floor is set for legibility — the longest label ("YET TO
   REGISTER") needs about this much room before it wraps to three lines.

   auto-FILL, not auto-fit: the two wrap identically once there are at least
   as many items as tracks, but auto-fit collapses the empty tracks and hands
   the freed space to the survivors. The Membership row has three tiles, which
   auto-fit stretched to ~400px each — three near-empty slabs holding one
   number apiece. */
.portal-admin-counts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
  gap: var(--space-3);
  align-items: stretch;
}

.portal-count-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  box-shadow: var(--shadow-1), var(--edge-top);
  transition: border-color 0.2s var(--ease-out), transform 0.2s var(--ease-out),
    box-shadow 0.2s var(--ease-out), background-color 0.2s var(--ease-out);
}

/* :not(.portal-count-card-active) — a plain background-colour hover is
   specificity (0,2,0) and would out-rank .portal-count-card-active's gold
   wash at (0,1,0), so hovering the filter you have *applied* would wipe the
   only thing showing it is applied. */
.portal-count-card:hover:not(.portal-count-card-active) {
  background-color: var(--surface-raised);
}

.portal-count-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-2), var(--edge-top);
}

/* The active tile still needs to acknowledge the cursor — it just does it by
   deepening its own wash rather than losing it. */
.portal-count-card-active:hover {
  background-color: rgba(var(--accent-rgb), 0.14);
}

/* Deliberately NOT `margin-top: auto` on the label. Grid items already
   stretch and the number is the first flex child, so numbers were already
   aligned across a row — and pushing the label to the floor would drag the
   `.portal-count-note` that follows it on the shelter cards down with it,
   misaligning those labels against their note-less neighbours. */
.portal-count-card .portal-count-label {
  padding-top: var(--space-1);
}

.portal-count-number {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  line-height: 1;
  color: var(--text);
}

.portal-count-label {
  font-size: var(--text-xs);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* Dashboard section wrappers: eyebrow + optional explainer above a tile grid. */
.portal-admin-section {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.portal-admin-section + .portal-admin-section,
.portal-admin-section + .portal-admin-queues,
.portal-admin-queues + .portal-admin-section {
  margin-top: 2.5rem;
}

.portal-admin-section > .portal-small {
  margin: -0.4rem 0 0;
}

/* The headline registration card spans two tile slots and carries a progress bar. */
.portal-count-card-wide {
  grid-column: span 2;
}

@media (max-width: 480px) {
  .portal-count-card-wide {
    grid-column: span 1;
  }
}

.portal-count-of {
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--text-muted);
}

.portal-count-progress {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 4px;
  margin-top: 0.5rem;
  border: 0;
  border-radius: var(--radius-xs);
  overflow: hidden;
  background: var(--border);
}

.portal-count-progress::-webkit-progress-bar { background: var(--border); }
.portal-count-progress::-webkit-progress-value { background: var(--accent); }
.portal-count-progress::-moz-progress-bar { background: var(--accent); }

/* ---------- Shelters overview (/admin/shelters) ---------- */
.portal-shelter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  margin-top: 0.6rem;
}

.portal-shelter {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem 1.2rem 1.1rem;
  box-shadow: var(--shadow-1), var(--edge-top);
}

.portal-shelter-head {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
}

.portal-shelter-head .portal-count-icon {
  margin-top: 0.15rem;
  color: var(--accent);
}

.portal-shelter-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  margin: 0;
}

.portal-shelter-people {
  list-style: none;
  margin: 0.8rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.portal-shelter-people li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
}

.portal-shelter-people li:last-child {
  border-bottom: none;
}

.portal-shelter-people button[disabled] {
  opacity: 0.45;
  cursor: default;
}

/* The chase list is one flat list rather than a card grid, so it can run wide. */
.portal-shelter-people-wide {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0 1.4rem;
}

.portal-shelter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  margin-top: 0.9rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--border);
}

.portal-shelter-form {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  flex: 1 1 auto;
  min-width: 0;
}

.portal-shelter-form .portal-field {
  flex: 1 1 auto;
  min-width: 0;
}

/* Keep "Move in" / "Save kind" on one line — they sit next to a select that
   will happily take the rest of the row. */
.portal-shelter-form .portal-btn {
  flex: 0 0 auto;
  white-space: nowrap;
}

@media (max-width: 420px) {
  .portal-shelter-form {
    flex-wrap: wrap;
  }
}

/* The kind of shelter, drawn. Sits above the number and takes its colour from
   the card, so the active filter's icon goes gold with everything else. */
.portal-count-icon {
  width: 30px;
  height: 30px;
  color: var(--text-muted);
  margin-bottom: 0.1rem;
}

.portal-count-card-active .portal-count-icon,
.portal-count-card-accent .portal-count-icon {
  color: var(--accent);
}

/* A second line under a count — what the "other" shelters actually are, or
   what the number means. Sits below the label, quieter than it. */
.portal-count-note {
  font-size: var(--text-xs);
  line-height: 1.4;
  color: var(--text-muted);
  opacity: 0.85;
  overflow-wrap: anywhere;
}

/* Count cards that act as filters: the one currently applied reads as pressed
   rather than merely hovered. */
.portal-count-card-active {
  border-color: var(--accent);
  background: rgba(var(--accent-rgb), 0.08);
}

.portal-count-card-active .portal-count-number {
  color: var(--accent);
}

/* The tile that wants action: gold border pulls the eye to it. */
.portal-count-card-accent {
  border-color: rgba(var(--accent-rgb), 0.55);
}

.portal-count-card-accent .portal-count-number {
  color: var(--accent);
}

/* Lifetime membership counts matter less than the season, so shrink them. */
.portal-admin-counts-secondary .portal-count-number {
  font-size: var(--text-xl);
}

.portal-admin-counts-secondary .portal-count-card {
  padding: 0.7rem 1rem;
}

/* Roster cell for eligible members who haven't answered their year card. */
.portal-tag-notreg {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: var(--radius-pill);
  font-size: var(--text-2xs);
  letter-spacing: 0.04em;
  background: rgba(var(--accent-rgb), 0.12);
  color: var(--accent);
  border: 1px solid rgba(var(--accent-rgb), 0.35);
  white-space: nowrap;
}

.portal-admin-queues {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 720px) {
  .portal-admin-queues {
    grid-template-columns: 1fr;
  }
}

.portal-admin-audit {
  margin-top: 1rem;
}

.portal-audit-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: var(--text-sm);
}

.portal-audit-list li {
  display: grid;
  grid-template-columns: 160px 1fr 1fr auto;
  gap: 0.8rem;
  padding: 0.5rem 0.7rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
}

.portal-audit-action {
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: var(--text-xs);
}

.portal-audit-target {
  color: var(--text-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: var(--text-xs);
}

@media (max-width: 640px) {
  .portal-audit-list li {
    grid-template-columns: 1fr;
    gap: 0.1rem;
  }
}

/* ---------- Admin table + filters ---------- */
.portal-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.portal-filter {
  padding: 0.4rem 0.9rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--bg-alt);
  color: var(--text-muted);
  font-size: var(--text-sm);
  transition: border-color 0.2s var(--ease-out), color 0.2s var(--ease-out);
}

.portal-filter:hover,
.portal-filter-active {
  border-color: var(--accent);
  color: var(--accent);
}

.portal-table {
  width: 100%;
  /* `separate` (not `collapse`) is required for sticky <th> to paint its
     background reliably during scroll. */
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--text-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  /* No `overflow: hidden` on the table — it would establish a containing
     block that traps sticky <th> inside the table's own (non-scrolling) box.
     Round corners are applied to the first/last cells in each end row below. */
}

.portal-table thead tr:first-child th:first-child { border-top-left-radius: var(--radius-inner); }
.portal-table thead tr:first-child th:last-child  { border-top-right-radius: var(--radius-inner); }
.portal-table tbody tr:last-child td:first-child  { border-bottom-left-radius: var(--radius-inner); }
.portal-table tbody tr:last-child td:last-child   { border-bottom-right-radius: var(--radius-inner); }

.portal-table th {
  text-align: left;
  font-size: var(--text-2xs);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0.7rem 1rem;
  background: var(--bg-alt);
  /* Sticky header — sits just below the sticky nav so column labels stay
     visible while scrolling long lists (roster has 60+ rows). */
  position: sticky;
  top: var(--portal-nav-h, 56px);
  z-index: 2;
  /* `border-bottom` doesn't paint reliably under sticky positioning; use a
     box-shadow as a 1px hairline that always renders. */
  box-shadow: inset 0 -1px 0 var(--border);
}

.portal-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: top;
}

.portal-table tr:last-child td {
  border-bottom: 0;
}

.portal-table a {
  color: var(--accent);
}

/* Row hover affordance + whole-row click cursor on opt-in tables. The JS in
   portal.js wires the actual click handler; this is the visual signal. */
.portal-table-rowlinked tbody tr {
  transition: background 0.15s var(--ease-out);
  cursor: pointer;
}

.portal-table-rowlinked tbody tr:hover {
  background: var(--accent-bg-soft);
}

/* Roster photo thumbnail — square, rounded, with a graceful fallback for
   members without a photo. Fixed-width column so rows don't shimmy as
   photos load in (`loading="lazy"` is applied per-image). */
.portal-roster-thumb-cell {
  width: 48px;
  padding-right: 0;
}
.portal-roster-thumb {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  vertical-align: middle;
  /* Avoid jagged scale-down on retina + non-retina. */
  image-rendering: -webkit-optimize-contrast;
}
.portal-roster-thumb-empty {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  color: var(--text-muted);
}

/* Sortable table headers: clickable + an arrow indicator for the active column. */
.portal-table[data-sortable] th[data-sort-key] {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.portal-table[data-sortable] th[data-sort-key]:hover {
  color: var(--text);
}
.portal-table[data-sortable] th[data-sort-key]::after {
  /* Reserve column width for the sort arrow even when un-sorted, so headers
     don't jump horizontally the first time you click one. */
  content: '';
  display: inline-block;
  width: 0.5em;
  margin-left: 0.35em;
  opacity: 0.35;
}
.portal-table[data-sortable] th[aria-sort="ascending"]::after {
  content: '\2191'; /* ↑ */
  opacity: 1;
}
.portal-table[data-sortable] th[aria-sort="descending"]::after {
  content: '\2193'; /* ↓ */
  opacity: 1;
}
.portal-table[data-sortable] th[aria-sort="ascending"],
.portal-table[data-sortable] th[aria-sort="descending"] {
  color: var(--text);
}

.portal-status {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-pill);
  font-size: var(--text-2xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ---------- Vote tally pill cluster ---------- */
/* Used in /admin/applications instead of "4 yes · 1 discuss · 0 no" prose —
   easier to scan as three coloured numbers. */
.portal-tally {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.portal-tally-pip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.6rem;
  height: 1.6rem;
  padding: 0 0.45rem;
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  border: 1px solid transparent;
}

.portal-tally-yes {
  background: rgba(var(--success-rgb), 0.12);
  color: var(--success);
  border-color: rgba(var(--success-rgb), 0.35);
}

.portal-tally-discuss {
  background: rgba(var(--accent-rgb), 0.12);
  color: var(--accent);
  border-color: rgba(var(--accent-rgb), 0.35);
}

.portal-tally-no {
  background: rgba(var(--danger-rgb), 0.12);
  color: var(--danger);
  border-color: rgba(var(--danger-rgb), 0.35);
}
.portal-status-pending           { background: var(--bg-alt); color: var(--text-muted); border: 1px solid var(--border); }
.portal-status-needs_discussion  { background: rgba(var(--accent-rgb), 0.1); color: var(--accent); border: 1px solid rgba(var(--accent-rgb), 0.35); }
.portal-status-approved          { background: rgba(var(--success-rgb), 0.12); color: var(--success); border: 1px solid rgba(var(--success-rgb), 0.35); }
.portal-status-rejected          { background: rgba(var(--danger-rgb), 0.12); color: var(--danger); border: 1px solid rgba(var(--danger-rgb), 0.35); }

.portal-form-actions-wide {
  justify-content: flex-start;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.portal-btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(var(--danger-rgb), 0.45);
}

.portal-btn-danger:hover {
  border-color: var(--danger-strong);
  background: rgba(var(--danger-rgb), 0.08);
}

/* ---------- Pay page ---------- */
/* Participation-prompt pick-list. */
.portal-nudge-list {
  list-style: none;
  margin: 0.75rem 0 1.25rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.portal-nudge-row {
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid var(--border);
}
.portal-nudge-row:last-child {
  border-bottom: 0;
}
.portal-nudge-row .portal-check {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  cursor: pointer;
}

/* Prominent "pay online" CTA above the manual methods. */
.portal-pay-online {
  margin: 1.5rem 0 0.5rem;
}

.portal-btn-large {
  padding: 0.95rem 1.8rem;
  font-size: var(--text-md);
}

.portal-pay-methods {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}

.portal-pay-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.2rem 1.3rem;
  box-shadow: var(--shadow-1), var(--edge-top);
}

.portal-pay-card h2 {
  margin-bottom: 0.5rem;
}

.portal-pay-handle {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: var(--text-md);
  color: var(--accent);
  margin-bottom: 0.4rem;
}

/* ---------- Admin roster filters ---------- */
.portal-admin-filter-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 1rem;
  align-items: center;
}

.portal-admin-filter-form select,
.portal-admin-search {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.8rem;
  color: var(--text);
  font: inherit;
  font-size: var(--text-sm);
  line-height: 1.4;
  box-sizing: border-box;
  transition: border-color 0.2s var(--ease-out), background-color 0.2s var(--ease-out);
}

.portal-admin-filter-form select:focus,
.portal-admin-search:focus {
  outline: none;
  border-color: var(--accent);
  background-color: var(--bg-alt);
}

.portal-admin-search {
  flex: 1 1 220px;
  min-width: 180px;
}

/* Selects: strip the inconsistent native control so dropdowns match text
   inputs in height, font, and theming, with one shared chevron across every
   portal <select> (form fields and the admin filter bar). This taupe stroke
   is tuned for the dark surface; the light theme overrides it with a darker
   stroke below for contrast. A full control-sizing tokenisation is tracked in
   the design-system refresh issue. */
.portal-field select,
.portal-admin-filter-form select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' stroke='%23a89888' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.8rem center;
  padding-right: 2.2rem;
}

.portal-btn-sm {
  padding: 0.55rem 1rem;
  font-size: var(--text-sm);
}

.portal-check-inline {
  display: inline-flex;
  padding: 0.35rem 0.8rem;
  font-size: var(--text-sm);
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  gap: 0.4rem;
  cursor: pointer;
}

/* Export CSV gets demoted to a quiet trailing link on mobile (where the
   filter form stacks); on desktop it stays inline with the rest of the bar. */
.portal-admin-export {
  margin-left: auto;
}

/* ---------- Admin tables: mobile card reflow (≤720px) ---------- */
/* Each <tr> becomes a stacked card via CSS Grid. <thead> is hidden — names
   are clear from context. data-col attrs (set in the view) drive cell
   placement so changing column order in markup doesn't break the layout. */
@media (max-width: 720px) {

  /* Filter bar: every control goes full-width, button + export demoted to
     their own row at the bottom. */
  .portal-admin-filter-form {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
    align-items: stretch;
  }
  .portal-admin-filter-form select,
  .portal-admin-search,
  .portal-admin-filter-form .portal-check-inline,
  .portal-admin-filter-form .portal-btn {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }
  .portal-admin-filter-form .portal-check-inline {
    justify-content: flex-start;
  }
  .portal-admin-export {
    margin-left: 0;
    text-align: center;
    padding: 0.4rem 0;
  }

  /* Status pills slightly larger so they're tappable + legible at arm's length. */
  .portal-status {
    font-size: var(--text-xs);
    padding: 0.3rem 0.8rem;
  }

  /* Drop the table chrome and reflow as a stack of cards. */
  .portal-table {
    display: block;
    background: transparent;
    border: 0;
    border-radius: 0;
    overflow: visible;
    font-size: var(--text-base);
  }
  .portal-table thead { display: none; }
  .portal-table tbody {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
  }
  .portal-table tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 0.8rem;
    row-gap: 0.3rem;
    padding: 0.9rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    align-items: start;
  }
  .portal-table-rowlinked tbody tr:hover {
    border-color: var(--accent);
  }
  .portal-table td {
    padding: 0;
    border: 0;
    vertical-align: baseline;
  }

  /* Primary line: name spans both cols. The <a> is the tap target — sized
     up to a generous 44px+ row when combined with surrounding padding. */
  .portal-table td[data-col="name"] {
    grid-column: 1;
    grid-row: 1;
    font-size: var(--text-md);
    line-height: 1.35;
    min-width: 0;
  }
  .portal-table td[data-col="name"] a {
    color: var(--text);
    font-weight: 500;
  }

  /* Status pill nestles top-right beside the name. */
  .portal-table td[data-col="status"] {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
  }

  /* Secondary metadata stacks below in muted text. Use ::before to label
     fields whose context isn't obvious without the column header. */
  .portal-table td[data-col="from"],
  .portal-table td[data-col="coming"],
  .portal-table td[data-col="ticket"],
  .portal-table td[data-col="paid"],
  .portal-table td[data-col="sponsor"],
  .portal-table td[data-col="submitted"] {
    grid-column: 1 / -1;
    color: var(--text-muted);
    font-size: var(--text-sm);
  }
  .portal-table td[data-col="from"]::before { content: '📍 '; opacity: 0.7; }
  .portal-table td[data-col="coming"]::before     { content: 'Coming: '; }
  .portal-table td[data-col="ticket"]::before     { content: 'Ticket: '; }
  .portal-table td[data-col="paid"]::before       { content: 'Paid: '; }
  .portal-table td[data-col="sponsor"]::before    { content: 'Sponsor: '; }
  .portal-table td[data-col="submitted"]::before  { content: 'Submitted: '; }

  /* Coming/ticket sit on the same line as a compact pair when both present. */
  .portal-table td[data-col="coming"] { padding-right: 0.5rem; }

  /* Vote tally: own line, full width. */
  .portal-table td[data-col="votes"] {
    grid-column: 1 / -1;
  }

  /* Contact (email + phone): demoted to a small footer line with a hairline
     divider, so the dense address strings don't dominate the card. */
  .portal-table td[data-col="contact"] {
    grid-column: 1 / -1;
    font-size: var(--text-xs);
    color: var(--text-muted);
    padding-top: 0.5rem;
    margin-top: 0.2rem;
    border-top: 1px solid var(--border);
    word-break: break-word;
  }

  /* Drop sticky header behaviour on mobile (no thead anyway). */
  .portal-table th { position: static; }

  /* Photo thumb on the mobile card sits top-left next to the name. */
  .portal-table td.portal-roster-thumb-cell {
    grid-column: 1 / span 2;
    grid-row: 0;
    margin-bottom: 0.4rem;
  }
}

.portal-tag-small {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: var(--text-2xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--bg-alt);
  border: 1px solid var(--border);
  margin-left: 0.4rem;
}

/* ---------- GDPR row ---------- */
.portal-gdpr-row {
  display: flex;
  gap: 0.8rem;
  align-items: center;
  color: var(--text-muted);
  font-size: var(--text-sm);
  padding-top: 0.5rem;
}

.portal-link-btn-danger {
  color: var(--danger) !important;
}

.portal-link-btn-danger:hover {
  color: var(--danger-strong) !important;
}

/* ---------- Sessions ---------- */
.portal-session-list {
  list-style: none;
  padding: 0;
  margin: 1.5rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.portal-session-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.1rem;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-1), var(--edge-top);
}

.portal-session-item.portal-session-current {
  border-color: rgba(var(--accent-rgb), 0.45);
  background: rgba(var(--accent-rgb), 0.04);
}

.portal-session-agent {
  color: var(--text);
  font-weight: 500;
  margin-bottom: 0.2rem;
}

.portal-audit-full li {
  grid-template-columns: 180px 160px 1fr 1fr;
}

.portal-audit-meta {
  grid-column: 1 / -1;
  margin-top: 0.3rem;
}

.portal-audit-meta pre {
  font-size: var(--text-xs);
  background: var(--bg);
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  color: var(--text-muted);
}

.portal-audit-pager {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.5rem;
}

/* Dashboard audit accordion — the recent-activity list is collapsed
   by default on /admin so it doesn't dominate the page; admins click
   to expand. Styled to look like a section heading instead of the
   browser-default disclosure triangle. */
.portal-admin-audit-accordion {
  margin-top: 1rem;
}

.portal-admin-audit-accordion > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  font-family: var(--font-display);
  font-size: var(--text-lg);
  color: var(--text);
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.portal-admin-audit-accordion > summary::-webkit-details-marker {
  display: none;
}

.portal-admin-audit-accordion > summary::before {
  content: "▸";
  font-size: 0.75em;
  color: var(--text-muted);
  transition: transform 0.15s var(--ease-out);
  display: inline-block;
}

.portal-admin-audit-accordion[open] > summary::before {
  transform: rotate(90deg);
}

.portal-admin-audit-accordion > summary .portal-muted {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: normal;
  margin-left: auto;
}

.portal-admin-audit-accordion > .portal-audit-list {
  margin-top: 0.8rem;
}

/* Email-templates list card — simple two-column row (meta on the
   left, edit pill on the right). Distinct from .portal-review-card,
   which has a photo column that squashes the text when omitted. */
.portal-email-template-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1.2rem 1.4rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.2s var(--ease-out), transform 0.2s var(--ease-out);
  box-shadow: var(--shadow-1), var(--edge-top);
}

.portal-email-template-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.portal-email-template-card .portal-email-template-meta {
  min-width: 0;
  flex: 1;
}

.portal-email-template-card .portal-email-template-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  line-height: 1.25;
  color: var(--text);
  margin-bottom: 0.35rem;
}

.portal-email-template-card .portal-email-template-desc {
  font-size: var(--text-sm);
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 0.4rem;
}

.portal-email-template-card .portal-email-template-line {
  font-size: var(--text-xs);
  color: var(--text-muted);
  line-height: 1.6;
}

@media (max-width: 640px) {
  .portal-email-template-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.8rem;
  }
}

/* ---------- Footer ---------- */
.portal-footer {
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.portal-footer-inner {
  max-width: var(--container);
  margin: 0 auto;
  padding: 1.8rem var(--gutter);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.portal-footer-inner a {
  color: var(--text-muted);
}

.portal-footer-inner a:hover {
  color: var(--accent);
}

/* ---------- Theme toggle (inside the burger panel) ---------- */
.portal-theme-form {
  margin: 0;
  /* Sit at the top of the mobile burger column. order:0 keeps it above the
     nav links; on desktop the panel isn't visible anyway so this is moot. */
  order: 0;
}

.portal-theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius-pill);
  padding: 0.5rem 0.9rem;
  font: inherit;
  font-size: var(--text-sm);
  cursor: pointer;
  transition: border-color 0.2s var(--ease-out), color 0.2s var(--ease-out), background 0.2s var(--ease-out);
}

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

.portal-theme-toggle-icon {
  font-size: var(--text-base);
  line-height: 1;
}

/* ---------- Light theme overrides ----------
   Activated by `<html data-theme="light">`, which the server emits when the
   `theme=light` cookie is set. All contrast ratios verified against the
   #f5f0e8 bg: accent 5.43:1 AA, accent-hover 7.65:1 AAA, text 13.29:1 AAA,
   text-muted 6.61:1 AA. Status colours recomputed for the linen bg. */
[data-theme="light"] {
  --bg: #f5f0e8;
  --bg-alt: #ece5d8;
  --surface: #ffffff;
  --border: #d8cdb9;
  --text: #2c2520;
  --text-muted: #5e5346;
  --accent: #7a5d18;
  --accent-hover: #5f4810;
  --accent-rgb: 122, 93, 24;
  --accent-bg-soft: rgba(var(--accent-rgb), 0.10);
  --on-accent: #ffffff;

  --success: #1f7a3e;
  --success-strong: #155a2c;
  --success-rgb: 31, 122, 62;
  --danger: #9a2828;
  --danger-strong: #7a1d1d;
  --danger-rgb: 154, 40, 40;

  /* Solid nav background — no translucent + blur on the lighter palette
     (the gold accent doesn't read well behind a translucent stack). */
  --nav-bg: var(--bg);
}

/* In light mode the nav looks better without the blur halo. */
[data-theme="light"] .portal-nav {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

/* The gold-on-dark primary button needs the accent darker than its hover in
   light mode (we want hover to deepen, not brighten). The base styles use
   `--accent` for background; the hover override below makes hover go to the
   darker `--accent-hover` and brightens the text-on-gold for legibility. */
[data-theme="light"] .portal-btn-primary {
  color: #ffffff;
}
[data-theme="light"] .portal-btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 8px 20px rgba(var(--accent-rgb), 0.25);
}

/* Darker select chevron in light theme — the dark-surface taupe (#a89888) is
   only ~2.8:1 on white, under the 3:1 non-text bar. This stroke (#5e5346, the
   light-theme muted text) clears it comfortably. */
[data-theme="light"] .portal-field select,
[data-theme="light"] .portal-admin-filter-form select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' stroke='%235e5346' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

/* ---------- People directory (/ops/people) ---------- */
/* Photo-led cards: the photo is the point of this page, so it owns the top
   half and the name sits on it. Every row below the photo is a fixed height,
   because a roster is scanned down the columns and ragged card bottoms make
   that harder than it needs to be. */
.portal-people-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(258px, 1fr));
  gap: 1.1rem;
}

.portal-people-search {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin: 0.8rem 0 0.4rem;
}

.portal-people-search .portal-admin-search {
  flex: 1 1 260px;
  min-width: 0;
}

.portal-person-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.2s var(--ease-out), transform 0.2s var(--ease-out), box-shadow 0.2s var(--ease-out);
}

.portal-person-card:hover {
  border-color: var(--accent);
  transform: translateY(-3px);
  box-shadow: 0 10px 24px rgba(var(--accent-rgb), 0.14);
}

/* Someone on playa today gets a warm top edge. The badge on the photo says the
   same thing, but this survives being scanned peripherally. */
.portal-person-card-here {
  border-top: 3px solid var(--accent);
}

/* ---------- the photo half ---------- */

.portal-portrait {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--bg-alt);
}

.portal-portrait-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s var(--ease-out);
}

.portal-person-card:hover .portal-portrait-img {
  transform: scale(1.03);
}

/* No photo is a designed state, not a hole: a warm duotone panel with the
   member's initials, so a card without a photo still reads as a person.
   Its background is defined with the shared tint table below. */

.portal-portrait-initials {
  position: absolute;
  top: 42%;
  left: 50%;
  transform: translate(-50%, -56%);
  font-family: var(--font-display);
  font-style: italic;
  font-size: clamp(2.9rem, 6vw, 4rem);
  letter-spacing: 0.05em;
  color: rgba(255, 245, 226, 0.9);
  text-shadow: 0 2px 18px rgba(20, 10, 2, 0.28);
  user-select: none;
}

/* Tints are defined once, as a hue, in the shared table further down
   (--tint-h). Both the big portrait panel and the small roster circle read
   from it, so the same person is the same colour everywhere. They used to be
   two hand-written lists indexed by the same avatarTint() but with different
   hues, which is why one member could be gold in one place and rust in
   another — and two of the portrait tints (a purple and a teal) sat outside
   the warm palette altogether. */
.portal-portrait-empty {
  background: linear-gradient(
    148deg,
    hsl(var(--tint-h) 48% 42%),
    hsl(var(--tint-h) 58% 19%) 88%
  );
}

/* Fixed dark ink on the scrim, not var(--text): the photo underneath is the
   same in both themes, so a theme-following colour would vanish in light. */
.portal-portrait-scrim {
  position: absolute;
  inset: auto 0 0 0;
  height: 74%;
  background: linear-gradient(180deg, rgba(26, 17, 8, 0) 0%, rgba(26, 17, 8, 0.62) 40%, rgba(26, 17, 8, 0.82) 100%);
  pointer-events: none;
}

.portal-portrait-ident {
  position: absolute;
  left: 0.95rem;
  right: 0.95rem;
  bottom: 0.7rem;
}

.portal-portrait-name {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--text-xl);
  line-height: 1.14;
  color: #fdf8ef;
  text-shadow: 0 1px 10px rgba(20, 12, 4, 0.5);
  overflow-wrap: anywhere;
  /* Two lines of a long playa name, then ellipsis, so the photo half can
     never grow and push the card out of step with its neighbours. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.portal-portrait-name.is-playa {
  font-style: italic;
}

.portal-portrait-sub {
  margin: 0.15rem 0 0;
  font-size: var(--text-2xs);
  line-height: 1.35;
  color: rgba(253, 248, 239, 0.85);
  text-shadow: 0 1px 8px rgba(20, 12, 4, 0.6);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.portal-portrait-badges {
  position: absolute;
  top: 0.6rem;
  left: 0.6rem;
  right: 0.6rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.portal-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  border-radius: var(--radius-pill);
  background: rgba(18, 12, 6, 0.65);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  border: 1px solid rgba(255, 244, 220, 0.24);
  color: #f2ecdf;
  font-size: var(--text-2xs);
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.portal-badge-first {
  padding: 0.3rem;
  color: #b7e9c6;
}

.portal-badge-first svg {
  display: block;
}

/* Pushed right even when the First Teapunk badge is absent. */
.portal-badge-here {
  padding: 0.25rem 0.6rem 0.25rem 0.5rem;
  margin-left: auto;
}

.portal-badge-dot {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-circle);
  background: #6fdd93;
  box-shadow: 0 0 6px 1px rgba(111, 221, 147, 0.85);
}

/* ---------- the fixed-height body ---------- */

.portal-person-body {
  display: flex;
  flex-direction: column;
  padding: 0.8rem 0.95rem 0.85rem;
  flex: 1;
}

.portal-person-presence {
  display: flex;
  flex-direction: column;
  gap: 0.32rem;
}

.portal-daydates {
  display: block;
  height: 1.15rem;
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Half a window ("arrives Aug 30, no departure yet") is a different fact from
   no window at all, so it keeps a normal weight and only the strip ghosts. */
.portal-daydates.is-partial {
  color: var(--text);
}

.portal-daydates.is-pending {
  color: var(--text-muted);
  font-style: italic;
  font-weight: 400;
}

.portal-daysep {
  margin: 0 0.3rem;
  color: var(--text-muted);
  opacity: 0.7;
}

.portal-daylen {
  color: var(--text-muted);
  font-weight: 400;
}

/* ---------- the day strip ----------
   Fixed cell size rather than a fluid one, so every strip on the page is the
   same ruler and run lengths compare directly from card to card.

   Colour carries presence and nothing else. Phase is grouped by whitespace,
   which costs no contrast and survives greyscale and forced-colors. Weekend
   and today markers live in a row *below* the cells, because tinting an empty
   cell on a binary chart makes it read as half filled, and Sat 29 Aug is both
   a weekend and a build day. */
.portal-daystrip-wrap {
  --day-cell: 10px;
  --day-gap: 2px;
  --day-seam: 6px;
  --day-gutter: 8px;
}

.portal-daystrip {
  display: flex;
  gap: var(--day-gap);
  align-items: stretch;
}

.portal-daycell {
  width: var(--day-cell);
  height: 12px;
  flex: none;
  border-radius: var(--radius-hairline);
  border: 1px solid var(--day-line);
  background: transparent;
}

.portal-daycell.is-on {
  background: var(--accent);
  border-color: var(--accent);
}

.portal-daycell-build + .portal-daycell-event,
.portal-daycell-event + .portal-daycell-strike {
  margin-left: var(--day-seam);
}

/* Dates not given is a different fact from "here zero days", so it is ghosted
   and dashed rather than simply empty. */
.portal-daystrip.is-pending .portal-daycell {
  border-style: dashed;
}

/* Always present, chevron or not, so all strips line up down the column. */
.portal-daygutter {
  width: var(--day-gutter);
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  font-size: var(--text-xs);
  font-weight: 700;
  line-height: 1;
}

.portal-daymarks {
  display: flex;
  gap: var(--day-gap);
  height: 5px;
  margin-top: 3px;
}

.portal-daymark {
  width: var(--day-cell);
  flex: none;
  position: relative;
}

.portal-daymark-build + .portal-daymark-event,
.portal-daymark-event + .portal-daymark-strike {
  margin-left: var(--day-seam);
}

.portal-daymark.is-weekend::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 1px;
  height: 2px;
  background: var(--day-mark);
}

.portal-daymark.is-today::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  width: 3px;
  height: 3px;
  margin-left: -1.5px;
  border-radius: var(--radius-circle);
  background: var(--accent);
}

/* High-contrast mode drops custom colours, so restate the one distinction
   that carries the data: solid versus outline. */
@media (forced-colors: active) {
  .portal-daycell {
    border: 1px solid CanvasText;
    background: Canvas;
  }
  .portal-daycell.is-on {
    background: CanvasText;
  }
  .portal-daykey-cell {
    border: 1px solid CanvasText;
  }
  .portal-daykey-sw.is-on {
    background: CanvasText;
  }
  /* HCM forces background-color to Canvas, which would erase every mark. */
  .portal-daymark.is-weekend::after,
  .portal-daymark.is-today::before,
  .portal-daykey-cell.is-weekend::after,
  .portal-daykey-cell.is-today::before,
  .portal-daykey-sw.is-weekend::after,
  .portal-daykey-sw.is-today::after {
    background: CanvasText;
  }
}

/* ---------- dietary + involvement ---------- */

/* Always one line, so the row never changes height. Dietary stays on the card
   for food safety, but a real restriction is flagged and an unrestricted
   answer is left quiet, so meal leads scan for constraints rather than
   reading "Omnivore" thirty times. */
.portal-person-diet {
  margin: 0.72rem 0 0;
  height: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: var(--text-2xs);
  color: var(--text);
  overflow: hidden;
}

/* text-overflow applies to a block box, not to a flex container, so the
   ellipsis has to live on the text itself or a long restriction is chopped
   mid-word with no indication there is more. */
.portal-person-diet-text {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* No opacity: --text-muted alone is 7.5:1 light and 4.63:1 dark; at 0.85 the
   dark theme dropped to 3.41:1. */
.portal-person-diet.is-quiet {
  color: var(--text-muted);
  font-style: italic;
}

.portal-person-diet-flag {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  flex: none;
  padding: 0.1rem 0.4rem;
  border-radius: var(--radius-sm);
  background: rgba(var(--accent-rgb), 0.13);
  border: 1px solid rgba(var(--accent-rgb), 0.3);
  color: var(--accent);
  font-size: var(--text-3xs);
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

/* Meals, shifts and items for everyone, zeros dimmed. Three dim zeros is a
   useful sight on a roster: that is someone who has not signed up for
   anything yet. */
.portal-person-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-top: auto;
  padding-top: 0.65rem;
  border-top: 1px solid var(--border);
}

.portal-person-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}

.portal-person-stat + .portal-person-stat {
  border-left: 1px solid var(--border);
}

.portal-person-stat-n {
  font-family: var(--font-display);
  font-size: var(--text-md);
  line-height: 1.1;
  color: var(--text);
}

.portal-person-stat-l {
  font-size: var(--text-3xs);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* A zero is data the client asked to see, so it stays legible (7.5:1 light,
   4.63:1 dark). The signal is the digit 0, not a fade. */
.portal-person-stat.is-zero .portal-person-stat-n {
  color: var(--text-muted);
}

/* ---------- the day-strip key ----------
   Stated once above the grid and sticky, never repeated on the cards: fourteen
   day letters across thirty-five cards would be 490 glyphs fighting the data.
   Runs at 1.6x the card strip so the letters stay legible; what transfers is
   the 4 / 9 / 1 rhythm, not the pixel size. */
.portal-daykey {
  --key-cell: 16px;
  --key-gap: 3px;
  --key-seam: 9px;
  position: sticky;
  /* Below the sticky nav, not behind it. Pinning to 0 put the key under the
     nav's translucent blur, where it read as a smear. Same offset the sticky
     table head uses; portal.js keeps --portal-nav-h current. */
  top: var(--portal-nav-h, 56px);
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1rem 1.8rem;
  margin: 0 0 1.3rem;
  padding: 0.85rem 1.1rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.portal-daykey-axis {
  flex: none;
}

.portal-daykey-title {
  margin: 0 0 0.45rem;
  font-size: var(--text-3xs);
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.portal-daykey-row {
  display: flex;
  gap: var(--key-gap);
}

.portal-daykey-row > * {
  width: var(--key-cell);
  flex: none;
  text-align: center;
}

/* Seams come from the phase, exactly as the card strips do, so the key can
   never drift out of step with the thing it is a key for. Hard-coding the
   positions here is how a key starts quietly lying about which day is which. */
.portal-daykey-build + .portal-daykey-event,
.portal-daykey-event + .portal-daykey-strike {
  margin-left: var(--key-seam);
}

.portal-daykey-cellwrap {
  font-size: var(--text-3xs);
  line-height: 1.45;
  color: var(--text-muted);
}

.portal-daykey-nums .portal-daykey-cellwrap {
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}

.portal-daykey-dows .portal-daykey-cellwrap {
  text-transform: uppercase;
  font-weight: 600;
}

.portal-daykey-cellwrap.is-weekend {
  color: var(--text);
  font-weight: 700;
}

.portal-daykey-cells {
  margin-top: 2px;
}

.portal-daykey-cell {
  height: 14px;
  border-radius: var(--radius-hairline);
  border: 1px solid var(--day-line);
  background: transparent;
  position: relative;
}

.portal-daykey-cell.is-weekend::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -4px;
  height: 1px;
  background: var(--day-mark);
}

.portal-daykey-cell.is-today::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -7px;
  width: 3px;
  height: 3px;
  margin-left: -1.5px;
  border-radius: var(--radius-circle);
  background: var(--accent);
}

.portal-daykey-phases {
  margin-top: 0.7rem;
}

/* data-span, not an inline style: the CSP forbids style attributes, and the
   phase lengths come from the camp window rather than being hard-coded. */
.portal-daykey-phases > .portal-daykey-phase {
  flex: none;
  padding-top: 0.25rem;
  border-top: 1px solid var(--border);
  font-size: var(--text-3xs);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: center;
  white-space: nowrap;
  /* The rule above the label is what encodes the span, so a one-day phase
     keeps a one-cell rule and lets its label spill either side rather than
     clipping "Strike" down to "Str". */
  overflow: visible;
}

.portal-daykey-phase[data-span="1"]  { width: calc(1 * var(--key-cell)); }
.portal-daykey-phase[data-span="2"]  { width: calc(2 * var(--key-cell) + 1 * var(--key-gap)); }
.portal-daykey-phase[data-span="3"]  { width: calc(3 * var(--key-cell) + 2 * var(--key-gap)); }
.portal-daykey-phase[data-span="4"]  { width: calc(4 * var(--key-cell) + 3 * var(--key-gap)); }
.portal-daykey-phase[data-span="5"]  { width: calc(5 * var(--key-cell) + 4 * var(--key-gap)); }
.portal-daykey-phase[data-span="6"]  { width: calc(6 * var(--key-cell) + 5 * var(--key-gap)); }
.portal-daykey-phase[data-span="7"]  { width: calc(7 * var(--key-cell) + 6 * var(--key-gap)); }
.portal-daykey-phase[data-span="8"]  { width: calc(8 * var(--key-cell) + 7 * var(--key-gap)); }
.portal-daykey-phase[data-span="9"]  { width: calc(9 * var(--key-cell) + 8 * var(--key-gap)); }
.portal-daykey-phase[data-span="10"] { width: calc(10 * var(--key-cell) + 9 * var(--key-gap)); }
.portal-daykey-phase[data-span="11"] { width: calc(11 * var(--key-cell) + 10 * var(--key-gap)); }
.portal-daykey-phase[data-span="12"] { width: calc(12 * var(--key-cell) + 11 * var(--key-gap)); }
.portal-daykey-phase[data-span="13"] { width: calc(13 * var(--key-cell) + 12 * var(--key-gap)); }
.portal-daykey-phase[data-span="14"] { width: calc(14 * var(--key-cell) + 13 * var(--key-gap)); }
.portal-daykey-phase[data-span="15"] { width: calc(15 * var(--key-cell) + 14 * var(--key-gap)); }
.portal-daykey-phase[data-span="16"] { width: calc(16 * var(--key-cell) + 15 * var(--key-gap)); }
.portal-daykey-phase[data-span="17"] { width: calc(17 * var(--key-cell) + 16 * var(--key-gap)); }
.portal-daykey-phase[data-span="18"] { width: calc(18 * var(--key-cell) + 17 * var(--key-gap)); }
.portal-daykey-phase[data-span="19"] { width: calc(19 * var(--key-cell) + 18 * var(--key-gap)); }
.portal-daykey-phase[data-span="20"] { width: calc(20 * var(--key-cell) + 19 * var(--key-gap)); }
.portal-daykey-phase[data-span="21"] { width: calc(21 * var(--key-cell) + 20 * var(--key-gap)); }
.portal-daykey-phase[data-span="22"] { width: calc(22 * var(--key-cell) + 21 * var(--key-gap)); }
.portal-daykey-phase[data-span="23"] { width: calc(23 * var(--key-cell) + 22 * var(--key-gap)); }
.portal-daykey-phase[data-span="24"] { width: calc(24 * var(--key-cell) + 23 * var(--key-gap)); }

.portal-daykey-phase-event {
  border-top-color: rgba(var(--accent-rgb), 0.55);
  color: var(--accent);
}

.portal-daykey-legend {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 1rem;
  margin: 0;
  padding: 0 0 0.15rem;
  font-size: var(--text-2xs);
  color: var(--text-muted);
}

.portal-daykey-legend li {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.portal-daykey-sw {
  width: 12px;
  height: 14px;
  flex: none;
  position: relative;
  border-radius: var(--radius-hairline);
  border: 1px solid var(--day-line);
}

.portal-daykey-sw.is-on {
  background: var(--accent);
  border-color: var(--accent);
}

.portal-daykey-sw.is-weekend::after {
  content: "";
  position: absolute;
  left: -1px;
  right: -1px;
  bottom: -4px;
  height: 1px;
  background: var(--day-mark);
}

.portal-daykey-sw.is-today::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -6px;
  width: 3px;
  height: 3px;
  margin-left: -1.5px;
  border-radius: var(--radius-circle);
  background: var(--accent);
}

.portal-daykey-sw.is-pending {
  border-style: dashed;
}

.portal-daykey-sw.is-chev {
  border: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  font-size: var(--text-sm);
  font-weight: 700;
  line-height: 1;
}

@media (prefers-reduced-motion: reduce) {
  .portal-person-card,
  .portal-portrait-img {
    transition: none;
  }
}

@media (max-width: 720px) {
  .portal-people-grid {
    grid-template-columns: repeat(auto-fill, minmax(100%, 1fr));
    gap: 0.8rem;
  }
  .portal-people-search .portal-admin-search,
  .portal-people-search .portal-btn {
    width: 100%;
  }
  /* The key is tall on a phone and the grid is one card wide, so let it
     scroll away rather than eating a third of the viewport. Shrink the cells
     too: at 16px the axis is 318px, which overflows a 360px screen. */
  .portal-daykey {
    position: static;
    --key-cell: 13px;
    --key-gap: 2px;
    --key-seam: 7px;
  }
  /* Belt and braces for a very narrow phone: scroll the axis, not the page. */
  .portal-daykey-axis {
    max-width: 100%;
    overflow-x: auto;
  }
}

.portal-person-legend {
  font-style: italic;
  opacity: 0.8;
}

/* ---------- Person detail (/ops/people/:id) ----------
   The directory card no longer uses a round avatar, but the detail page still
   does, so these live on rather than being folded into the card styles. */
.portal-person-avatar {
  flex: 0 0 auto;
  width: 58px;
  height: 58px;
  border-radius: var(--radius-circle);
  object-fit: cover;
  background: var(--bg-alt);
  border: 1px solid var(--border);
}

.portal-person-avatar-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: var(--text-lg);
  letter-spacing: 0.02em;
  /* Fixed dark ink, not var(--bg): the tints below are the same in both
     themes, so theme-following text drops to ~2:1 contrast in light mode. */
  color: #241a0e;
}

/* ---------- Shared avatar tint table ----------
   One hue per tint index, consumed by BOTH the small roster circle and the
   large portrait panel, so avatarTint(id) produces the same colour for a
   person wherever they appear. Six hues spread across 8°–58°, which is the
   warm arc the whole palette lives on: ember through terracotta, copper,
   gold, to dry olive. Nothing outside it — the previous portrait list had a
   purple and a teal in it.

   Saturation and lightness are set by the component, not here, because the
   two treatments need very different values: a small circle carries dark ink
   on a light fill, the big panel is a deep duotone behind pale initials.

   These stay identical in both themes on purpose. The panel stands in for a
   photograph, and a photograph doesn't lighten when the UI does — the same
   reasoning as .portal-portrait-scrim above. */
.portal-person-avatar-t0, .portal-portrait-t0 { --tint-h: 36; }
.portal-person-avatar-t1, .portal-portrait-t1 { --tint-h: 18; }
.portal-person-avatar-t2, .portal-portrait-t2 { --tint-h: 8; }
.portal-person-avatar-t3, .portal-portrait-t3 { --tint-h: 45; }
.portal-person-avatar-t4, .portal-portrait-t4 { --tint-h: 27; }
.portal-person-avatar-t5, .portal-portrait-t5 { --tint-h: 50; }

/* Light fill, dark ink — contrast for the initials is handled by
   .portal-person-avatar-empty's fixed #241a0e. */
.portal-person-avatar-empty { background: hsl(var(--tint-h) 38% 60%); }

.portal-person-playa {
  font-size: var(--text-xs);
  line-height: 1.35;
  font-style: italic;
  color: var(--accent);
  overflow-wrap: anywhere;
}

.portal-person-dietary {
  margin: 0;
  font-size: var(--text-xs);
  line-height: 1.4;
  color: var(--text);
  overflow-wrap: anywhere;
}

.portal-person-dietary-none {
  color: var(--text-muted);
}

.portal-person-dietary-flag {
  display: inline-block;
  margin-right: 0.35rem;
  padding: 0.05rem 0.4rem;
  border-radius: var(--radius-sm);
  font-size: var(--text-2xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: rgba(var(--accent-rgb), 0.16);
  color: var(--accent);
  border: 1px solid rgba(var(--accent-rgb), 0.3);
  vertical-align: 0.05em;
}

/* Same avatar treatment, one size up. */
.portal-person-detail-photo .portal-person-avatar {
  width: 96px;
  height: 96px;
}

.portal-person-detail-photo .portal-person-avatar-empty {
  font-size: var(--text-2xl);
}

/* ============================================
   Styles that used to be inline `style=""`
   ============================================
   The CSP has no `style-src 'unsafe-inline'`, which governs style ATTRIBUTES
   as well as <style> blocks — so every one of these declarations was being
   dropped by the browser and had never rendered. Two were doing real work and
   had been silently broken: the email-template preview panel (below) and the
   profile completion bar, which always drew itself full regardless of the
   percentage because the inline width never applied.

   Do not put these back inline. If something here needs a value computed at
   request time, use a native element attribute (see .portal-meter) or a data
   attribute read by portal.js — not a style attribute. */

/* ---------- Email template preview (/admin/emails/:slug) ---------- */
.portal-email-preview-group { margin-top: var(--space-4); }

.portal-email-preview-subject {
  padding: var(--space-2) var(--space-3);
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin: var(--space-1) 0 var(--space-4);
}

/* The rendered email is a separate document: renderMarkdownEmail inline-styles
   everything because mail clients demand it. Those inline styles are stripped
   here by the same CSP as everything else, so the frame restores them as real
   rules — the selectors below deliberately mirror the values in
   src/lib/markdown.ts so what an admin sees is what the applicant receives.
   If the email styling changes there, change it here too. */

/* These values are LITERALS on purpose, and must not be tokenised. They are a
   copy of what renderMarkdownEmail writes inline in src/lib/markdown.ts, and
   the whole point is that an admin sees what the applicant will receive. The
   moment one of these becomes var(--text-lg) it starts tracking the portal's
   scale instead of the email's, and the preview quietly stops being accurate.
   If markdown.ts changes, change these to match — nothing else. */
.portal-email-preview-frame > div {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  max-width: 600px;
  margin: 0;
  padding: 0;
}

/* The email sets no colours, so it takes the reader's own. The preview shows
   it as a light-mode mail app would: white page, dark text, whatever the
   portal's own theme. The padding is the mail app's margin, not part of the
   email. The frame sits inside .portal-review-block, whose paragraph and
   heading rules would otherwise leak in (light text on white in the dark
   theme), so those are reset here explicitly. */
.portal-email-preview-frame {
  margin: var(--space-1) 0 var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-1);
  background: #ffffff;
  color: #1f1f1f;
  padding: 24px;
}

.portal-email-preview-frame p {
  margin: 0 0 16px;
  color: inherit;
  line-height: inherit;
  white-space: normal;
}
.portal-email-preview-frame ul { margin: 0 0 16px 20px; padding: 0; }
.portal-email-preview-frame li { margin: 0 0 4px; }
.portal-email-preview-frame a { color: #9a7422; text-decoration: underline; }
.portal-email-preview-frame p:has(> .email-button) { margin: 24px 0; }
.portal-email-preview-frame .email-button {
  display: inline-block;
  background: #c9a84c;
  color: #0a0908;
  text-decoration: none;
  font-weight: 600;
  padding: 12px 22px;
  border-radius: 6px;
}
.portal-email-preview-frame h1,
.portal-email-preview-frame h2,
.portal-email-preview-frame h3 {
  margin: 24px 0 12px;
  line-height: 1.3;
  font-family: inherit;
  font-weight: 700;
  color: inherit;
}
.portal-email-preview-frame > div > :first-child { margin-top: 0; }
.portal-email-preview-frame h1 { font-size: 24px; }
.portal-email-preview-frame h2 { font-size: 20px; }
.portal-email-preview-frame h3 { font-size: 17px; }

.portal-email-preview-toggle { cursor: pointer; }

.portal-email-preview-text {
  white-space: pre-wrap;
  padding: var(--space-4);
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin: var(--space-2) 0 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: var(--text-sm);
  color: var(--text-muted);
}

/* ---------- Meter ----------
   A native <progress>, so the value arrives as an attribute rather than an
   inline width the CSP would strip. */
.portal-meter {
  appearance: none;
  -webkit-appearance: none;
  display: block;
  width: 100%;
  height: 6px;
  border: 0;
  border-radius: var(--radius-xs);
  overflow: hidden;
  /* Not --bg-alt: on the light page background that's 1.10:1 and the
     empty part of the bar disappears, so a 3/10 reads like a full bar. */
  background: var(--meter-track);
}
.portal-meter::-webkit-progress-bar { background: var(--meter-track); }
.portal-meter::-webkit-progress-value {
  background: var(--accent);
  transition: width 0.4s var(--ease-out);
}
.portal-meter::-moz-progress-bar { background: var(--accent); }

/* ---------- Small layout helpers ---------- */
.portal-stack-top { margin-top: var(--space-4); }
.portal-stack-top-lg { margin-top: var(--space-6); }
.portal-inline-form { display: inline; }
.portal-centred-block { text-align: center; padding: var(--space-7) 0; }

.portal-photo-preview-sm {
  max-width: 160px;
  margin-bottom: var(--space-3);
}

/* A rule above a trailing block — the GDPR row on /me/profile and the
   sign-out-everywhere note on /me/sessions. */
.portal-section-divided {
  margin-top: var(--space-7);
  padding-top: var(--space-6);
  border-top: 1px solid var(--border);
}

/* ============================================
   Focus
   ============================================
   Form fields used to drop the outline and signal focus with a border-colour
   change alone. That is a colour-only cue on a low-contrast pair — hard to
   see at a glance, and invisible to anyone who can't separate those two
   browns. It also meant the portal had two different focus treatments: the
   browser's default ring on links and buttons, and this on inputs.

   One ring for everything now, drawn with outline so it follows the element's
   shape and never affects layout. :focus-visible rather than :focus so a
   mouse click on a button doesn't leave a ring behind — keyboard users get
   it, pointer users don't. */
/* No border-radius here. The outline already follows the element's own
   corners, so setting one would reshape every focused control — an input
   would visibly snap from 6px to 3px the moment you tabbed into it. */
.portal-body :focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Fields keep the accent border and the lift in background, and now get the
   ring as well. The offset is tighter here because an input already has a
   visible boundary for the ring to sit against. */
.portal-field input:focus-visible,
.portal-field select:focus-visible,
.portal-field textarea:focus-visible,
.portal-admin-filter-form select:focus-visible,
.portal-admin-search:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* ---------- Reduced motion ----------
   The portal honoured this in one place and the marketing page not at all.
   Anything that moves is a nicety here — nothing conveys meaning by moving —
   so the safe blanket response is to stop it. Transitions are collapsed to
   1ms rather than 0 so transitionend still fires and nothing waiting on it
   hangs. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- Camp survey ----------
   Phone first: most people open it from an email on a phone. Every answer is
   a tap target of at least 44px, and nothing sits side by side until there is
   room for it. Scales and options are real radios/checkboxes, visually
   hidden, with the label drawn as the button, so keyboard and screen-reader
   users still get a proper radio group. */
.portal-survey-call-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.portal-survey-call-actions .portal-btn {
  margin-top: 0;
  align-self: stretch;
}

.portal-survey-known p + ul {
  margin-top: var(--space-3);
}

.portal-survey-known-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding-left: var(--space-5);
}

.portal-survey-anon {
  border-left: 2px solid var(--accent);
  padding-left: var(--space-3);
}

.portal-survey-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  padding-top: var(--space-6);
  border-top: 1px solid var(--border);
}

.portal-survey-section > .portal-heading-md {
  margin-bottom: 0;
}

.portal-survey-q {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
}

.portal-survey-legend {
  display: block;
  padding: 0;
  margin-bottom: var(--space-3);
  font-size: var(--text-md);
  line-height: 1.4;
  color: var(--text);
}

/* The label inside .portal-field would otherwise pick up the small-caps
   field label treatment. A question is a sentence, not a field name. */
.portal-field > span.portal-survey-legend {
  font-size: var(--text-md);
  letter-spacing: normal;
  text-transform: none;
  color: var(--text);
  margin-bottom: 0;
}

.portal-survey-scale {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: var(--space-2);
}

.portal-survey-pip,
.portal-survey-option {
  position: relative;
  cursor: pointer;
}

.portal-survey-pip span,
.portal-survey-option span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-alt);
  color: var(--text);
  text-align: center;
  transition: border-color 0.2s var(--ease-out), background-color 0.2s var(--ease-out), color 0.2s var(--ease-out);
}

.portal-survey-pip span {
  padding: var(--space-2) 0;
  font-size: var(--text-md);
  font-variant-numeric: tabular-nums;
}

.portal-survey-pip:hover span,
.portal-survey-option:hover span {
  border-color: var(--accent);
}

.portal-survey-pip input:checked + span,
.portal-survey-option input:checked + span {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.portal-survey-option input[type="checkbox"]:checked + span::before {
  content: "✓";
  margin-right: var(--space-2);
}

.portal-survey-pip input:focus-visible + span,
.portal-survey-option input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.portal-survey-ends {
  display: flex;
  justify-content: space-between;
  margin-top: var(--space-2);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text);
}

/* The low end reads quieter than the high end, so the direction of the scale
   is obvious at a glance, not only from the words. */
.portal-survey-ends span:first-child {
  color: var(--text-muted);
}

.portal-survey-ends span:last-child {
  color: var(--accent);
}

.portal-survey-picks {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-2);
}

@media (min-width: 640px) {
  .portal-survey-picks {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.portal-survey-note {
  margin: calc(var(--space-2) * -1) 0 var(--space-3);
  font-size: var(--text-sm);
  color: var(--accent);
}

.portal-survey-key {
  font-size: var(--text-md);
  color: var(--text-muted);
}

.portal-survey-key strong {
  color: var(--text);
  font-weight: 500;
}

.portal-survey-options {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-2);
}

.portal-survey-submit .portal-btn {
  width: 100%;
}

@media (min-width: 640px) {
  .portal-survey-call-actions {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .portal-survey-call-actions .portal-btn {
    align-self: auto;
  }
  .portal-survey-scale-10 {
    grid-template-columns: repeat(10, minmax(0, 1fr));
  }
  .portal-survey-options {
    display: flex;
    flex-wrap: wrap;
  }
  .portal-survey-options-stack {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .portal-survey-submit .portal-btn {
    width: auto;
  }
}

/* Admin results. */
.portal-survey-bars,
.portal-survey-quotes,
.portal-survey-hands {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.portal-survey-bar {
  display: grid;
  grid-template-columns: minmax(0, 7.5rem) minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-3);
}

.portal-survey-bar-label {
  font-size: var(--text-sm);
  line-height: 1.3;
}

.portal-survey-bar-count {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

@media (min-width: 640px) {
  .portal-survey-bar {
    grid-template-columns: minmax(10rem, 16rem) minmax(0, 1fr) 4.5rem;
  }
}

.portal-survey-quote {
  white-space: pre-line;
  border-left: 2px solid rgba(var(--accent-rgb), 0.5);
  padding: var(--space-1) 0 var(--space-1) var(--space-3);
  color: var(--text);
}

.portal-survey-hands .portal-card p {
  color: var(--text);
}

/* ---------- Survey results ----------
   Phone first, like the survey itself: stat tiles two across, theme cards
   one across, and everything else a single column. */
.portal-results-stealth {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4);
  margin-bottom: var(--space-5);
  border: 1px dashed rgba(var(--accent-rgb), 0.6);
  border-radius: var(--radius-md);
  background: rgba(var(--accent-rgb), 0.06);
  font-size: var(--text-sm);
}

.portal-results-stealth-live {
  border-style: solid;
  border-color: rgba(var(--success-rgb), 0.4);
  background: rgba(var(--success-rgb), 0.06);
}

.portal-results-points {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding-left: var(--space-5);
  font-size: var(--text-md);
  line-height: 1.55;
}

.portal-results-action {
  margin-top: var(--space-6);
  padding: var(--space-5);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  background: rgba(var(--accent-rgb), 0.08);
}

.portal-results-action .portal-eyebrow {
  color: var(--accent);
}

/* 2026 photos on the results pages. They come from /images, which is
   public, so the files are named for what's in them, never for the survey.
   Cover and banner are decoration around the numbers, not part of them. */
.portal-results-banner {
  margin: 0 0 var(--space-6);
}

.portal-results-banner img {
  display: block;
  width: 100%;
  object-fit: cover;
}

.portal-results-banner img {
  aspect-ratio: 2 / 1;
  border-radius: var(--radius-md);
}

/* A theme card's photo band bleeds to the card's edges. */
.portal-results-card {
  padding-top: 0;
  overflow: hidden;
}

.portal-results-card-img {
  display: block;
  margin: 0 calc(-1 * var(--space-6)) var(--space-2);
  aspect-ratio: 16 / 9;
  overflow: hidden;
}

.portal-results-card-img img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s var(--ease-out);
}

/* Themes without a photo keep the band, so a row of cards still lines up. */
.portal-results-card-blank {
  background: linear-gradient(160deg, var(--sky-soft), var(--dust));
}

a.portal-results-card:hover .portal-results-card-img img {
  transform: scale(1.04);
}

.portal-results-action p {
  margin: var(--space-2) 0 0;
  font-size: var(--text-md);
}

.portal-results-nav {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  margin-top: var(--space-6);
}

@media (min-width: 640px) {
  .portal-results-stealth {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
  .portal-results-banner img {
    aspect-ratio: 3 / 1;
  }
}

/* ---------- Survey results: the report ----------
   The results pages borrow the homepage's sunset accent so the charts, the
   headings and the links read as one designed report rather than the portal
   with graphs added. Scoped to .results, which wraps both results views. */
.results {
  --accent: #b0401a;
  --accent-hover: #8f3312;
  --accent-rgb: 176, 64, 26;
}

[data-theme="dark"] .results,
:root:not([data-theme="light"]) .results {
  --accent: #ee8a57;
  --accent-hover: #f6b48e;
  --accent-rgb: 238, 138, 87;
}

/* Chart colours. o1 is the strongest orange and o4 the lightest (in dark
   mode, strongest = brightest), b1/b2 strong and light blue, n the neutral
   middle, g1/g2 light and strong grey. Both orange ramps and both blue arms
   pass the dataviz validator (--ordinal) against the card surface in their
   mode. n and g1 sit below 3:1 on purpose (a middle that recedes); every
   chart has labels and a table, which the relief rule asks for. */
:root {
  --viz-o1: #f6b48e;
  --viz-o2: #ee8a57;
  --viz-o3: #d0612f;
  --viz-o4: #a2461f;
  --viz-b1: #a9c0e0;
  --viz-b2: #6f8db8;
  --viz-n: #5d5751;
  --viz-g1: #4a443f;
  --viz-g2: #9d948a;
}

[data-theme="light"] {
  --viz-o1: #7a2e10;
  --viz-o2: #b5461a;
  --viz-o3: #e2703f;
  --viz-o4: #f0a074;
  --viz-b1: #2f4a73;
  --viz-b2: #7f9cc4;
  --viz-n: #c9c2b9;
  --viz-g1: #d9d3cb;
  --viz-g2: #6f685f;
}

.viz-o1 { fill: var(--viz-o1); background-color: var(--viz-o1); }
.viz-o2 { fill: var(--viz-o2); background-color: var(--viz-o2); }
.viz-o3 { fill: var(--viz-o3); background-color: var(--viz-o3); }
.viz-o4 { fill: var(--viz-o4); background-color: var(--viz-o4); }
.viz-b1 { fill: var(--viz-b1); background-color: var(--viz-b1); }
.viz-b2 { fill: var(--viz-b2); background-color: var(--viz-b2); }
.viz-n { fill: var(--viz-n); background-color: var(--viz-n); }
.viz-g1 { fill: var(--viz-g1); background-color: var(--viz-g1); }
.viz-g2 { fill: var(--viz-g2); background-color: var(--viz-g2); }

/* Text set inside a segment: white or ink, whichever clears contrast on
   that fill in that mode (all >= 4.5:1). */
.viz-in-o1, .viz-in-o2, .viz-in-b1, .viz-in-g2 { color: #ffffff; }
.viz-in-o3, .viz-in-o4, .viz-in-b2, .viz-in-n, .viz-in-g1 { color: #2c2520; }
:root:not([data-theme="light"]) .viz-in-o1,
:root:not([data-theme="light"]) .viz-in-o2,
:root:not([data-theme="light"]) .viz-in-o3,
:root:not([data-theme="light"]) .viz-in-b1,
:root:not([data-theme="light"]) .viz-in-b2,
:root:not([data-theme="light"]) .viz-in-g2 { color: #171412; }
:root:not([data-theme="light"]) .viz-in-o4,
:root:not([data-theme="light"]) .viz-in-n,
:root:not([data-theme="light"]) .viz-in-g1 { color: #ede6de; }

.viz-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* The video */
.results-video {
  position: relative;
  margin: 0 0 var(--space-6);
}

.results-video video {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: var(--radius-lg);
  background: var(--bg-alt);
  box-shadow: var(--shadow-2), var(--edge-top);
}

.results-video figcaption {
  margin-top: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.results-video-toggle {
  position: absolute;
  right: var(--space-3);
  bottom: calc(var(--space-3) + 1.9rem);
  min-height: 36px;
  padding: 0 var(--space-4);
  border: 0;
  border-radius: var(--radius-pill);
  background: rgb(23 20 18 / 0.72);
  color: #ffffff;
  font: inherit;
  font-size: var(--text-xs);
  font-weight: 600;
  cursor: pointer;
}

.results-video-toggle:hover {
  background: rgb(23 20 18 / 0.88);
}

/* Panels */
.results-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-1), var(--edge-top);
  padding: var(--space-5);
  margin-bottom: var(--space-4);
}

.results-panel-wide {
  margin-bottom: var(--space-6);
}

.results-headline {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.results-headline .results-panel {
  margin-bottom: 0;
}

/* Charts */
.viz {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.viz-caption {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
}

.viz-svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.viz-hero {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  margin: 0;
}

/* The one hero figure: same sans as the body, proportional figures. */
.viz-hero-num {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: clamp(3rem, 2rem + 4vw, 4.5rem);
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--text);
}

.viz-hero-of {
  font-size: var(--text-md);
  color: var(--text-muted);
}

.viz-tick {
  fill: var(--text-muted);
  font-size: var(--text-2xs);
  font-variant-numeric: tabular-nums;
}

.viz-value {
  fill: var(--text);
  font-size: var(--text-xs);
  font-weight: 600;
}

.viz-axis,
.viz-grid {
  stroke: var(--border);
  stroke-width: 1;
}

.viz-seg {
  stroke: var(--surface);
  stroke-width: 2px;
}

.viz-zero {
  stroke: var(--text);
  stroke-width: 1px;
}

.viz-hit path,
.viz-hit .viz-dot,
.viz-seg {
  transition: opacity 0.15s var(--ease-out);
}

.viz-hit:hover path,
.viz-hit:hover .viz-dot,
.viz-seg:hover {
  opacity: 0.78;
}

.viz-note {
  margin: 0;
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.viz-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.viz-legend li {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.viz-legend strong {
  color: var(--text);
  font-weight: 600;
}

.viz-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: var(--radius-xs);
  flex: none;
}

/* A 100% bar: an SVG that stretches to the width, with labels over it in
   HTML so the text doesn't stretch with it. 22px tall (the guidance caps
   bars at 24). */
.viz-bar {
  position: relative;
}

.viz-row {
  display: block;
  width: 100%;
  height: 22px;
  overflow: visible;
}

.viz-row-thin {
  height: 14px;
}

.viz-row-labels {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.viz-in {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: var(--text-2xs);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.viz-at-5 { left: 5%; }
.viz-at-10 { left: 10%; }
.viz-at-15 { left: 15%; }
.viz-at-20 { left: 20%; }
.viz-at-25 { left: 25%; }
.viz-at-30 { left: 30%; }
.viz-at-35 { left: 35%; }
.viz-at-40 { left: 40%; }
.viz-at-45 { left: 45%; }
.viz-at-50 { left: 50%; }
.viz-at-55 { left: 55%; }
.viz-at-60 { left: 60%; }
.viz-at-65 { left: 65%; }
.viz-at-70 { left: 70%; }
.viz-at-75 { left: 75%; }
.viz-at-80 { left: 80%; }
.viz-at-85 { left: 85%; }
.viz-at-90 { left: 90%; }
.viz-at-95 { left: 95%; }

/* Plain bars */
.viz-bar-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin: 0;
  padding: 0;
  list-style: none;
}

.viz-bar-list li {
  display: grid;
  grid-template-columns: 1fr 3.5rem;
  grid-template-areas:
    "label label"
    "bar value";
  gap: var(--space-1) var(--space-3);
  align-items: center;
}

.viz-bar-label {
  grid-area: label;
  font-size: var(--text-sm);
}

.viz-bar-list .viz-row {
  grid-area: bar;
}

.viz-bar-value {
  grid-area: value;
  font-size: var(--text-sm);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* Line. Drawn in a 560-unit viewBox; past ~720px wide its text would be
   scaled up past the type scale, so it stops growing there. */
.viz-line .viz-svg {
  max-width: 720px;
}

/* Line */
.viz-line-path {
  fill: none;
  stroke: var(--viz-o2);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.viz-area {
  fill: var(--viz-o2);
  opacity: 0.1;
}

.viz-dot {
  fill: var(--viz-o2);
  stroke: var(--surface);
  stroke-width: 2;
}

/* Table view */
.viz-table summary {
  cursor: pointer;
  font-size: var(--text-sm);
  color: var(--accent);
  width: fit-content;
}

.viz-table table {
  margin-top: var(--space-3);
  border-collapse: collapse;
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
}

.viz-table th,
.viz-table td {
  padding: var(--space-1) var(--space-4) var(--space-1) 0;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.viz-table thead th {
  color: var(--text-muted);
  font-weight: 600;
}

@media (min-width: 720px) {
  .results-headline {
    grid-template-columns: 1.25fr 1fr 0.85fr;
  }

  .viz-bar-list li {
    grid-template-columns: minmax(9rem, 16rem) 1fr 3.5rem;
    grid-template-areas: "label bar value";
  }
}

/* Who's up for what: one panel per area, names as soft chips. */
.results-whos-up-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: var(--space-4);
}

.results-whos-up-area {
  margin-bottom: 0;
}

.results-whos-up-title {
  font-size: var(--text-md);
  font-weight: 600;
  margin: 0 0 var(--space-3);
}

.results-whos-up-names {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.results-whos-up-names li {
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-pill);
  background: rgba(var(--accent-rgb), 0.1);
  color: var(--text);
  font-size: var(--text-sm);
}

/* Plain-English lead under a chart title: the count that carries the
   message ("24 of 28 gave it a 9 or a 10"). */
.viz-lead {
  margin: 0;
  font-size: var(--text-md);
  color: var(--text);
  line-height: 1.45;
}

.viz-lead strong {
  font-weight: 700;
}

/* One square per person. */
.viz-waffle {
  max-width: 520px;
}

/* Ranked ratings: label, big average, bar, "N of M Brilliant". */
.viz-rating-rows {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin: 0;
  padding: 0;
  list-style: none;
}

.viz-rating-row {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "label mean"
    "bar top";
  gap: var(--space-1) var(--space-3);
  align-items: center;
}

.viz-rating-label {
  grid-area: label;
  font-size: var(--text-sm);
}

.viz-rating-mean {
  grid-area: mean;
  font-size: var(--text-xl);
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.viz-rating-bar {
  grid-area: bar;
}

.viz-rating-bar .viz-row {
  height: 12px;
}

.viz-rating-top {
  grid-area: top;
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

/* Headline strip extras */
.results-big-claim {
  margin: 0 0 var(--space-2);
  font-family: var(--font-body);
  font-size: var(--text-xl);
  font-weight: 600;
  line-height: 1.25;
  color: var(--text);
}

.results-turnout {
  margin: calc(-1 * var(--space-2)) 0 var(--space-5);
}

/* What we got just right */
.results-consensus {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: var(--space-4);
  margin: 0;
  padding: 0;
  list-style: none;
}

.results-consensus li {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.results-consensus-num {
  font-size: var(--text-2xl);
  font-weight: 600;
  line-height: 1.1;
  color: var(--text);
}

.results-consensus-of {
  font-size: var(--text-md);
  font-weight: 400;
  color: var(--text-muted);
}

/* What's next: neutral, not alarm. Each line links to its theme. */
.results-next {
  background: var(--bg-alt);
}

.results-next-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin: 0;
  padding-left: var(--space-5);
  font-size: var(--text-md);
}

.results-next-list a {
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: rgba(var(--accent-rgb), 0.5);
  text-underline-offset: 0.2em;
}

.results-next-list a:hover {
  text-decoration-color: var(--accent);
}

@media (min-width: 720px) {
  .viz-rating-row {
    grid-template-columns: minmax(9rem, 15rem) 3rem 1fr 7.5rem;
    grid-template-areas: "label mean bar top";
  }
}

/* The leads' "email the camp" panel sits under the publish banner. */
.results-email-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
}

.results-email-actions form {
  margin: 0;
}
